MediaWiki
1.34.0
|
Handler for the "LinksUpdate" hook. More...
Public Member Functions | |
doLinksUpdate (LinksUpdate $linksUpdate) | |
getPageImageCandidates (LinksUpdate $linksUpdate) | |
Returns a list of page image candidates for consideration for scoring algorithm. More... | |
Static Public Member Functions | |
static | onLinksUpdate (LinksUpdate $linksUpdate) |
LinksUpdate hook handler, sets at most 2 page properties depending on images on page. More... | |
Protected Member Functions | |
fetchFileMetadata ( $file) | |
Fetch file metadata. More... | |
getBlacklist () | |
Returns a list of images blacklisted from influencing this extension's output. More... | |
getRatio (array $image) | |
Returns width/height ratio of an image as displayed or 0 is not available. More... | |
getScore (array $image, $position) | |
Returns score for image, the more the better, if it is less than zero, the image shouldn't be used for anything. More... | |
isImageFree ( $fileName) | |
Check whether image's copyright allows it to be used freely. More... | |
scoreFromTable ( $value, array $scores) | |
Returns score based on table of ranges. More... | |
Private Member Functions | |
getDbBlacklist ( $dbName, $page) | |
Returns list of images linked by the given blacklist page. More... | |
getUrlBlacklist ( $url) | |
Returns list of images on given remote blacklist page. More... | |
Handler for the "LinksUpdate" hook.
Definition at line 22 of file LinksUpdateHookHandler.php.
PageImages\Hooks\LinksUpdateHookHandler::doLinksUpdate | ( | LinksUpdate | $linksUpdate | ) |
LinksUpdate | $linksUpdate | the LinksUpdate object that was passed to the handler |
Definition at line 75 of file LinksUpdateHookHandler.php.
References PageImages\Hooks\LinksUpdateHookHandler\getPageImageCandidates(), PageImages\getPropName(), PageImages\Hooks\LinksUpdateHookHandler\getScore(), and PageImages\Hooks\LinksUpdateHookHandler\isImageFree().
|
protected |
Fetch file metadata.
Definition at line 206 of file LinksUpdateHookHandler.php.
References $context, and $file.
Referenced by PageImages\Hooks\LinksUpdateHookHandler\isImageFree().
|
protected |
Returns a list of images blacklisted from influencing this extension's output.
Exception |
Definition at line 241 of file LinksUpdateHookHandler.php.
References $source, $wgMemc, PageImages\Hooks\LinksUpdateHookHandler\getDbBlacklist(), PageImages\Hooks\LinksUpdateHookHandler\getUrlBlacklist(), wfDebug(), and wfMemcKey().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\getScore().
|
private |
Returns list of images linked by the given blacklist page.
string | bool | $dbName | Database name or false for current database |
string | $page |
Definition at line 285 of file LinksUpdateHookHandler.php.
References $dbr, $res, $title, DB_REPLICA, Title\newFromText(), NS_FILE, and wfGetDB().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\getBlacklist().
PageImages\Hooks\LinksUpdateHookHandler::getPageImageCandidates | ( | LinksUpdate | $linksUpdate | ) |
Returns a list of page image candidates for consideration for scoring algorithm.
LinksUpdate | $linksUpdate | LinksUpdate object used to determine what page to get page images for |
Definition at line 43 of file LinksUpdateHookHandler.php.
References $content, LinksUpdate\getParserOutput(), LinksUpdate\getRevision(), LinksUpdate\getTitle(), and Revision\newFromTitle().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\doLinksUpdate().
|
protected |
Returns width/height ratio of an image as displayed or 0 is not available.
array | $image | Array representing the image to get the aspect ratio from |
Definition at line 224 of file LinksUpdateHookHandler.php.
Referenced by PageImages\Hooks\LinksUpdateHookHandler\getScore().
|
protected |
Returns score for image, the more the better, if it is less than zero, the image shouldn't be used for anything.
array | $image | Associative array describing an image |
int | $position | Image order on page |
Definition at line 128 of file LinksUpdateHookHandler.php.
References PageImages\Hooks\LinksUpdateHookHandler\getBlacklist(), PageImages\Hooks\LinksUpdateHookHandler\getRatio(), and PageImages\Hooks\LinksUpdateHookHandler\scoreFromTable().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\doLinksUpdate().
|
private |
Returns list of images on given remote blacklist page.
Not quite 100% bulletproof due to localised namespaces and so on. Though if you beat people if they add bad entries to the list... :)
string | $url |
Definition at line 320 of file LinksUpdateHookHandler.php.
References $matches, $s, $t, $wgFileExtensions, Http\get(), Title\makeTitleSafe(), and NS_FILE.
Referenced by PageImages\Hooks\LinksUpdateHookHandler\getBlacklist().
|
protected |
Check whether image's copyright allows it to be used freely.
string | $fileName | Name of the image file |
Definition at line 190 of file LinksUpdateHookHandler.php.
References $file, PageImages\Hooks\LinksUpdateHookHandler\fetchFileMetadata(), and wfFindFile().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\doLinksUpdate().
|
static |
LinksUpdate hook handler, sets at most 2 page properties depending on images on page.
LinksUpdate | $linksUpdate | the LinksUpdate object that this hook is parsing |
Definition at line 31 of file LinksUpdateHookHandler.php.
|
protected |
Returns score based on table of ranges.
int | $value | The number that the various bounds are compared against to calculate the score |
float[] | $scores | Table of scores for different ranges of $value |
Definition at line 163 of file LinksUpdateHookHandler.php.
References wfLogWarning().
Referenced by PageImages\Hooks\LinksUpdateHookHandler\getScore().