listFiles() returns false when empty. Special:UplaodStash now deals with that correctly
[lhc/web/wiklou.git] / includes / WikiCategoryPage.php
1 <?php
2 /**
3 * Special handling for category pages
4 */
5 class WikiCategoryPage extends WikiPage {
6 /**
7 * Constructor from a page id
8 * @param $id Int article ID to load
9 *
10 * @return WikiCategoryPage
11 */
12 public static function newFromID( $id ) {
13 $t = Title::newFromID( $id );
14 # @todo FIXME: Doesn't inherit right
15 return $t == null ? null : new self( $t );
16 # return $t == null ? null : new static( $t ); // PHP 5.3
17 }
18
19 /**
20 * Don't return a 404 for categories in use.
21 * In use defined as: either the actual page exists
22 * or the category currently has members.
23 *
24 * @return bool
25 */
26 public function hasViewableContent() {
27 if ( parent::hasViewableContent() ) {
28 return true;
29 } else {
30 $cat = Category::newFromTitle( $this->mTitle );
31 // If any of these are not 0, then has members
32 if ( $cat->getPageCount()
33 || $cat->getSubcatCount()
34 || $cat->getFileCount()
35 ) {
36 return true;
37 }
38 }
39 return false;
40 }
41 }