Properties

$url

$url : 

Type

$echoRet

$echoRet : 

Type

$site_url

$site_url : 

Type

$url

$url : string

The Project URL (API path)

Type

string

$site_url

$site_url : string

The project URL (main page)

Type

string

$flickr_licenses_blacklist

$flickr_licenses_blacklist : string

The Flickr Licenses blacklist array

Type

string

$ipernity_licenses_blacklist

$ipernity_licenses_blacklist : string

The Ipernity Licenses blacklist array

Type

string

$picasa_licenses_blacklist

$picasa_licenses_blacklist : string

The Picasa Licenses blacklist array

Type

string

$flickr_api_key

$flickr_api_key : string

The Flickr API key (optional)

Type

string

$ipernity_api_key

$ipernity_api_key : string

The Ipernity API key (optional)

Type

string

$url

$url : string

The Project URL (API path).

Type

string

$http

$http : 

Type

$token

$token : 

Type

$ecTimestamp

$ecTimestamp : 

Type

$flickr_api_key

$flickr_api_key : 

Type

$ipernity_api_key

$ipernity_api_key : 

Type

$flickr_licenses_blacklist

$flickr_licenses_blacklist : 

Type

$ipernity_licenses_blacklist

$ipernity_licenses_blacklist : 

Type

$picasa_licenses_blacklist

$picasa_licenses_blacklist : 

Type

Methods

__construct()

__construct(  $url,   $flickr_licenses_blacklist,   $ipernity_licenses_blacklist,   $picasa_licenses_blacklist,   $flickr_api_key = null,   $ipernity_api_key = null) : void

This is the constructor

Parameters

$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

__set()

__set(  $var,   $val) : void

The set.

Parameters

$var
$val

setUserAgent()

setUserAgent(  $userAgent) 

Set/change the user agent.

Parameters

$userAgent

The user agent string.

setHttpHeader()

setHttpHeader(  $httpHeader) 

Set/change the http header.

Parameters

$httpHeader

The http header.

useDefaultHttpHeader()

useDefaultHttpHeader() 

Set/change the http headers.

query()

query(  $query,   $post = null,   $repeat = null,   $url = null) : mixed

Sends a query to the API.

Parameters

$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).

Returns

mixed —

The response from server (API result).

getpage()

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

Parameters

$page

The wikipedia page to fetch.

$revid

The revision id to fetch (optional).

$detectEditConflict

Returns

string —

The wikitext for the given page.

getpageid()

getpageid(  $page) : string

Gets the ID for a page.

Parameters

$page

The wikipedia page to get the id for.

Returns

string —

The page ID.

categorymembers()

categorymembers(  $category,   $limit = 10,   $continue = null,   $subcat = false) : array

Returns an array with all the members of $category

Parameters

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

Returns

array —

The category ID.

subpages()

subpages(  $page) : array

Returns an array with all the subpages of $page.

Parameters

$page

Returns

array —

The subpages list.

login()

login(  $user,   $pass) : array

This function takes a username and password and logs you into Wiki.

Parameters

$user

Username to login as.

$pass

Password that corrisponds to the username.

Returns

array —

The API result

setLogin()

setLogin(  $data) : void

crappy hack to allow users to use cookies from old sessions.

Parameters

$data

The data to be parsed.

nobots()

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.

Parameters

$page

The page we want to edit.

$user

The bot's username.

$text

Returns

boolean

getedittoken()

getedittoken() : string

This function returns the edit token for the current user.

Returns

string —

The edit token.

edit()

edit(  $page,   $data,   $summary = '',   $minor = false,   $bot = true,   $section = null,   $detectEC = false,   $maxlag = '') : array

Edits a page.

Parameters

$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

Returns

array —

The API result

getfilelocation()

getfilelocation(  $page) : string

BMcN 2012-09-16 Retrieve a media file's actual location.

Parameters

$page

The "File:" page on the wiki which the URL of is desired.

Returns

string —

