mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-30 11:06:55 +00:00
use wgMsgXXX consistently. Add support for {{PLURAL}} where appropriate (bug 14690).
This commit is contained in:
parent
30739f8a50
commit
2696d25af4
|
@ -118,7 +118,7 @@ class CategoryTreeCategoryViewer extends CategoryViewer {
|
|||
}
|
||||
}
|
||||
return $r;
|
||||
}*/
|
||||
}
|
||||
|
||||
function makeShowAsLink( $targetValue, $currentValue ) {
|
||||
$msg = htmlspecialchars( CategoryTree::msg( "show-$targetValue" ) );
|
||||
|
@ -128,7 +128,7 @@ class CategoryTreeCategoryViewer extends CategoryViewer {
|
|||
} else {
|
||||
return $this->getSkin()->makeKnownLinkObj( $this->title, $msg, "showas=$targetValue" );
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
function clearCategoryState() {
|
||||
$this->child_cats = array();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -101,7 +101,7 @@ class CategoryTree {
|
|||
*/
|
||||
static function setHeaders( &$outputPage ) {
|
||||
global $wgJsMimeType, $wgScriptPath, $wgContLang, $wgCategoryTreeExtPath, $wgCategoryTreeVersion;
|
||||
wfLoadExtensionMessages( 'CategoryTree' );
|
||||
self::init();
|
||||
|
||||
# Register css file for CategoryTree
|
||||
$outputPage->addLink(
|
||||
|
@ -132,17 +132,17 @@ class CategoryTree {
|
|||
# Add messages
|
||||
$outputPage->addScript(
|
||||
" <script type=\"{$wgJsMimeType}\">
|
||||
var categoryTreeCollapseMsg = \"".Xml::escapeJsString(self::msg('collapse'))."\";
|
||||
var categoryTreeExpandMsg = \"".Xml::escapeJsString(self::msg('expand'))."\";
|
||||
var categoryTreeCollapseBulletMsg = \"".Xml::escapeJsString(self::msg('collapse-bullet'))."\";
|
||||
var categoryTreeExpandBulletMsg = \"".Xml::escapeJsString(self::msg('expand-bullet'))."\";
|
||||
var categoryTreeLoadMsg = \"".Xml::escapeJsString(self::msg('load'))."\";
|
||||
var categoryTreeLoadingMsg = \"".Xml::escapeJsString(self::msg('loading'))."\";
|
||||
var categoryTreeNothingFoundMsg = \"".Xml::escapeJsString(self::msg('nothing-found'))."\";
|
||||
var categoryTreeNoSubcategoriesMsg = \"".Xml::escapeJsString(self::msg('no-subcategories'))."\";
|
||||
var categoryTreeNoPagesMsg = \"".Xml::escapeJsString(self::msg('no-pages'))."\";
|
||||
var categoryTreeErrorMsg = \"".Xml::escapeJsString(self::msg('error'))."\";
|
||||
var categoryTreeRetryMsg = \"".Xml::escapeJsString(self::msg('retry'))."\";
|
||||
var categoryTreeCollapseMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-collapse'))."\";
|
||||
var categoryTreeExpandMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-expand'))."\";
|
||||
var categoryTreeCollapseBulletMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-collapse-bullet'))."\";
|
||||
var categoryTreeExpandBulletMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-expand-bullet'))."\";
|
||||
var categoryTreeLoadMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-load'))."\";
|
||||
var categoryTreeLoadingMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-loading'))."\";
|
||||
var categoryTreeNothingFoundMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-nothing-found'))."\";
|
||||
var categoryTreeNoSubcategoriesMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-no-subcategories'))."\";
|
||||
var categoryTreeNoPagesMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-no-pages'))."\";
|
||||
var categoryTreeErrorMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-error'))."\";
|
||||
var categoryTreeRetryMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-retry'))."\";
|
||||
</script>\n"
|
||||
);
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ class CategoryTree {
|
|||
|
||||
if ( !$title->getArticleID() ) {
|
||||
$html .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) );
|
||||
$html .= self::msg( 'not-found' , htmlspecialchars( $category ) );
|
||||
$html .= wfMsgExt( 'categorytree-not-found', 'parserinline', htmlspecialchars( $category ) );
|
||||
$html .= Xml::closeElement( 'span' );
|
||||
}
|
||||
else {
|
||||
|
@ -483,6 +483,8 @@ class CategoryTree {
|
|||
function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
|
||||
static $uniq = 0;
|
||||
|
||||
$this->init(); # initialize messages
|
||||
|
||||
$mode = $this->getOption('mode');
|
||||
$load = false;
|
||||
|
||||
|
@ -551,26 +553,26 @@ class CategoryTree {
|
|||
|
||||
if ( $count === 0 ) {
|
||||
$tag = 'span';
|
||||
$txt = $this->msg('empty-bullet');
|
||||
$txt = wfMsgNoTrans( 'categorytree-empty-bullet' );
|
||||
}
|
||||
else if ( $children == 0 || $loadchildren ) {
|
||||
$tag = 'a';
|
||||
$txt = $this->msg('expand-bullet');
|
||||
$txt = wfMsgNoTrans( 'categorytree-expand-bullet' );
|
||||
$linkattr[ 'onclick' ] = "this.href='javascript:void(0)'; categoryTreeExpandNode('".Xml::escapeJsString($key)."',".$this->getOptionsAsJsStructure().",this);";
|
||||
# Don't load this message for ajax requests, so that we don't have to initialise $wgLang
|
||||
$linkattr[ 'title' ] = $this->mIsAjaxRequest ? '##LOAD##' : self::msg('expand');
|
||||
$linkattr[ 'title' ] = $this->mIsAjaxRequest ? '##LOAD##' : wfMsgNoTrans('categorytree-expand');
|
||||
}
|
||||
else {
|
||||
$tag = 'a';
|
||||
$txt = $this->msg('collapse-bullet');
|
||||
$txt = wfMsgNoTrans( 'categorytree-collapse-bullet' );
|
||||
$linkattr[ 'onclick' ] = "this.href='javascript:void(0)'; categoryTreeCollapseNode('".Xml::escapeJsString($key)."',".$this->getOptionsAsJsStructure().",this);";
|
||||
$linkattr[ 'title' ] = self::msg('collapse');
|
||||
$linkattr[ 'title' ] = wfMsgNoTrans('categorytree-collapse');
|
||||
$linkattr[ 'class' ] .= ' CategoryTreeLoaded';
|
||||
}
|
||||
|
||||
$s .= Xml::openElement( $tag, $linkattr ) . $txt . Xml::closeElement( $tag ) . ' ';
|
||||
} else {
|
||||
$s .= $this->msg('page-bullet');
|
||||
$s .= wfMsgNoTrans( 'categorytree-page-bullet' );
|
||||
}
|
||||
|
||||
$s .= Xml::closeElement( 'span' );
|
||||
|
@ -581,7 +583,7 @@ class CategoryTree {
|
|||
$pages = $cat->getPageCount() - $cat->getSubcatCount() - $cat->getFileCount();
|
||||
|
||||
$attr = array(
|
||||
'title' => $this->msg( 'member-counts', $cat->getSubcatCount(), $pages , $cat->getFileCount() )
|
||||
'title' => wfMsgExt( 'categorytree-member-counts', 'parsemag', $cat->getSubcatCount(), $pages , $cat->getFileCount() )
|
||||
);
|
||||
|
||||
$s .= Xml::element( 'span', $attr, ' (' . $count . ')' );
|
||||
|
@ -630,21 +632,16 @@ class CategoryTree {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a CategoryTree message, "categorytree-" prefix added automatically
|
||||
* Initialize. Load messages, if not ajax request.
|
||||
*/
|
||||
static function msg( $msg /*, ...*/ ) {
|
||||
wfLoadExtensionMessages( 'CategoryTree' );
|
||||
static function init( ) {
|
||||
static $initialized = false;
|
||||
if ( $initialized ) return;
|
||||
$initialized = true;
|
||||
|
||||
if ( $msg === false ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
$msg = array_shift( $args );
|
||||
if ( $msg == '' ) {
|
||||
return wfMsgReal( $msg, $args );
|
||||
} else {
|
||||
return wfMsgReal( "categorytree-$msg", $args );
|
||||
}
|
||||
#NOTE: don't load messages for ajax requests. Ajax requests are cachable and language-neutral.
|
||||
# Messages used in JS are defined by setHeaders
|
||||
if ( !isset( $this ) || !$this->mIsAjaxRequest )
|
||||
wfLoadExtensionMessages( 'CategoryTree' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ class CategoryTreePage extends SpecialPage {
|
|||
|
||||
$this->tree = new CategoryTree( $options );
|
||||
|
||||
$wgOut->addWikiText( wfMsgNoTrans( 'categorytree-header' ) );
|
||||
$wgOut->addWikiMsg( 'categorytree-header' );
|
||||
|
||||
$wgOut->addHtml( $this->makeInputForm() );
|
||||
$this->executeInputForm();
|
||||
|
||||
if( $this->target !== '' && $this->target !== NULL ) {
|
||||
CategoryTree::setHeaders( $wgOut );
|
||||
|
@ -74,28 +74,27 @@ class CategoryTreePage extends SpecialPage {
|
|||
$title = CategoryTree::makeTitle( $this->target );
|
||||
|
||||
if ( $title && $title->getArticleID() ) {
|
||||
$html = Xml::openElement( 'div', array( 'class' => 'CategoryTreeParents' ) );
|
||||
$html .= wfMsg( 'categorytree-parents' ) . ': ';
|
||||
$wgOut->addHtml( Xml::openElement( 'div', array( 'class' => 'CategoryTreeParents' ) ) );
|
||||
$wgOut->addHtml( wfMsgExt( 'categorytree-parents', 'parseinline' ) );
|
||||
$wgOut->addHtml( ': ' );
|
||||
|
||||
$parents = $this->tree->renderParents( $title );
|
||||
|
||||
if ( $parents == '' ) {
|
||||
$html .= wfMsg( 'categorytree-nothing-found' );
|
||||
$wgOut->addHtml( wfMsgExt( 'categorytree-nothing-found', 'parseinline' ) );
|
||||
} else {
|
||||
$html .= $parents;
|
||||
$wgOut->addHtml( $parents );
|
||||
}
|
||||
|
||||
$html .= Xml::closeElement( 'div' );
|
||||
$wgOut->addHtml( Xml::closeElement( 'div' ) );
|
||||
|
||||
$html .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeResult' ) );
|
||||
$html .= $this->tree->renderNode( $title, 1 ) .
|
||||
$html .= Xml::closeElement( 'div' );
|
||||
|
||||
$wgOut->addHtml( $html );
|
||||
$wgOut->addHtml( Xml::openElement( 'div', array( 'class' => 'CategoryTreeResult' ) ) );
|
||||
$wgOut->addHtml( $this->tree->renderNode( $title, 1 ) );
|
||||
$wgOut->addHtml( Xml::closeElement( 'div' ) );
|
||||
}
|
||||
else {
|
||||
$wgOut->addHtml( Xml::openElement( 'div', array( 'class' => 'CategoryTreeNotice' ) ) );
|
||||
$wgOut->addWikiText( wfMsg( 'categorytree-not-found' , $this->target ) );
|
||||
$wgOut->addHtml( wfMsgExt( 'categorytree-not-found', 'parseinline' , $this->target ) );
|
||||
$wgOut->addHtml( Xml::closeElement( 'div' ) );
|
||||
}
|
||||
}
|
||||
|
@ -105,24 +104,23 @@ class CategoryTreePage extends SpecialPage {
|
|||
/**
|
||||
* Input form for entering a category
|
||||
*/
|
||||
function makeInputForm() {
|
||||
global $wgScript;
|
||||
function executeInputForm() {
|
||||
global $wgScript, $wgOut;
|
||||
$thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
|
||||
$mode = $this->getOption('mode');
|
||||
|
||||
$form = Xml::openElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-categorytree-form' ) ) .
|
||||
Xml::openElement( 'fieldset' ) .
|
||||
Xml::element( 'legend', null, wfMsg( 'categorytree-legend' ) ) .
|
||||
Xml::hidden( 'title', $thisTitle->getPrefixedDbKey() ) .
|
||||
Xml::inputLabel( wfMsg( 'categorytree-category' ), 'target', 'target', 20, $this->target ) . ' ' .
|
||||
Xml::openElement( 'select', array( 'name' => 'mode' ) ) .
|
||||
Xml::option( wfMsg( 'categorytree-mode-categories' ), 'categories', $mode == CT_MODE_CATEGORIES ? true : false ) .
|
||||
Xml::option( wfMsg( 'categorytree-mode-pages' ), 'pages', $mode == CT_MODE_PAGES ? true : false ) .
|
||||
Xml::option( wfMsg( 'categorytree-mode-all' ), 'all', $mode == CT_MODE_ALL ? true : false ) .
|
||||
Xml::closeElement( 'select' ) . ' ' .
|
||||
Xml::submitButton( wfMsg( 'categorytree-go' ), array( 'name' => 'dotree' ) ) .
|
||||
Xml::closeElement( 'fieldset' ) .
|
||||
Xml::closeElement( 'form' );
|
||||
return $form;
|
||||
$wgOut->addHTML( Xml::openElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-categorytree-form' ) ) );
|
||||
$wgOut->addHTML( Xml::openElement( 'fieldset' ) );
|
||||
$wgOut->addHTML( Xml::element( 'legend', null, wfMsgNoTrans( 'categorytree-legend' ) ) );
|
||||
$wgOut->addHTML( Xml::hidden( 'title', $thisTitle->getPrefixedDbKey() ) );
|
||||
$wgOut->addHTML( Xml::inputLabel( wfMsgNoTrans( 'categorytree-category' ), 'target', 'target', 20, $this->target ) . ' ' );
|
||||
$wgOut->addHTML( Xml::openElement( 'select', array( 'name' => 'mode' ) ) );
|
||||
$wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-categories' ), 'categories', $mode == CT_MODE_CATEGORIES ? true : false ) );
|
||||
$wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-pages' ), 'pages', $mode == CT_MODE_PAGES ? true : false ) );
|
||||
$wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-all' ), 'all', $mode == CT_MODE_ALL ? true : false ) );
|
||||
$wgOut->addHTML( Xml::closeElement( 'select' ) . ' ' );
|
||||
$wgOut->addHTML( Xml::submitButton( wfMsgNoTrans( 'categorytree-go' ), array( 'name' => 'dotree' ) ) );
|
||||
$wgOut->addHTML( Xml::closeElement( 'fieldset' ) );
|
||||
$wgOut->addHTML( Xml::closeElement( 'form' ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue