Esempio n. 1
0
 function execute($par)
 {
     global $wgUrlProtocols, $wgMiserMode;
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->allowClickjacking();
     $request = $this->getRequest();
     $target = $request->getVal('target', $par);
     $namespace = $request->getIntorNull('namespace', null);
     $protocols_list = array();
     foreach ($wgUrlProtocols as $prot) {
         if ($prot !== '//') {
             $protocols_list[] = $prot;
         }
     }
     $target2 = $target;
     $protocol = '';
     $pr_sl = strpos($target2, '//');
     $pr_cl = strpos($target2, ':');
     if ($pr_sl) {
         // For protocols with '//'
         $protocol = substr($target2, 0, $pr_sl + 2);
         $target2 = substr($target2, $pr_sl + 2);
     } elseif (!$pr_sl && $pr_cl) {
         // For protocols without '//' like 'mailto:'
         $protocol = substr($target2, 0, $pr_cl + 1);
         $target2 = substr($target2, $pr_cl + 1);
     } elseif ($protocol == '' && $target2 != '') {
         // default
         $protocol = 'http://';
     }
     if ($protocol != '' && !in_array($protocol, $protocols_list)) {
         // unsupported protocol, show original search request
         $target2 = $target;
         $protocol = '';
     }
     $out->addWikiMsg('linksearch-text', '<nowiki>' . $this->getLang()->commaList($wgUrlProtocols) . '</nowiki>');
     $s = Xml::openElement('form', array('id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'])) . Html::hidden('title', $this->getTitle()->getPrefixedDbKey()) . '<fieldset>' . Xml::element('legend', array(), wfMsg('linksearch')) . Xml::inputLabel(wfMsg('linksearch-pat'), 'target', 'target', 50, $target) . ' ';
     if (!$wgMiserMode) {
         $s .= Xml::label(wfMsg('linksearch-ns'), 'namespace') . ' ' . Xml::namespaceSelector($namespace, '');
     }
     $s .= Xml::submitButton(wfMsg('linksearch-ok')) . '</fieldset>' . Xml::closeElement('form');
     $out->addHTML($s);
     if ($target != '') {
         $this->setParams(array('query' => $target2, 'namespace' => $namespace, 'protocol' => $protocol));
         parent::execute($par);
         if ($this->mMungedQuery === false) {
             $out->addWikiMsg('linksearch-error');
         }
     }
 }
 /**
  * HTML for the top form
  * @param integer $namespace A namespace constant (default NS_MAIN).
  * @param string $from Article name we are starting listing at.
  */
 function namespaceForm($namespace = NS_MAIN, $from = '')
 {
     global $wgScript, $wgContLang;
     $t = SpecialPage::getTitleFor($this->name);
     $align = $wgContLang->isRtl() ? 'left' : 'right';
     $out = Xml::openElement('div', array('class' => 'namespaceoptions'));
     $out .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     $out .= Xml::hidden('title', $t->getPrefixedText());
     $out .= Xml::openElement('table', array('id' => 'nsselect', 'class' => 'allpages'));
     $out .= "<tr>\n\t\t\t<td align='{$align}'>" . Xml::label(wfMsg($this->nsfromMsg), 'nsfrom') . "</td>\n\t\t\t<td>" . Xml::input('from', 20, $from, array('id' => 'nsfrom')) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='{$align}'>" . Xml::label(wfMsg('namespace'), 'namespace') . "</td>\n\t\t\t<td>" . Xml::namespaceSelector($namespace, null) . Xml::submitButton(wfMsg('allpagessubmit')) . "</td>\n\t\t\t</tr>";
     $out .= Xml::closeElement('table');
     $out .= Xml::closeElement('form');
     $out .= Xml::closeElement('div');
     return $out;
 }
Esempio n. 3
0
/**
 * Special:LinkSearch to search the external-links table.
 */
function wfSpecialLinkSearch($par)
{
    list($limit, $offset) = wfCheckLimits();
    global $wgOut, $wgUrlProtocols, $wgMiserMode, $wgLang;
    $target = $GLOBALS['wgRequest']->getVal('target', $par);
    $namespace = $GLOBALS['wgRequest']->getIntorNull('namespace', null);
    $protocols_list[] = '';
    foreach ($wgUrlProtocols as $prot) {
        $protocols_list[] = $prot;
    }
    $target2 = $target;
    $protocol = '';
    $pr_sl = strpos($target2, '//');
    $pr_cl = strpos($target2, ':');
    if ($pr_sl) {
        // For protocols with '//'
        $protocol = substr($target2, 0, $pr_sl + 2);
        $target2 = substr($target2, $pr_sl + 2);
    } elseif (!$pr_sl && $pr_cl) {
        // For protocols without '//' like 'mailto:'
        $protocol = substr($target2, 0, $pr_cl + 1);
        $target2 = substr($target2, $pr_cl + 1);
    } elseif ($protocol == '' && $target2 != '') {
        // default
        $protocol = 'http://';
    }
    if (!in_array($protocol, $protocols_list)) {
        // unsupported protocol, show original search request
        $target2 = $target;
        $protocol = '';
    }
    $self = Title::makeTitle(NS_SPECIAL, 'Linksearch');
    $wgOut->allowClickjacking();
    $wgOut->addWikiMsg('linksearch-text', '<nowiki>' . $wgLang->commaList($wgUrlProtocols) . '</nowiki>');
    $s = Xml::openElement('form', array('id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'])) . Html::hidden('title', $self->getPrefixedDbKey()) . '<fieldset>' . Xml::element('legend', array(), wfMsg('linksearch')) . Xml::inputLabel(wfMsg('linksearch-pat'), 'target', 'target', 50, $target) . ' ';
    if (!$wgMiserMode) {
        $s .= Xml::label(wfMsg('linksearch-ns'), 'namespace') . ' ' . Xml::namespaceSelector($namespace, '');
    }
    $s .= Xml::submitButton(wfMsg('linksearch-ok')) . '</fieldset>' . Xml::closeElement('form');
    $wgOut->addHTML($s);
    if ($target != '') {
        $searcher = new LinkSearchPage();
        $searcher->setParams(array('query' => $target2, 'namespace' => $namespace, 'protocol' => $protocol));
        $searcher->doQuery($offset, $limit);
    }
}
 /**
  * HTML for the top form
  * @param integer $namespace A namespace constant (default NS_MAIN).
  * @param string $from dbKey we are starting listing at.
  * @param string $to dbKey we are ending listing at.
  */
 function namespaceForm($namespace = NS_MAIN, $from = '', $to = '')
 {
     global $wgScript;
     $t = $this->getTitle();
     $out = Xml::openElement('div', array('class' => 'namespaceoptions'));
     $out .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     $out .= Xml::hidden('title', $t->getPrefixedText());
     $out .= Xml::openElement('fieldset');
     $out .= Xml::element('legend', null, wfMsg('allpages'));
     $out .= Xml::openElement('table', array('id' => 'nsselect', 'class' => 'allpages'));
     $out .= "<tr>\n\t<td class='mw-label'>" . Xml::label(wfMsg('allpagesfrom'), 'nsfrom') . "\t</td>\n\t<td class='mw-input'>" . Xml::input('from', 30, str_replace('_', ' ', $from), array('id' => 'nsfrom')) . "\t</td>\n</tr>\n<tr>\n\t<td class='mw-label'>" . Xml::label(wfMsg('allpagesto'), 'nsto') . "\t</td>\n\t\t\t<td class='mw-input'>" . Xml::input('to', 30, str_replace('_', ' ', $to), array('id' => 'nsto')) . "\t\t</td>\n</tr>\n<tr>\n\t<td class='mw-label'>" . Xml::label(wfMsg('namespace'), 'namespace') . "\t</td>\n\t\t\t<td class='mw-input'>" . Xml::namespaceSelector($namespace, null) . ' ' . Xml::submitButton(wfMsg('allpagessubmit')) . "\t</td>\n</tr>";
     $out .= Xml::closeElement('table');
     $out .= Xml::closeElement('fieldset');
     $out .= Xml::closeElement('form');
     $out .= Xml::closeElement('div');
     return $out;
 }
 public function getHTML()
 {
     global $wgRequest, $wgScript, $wgTitle;
     $s = '';
     $s .= Xml::fieldset(wfMsg('listuserrestrictions-legend'));
     $s .= "<form action=\"{$wgScript}\">";
     $s .= Xml::hidden('title', $wgTitle->getPrefixedDbKey());
     $s .= Xml::label(wfMsgHtml('listuserrestrictions-type'), 'type') . '&nbsp;' . self::typeSelector('type', $wgRequest->getVal('type'), 'type');
     $s .= '&nbsp;';
     $s .= Xml::inputLabel(wfMsgHtml('listuserrestrictions-user'), 'user', 'user', false, $wgRequest->getVal('user'));
     $s .= '<p>';
     $s .= Xml::label(wfMsgHtml('listuserrestrictions-namespace'), 'namespace') . '&nbsp;' . Xml::namespaceSelector($wgRequest->getVal('namespace'), '', 'namespace');
     $s .= '&nbsp;';
     $s .= Xml::inputLabel(wfMsgHtml('listuserrestrictions-page'), 'page', 'page', false, $wgRequest->getVal('page'));
     $s .= Xml::submitButton(wfMsg('listuserrestrictions-submit'));
     $s .= "</p></form></fieldset>";
     return $s;
 }
Esempio n. 6
0
 /**
  * Generates the namespace selector form with hidden attributes.
  * @param $this->opts Array: the options to be included.
  */
 protected function getForm()
 {
     global $wgScript;
     $this->opts['title'] = $this->getTitle()->getPrefixedText();
     if (!isset($this->opts['target'])) {
         $this->opts['target'] = '';
     } else {
         $this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
     }
     if (!isset($this->opts['namespace'])) {
         $this->opts['namespace'] = '';
     }
     if (!isset($this->opts['contribs'])) {
         $this->opts['contribs'] = 'user';
     }
     if (!isset($this->opts['year'])) {
         $this->opts['year'] = '';
     }
     if (!isset($this->opts['month'])) {
         $this->opts['month'] = '';
     }
     if ($this->opts['contribs'] == 'newbie') {
         $this->opts['target'] = '';
     }
     if (!isset($this->opts['tagfilter'])) {
         $this->opts['tagfilter'] = '';
     }
     $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     # Add hidden params for tracking
     foreach ($this->opts as $name => $value) {
         if (in_array($name, array('namespace', 'target', 'contribs', 'year', 'month'))) {
             continue;
         }
         $f .= "\t" . Xml::hidden($name, $value) . "\n";
     }
     $tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
     $f .= '<fieldset>' . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . Xml::radioLabel(wfMsgExt('sp-contributions-newbies', array('parsemag')), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie' ? true : false) . '<br />' . Xml::radioLabel(wfMsgExt('sp-contributions-username', array('parsemag')), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user' ? true : false) . ' ' . Html::input('target', $this->opts['target'], 'text', array('size' => '20', 'required' => '') + ($this->opts['target'] ? array() : array('autofocus'))) . ' ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($this->opts['namespace'], '') . '</span>' . ($tagFilter ? Xml::tags('p', null, implode('&nbsp;', $tagFilter)) : '') . Xml::openElement('p') . '<span style="white-space: nowrap">' . Xml::dateMenu($this->opts['year'], $this->opts['month']) . '</span>' . ' ' . Xml::submitButton(wfMsg('sp-contributions-submit')) . Xml::closeElement('p');
     $explain = wfMsgExt('sp-contributions-explain', 'parseinline');
     if (!wfEmptyMsg('sp-contributions-explain', $explain)) {
         $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
     }
     $f .= '</fieldset>' . Xml::closeElement('form');
     return $f;
 }
