示例#1
0
 /**
  * Set the text to be displayed above the changes
  *
  * @param FormOptions $opts
  * @param int $numRows Number of rows in the result to show after this header
  */
 public function doHeader($opts, $numRows)
 {
     $this->setTopText($opts);
     $defaults = $opts->getAllValues();
     $nondefaults = $opts->getChangedValues();
     $panel = array();
     $panel[] = self::makeLegend($this->getContext());
     $panel[] = $this->optionsPanel($defaults, $nondefaults, $numRows);
     $panel[] = '<hr />';
     $extraOpts = $this->getExtraOptions($opts);
     $extraOptsCount = count($extraOpts);
     $count = 0;
     $submit = ' ' . Xml::submitbutton($this->msg('allpagessubmit')->text());
     $out = Xml::openElement('table', array('class' => 'mw-recentchanges-table'));
     foreach ($extraOpts as $name => $optionRow) {
         # Add submit button to the last row only
         ++$count;
         $addSubmit = $count === $extraOptsCount ? $submit : '';
         $out .= Xml::openElement('tr');
         if (is_array($optionRow)) {
             $out .= Xml::tags('td', array('class' => 'mw-label mw-' . $name . '-label'), $optionRow[0]);
             $out .= Xml::tags('td', array('class' => 'mw-input'), $optionRow[1] . $addSubmit);
         } else {
             $out .= Xml::tags('td', array('class' => 'mw-input', 'colspan' => 2), $optionRow . $addSubmit);
         }
         $out .= Xml::closeElement('tr');
     }
     $out .= Xml::closeElement('table');
     $unconsumed = $opts->getUnconsumedValues();
     foreach ($unconsumed as $key => $value) {
         $out .= Html::hidden($key, $value);
     }
     $t = $this->getPageTitle();
     $out .= Html::hidden('title', $t->getPrefixedText());
     $form = Xml::tags('form', array('action' => wfScript()), $out);
     $panel[] = $form;
     $panelString = implode("\n", $panel);
     $this->getOutput()->addHTML(Xml::fieldset($this->msg('recentchanges-legend')->text(), $panelString, array('class' => 'rcoptions')));
     $this->setBottomText($opts);
 }
	/**
	 * 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;
	}
	/**
	 * Generates and returns a "post new comment" form for the user to fill in
	 * and submit.
	 *
	 * @param $parent If provided, generates a "post reply" form to reply to
	 *   the given comment.
	 */
	public function getPostCommentForm( $parent = null ) {
		global $wgUser, $wgTitle, $wgScript, $wgRequest;
		global $wgWikilogModerateAnonymous;

		$comment = $this->mPostedComment;
		$opts = $this->mFormOptions;

		$preview = '';
		$pid = $parent ? $parent->mID : null;
		if ( $comment && $comment->mParent == $pid ) {
			$check = $this->validateComment( $comment );
			if ( $check ) {
				$preview = Xml::wrapClass( wfMsg( $check ), 'mw-warning', 'div' );
			} else {
				$preview = $this->mFormatter->formatComment( $this->mPostedComment );
			}
			$header = wfMsgHtml( 'wikilog-form-preview' );
			$preview = "<b>{$header}</b>{$preview}<hr/>";
		}

		$form =
			Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
			Html::hidden( 'action', 'wikilog' ) .
			Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
			( $parent ? Html::hidden( 'wlParent', $parent->mID ) : '' );

		$fields = array();

		if ( $wgUser->isLoggedIn() ) {
			$fields[] = array(
				wfMsg( 'wikilog-form-name' ),
				$this->mSkin->userLink( $wgUser->getId(), $wgUser->getName() )
			);
		} else {
			$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
			$loginLink = $this->mSkin->link( $loginTitle,
				wfMsgHtml( 'loginreqlink' ), array(),
				array( 'returnto' => $wgTitle->getPrefixedUrl() )
			);
			$message = wfMsg( 'wikilog-posting-anonymously', $loginLink );
			$fields[] = array(
				Xml::label( wfMsg( 'wikilog-form-name' ), 'wl-name' ),
				Xml::input( 'wlAnonName', 25, $opts->consumeValue( 'wlAnonName' ),
					array( 'id' => 'wl-name', 'maxlength' => 255 ) ) .
					"<p>{$message}</p>"
			);
		}

		$autofocus = $parent ? array( 'autofocus' => 'autofocus' ) : array();
		$fields[] = array(
			Xml::label( wfMsg( 'wikilog-form-comment' ), 'wl-comment' ),
			Xml::textarea( 'wlComment', $opts->consumeValue( 'wlComment' ),
				40, 5, array( 'id' => 'wl-comment' ) + $autofocus )
		);

		if ( $this->mCaptchaForm ) {
			$fields[] = array( '', $this->mCaptchaForm );
		}

		if ( $wgWikilogModerateAnonymous && $wgUser->isAnon() ) {
			$fields[] = array( '', wfMsg( 'wikilog-anonymous-moderated' ) );
		}

		$fields[] = array( '',
			Xml::submitbutton( wfMsg( 'wikilog-submit' ), array( 'name' => 'wlActionCommentSubmit' ) ) . WL_NBSP .
			Xml::submitbutton( wfMsg( 'wikilog-preview' ), array( 'name' => 'wlActionCommentPreview' ) )
		);

		$form .= WikilogUtils::buildForm( $fields );

		foreach ( $opts->getUnconsumedValues() as $key => $value ) {
			$form .= Html::hidden( $key, $value );
		}

		$form = Xml::tags( 'form', array(
			'action' => "{$wgScript}#wl-comment-form",
			'method' => 'post'
		), $form );

		$msgid = ( $parent ? 'wikilog-post-reply' : 'wikilog-post-comment' );
		return Xml::fieldset( wfMsg( $msgid ), $preview . $form,
			array( 'id' => 'wl-comment-form' ) ) . "\n";
	}
