*
* @param string $element
* @param array $attribs Name=>value pairs. Values will be escaped.
- * @param bool $contents NULL to make an open tag only; '' for a contentless closed tag (default)
+ * @param string $contents NULL to make an open tag only; '' for a contentless closed tag (default)
* @return string
*/
function wfElement( $element, $attribs = null, $contents = '') {
*
* @param string $element
* @param array $attribs Name=>value pairs. Values will be escaped.
- * @param bool $contents NULL to make an open tag only; '' for a contentless closed tag (default)
+ * @param string $contents NULL to make an open tag only; '' for a contentless closed tag (default)
* @return string
*/
function wfElementClean( $element, $attribs = array(), $contents = '') {
return wfElement( $element, $attribs, $contents );
}
+/**
+ * Create a namespace selector
+ *
+ * @param mixed $selected The namespace which should be selected, default ''
+ * @param string $allnamespaces Value of a special item denoting all namespaces. Null to not include (default)
+ * @return Html string containing the namespace selector
+ */
+function &HTMLnamespaceselector($selected = '', $allnamespaces = null) {
+ global $wgContLang;
+ $s = "<select name='namespace' class='namespaceselector'>\n";
+ $arr = $wgContLang->getFormattedNamespaces();
+ if( !is_null($allnamespaces) ) {
+ /* TODO: rename contributionsall to something meaningfull */
+ $arr = array($allnamespaces => wfMsgHtml('contributionsall')) + $arr;
+ }
+ foreach ($arr as $index => $name) {
+ if ($index < NS_MAIN) continue;
+
+ $name = $index !== 0 ? $name : wfMsgHtml('blanknamespace');
+
+ if ($index === $selected) {
+ $s .= wfElement("option",
+ array("value" => $index, "selected" => "selected"),
+ $name);
+ } else {
+ $s .= wfElement("option", array("value" => $index), $name);
+ }
+ }
+ $s .= "</select>\n";
+ return $s;
+}
+
/** Global singleton instance of MimeMagic. This is initialized on demand,
* please always use the wfGetMimeMagic() function to get the instance.
*
global $wgContLang, $wgScript;
$t = Title::makeTitle( NS_SPECIAL, "Allpages" );
- $namespaceselect = "<select name='namespace' id='nsselectbox'>";
- $arr = $wgContLang->getFormattedNamespaces();
- foreach ( $arr as $ns => $name ) {
- if ($ns < NS_MAIN)
- continue;
- $n = $ns == 0 ? wfMsgHtml ( 'blanknamespace' ) : $name;
- $sel = $ns == $namespace ? ' selected="selected"' : '';
- $namespaceselect .= "<option value='$ns'$sel>$n</option>\n";
- }
- $namespaceselect .= '</select>';
+ $namespaceselect = HTMLnamespaceselector($namespace, null);
$frombox = "<input type='text' size='20' name='from' id='nsfrom' value=\""
. htmlspecialchars ( $from ) . '"/>';
$sk = $wgUser->getSkin();
+ $fromTitle = null;
if ($from!="") {
$fromTitle = Title::newFromURL( $from );
$fromNS = $fromTitle->getNamespace();
"type" => "hidden",
"value" => $target));
$nsform .= "<p>";
- $nsform .= htmlspecialchars(wfMsg('namespace')) . " <select name='namespace'>\n";
- foreach (array("" => wfMsg('contributionsall')) + $arr as $nsn => $name) {
- if ($nsn < 0)
- continue;
- $name = $nsn!==0 ? $name : wfMsg('blanknamespace');
- $nsform .= ("$nsn" == "$ns") ?
- wfElement("option",
- array("value" => $nsn, "selected" => "selected"),
- $name)
- :
- wfElement("option", array("value" => $nsn), $name);
- }
- $nsform .= "</select>\n";
+ $nsform .= wfMsgHtml('namespace');
+
+ $nsform .= HTMLnamespaceselector($ns, '');
+
$nsform .= wfElement("input", array(
"type" => "submit",
"value" => wfMsg('allpagessubmit')));
wfAppendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
// Add end of the texts
- $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) );
+ $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) . "\n" );
$wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '</div>');
}
global $wgContLang, $wgScript;
$t = Title::makeTitle( NS_SPECIAL, 'Recentchanges' );
- $namespaceselect = "<select name='namespace' id='nsselectbox'>";
- $namespaceselect .= '<option value="" ' . ($namespace === '' ? ' selected="selected"' : '') . '>' . wfMsg( 'contributionsall' ) . '</option>';
- $arr = $wgContLang->getFormattedNamespaces();
- foreach ( $arr as $ns => $name ) {
- if( $ns < NS_MAIN )
- continue;
- $n = $ns === NS_MAIN ? wfMsg ( 'blanknamespace' ) : $name;
- $sel = $namespace === (string) $ns ? ' selected="selected"' : '';
- $namespaceselect .= "<option value='$ns'$sel>$n</option>";
- }
- $namespaceselect .= '</select>';
+ $namespaceselect = HTMLnamespaceselector($namespace, '');
+ $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" />';
+ $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
+
+ $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
- $out = '';
- $out .= "<div class='namespaceselector'><form method='get' action='{$wgScript}'>\n";
foreach ( $nondefaults as $key => $value ) {
if ($key != 'namespace' && $key != 'invert')
- $out .= "<input type='hidden' name='$key' value='$value' />";
+ $out .= wfElement('input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value));
}
-
- $submitbutton = '<input type="submit" value="' . wfMsg( 'allpagessubmit' ) . '" />';
- $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
-
$out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
$out .= "
<div id='nsselect' class='recentchanges'>
- <label for='nsselectbox'>" . wfMsg('namespace') . "</label>
- $namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsg('invert') . "</label>
+ <label for='namespace'>" . wfMsgHtml('namespace') . "</label>
+ $namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>
</div>";
$out .= '</form></div>';
return $out;