* to ensure that client-side caches don't keep obsolete copies of global
* styles.
*/
-$wgStyleVersion = '116';
+$wgStyleVersion = '117';
# Server-side caching:
* Add an array of categories, with names in the keys
*/
public function addCategoryLinks( $categories ) {
- global $wgUser, $wgContLang, $wgTitle;
+ global $wgUser, $wgContLang;
- if ( !is_array( $categories ) ) {
- return;
- }
- if ( count( $categories ) == 0 ) {
+ if ( !is_array( $categories ) || count( $categories ) == 0 ) {
return;
}
+
# Add the links to a LinkBatch
$arr = array( NS_CATEGORY => $categories );
$lb = new LinkBatch;
# Fetch existence plus the hiddencat property
$dbr = wfGetDB( DB_SLAVE );
$pageTable = $dbr->tableName( 'page' );
- $propsTable = $dbr->tableName( 'page_props' );
$where = $lb->constructSet( 'page', $dbr );
+ $propsTable = $dbr->tableName( 'page_props' );
$sql = "SELECT page_id, page_namespace, page_title, pp_value FROM $pageTable LEFT JOIN $propsTable " .
" ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
$res = $dbr->query( $sql, __METHOD__ );
# Add the results to the link cache
$lb->addResultToCache( LinkCache::singleton(), $res );
- # Remove categories with hiddencat
+ # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
+ $categories = array_combine( array_keys( $categories ),
+ array_fill( 0, count( $categories ), 'normal' ) );
+
+ # Mark hidden categories
foreach ( $res as $row ) {
- if ( isset( $row->pp_value ) and $wgTitle->getNamespace() != NS_CATEGORY ) {
- unset( $categories[$row->page_title] );
+ if ( isset( $row->pp_value ) ) {
+ $categories[$row->page_title] = 'hidden';
}
}
-
+
# Add the remaining categories to the skin
$sk = $wgUser->getSkin();
- foreach ( $categories as $category => $unused ) {
+ foreach ( $categories as $category => $type ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
$text = $wgContLang->convertHtml( $title->getText() );
- $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
+ $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
}
}
}
if ( isset( $this->mDoubleUnderscores['hiddencat'] ) ) {
$this->mOutput->setProperty( 'hiddencat', 'y' );
+
+ $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsg( 'hidden-category-category' ) );
+ if ( $containerCategory ) {
+ $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() );
+ } else {
+ wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" );
+ }
}
return $text;
}
global $wgScript, $wgStylePath, $wgUser;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
- global $wgBreakFrames, $wgRequest;
+ global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
'wgArticlePath' => $wgArticlePath,
'wgScriptPath' => $wgScriptPath,
'wgScript' => $wgScript,
+ 'wgVariantArticlePath' => $wgVariantArticlePath,
+ 'wgActionPaths' => $wgActionPaths,
'wgServer' => $wgServer,
'wgCanonicalNamespace' => $nsname,
'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ),
function getCategoryLinks () {
global $wgOut, $wgTitle, $wgUseCategoryBrowser;
- global $wgContLang;
+ global $wgContLang, $wgUser;
if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
$dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$embed = "<span dir='$dir'>";
$pop = '</span>';
- $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop;
- $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks ) );
- $s = $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
- . ': ' . $t;
+ $allCats = $wgOut->getCategoryLinks();
+ $s = '';
+ if ( !empty( $allCats['normal'] ) ) {
+ $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+
+ $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $allCats['normal'] ) );
+ $s .= '<div id="mw-normal-catlinks">' .
+ $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
+ . ': ' . $t . '</div>';
+ }
+
+ # Hidden categories
+ if ( isset( $allCats['hidden'] ) ) {
+ if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
+ $class ='mw-hidden-cats-user-shown';
+ } elseif ( $wgTitle->getNamespace() == NS_CATEGORY ) {
+ $class = 'mw-hidden-cats-ns-shown';
+ } else {
+ $class = 'mw-hidden-cats-hidden';
+ }
+ $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
+ wfMsgExt( 'hidden-categories', array( 'parsemag', 'escape' ), count( $allCats['hidden'] ) ) .
+ ': ' . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
+ "</div>";
+ }
# optional 'dmoz-like' category browser. Will be shown under the list
# of categories an article belong to
function getCategories() {
$catlinks=$this->getCategoryLinks();
if(!empty($catlinks)) {
- return "<p class='catlinks'>{$catlinks}</p>";
+ return "<div class='catlinks'>{$catlinks}</div>";
}
}
'watchlisthideminor',
'ccmeonemails',
'diffonly',
+ 'showhiddencats',
);
/**
'tog-nolangconversion' => 'Disable variants conversion', # only translate this message to other languages if you have to change it
'tog-ccmeonemails' => 'Send me copies of emails I send to other users',
'tog-diffonly' => "Don't show page content below diffs",
+'tog-showhiddencats' => 'Show hidden categories',
'underline-always' => 'Always',
'underline-never' => 'Never',
'subcategories' => 'Subcategories',
'category-media-header' => 'Media in category "$1"',
'category-empty' => "''This category currently contains no pages or media.''",
+'hidden-categories' => '{{PLURAL:$1|Hidden category|Hidden categories}}',
+'hidden-category-category' => 'Hidden categories', # Name of the category where hidden categories will be listed
'linkprefix' => '/^(.*?)([a-zA-Z\x80-\xff]+)$/sD', # only translate this message to other languages if you have to change it
'mainpagetext' => "<big>'''MediaWiki has been successfully installed.'''</big>",
body.ltr .thumbcaption { text-align:left; }
body.ltr .magnify { float:right; }
+
+/**
+ * Hidden categories
+ */
+.mw-hidden-cats-hidden { display: none; }