protected function listItem($row, $nt, $target, $notClose = false)
 {
     $dirmark = $this->getLanguage()->getDirMark();
     # local message cache
     static $msgcache = null;
     if ($msgcache === null) {
         static $msgs = ['isredirect', 'istemplate', 'semicolon-separator', 'whatlinkshere-links', 'isimage', 'editlink'];
         $msgcache = [];
         foreach ($msgs as $msg) {
             $msgcache[$msg] = $this->msg($msg)->escaped();
         }
     }
     if ($row->rd_from) {
         $query = ['redirect' => 'no'];
     } else {
         $query = [];
     }
     $link = Linker::linkKnown($nt, null, $row->page_is_redirect ? ['class' => 'mw-redirect'] : [], $query);
     // Display properties (redirect or template)
     $propsText = '';
     $props = [];
     if ($row->rd_from) {
         $props[] = $msgcache['isredirect'];
     }
     if ($row->is_template) {
         $props[] = $msgcache['istemplate'];
     }
     if ($row->is_image) {
         $props[] = $msgcache['isimage'];
     }
     Hooks::run('WhatLinksHereProps', [$row, $nt, $target, &$props]);
     if (count($props)) {
         $propsText = $this->msg('parentheses')->rawParams(implode($msgcache['semicolon-separator'], $props))->escaped();
     }
     # Space for utilities links, with a what-links-here link provided
     $wlhLink = $this->wlhLink($nt, $msgcache['whatlinkshere-links'], $msgcache['editlink']);
     $wlh = Xml::wrapClass($this->msg('parentheses')->rawParams($wlhLink)->escaped(), 'mw-whatlinkshere-tools');
     return $notClose ? Xml::openElement('li') . "{$link} {$propsText} {$dirmark} {$wlh}\n" : Xml::tags('li', null, "{$link} {$propsText} {$dirmark} {$wlh}") . "\n";
 }
 protected function listItem($row, $nt, $notClose = false)
 {
     global $wgLang;
     $dirmark = $wgLang->getDirMark();
     # local message cache
     static $msgcache = null;
     if ($msgcache === null) {
         static $msgs = array('isredirect', 'istemplate', 'semicolon-separator', 'whatlinkshere-links', 'isimage');
         $msgcache = array();
         foreach ($msgs as $msg) {
             $msgcache[$msg] = wfMsgExt($msg, array('escapenoentities'));
         }
     }
     if ($row->page_is_redirect) {
         $query = array('redirect' => 'no');
     } else {
         $query = array();
     }
     $link = Linker::linkKnown($nt, null, array(), $query);
     // Display properties (redirect or template)
     $propsText = '';
     $props = array();
     if ($row->page_is_redirect) {
         $props[] = $msgcache['isredirect'];
     }
     if ($row->is_template) {
         $props[] = $msgcache['istemplate'];
     }
     if ($row->is_image) {
         $props[] = $msgcache['isimage'];
     }
     if (count($props)) {
         $propsText = '(' . implode($msgcache['semicolon-separator'], $props) . ')';
     }
     # Space for utilities links, with a what-links-here link provided
     $wlhLink = $this->wlhLink($nt, $msgcache['whatlinkshere-links']);
     $wlh = Xml::wrapClass("({$wlhLink})", 'mw-whatlinkshere-tools');
     return $notClose ? Xml::openElement('li') . "{$link} {$propsText} {$dirmark} {$wlh}\n" : Xml::tags('li', null, "{$link} {$propsText} {$dirmark} {$wlh}") . "\n";
 }
	/**
	 * 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";
	}
	/**
	 * Format and return the navigation bar.
	 * @param $limit integer  Number of itens being displayed.
	 * @return string  HTML-formatted navigation bar.
	 */
	public function getNavigationBar( $limit ) {
		global $wgLang;

		$limit = $wgLang->formatNum( $limit );
		$opts = array( 'parsemag', 'escapenoentities' );
		$linkTexts = $disabledTexts = array();
		foreach ( self::$linkTextMsgs[$this->mType] as $type => $msg ) {
			$label = wfMsgExt( $msg, $opts, $limit );
			$linkTexts[$type] = wfMsgReplaceArgs( self::$pagingLabels[$type], array( $label ) );
			$disabledTexts[$type] = Xml::wrapClass( $linkTexts[$type], 'disabled' );
		}

		$pagingLinks = $this->mPager->getPagingLinks( $linkTexts, $disabledTexts );
// 		$limitLinks = $this->mPager->getLimitLinks(); // XXX: Not used yet.
		$ellipsis = wfMsg( 'ellipsis' );
		$html = "{$pagingLinks['first']} {$pagingLinks['prev']} {$ellipsis} {$pagingLinks['next']} {$pagingLinks['last']}";
		$html = WikilogUtils::wrapDiv( 'wl-pagination', $html );

		$dir = $wgLang->getDir();

		return Xml::tags( 'div',
			array(
				'class' => 'wl-navbar',
				'dir' => $dir
			),
			$html
		);
	}
	/**
	 * Format the HTML output of the special page.
	 * @param $opts Form options, such as wikilog name, category, date, etc.
	 */
	public function webOutput( FormOptions $opts ) {
		global $wgRequest, $wgOut, $wgMimeType, $wgTitle, $wgParser;

		# Set page title, html title, nofollow, noindex, etc...
		$this->setHeaders();
		$this->outputHeader();

		# Build query object.
		$query = self::getQuery( $opts );

		# Prepare the parser.
		# This must be called here if not including, before the pager
		# object is created. WikilogTemplatePager fails otherwise.
		if ( !$this->including() ) {
			$popts = $wgOut->parserOptions();
			$wgParser->startExternalParse( $wgTitle, $popts, Parser::OT_HTML );
		}

		# Create the pager object that will create the list of articles.
		if ( $opts['view'] == 'archives' ) {
			$pager = new WikilogArchivesPager( $query, $this->including() );
		} elseif ( $opts['template'] ) {
			$templ = Title::makeTitle( NS_TEMPLATE, $opts['template'] );
			$pager = new WikilogTemplatePager( $query, $templ, $opts['limit'], $this->including() );
		} else {
			$pager = new WikilogSummaryPager( $query, $opts['limit'], $this->including() );
		}

		# Handle special page inclusion.
		if ( $this->including() ) {
			# Get pager body.
			$body = $pager->getBody();
		}
		else {
			# If a wikilog is selected, set the title.
			$title = $query->getWikilogTitle();
			if ( !is_null( $title ) ) {
				# Retrieve wikilog front page
				$article = new Article( $title );
				$content = $article->getContent();
				$wgOut->setPageTitle( $title->getPrefixedText() );
				$wgOut->addWikiTextTitle( $content, $title );
			}

			# Display query options.
			$body = $this->getHeader( $opts );

			# Get pager body.
			$body .= $pager->getBody();

			# Add navigation bars.
			$body .= $pager->getNavigationBar();
		}

		# Output.
		$body = Xml::wrapClass( $body, 'wl-wrapper', 'div' );
		$wgOut->addHTML( $body );

		# Get query parameter array, for the following links.
		$qarr = $query->getDefaultQuery();

		# Add feed links.
		$wgOut->setSyndicated();
		$altquery = wfArrayToCGI( array_intersect_key( $qarr, WikilogItemFeed::$paramWhitelist ) );
		if ( $altquery ) {
			$wgOut->setFeedAppendQuery( $altquery );
		}

		# Add links for alternate views.
		foreach ( self::$views as $alt ) {
			if ( $alt != $opts['view'] ) {
				$altquery = wfArrayToCGI( array( 'view' => $alt ), $qarr );
				$wgOut->addLink( array(
					'rel' => 'alternate',
					'href' => $wgTitle->getLocalURL( $altquery ),
					'type' => $wgMimeType,
					'title' => wfMsgExt( "wikilog-view-{$alt}",
						array( 'content', 'parsemag' ) )
				) );
			}
		}
	}
 protected function listItem($row, $nt, $notClose = false)
 {
     # local message cache
     static $msgcache = null;
     if ($msgcache === null) {
         static $msgs = array('isredirect', 'istemplate', 'semicolon-separator', 'whatlinkshere-links', 'isimage');
         $msgcache = array();
         foreach ($msgs as $msg) {
             $msgcache[$msg] = wfMsgExt($msg, array('escapenoentities'));
         }
     }
     $suppressRedirect = $row->page_is_redirect ? 'redirect=no' : '';
     $link = $this->skin->makeKnownLinkObj($nt, '', $suppressRedirect);
     // Display properties (redirect or template)
     $propsText = '';
     $props = array();
     if ($row->page_is_redirect) {
         $props[] = $msgcache['isredirect'];
     }
     if ($row->is_template) {
         $props[] = $msgcache['istemplate'];
     }
     if ($row->is_image) {
         $props[] = $msgcache['isimage'];
     }
     if (count($props)) {
         $propsText = '(' . implode($msgcache['semicolon-separator'], $props) . ')';
     }
     # Space for utilities links, with a what-links-here link provided
     $wlhLink = $this->wlhLink($nt, $msgcache['whatlinkshere-links']);
     $wlh = Xml::wrapClass("({$wlhLink})", 'mw-whatlinkshere-tools');
     return $notClose ? Xml::openElement('li') . "{$link} {$propsText} {$wlh}\n" : Xml::tags('li', null, "{$link} {$propsText} {$wlh}") . "\n";
 }
	/**
	 * Returns an array with common header and footer system message
	 * parameters that are used in 'wikilog-comment-header' and
	 * 'wikilog-comment-footer'.
	 *
	 * Note: *Content* language should be used for everything but final
	 * strings (like tooltips). These messages are intended to be customized
	 * by the wiki admin, and we don't want to require changing it for the
	 * 300+ languages suported by MediaWiki.
	 *
	 * Parameters should be HTML-formated. They are substituded using
	 * 'replaceafter' parameter to wfMsgExt().
	 *
	 * @param $comment Comment.
	 * @return Array with message parameters.
	 */
	public function getCommentMsgParams( $comment ) {
		global $wgContLang;

		if ( $comment->mUserID ) {
			$authorPlain = htmlspecialchars( $comment->mUserText );
			$authorFmt = wfMsgExt( 'wikilog-simple-signature',
				array( 'content', 'parseinline', 'replaceafter' ),
				Xml::wrapClass( $this->mSkin->userLink( $comment->mUserID, $comment->mUserText ), 'wl-comment-author' ),
				$this->mSkin->userTalkLink( $comment->mUserID, $comment->mUserText ),
				$comment->mUserText
			);
		} else {
			$authorPlain = htmlspecialchars( $comment->mAnonName );
			$authorFmt = wfMsgForContent( 'wikilog-comment-anonsig',
				Xml::wrapClass( $this->mSkin->userLink( $comment->mUserID, $comment->mUserText ), 'wl-comment-author' ),
				$this->mSkin->userTalkLink( $comment->mUserID, $comment->mUserText ),
				htmlspecialchars( $comment->mAnonName )
			);
		}

		list( $date, $time, $tz ) = WikilogUtils::getLocalDateTime( $comment->mTimestamp );
		$permalink = $this->getCommentPermalink( $comment, $date, $time, $tz );

		$extra = array();
		if ( $this->mShowItem && $comment->mItem ) {
			# Display item title.
			$extra[] = wfMsgForContent( 'wikilog-comment-note-item',
				$this->mSkin->link( $comment->mItem->mTitle, $comment->mItem->mName )
			);
		}
		if ( $comment->mID && $comment->mCommentTitle &&
				$comment->mCommentTitle->exists() )
		{
			if ( $comment->mUpdated != $comment->mTimestamp ) {
				# Comment was edited.
				list( $updDate, $updTime, $updTz ) = WikilogUtils::getLocalDateTime( $comment->mUpdated );
				$extra[] = $this->mSkin->link( $comment->mCommentTitle,
					wfMsgForContent( 'wikilog-comment-note-edited', $updDate, $updTime, $updTz ),
					array( 'title' => wfMsg( 'wikilog-comment-history' ) ),
					array( 'action' => 'history' ), 'known'
				);
			}
		}
		if ( $extra ) {
			$extra = wfMsgForContent( 'parentheses', $wgContLang->pipeList( $extra ) );
		} else {
			$extra = "";
		}

		return array(
			/* $1  */ $authorPlain,
			/* $2  */ $authorFmt,
			/* $3  */ $date,
			/* $4  */ $time,
			/* $5  */ $permalink,
			/* $6  */ $extra
		);
	}
	function formatValue( $name, $value ) {
		global $wgContLang;

		switch ( $name ) {
			case 'wlp_pubdate':
				$s = $wgContLang->timeanddate( $value, true );
				if ( !$this->mCurrentRow->wlp_publish ) {
					$s = Xml::wrapClass( $s, 'wl-draft-inline' );
				}
				return $s;

			case 'wlp_updated':
				return $value;

			case 'wlp_authors':
				return $this->authorList( $this->mCurrentItem->mAuthors );

			case 'wlw_title':
				$page = $this->mCurrentItem->mParentTitle;
				$text = Sanitizer::escapeHtmlAllowEntities( $this->mCurrentItem->mParentName );
				return $this->getSkin()->link( $page, $text, array(), array(),
					array( 'known', 'noclasses' ) );

			case 'wlp_title':
				$page = $this->mCurrentItem->mTitle;
				$text = Sanitizer::escapeHtmlAllowEntities( $this->mCurrentItem->mName );
				$s = $this->getSkin()->link( $page, $text, array(), array(),
					array( 'known', 'noclasses' ) );
				if ( !$this->mCurrentRow->wlp_publish ) {
					$draft = wfMsg( 'wikilog-draft-title-mark' );
					$s = Xml::wrapClass( "$s $draft", 'wl-draft-inline' );
				}
				return $s;

			case 'wlp_num_comments':
				$page = $this->mCurrentItem->mTitle->getTalkPage();
				$text = $this->mCurrentItem->getNumComments();
				return $this->getSkin()->link( $page, $text, array(), array(),
					array( 'known', 'noclasses' ) );

			case '_wl_actions':
				if ( $this->mCurrentItem->mTitle->quickUserCan( 'edit' ) ) {
					return $this->doEditLink( $this->mCurrentItem->mTitle, $this->mCurrentItem->mName );
				} else {
					return '';
				}

			default:
				return htmlentities( $value );
		}
	}
Esempio n. 9
0
 protected function getLogo()
 {
     global $wgOut;
     $logo = Xml::wrapClass(Xml::element('a', array('href' => self::APCURL), 'APC'), 'mw-apc-logo') . Xml::wrapClass('Opcode Cache', 'mw-apc-nameinfo');
     $wgOut->addHTML(Xml::openElement('div', array('class' => 'head')) . Xml::tags('h1', array('class' => 'apc-header-1'), Xml::wrapClass($logo, 'mw-apc-logo-outer', 'span')) . Xml::element('hr', array('class' => 'mw-apc-separator')) . Xml::closeElement('div'));
 }