* Add a nice fieldset around the input form

* Use proper XML function
This commit is contained in:
Raimond Spekking 2008-03-18 17:38:32 +00:00
parent af1e2e32c0
commit 56bd285d84
4 changed files with 71 additions and 57 deletions

View file

@ -1,27 +1,28 @@
<?php
/**
* Internationalisation file for extension Gadgets.
* Internationalisation file for extension CategoryTree.
*
* @addtogroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2006-2008 Daniel Kinzler
* @licence GNU General Public Licence 2.0 or later
* @license GNU General Public Licence 2.0 or later
*/
$messages = array();
/* English
/** English
* @author Daniel Kinzler, brightbyte.de
*/
$messages['en'] = array(
'categorytree' => 'CategoryTree',
'categorytree-tab' => 'Tree',
'categorytree-legend' => 'Show category tree',
'categorytree-desc' => 'AJAX based gadget to display the [[Special:CategoryTree|category structure]] of a wiki',
'categorytree-header' => 'Enter a category name to see its contents as a tree structure.
Note that this requires advanced JavaScript functionality known as AJAX.
If you have a very old browser, or have JavaScript disabled, it will not work.',
'categorytree-category' => 'Category',
'categorytree-category' => 'Category:',
'categorytree-go' => 'Show Tree',
'categorytree-parents' => 'Parents',
@ -461,15 +462,18 @@ $messages['da'] = array(
'categorytree-too-many-subcats' => 'Kan ikke vise underkategorier som træ, der er for mange.',
);
/** German (Deutsch) */
/** German (Deutsch)
* @author Raimond Spekking
*/
$messages['de'] = array(
'categorytree' => 'Kategorienbaum',
'categorytree-tab' => 'Baum',
'categorytree-legend' => 'Zeige Kategorienbaum',
'categorytree-desc' => 'AJAX-basiertes Gadget, um sich die [[Special:CategoryTree|Kategorien-Struktur]] eines Wikis anzuzeigen',
'categorytree-header' => 'Zeigt für die angegebene Kategorie die Unterkategorien in einer Baumstruktur.
Diese Seite benötigt bestimmte JavaScript-Funktionen (AJAX).
In sehr alten Browsern, oder wenn JavaScript abgeschaltet ist, funktioniert diese Seite eventuell nicht.',
'categorytree-category' => 'Kategorie',
'categorytree-category' => 'Kategorie:',
'categorytree-go' => 'Laden',
'categorytree-parents' => 'Oberkategorien',
'categorytree-mode-categories' => 'nur Kategorien',
@ -482,7 +486,7 @@ In sehr alten Browsern, oder wenn JavaScript abgeschaltet ist, funktioniert dies
'categorytree-nothing-found' => 'Nichts gefunden',
'categorytree-no-subcategories' => 'Keine Unterkategorien',
'categorytree-no-pages' => 'Keine Seite oder Unterkategorien',
'categorytree-not-found' => "Kategorie ''$1'' nicht gefunden",
'categorytree-not-found' => "Kategorie $1“ nicht gefunden",
'categorytree-error' => 'Probleme beim Laden der Daten.',
'categorytree-retry' => 'Bitte warte einen Moment und versuche es dann erneut.',
'categorytree-show-list' => 'Zeige als Liste',
@ -490,6 +494,13 @@ In sehr alten Browsern, oder wenn JavaScript abgeschaltet ist, funktioniert dies
'categorytree-too-many-subcats' => 'Unterkategorien können nicht als Baum dargestellt werden, da es zuviele sind.',
);
/** German - formal address (Deutsch - förmliche Anrede)
* @author Raimond Spekking
*/
$messages['de-formal'] = array(
'categorytree-retry' => 'Bitte warten Sie einen Moment und versuchen Sie es dann erneut.',
);
/** Zazaki (Zazaki)
* @author SPQRobin
*/

View file

@ -7,7 +7,7 @@
* @addtogroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2006-2007 Daniel Kinzler
* @licence GNU General Public Licence 2.0 or later
* @license GNU General Public Licence 2.0 or later
*/
if( !defined( 'MEDIAWIKI' ) ) {

View file

@ -7,7 +7,7 @@
* @addtogroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2006-2007 Daniel Kinzler
* @licence GNU General Public Licence 2.0 or later
* @license GNU General Public Licence 2.0 or later
*/
if( !defined( 'MEDIAWIKI' ) ) {
@ -133,12 +133,12 @@ class CategoryTree {
if ( $title === false || $title === NULL ) return false;
$html = '';
$html .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeTag', 'style' => $style ) );
$html .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeTag', 'style' => $style ) );
if ( !$title->getArticleID() ) {
$html .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeNotice' ) );
$html .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) );
$html .= self::msg( 'not-found' , htmlspecialchars( $category ) );
$html .= wfCloseElement( 'span' );
$html .= Xml::closeElement( 'span' );
}
else {
if ( !$hideroot ) $html .= CategoryTree::renderNode( $title, $mode, $depth>0, $wgCategoryTreeDynamicTag, $depth-1 );
@ -147,13 +147,13 @@ class CategoryTree {
$uniq += 1;
$load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );
$html .= wfOpenElement( 'script', array( 'type' => 'text/javascript', 'id' => $load ) );
$html .= Xml::openElement( 'script', array( 'type' => 'text/javascript', 'id' => $load ) );
$html .= 'categoryTreeLoadChildren("' . Xml::escapeJsString( $title->getDBkey() ) . '", "' . $mode . '", document.getElementById("' . $load . '").parentNode );';
$html .= wfCloseElement( 'script' );
$html .= Xml::closeElement( 'script' );
}
}
$html .= wfCloseElement( 'div' );
$html .= Xml::closeElement( 'div' );
$html .= "\n\t\t";
return $html;
@ -260,15 +260,15 @@ class CategoryTree {
$trans = ''; #place holder for when translated titles are available
$label = htmlspecialchars( $t->getText() );
if ( $trans && $trans!=$label ) $label.= ' ' . wfElement( 'i', array( 'class' => 'translation'), $trans );
if ( $trans && $trans!=$label ) $label.= ' ' . Xml::element( 'i', array( 'class' => 'translation'), $trans );
$wikiLink = $special->getLocalURL( 'target=' . $t->getPartialURL() . '&mode=' . $mode );
if ( $s !== '' ) $s .= ' | ';
$s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeItem' ) );
$s .= wfOpenElement( 'a', array( 'class' => 'CategoryTreeLabel', 'href' => $wikiLink ) ) . $label . wfCloseElement( 'a' );
$s .= wfCloseElement( 'span' );
$s .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeItem' ) );
$s .= Xml::openElement( 'a', array( 'class' => 'CategoryTreeLabel', 'href' => $wikiLink ) ) . $label . Xml::closeElement( 'a' );
$s .= Xml::closeElement( 'span' );
$s .= "\n\t\t";
}
@ -307,7 +307,7 @@ class CategoryTree {
if ( $wgCategoryTreeOmitNamespace || $mode == CT_MODE_CATEGORIES ) $label = htmlspecialchars( $title->getText() );
else $label = htmlspecialchars( $title->getPrefixedText() );
if ( $trans && $trans!=$label ) $label.= ' ' . wfElement( 'i', array( 'class' => 'translation'), $trans );
if ( $trans && $trans!=$label ) $label.= ' ' . Xml::element( 'i', array( 'class' => 'translation'), $trans );
$wikiLink = $title->getLocalURL();
@ -344,31 +344,31 @@ class CategoryTree {
# Specifically, the CategoryTreeChildren div must be the first
# sibling with nodeName = DIV of the grandparent of the expland link.
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeSection' ) );
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeItem' ) );
$s .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeSection' ) );
$s .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeItem' ) );
if ( $ns == NS_CATEGORY ) {
$s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
$s .= '[' . wfElement( 'a', $linkattr, $txt ) . '] ';
$s .= wfCloseElement( 'span' );
$s .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
$s .= '[' . Xml::element( 'a', $linkattr, $txt ) . '] ';
$s .= Xml::closeElement( 'span' );
} else {
$s .= ' ';
}
$s .= wfOpenElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . wfCloseElement( 'a' );
$s .= wfCloseElement( 'div' );
$s .= Xml::openElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . Xml::closeElement( 'a' );
$s .= Xml::closeElement( 'div' );
$s .= "\n\t\t";
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeChildren', 'style' => $children ? "display:block" : "display:none" ) );
$s .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeChildren', 'style' => $children ? "display:block" : "display:none" ) );
//HACK here?
if ( $children ) $s .= $this->renderChildren( $title, $mode, $depth );
$s .= wfCloseElement( 'div' );
$s .= wfCloseElement( 'div' );
$s .= Xml::closeElement( 'div' );
$s .= Xml::closeElement( 'div' );
if ( $load ) {
$s .= "\n\t\t";
$s .= wfOpenElement( 'script', array( 'type' => 'text/javascript' ) );
$s .= Xml::openElement( 'script', array( 'type' => 'text/javascript' ) );
$s .= 'categoryTreeExpandNode("'.Xml::escapeJsString($key).'", "'.$mode.'", document.getElementById("'.$load.'") );';
$s .= wfCloseElement( 'script' );
$s .= Xml::closeElement( 'script' );
}
$s .= "\n\t\t";

View file

@ -6,7 +6,7 @@
* @addtogroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2006 Daniel Kinzler
* @licence GNU General Public Licence 2.0 or later
* @license GNU General Public Licence 2.0 or later
*/
if( !defined( 'MEDIAWIKI' ) ) {
@ -63,29 +63,30 @@ class CategoryTreePage extends SpecialPage {
$title = CategoryTree::makeTitle( $this->target );
if ( $title && $title->getArticleID() ) {
$html = '';
$html .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeParents' ) );
$html .= wfElement( 'span',
$html = Xml::openElement( 'div', array( 'class' => 'CategoryTreeParents' ) );
Xml::element( 'span',
array( 'class' => 'CategoryTreeParents' ),
wfMsg( 'categorytree-parents' ) ) . ': ';
$ct = new CategoryTree;
$parents = $ct->renderParents( $title, $this->mode );
if ( $parents == '' ) $html .= wfMsg( 'categorytree-nothing-found' );
else $html .= $parents;
if ( $parents == '' ) {
$html .= wfMsg( 'categorytree-nothing-found' );
} else {
$html .= $parents;
}
$html .= wfCloseElement( 'div' );
$html .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeResult' ) );
$html .= $ct->renderNode( $title, $this->mode, true, false );
$html .= wfCloseElement( 'div' );
$html .= Xml::closeElement( 'div' ) .
Xml::openElement( 'div', array( 'class' => 'CategoryTreeResult' ) ) .
$ct->renderNode( $title, $this->mode, true, false ) .
Xml::closeElement( 'div' );
$wgOut->addHtml( $html );
}
else {
$wgOut->addHtml( wfOpenElement( 'div', array( 'class' => 'CategoryTreeNotice' ) ) );
$wgOut->addHtml( Xml::openElement( 'div', array( 'class' => 'CategoryTreeNotice' ) ) );
$wgOut->addWikiText( wfMsg( 'categorytree-not-found' , $this->target ) );
$wgOut->addHtml( wfCloseElement( 'div' ) );
$wgOut->addHtml( Xml::closeElement( 'div' ) );
}
}
@ -97,18 +98,20 @@ class CategoryTreePage extends SpecialPage {
function makeInputForm() {
global $wgScript;
$thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
$form = '';
$form .= wfOpenElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript ) );
$form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'title', 'value' => $thisTitle->getPrefixedDbKey() ) );
$form .= wfElement( 'label', array( 'for' => 'target' ), wfMsg( 'categorytree-category' ) ) . ' ';
$form .= wfElement( 'input', array( 'type' => 'text', 'name' => 'target', 'id' => 'target', 'value' => $this->target ) ) . ' ';
$form .= wfOpenElement( 'select', array( 'name' => 'mode' ) );
$form .= wfElement( 'option', array( 'value' => 'categories' ) + ( $this->mode == CT_MODE_CATEGORIES ? array ( 'selected' => 'selected' ) : array() ), wfMsg( 'categorytree-mode-categories' ) );
$form .= wfElement( 'option', array( 'value' => 'pages' ) + ( $this->mode == CT_MODE_PAGES ? array ( 'selected' => 'selected' ) : array() ), wfMsg( 'categorytree-mode-pages' ) );
$form .= wfElement( 'option', array( 'value' => 'all' ) + ( $this->mode == CT_MODE_ALL ? array ( 'selected' => 'selected' ) : array() ), wfMsg( 'categorytree-mode-all' ) );
$form .= wfCloseElement( 'select' );
$form .= wfElement( 'input', array( 'type' => 'submit', 'name' => 'dotree', 'value' => wfMsg( 'categorytree-go' ) ) );
$form .= wfCloseElement( 'form' );
$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', $this->mode == CT_MODE_CATEGORIES ? true : false ) .
Xml::option( wfMsg( 'categorytree-mode-pages' ), 'pages', $this->mode == CT_MODE_PAGES ? true : false ) .
Xml::option( wfMsg( 'categorytree-mode-all' ), 'all', $this->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;
}
}