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.
*
$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 ;
<div class='templatesUsed'>
{$formattedtemplates}
</div>
-" );
+<div class='hiddencats'>
+{$formattedhiddencats}
+</div>
+");
/**
* To make it harder for someone to slip a user a page
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 = '<div class="mw-hiddenCategoriesExplanation">';
+ $outText .= wfMsgExt( 'hiddencategories', array( 'parse' ) );
+ $outText .= '</div><ul>';
+
+ foreach ( $hiddencats as $titleObj ) {
+ $outText .= '<li>' . $sk->makeKnownLinkObj( $titleObj ) . '</li>'; # If it's hidden, it must exist - no need to check with a LinkBatch
+ }
+ $outText .= '</ul>';
+ }
+ wfProfileOut( __METHOD__ );
+ return $outText;
+ }
/**
* Format a size in bytes for output, using an appropriate
'templatesusedsection' => 'Templates used in this section:',
'template-protected' => '(protected)',
'template-semiprotected' => '(semi-protected)',
+'hiddencategories' => 'Hidden categories this page is a member of:',
'edittools' => '<!-- Text here will be shown below edit and upload forms. -->', # 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.