Esempio n. 7
0
 /**
  * Generates the namespace selector form with hidden attributes.
  * @return String: HTML fragment
  */
 protected function getForm()
 {
     global $wgScript;
     $this->opts['title'] = $this->getTitle()->getPrefixedText();
     if (!isset($this->opts['target'])) {
         $this->opts['target'] = '';
     } else {
         $this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
     }
     if (!isset($this->opts['namespace'])) {
         $this->opts['namespace'] = '';
     }
     if (!isset($this->opts['nsInvert'])) {
         $this->opts['nsInvert'] = '';
     }
     if (!isset($this->opts['associated'])) {
         $this->opts['associated'] = false;
     }
     if (!isset($this->opts['contribs'])) {
         $this->opts['contribs'] = 'user';
     }
     if (!isset($this->opts['year'])) {
         $this->opts['year'] = '';
     }
     if (!isset($this->opts['month'])) {
         $this->opts['month'] = '';
     }
     if ($this->opts['contribs'] == 'newbie') {
         $this->opts['target'] = '';
     }
     if (!isset($this->opts['tagfilter'])) {
         $this->opts['tagfilter'] = '';
     }
     if (!isset($this->opts['topOnly'])) {
         $this->opts['topOnly'] = false;
     }
     $form = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form'));
     # Add hidden params for tracking except for parameters in $skipParameters
     $skipParameters = array('namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated');
     foreach ($this->opts as $name => $value) {
         if (in_array($name, $skipParameters)) {
             continue;
         }
         $form .= "\t" . Html::hidden($name, $value) . "\n";
     }
     $tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
     if ($tagFilter) {
         $filterSelection = Xml::tags('td', array('class' => 'mw-label'), array_shift($tagFilter)) . Xml::tags('td', array('class' => 'mw-input'), implode('&#160', $tagFilter));
     } else {
         $filterSelection = Xml::tags('td', array('colspan' => 2), '');
     }
     $targetSelection = Xml::tags('td', array('colspan' => 2), Xml::radioLabel($this->msg('sp-contributions-newbies')->text(), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie', array('class' => 'mw-input')) . '<br />' . Xml::radioLabel($this->msg('sp-contributions-username')->text(), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user', array('class' => 'mw-input')) . ' ' . Html::input('target', $this->opts['target'], 'text', array('size' => '20', 'required' => '', 'class' => 'mw-input') + ($this->opts['target'] ? array() : array('autofocus'))) . ' ');
     $namespaceSelection = Xml::tags('td', array('class' => 'mw-label'), Xml::label($this->msg('namespace')->text(), 'namespace', '')) . Xml::tags('td', null, Xml::namespaceSelector($this->opts['namespace'], '') . '&#160;' . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('invert')->text(), 'nsInvert', 'nsInvert', $this->opts['nsInvert'], array('title' => $this->msg('tooltip-invert')->text(), 'class' => 'mw-input')) . '&#160;') . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $this->opts['associated'], array('title' => $this->msg('tooltip-namespace_association')->text(), 'class' => 'mw-input')) . '&#160;'));
     $extraOptions = Xml::tags('td', array('colspan' => 2), Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'], array('class' => 'mw-input'))) . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('sp-contributions-toponly')->text(), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'], array('class' => 'mw-input'))));
     $dateSelectionAndSubmit = Xml::tags('td', array('colspan' => 2), Xml::dateMenu($this->opts['year'], $this->opts['month']) . ' ' . Xml::submitButton($this->msg('sp-contributions-submit')->text(), array('class' => 'mw-submit')));
     $form .= Xml::fieldset($this->msg('sp-contributions-search')->text()) . Xml::openElement('table', array('class' => 'mw-contributions-table')) . Xml::openElement('tr') . $targetSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $namespaceSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $filterSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $extraOptions . Xml::closeElement('tr') . Xml::openElement('tr') . $dateSelectionAndSubmit . Xml::closeElement('tr') . Xml::closeElement('table');
     $explain = $this->msg('sp-contributions-explain');
     if ($explain->exists()) {
         $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
     }
     $form .= Xml::closeElement('fieldset') . Xml::closeElement('form');
     return $form;
 }
 function whatlinkshereForm()
 {
     global $wgScript;
     // We get nicer value from the title object
     $this->opts->consumeValue('target');
     // Reset these for new requests
     $this->opts->consumeValues(array('back', 'from'));
     $target = $this->target ? $this->target->getPrefixedText() : '';
     $namespace = $this->opts->consumeValue('namespace');
     # Build up the form
     $f = Xml::openElement('form', array('action' => $wgScript));
     # Values that should not be forgotten
     $f .= Html::hidden('title', $this->getTitle()->getPrefixedText());
     foreach ($this->opts->getUnconsumedValues() as $name => $value) {
         $f .= Html::hidden($name, $value);
     }
     $f .= Xml::fieldset(wfMsg('whatlinkshere'));
     # Target input
     $f .= Xml::inputLabel(wfMsg('whatlinkshere-page'), 'target', 'mw-whatlinkshere-target', 40, $target);
     $f .= ' ';
     # Namespace selector
     $f .= Xml::label(wfMsg('namespace'), 'namespace') . '&#160;' . Xml::namespaceSelector($namespace, '');
     $f .= ' ';
     # Submit
     $f .= Xml::submitButton(wfMsg('allpagessubmit'));
     # Close
     $f .= Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n";
     return $f;
 }
 /**
  * Generates the namespace selector form with hidden attributes.
  * @param $this->opts Array: the options to be included.
  */
 protected function getForm()
 {
     global $wgScript, $wgTitle;
     $this->opts['title'] = $wgTitle->getPrefixedText();
     if (!isset($this->opts['target'])) {
         $this->opts['target'] = '';
     } else {
         $this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
     }
     if (!isset($this->opts['namespace'])) {
         $this->opts['namespace'] = '';
     }
     if (!isset($this->opts['contribs'])) {
         $this->opts['contribs'] = 'user';
     }
     if (!isset($this->opts['year'])) {
         $this->opts['year'] = '';
     }
     if (!isset($this->opts['month'])) {
         $this->opts['month'] = '';
     }
     if ($this->opts['contribs'] == 'newbie') {
         $this->opts['target'] = '';
     }
     $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     foreach ($this->opts as $name => $value) {
         if (in_array($name, array('namespace', 'target', 'contribs', 'year', 'month'))) {
             continue;
         }
         $f .= "\t" . Xml::hidden($name, $value) . "\n";
     }
     $f .= '<fieldset>' . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . Xml::radioLabel(wfMsgExt('sp-contributions-newbies', array('parseinline')), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie' ? true : false) . '<br />' . Xml::radioLabel(wfMsgExt('sp-contributions-username', array('parseinline')), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user' ? true : false) . ' ' . Xml::input('target', 20, $this->opts['target']) . ' ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($this->opts['namespace'], '') . '</span>' . Xml::openElement('p') . '<span style="white-space: nowrap">' . Xml::label(wfMsg('year'), 'year') . ' ' . Xml::input('year', 4, $this->opts['year'], array('id' => 'year', 'maxlength' => 4)) . '</span>' . ' ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('month'), 'month') . ' ' . Xml::monthSelector($this->opts['month'], -1) . ' ' . '</span>' . Xml::submitButton(wfMsg('sp-contributions-submit')) . Xml::closeElement('p');
     $explain = wfMsgExt('sp-contributions-explain', 'parseinline');
     if (!wfEmptyMsg('sp-contributions-explain', $explain)) {
         $f .= "<p>{$explain}</p>";
     }
     $f .= '</fieldset>' . Xml::closeElement('form');
     return $f;
 }
Esempio n. 10
0
 function showForm($err = '')
 {
     global $wgOut;
     if ($err) {
         $wgOut->addHTML('<div class="wikierror">' . htmlspecialchars($err) . '</div>');
     }
     $wgOut->addWikiMsg('masseditregextext');
     $titleObj = SpecialPage::getTitleFor('MassEditRegex');
     $wgOut->addHTML(Xml::openElement('form', array('id' => 'masseditregex', 'method' => 'post', 'action' => $titleObj->getLocalURL('action=submit'))) . Xml::element('p', null, wfMsg('masseditregex-pagelisttxt')) . Xml::textarea('wpPageList', join("\n", $this->aPageList)) . Xml::namespaceSelector($this->iNamespace, null, 'namespace', wfMsg('masseditregex-namespace-intro')) . Xml::element('br') . Xml::element('span', null, wfMsg('masseditregex-listtype-intro')) . Xml::openElement('ul', array('style' => 'list-style: none')));
     // Generate HTML for the radio buttons (one for each list type)
     foreach (array('pagenames', 'pagename-prefixes', 'categories', 'backlinks') as $strValue) {
         // Have to use openElement because putting an Xml::xxx return value
         // inside an Xml::element causes the HTML code to be escaped and appear
         // on the page.
         $wgOut->addHTML(Xml::openElement('li') . Xml::radioLabel(wfMsg('masseditregex-listtype-' . $strValue), 'wpPageListType', $strValue, 'masseditregex-radio-' . $strValue, $strValue == $this->strPageListType) . Xml::closeElement('li'));
     }
     $wgOut->addHTML(Xml::closeElement('ul') . Xml::openElement('table', array('style' => 'width: 100%')) . Xml::openElement('tr') . Xml::openElement('td') . Xml::element('p', null, wfMsg('masseditregex-matchtxt')) . Xml::textarea('wpMatch', join("\n", $this->aMatch)) . Xml::closeElement('td') . Xml::openElement('td') . Xml::element('p', null, wfMsg('masseditregex-replacetxt')) . Xml::textarea('wpReplace', $this->strReplace) . Xml::closeElement('td') . Xml::closeElement('tr') . Xml::closeElement('table') . Xml::openElement('div', array('class' => 'editOptions')) . Xml::tags('span', array('class' => 'mw-summary', 'id' => 'wpSummaryLabel'), Xml::tags('label', array('for' => 'wpSummary'), wfMsg('summary'))) . ' ' . Xml::input('wpSummary', 60, $this->strSummary, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1')) . Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsgExt('summary-preview', 'parseinline') . $this->sk->commentBlock($this->strSummary)) . Xml::closeElement('div') . Xml::element('input', array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'value' => wfMsg('masseditregex-executebtn'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('masseditregex-tooltip-execute') . ' [' . wfMsg('accesskey-save') . ']')) . Xml::element('input', array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview') . ' [' . wfMsg('accesskey-preview') . ']')));
     $wgOut->addHTML(Xml::closeElement('form'));
 }
Esempio n. 11
0
 function testNamespaceSelector()
 {
     $this->assertEquals('<select class="namespaceselector" id="namespace" name="namespace">' . "\n" . '<option value="0">(Main)</option>' . "\n" . '<option value="1">Talk</option>' . "\n" . '<option value="2">User</option>' . "\n" . '<option value="3">User talk</option>' . "\n" . '<option value="4">MyWiki</option>' . "\n" . '<option value="5">MyWiki Talk</option>' . "\n" . '<option value="6">File</option>' . "\n" . '<option value="7">File talk</option>' . "\n" . '<option value="8">MediaWiki</option>' . "\n" . '<option value="9">MediaWiki talk</option>' . "\n" . '<option value="10">Template</option>' . "\n" . '<option value="11">Template talk</option>' . "\n" . '<option value="100">Custom</option>' . "\n" . '<option value="101">Custom talk</option>' . "\n" . '</select>', Xml::namespaceSelector(), 'Basic namespace selector without custom options');
     $this->assertEquals('<label for="namespace">Select a namespace:</label>' . '&#160;<select class="namespaceselector" id="namespace" name="myname">' . "\n" . '<option value="all">all</option>' . "\n" . '<option value="0">(Main)</option>' . "\n" . '<option value="1">Talk</option>' . "\n" . '<option value="2" selected="">User</option>' . "\n" . '<option value="3">User talk</option>' . "\n" . '<option value="4">MyWiki</option>' . "\n" . '<option value="5">MyWiki Talk</option>' . "\n" . '<option value="6">File</option>' . "\n" . '<option value="7">File talk</option>' . "\n" . '<option value="8">MediaWiki</option>' . "\n" . '<option value="9">MediaWiki talk</option>' . "\n" . '<option value="10">Template</option>' . "\n" . '<option value="11">Template talk</option>' . "\n" . '<option value="100">Custom</option>' . "\n" . '<option value="101">Custom talk</option>' . "\n" . '</select>', Xml::namespaceSelector($selected = '2', $all = 'all', $element_name = 'myname', $label = 'Select a namespace:'), 'Basic namespace selector with custom values');
 }
function HTMLnamespaceselector($selected = '', $allnamespaces = null, $includehidden = false)
{
    return Xml::namespaceSelector($selected, $allnamespaces, $includehidden);
}
Esempio n. 13
0
 public function execute($par)
 {
     global $wgSitename, $wgExportAllowListContributors, $wgExportFromNamespaces;
     global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxLinkDepth;
     global $wgExportAllowAll;
     $this->setHeaders();
     $this->outputHeader();
     // Set some variables
     $this->curonly = true;
     $this->doExport = false;
     $request = $this->getRequest();
     $this->templates = $request->getCheck('templates');
     $this->images = $request->getCheck('images');
     // Doesn't do anything yet
     $this->pageLinkDepth = $this->validateLinkDepth($request->getIntOrNull('pagelink-depth'));
     $nsindex = '';
     $exportall = false;
     if ($request->getCheck('addcat')) {
         $page = $request->getText('pages');
         $catname = $request->getText('catname');
         if ($catname !== '' && $catname !== null && $catname !== false) {
             $t = Title::makeTitleSafe(NS_MAIN, $catname);
             if ($t) {
                 /**
                  * @todo FIXME: This can lead to hitting memory limit for very large
                  * categories. Ideally we would do the lookup synchronously
                  * during the export in a single query.
                  */
                 $catpages = $this->getPagesFromCategory($t);
                 if ($catpages) {
                     $page .= "\n" . implode("\n", $catpages);
                 }
             }
         }
     } elseif ($request->getCheck('addns') && $wgExportFromNamespaces) {
         $page = $request->getText('pages');
         $nsindex = $request->getText('nsindex', '');
         if (strval($nsindex) !== '') {
             /**
              * Same implementation as above, so same @todo
              */
             $nspages = $this->getPagesFromNamespace($nsindex);
             if ($nspages) {
                 $page .= "\n" . implode("\n", $nspages);
             }
         }
     } elseif ($request->getCheck('exportall') && $wgExportAllowAll) {
         $this->doExport = true;
         $exportall = true;
     } elseif ($request->wasPosted() && $par == '') {
         $page = $request->getText('pages');
         $this->curonly = $request->getCheck('curonly');
         $rawOffset = $request->getVal('offset');
         if ($rawOffset) {
             $offset = wfTimestamp(TS_MW, $rawOffset);
         } else {
             $offset = null;
         }
         $limit = $request->getInt('limit');
         $dir = $request->getVal('dir');
         $history = array('dir' => 'asc', 'offset' => false, 'limit' => $wgExportMaxHistory);
         $historyCheck = $request->getCheck('history');
         if ($this->curonly) {
             $history = WikiExporter::CURRENT;
         } elseif (!$historyCheck) {
             if ($limit > 0 && ($wgExportMaxHistory == 0 || $limit < $wgExportMaxHistory)) {
                 $history['limit'] = $limit;
             }
             if (!is_null($offset)) {
                 $history['offset'] = $offset;
             }
             if (strtolower($dir) == 'desc') {
                 $history['dir'] = 'desc';
             }
         }
         if ($page != '') {
             $this->doExport = true;
         }
     } else {
         // Default to current-only for GET requests.
         $page = $request->getText('pages', $par);
         $historyCheck = $request->getCheck('history');
         if ($historyCheck) {
             $history = WikiExporter::FULL;
         } else {
             $history = WikiExporter::CURRENT;
         }
         if ($page != '') {
             $this->doExport = true;
         }
     }
     if (!$wgExportAllowHistory) {
         // Override
         $history = WikiExporter::CURRENT;
     }
     $list_authors = $request->getCheck('listauthors');
     if (!$this->curonly || !$wgExportAllowListContributors) {
         $list_authors = false;
     }
     if ($this->doExport) {
         $this->getOutput()->disable();
         // Cancel output buffering and gzipping if set
         // This should provide safer streaming for pages with history
         wfResetOutputBuffers();
         $request->response()->header("Content-type: application/xml; charset=utf-8");
         if ($request->getCheck('wpDownload')) {
             // Provide a sane filename suggestion
             $filename = urlencode($wgSitename . '-' . wfTimestampNow() . '.xml');
             $request->response()->header("Content-disposition: attachment;filename={$filename}");
         }
         $this->doExport($page, $history, $list_authors, $exportall);
         return;
     }
     $out = $this->getOutput();
     $out->addWikiMsg('exporttext');
     $form = Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl('action=submit')));
     $form .= Xml::inputLabel(wfMsg('export-addcattext'), 'catname', 'catname', 40) . '&#160;';
     $form .= Xml::submitButton(wfMsg('export-addcat'), array('name' => 'addcat')) . '<br />';
     if ($wgExportFromNamespaces) {
         $form .= Xml::namespaceSelector($nsindex, null, 'nsindex', wfMsg('export-addnstext')) . '&#160;';
         $form .= Xml::submitButton(wfMsg('export-addns'), array('name' => 'addns')) . '<br />';
     }
     if ($wgExportAllowAll) {
         $form .= Xml::checkLabel(wfMsg('exportall'), 'exportall', 'exportall', $request->wasPosted() ? $request->getCheck('exportall') : false) . '<br />';
     }
     $form .= Xml::element('textarea', array('name' => 'pages', 'cols' => 40, 'rows' => 10), $page, false);
     $form .= '<br />';
     if ($wgExportAllowHistory) {
         $form .= Xml::checkLabel(wfMsg('exportcuronly'), 'curonly', 'curonly', $request->wasPosted() ? $request->getCheck('curonly') : true) . '<br />';
     } else {
         $out->addHTML(wfMsgExt('exportnohistory', 'parse'));
     }
     $form .= Xml::checkLabel(wfMsg('export-templates'), 'templates', 'wpExportTemplates', $request->wasPosted() ? $request->getCheck('templates') : false) . '<br />';
     if ($wgExportMaxLinkDepth || $this->userCanOverrideExportDepth()) {
         $form .= Xml::inputLabel(wfMsg('export-pagelinks'), 'pagelink-depth', 'pagelink-depth', 20, 0) . '<br />';
     }
     // Enable this when we can do something useful exporting/importing image information. :)
     //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
     $form .= Xml::checkLabel(wfMsg('export-download'), 'wpDownload', 'wpDownload', $request->wasPosted() ? $request->getCheck('wpDownload') : true) . '<br />';
     if ($wgExportAllowListContributors) {
         $form .= Xml::checkLabel(wfMsg('exportlistauthors'), 'listauthors', 'listauthors', $request->wasPosted() ? $request->getCheck('listauthors') : false) . '<br />';
     }
     $form .= Xml::submitButton(wfMsg('export-submit'), Linker::tooltipAndAccesskeyAttribs('export'));
     $form .= Xml::closeElement('form');
     $out->addHTML($form);
 }
/**
 * Generates the namespace selector form with hidden attributes.
 * @param $options Array: the options to be included.
 */
function deletedContributionsForm($options)
{
    global $wgScript, $wgTitle, $wgRequest;
    $options['title'] = $wgTitle->getPrefixedText();
    if (!isset($options['target'])) {
        $options['target'] = '';
    } else {
        $options['target'] = str_replace('_', ' ', $options['target']);
    }
    if (!isset($options['namespace'])) {
        $options['namespace'] = '';
    }
    if (!isset($options['contribs'])) {
        $options['contribs'] = 'user';
    }
    if ($options['contribs'] == 'newbie') {
        $options['target'] = '';
    }
    $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
    foreach ($options as $name => $value) {
        if (in_array($name, array('namespace', 'target', 'contribs'))) {
            continue;
        }
        $f .= "\t" . Xml::hidden($name, $value) . "\n";
    }
    $f .= '<fieldset>' . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . wfMsgExt('sp-contributions-username', array('parseinline')) . ' ' . Xml::input('target', 20, $options['target']) . ' ' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($options['namespace'], '') . Xml::submitButton(wfMsg('sp-contributions-submit')) . '</fieldset>' . Xml::closeElement('form');
    return $f;
}
 /**
  * Generates the namespace selector form with hidden attributes.
  * @param $options Array: the options to be included.
  */
 function getForm($options)
 {
     global $wgScript;
     $options['title'] = SpecialPage::getTitleFor('DeletedContributions')->getPrefixedText();
     if (!isset($options['target'])) {
         $options['target'] = '';
     } else {
         $options['target'] = str_replace('_', ' ', $options['target']);
     }
     if (!isset($options['namespace'])) {
         $options['namespace'] = '';
     }
     if (!isset($options['contribs'])) {
         $options['contribs'] = 'user';
     }
     if ($options['contribs'] == 'newbie') {
         $options['target'] = '';
     }
     $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     foreach ($options as $name => $value) {
         if (in_array($name, array('namespace', 'target', 'contribs'))) {
             continue;
         }
         $f .= "\t" . Html::hidden($name, $value) . "\n";
     }
     $f .= Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . Xml::tags('label', array('for' => 'target'), wfMsgExt('sp-contributions-username', 'parseinline')) . ' ' . Html::input('target', $options['target'], 'text', array('size' => '20', 'required' => '') + ($options['target'] ? array() : array('autofocus'))) . ' ' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($options['namespace'], '') . ' ' . Xml::submitButton(wfMsg('sp-contributions-submit')) . Xml::closeElement('fieldset') . Xml::closeElement('form');
     return $f;
 }