示例#4
0
 /**
  * Return the text to be displayed above the changes
  *
  * @param $opts FormOptions
  * @return String: XHTML
  */
 public function doHeader($opts)
 {
     global $wgScript, $wgOut;
     $this->setTopText($wgOut, $opts);
     $defaults = $opts->getAllValues();
     $nondefaults = $opts->getChangedValues();
     $opts->consumeValues(array('namespace', 'invert', 'tagfilter'));
     $panel = array();
     $panel[] = $this->optionsPanel($defaults, $nondefaults);
     $panel[] = '<hr />';
     $extraOpts = $this->getExtraOptions($opts);
     $extraOptsCount = count($extraOpts);
     $count = 0;
     $submit = ' ' . Xml::submitbutton(wfMsg('allpagessubmit'));
     $out = Xml::openElement('table', array('class' => 'mw-recentchanges-table'));
     foreach ($extraOpts as $optionRow) {
         # Add submit button to the last row only
         ++$count;
         $addSubmit = $count === $extraOptsCount ? $submit : '';
         $out .= Xml::openElement('tr');
         if (is_array($optionRow)) {
             $out .= Xml::tags('td', array('class' => 'mw-label'), $optionRow[0]);
             $out .= Xml::tags('td', array('class' => 'mw-input'), $optionRow[1] . $addSubmit);
         } else {
             $out .= Xml::tags('td', array('class' => 'mw-input', 'colspan' => 2), $optionRow . $addSubmit);
         }
         $out .= Xml::closeElement('tr');
     }
     $out .= Xml::closeElement('table');
     $unconsumed = $opts->getUnconsumedValues();
     foreach ($unconsumed as $key => $value) {
         $out .= Xml::hidden($key, $value);
     }
     $t = $this->getTitle();
     $out .= Xml::hidden('title', $t->getPrefixedText());
     $form = Xml::tags('form', array('action' => $wgScript), $out);
     $panel[] = $form;
     $panelString = implode("\n", $panel);
     $wgOut->addHTML(Xml::fieldset(wfMsg('recentchanges-legend'), $panelString, array('class' => 'rcoptions')));
     $wgOut->addHTML(ChangesList::flagLegend());
     $this->setBottomText($wgOut, $opts);
 }