Index: trunk/phase3/includes/Title.php |
— | — | @@ -3530,6 +3530,31 @@ |
3531 | 3531 | return !$this->isExternal() && MWNamespace::isWatchable( $this->getNamespace() ); |
3532 | 3532 | } |
3533 | 3533 | |
| 3534 | + /* |
| 3535 | + * Returns whether an article is in the specific category |
| 3536 | + * |
| 3537 | + * @param $category String: The category name (without Category: Prefix) |
| 3538 | + * |
| 3539 | + * @return bool |
| 3540 | + */ |
| 3541 | + public function isInCategory( $category ) { |
| 3542 | + $dbr = wfGetDB( DB_SLAVE ); |
| 3543 | + $res = $dbr->select( |
| 3544 | + 'categorylinks', |
| 3545 | + '*', |
| 3546 | + array( |
| 3547 | + 'cl_from' => $this->getArticleId(), |
| 3548 | + 'cl_to' => $category, |
| 3549 | + ), |
| 3550 | + __METHOD__, |
| 3551 | + array( |
| 3552 | + 'LIMIT' => 1 |
| 3553 | + ) |
| 3554 | + ); |
| 3555 | + |
| 3556 | + return ( $dbr->numRows( $res ) > 0 ); |
| 3557 | + } |
| 3558 | + |
3534 | 3559 | /** |
3535 | 3560 | * Get categories to which this Title belongs and return an array of |
3536 | 3561 | * categories' names. |
— | — | @@ -3553,9 +3578,10 @@ |
3554 | 3579 | $res = $dbr->query( $sql ); |
3555 | 3580 | |
3556 | 3581 | if ( $dbr->numRows( $res ) > 0 ) { |
3557 | | - foreach ( $res as $row ) |
| 3582 | + foreach ( $res as $row ) { |
3558 | 3583 | // $data[] = Title::newFromText($wgContLang->getNSText ( NS_CATEGORY ).':'.$row->cl_to); |
3559 | 3584 | $data[$wgContLang->getNSText( NS_CATEGORY ) . ':' . $row->cl_to] = $this->getFullText(); |
| 3585 | + } |
3560 | 3586 | } else { |
3561 | 3587 | $data = array(); |
3562 | 3588 | } |