Support WAI-ARIA's role="presentation" inside of WikiText.
[lhc/web/wiklou.git] / includes / CategoryViewer.php
index 3d66b74..7678ffe 100644 (file)
@@ -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,8 +311,11 @@ class CategoryViewer extends ContextSource {
                                        'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
                                ),
                                array(
-                                       'categorylinks'  => array( 'INNER JOIN', 'cl_from = page_id' ),
-                                       'category' => array( 'LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY )
+                                       'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
+                                       'category' => array( 'LEFT JOIN', array(
+                                               'cat_title = page_title',
+                                               'page_namespace' => NS_CATEGORY
+                                       ))
                                )
                        );
 
@@ -469,7 +473,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 +482,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 +608,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 +639,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 +681,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 ) {