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') . ' ' . Xml::namespaceSelector($namespace, ''); $f .= ' '; # Submit $f .= Xml::submitButton(wfMsg('allpagessubmit')); # Close $f .= Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n"; return $f; }
protected function form() { $out = $this->getOutput(); $out->addModules('mediawiki.userSuggest'); // Consume values $this->opts->consumeValue('offset'); // don't carry offset, DWIW $namespace = $this->opts->consumeValue('namespace'); $username = $this->opts->consumeValue('username'); $tagFilterVal = $this->opts->consumeValue('tagfilter'); $nsinvert = $this->opts->consumeValue('invert'); // 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[] = Html::hidden($key, $value); } $hidden = implode("\n", $hidden); $form = array('namespace' => array('type' => 'namespaceselect', 'name' => 'namespace', 'label-message' => 'namespace', 'default' => $namespace), 'nsinvert' => array('type' => 'check', 'name' => 'invert', 'label-message' => 'invert', 'default' => $nsinvert, 'tooltip' => 'invert'), 'tagFilter' => array('type' => 'tagfilter', 'name' => 'tagfilter', 'label-raw' => $this->msg('tag-filter')->parse(), 'default' => $tagFilterVal), 'username' => array('type' => 'text', 'name' => 'username', 'label-message' => 'newpages-username', 'default' => $userText, 'id' => 'mw-np-username', 'size' => 30, 'cssclass' => 'mw-autocomplete-user')); $htmlForm = new HTMLForm($form, $this->getContext()); $htmlForm->setSubmitText($this->msg('allpagessubmit')->text()); $htmlForm->setSubmitProgressive(); // The form should be visible on each request (inclusive requests with submitted forms), so // return always false here. $htmlForm->setSubmitCallback(function () { return false; }); $htmlForm->setMethod('get'); $out->addHtml(Xml::fieldset($this->msg('newpages')->text())); $htmlForm->show(); $out->addHtml(Html::rawElement('div', null, $this->filterLinks()) . Xml::closeElement('fieldset')); }
function whatlinkshereForm() { // We get nicer value from the title object $this->opts->consumeValue('target'); // Reset these for new requests $this->opts->consumeValues(['back', 'from']); $target = $this->target ? $this->target->getPrefixedText() : ''; $namespace = $this->opts->consumeValue('namespace'); $nsinvert = $this->opts->consumeValue('invert'); # Build up the form $f = Xml::openElement('form', ['action' => wfScript()]); # Values that should not be forgotten $f .= Html::hidden('title', $this->getPageTitle()->getPrefixedText()); foreach ($this->opts->getUnconsumedValues() as $name => $value) { $f .= Html::hidden($name, $value); } $f .= Xml::fieldset($this->msg('whatlinkshere')->text()); # Target input (.mw-searchInput enables suggestions) $f .= Xml::inputLabel($this->msg('whatlinkshere-page')->text(), 'target', 'mw-whatlinkshere-target', 40, $target, ['class' => 'mw-searchInput']); $f .= ' '; # Namespace selector $f .= Html::namespaceSelector(['selected' => $namespace, 'all' => '', 'label' => $this->msg('namespace')->text()], ['name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector']); $f .= ' ' . Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $nsinvert, ['title' => $this->msg('tooltip-whatlinkshere-invert')->text()]); $f .= ' '; # Submit $f .= Xml::submitButton($this->msg('whatlinkshere-submit')->text()); # Close $f .= Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n"; return $f; }
protected function form() { global $wgEnableNewpagesUserFilter, $wgScript; // Consume values $this->opts->consumeValue('offset'); // don't carry offset, DWIW $namespace = $this->opts->consumeValue('namespace'); $username = $this->opts->consumeValue('username'); $tagFilterVal = $this->opts->consumeValue('tagfilter'); $nsinvert = $this->opts->consumeValue('invert'); // 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[] = Html::hidden($key, $value); } $hidden = implode("\n", $hidden); $tagFilter = ChangeTags::buildTagFilterSelector($tagFilterVal); if ($tagFilter) { list($tagFilterLabel, $tagFilterSelector) = $tagFilter; } $form = Xml::openElement('form', array('action' => $wgScript)) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . Xml::fieldset($this->msg('newpages')->text()) . Xml::openElement('table', array('id' => 'mw-newpages-table')) . '<tr> <td class="mw-label">' . Xml::label($this->msg('namespace')->text(), 'namespace') . '</td> <td class="mw-input">' . Html::namespaceSelector(array('selected' => $namespace, 'all' => 'all'), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . ' ' . Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $nsinvert, array('title' => $this->msg('tooltip-invert')->text())) . '</td> </tr>' . ($tagFilter ? '<tr> <td class="mw-label">' . $tagFilterLabel . '</td> <td class="mw-input">' . $tagFilterSelector . '</td> </tr>' : '') . ($wgEnableNewpagesUserFilter ? '<tr> <td class="mw-label">' . Xml::label($this->msg('newpages-username')->text(), 'mw-np-username') . '</td> <td class="mw-input">' . Xml::input('username', 30, $userText, array('id' => 'mw-np-username')) . '</td> </tr>' : '') . '<tr> <td></td> <td class="mw-submit">' . Xml::submitButton($this->msg('allpagessubmit')->text()) . '</td> </tr>' . '<tr> <td></td> <td class="mw-input">' . $this->filterLinks() . '</td> </tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset') . $hidden . Xml::closeElement('form'); $this->getOutput()->addHTML($form); }
/** * Returns query form fields. * @param $opts Form options. * @return Array of form fields. */ protected static function getQueryFormFields( FormOptions $opts ) { global $wgWikilogEnableTags; $fields = array(); $fields['wikilog'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-wikilog' ), 'wikilog', 'wl-wikilog', 40, str_replace( '_', ' ', $opts->consumeValue( 'wikilog' ) ) ); $fields['category'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-category' ), 'category', 'wl-category', 40, str_replace( '_', ' ', $opts->consumeValue( 'category' ) ) ); $fields['author'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-author' ), 'author', 'wl-author', 40, str_replace( '_', ' ', $opts->consumeValue( 'author' ) ) ); if ( $wgWikilogEnableTags ) { $fields['tag'] = Xml::inputLabelSep( wfMsg( 'wikilog-form-tag' ), 'tag', 'wl-tag', 40, str_replace( '_', ' ', $opts->consumeValue( 'tag' ) ) ); } $fields['date'] = array( Xml::label( wfMsg( 'wikilog-form-date' ), 'wl-month' ), Xml::monthSelector( $opts->consumeValue( 'month' ), '', 'wl-month' ) . " " . Xml::input( 'year', 4, $opts->consumeValue( 'year' ), array( 'maxlength' => 4 ) ) ); $opts->consumeValue( 'day' ); // ignore day, not really useful $statusSelect = new XmlSelect( 'show', 'wl-status', $opts->consumeValue( 'show' ) ); $statusSelect->addOption( wfMsg( 'wikilog-show-all' ), 'all' ); $statusSelect->addOption( wfMsg( 'wikilog-show-published' ), 'published' ); $statusSelect->addOption( wfMsg( 'wikilog-show-drafts' ), 'drafts' ); $fields['status'] = array( Xml::label( wfMsg( 'wikilog-form-status' ), 'wl-status' ), $statusSelect->getHTML() ); $fields['submit'] = Xml::submitbutton( wfMsg( 'allpagessubmit' ) ); return $fields; }