Esempio n. 16
0
 /**
  * Creates the choose namespace selection
  *
  * @param $opts FormOptions
  * @return string
  */
 protected function namespaceFilterForm(FormOptions $opts)
 {
     $nsSelect = Xml::namespaceSelector($opts['namespace'], '');
     $nsLabel = Xml::label(wfMsg('namespace'), 'namespace');
     $invert = Xml::checkLabel(wfMsg('invert'), 'invert', 'nsinvert', $opts['invert']);
     return array($nsLabel, "{$nsSelect} {$invert}");
 }
Esempio n. 17
0
function HTMLnamespaceselector($selected = '', $allnamespaces = null)
{
    wfDeprecated(__FUNCTION__);
    return Xml::namespaceSelector($selected, $allnamespaces);
}
Esempio n. 18
0
    /**
     * Show the standard watchlist editing form
     *
     * @param $output OutputPage
     * @param $user User
     * @param $namespace A namespace constant, such as NS_MAIN
     * @param $guide GuideName
     */
    private function showForm($output, $user, $namespace, $guide)
    {
        global $wgScript, $wgContLang;
        $self = SpecialPage::getTitleFor('Watchsubpages');
        # Input boxes at the top
        $form = Xml::openElement('div', array('class' => 'namespaceoptions'));
        $form .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
        $form .= Html::Hidden('title', $self->getPrefixedText());
        $form .= Xml::openElement('table', array('id' => 'nsselect', 'class' => 'allpages'));
        $form .= '<tr>
				<td>' . Xml::label('Guide name:', 'nsfrom') . '</td>
				<td>' . Xml::input('guide', 20, htmlspecialchars($guide . '/'), array('id' => 'nsfrom')) . '</td>
			</tr>
			<tr>
				<td>' . Xml::label(wfMsg('namespace'), 'namespace') . '</td>
				<td>' . Xml::namespaceSelector($namespace, null) . Xml::submitButton(wfMsg('allpagessubmit')) . '</td>
			</tr>';
        $form .= Xml::closeElement('table');
        $form .= Xml::closeElement('form');
        $form .= Xml::closeElement('div');
        if ($guide !== '') {
            $form .= Xml::openElement('form', array('method' => 'post', 'action' => $self->getLocalUrl('guide=' . $guide)));
            $form .= Html::Hidden('token', $user->editToken('watchsubpages'));
            $form .= '<fieldset><legend>' . wfMsg('watchsubpages-addtitles') . '</legend>';
            $form .= wfMsg('watchsubpages-form');
            foreach ($this->getPrefixlistInfo($namespace, $guide . '/') as $namespace => $pages) {
                $form .= '<h2>' . $this->getNamespaceHeading($namespace) . '</h2>';
                $form .= '<ul>';
                foreach ($pages as $dbkey => $redirect) {
                    $title = Title::makeTitleSafe($namespace, $dbkey);
                    $form .= $this->buildLine($title, $redirect, $user->getSkin());
                }
                $form .= '</ul>';
            }
            $form .= '<p>' . Xml::submitButton(wfMsg('watchsubpages-addtitles')) . '</p>';
            $form .= '</fieldset></form>';
        }
        $output->addHTML($form);
    }
/**
 * Constructor
 *
 * @param $par Parameter passed to the page
 */
function wfSpecialWatchlist($par)
{
    global $wgUser, $wgOut, $wgLang, $wgRequest;
    global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
    global $wgEnotifWatchlist;
    $fname = 'wfSpecialWatchlist';
    $skin = $wgUser->getSkin();
    $specialTitle = SpecialPage::getTitleFor('Watchlist');
    $wgOut->setRobotPolicy('noindex,nofollow');
    # Anons don't get a watchlist
    if ($wgUser->isAnon()) {
        $wgOut->setPageTitle(wfMsg('watchnologin'));
        $llink = $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), 'returnto=' . $specialTitle->getPrefixedUrl());
        $wgOut->addHtml(wfMsgWikiHtml('watchlistanontext', $llink));
        return;
    }
    $wgOut->setPageTitle(wfMsg('watchlist'));
    $sub = wfMsgExt('watchlistfor', 'parseinline', $wgUser->getName());
    $sub .= '<br />' . WatchlistEditor::buildTools($wgUser->getSkin());
    $wgOut->setSubtitle($sub);
    if (($mode = WatchlistEditor::getMode($wgRequest, $par)) !== false) {
        $editor = new WatchlistEditor();
        $editor->execute($wgUser, $wgOut, $wgRequest, $mode);
        return;
    }
    $uid = $wgUser->getId();
    if ($wgEnotifWatchlist && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) {
        $wgUser->clearAllNotifications($uid);
        $wgOut->redirect($specialTitle->getFullUrl());
        return;
    }
    $defaults = array('days' => floatval($wgUser->getOption('watchlistdays')), 'hideOwn' => (int) $wgUser->getBoolOption('watchlisthideown'), 'hideBots' => (int) $wgUser->getBoolOption('watchlisthidebots'), 'hideMinor' => (int) $wgUser->getBoolOption('watchlisthideminor'), 'namespace' => 'all');
    extract($defaults);
    # Extract variables from the request, falling back to user preferences or
    # other default values if these don't exist
    $prefs['days'] = floatval($wgUser->getOption('watchlistdays'));
    $prefs['hideown'] = $wgUser->getBoolOption('watchlisthideown');
    $prefs['hidebots'] = $wgUser->getBoolOption('watchlisthidebots');
    $prefs['hideminor'] = $wgUser->getBoolOption('watchlisthideminor');
    # Get query variables
    $days = $wgRequest->getVal('days', $prefs['days']);
    $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']);
    $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']);
    $hideMinor = $wgRequest->getBool('hideMinor', $prefs['hideminor']);
    # Get namespace value, if supplied, and prepare a WHERE fragment
    $nameSpace = $wgRequest->getIntOrNull('namespace');
    if (!is_null($nameSpace)) {
        $nameSpace = intval($nameSpace);
        $nameSpaceClause = " AND rc_namespace = {$nameSpace}";
    } else {
        $nameSpace = '';
        $nameSpaceClause = '';
    }
    $dbr = wfGetDB(DB_SLAVE, 'watchlist');
    list($page, $watchlist, $recentchanges) = $dbr->tableNamesN('page', 'watchlist', 'recentchanges');
    $sql = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_user={$uid}";
    $res = $dbr->query($sql, $fname);
    $s = $dbr->fetchObject($res);
    #	Patch *** A1 *** (see A2 below)
    #	adjust for page X, talk:page X, which are both stored separately, but treated together
    $nitems = floor($s->n / 2);
    #	$nitems = $s->n;
    if ($nitems == 0) {
        $wgOut->addWikiText(wfMsg('nowatchlist'));
        return;
    }
    if (is_null($days) || !is_numeric($days)) {
        $big = 1000;
        /* The magical big */
        if ($nitems > $big) {
            # Set default cutoff shorter
            $days = $defaults['days'] = 12.0 / 24.0;
            # 12 hours...
        } else {
            $days = $defaults['days'];
            # default cutoff for shortlisters
        }
    } else {
        $days = floatval($days);
    }
    // Dump everything here
    $nondefaults = array();
    wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideMinor', (int) $hideMinor, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults);
    if ($days <= 0) {
        $andcutoff = '';
    } else {
        $andcutoff = "AND rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'";
        /*
        $sql = "SELECT COUNT(*) AS n FROM $page, $revision  WHERE rev_timestamp>'$cutoff' AND page_id=rev_page";
        $res = $dbr->query( $sql, $fname );
        $s = $dbr->fetchObject( $res );
        $npages = $s->n;
        */
    }
    # If the watchlist is relatively short, it's simplest to zip
    # down its entirety and then sort the results.
    # If it's relatively long, it may be worth our while to zip
    # through the time-sorted page list checking for watched items.
    # Up estimate of watched items by 15% to compensate for talk pages...
    # Toggles
    $andHideOwn = $hideOwn ? "AND (rc_user <> {$uid})" : '';
    $andHideBots = $hideBots ? "AND (rc_bot = 0)" : '';
    $andHideMinor = $hideMinor ? 'AND rc_minor = 0' : '';
    # Show watchlist header
    $header = '';
    if ($wgUser->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
        $header .= wfMsg('wlheader-enotif') . "\n";
    }
    if ($wgEnotifWatchlist && $wgShowUpdatedMarker) {
        $header .= wfMsg('wlheader-showupdated') . "\n";
    }
    # Toggle watchlist content (all recent edits or just the latest)
    if ($wgUser->getOption('extendwatchlist')) {
        $andLatest = '';
        $limitWatchlist = 'LIMIT ' . intval($wgUser->getOption('wllimit'));
    } else {
        $andLatest = 'AND rc_this_oldid=page_latest';
        $limitWatchlist = '';
    }
    $header .= wfMsgExt('watchlist-details', array('parsemag'), $wgLang->formatNum($nitems));
    $wgOut->addWikiText($header);
    # Show a message about slave lag, if applicable
    if (($lag = $dbr->getLag()) > 0) {
        $wgOut->showLagWarning($lag);
    }
    if ($wgEnotifWatchlist && $wgShowUpdatedMarker) {
        $wgOut->addHTML('<form action="' . $specialTitle->escapeLocalUrl() . '" method="post"><input type="submit" name="dummy" value="' . htmlspecialchars(wfMsg('enotif_reset')) . '" /><input type="hidden" name="reset" value="all" /></form>' . "\n\n");
    }
    $sql = "SELECT *\r\n\t  FROM {$watchlist},{$recentchanges},{$page}\r\n\t  WHERE wl_user={$uid}\r\n\t  AND wl_namespace=rc_namespace\r\n\t  AND wl_title=rc_title\r\n\t  AND rc_cur_id=page_id\r\n\t  {$andcutoff}\r\n\t  {$andLatest}\r\n\t  {$andHideOwn}\r\n\t  {$andHideBots}\r\n\t  {$andHideMinor}\r\n\t  {$nameSpaceClause}\r\n\t  ORDER BY rc_timestamp DESC\r\n\t  {$limitWatchlist}";
    $res = $dbr->query($sql, $fname);
    $numRows = $dbr->numRows($res);
    /* Start bottom header */
    $wgOut->addHTML("<hr />\n");
    if ($days >= 1) {
        $wgOut->addWikiText(wfMsgExt('rcnote', array('parseinline'), $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true)) . '<br />', false);
    } elseif ($days > 0) {
        $wgOut->addWikiText(wfMsgExt('wlnote', array('parseinline'), $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />', false);
    }
    $wgOut->addHTML("\n" . wlCutoffLinks($days, 'Watchlist', $nondefaults) . "<br />\n");
    # Spit out some control panel links
    $thisTitle = SpecialPage::getTitleFor('Watchlist');
    $skin = $wgUser->getSkin();
    # Hide/show bot edits
    $label = $hideBots ? wfMsgHtml('watchlist-show-bots') : wfMsgHtml('watchlist-hide-bots');
    $linkBits = wfArrayToCGI(array('hideBots' => 1 - (int) $hideBots), $nondefaults);
    $links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
    # Hide/show own edits
    $label = $hideOwn ? wfMsgHtml('watchlist-show-own') : wfMsgHtml('watchlist-hide-own');
    $linkBits = wfArrayToCGI(array('hideOwn' => 1 - (int) $hideOwn), $nondefaults);
    $links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
    # Hide/show minor edits
    $label = $hideMinor ? wfMsgHtml('watchlist-show-minor') : wfMsgHtml('watchlist-hide-minor');
    $linkBits = wfArrayToCGI(array('hideMinor' => 1 - (int) $hideMinor), $nondefaults);
    $links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
    $wgOut->addHTML(implode(' | ', $links));
    # Form for namespace filtering
    $form = Xml::openElement('form', array('method' => 'post', 'action' => $thisTitle->getLocalUrl()));
    $form .= '<p>';
    $form .= Xml::label(wfMsg('namespace'), 'namespace') . '&nbsp;';
    $form .= Xml::namespaceSelector($nameSpace, '') . '&nbsp;';
    $form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
    $form .= Xml::hidden('days', $days);
    if ($hideOwn) {
        $form .= Xml::hidden('hideOwn', 1);
    }
    if ($hideBots) {
        $form .= Xml::hidden('hideBots', 1);
    }
    if ($hideMinor) {
        $form .= Xml::hidden('hideMinor', 1);
    }
    $form .= Xml::closeElement('form');
    $wgOut->addHtml($form);
    # If there's nothing to show, stop here
    if ($numRows == 0) {
        $wgOut->addWikiText(wfMsgNoTrans('watchnochange'));
        return;
    }
    /* End bottom header */
    /* Do link batch query */
    $linkBatch = new LinkBatch();
    while ($row = $dbr->fetchObject($res)) {
        $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
        if ($row->rc_user != 0) {
            $linkBatch->add(NS_USER, $userNameUnderscored);
        }
        $linkBatch->add(NS_USER_TALK, $userNameUnderscored);
    }
    $linkBatch->execute();
    $dbr->dataSeek($res, 0);
    $list = ChangesList::newFromUser($wgUser);
    $s = $list->beginRecentChangesList();
    $counter = 1;
    while ($obj = $dbr->fetchObject($res)) {
        # Make RC entry
        $rc = RecentChange::newFromRow($obj);
        $rc->counter = $counter++;
        if ($wgShowUpdatedMarker) {
            $updated = $obj->wl_notificationtimestamp;
        } else {
            // Same visual appearance as MW 1.4
            $updated = true;
        }
        if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
            $sql3 = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_title='" . $dbr->strencode($obj->page_title) . "' AND wl_namespace='{$obj->page_namespace}'";
            $res3 = $dbr->query($sql3, $fname);
            $x = $dbr->fetchObject($res3);
            $rc->numberofWatchingusers = $x->n;
        } else {
            $rc->numberofWatchingusers = 0;
        }
        $s .= $list->recentChangesLine($rc, $updated);
    }
    $s .= $list->endRecentChangesList();
    $dbr->freeResult($res);
    $wgOut->addHTML($s);
}
Esempio n. 20
0
 protected function form()
 {
     global $wgOut, $wgEnableNewpagesUserFilter, $wgScript;
     // Consume values
     $this->opts->consumeValue('offset');
     // don't carry offset, DWIW
     $namespace = $this->opts->consumeValue('namespace');
     $username = $this->opts->consumeValue('username');
     // Check username input validity
     $ut = Title::makeTitleSafe(NS_USER, $username);
     $userText = $ut ? $ut->getText() : '';
     // Store query values in hidden fields so that form submission doesn't lose them
     $hidden = array();
     foreach ($this->opts->getUnconsumedValues() as $key => $value) {
         $hidden[] = Xml::hidden($key, $value);
     }
     $hidden = implode("\n", $hidden);
     $form = Xml::openElement('form', array('action' => $wgScript)) . Xml::hidden('title', $this->getTitle()->getPrefixedDBkey()) . Xml::fieldset(wfMsg('newpages')) . Xml::openElement('table', array('id' => 'mw-newpages-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('namespace'), 'namespace') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::namespaceSelector($namespace, 'all') . "</td>\n\t\t\t</tr>" . ($wgEnableNewpagesUserFilter ? "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('newpages-username'), 'mw-np-username') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('username', 30, $userText, array('id' => 'mw-np-username')) . "</td>\n\t\t\t</tr>" : "") . "<tr> <td></td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('allpagessubmit')) . "</td>\n\t\t\t</tr>" . "<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='mw-input'>" . $this->filterLinks() . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset') . $hidden . Xml::closeElement('form');
     $wgOut->addHTML($form);
 }
Esempio n. 21
0
/**
 * Generates the namespace selector form with hidden attributes.
 * @param $options Array: the options to be included.
 */
function contributionsForm($options)
{
    global $wgScript, $wgTitle, $wgRequest;
    $options['title'] = $wgTitle->getPrefixedText();
    if (!isset($options['target'])) {
        $options['target'] = '';
    } else {
        //XXCHANGED
        $options['target'] = str_replace('-', ' ', $options['target']);
    }
    if (!isset($options['namespace'])) {
        $options['namespace'] = '';
    }
    if (!isset($options['contribs'])) {
        $options['contribs'] = 'user';
    }
    if (!isset($options['year'])) {
        $options['year'] = '';
    }
    if (!isset($options['month'])) {
        $options['month'] = '';
    }
    if ($options['contribs'] == 'newbie') {
        $options['target'] = '';
    }
    $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
    foreach ($options as $name => $value) {
        if (in_array($name, array('namespace', 'target', 'contribs', 'year', 'month'))) {
            continue;
        }
        $f .= "\t" . Xml::hidden($name, $value) . "\n";
    }
    $f .= '<fieldset>' . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . Xml::radioLabel(wfMsgExt('sp-contributions-newbies', array('parseinline')), 'contribs', 'newbie', 'newbie', $options['contribs'] == 'newbie' ? true : false) . '<br />' . Xml::radioLabel(wfMsgExt('sp-contributions-username', array('parseinline')), 'contribs', 'user', 'user', $options['contribs'] == 'user' ? true : false) . ' ' . Xml::input('target', 20, $options['target']) . '&nbsp;&nbsp;&nbsp; ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($options['namespace'], '') . '</span>' . Xml::openElement('p') . '<span style="white-space: nowrap">' . Xml::label(wfMsg('year'), 'year') . ' ' . Xml::input('year', 4, $options['year'], array('id' => 'year', 'maxlength' => 4)) . '&nbsp;&nbsp;</span>' . ' ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('month'), 'month') . ' ' . Xml::monthSelector($options['month'], -1) . ' ' . '&nbsp;&nbsp;</span><br />' . Xml::submitButton(wfMsg('sp-contributions-submit'), array("class" => "button primary", "style" => "float:right; margin-top:5px; margin-right:0;")) . Xml::closeElement('p');
    $explain = wfMsgExt('sp-contributions-explain', 'parseinline');
    if (!wfEmptyMsg('sp-contributions-explain', $explain)) {
        $f .= "<p>{$explain}</p>";
    }
    $f .= '</fieldset>' . Xml::closeElement('form');
    return $f;
}
Esempio n. 22
0
/**
 * Constructor
 *
 * @param $par Parameter passed to the page
 */
function wfSpecialWatchlist($par)
{
    global $wgUser, $wgOut, $wgLang, $wgRequest;
    global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
    global $wgEnotifWatchlist;
    $skin = $wgUser->getSkin();
    $specialTitle = SpecialPage::getTitleFor('Watchlist');
    $wgOut->setRobotPolicy('noindex,nofollow');
    # Anons don't get a watchlist
    if ($wgUser->isAnon()) {
        $wgOut->setPageTitle(wfMsg('watchnologin'));
        $llink = $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), 'returnto=' . $specialTitle->getPrefixedUrl());
        $wgOut->addHTML(wfMsgWikiHtml('watchlistanontext', $llink));
        return;
    }
    $wgOut->setPageTitle(wfMsg('watchlist'));
    $sub = wfMsgExt('watchlistfor', 'parseinline', $wgUser->getName());
    $sub .= '<br />' . WatchlistEditor::buildTools($wgUser->getSkin());
    $wgOut->setSubtitle($sub);
    if (($mode = WatchlistEditor::getMode($wgRequest, $par)) !== false) {
        $editor = new WatchlistEditor();
        $editor->execute($wgUser, $wgOut, $wgRequest, $mode);
        return;
    }
    $uid = $wgUser->getId();
    if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) {
        $wgUser->clearAllNotifications($uid);
        $wgOut->redirect($specialTitle->getFullUrl());
        return;
    }
    $defaults = array('days' => floatval($wgUser->getOption('watchlistdays')), 'hideMinor' => (int) $wgUser->getBoolOption('watchlisthideminor'), 'hideBots' => (int) $wgUser->getBoolOption('watchlisthidebots'), 'hideAnons' => (int) $wgUser->getBoolOption('watchlisthideanons'), 'hideLiu' => (int) $wgUser->getBoolOption('watchlisthideliu'), 'hidePatrolled' => (int) $wgUser->getBoolOption('watchlisthidepatrolled'), 'hideOwn' => (int) $wgUser->getBoolOption('watchlisthideown'), 'namespace' => 'all', 'invert' => false);
    extract($defaults);
    # Extract variables from the request, falling back to user preferences or
    # other default values if these don't exist
    $prefs['days'] = floatval($wgUser->getOption('watchlistdays'));
    $prefs['hideminor'] = $wgUser->getBoolOption('watchlisthideminor');
    $prefs['hidebots'] = $wgUser->getBoolOption('watchlisthidebots');
    $prefs['hideanons'] = $wgUser->getBoolOption('watchlisthideanon');
    $prefs['hideliu'] = $wgUser->getBoolOption('watchlisthideliu');
    $prefs['hideown'] = $wgUser->getBoolOption('watchlisthideown');
    $prefs['hidepatrolled'] = $wgUser->getBoolOption('watchlisthidepatrolled');
    # Get query variables
    $days = $wgRequest->getVal('days', $prefs['days']);
    $hideMinor = $wgRequest->getBool('hideMinor', $prefs['hideminor']);
    $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']);
    $hideAnons = $wgRequest->getBool('hideAnons', $prefs['hideanons']);
    $hideLiu = $wgRequest->getBool('hideLiu', $prefs['hideliu']);
    $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']);
    $hidePatrolled = $wgRequest->getBool('hidePatrolled', $prefs['hidepatrolled']);
    # Get namespace value, if supplied, and prepare a WHERE fragment
    $nameSpace = $wgRequest->getIntOrNull('namespace');
    $invert = $wgRequest->getIntOrNull('invert');
    if (!is_null($nameSpace)) {
        $nameSpace = intval($nameSpace);
        if ($invert && $nameSpace !== 'all') {
            $nameSpaceClause = "rc_namespace != {$nameSpace}";
        } else {
            $nameSpaceClause = "rc_namespace = {$nameSpace}";
        }
    } else {
        $nameSpace = '';
        $nameSpaceClause = '';
    }
    $dbr = wfGetDB(DB_SLAVE, 'watchlist');
    list($page, $watchlist, $recentchanges) = $dbr->tableNamesN('page', 'watchlist', 'recentchanges');
    $watchlistCount = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_user' => $uid), __METHOD__);
    // Adjust for page X, talk:page X, which are both stored separately,
    // but treated together
    $nitems = floor($watchlistCount / 2);
    if (is_null($days) || !is_numeric($days)) {
        $big = 1000;
        /* The magical big */
        if ($nitems > $big) {
            # Set default cutoff shorter
            $days = $defaults['days'] = 12.0 / 24.0;
            # 12 hours...
        } else {
            $days = $defaults['days'];
            # default cutoff for shortlisters
        }
    } else {
        $days = floatval($days);
    }
    // Dump everything here
    $nondefaults = array();
    wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideMinor', (int) $hideMinor, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideAnons', (int) $hideAnons, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideLiu', (int) $hideLiu, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hidePatrolled', (int) $hidePatrolled, $defaults, $nondefaults);
    if ($nitems == 0) {
        $wgOut->addWikiMsg('nowatchlist');
        return;
    }
    if ($days <= 0) {
        $andcutoff = '';
    } else {
        $andcutoff = "rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'";
    }
    # If the watchlist is relatively short, it's simplest to zip
    # down its entirety and then sort the results.
    # If it's relatively long, it may be worth our while to zip
    # through the time-sorted page list checking for watched items.
    # Up estimate of watched items by 15% to compensate for talk pages...
    # Toggles
    $andHideOwn = $hideOwn ? "rc_user != {$uid}" : '';
    $andHideBots = $hideBots ? "rc_bot = 0" : '';
    $andHideMinor = $hideMinor ? "rc_minor = 0" : '';
    $andHideLiu = $hideLiu ? "rc_user = 0" : '';
    $andHideAnons = $hideAnons ? "rc_user != 0" : '';
    $andHidePatrolled = $wgUser->useRCPatrol() && $hidePatrolled ? "rc_patrolled != 1" : '';
    # Toggle watchlist content (all recent edits or just the latest)
    if ($wgUser->getOption('extendwatchlist')) {
        $andLatest = '';
        $limitWatchlist = intval($wgUser->getOption('wllimit'));
    } else {
        # Top log Ids for a page are not stored
        $andLatest = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
        $limitWatchlist = 0;
    }
    # Show a message about slave lag, if applicable
    if (($lag = $dbr->getLag()) > 0) {
        $wgOut->showLagWarning($lag);
    }
    # Create output form
    $form = Xml::fieldset(wfMsg('watchlist-options'), false, array('id' => 'mw-watchlist-options'));
    # Show watchlist header
    $form .= wfMsgExt('watchlist-details', array('parseinline'), $wgLang->formatNum($nitems));
    if ($wgUser->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
        $form .= wfMsgExt('wlheader-enotif', 'parse') . "\n";
    }
    if ($wgShowUpdatedMarker) {
        $form .= Xml::openElement('form', array('method' => 'post', 'action' => $specialTitle->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . wfMsgExt('wlheader-showupdated', array('parseinline')) . ' ' . Xml::submitButton(wfMsg('enotif_reset'), array('name' => 'dummy')) . Xml::hidden('reset', 'all') . Xml::closeElement('form');
    }
    $form .= '<hr />';
    $tables = array('recentchanges', 'watchlist', 'page');
    $fields = array("{$recentchanges}.*");
    $conds = array();
    $join_conds = array('watchlist' => array('INNER JOIN', "wl_user='******' AND wl_namespace=rc_namespace AND wl_title=rc_title"), 'page' => array('LEFT JOIN', 'rc_cur_id=page_id'));
    $options = array('ORDER BY' => 'rc_timestamp DESC');
    if ($wgShowUpdatedMarker) {
        $fields[] = 'wl_notificationtimestamp';
    }
    if ($limitWatchlist) {
        $options['LIMIT'] = $limitWatchlist;
    }
    if ($andcutoff) {
        $conds[] = $andcutoff;
    }
    if ($andLatest) {
        $conds[] = $andLatest;
    }
    if ($andHideOwn) {
        $conds[] = $andHideOwn;
    }
    if ($andHideBots) {
        $conds[] = $andHideBots;
    }
    if ($andHideMinor) {
        $conds[] = $andHideMinor;
    }
    if ($andHideLiu) {
        $conds[] = $andHideLiu;
    }
    if ($andHideAnons) {
        $conds[] = $andHideAnons;
    }
    if ($andHidePatrolled) {
        $conds[] = $andHidePatrolled;
    }
    if ($nameSpaceClause) {
        $conds[] = $nameSpaceClause;
    }
    wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
    $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
    $numRows = $dbr->numRows($res);
    /* Start bottom header */
    $wlInfo = '';
    if ($days >= 1) {
        $wlInfo = wfMsgExt('rcnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true), $wgLang->date(wfTimestampNow(), true), $wgLang->time(wfTimestampNow(), true)) . '<br />';
    } elseif ($days > 0) {
        $wlInfo = wfMsgExt('wlnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />';
    }
    $cutofflinks = "\n" . wlCutoffLinks($days, 'Watchlist', $nondefaults) . "<br />\n";
    # Spit out some control panel links
    $thisTitle = SpecialPage::getTitleFor('Watchlist');
    $skin = $wgUser->getSkin();
    $showLinktext = wfMsgHtml('show');
    $hideLinktext = wfMsgHtml('hide');
    # Hide/show minor edits
    $label = $hideMinor ? $showLinktext : $hideLinktext;
    $linkBits = wfArrayToCGI(array('hideMinor' => 1 - (int) $hideMinor), $nondefaults);
    $links[] = wfMsgHtml('rcshowhideminor', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    # Hide/show bot edits
    $label = $hideBots ? $showLinktext : $hideLinktext;
    $linkBits = wfArrayToCGI(array('hideBots' => 1 - (int) $hideBots), $nondefaults);
    $links[] = wfMsgHtml('rcshowhidebots', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    # Hide/show anonymous edits
    $label = $hideAnons ? $showLinktext : $hideLinktext;
    $linkBits = wfArrayToCGI(array('hideAnons' => 1 - (int) $hideAnons), $nondefaults);
    $links[] = wfMsgHtml('rcshowhideanons', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    # Hide/show logged in edits
    $label = $hideLiu ? $showLinktext : $hideLinktext;
    $linkBits = wfArrayToCGI(array('hideLiu' => 1 - (int) $hideLiu), $nondefaults);
    $links[] = wfMsgHtml('rcshowhideliu', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    # Hide/show own edits
    $label = $hideOwn ? $showLinktext : $hideLinktext;
    $linkBits = wfArrayToCGI(array('hideOwn' => 1 - (int) $hideOwn), $nondefaults);
    $links[] = wfMsgHtml('rcshowhidemine', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    # Hide/show patrolled edits
    if ($wgUser->useRCPatrol()) {
        $label = $hidePatrolled ? $showLinktext : $hideLinktext;
        $linkBits = wfArrayToCGI(array('hidePatrolled' => 1 - (int) $hidePatrolled), $nondefaults);
        $links[] = wfMsgHtml('rcshowhidepatr', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
    }
    # Namespace filter and put the whole form together.
    $form .= $wlInfo;
    $form .= $cutofflinks;
    $form .= implode(' | ', $links);
    $form .= Xml::openElement('form', array('method' => 'post', 'action' => $thisTitle->getLocalUrl()));
    $form .= '<hr /><p>';
    $form .= Xml::label(wfMsg('namespace'), 'namespace') . '&nbsp;';
    $form .= Xml::namespaceSelector($nameSpace, '') . '&nbsp;';
    $form .= Xml::checkLabel(wfMsg('invert'), 'invert', 'nsinvert', $invert) . '&nbsp;';
    $form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
    $form .= Xml::hidden('days', $days);
    if ($hideMinor) {
        $form .= Xml::hidden('hideMinor', 1);
    }
    if ($hideBots) {
        $form .= Xml::hidden('hideBots', 1);
    }
    if ($hideAnons) {
        $form .= Xml::hidden('hideAnons', 1);
    }
    if ($hideLiu) {
        $form .= Xml::hidden('hideLiu', 1);
    }
    if ($hideOwn) {
        $form .= Xml::hidden('hideOwn', 1);
    }
    $form .= Xml::closeElement('form');
    $form .= Xml::closeElement('fieldset');
    $wgOut->addHTML($form);
    # If there's nothing to show, stop here
    if ($numRows == 0) {
        $wgOut->addWikiMsg('watchnochange');
        return;
    }
    /* End bottom header */
    /* Do link batch query */
    $linkBatch = new LinkBatch();
    while ($row = $dbr->fetchObject($res)) {
        $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
        if ($row->rc_user != 0) {
            $linkBatch->add(NS_USER, $userNameUnderscored);
        }
        $linkBatch->add(NS_USER_TALK, $userNameUnderscored);
    }
    $linkBatch->execute();
    $dbr->dataSeek($res, 0);
    $list = ChangesList::newFromUser($wgUser);
    $s = $list->beginRecentChangesList();
    $counter = 1;
    while ($obj = $dbr->fetchObject($res)) {
        # Make RC entry
        $rc = RecentChange::newFromRow($obj);
        $rc->counter = $counter++;
        if ($wgShowUpdatedMarker) {
            $updated = $obj->wl_notificationtimestamp;
        } else {
            $updated = false;
        }
        if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
            $rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
        } else {
            $rc->numberofWatchingusers = 0;
        }
        $s .= $list->recentChangesLine($rc, $updated);
    }
    $s .= $list->endRecentChangesList();
    $dbr->freeResult($res);
    $wgOut->addHTML($s);
}
 function whatlinkshereForm($options = array('target' => '', 'namespace' => ''))
 {
     global $wgScript, $wgTitle;
     $options['title'] = $wgTitle->getPrefixedText();
     $f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('whatlinkshere')) . Xml::inputLabel(wfMsg('whatlinkshere-page'), 'target', 'mw-whatlinkshere-target', 40, $options['target']) . ' ';
     foreach ($options as $name => $value) {
         if ($name === 'namespace' || $name === 'target') {
             continue;
         }
         $f .= "\t" . Xml::hidden($name, $value) . "\n";
     }
     $f .= Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($options['namespace'], '') . Xml::submitButton(wfMsg('allpagessubmit')) . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n";
     return $f;
 }
Esempio n. 24
0
 public static function namespaceRestrictionForm($uid, $user, $oldRestrictions)
 {
     global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgContLang;
     $error = '';
     $success = false;
     if ($wgRequest->wasPosted() && $wgRequest->getVal('type') == UserRestriction::NAMESPACE && $wgUser->matchEditToken($wgRequest->getVal('edittoken'))) {
         $ns = $wgRequest->getVal('namespace');
         if ($wgContLang->getNsText($ns) === false) {
             $error = wfMsgExt('restrictuser-badnamespace', 'parseinline');
         } elseif (UserRestriction::convertExpiry($wgRequest->getVal('expiry')) === false) {
             $error = wfMsgExt('restrictuser-badexpiry', 'parseinline', $wgRequest->getVal('expiry'));
         } else {
             foreach ($oldRestrictions as $r) {
                 if ($r->isNamespace() && $r->getNamespace() == $ns) {
                     $error = wfMsgExt('restrictuser-dupnamespace', 'parse');
                 }
             }
         }
         if (!$error) {
             self::doNamespaceRestriction($uid, $user);
             $success = array('restrictuser-success', $user);
         }
     }
     $useRequestValues = $wgRequest->getVal('type') == UserRestriction::NAMESPACE;
     $wgOut->addHTML(Xml::fieldset(wfMsg('restrictuser-legend-namespace')));
     self::printSuccessError($success, $error);
     $wgOut->addHTML(Xml::openElement('form', array('action' => $wgTitle->getLocalUrl(), 'method' => 'post')));
     $wgOut->addHTML(Xml::hidden('type', UserRestriction::NAMESPACE));
     $wgOut->addHTML(Xml::hidden('edittoken', $wgUser->editToken()));
     $wgOut->addHTML(Xml::hidden('user', $user));
     $form = array();
     $form['restrictuser-namespace'] = Xml::namespaceSelector($wgRequest->getVal('namespace'));
     $form['restrictuser-expiry'] = Xml::input('expiry', false, $useRequestValues ? $wgRequest->getVal('expiry') : false);
     $form['restrictuser-reason'] = Xml::input('reason', false, $useRequestValues ? $wgRequest->getVal('reason') : false);
     $wgOut->addHTML(Xml::buildForm($form, 'restrictuser-submit'));
     $wgOut->addHTML("</form></fieldset>");
 }
Esempio n. 25
0
 private function showForm()
 {
     global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources, $wgExportMaxLinkDepth;
     if (!$wgUser->isAllowed('import') && !$wgUser->isAllowed('importupload')) {
         return $wgOut->permissionRequired('import');
     }
     $action = $wgTitle->getLocalUrl('action=submit');
     if ($wgUser->isAllowed('importupload')) {
         $wgOut->addWikiMsg("importtext");
         $wgOut->addHTML(Xml::fieldset(wfMsg('import-upload')) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action, 'id' => 'mw-import-upload-form')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'upload') . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-upload-filename'), 'xmlimport') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('xmlimport', 50, '', array('type' => 'file')) . ' ' . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-comment'), 'mw-import-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-import-comment', 'type' => 'text')) . ' ' . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('uploadbtn')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::hidden('editToken', $wgUser->editToken()) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     } else {
         if (empty($wgImportSources)) {
             $wgOut->addWikiMsg('importnosources');
         }
     }
     if ($wgUser->isAllowed('import') && !empty($wgImportSources)) {
         # Show input field for import depth only if $wgExportMaxLinkDepth > 0
         $importDepth = '';
         if ($wgExportMaxLinkDepth > 0) {
             $importDepth = "<tr>\n\t\t\t\t\t\t\t<td class='mw-label'>" . wfMsgExt('export-pagelinks', 'parseinline') . "</td>\n\t\t\t\t\t\t\t<td class='mw-input'>" . Xml::input('pagelink-depth', 3, 0) . "</td>\n\t\t\t\t\t\t</tr>";
         }
         $wgOut->addHTML(Xml::fieldset(wfMsg('importinterwiki')) . Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'mw-import-interwiki-form')) . wfMsgExt('import-interwiki-text', array('parse')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'interwiki') . Xml::hidden('editToken', $wgUser->editToken()) . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-interwiki-source'), 'interwiki') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::openElement('select', array('name' => 'interwiki')));
         foreach ($wgImportSources as $prefix) {
             $selected = $this->interwiki === $prefix ? ' selected="selected"' : '';
             $wgOut->addHTML(Xml::option($prefix, $prefix, $selected));
         }
         $wgOut->addHTML(Xml::closeElement('select') . Xml::input('frompage', 50, $this->frompage) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $this->history) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('import-interwiki-templates'), 'interwikiTemplates', 'interwikiTemplates', $this->includeTemplates) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t{$importDepth}\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-interwiki-namespace'), 'namespace') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::namespaceSelector($this->namespace, '') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-comment'), 'mw-interwiki-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-interwiki-comment', 'type' => 'text')) . ' ' . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('import-interwiki-submit'), array('accesskey' => 's')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     }
 }
 /**
  * Display the interwiki watchlist
  */
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgRequest;
     global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
     // Add feed links
     $wlToken = $wgUser->getOption('watchlisttoken');
     if (!$wlToken) {
         $wlToken = sha1(mt_rand() . microtime(true));
         $wgUser->setOption('watchlisttoken', $wlToken);
         $wgUser->saveSettings();
     }
     global $wgServer, $wgScriptPath, $wgFeedClasses;
     $apiParams = array('action' => 'feedwatchlist', 'allrev' => 'allrev', 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken);
     $feedTemplate = wfScript('api') . '?';
     foreach ($wgFeedClasses as $format => $class) {
         $theseParams = $apiParams + array('feedformat' => $format);
         $url = $feedTemplate . wfArrayToCGI($theseParams);
         $wgOut->addFeedLink($format, $url);
     }
     $skin = $wgUser->getSkin();
     $specialTitle = SpecialPage::getTitleFor('InterwikiWatchlist');
     $wgOut->setRobotPolicy('noindex,nofollow');
     # Anons don't get a watchlist
     if ($wgUser->isAnon()) {
         $wgOut->setPageTitle(wfMsg('watchnologin'));
         $llink = $skin->linkKnown(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), array(), array('returnto' => $specialTitle->getPrefixedText()));
         $wgOut->addHTML(wfMsgWikiHtml('watchlistanontext', $llink));
         return;
     }
     $wgOut->setPageTitle(wfMsg('interwikiwatchlist'));
     $sub = wfMsgExt('watchlistfor', 'parseinline', $wgUser->getName());
     $sub .= '<br />' . SpecialEditWatchlist::buildTools($wgUser->getSkin());
     $wgOut->setSubtitle($sub);
     $mode = SpecialEditWatchlist::getMode($this->getRequest(), $par);
     if ($mode !== false) {
         # TODO: localise?
         switch ($mode) {
             case SpecialEditWatchlist::EDIT_CLEAR:
                 $mode = 'clear';
                 break;
             case SpecialEditWatchlist::EDIT_RAW:
                 $mode = 'raw';
                 break;
             default:
                 $mode = null;
         }
         $title = SpecialPage::getTitleFor('EditWatchlist', $mode);
         $wgOut->redirect($title->getLocalUrl());
         return;
     }
     $uid = $wgUser->getId();
     if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) {
         $wgUser->clearAllNotifications();
         $wgOut->redirect($specialTitle->getFullUrl());
         return;
     }
     $defaults = array('days' => floatval($wgUser->getOption('watchlistdays')), 'hideMinor' => (int) $wgUser->getBoolOption('watchlisthideminor'), 'hideBots' => (int) $wgUser->getBoolOption('watchlisthidebots'), 'hideAnons' => (int) $wgUser->getBoolOption('watchlisthideanons'), 'hideLiu' => (int) $wgUser->getBoolOption('watchlisthideliu'), 'hidePatrolled' => (int) $wgUser->getBoolOption('watchlisthidepatrolled'), 'hideOwn' => (int) $wgUser->getBoolOption('watchlisthideown'), 'namespace' => 'all', 'invert' => false);
     extract($defaults);
     # Extract variables from the request, falling back to user preferences or
     # other default values if these don't exist
     $prefs['days'] = floatval($wgUser->getOption('watchlistdays'));
     $prefs['hideminor'] = $wgUser->getBoolOption('watchlisthideminor');
     $prefs['hidebots'] = $wgUser->getBoolOption('watchlisthidebots');
     $prefs['hideanons'] = $wgUser->getBoolOption('watchlisthideanon');
     $prefs['hideliu'] = $wgUser->getBoolOption('watchlisthideliu');
     $prefs['hideown'] = $wgUser->getBoolOption('watchlisthideown');
     $prefs['hidepatrolled'] = $wgUser->getBoolOption('watchlisthidepatrolled');
     # Get query variables
     $days = $wgRequest->getVal('days', $prefs['days']);
     $hideMinor = $wgRequest->getBool('hideMinor', $prefs['hideminor']);
     $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']);
     $hideAnons = $wgRequest->getBool('hideAnons', $prefs['hideanons']);
     $hideLiu = $wgRequest->getBool('hideLiu', $prefs['hideliu']);
     $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']);
     $hidePatrolled = $wgRequest->getBool('hidePatrolled', $prefs['hidepatrolled']);
     # Get namespace value, if supplied, and prepare a WHERE fragment
     $nameSpace = $wgRequest->getIntOrNull('namespace');
     $invert = $wgRequest->getIntOrNull('invert');
     if (!is_null($nameSpace)) {
         $nameSpace = intval($nameSpace);
         if ($invert && $nameSpace !== 'all') {
             $nameSpaceClause = "integration_rc_namespace != {$nameSpace}";
         } else {
             $nameSpaceClause = "integration_rc_namespace = {$nameSpace}";
         }
     } else {
         $nameSpace = '';
         $nameSpaceClause = '';
     }
     $dbr = wfGetDB(DB_SLAVE, 'integration_watchlist');
     $recentchanges = $dbr->tableName('integration_recentchanges');
     $nitems = $this->countItems();
     if (is_null($days) || !is_numeric($days)) {
         $big = 1000;
         /* The magical big */
         if ($nitems > $big) {
             # Set default cutoff shorter
             $days = $defaults['days'] = 12.0 / 24.0;
             # 12 hours...
         } else {
             $days = $defaults['days'];
             # default cutoff for shortlisters
         }
     } else {
         $days = floatval($days);
     }
     // Dump everything here
     $nondefaults = array();
     wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideMinor', (int) $hideMinor, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideAnons', (int) $hideAnons, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideLiu', (int) $hideLiu, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hidePatrolled', (int) $hidePatrolled, $defaults, $nondefaults);
     if ($nitems == 0) {
         $wgOut->addWikiMsg('nowatchlist');
         return;
     }
     # Possible where conditions
     $conds = array();
     if ($days <= 0) {
         $andcutoff = '';
     } else {
         $conds[] = "integration_rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'";
     }
     # If the watchlist is relatively short, it's simplest to zip
     # down its entirety and then sort the results.
     # If it's relatively long, it may be worth our while to zip
     # through the time-sorted page list checking for watched items.
     # Up estimate of watched items by 15% to compensate for talk pages...
     # Toggles
     if ($hideOwn) {
         $conds[] = "integration_rc_user != {$uid}";
     }
     if ($hideBots) {
         $conds[] = 'integration_rc_bot = 0';
     }
     if ($hideMinor) {
         $conds[] = 'integration_rc_minor = 0';
     }
     if ($hideLiu) {
         $conds[] = 'integration_rc_user = 0';
     }
     if ($hideAnons) {
         $conds[] = 'integration_rc_user != 0';
     }
     if ($wgUser->useRCPatrol() && $hidePatrolled) {
         $conds[] = 'integration_rc_patrolled != 1';
     }
     if ($nameSpaceClause) {
         $conds[] = $nameSpaceClause;
     }
     # Toggle watchlist content (all recent edits or just the latest)
     if ($wgUser->getOption('extendwatchlist')) {
         $limitWatchlist = intval($wgUser->getOption('wllimit'));
         $usePage = false;
     } else {
         # Top log Ids for a page are not stored
         $conds[] = 'integration_rc_this_oldid=integration_page_latest OR integration_rc_type=' . RC_LOG;
         $limitWatchlist = 0;
         $usePage = true;
     }
     # Show a message about slave lag, if applicable
     $lag = wfGetLB()->safeGetLag($dbr);
     if ($lag > 0) {
         $wgOut->showLagWarning($lag);
     }
     # Create output form
     $form = Xml::fieldset(wfMsg('watchlist-options'), false, array('id' => 'mw-watchlist-options'));
     # Show watchlist header
     $form .= wfMsgExt('watchlist-details', array('parseinline'), $wgLang->formatNum($nitems));
     if ($wgUser->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
         $form .= wfMsgExt('wlheader-enotif', 'parse') . "\n";
     }
     if ($wgShowUpdatedMarker) {
         $form .= Xml::openElement('form', array('method' => 'post', 'action' => $specialTitle->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . wfMsgExt('wlheader-showupdated', array('parseinline')) . ' ' . Xml::submitButton(wfMsg('enotif_reset'), array('name' => 'dummy')) . Html::Hidden('reset', 'all') . Xml::closeElement('form');
     }
     $form .= '<hr />';
     $tables = array('integration_recentchanges', 'integration_watchlist');
     $fields = array("{$recentchanges}.*");
     $join_conds = array('integration_watchlist' => array('INNER JOIN', "integration_wl_user='******' AND integration_wl_namespace=integration_rc_namespace AND integration_wl_title=integration_rc_title AND integration_wl_db=integration_rc_db"));
     $options = array('ORDER BY' => 'integration_rc_timestamp DESC');
     if ($wgShowUpdatedMarker) {
         $fields[] = 'integration_wl_notificationtimestamp';
     }
     if ($limitWatchlist) {
         $options['LIMIT'] = $limitWatchlist;
     }
     $rollbacker = $wgUser->isAllowed('rollback');
     if ($usePage || $rollbacker) {
         $tables[] = 'integration_page';
         $join_conds['integration_page'] = array('LEFT JOIN', 'integration_rc_cur_id=integration_page_id', 'integration_rc_db=integration_page_db');
         if ($rollbacker) {
             $fields[] = 'integration_page_latest';
         }
     }
     InterwikiIntegrationFunctions::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
     wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
     $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
     $numRows = $dbr->numRows($res);
     /* Start bottom header */
     $wlInfo = '';
     if ($days >= 1) {
         $wlInfo = wfMsgExt('rcnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true), $wgLang->date(wfTimestampNow(), true), $wgLang->time(wfTimestampNow(), true)) . '<br />';
     } elseif ($days > 0) {
         $wlInfo = wfMsgExt('wlnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />';
     }
     $cutofflinks = "\n" . $this->cutoffLinks($days, $nondefaults) . "<br />\n";
     # Spit out some control panel links
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideminor', 'hideMinor', $hideMinor);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhidebots', 'hideBots', $hideBots);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideanons', 'hideAnons', $hideAnons);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideliu', 'hideLiu', $hideLiu);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn);
     if ($wgUser->useRCPatrol()) {
         $links[] = $this->showHideLink($nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled);
     }
     # Namespace filter and put the whole form together.
     $form .= $wlInfo;
     $form .= $cutofflinks;
     $form .= $wgLang->pipeList($links);
     $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector'));
     $form .= '<hr /><p>';
     $form .= Xml::label(wfMsg('namespace'), 'namespace') . '&#160;';
     $form .= Xml::namespaceSelector($nameSpace, '') . '&#160;';
     $form .= Xml::checkLabel(wfMsg('invert'), 'invert', 'nsinvert', $invert) . '&#160;';
     $form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
     $form .= Html::Hidden('days', $days);
     if ($hideMinor) {
         $form .= Html::Hidden('hideMinor', 1);
     }
     if ($hideBots) {
         $form .= Html::Hidden('hideBots', 1);
     }
     if ($hideAnons) {
         $form .= Html::Hidden('hideAnons', 1);
     }
     if ($hideLiu) {
         $form .= Html::Hidden('hideLiu', 1);
     }
     if ($hideOwn) {
         $form .= Html::Hidden('hideOwn', 1);
     }
     $form .= Xml::closeElement('form');
     $form .= Xml::closeElement('fieldset');
     $wgOut->addHTML($form);
     $wgOut->addHTML(InterwikiIntegrationChangesList::flagLegend());
     # If there's nothing to show, stop here
     if ($numRows == 0) {
         $wgOut->addWikiMsg('watchnochange');
         return;
     }
     /* End bottom header */
     /* Do link batch query */
     $linkBatch = new LinkBatch();
     while ($row = $dbr->fetchObject($res)) {
         $userNameUnderscored = str_replace(' ', '_', $row->integration_rc_user_text);
         if ($row->integration_rc_user != 0) {
             $linkBatch->add(NS_USER, $userNameUnderscored);
         }
         $linkBatch->add(NS_USER_TALK, $userNameUnderscored);
         $linkBatch->add($row->integration_rc_namespace, $row->integration_rc_title);
     }
     $linkBatch->execute();
     $dbr->dataSeek($res, 0);
     $list = InterwikiIntegrationChangesList::newFromUser($wgUser);
     $list->setWatchlistDivs();
     $s = $list->beginRecentInterwikiIntegrationChangesList();
     $counter = 1;
     while ($obj = $dbr->fetchObject($res)) {
         # Make RC entry
         $rc = InterwikiIntegrationRecentChange::newFromRow($obj);
         $rc->counter = $counter++;
         if ($wgShowUpdatedMarker) {
             $updated = $obj->integration_wl_notificationtimestamp;
         } else {
             $updated = false;
         }
         if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
             $rc->numberofWatchingusers = $dbr->selectField('integration_watchlist', 'COUNT(*)', array('integration_wl_namespace' => $obj->integration_rc_namespace, 'integration_wl_title' => $obj->integration_rc_title), __METHOD__);
         } else {
             $rc->numberofWatchingusers = 0;
         }
         $s .= $list->recentChangesLine($rc, $updated, $counter);
     }
     $s .= $list->endRecentInterwikiIntegrationChangesList();
     $dbr->freeResult($res);
     $wgOut->addHTML($s);
 }
Esempio n. 27
0
 /**
  * Prepare the namespace filter drop-down; standard namespace
  * selector, sans the MediaWiki namespace
  *
  * @param $namespace Mixed: pre-select namespace
  * @return string
  */
 function getNamespaceMenu($namespace = null)
 {
     return Xml::label(wfMsg('namespace'), 'namespace') . '&#160;' . Xml::namespaceSelector($namespace, '');
 }
 /**
  * Show a form for filtering namespace and username
  *
  * @return string
  */
 function getPageHeader()
 {
     global $wgScript, $wgContLang, $wgGroupPermissions, $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
     $sk = $wgUser->getSkin();
     $align = $wgContLang->isRTL() ? 'left' : 'right';
     $self = SpecialPage::getTitleFor($this->getName());
     // show/hide links
     $showhide = array(wfMsgHtml('show'), wfMsgHtml('hide'));
     $hidelinks = array();
     if ($wgGroupPermissions['*']['createpage'] === true) {
         $hidelinks['hideliu'] = 'rcshowhideliu';
     }
     if ($wgUseNPPatrol || $wgUseRCPatrol) {
         $hidelinks['hidepatrolled'] = 'rcshowhidepatr';
     }
     $hidelinks['hidebots'] = 'rcshowhidebots';
     $links = array();
     foreach ($hidelinks as $key => $msg) {
         $reversed = 1 - $this->options[$key];
         $link = $sk->makeKnownLinkObj($self, $showhide[$reversed], wfArrayToCGI(array($key => $reversed), $this->nondefaults));
         $links[$key] = wfMsgHtml($msg, $link);
     }
     $hl = implode(' | ', $links);
     // Store query values in hidden fields so that form submission doesn't lose them
     $hidden = array();
     foreach ($this->nondefaults as $key => $value) {
         if ($key === 'namespace') {
             continue;
         }
         if ($key === 'username') {
             continue;
         }
         $hidden[] = Xml::hidden($key, $value);
     }
     $hidden = implode("\n", $hidden);
     $form = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . Xml::hidden('title', $self->getPrefixedDBkey()) . Xml::openElement('table') . "<tr>\n\t\t\t\t<td align=\"{$align}\">" . Xml::label(wfMsg('namespace'), 'namespace') . "</td>\n\t\t\t\t<td>" . Xml::namespaceSelector($this->options['namespace'], 'all') . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=\"{$align}\">" . Xml::label(wfMsg('newpages-username'), 'mw-np-username') . "</td>\n\t\t\t\t<td>" . Xml::input('username', 30, $this->options['username'], array('id' => 'mw-np-username')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr> <td></td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('allpagessubmit')) . "</td>\n\t\t\t</tr>" . "<tr><td></td><td>" . $hl . "</td></tr>" . Xml::closeElement('table') . $hidden . Xml::closeElement('form');
     return $form;
 }
/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
    global $wgImportTargetNamespace;
    $interwiki = false;
    $namespace = $wgImportTargetNamespace;
    $frompage = '';
    $history = true;
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        $isUpload = false;
        $namespace = $wgRequest->getIntOrNull('namespace');
        switch ($wgRequest->getVal("source")) {
            case "upload":
                $isUpload = true;
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $interwiki = $wgRequest->getVal('interwiki');
                $history = $wgRequest->getCheck('interwikiHistory');
                $frompage = $wgRequest->getText("frompage");
                $source = ImportStreamSource::newFromInterwiki($interwiki, $frompage, $history);
                break;
            default:
                $source = new WikiErrorMsg("importunknownsource");
        }
        if (WikiError::isError($source)) {
            $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage()));
        } else {
            $wgOut->addWikiMsg("importstart");
            $importer = new WikiImporter($source);
            if (!is_null($namespace)) {
                $importer->setTargetNamespace($namespace);
            }
            $reporter = new ImportReporter($importer, $isUpload, $interwiki);
            $reporter->open();
            $result = $importer->doImport();
            $resultCount = $reporter->close();
            if (WikiError::isError($result)) {
                # No source or XML parse error
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage()));
            } elseif (WikiError::isError($resultCount)) {
                # Zero revisions
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage()));
            } else {
                # Success!
                $wgOut->addWikiMsg('importsuccess');
            }
            $wgOut->addWikiText('<hr />');
        }
    }
    $action = $wgTitle->getLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiMsg("importtext");
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('upload')) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action)) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'upload') . "<input type='file' name='xmlimport' value='' size='30' />" . Xml::submitButton(wfMsg('uploadbtn')) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiMsg('importnosources');
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('importinterwiki')) . Xml::openElement('form', array('method' => 'post', 'action' => $action)) . wfMsgExt('import-interwiki-text', array('parse')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'interwiki') . Xml::openElement('table') . "<tr>\n\t\t\t\t<td>" . Xml::openElement('select', array('name' => 'interwiki')));
        foreach ($wgImportSources as $prefix) {
            $selected = $interwiki === $prefix ? ' selected="selected"' : '';
            $wgOut->addHTML(Xml::option($prefix, $prefix, $selected));
        }
        $wgOut->addHTML(Xml::closeElement('select') . "</td>\n\t\t\t\t<td>" . Xml::input('frompage', 50, $frompage) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::checkLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $history) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::label(wfMsg('import-interwiki-namespace'), 'namespace') . Xml::namespaceSelector($namespace, '') . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('import-interwiki-submit')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    }
}
Esempio n. 30
0
 /**
  * Prepare the namespace filter drop-down; standard namespace
  * selector, sans the MediaWiki namespace
  *
  * @param mixed $namespace Pre-select namespace
  * @return string
  */
 protected function getNamespaceMenu($namespace = null)
 {
     return "<span style='white-space: nowrap'>" . Xml::label(wfMsg('namespace'), 'namespace') . '&nbsp;' . Xml::namespaceSelector($namespace, '') . "</span>";
 }