PHP Class WikiFile, Wikimate

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

Protected Properties

Property Type Description
$edittoken
$error
$exists
$filename
$history
$info
$invalid
$wikimate

Public Methods

Method 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

Method 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 method

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 method

Forget all object properties.
public __destruct ( ) :
return

delete() public method

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
return boolean True if file (revision) was deleted successfully

destroy() public method

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

downloadData() public method

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

downloadFile() public method

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
return boolean True if path was written successfully

exists() public method

Returns the file existence status.
public exists ( ) : boolean
return boolean True if file exists

getArchivename() public method

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
return mixed The archive name (string), or null if not found

getAspectRatio() public method

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

getBitDepth() public method

Returns the bit depth of this file.
public getBitDepth ( ) : integer
return integer The bit depth of this file

getCanonicalTitle() public method

Returns the canonical title of this file.
public getCanonicalTitle ( ) : string
return string The canonical title of this file

getComment() public method

Returns the edit comment of this file.
public getComment ( ) : string
return string The edit comment of this file

getCommonMetadata() public method

Returns the common metadata of this file.
public getCommonMetadata ( ) : array
return array The common metadata of this file

getDescriptionUrl() public method

Returns the description URL of this file.
public getDescriptionUrl ( ) : string
return string The description URL of this file

getError() public method

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

getExtendedMetadata() public method

Returns the extended metadata of this file.
public getExtendedMetadata ( ) : array
return array The extended metadata of this file

getFilename() public method

Returns the name of this file.
public getFilename ( ) : string
return string The name of this file

getHeight() public method

Returns the height of this file.
public getHeight ( ) : integer
return integer The height of this file

getHistory() public method

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)
return mixed The array of selected file revisions, or null if error

getInfo() public method

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
return mixed The info of the file (array), or null if error

getMediaType() public method

Returns the media type of this file.
public getMediaType ( ) : string
return string The media type of this file

getMetadata() public method

Returns the Exif metadata of this file.
public getMetadata ( ) : array
return array The metadata of this file

getMime() public method

Returns the MIME type of this file.
public getMime ( ) : string
return string The MIME type of this file

getParsedComment() public method

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

getRevision() public method

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
return mixed The properties (array), or null if not found

getSha1() public method

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

getSize() public method

Returns the size of this file.
public getSize ( ) : integer
return integer The size of this file

getThumbMime() public method

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

getTimestamp() public method

Returns the timestamp of this file.
public getTimestamp ( ) : string
return string The timestamp of this file

getUrl() public method

Returns the URL of this file.
public getUrl ( ) : string
return string The URL of this file

getUser() public method

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

getUserId() public method

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

getWidth() public method

Returns the width of this file.
public getWidth ( ) : integer
return integer The width of this file

uploadData() public method

$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
return boolean True if uploading was successful

uploadFile() public method

$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
return boolean True if uploading was successful

uploadFromUrl() public method

$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
return 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