$url
$url :
This class is intended to do the license check/pass.
__construct( $url, $flickr_licenses_blacklist, $ipernity_licenses_blacklist, $picasa_licenses_blacklist, $flickr_api_key = null, $ipernity_api_key = null) : void
This is the constructor
$url | The Project URL (forwarded to the parent class) |
|
$flickr_licenses_blacklist | The list of Flickr licenses ID not allowed at Wiki |
|
$ipernity_licenses_blacklist | The list of Ipernity licenses ID not allowed at Wiki |
|
$picasa_licenses_blacklist | The list of Picasa licenses ID not allowed at Wiki |
|
$flickr_api_key | The Flckr API key |
|
$ipernity_api_key | The Ipernity API key |
query( $query, $post = null, $repeat = null, $url = null) : mixed
Sends a query to the API.
$query | The query string. |
|
$post | POST data if its a post request (optional). |
|
$repeat | How many times the request will be repeated. |
|
$url | The URL where we want to work (for external services API). |
The response from server (API result).
getpage( $page, $revid = null, $detectEditConflict = false) : string
Gets the content of a page. Returns false on error.
Use getPageContents() as alternative to get the page in multiple formats
$page | The wikipedia page to fetch. |
|
$revid | The revision id to fetch (optional). |
|
$detectEditConflict |
The wikitext for the given page.
categorymembers( $category, $limit = 10, $continue = null, $subcat = false) : array
Returns an array with all the members of $category
$category | The category to use. |
|
$limit | The maximum members returned (10 by default) |
|
$continue | The parameters to continue previous query |
|
$subcat | (bool) Go into sub categories? |
The category ID.
nobots( $page, $user = null, $text = null) : boolean
Check if we're allowed to edit $page.
See http://en.wikipedia.org/wiki/Template:Bots for more info.
$page | The page we want to edit. |
|
$user | The bot's username. |
|
$text |
edit( $page, $data, $summary = '', $minor = false, $bot = true, $section = null, $detectEC = false, $maxlag = '') : array
Edits a page.
$page | Page name to edit. |
|
$data | Data to post to page. |
|
$summary | Edit summary to use. |
|
$minor | Whether or not to mark edit as minor. (Default false) |
|
$bot | Whether or not to mark edit as a bot edit. (Default true) |
|
$section | ||
$detectEC | ||
$maxlag |
The API result
getfilelocation( $page) : string
BMcN 2012-09-16 Retrieve a media file's actual location.
$page | The "File:" page on the wiki which the URL of is desired. |
The URL pointing directly to the media file (Eg http://upload.mediawiki.org/wikipedia/en/1/1/Example.jpg)
replacestring( $page, $string, $newstring, $regex = false) : string
Replace a string
$page | The page we're working with. |
|
$string | The string that you want to replace. (it can be a string or an array |
|
$newstring | The string that will replace the present string. (same as above) |
|
$regex | If $string will be considered as a regular expression |
The new text of page
getPageContents( $page, $props = null) : array
Get the contents from the Wiki page in several formats, using the MediaWiki API (cached)
$page | The page that we're working |
|
$props | The properties that we want to obtain from the query (string or array) |
The contents as array
getThumbURL( $page, $width = null, $height = null) : string
Get the URL of the thumbnail of a File, best fit to width and height (cached)
$page | The page in File: namespace that we want to get the URL |
|
$width | The desired width |
|
$height | The desired height |
The URL as string
getTemplates( $content, $tags = null) : array
Get the template tags from the given page, with its parameters (everything between {{}})
$content | The contents (wiki markup) that we're working with |
|
$tags | The specific template tags what we want to match, as string or array |
The desired template tags
getExternalInfo( $url_g) : array
Get information about external sources from an URL. URL is parsed using regex, the relevant components are extracted from the first valid URL, and then the information is obtained using the external services API.
$url_g | The URL to be parsed, either string or array |
An array with the following elements:
bestFit( $haystack, $needle, $use_key = false) : string
Get the closest (and not greater) number present in an array against an arbitrary number, specifically, the thumbnail sizes available, extracted from an external service API query.
Credits to "Tim Cooper" at Stack Overflow: http://stackoverflow.com/users/142162/tim-cooper
$haystack | The arbitrary number where find them |
|
$needle | The array with the (integer) values to get the closest one |
|
$use_key | To return the array key instead of its value |
The closest (and not greater) value or its key
getPhotoID( $url, $where = null) : string
Extract the desired parameter from an URL (mainly for the Photo ID).
URL components are extracted using parse_url() with either PHP_URL_PATH (for services using URL rewrite) or PHP_URL_QUERY (for services that doesn't support it and receives the ID as a GET parameter). Photo ID from Flickr and Ipernity are fuond usually at the fourth position ($id[3]).
$url | The URL to be parsed |
|
$where | The desired position or parameter to extract the ID If integer, the position of the array given with explode() If string, the name of the parameter in the URI |
The numeric ID
hexColor( $color, $bg = false) : string
Get a valid colour in hexadecimal notation (for css) and return default values if them are not valid
$color | The colour in hexadecimal notation (eg ABF or ACDCEF) |
|
$bg | If the colour is intended for background or foreground |
The valid colour in hexadecimal nottaion, or '000' for foreground and 'fff' for background
getIpernityLicense( $id) : string
Match the Ipernity license ID with the list of available licenses.
Unlike Flickr, the licenses are not available through the API and should be stablished here statically.
$id | The License ID, obtained from getIpernityInfo() |
The license text
getIpernityThumbURL( $thumbs, $max = null) : string
Extract the Thumbnail URL from an array of thumbnails, obtained with getIpernityInfo(), and find the best size with bestFit().
$thumbs | The Array containing the Thumbs element |
|
$max | The maximum desired height |
The desired URL of the thumbnail
getPicasaInformation( $user, $album, $photoid) : array
Get information about a file at Picasa, using the ATOM feed retreived as JSON (cached)
$user | The Username of the owner (either numeric or string) |
|
$album | The Album (either numeric or string) |
|
$photoid | The photo ID (as numeric) |
The desired information