From: Andrew Garrett Date: Mon, 25 Feb 2008 13:38:21 +0000 (+0000) Subject: For pages with hidden categories, add a list of these categories down the bottom... X-Git-Tag: 1.31.0-rc.0~49364 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=5248b38e73e36932965723029c4aeae8d31b6475;p=lhc%2Fweb%2Fwiklou.git For pages with hidden categories, add a list of these categories down the bottom of the "edit" page - underneath the list of included templates. --- diff --git a/includes/Article.php b/includes/Article.php index 6d893d6a96..68e561ab06 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -3071,6 +3071,36 @@ class Article { return $result; } + /** + * Returns a list of hidden categories this page is a member of. + * Uses the page_props and categorylinks tables. + * + * @return array Array of Title objects + */ + function getHiddenCategories() { + $result = array(); + $id = $this->mTitle->getArticleID(); + if( $id == 0 ) { + return array(); + } + + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ), + array( 'cl_to' ), + array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', + 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'), + 'Article:getHiddenCategories' ); + if ( false !== $res ) { + if ( $dbr->numRows( $res ) ) { + while ( $row = $dbr->fetchObject( $res ) ) { + $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to ); + } + } + } + $dbr->freeResult( $res ); + return $result; + } + /** * Return an auto-generated summary if the text provided is a redirect. * diff --git a/includes/EditPage.php b/includes/EditPage.php index 45ca48d02a..2bb9e72b8a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1248,6 +1248,9 @@ class EditPage { $templates = ($this->preview || $this->section != '') ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates(); $formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != ''); + $hiddencats = $this->mArticle->getHiddenCategories(); + $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats ); + global $wgUseMetadataEdit ; if ( $wgUseMetadataEdit ) { $metadata = $this->mMetaData ; @@ -1346,7 +1349,10 @@ END
{$formattedtemplates}
-" ); +
+{$formattedhiddencats} +
+"); /** * To make it harder for someone to slip a user a page diff --git a/includes/Linker.php b/includes/Linker.php index ea74fa527d..a27c6c7a32 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1359,6 +1359,35 @@ class Linker { wfProfileOut( __METHOD__ ); return $outText; } + + /** + * Returns HTML for the "hidden categories on this page" list. + * + * @param array $hiddencats Array of hidden categories from Article::getHiddenCategories + * or similar + * @return string HTML output + */ + public function formatHiddenCategories( $hiddencats) { + global $wgUser; + wfProfileIn( __METHOD__ ); + + $sk = $wgUser->getSkin(); + + $outText = ''; + if ( count( $hiddencats ) > 0 ) { + # Construct the HTML + $outText = '
'; + $outText .= wfMsgExt( 'hiddencategories', array( 'parse' ) ); + $outText .= '
'; + } + wfProfileOut( __METHOD__ ); + return $outText; + } /** * Format a size in bytes for output, using an appropriate diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5249ef74c6..a144f8f388 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1063,6 +1063,7 @@ Please consider breaking the page into smaller sections.', 'templatesusedsection' => 'Templates used in this section:', 'template-protected' => '(protected)', 'template-semiprotected' => '(semi-protected)', +'hiddencategories' => 'Hidden categories this page is a member of:', 'edittools' => '', # only translate this message to other languages if you have to change it 'nocreatetitle' => 'Page creation limited', 'nocreatetext' => '{{SITENAME}} has restricted the ability to create new pages.