The URL pointing directly to the media file (Eg http://upload.mediawiki.org/wikipedia/en/1/1/Example.jpg)

getfileuploader()

getfileuploader(  $page) : string

BMcN 2012-09-16 Retrieve a media file's uploader.

Parameters

$page

The "File:" page

Returns

string —

The user who uploaded the topmost version of the file.

findstring()

findstring(  $page,   $string) : boolean

Find a string

Parameters

$page

The page we're working with.

$string

The string that you want to find.

Returns

boolean —

Value (1 found and 0 not-found)

replacestring()

replacestring(  $page,   $string,   $newstring,   $regex = false) : string

Replace a string

Parameters

$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

Returns

string —

The new text of page

gettemplate()

gettemplate(  $page,   $template) : string

Get a template from a page

Parameters

$page

The page we're working with

$template

The name of the template we are looking for

Returns

string —

The searched (NULL if the template has not been found)

getPageContents()

getPageContents(  $page,   $props = null) : array

Get the contents from the Wiki page in several formats, using the MediaWiki API (cached)

Parameters

$page

The page that we're working

$props

The properties that we want to obtain from the query (string or array)

Returns

array —

The contents as array

getThumbURL()

getThumbURL(  $page,   $width = null,   $height = null) : string

Get the URL of the thumbnail of a File, best fit to width and height (cached)

Parameters

$page

The page in File: namespace that we want to get the URL

$width

The desired width

$height

The desired height

Returns

string —

The URL as string

getTemplates()

getTemplates(  $content,   $tags = null) : array

Get the template tags from the given page, with its parameters (everything between {{}})

Parameters

$content

The contents (wiki markup) that we're working with

$tags

The specific template tags what we want to match, as string or array

Returns

array —

The desired template tags

getExternalInfo()

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.

Parameters

$url_g

The URL to be parsed, either string or array

Returns

array —

An array with the following elements:

  • 'service' The external service found
  • 'license' The license text (eg. Creative Commons Attribution)
  • 'thumburl' The url of the file thumbnail, to be displayed at the page and compare it with the file found at the Wiki
  • 'url' The actual URL to the file located at the external service
  • 'allowed' If the license is allowed at the Wiki (false if not)
  • If no valid URL found, return false.

bestFit()

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

Parameters

$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

Returns

string —

The closest (and not greater) value or its key

getPhotoID()

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]).

Parameters

$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

Returns

string —

The numeric ID

hexColor()

hexColor(  $color,   $bg = false) : string

Get a valid colour in hexadecimal notation (for css) and return default values if them are not valid

Parameters

$color

The colour in hexadecimal notation (eg ABF or ACDCEF)

$bg

If the colour is intended for background or foreground

Returns

string —

The valid colour in hexadecimal nottaion, or '000' for foreground and 'fff' for background

flickrBase58Decode()

flickrBase58Decode(  $num,   $alphabet) : string

Decode a base58 encoded Flickr shorten URL

Parameters

$num

The sorten ID

$alphabet

The alphabet where find

Returns

string —

The ID as base10

getFlickrInfo()

getFlickrInfo(  $id) : array

Get useful information from a Flickr file using the Flickr API (cached)

Parameters

$id

The Flickr File ID

Returns

array —

The desired information

getFlickrLicense()

getFlickrLicense(  $id) : string

Get the license text from a Flickr License ID (cached)

Parameters

$id

The Flickr License ID (NOT the file ID)

Returns

string —

The license text

getFlickrThumbURL()

getFlickrThumbURL(  $id,   $max_height = 200) : string

Get the thumbnail of a Flickr file using its ID (cached)

Parameters

$id

The Flickr file ID

$max_height

= The maximum desired height

Returns

string —

The numeric ID

getIpernityInfo()

getIpernityInfo(  $id) : array

Get the information from a file in Ipernity using its ID

Parameters

$id

The file ID

Returns

array —

The information of the given file

getIpernityLicense()

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.

Parameters

$id

The License ID, obtained from getIpernityInfo()

Returns

string —

The license text

getIpernityThumbURL()

getIpernityThumbURL(  $thumbs,   $max = null) : string

Extract the Thumbnail URL from an array of thumbnails, obtained with getIpernityInfo(), and find the best size with bestFit().

Parameters

$thumbs

The Array containing the Thumbs element

$max

The maximum desired height

Returns

string —

The desired URL of the thumbnail

getPicasaInformation()

getPicasaInformation(  $user,   $album,   $photoid) : array

Get information about a file at Picasa, using the ATOM feed retreived as JSON (cached)

Parameters

$user

The Username of the owner (either numeric or string)

$album

The Album (either numeric or string)

$photoid

The photo ID (as numeric)

Returns

array —

The desired information

getPicasaThumbURL()

getPicasaThumbURL(  $url,   $bestfit = 200) : string

Parse a Picasa file URL (direct link), and modify the height; bestfit() is not needed

Parameters

$url

The URL to be parsed

$bestfit

The (maximum) desired height

Returns

string —

The URL with the desired height established