Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -23,6 +23,9 @@ |
24 | 24 | class SpecialCollection extends SpecialPage { |
25 | 25 | var $tempfile; |
26 | 26 | |
| 27 | + /** |
| 28 | + * @param $PODPartners bool|array |
| 29 | + */ |
27 | 30 | public function __construct( $PODPartners = false ) { |
28 | 31 | parent::__construct( "Book" ); |
29 | 32 | global $wgCollectionPODPartners; |
— | — | @@ -190,7 +193,8 @@ |
191 | 194 | } |
192 | 195 | $collection = $this->loadCollection( $title ); |
193 | 196 | $partner = $wgRequest->getVal( 'partner', key( $this->mPODPartners ) ); |
194 | | - return $this->postZIP( $collection, $partner ); |
| 197 | + $this->postZIP( $collection, $partner ); |
| 198 | + return; |
195 | 199 | case 'save_collection': |
196 | 200 | if ( $wgRequest->getVal( 'abort' ) ) { |
197 | 201 | $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
— | — | @@ -229,11 +233,12 @@ |
230 | 234 | } |
231 | 235 | return; |
232 | 236 | case 'render': |
233 | | - return $this->renderCollection( |
| 237 | + $this->renderCollection( |
234 | 238 | CollectionSession::getCollection(), |
235 | 239 | SpecialPage::getTitleFor( 'Book' ), |
236 | 240 | $wgRequest->getVal( 'writer', '' ) |
237 | 241 | ); |
| 242 | + return; |
238 | 243 | case 'forcerender': |
239 | 244 | $this->forceRenderCollection(); |
240 | 245 | return; |
— | — | @@ -298,6 +303,11 @@ |
299 | 304 | } |
300 | 305 | } |
301 | 306 | |
| 307 | + /** |
| 308 | + * @param $referer |
| 309 | + * @param $par |
| 310 | + * @return mixed |
| 311 | + */ |
302 | 312 | function renderBookCreatorPage( $referer, $par ) { |
303 | 313 | global $wgOut, $wgJsMimeType; |
304 | 314 | |
— | — | @@ -379,6 +389,9 @@ |
380 | 390 | $wgOut->addWikiMsg( 'coll-book_creator_help' ); |
381 | 391 | } |
382 | 392 | |
| 393 | + /** |
| 394 | + * @param $referer |
| 395 | + */ |
383 | 396 | function renderStopBookCreatorPage( $referer ) { |
384 | 397 | global $wgOut; |
385 | 398 | |
— | — | @@ -420,6 +433,9 @@ |
421 | 434 | ); |
422 | 435 | } |
423 | 436 | |
| 437 | + /** |
| 438 | + * @return array |
| 439 | + */ |
424 | 440 | static function getBookPagePrefixes() { |
425 | 441 | global $wgUser, $wgCommunityCollectionNamespace; |
426 | 442 | |
— | — | @@ -475,6 +491,11 @@ |
476 | 492 | CollectionSession::setCollection( $collection ); |
477 | 493 | } |
478 | 494 | |
| 495 | + /** |
| 496 | + * @param $a array |
| 497 | + * @param $b array |
| 498 | + * @return int |
| 499 | + */ |
479 | 500 | static function title_cmp( $a, $b ) { |
480 | 501 | return strcasecmp( $a['title'], $b['title'] ); |
481 | 502 | } |
— | — | @@ -497,6 +518,9 @@ |
498 | 519 | CollectionSession::setCollection( $collection ); |
499 | 520 | } |
500 | 521 | |
| 522 | + /** |
| 523 | + * @param $name string |
| 524 | + */ |
501 | 525 | static function addChapter( $name ) { |
502 | 526 | $collection = CollectionSession::getCollection(); |
503 | 527 | array_push( $collection['items'], array( |
— | — | @@ -506,6 +530,10 @@ |
507 | 531 | CollectionSession::setCollection( $collection ); |
508 | 532 | } |
509 | 533 | |
| 534 | + /** |
| 535 | + * @param $index int |
| 536 | + * @param $name string |
| 537 | + */ |
510 | 538 | static function renameChapter( $index, $name ) { |
511 | 539 | if ( !is_int( $index ) ) { |
512 | 540 | return; |
— | — | @@ -518,6 +546,12 @@ |
519 | 547 | CollectionSession::setCollection( $collection ); |
520 | 548 | } |
521 | 549 | |
| 550 | + /** |
| 551 | + * @param $namespace int |
| 552 | + * @param $name string |
| 553 | + * @param int $oldid |
| 554 | + * @return bool |
| 555 | + */ |
522 | 556 | static function addArticleFromName( $namespace, $name, $oldid = 0 ) { |
523 | 557 | $title = Title::makeTitleSafe( $namespace, $name ); |
524 | 558 | if ( !$title ) { |
— | — | @@ -581,6 +615,12 @@ |
582 | 616 | return true; |
583 | 617 | } |
584 | 618 | |
| 619 | + /** |
| 620 | + * @param $namespace string |
| 621 | + * @param $name string |
| 622 | + * @param $oldid int |
| 623 | + * @return bool |
| 624 | + */ |
585 | 625 | static function removeArticleFromName( $namespace, $name, $oldid = 0 ) { |
586 | 626 | $title = Title::makeTitleSafe( $namespace, $name ); |
587 | 627 | return self::removeArticle( $title, $oldid ); |
— | — | @@ -604,18 +644,26 @@ |
605 | 645 | return true; |
606 | 646 | } |
607 | 647 | |
| 648 | + /** |
| 649 | + * @param $name string |
| 650 | + * @return bool |
| 651 | + */ |
608 | 652 | static function addCategoryFromName( $name ) { |
609 | 653 | $title = Title::makeTitleSafe( NS_CATEGORY, $name ); |
610 | 654 | return self::addCategory( $title ); |
611 | 655 | } |
612 | 656 | |
| 657 | + /** |
| 658 | + * @param $title Title |
| 659 | + * @return bool |
| 660 | + */ |
613 | 661 | static function addCategory( $title ) { |
614 | 662 | global $wgCollectionMaxArticles, $wgCollectionArticleNamespaces; |
615 | 663 | |
616 | 664 | $limit = $wgCollectionMaxArticles - CollectionSession::countArticles(); |
617 | 665 | if ( $limit <= 0 ) { |
618 | 666 | self::limitExceeded(); |
619 | | - return; |
| 667 | + return false; |
620 | 668 | } |
621 | 669 | $db = wfGetDB( DB_SLAVE ); |
622 | 670 | $tables = array( 'page', 'categorylinks' ); |
— | — | @@ -668,6 +716,11 @@ |
669 | 717 | return true; |
670 | 718 | } |
671 | 719 | |
| 720 | + /** |
| 721 | + * @param $index |
| 722 | + * @param $delta |
| 723 | + * @return bool |
| 724 | + */ |
672 | 725 | static function moveItem( $index, $delta ) { |
673 | 726 | if ( !CollectionSession::hasSession() ) { |
674 | 727 | return false; |
— | — | @@ -680,6 +733,9 @@ |
681 | 734 | return true; |
682 | 735 | } |
683 | 736 | |
| 737 | + /** |
| 738 | + * @param $items array |
| 739 | + */ |
684 | 740 | static function setSorting( $items ) { |
685 | 741 | if ( !CollectionSession::hasSession() ) { |
686 | 742 | return; |
— | — | @@ -694,6 +750,12 @@ |
695 | 751 | CollectionSession::setCollection( $collection ); |
696 | 752 | } |
697 | 753 | |
| 754 | + /** |
| 755 | + * @param $collection |
| 756 | + * @param $line |
| 757 | + * @param $append |
| 758 | + * @return array|null |
| 759 | + */ |
698 | 760 | function parseCollectionLine( &$collection, $line, $append ) { |
699 | 761 | $line = trim( $line ); |
700 | 762 | if ( !$append && preg_match( '/^===\s*(.*?)\s*===$/', $line, $match ) ) { |
— | — | @@ -775,7 +837,7 @@ |
776 | 838 | |
777 | 839 | if ( is_null( $title ) ) { |
778 | 840 | $wgOut->showErrorPage( 'coll-notitle_title', 'coll-notitle_msg' ); |
779 | | - return; |
| 841 | + return null; |
780 | 842 | } |
781 | 843 | |
782 | 844 | if ( !$title->exists() ) { |
— | — | @@ -872,6 +934,9 @@ |
873 | 935 | return true; |
874 | 936 | } |
875 | 937 | |
| 938 | + /** |
| 939 | + * @return array |
| 940 | + */ |
876 | 941 | function getLicenseInfos() { |
877 | 942 | global $wgCollectionLicenseName, $wgCollectionLicenseURL, $wgRightsIcon; |
878 | 943 | global $wgRightsPage, $wgRightsText, $wgRightsUrl; |
— | — | @@ -904,6 +969,10 @@ |
905 | 970 | return array( $licenseInfo ); |
906 | 971 | } |
907 | 972 | |
| 973 | + /** |
| 974 | + * @param $collection array |
| 975 | + * @return string |
| 976 | + */ |
908 | 977 | function buildJSONCollection( $collection ) { |
909 | 978 | $result = array( |
910 | 979 | 'type' => 'collection', |
— | — | @@ -943,6 +1012,12 @@ |
944 | 1013 | return $json->encode( $result ); |
945 | 1014 | } |
946 | 1015 | |
| 1016 | + /** |
| 1017 | + * @param $collection |
| 1018 | + * @param $referrer Title |
| 1019 | + * @param $writer |
| 1020 | + * @return mixed |
| 1021 | + */ |
947 | 1022 | function renderCollection( $collection, $referrer, $writer ) { |
948 | 1023 | global $wgOut, $wgContLang, $wgScriptPath, $wgScriptExtension; |
949 | 1024 | |
— | — | @@ -1031,7 +1106,6 @@ |
1032 | 1107 | |
1033 | 1108 | switch ( $response['state'] ) { |
1034 | 1109 | case 'progress': |
1035 | | - $url = htmlspecialchars( SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=rendering&' . $query ) ); |
1036 | 1110 | $wgOut->addHeadItem( 'refresh-nojs', '<noscript><meta http-equiv="refresh" content="2" /></noscript>' ); |
1037 | 1111 | $wgOut->addInlineScript( 'var collection_id = "' . urlencode( $response['collection_id'] ) . '";' ); |
1038 | 1112 | $wgOut->addInlineScript( 'var writer = "' . urlencode( $response['writer'] ) . '";' ); |
— | — | @@ -1123,6 +1197,11 @@ |
1124 | 1198 | $wgOut->disable(); |
1125 | 1199 | } |
1126 | 1200 | |
| 1201 | + /** |
| 1202 | + * @param $res |
| 1203 | + * @param $content |
| 1204 | + * @return int |
| 1205 | + */ |
1127 | 1206 | function writeToTempFile( $res, $content ) { |
1128 | 1207 | return fwrite( $this->tempfile, $content ); |
1129 | 1208 | } |
— | — | @@ -1157,6 +1236,11 @@ |
1158 | 1237 | $this->renderCollection( array( 'items' => array( $article ) ), $title, $writer ); |
1159 | 1238 | } |
1160 | 1239 | |
| 1240 | + /** |
| 1241 | + * @param $collection |
| 1242 | + * @param $partner |
| 1243 | + * @return mixed |
| 1244 | + */ |
1161 | 1245 | function postZIP( $collection, $partner ) { |
1162 | 1246 | global $wgScriptPath, $wgScriptExtension, $wgOut; |
1163 | 1247 | |
— | — | @@ -1181,6 +1265,12 @@ |
1182 | 1266 | $wgOut->redirect( $response['redirect_url'] ); |
1183 | 1267 | } |
1184 | 1268 | |
| 1269 | + /** |
| 1270 | + * @param $colltype |
| 1271 | + * @param $title |
| 1272 | + * @param $pcollname |
| 1273 | + * @param $ccollname |
| 1274 | + */ |
1185 | 1275 | private function renderSaveOverwritePage( $colltype, $title, $pcollname, $ccollname ) { |
1186 | 1276 | global $wgOut; |
1187 | 1277 | |
— | — | @@ -1195,6 +1285,9 @@ |
1196 | 1286 | $wgOut->addTemplate( $template ); |
1197 | 1287 | } |
1198 | 1288 | |
| 1289 | + /** |
| 1290 | + * @param $title |
| 1291 | + */ |
1199 | 1292 | private function renderLoadOverwritePage( $title ) { |
1200 | 1293 | global $wgOut; |
1201 | 1294 | |
— | — | @@ -1206,13 +1299,19 @@ |
1207 | 1300 | $wgOut->addTemplate( $template ); |
1208 | 1301 | } |
1209 | 1302 | |
| 1303 | + /** |
| 1304 | + * @param $command |
| 1305 | + * @param $args |
| 1306 | + * @return bool|array |
| 1307 | + */ |
1210 | 1308 | static function mwServeCommand( $command, $args ) { |
1211 | 1309 | global $wgOut, $wgCollectionMWServeURL, $wgCollectionMWServeCredentials, $wgCollectionFormatToServeURL; |
1212 | 1310 | |
1213 | 1311 | $serveURL = $wgCollectionMWServeURL; |
1214 | 1312 | if ( isset ( $args['writer'] ) ) { |
1215 | | - if ( array_key_exists( $args['writer'], $wgCollectionFormatToServeURL ) ) |
| 1313 | + if ( array_key_exists( $args['writer'], $wgCollectionFormatToServeURL ) ) { |
1216 | 1314 | $serveURL = $wgCollectionFormatToServeURL[ $args['writer'] ]; |
| 1315 | + } |
1217 | 1316 | } |
1218 | 1317 | |
1219 | 1318 | $args['command'] = $command; |
Index: trunk/extensions/Collection/Collection.suggest.php |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | * @param $param (type string) name of the article to be added, banned or removed |
85 | 85 | * or a number of articles to add or a value (1 - 1.5) all articles with a |
86 | 86 | * higher value will be added to the collection |
87 | | - * @return (type string) html-code for the proposallist and the memberlist |
| 87 | + * @return string html-code for the proposallist and the memberlist |
88 | 88 | */ |
89 | 89 | public static function refresh( $mode, $param ) { |
90 | 90 | global $wgLang; |
— | — | @@ -96,6 +96,11 @@ |
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
| 100 | + /** |
| 101 | + * @param $lastAction |
| 102 | + * @param $article |
| 103 | + * @return array |
| 104 | + */ |
100 | 105 | public static function undo( $lastAction, $article ) { |
101 | 106 | switch ( $lastAction ) { |
102 | 107 | case 'add': |
— | — | @@ -155,7 +160,7 @@ |
156 | 161 | * @param $param (type string) name of the article to be added, banned or removed |
157 | 162 | * or a number of articles to add or a value (1 - 1.5) all articles with a |
158 | 163 | * higher value will be added to the collection |
159 | | - * @return the template for the wikipage |
| 164 | + * @return CollectionSuggestTemplate the template for the wikipage |
160 | 165 | */ |
161 | 166 | private static function getCollectionSuggestTemplate( $mode, $param ) { |
162 | 167 | global $wgCollectionMaxSuggestions; |
— | — | @@ -204,8 +209,8 @@ |
205 | 210 | /** |
206 | 211 | * Add some articles and update the book of the Proposal-Object |
207 | 212 | * |
208 | | - * @param $articleList an array with the names of the articles to be added |
209 | | - * @param $prop the proposal-Object |
| 213 | + * @param $articleList array with the names of the articles to be added |
| 214 | + * @param $prop Proposals the proposal-Object |
210 | 215 | */ |
211 | 216 | private static function addArticlesFromName( $articleList, $prop ) { |
212 | 217 | foreach ( $articleList as $article ) { |
— | — | @@ -312,6 +317,9 @@ |
313 | 318 | } |
314 | 319 | } |
315 | 320 | |
| 321 | + /** |
| 322 | + * @return bool |
| 323 | + */ |
316 | 324 | public function hasBans() { |
317 | 325 | return count( $this->mBanList ) > 0; |
318 | 326 | } |
— | — | @@ -368,6 +376,10 @@ |
369 | 377 | $this->mLinkList = $newList; |
370 | 378 | } |
371 | 379 | |
| 380 | + /** |
| 381 | + * @param $title Title |
| 382 | + * @return Title |
| 383 | + */ |
372 | 384 | private function resolveRedirects( $title ) { |
373 | 385 | if ( !$title->isRedirect() ) { |
374 | 386 | return $title; |
— | — | @@ -384,8 +396,8 @@ |
385 | 397 | /** |
386 | 398 | * Extract & count links from wikitext |
387 | 399 | * |
388 | | - * @param wikitext: article text |
389 | | - * @return an array with links and their weights |
| 400 | + * @param wikitext string article text |
| 401 | + * @return array with links and their weights |
390 | 402 | */ |
391 | 403 | private function getWeightedLinks( $num_articles, $wikitext ) { |
392 | 404 | global $wgCollectionSuggestCheapWeightThreshhold; |
— | — | @@ -493,7 +505,9 @@ |
494 | 506 | } |
495 | 507 | } |
496 | 508 | |
497 | | - // Calculate the $mPropList from $mLinkList and $mBanList |
| 509 | + /** |
| 510 | + * Calculate the $mPropList from $mLinkList and $mBanList |
| 511 | + */ |
498 | 512 | private function getPropList() { |
499 | 513 | $prop = array(); |
500 | 514 | foreach ( $this->mLinkList as $article ) { |
— | — | @@ -531,9 +545,9 @@ |
532 | 546 | * if the array doesn't contain the article |
533 | 547 | * |
534 | 548 | * @param $entry (type string) an articlename |
535 | | - * @param $array the array to be searched, it has to 2-dimensional |
| 549 | + * @param $array array to be searched, it has to 2-dimensional |
536 | 550 | * the 2nd dimension needs the key 'name' |
537 | | - * @return the key as integer or false |
| 551 | + * @return bool|int the key as integer or false |
538 | 552 | */ |
539 | 553 | private function searchEntry( $entry, $array ) { |
540 | 554 | for ( $i = 0; $i < count( $array ); $i++ ) { |
— | — | @@ -547,8 +561,8 @@ |
548 | 562 | /** |
549 | 563 | * Check if an article is banned or belongs to the book/collection |
550 | 564 | * |
551 | | - * @param $link (type string) an articlename |
552 | | - * @return (type boolean) true: if the article can be added to the proposals |
| 565 | + * @param $link string an articlename |
| 566 | + * @return boolean true: if the article can be added to the proposals |
553 | 567 | * false: if the article can't be added to the proposals |
554 | 568 | */ |
555 | 569 | private function checkLink( $link ) { |
— | — | @@ -565,28 +579,10 @@ |
566 | 580 | return true; |
567 | 581 | } |
568 | 582 | |
| 583 | + /** |
| 584 | + * @return int |
| 585 | + */ |
569 | 586 | private function getPropCount() { |
570 | 587 | return count( $this->mPropList ); |
571 | 588 | } |
572 | 589 | } |
573 | | - |
574 | | -/** |
575 | | - * sort $mPropList by the entries values |
576 | | - * sort alphabetically by equal values |
577 | | - * |
578 | | - * @param $a, $b: arrays that contain two entries |
579 | | - * the keys: 'name' & 'val' |
580 | | - * 'name': an articlename |
581 | | - * 'val' : a value from 1 to 1.5 |
582 | | - * @return 1, -1 or 0 |
583 | | - */ |
584 | | -function wgCollectionCompareProps( $a, $b ) { |
585 | | - if ( $a['val'] == $b['val'] ) { |
586 | | - return strcmp( $a['name'], $b['name'] ); |
587 | | - } |
588 | | - if ( $a['val'] < $b['val'] ) { |
589 | | - return 1; |
590 | | - } else { |
591 | | - return - 1; |
592 | | - } |
593 | | -} |
Index: trunk/extensions/Collection/Collection.hooks.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | $title = $sk->getTitle(); |
76 | 76 | |
77 | 77 | if ( is_null( $title ) || !$title->exists() ) { |
78 | | - return; |
| 78 | + return false; |
79 | 79 | } |
80 | 80 | |
81 | 81 | $namespace = $title->getNamespace(); |
— | — | @@ -155,9 +155,9 @@ |
156 | 156 | global $wgOut; |
157 | 157 | if ( !$wgOut->isPrintable() ) { |
158 | 158 | $attribs = array( |
159 | | - 'href' => $sk->getTitle()->getLocalUrl( $wgRequest->appendQueryValue( 'printable', 'yes', true ) ), |
160 | | - 'title' => $sk->titleAttrib( 't-print', 'withaccess' ), |
161 | | - 'accesskey' => $sk->accesskey( 't-print' ), |
| 159 | + 'href' => $title->getLocalUrl( $wgRequest->appendQueryValue( 'printable', 'yes', true ) ), |
| 160 | + 'title' => Linker::titleAttrib( 't-print', 'withaccess' ), |
| 161 | + 'accesskey' => Linker::accesskey( 't-print' ), |
162 | 162 | ); |
163 | 163 | if ( $attribs['title'] === false ) { |
164 | 164 | unset( $attribs['title'] ); |
— | — | @@ -178,6 +178,9 @@ |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Callback for hook SiteNoticeAfter |
| 182 | + * @param $siteNotice |
| 183 | + * @param $skin Skin |
| 184 | + * @return bool |
182 | 185 | */ |
183 | 186 | static function siteNoticeAfter( &$siteNotice, $skin = null ) { |
184 | 187 | global $wgCollectionArticleNamespaces; |
— | — | @@ -227,7 +230,6 @@ |
228 | 231 | |
229 | 232 | /** |
230 | 233 | * @param $title Title |
231 | | - * @param $skin Skin |
232 | 234 | * @param $mode string |
233 | 235 | * @return string |
234 | 236 | */ |
— | — | @@ -316,6 +318,12 @@ |
317 | 319 | return $html; |
318 | 320 | } |
319 | 321 | |
| 322 | + /** |
| 323 | + * @param $title |
| 324 | + * @param $ajaxHint null |
| 325 | + * @param $oldid null|int |
| 326 | + * @return string |
| 327 | + */ |
320 | 328 | static function getBookCreatorBoxContent( $title, $ajaxHint = null, $oldid = null ) { |
321 | 329 | $imagePath = SpecialCollection::getMediaPath(); |
322 | 330 | |
— | — | @@ -325,7 +333,6 @@ |
326 | 334 | } |
327 | 335 | |
328 | 336 | /** |
329 | | - * @param $sk Skin |
330 | 337 | * @param $imagePath |
331 | 338 | * @param $ajaxHint |
332 | 339 | * @param $title Title |
— | — | @@ -403,6 +410,11 @@ |
404 | 411 | |
405 | 412 | } |
406 | 413 | |
| 414 | + /** |
| 415 | + * @param $imagePath |
| 416 | + * @param $ajaxHint |
| 417 | + * @return string |
| 418 | + */ |
407 | 419 | static function getBookCreatorBoxShowBookLink( $imagePath, $ajaxHint ) { |
408 | 420 | $numArticles = CollectionSession::countArticles(); |
409 | 421 | |
— | — | @@ -446,6 +458,11 @@ |
447 | 459 | } |
448 | 460 | } |
449 | 461 | |
| 462 | + /** |
| 463 | + * @param $imagePath |
| 464 | + * @param $ajaxHint |
| 465 | + * @return string |
| 466 | + */ |
450 | 467 | static function getBookCreatorBoxSuggestLink( $imagePath, $ajaxHint ) { |
451 | 468 | if ( wfMsg( 'coll-suggest_enabled' ) != '1' ) { |
452 | 469 | return ''; |
— | — | @@ -492,8 +509,10 @@ |
493 | 510 | } |
494 | 511 | |
495 | 512 | /** |
496 | | - * OutputPageCheckLastModified hook |
497 | | - */ |
| 513 | + * OutputPageCheckLastModified hook |
| 514 | + * @param $modifiedTimes array |
| 515 | + * @return bool |
| 516 | + */ |
498 | 517 | static function checkLastModified( $modifiedTimes ) { |
499 | 518 | if ( CollectionSession::hasSession() ) { |
500 | 519 | $modifiedTimes['collection'] = $_SESSION['wsCollection']['timestamp']; |
— | — | @@ -503,6 +522,8 @@ |
504 | 523 | |
505 | 524 | /** |
506 | 525 | * ResourceLoaderGetConfigVars hook |
| 526 | + * @param $vars array |
| 527 | + * @return bool |
507 | 528 | */ |
508 | 529 | static function resourceLoaderGetConfigVars( &$vars ) { |
509 | 530 | $vars['wgCollectionVersion'] = $GLOBALS['wgCollectionVersion']; |
Index: trunk/extensions/Collection/Collection.session.php |
— | — | @@ -22,8 +22,14 @@ |
23 | 23 | */ |
24 | 24 | |
25 | 25 | class CollectionSession { |
| 26 | + |
| 27 | + /** |
| 28 | + * @return bool |
| 29 | + */ |
26 | 30 | static function hasSession() { |
27 | | - if ( !session_id() ) return false; |
| 31 | + if ( !session_id() ) { |
| 32 | + return false; |
| 33 | + } |
28 | 34 | return isset( $_SESSION['wsCollection'] ); |
29 | 35 | } |
30 | 36 | |
— | — | @@ -69,10 +75,16 @@ |
70 | 76 | self::touchSession(); |
71 | 77 | } |
72 | 78 | |
| 79 | + /** |
| 80 | + * @return bool |
| 81 | + */ |
73 | 82 | static function isEnabled() { |
74 | 83 | return ( self::hasSession() && $_SESSION['wsCollection']['enabled'] ); |
75 | 84 | } |
76 | 85 | |
| 86 | + /** |
| 87 | + * @return int |
| 88 | + */ |
77 | 89 | static function countArticles() { |
78 | 90 | if ( !self::hasSession() ) { |
79 | 91 | return 0; |
— | — | @@ -86,6 +98,11 @@ |
87 | 99 | return $count; |
88 | 100 | } |
89 | 101 | |
| 102 | + /** |
| 103 | + * @param $title |
| 104 | + * @param $oldid int |
| 105 | + * @return int |
| 106 | + */ |
90 | 107 | static function findArticle( $title, $oldid = 0 ) { |
91 | 108 | if ( !self::hasSession() ) { |
92 | 109 | return - 1; |
— | — | @@ -107,6 +124,9 @@ |
108 | 125 | return - 1; |
109 | 126 | } |
110 | 127 | |
| 128 | + /** |
| 129 | + * @return bool |
| 130 | + */ |
111 | 131 | static function purge() { |
112 | 132 | if ( !self::hasSession() ) { |
113 | 133 | return false; |
— | — | @@ -139,10 +159,16 @@ |
140 | 160 | return true; |
141 | 161 | } |
142 | 162 | |
| 163 | + /** |
| 164 | + * @return array |
| 165 | + */ |
143 | 166 | static function getCollection() { |
144 | 167 | return self::purge() ? $_SESSION['wsCollection'] : array(); |
145 | 168 | } |
146 | 169 | |
| 170 | + /** |
| 171 | + * @param $collection |
| 172 | + */ |
147 | 173 | static function setCollection( $collection ) { |
148 | 174 | $_SESSION['wsCollection'] = $collection; |
149 | 175 | self::touchSession(); |