PHP Class WikiFile, Wikimate

All properties pertain to the current revision of the file.
Author: Robert McLeod & Frans P. de Vries
Afficher le fichier Open project: hamstar/Wikimate Class Usage Examples

Protected Properties

Свойство Type Description
$edittoken
$error
$exists
$filename
$history
$info
$invalid
$wikimate

Méthodes publiques

Méthode Description
__construct ( string $filename, Wikimate $wikimate ) Constructs a WikiFile object from the filename given and associate with the passed Wikimate object.
__destruct ( ) : Forget all object properties.
delete ( string $reason = null, string $archivename = null ) : boolean Delete the file, or only an older revision of it.
destroy ( ) Alias of self::__destruct().
downloadData ( ) : mixed Downloads and returns the current file's contents, or null if an error occurs.
downloadFile ( string $path ) : boolean Downloads the current file's contents and writes it to the given path.
exists ( ) : boolean Returns the file existence status.
getArchivename ( mixed $revision ) : mixed Returns the archive name of the specified file revision.
getAspectRatio ( ) : float Returns the aspect ratio of this image, or 0 if file is not an image (and thus has no dimensions).
getBitDepth ( ) : integer Returns the bit depth of this file.
getCanonicalTitle ( ) : string Returns the canonical title of this file.
getComment ( ) : string Returns the edit comment of this file.
getCommonMetadata ( ) : array Returns the common metadata of this file.
getDescriptionUrl ( ) : string Returns the description URL of this file.
getError ( ) : mixed Returns the latest error if there is one.
getExtendedMetadata ( ) : array Returns the extended metadata of this file.
getFilename ( ) : string Returns the name of this file.
getHeight ( ) : integer Returns the height of this file.
getHistory ( boolean $refresh = false, integer $limit = null, string $startts = null, string $endts = null ) : mixed Returns the revision history of this file with all properties.
getInfo ( boolean $refresh = false, array $history = null ) : mixed Gets the information of the file. If refresh is true, then this method will query the wiki API again for the file details.
getMediaType ( ) : string Returns the media type of this file.
getMetadata ( ) : array Returns the Exif metadata of this file.
getMime ( ) : string Returns the MIME type of this file.
getParsedComment ( ) : string Returns the parsed edit comment of this file.
getRevision ( mixed $revision ) : mixed Returns the properties of the specified file revision.
getSha1 ( ) : string Returns the SHA-1 hash of this file.
getSize ( ) : integer Returns the size of this file.
getThumbMime ( ) : string Returns the MIME type of this file's thumbnail, or null if property not available.
getTimestamp ( ) : string Returns the timestamp of this file.
getUrl ( ) : string Returns the URL of this file.
getUser ( ) : string Returns the user who uploaded this file.
getUserId ( ) : integer Returns the ID of the user who uploaded this file.
getWidth ( ) : integer Returns the width of this file.
uploadData ( string $data, string $comment, string $text = null, boolean $overwrite = false ) : boolean Uploads the given contents to the current file.
uploadFile ( string $path, string $comment, string $text = null, boolean $overwrite = false ) : boolean Reads contents from the given path and uploads it to the current file.
uploadFromUrl ( string $url, string $comment, string $text = null, boolean $overwrite = false ) : boolean Uploads file contents from the given URL to the current file.

Private Methods

Méthode Description
uploadCommon ( array $params, string $comment, string $text = null, boolean $overwrite = false ) : boolean Uploads to the current file using the given parameters.

Method Details

__construct() public méthode

Constructs a WikiFile object from the filename given and associate with the passed Wikimate object.
public __construct ( string $filename, Wikimate $wikimate )
$filename string Name of the wiki file
$wikimate Wikimate Wikimate object

__destruct() public méthode

Forget all object properties.
public __destruct ( ) :
Résultat

delete() public méthode

Delete the file, or only an older revision of it.
public delete ( string $reason = null, string $archivename = null ) : boolean
$reason string Reason for the deletion
$archivename string The archive name of the older revision
Résultat boolean True if file (revision) was deleted successfully

destroy() public méthode

Alias of self::__destruct().
public destroy ( )

downloadData() public méthode

Downloads and returns the current file's contents, or null if an error occurs.
public downloadData ( ) : mixed
Résultat mixed Contents (string), or null if error

downloadFile() public méthode

Downloads the current file's contents and writes it to the given path.
public downloadFile ( string $path ) : boolean
$path string The file path to write to
Résultat boolean True if path was written successfully

exists() public méthode

Returns the file existence status.
public exists ( ) : boolean
Résultat boolean True if file exists

getArchivename() public méthode

Revision can be the following: - revision timestamp (string, e.g. "2001-01-15T14:56:00Z") - revision index (int, e.g. 3) The most recent revision has index 0, and it increments towards older revisions. A timestamp must be in ISO 8601 format.
public getArchivename ( mixed $revision ) : mixed
$revision mixed The index or timestamp of the revision
Résultat mixed The archive name (string), or null if not found

getAspectRatio() public méthode

Returns the aspect ratio of this image, or 0 if file is not an image (and thus has no dimensions).
public getAspectRatio ( ) : float
Résultat float The aspect ratio of this image, or 0 if no dimensions

getBitDepth() public méthode

Returns the bit depth of this file.
public getBitDepth ( ) : integer
Résultat integer The bit depth of this file

getCanonicalTitle() public méthode

Returns the canonical title of this file.
public getCanonicalTitle ( ) : string
Résultat string The canonical title of this file

getComment() public méthode

Returns the edit comment of this file.
public getComment ( ) : string
Résultat string The edit comment of this file

getCommonMetadata() public méthode

Returns the common metadata of this file.
public getCommonMetadata ( ) : array
Résultat array The common metadata of this file

getDescriptionUrl() public méthode

Returns the description URL of this file.
public getDescriptionUrl ( ) : string
Résultat string The description URL of this file

getError() public méthode

Returns the latest error if there is one.
public getError ( ) : mixed
Résultat mixed The error array, or null if no error

getExtendedMetadata() public méthode

Returns the extended metadata of this file.
public getExtendedMetadata ( ) : array
Résultat array The extended metadata of this file

getFilename() public méthode

Returns the name of this file.
public getFilename ( ) : string
Résultat string The name of this file

getHeight() public méthode

Returns the height of this file.
public getHeight ( ) : integer
Résultat integer The height of this file

getHistory() public méthode

The initial history at object creation contains only the current revision of the file. To obtain more revisions, set $refresh to true and also optionally set $limit and the timestamps. The maximum limit is 500 for user accounts and 5000 for bot accounts. Timestamps can be in several formats as described here: https://www.mediawiki.org/w/api.php?action=help&modules=main#main.2Fdatatypes
public getHistory ( boolean $refresh = false, integer $limit = null, string $startts = null, string $endts = null ) : mixed
$refresh boolean True to query the wiki API again
$limit integer The number of file revisions to return (the maximum number by default)
$startts string The start timestamp of the listing (optional)
$endts string The end timestamp of the listing (optional)
Résultat mixed The array of selected file revisions, or null if error

getInfo() public méthode

Gets the information of the file. If refresh is true, then this method will query the wiki API again for the file details.
public getInfo ( boolean $refresh = false, array $history = null ) : mixed
$refresh boolean True to query the wiki API again
$history array An optional array of revision history parameters
Résultat mixed The info of the file (array), or null if error

getMediaType() public méthode

Returns the media type of this file.
public getMediaType ( ) : string
Résultat string The media type of this file

getMetadata() public méthode

Returns the Exif metadata of this file.
public getMetadata ( ) : array
Résultat array The metadata of this file

getMime() public méthode

Returns the MIME type of this file.
public getMime ( ) : string
Résultat string The MIME type of this file

getParsedComment() public méthode

Returns the parsed edit comment of this file.
public getParsedComment ( ) : string
Résultat string The parsed edit comment of this file

getRevision() public méthode

Revision can be the following: - revision timestamp (string, e.g. "2001-01-15T14:56:00Z") - revision index (int, e.g. 3) The most recent revision has index 0, and it increments towards older revisions. A timestamp must be in ISO 8601 format.
public getRevision ( mixed $revision ) : mixed
$revision mixed The index or timestamp of the revision
Résultat mixed The properties (array), or null if not found

getSha1() public méthode

Returns the SHA-1 hash of this file.
public getSha1 ( ) : string
Résultat string The SHA-1 hash of this file

getSize() public méthode

Returns the size of this file.
public getSize ( ) : integer
Résultat integer The size of this file

getThumbMime() public méthode

Returns the MIME type of this file's thumbnail, or null if property not available.
public getThumbMime ( ) : string
Résultat string The MIME type of this file's thumbnail, or null if unavailable

getTimestamp() public méthode

Returns the timestamp of this file.
public getTimestamp ( ) : string
Résultat string The timestamp of this file

getUrl() public méthode

Returns the URL of this file.
public getUrl ( ) : string
Résultat string The URL of this file

getUser() public méthode

Returns the user who uploaded this file.
public getUser ( ) : string
Résultat string The user of this file

getUserId() public méthode

Returns the ID of the user who uploaded this file.
public getUserId ( ) : integer
Résultat integer The user ID of this file

getWidth() public méthode

Returns the width of this file.
public getWidth ( ) : integer
Résultat integer The width of this file

uploadData() public méthode

$text is only used for the page contents of a new file, not an existing one (update that via WikiPage::setText()). If no $text is specified, $comment will be used as new page text.
public uploadData ( string $data, string $comment, string $text = null, boolean $overwrite = false ) : boolean
$data string The data to upload
$comment string Upload comment for the file
$text string The article text for the file page
$overwrite boolean True to overwrite existing file
Résultat boolean True if uploading was successful

uploadFile() public méthode

$text is only used for the page contents of a new file, not an existing one (update that via WikiPage::setText()). If no $text is specified, $comment will be used as new page text.
public uploadFile ( string $path, string $comment, string $text = null, boolean $overwrite = false ) : boolean
$path string The file path to upload
$comment string Upload comment for the file
$text string The article text for the file page
$overwrite boolean True to overwrite existing file
Résultat boolean True if uploading was successful

uploadFromUrl() public méthode

$text is only used for the page contents of a new file, not an existing one (update that via WikiPage::setText()). If no $text is specified, $comment will be used as new page text.
public uploadFromUrl ( string $url, string $comment, string $text = null, boolean $overwrite = false ) : boolean
$url string The URL from which to upload
$comment string Upload comment for the file
$text string The article text for the file page
$overwrite boolean True to overwrite existing file
Résultat boolean True if uploading was successful

Property Details

$edittoken protected_oe property

protected $edittoken

$error protected_oe property

protected $error

$exists protected_oe property

protected $exists

$filename protected_oe property

protected $filename

$history protected_oe property

protected $history

$info protected_oe property

protected $info

$invalid protected_oe property

protected $invalid

$wikimate protected_oe property

protected $wikimate