https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113986
Revision: 113986
Author: reedy
Date: 2012-03-16 01:26:34 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
Documentation stuffs
Modified Paths:
--------------
trunk/extensions/Collection/Collection.body.php
trunk/extensions/Collection/Collection.hooks.php
trunk/extensions/Collection/Collection.session.php
trunk/extensions/Collection/Collection.suggest.php
Modified: trunk/extensions/Collection/Collection.body.php
===================================================================
--- trunk/extensions/Collection/Collection.body.php 2012-03-16 01:07:57 UTC
(rev 113985)
+++ trunk/extensions/Collection/Collection.body.php 2012-03-16 01:26:34 UTC
(rev 113986)
@@ -23,6 +23,9 @@
class SpecialCollection extends SpecialPage {
var $tempfile;
+ /**
+ * @param $PODPartners bool|array
+ */
public function __construct( $PODPartners = false ) {
parent::__construct( "Book" );
global $wgCollectionPODPartners;
@@ -190,7 +193,8 @@
}
$collection = $this->loadCollection( $title );
$partner = $wgRequest->getVal( 'partner', key(
$this->mPODPartners ) );
- return $this->postZIP( $collection, $partner );
+ $this->postZIP( $collection, $partner );
+ return;
case 'save_collection':
if ( $wgRequest->getVal( 'abort' ) ) {
$wgOut->redirect(
SkinTemplate::makeSpecialUrl( 'Book' ) );
@@ -229,11 +233,12 @@
}
return;
case 'render':
- return $this->renderCollection(
+ $this->renderCollection(
CollectionSession::getCollection(),
SpecialPage::getTitleFor( 'Book' ),
$wgRequest->getVal( 'writer', '' )
);
+ return;
case 'forcerender':
$this->forceRenderCollection();
return;
@@ -298,6 +303,11 @@
}
}
+ /**
+ * @param $referer
+ * @param $par
+ * @return mixed
+ */
function renderBookCreatorPage( $referer, $par ) {
global $wgOut, $wgJsMimeType;
@@ -379,6 +389,9 @@
$wgOut->addWikiMsg( 'coll-book_creator_help' );
}
+ /**
+ * @param $referer
+ */
function renderStopBookCreatorPage( $referer ) {
global $wgOut;
@@ -420,6 +433,9 @@
);
}
+ /**
+ * @return array
+ */
static function getBookPagePrefixes() {
global $wgUser, $wgCommunityCollectionNamespace;
@@ -475,6 +491,11 @@
CollectionSession::setCollection( $collection );
}
+ /**
+ * @param $a array
+ * @param $b array
+ * @return int
+ */
static function title_cmp( $a, $b ) {
return strcasecmp( $a['title'], $b['title'] );
}
@@ -497,6 +518,9 @@
CollectionSession::setCollection( $collection );
}
+ /**
+ * @param $name string
+ */
static function addChapter( $name ) {
$collection = CollectionSession::getCollection();
array_push( $collection['items'], array(
@@ -506,6 +530,10 @@
CollectionSession::setCollection( $collection );
}
+ /**
+ * @param $index int
+ * @param $name string
+ */
static function renameChapter( $index, $name ) {
if ( !is_int( $index ) ) {
return;
@@ -518,6 +546,12 @@
CollectionSession::setCollection( $collection );
}
+ /**
+ * @param $namespace int
+ * @param $name string
+ * @param int $oldid
+ * @return bool
+ */
static function addArticleFromName( $namespace, $name, $oldid = 0 ) {
$title = Title::makeTitleSafe( $namespace, $name );
if ( !$title ) {
@@ -581,6 +615,12 @@
return true;
}
+ /**
+ * @param $namespace string
+ * @param $name string
+ * @param $oldid int
+ * @return bool
+ */
static function removeArticleFromName( $namespace, $name, $oldid = 0 ) {
$title = Title::makeTitleSafe( $namespace, $name );
return self::removeArticle( $title, $oldid );
@@ -604,18 +644,26 @@
return true;
}
+ /**
+ * @param $name string
+ * @return bool
+ */
static function addCategoryFromName( $name ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $name );
return self::addCategory( $title );
}
+ /**
+ * @param $title Title
+ * @return bool
+ */
static function addCategory( $title ) {
global $wgCollectionMaxArticles, $wgCollectionArticleNamespaces;
$limit = $wgCollectionMaxArticles -
CollectionSession::countArticles();
if ( $limit <= 0 ) {
self::limitExceeded();
- return;
+ return false;
}
$db = wfGetDB( DB_SLAVE );
$tables = array( 'page', 'categorylinks' );
@@ -668,6 +716,11 @@
return true;
}
+ /**
+ * @param $index
+ * @param $delta
+ * @return bool
+ */
static function moveItem( $index, $delta ) {
if ( !CollectionSession::hasSession() ) {
return false;
@@ -680,6 +733,9 @@
return true;
}
+ /**
+ * @param $items array
+ */
static function setSorting( $items ) {
if ( !CollectionSession::hasSession() ) {
return;
@@ -694,6 +750,12 @@
CollectionSession::setCollection( $collection );
}
+ /**
+ * @param $collection
+ * @param $line
+ * @param $append
+ * @return array|null
+ */
function parseCollectionLine( &$collection, $line, $append ) {
$line = trim( $line );
if ( !$append && preg_match( '/^===\s*(.*?)\s*===$/', $line,
$match ) ) {
@@ -775,7 +837,7 @@
if ( is_null( $title ) ) {
$wgOut->showErrorPage( 'coll-notitle_title',
'coll-notitle_msg' );
- return;
+ return null;
}
if ( !$title->exists() ) {
@@ -872,6 +934,9 @@
return true;
}
+ /**
+ * @return array
+ */
function getLicenseInfos() {
global $wgCollectionLicenseName, $wgCollectionLicenseURL,
$wgRightsIcon;
global $wgRightsPage, $wgRightsText, $wgRightsUrl;
@@ -904,6 +969,10 @@
return array( $licenseInfo );
}
+ /**
+ * @param $collection array
+ * @return string
+ */
function buildJSONCollection( $collection ) {
$result = array(
'type' => 'collection',
@@ -943,6 +1012,12 @@
return $json->encode( $result );
}
+ /**
+ * @param $collection
+ * @param $referrer Title
+ * @param $writer
+ * @return mixed
+ */
function renderCollection( $collection, $referrer, $writer ) {
global $wgOut, $wgContLang, $wgScriptPath, $wgScriptExtension;
@@ -1031,7 +1106,6 @@
switch ( $response['state'] ) {
case 'progress':
- $url = htmlspecialchars( SkinTemplate::makeSpecialUrl(
'Book', 'bookcmd=rendering&' . $query ) );
$wgOut->addHeadItem( 'refresh-nojs', '<noscript><meta
http-equiv="refresh" content="2" /></noscript>' );
$wgOut->addInlineScript( 'var collection_id = "' .
urlencode( $response['collection_id'] ) . '";' );
$wgOut->addInlineScript( 'var writer = "' . urlencode(
$response['writer'] ) . '";' );
@@ -1123,6 +1197,11 @@
$wgOut->disable();
}
+ /**
+ * @param $res
+ * @param $content
+ * @return int
+ */
function writeToTempFile( $res, $content ) {
return fwrite( $this->tempfile, $content );
}
@@ -1157,6 +1236,11 @@
$this->renderCollection( array( 'items' => array( $article ) ),
$title, $writer );
}
+ /**
+ * @param $collection
+ * @param $partner
+ * @return mixed
+ */
function postZIP( $collection, $partner ) {
global $wgScriptPath, $wgScriptExtension, $wgOut;
@@ -1181,6 +1265,12 @@
$wgOut->redirect( $response['redirect_url'] );
}
+ /**
+ * @param $colltype
+ * @param $title
+ * @param $pcollname
+ * @param $ccollname
+ */
private function renderSaveOverwritePage( $colltype, $title,
$pcollname, $ccollname ) {
global $wgOut;
@@ -1195,6 +1285,9 @@
$wgOut->addTemplate( $template );
}
+ /**
+ * @param $title
+ */
private function renderLoadOverwritePage( $title ) {
global $wgOut;
@@ -1206,13 +1299,19 @@
$wgOut->addTemplate( $template );
}
+ /**
+ * @param $command
+ * @param $args
+ * @return bool|array
+ */
static function mwServeCommand( $command, $args ) {
global $wgOut, $wgCollectionMWServeURL,
$wgCollectionMWServeCredentials, $wgCollectionFormatToServeURL;
$serveURL = $wgCollectionMWServeURL;
if ( isset ( $args['writer'] ) ) {
- if ( array_key_exists( $args['writer'],
$wgCollectionFormatToServeURL ) )
+ if ( array_key_exists( $args['writer'],
$wgCollectionFormatToServeURL ) ) {
$serveURL = $wgCollectionFormatToServeURL[
$args['writer'] ];
+ }
}
$args['command'] = $command;
Modified: trunk/extensions/Collection/Collection.hooks.php
===================================================================
--- trunk/extensions/Collection/Collection.hooks.php 2012-03-16 01:07:57 UTC
(rev 113985)
+++ trunk/extensions/Collection/Collection.hooks.php 2012-03-16 01:26:34 UTC
(rev 113986)
@@ -74,7 +74,7 @@
$title = $sk->getTitle();
if ( is_null( $title ) || !$title->exists() ) {
- return;
+ return false;
}
$namespace = $title->getNamespace();
@@ -155,9 +155,9 @@
global $wgOut;
if ( !$wgOut->isPrintable() ) {
$attribs = array(
- 'href' => $sk->getTitle()->getLocalUrl(
$wgRequest->appendQueryValue( 'printable', 'yes', true ) ),
- 'title' => $sk->titleAttrib( 't-print',
'withaccess' ),
- 'accesskey' => $sk->accesskey(
't-print' ),
+ 'href' => $title->getLocalUrl(
$wgRequest->appendQueryValue( 'printable', 'yes', true ) ),
+ 'title' => Linker::titleAttrib(
't-print', 'withaccess' ),
+ 'accesskey' => Linker::accesskey(
't-print' ),
);
if ( $attribs['title'] === false ) {
unset( $attribs['title'] );
@@ -178,6 +178,9 @@
/**
* Callback for hook SiteNoticeAfter
+ * @param $siteNotice
+ * @param $skin Skin
+ * @return bool
*/
static function siteNoticeAfter( &$siteNotice, $skin = null ) {
global $wgCollectionArticleNamespaces;
@@ -227,7 +230,6 @@
/**
* @param $title Title
- * @param $skin Skin
* @param $mode string
* @return string
*/
@@ -316,6 +318,12 @@
return $html;
}
+ /**
+ * @param $title
+ * @param $ajaxHint null
+ * @param $oldid null|int
+ * @return string
+ */
static function getBookCreatorBoxContent( $title, $ajaxHint = null,
$oldid = null ) {
$imagePath = SpecialCollection::getMediaPath();
@@ -325,7 +333,6 @@
}
/**
- * @param $sk Skin
* @param $imagePath
* @param $ajaxHint
* @param $title Title
@@ -403,6 +410,11 @@
}
+ /**
+ * @param $imagePath
+ * @param $ajaxHint
+ * @return string
+ */
static function getBookCreatorBoxShowBookLink( $imagePath, $ajaxHint ) {
$numArticles = CollectionSession::countArticles();
@@ -446,6 +458,11 @@
}
}
+ /**
+ * @param $imagePath
+ * @param $ajaxHint
+ * @return string
+ */
static function getBookCreatorBoxSuggestLink( $imagePath, $ajaxHint ) {
if ( wfMsg( 'coll-suggest_enabled' ) != '1' ) {
return '';
@@ -492,8 +509,10 @@
}
/**
- * OutputPageCheckLastModified hook
- */
+ * OutputPageCheckLastModified hook
+ * @param $modifiedTimes array
+ * @return bool
+ */
static function checkLastModified( $modifiedTimes ) {
if ( CollectionSession::hasSession() ) {
$modifiedTimes['collection'] =
$_SESSION['wsCollection']['timestamp'];
@@ -503,6 +522,8 @@
/**
* ResourceLoaderGetConfigVars hook
+ * @param $vars array
+ * @return bool
*/
static function resourceLoaderGetConfigVars( &$vars ) {
$vars['wgCollectionVersion'] = $GLOBALS['wgCollectionVersion'];
Modified: trunk/extensions/Collection/Collection.session.php
===================================================================
--- trunk/extensions/Collection/Collection.session.php 2012-03-16 01:07:57 UTC
(rev 113985)
+++ trunk/extensions/Collection/Collection.session.php 2012-03-16 01:26:34 UTC
(rev 113986)
@@ -22,8 +22,14 @@
*/
class CollectionSession {
+
+ /**
+ * @return bool
+ */
static function hasSession() {
- if ( !session_id() ) return false;
+ if ( !session_id() ) {
+ return false;
+ }
return isset( $_SESSION['wsCollection'] );
}
@@ -69,10 +75,16 @@
self::touchSession();
}
+ /**
+ * @return bool
+ */
static function isEnabled() {
return ( self::hasSession() &&
$_SESSION['wsCollection']['enabled'] );
}
+ /**
+ * @return int
+ */
static function countArticles() {
if ( !self::hasSession() ) {
return 0;
@@ -86,6 +98,11 @@
return $count;
}
+ /**
+ * @param $title
+ * @param $oldid int
+ * @return int
+ */
static function findArticle( $title, $oldid = 0 ) {
if ( !self::hasSession() ) {
return - 1;
@@ -107,6 +124,9 @@
return - 1;
}
+ /**
+ * @return bool
+ */
static function purge() {
if ( !self::hasSession() ) {
return false;
@@ -139,10 +159,16 @@
return true;
}
+ /**
+ * @return array
+ */
static function getCollection() {
return self::purge() ? $_SESSION['wsCollection'] : array();
}
+ /**
+ * @param $collection
+ */
static function setCollection( $collection ) {
$_SESSION['wsCollection'] = $collection;
self::touchSession();
Modified: trunk/extensions/Collection/Collection.suggest.php
===================================================================
--- trunk/extensions/Collection/Collection.suggest.php 2012-03-16 01:07:57 UTC
(rev 113985)
+++ trunk/extensions/Collection/Collection.suggest.php 2012-03-16 01:26:34 UTC
(rev 113986)
@@ -83,7 +83,7 @@
* @param $param (type string) name of the article to be added, banned
or removed
* or a number of articles to add or a value (1 - 1.5) all
articles with a
* higher value will be added to the collection
- * @return (type string) html-code for the proposallist and the
memberlist
+ * @return string html-code for the proposallist and the memberlist
*/
public static function refresh( $mode, $param ) {
global $wgLang;
@@ -96,6 +96,11 @@
);
}
+ /**
+ * @param $lastAction
+ * @param $article
+ * @return array
+ */
public static function undo( $lastAction, $article ) {
switch ( $lastAction ) {
case 'add':
@@ -155,7 +160,7 @@
* @param $param (type string) name of the article to be added, banned
or removed
* or a number of articles to add or a value (1 - 1.5) all
articles with a
* higher value will be added to the collection
- * @return the template for the wikipage
+ * @return CollectionSuggestTemplate the template for the wikipage
*/
private static function getCollectionSuggestTemplate( $mode, $param ) {
global $wgCollectionMaxSuggestions;
@@ -204,8 +209,8 @@
/**
* Add some articles and update the book of the Proposal-Object
*
- * @param $articleList an array with the names of the articles to be
added
- * @param $prop the proposal-Object
+ * @param $articleList array with the names of the articles to be added
+ * @param $prop Proposals the proposal-Object
*/
private static function addArticlesFromName( $articleList, $prop ) {
foreach ( $articleList as $article ) {
@@ -312,6 +317,9 @@
}
}
+ /**
+ * @return bool
+ */
public function hasBans() {
return count( $this->mBanList ) > 0;
}
@@ -368,6 +376,10 @@
$this->mLinkList = $newList;
}
+ /**
+ * @param $title Title
+ * @return Title
+ */
private function resolveRedirects( $title ) {
if ( !$title->isRedirect() ) {
return $title;
@@ -384,8 +396,8 @@
/**
* Extract & count links from wikitext
*
- * @param wikitext: article text
- * @return an array with links and their weights
+ * @param wikitext string article text
+ * @return array with links and their weights
*/
private function getWeightedLinks( $num_articles, $wikitext ) {
global $wgCollectionSuggestCheapWeightThreshhold;
@@ -493,7 +505,9 @@
}
}
- // Calculate the $mPropList from $mLinkList and $mBanList
+ /**
+ * Calculate the $mPropList from $mLinkList and $mBanList
+ */
private function getPropList() {
$prop = array();
foreach ( $this->mLinkList as $article ) {
@@ -531,9 +545,9 @@
* if the array doesn't contain the article
*
* @param $entry (type string) an articlename
- * @param $array the array to be searched, it has to 2-dimensional
+ * @param $array array to be searched, it has to 2-dimensional
* the 2nd dimension needs the key 'name'
- * @return the key as integer or false
+ * @return bool|int the key as integer or false
*/
private function searchEntry( $entry, $array ) {
for ( $i = 0; $i < count( $array ); $i++ ) {
@@ -547,8 +561,8 @@
/**
* Check if an article is banned or belongs to the book/collection
*
- * @param $link (type string) an articlename
- * @return (type boolean) true: if the article can be added to the
proposals
+ * @param $link string an articlename
+ * @return boolean true: if the article can be added to the proposals
* false: if the article can't be added to the
proposals
*/
private function checkLink( $link ) {
@@ -565,28 +579,10 @@
return true;
}
+ /**
+ * @return int
+ */
private function getPropCount() {
return count( $this->mPropList );
}
}
-
-/**
- * sort $mPropList by the entries values
- * sort alphabetically by equal values
- *
- * @param $a, $b: arrays that contain two entries
- * the keys: 'name' & 'val'
- * 'name': an articlename
- * 'val' : a value from 1 to 1.5
- * @return 1, -1 or 0
- */
-function wgCollectionCompareProps( $a, $b ) {
- if ( $a['val'] == $b['val'] ) {
- return strcmp( $a['name'], $b['name'] );
- }
- if ( $a['val'] < $b['val'] ) {
- return 1;
- } else {
- return - 1;
- }
-}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs