X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCategoryViewer.php;h=b3741f8a7701f43e2d9a4289ee8113bf9d9c1b1d;hb=703752db95eeb841661602b9e17772885396fc29;hp=3d66b74a26a209e0be011b6f928dbd478159c4b0;hpb=d29e334c638a21ed7084b9240a216b7a30e853c3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 3d66b74a26..b3741f8a77 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -71,11 +71,12 @@ class CategoryViewer extends ContextSource { * @since 1.19 $context is a second, required parameter * @param $title Title * @param $context IContextSource - * @param $from String - * @param $until String + * @param $from Array An array with keys page, subcat, + * and file for offset of results of each section (since 1.17) + * @param $until Array An array with 3 keys for until of each section (since 1.17) * @param $query Array */ - function __construct( $title, IContextSource $context, $from = '', $until = '', $query = array() ) { + function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) { global $wgCategoryPagingLimit; $this->title = $title; $this->setContext( $context ); @@ -173,7 +174,7 @@ class CategoryViewer extends ContextSource { /** * Add a subcategory to the internal lists, using a title object - * @deprecated since 1.17 kept for compatibility, please use addSubcategoryObject instead + * @deprecated since 1.17 kept for compatibility, use addSubcategoryObject instead */ function addSubcategory( Title $title, $sortkey, $pageLength ) { wfDeprecated( __METHOD__, '1.17' ); @@ -181,14 +182,14 @@ class CategoryViewer extends ContextSource { } /** - * Get the character to be used for sorting subcategories. - * If there's a link from Category:A to Category:B, the sortkey of the resulting - * entry in the categorylinks table is Category:A, not A, which it SHOULD be. - * Workaround: If sortkey == "Category:".$title, than use $title for sorting, - * else use sortkey... - * - * @param Title $title - * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever). + * Get the character to be used for sorting subcategories. + * If there's a link from Category:A to Category:B, the sortkey of the resulting + * entry in the categorylinks table is Category:A, not A, which it SHOULD be. + * Workaround: If sortkey == "Category:".$title, than use $title for sorting, + * else use sortkey... + * + * @param Title $title + * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever). * @return string */ function getSubcategorySortChar( $title, $sortkey ) { @@ -259,15 +260,15 @@ class CategoryViewer extends ContextSource { function finaliseCategoryState() { if ( $this->flip['subcat'] ) { - $this->children = array_reverse( $this->children ); + $this->children = array_reverse( $this->children ); $this->children_start_char = array_reverse( $this->children_start_char ); } if ( $this->flip['page'] ) { - $this->articles = array_reverse( $this->articles ); + $this->articles = array_reverse( $this->articles ); $this->articles_start_char = array_reverse( $this->articles_start_char ); } if ( !$this->showGallery && $this->flip['file'] ) { - $this->imgsNoGallery = array_reverse( $this->imgsNoGallery ); + $this->imgsNoGallery = array_reverse( $this->imgsNoGallery ); $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char ); } } @@ -302,7 +303,7 @@ class CategoryViewer extends ContextSource { 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files', 'cl_sortkey_prefix', 'cl_collation' ), - array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ), + array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ), __METHOD__, array( 'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ), @@ -310,7 +311,7 @@ class CategoryViewer extends ContextSource { 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey', ), array( - 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ), + 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ), 'category' => array( 'LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY ) ) ); @@ -469,7 +470,7 @@ class CategoryViewer extends ContextSource { */ function formatList( $articles, $articles_start_char, $cutoff = 6 ) { $list = ''; - if ( count ( $articles ) > $cutoff ) { + if ( count( $articles ) > $cutoff ) { $list = self::columnList( $articles, $articles_start_char ); } elseif ( count( $articles ) > 0 ) { // for short lists of articles in categories. @@ -478,7 +479,7 @@ class CategoryViewer extends ContextSource { $pageLang = $this->title->getPageLanguage(); $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-'.$pageLang->getDir() ); + 'class' => 'mw-content-' . $pageLang->getDir() ); $list = Html::rawElement( 'div', $attribs, $list ); return $list; @@ -604,7 +605,7 @@ class CategoryViewer extends ContextSource { ); } - return $this->msg('categoryviewer-pagedlinks')->rawParams($prevLink, $nextLink)->escaped(); + return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped(); } /** @@ -635,6 +636,7 @@ class CategoryViewer extends ContextSource { return Title::makeTitle( $title->getNamespace(), $title->getDBkey(), $fragment ); } + /** * What to do if the category table conflicts with the number of results * returned? This function says what. Each type is considered independently @@ -676,8 +678,9 @@ class CategoryViewer extends ContextSource { $fromOrUntil = true; } - if ( $dbcnt == $rescnt || ( ( $rescnt == $this->limit || $fromOrUntil ) - && $dbcnt > $rescnt ) ) { + if ( $dbcnt == $rescnt || + ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt ) + ) { # Case 1: seems sane. $totalcnt = $dbcnt; } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {