Merge "Change if/else to a ternary operator"
[lhc/web/wiklou.git] / includes / CategoryViewer.php
index b66beae..d83e0e0 100644 (file)
@@ -1,7 +1,24 @@
 <?php
-
-if ( !defined( 'MEDIAWIKI' ) )
-       die( 1 );
+/**
+ * List and paging of category members.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
 
 class CategoryViewer extends ContextSource {
        var $limit, $from, $until,
@@ -12,7 +29,7 @@ class CategoryViewer extends ContextSource {
                $imgsNoGallery;
 
        /**
-        * @var
+        * @var Array
         */
        var $nextPage;
 
@@ -108,7 +125,7 @@ class CategoryViewer extends ContextSource {
                        $r = wfMsgExt( 'category-empty', array( 'parse' ) );
                }
 
-               $lang = $this->getLang();
+               $lang = $this->getLanguage();
                $langAttribs = array( 'lang' => $lang->getCode(), 'dir' => $lang->getDir() );
                # put a div around the headings which are in the user language
                $r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
@@ -133,6 +150,9 @@ class CategoryViewer extends ContextSource {
 
        /**
         * Add a subcategory to the internal lists, using a Category object
+        * @param $cat Category
+        * @param $sortkey
+        * @param $pageLength
         */
        function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
                // Subcategory; strip the 'Category' namespace from the link text.
@@ -156,6 +176,7 @@ class CategoryViewer extends ContextSource {
         * @deprecated since 1.17 kept for compatibility, please use addSubcategoryObject instead
         */
        function addSubcategory( Title $title, $sortkey, $pageLength ) {
+               wfDeprecated( __METHOD__, '1.17' );
                $this->addSubcategoryObject( Category::newFromTitle( $title ), $sortkey, $pageLength );
        }
 
@@ -168,7 +189,8 @@ class CategoryViewer extends ContextSource {
        *
        * @param Title $title
        * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever).
-       */
+        * @return string
+        */
        function getSubcategorySortChar( $title, $sortkey ) {
                global $wgContLang;
 
@@ -185,6 +207,10 @@ class CategoryViewer extends ContextSource {
 
        /**
         * Add a page in the image namespace
+        * @param $title Title
+        * @param $sortkey
+        * @param $pageLength
+        * @param $isRedirect bool
         */
        function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
                global $wgContLang;
@@ -211,6 +237,10 @@ class CategoryViewer extends ContextSource {
 
        /**
         * Add a miscellaneous page
+        * @param $title
+        * @param $sortkey
+        * @param $pageLength
+        * @param $isRedirect bool
         */
        function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
                global $wgContLang;
@@ -316,6 +346,9 @@ class CategoryViewer extends ContextSource {
                }
        }
 
+       /**
+        * @return string
+        */
        function getCategoryTop() {
                $r = $this->getCategoryBottom();
                return $r === ''
@@ -323,6 +356,9 @@ class CategoryViewer extends ContextSource {
                        : "<br style=\"clear:both;\"/>\n" . $r;
        }
 
+       /**
+        * @return string
+        */
        function getSubcategorySection() {
                # Don't show subcategories section if there are none.
                $r = '';
@@ -343,6 +379,9 @@ class CategoryViewer extends ContextSource {
                return $r;
        }
 
+       /**
+        * @return string
+        */
        function getPagesSection() {
                $ti = htmlspecialchars( $this->title->getText() );
                # Don't show articles section if there are none.
@@ -369,6 +408,9 @@ class CategoryViewer extends ContextSource {
                return $r;
        }
 
+       /**
+        * @return string
+        */
        function getImageSection() {
                $r = '';
                $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
@@ -408,6 +450,9 @@ class CategoryViewer extends ContextSource {
                }
        }
 
+       /**
+        * @return string
+        */
        function getCategoryBottom() {
                return '';
        }
@@ -459,10 +504,11 @@ class CategoryViewer extends ContextSource {
                # Split into three columns
                $columns = array_chunk( $columns, ceil( count( $columns ) / 3 ), true /* preserve keys */ );
 
-               $ret = '<table width="100%"><tr valign="top"><td>';
+               $ret = '<table width="100%"><tr valign="top">';
                $prevchar = null;
 
                foreach ( $columns as $column ) {
+                       $ret .= '<td width="33.3%">';
                        $colContents = array();
 
                        # Kind of like array_flip() here, but we keep duplicates in an
@@ -492,10 +538,10 @@ class CategoryViewer extends ContextSource {
                                $prevchar = $char;
                        }
 
-                       $ret .= "</td>\n<td>";
+                       $ret .= "</td>\n";
                }
 
-               $ret .= '</td></tr></table>';
+               $ret .= '</tr></table>';
                return $ret;
        }
 
@@ -567,6 +613,7 @@ class CategoryViewer extends ContextSource {
         *
         * @param Title $title: The title (usually $this->title)
         * @param String $section: Which section
+        * @return Title
         */
        private function addFragmentToTitle( $title, $section ) {
                switch ( $section ) {