示例#1
0
 function formatValue($field, $value)
 {
     global $wgLang;
     switch ($field) {
         case 'am_title':
             $title = Title::makeTitle(NS_MEDIAWIKI, $value . $this->suffix);
             $talk = Title::makeTitle(NS_MEDIAWIKI_TALK, $value . $this->suffix);
             if ($this->mCurrentRow->am_customised) {
                 $title = Linker::linkKnown($title, $wgLang->lcfirst($value));
             } else {
                 $title = Linker::link($title, $wgLang->lcfirst($value), array(), array(), array('broken'));
             }
             if ($this->mCurrentRow->am_talk_exists) {
                 $talk = Linker::linkKnown($talk, $this->talk);
             } else {
                 $talk = Linker::link($talk, $this->talk, array(), array(), array('broken'));
             }
             return $title . ' (' . $talk . ')';
         case 'am_default':
         case 'am_actual':
             return Sanitizer::escapeHtmlAllowEntities($value, ENT_QUOTES);
     }
     return '';
 }
示例#2
0
文件: Linker.php 项目: paladox/2
 /**
  * This function is called by all recent changes variants, by the page history,
  * and by the user contributions list. It is responsible for formatting edit
  * summaries. It escapes any HTML in the summary, but adds some CSS to format
  * auto-generated comments (from section editing) and formats [[wikilinks]].
  *
  * @author Erik Moeller <*****@*****.**>
  *
  * Note: there's not always a title to pass to this function.
  * Since you can't set a default parameter for a reference, I've turned it
  * temporarily to a value pass. Should be adjusted further. --brion
  *
  * @param string $comment
  * @param Title|null $title Title object (to generate link to the section in autocomment)
  *  or null
  * @param bool $local Whether section links should refer to local page
  * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to.
  *  For use with external changes.
  *
  * @return mixed|string
  */
 public static function formatComment($comment, $title = null, $local = false, $wikiId = null)
 {
     # Sanitize text a bit:
     $comment = str_replace("\n", " ", $comment);
     # Allow HTML entities (for bug 13815)
     $comment = Sanitizer::escapeHtmlAllowEntities($comment);
     # Render autocomments and make links:
     $comment = self::formatAutocomments($comment, $title, $local, $wikiId);
     $comment = self::formatLinksInComment($comment, $title, $local, $wikiId);
     return $comment;
 }
	/**
	 * View page action handler.
	 */
	public function view() {
		global $wgOut, $wgUser, $wgContLang, $wgFeed, $wgWikilogFeedClasses;

		# Get skin
		$skin = $wgUser->getSkin();

		if ( $this->mItem ) {
			$params = $this->mItem->getMsgParams( true );

			# Set page subtitle
			$subtitleTxt = wfMsgExt( 'wikilog-entry-sub',
				array( 'parsemag', 'content' ),
				$params
			);
			if ( !empty( $subtitleTxt ) ) {
				$wgOut->setSubtitle( $wgOut->parse( $subtitleTxt ) );
			}

			# Display draft notice.
			if ( !$this->mItem->getIsPublished() ) {
				$wgOut->wrapWikiMsg( '<div class="mw-warning">$1</div>', array( 'wikilog-reading-draft' ) );
			}

			# Item page header.
			$headerTxt = wfMsgExt( 'wikilog-entry-header',
				array( 'parse', 'content' ),
				$params
			);
			if ( !empty( $headerTxt ) ) {
				$wgOut->addHtml( WikilogUtils::wrapDiv( 'wl-entry-header', $headerTxt ) );
			}

			# Display article.
			parent::view();

			# Override page title.
			# NOTE (MW1.16+): Must come after parent::view().
			$fullPageTitle = wfMsg( 'wikilog-title-item-full',
					$this->mItem->mName,
					$this->mItem->mParentTitle->getPrefixedText()
			);
			$wgOut->setPageTitle( Sanitizer::escapeHtmlAllowEntities( $this->mItem->mName ) );
			$wgOut->setHTMLTitle( wfMsg( 'pagetitle', $fullPageTitle ) );

			# Item page footer.
			$footerTxt = wfMsgExt( 'wikilog-entry-footer',
				array( 'parse', 'content' ),
				$params
			);
			if ( !empty( $footerTxt ) ) {
				$wgOut->addHtml( WikilogUtils::wrapDiv( 'wl-entry-footer', $footerTxt ) );
			}

			# Add feed links.
			$links = array();
			if ( $wgFeed ) {
				foreach ( $wgWikilogFeedClasses as $format => $class ) {
					$wgOut->addLink( array(
						'rel' => 'alternate',
						'type' => "application/{$format}+xml",
						'title' => wfMsgExt(
							"page-{$format}-feed",
							array( 'content', 'parsemag' ),
							$this->mItem->mParentTitle->getPrefixedText()
						),
						'href' => $this->mItem->mParentTitle->getLocalUrl( "feed={$format}" )
					) );
				}
			}
		} else {
			# Display article.
			parent::view();
		}
	}
/**
 * Returns message in the requested format
 * @param $key String: key of the message
 * @param $options Array: processing rules. Can take the following options:
 *   <i>parse</i>: parses wikitext to HTML
 *   <i>parseinline</i>: parses wikitext to HTML and removes the surrounding
 *       p's added by parser or tidy
 *   <i>escape</i>: filters message through htmlspecialchars
 *   <i>escapenoentities</i>: same, but allows entity references like &#160; through
 *   <i>replaceafter</i>: parameters are substituted after parsing or escaping
 *   <i>parsemag</i>: transform the message using magic phrases
 *   <i>content</i>: fetch message for content language instead of interface
 * Also can accept a single associative argument, of the form 'language' => 'xx':
 *   <i>language</i>: Language object or language code to fetch message for
 *       (overriden by <i>content</i>).
 * Behavior for conflicting options (e.g., parse+parseinline) is undefined.
 *
 * @return String
 */
function wfMsgExt($key, $options)
{
    $args = func_get_args();
    array_shift($args);
    array_shift($args);
    $options = (array) $options;
    foreach ($options as $arrayKey => $option) {
        if (!preg_match('/^[0-9]+|language$/', $arrayKey)) {
            # An unknown index, neither numeric nor "language"
            wfWarn("wfMsgExt called with incorrect parameter key {$arrayKey}", 1, E_USER_WARNING);
        } elseif (preg_match('/^[0-9]+$/', $arrayKey) && !in_array($option, array('parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', 'parsemag', 'content'))) {
            # A numeric index with unknown value
            wfWarn("wfMsgExt called with incorrect parameter {$option}", 1, E_USER_WARNING);
        }
    }
    if (in_array('content', $options, true)) {
        $forContent = true;
        $langCode = true;
        $langCodeObj = null;
    } elseif (array_key_exists('language', $options)) {
        $forContent = false;
        $langCode = wfGetLangObj($options['language']);
        $langCodeObj = $langCode;
    } else {
        $forContent = false;
        $langCode = false;
        $langCodeObj = null;
    }
    $string = wfMsgGetKey($key, true, $langCode, false);
    if (!in_array('replaceafter', $options, true)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    $messageCache = MessageCache::singleton();
    if (in_array('parse', $options, true)) {
        $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText();
    } elseif (in_array('parseinline', $options, true)) {
        $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText();
        $m = array();
        if (preg_match('/^<p>(.*)\\n?<\\/p>\\n?$/sU', $string, $m)) {
            $string = $m[1];
        }
    } elseif (in_array('parsemag', $options, true)) {
        $string = $messageCache->transform($string, !$forContent, $langCodeObj);
    }
    if (in_array('escape', $options, true)) {
        $string = htmlspecialchars($string);
    } elseif (in_array('escapenoentities', $options, true)) {
        $string = Sanitizer::escapeHtmlAllowEntities($string);
    }
    if (in_array('replaceafter', $options, true)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    return $string;
}
示例#5
0
">
				<?php 
    foreach ($categoriesSet as $category) {
        ?>
						<label>
							<input type="checkbox"
								value="<?php 
        echo Sanitizer::encodeAttribute($category['id']);
        ?>
"
								data-short="<?php 
        echo Sanitizer::encodeAttribute($category['short']);
        ?>
">
							<span><?php 
        echo Sanitizer::escapeHtmlAllowEntities($category['name']);
        ?>
</span>
						</label>
				<?php 
    }
    ?>
					</div>
			<?php 
}
?>
				</div>

				<nav class="back-controls">
					<input type="button" value="<?php 
echo wfMessage('cnw-back')->escaped();
 function formatValue($field, $value)
 {
     switch ($field) {
         case 'am_title':
             $title = Title::makeTitle(NS_MEDIAWIKI, $value . $this->suffix);
             $talk = Title::makeTitle(NS_MEDIAWIKI_TALK, $value . $this->suffix);
             $translation = Linker::makeExternalLink('https://translatewiki.net/w/i.php?' . wfArrayToCgi(array('title' => 'Special:SearchTranslations', 'group' => 'mediawiki', 'grouppath' => 'mediawiki', 'query' => 'language:' . $this->getLanguage()->getCode() . '^25 ' . 'messageid:"MediaWiki:' . $value . '"^10 "' . $this->msg($value)->inLanguage('en')->plain() . '"')), $this->msg('allmessages-filter-translate')->text());
             if ($this->mCurrentRow->am_customised) {
                 $title = Linker::linkKnown($title, $this->getLanguage()->lcfirst($value));
             } else {
                 $title = Linker::link($title, $this->getLanguage()->lcfirst($value), array(), array(), array('broken'));
             }
             if ($this->mCurrentRow->am_talk_exists) {
                 $talk = Linker::linkKnown($talk, $this->talk);
             } else {
                 $talk = Linker::link($talk, $this->talk, array(), array(), array('broken'));
             }
             return $title . ' ' . $this->msg('parentheses')->rawParams($talk)->escaped() . ' ' . $this->msg('parentheses')->rawParams($translation)->escaped();
         case 'am_default':
         case 'am_actual':
             return Sanitizer::escapeHtmlAllowEntities($value, ENT_QUOTES);
     }
     return '';
 }
示例#7
0
    /**
     * Get the header for the social profile page, which includes the user's
     * points and user level (if enabled in the site configuration) and lots
     * more.
     *
     * @param $user_id Integer: user ID
     * @param $user_name String: user name
     */
    function getProfileTop($user_id, $user_name)
    {
        global $wgOut, $wgUser, $wgLang;
        global $wgUserLevels;
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $user_level = new UserLevel($stats_data['points']);
        $level_link = Title::makeTitle(NS_HELP, wfMessage('user-profile-userlevels-link')->inContentLanguage()->text());
        $this->initializeProfileData($user_name);
        $profile_data = $this->profile_data;
        // Variables and other crap
        $page_title = $this->getTitle()->getText();
        $title_parts = explode('/', $page_title);
        $user = $title_parts[0];
        $id = User::idFromName($user);
        $user_safe = urlencode($user);
        // Safe urls
        $add_relationship = SpecialPage::getTitleFor('AddRelationship');
        $remove_relationship = SpecialPage::getTitleFor('RemoveRelationship');
        $give_gift = SpecialPage::getTitleFor('GiveGift');
        $send_board_blast = SpecialPage::getTitleFor('SendBoardBlast');
        $update_profile = SpecialPage::getTitleFor('UpdateProfile');
        $watchlist = SpecialPage::getTitleFor('Watchlist');
        $contributions = SpecialPage::getTitleFor('Contributions', $user);
        $send_message = SpecialPage::getTitleFor('UserBoard');
        $upload_avatar = SpecialPage::getTitleFor('UploadAvatar');
        $user_page = Title::makeTitle(NS_USER, $user);
        $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
        $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
        $us = new UserStatus($this->user);
        $city = $us->getCity();
        $city = Sanitizer::escapeHtmlAllowEntities($city);
        $birthday = $us->getBirthday();
        $status = $us->getStatus();
        $status = Sanitizer::escapeHtmlAllowEntities($status);
        $gender = $us->getGender();
        if ($gender == 'male') {
            $genderIcon = '♂';
            $gendertext = '他';
        } elseif ($gender == 'female') {
            $genderIcon = '♀';
            $gendertext = '她';
        } else {
            $genderIcon = '♂/♀';
            $gendertext = 'TA';
        }
        if ($this->isOwner()) {
            $gendertext = '你';
        }
        if ($id != 0) {
            $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
        }
        $avatar = new wAvatar($this->user_id, 'l');
        wfDebug('profile type: ' . $profile_data['user_page_type'] . "\n");
        $output = '';
        //get more
        $target = SpecialPage::getTitleFor('ShowFollowedSites');
        $query = array('user_id' => $wgUser->getId(), 'target_user_id' => $this->user_id);
        $mailVerify = $wgUser->getEmailAuthenticationTimestamp();
        if ($mailVerify == NULL) {
            $href = "/wiki/Special:ConfirmEmail";
        } else {
            $href = "/wiki/Special:UploadAvatar";
        }
        $output .= '<div id="profile-right" class="col-md-6 col-sm-12 col-xs-12">';
        $output .= '<div id="profile-title-container">
				<h1 id="profile-title">
				<div id="profile-image">' . ($this->isOwner() ? '<div class="profile-image-container crop-headimg" id="crop-avatar"><div class="avatar-view upload-tool" title="上传头像">' . $avatar->getOwnerAvatarURL() . '</div>' . $this->cropModal() . '</div>' : $avatar->getAvatarURL()) . '</div>' . $user_name . '</h1></div>';
        $output .= '<div class="modal fade watch-url" tabindex="-1" role="dialog" aria-labelledby="mySmModalLabel" aria-hidden="true">
                      <div class="modal-dialog modal-sm">
                        <div class="modal-content">
                          <div class="modal-header">
                              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                              <h4 class="modal-title" id="gridSystemModalLabel">' . $gendertext . '关注的wiki</h4>
                          </div>
                            <div class="modal-body">
	                            <div class="list-group">
								</div>
								' . Linker::LinkKnown($target, '<i class="fa fa-arrows-alt"></i> 全部', array('type' => 'button', 'class' => 'btn btn-default'), $query) . '
							</div>
                        </div>
                      </div>
                    </div>';
        // Show the user's level and the amount of points they have if
        // UserLevels has been configured contributions
        $notice = SpecialPage::getTitleFor('ViewFollows');
        $contributions = SpecialPage::getTitleFor('Contributions');
        $output .= '<div>
					    <ul class="user-follow-msg">
					        <li><h5>编辑</h5>' . Linker::link($contributions, $stats_data['edits'], array(), array('target' => $user, 'contribs' => 'user')) . '</li>
					        <li><h4>|</h4></li>
					        <li><h5>关注</h5>' . Linker::link($notice, UserUserFollow::getFollowingCount(User::newFromName($user)), array('id' => 'user-following-count'), array('user' => $user, 'rel_type' => 1)) . '</li>
					        <li><h4>|</h4></li>
					        <li><h5>被关注</h5>' . Linker::link($notice, UserUserFollow::getFollowerCount(User::newFromName($user)), array('id' => 'user-follower-count'), array('user' => $user, 'rel_type' => 2)) . '</li>
                        </ul>
                        <div class="cleared"></div>
                    </div>
                    <!--<span id="user-site-count">' . '</span>个站点。-->';
        if ($wgUserLevels) {
            $progress = $user_level->getLevelProgress() * 100;
            $output .= '<div id="honorific-level" class="label">
						<a href="' . htmlspecialchars($level_link->getFullURL()) . '" rel="nofollow">' . $user_level->getLevelName() . '</a>
					</div>
					<div id="points-level" class="progress">
						<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="' . $progress . '" aria-valuemin="0" aria-valuemax="100" style="width: ' . $progress . '%">
							<span class="sr-only">' . wfMessage('user-profile-points', $wgLang->formatNum($stats_data['points']))->escaped() . '</span>
						</div>

					</div>';
        }
        $output .= '<div class="profile-actions">';
        $output .= '<div class="form-container ' . ($this->isOwner() ? 'owner' : '') . '"><div class="form-msg"><a class="form-location ' . ($this->isOwner() ? 'edit' : '') . '">' . ($city == '' ? $this->isOwner() ? '填写居住地' : '居住地未公开' : $city) . '</a>
                    <span class="span-color">|</span><a class="form-date ' . ($this->isOwner() ? 'edit' : '') . '" data-birthday="' . ($birthday == '' || $birthday == '0000-00-00' ? '' : $birthday) . '">' . ($birthday == '' || $birthday == '0000-00-00' ? $this->isOwner() ? '填写生日' : '生日未公开' : '') . '</a>
                    <span class="span-color">|</span><a class="form-sex ' . ($this->isOwner() ? 'edit' : '') . '" data-sex="' . $gender . '">' . $genderIcon . '</a></div>';
        $output .= '<div class="user-autograph"><a class="form-autograph ' . ($this->isOwner() ? 'edit' : '') . '">' . ($status == '' ? $this->isOwner() ? '填写个人状态' : '这个人很懒,什么都没有写...' : $status) . '</a></div></div>';
        // Links to User:user_name from User_profile:
        // if ( $this->getTitle()->getNamespace() == NS_USER_PROFILE && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_page->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-page-link' )->escaped() . '</a> ';
        // }
        // // Links to User:user_name from User_profile:
        // if ( $this->getTitle()->getNamespace() == NS_USER && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_social_profile->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-social-profile-link' )->escaped() . '</a> ';
        // }
        // if ( $this->getTitle()->getNamespace() == NS_USER && ( !$this->profile_data['user_id'] || $this->profile_data['user_page_type'] == 1 ) ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_wiki->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-wiki-link' )->escaped() . '</a>';
        // }
        $output .= '</div></div>';
        return $output;
    }
示例#8
0
文件: View.php 项目: Rikuforever/wiki
 static function formatSubject($s)
 {
     # Sanitize text a bit:
     $s = str_replace("\n", " ", $s);
     # Allow HTML entities
     $s = Sanitizer::escapeHtmlAllowEntities($s);
     # Render links:
     return Linker::formatLinksInComment($s, null, false);
 }
 /**
  * @param $row
  * @return String
  */
 private function formatBlockStatus($row)
 {
     $additionalHtml = '';
     if (isset($row['blocked']) && $row['blocked']) {
         $flags = array();
         foreach (array('anononly', 'nocreate', 'noautoblock', 'noemail', 'nousertalk') as $option) {
             if ($row['block-' . $option]) {
                 $flags[] = $option;
             }
         }
         $flags = implode(',', $flags);
         $optionMessage = BlockLogFormatter::formatBlockFlags($flags, $this->getLanguage());
         if ($row['block-expiry'] == 'infinity') {
             $text = $this->msg('centralauth-admin-blocked2-indef')->parse();
         } else {
             $expiry = $this->getLanguage()->timeanddate($row['block-expiry'], true);
             $expiryd = $this->getLanguage()->date($row['block-expiry'], true);
             $expiryt = $this->getLanguage()->time($row['block-expiry'], true);
             $text = $this->msg('centralauth-admin-blocked2', $expiry, $expiryd, $expiryt)->parse();
         }
         if ($flags) {
             $additionalHtml .= ' ' . $optionMessage;
         }
         if ($row['block-reason']) {
             $reason = Sanitizer::escapeHtmlAllowEntities($row['block-reason']);
             $reason = Linker::formatLinksInComment($reason, null, false, $row['wiki']);
             $msg = $this->msg('centralauth-admin-blocked-reason');
             $msg->rawParams('<span class="plainlinks">' . $reason . '</span>');
             $additionalHtml .= ' ' . $msg->parse();
         }
     } else {
         $text = $this->msg('centralauth-admin-notblocked')->parse();
     }
     return self::foreignLink($row['wiki'], 'Special:Log/block', $text, $this->msg('centralauth-admin-blocklog')->text(), 'page=User:' . urlencode($this->mUserName)) . $additionalHtml;
 }
 /**
  * @dataProvider provideEscapeHtmlAllowEntities
  * @covers Sanitizer::escapeHtmlAllowEntities
  */
 public function testEscapeHtmlAllowEntities($expected, $html)
 {
     $this->assertEquals($expected, Sanitizer::escapeHtmlAllowEntities($html));
 }
	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 );
		}
	}
示例#12
0
 static function formatSubject($s)
 {
     wfProfileIn(__METHOD__);
     $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
     # Sanitize text a bit:
     $s = str_replace("\n", " ", $s);
     # Allow HTML entities
     $s = Sanitizer::escapeHtmlAllowEntities($s);
     # Render links:
     $s = $linker->formatLinksInComment($s, null, false);
     wfProfileOut(__METHOD__);
     return $s;
 }
					<span class="wam-vertical"><?php 
    echo $sWikiVerticalName;
    ?>
</span>
				</a>
			<?php 
}
?>
		</div>
	</div>
	<ol class="wam-top-gainers-list">
		<?php 
foreach ($visualizationWikis as $k => $wiki) {
    ?>
			<li class="wam-top-gainers-list-item"><?php 
    echo Sanitizer::escapeHtmlAllowEntities($wiki['title']);
    ?>
</li>
		<?php 
}
?>
	</ol>
</div>

<div class="wam-content">
	<div class="wam-content-logo"></div>
	<div class="wam-content-text">
		<h2><?php 
echo wfMessage('wampage-header-wam')->escaped();
?>
</h2>
示例#14
0
/**
 * Returns message in the requested format
 *
 * @deprecated since 1.18
 *
 * @param string $key Key of the message
 * @param array $options Processing rules.
 *   Can take the following options:
 *     parse: parses wikitext to HTML
 *     parseinline: parses wikitext to HTML and removes the surrounding
 *       p's added by parser or tidy
 *     escape: filters message through htmlspecialchars
 *     escapenoentities: same, but allows entity references like &#160; through
 *     replaceafter: parameters are substituted after parsing or escaping
 *     parsemag: transform the message using magic phrases
 *     content: fetch message for content language instead of interface
 *   Also can accept a single associative argument, of the form 'language' => 'xx':
 *     language: Language object or language code to fetch message for
 *       (overridden by content).
 * Behavior for conflicting options (e.g., parse+parseinline) is undefined.
 *
 * @return string
 */
function wfMsgExt($key, $options)
{
    wfDeprecated(__METHOD__, '1.21');
    $args = func_get_args();
    array_shift($args);
    array_shift($args);
    $options = (array) $options;
    $validOptions = array('parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', 'parsemag', 'content');
    foreach ($options as $arrayKey => $option) {
        if (!preg_match('/^[0-9]+|language$/', $arrayKey)) {
            // An unknown index, neither numeric nor "language"
            wfWarn("wfMsgExt called with incorrect parameter key {$arrayKey}", 1, E_USER_WARNING);
        } elseif (preg_match('/^[0-9]+$/', $arrayKey) && !in_array($option, $validOptions)) {
            // A numeric index with unknown value
            wfWarn("wfMsgExt called with incorrect parameter {$option}", 1, E_USER_WARNING);
        }
    }
    if (in_array('content', $options, true)) {
        $forContent = true;
        $langCode = true;
        $langCodeObj = null;
    } elseif (array_key_exists('language', $options)) {
        $forContent = false;
        $langCode = wfGetLangObj($options['language']);
        $langCodeObj = $langCode;
    } else {
        $forContent = false;
        $langCode = false;
        $langCodeObj = null;
    }
    $string = wfMsgGetKey($key, true, $langCode, false);
    if (!in_array('replaceafter', $options, true)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    $messageCache = MessageCache::singleton();
    $parseInline = in_array('parseinline', $options, true);
    if (in_array('parse', $options, true) || $parseInline) {
        $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj);
        if ($string instanceof ParserOutput) {
            $string = $string->getText();
        }
        if ($parseInline) {
            $string = Parser::stripOuterParagraph($string);
        }
    } elseif (in_array('parsemag', $options, true)) {
        $string = $messageCache->transform($string, !$forContent, $langCodeObj);
    }
    if (in_array('escape', $options, true)) {
        $string = htmlspecialchars($string);
    } elseif (in_array('escapenoentities', $options, true)) {
        $string = Sanitizer::escapeHtmlAllowEntities($string);
    }
    if (in_array('replaceafter', $options, true)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    return $string;
}
示例#15
0
<!-- s:<?php 
echo __FILE__;
?>
 -->
<!-- MAIN-PAGE -->

<p id="sponsorship-dashboard-nodata"><?php 
echo Sanitizer::escapeHtmlAllowEntities($emptyChartMsg);
?>
</p>

<!-- END OF MAIN-PAGE -->
<!-- e:<?php 
echo __FILE__;
?>
 -->
示例#16
0
 /**
  * This function is called by all recent changes variants, by the page history,
  * and by the user contributions list. It is responsible for formatting edit
  * comments. It escapes any HTML in the comment, but adds some CSS to format
  * auto-generated comments (from section editing) and formats [[wikilinks]].
  *
  * @author Erik Moeller <*****@*****.**>
  *
  * Note: there's not always a title to pass to this function.
  * Since you can't set a default parameter for a reference, I've turned it
  * temporarily to a value pass. Should be adjusted further. --brion
  *
  * @param $comment String
  * @param $title Mixed: Title object (to generate link to the section in autocomment) or null
  * @param $local Boolean: whether section links should refer to local page
  */
 static function formatComment($comment, $title = null, $local = false)
 {
     wfProfileIn(__METHOD__);
     # Sanitize text a bit:
     $comment = str_replace("\n", " ", $comment);
     # Allow HTML entities (for bug 13815)
     $comment = Sanitizer::escapeHtmlAllowEntities($comment);
     # Render autocomments and make links:
     $comment = self::formatAutocomments($comment, $title, $local);
     $comment = self::formatLinksInComment($comment, $title, $local);
     wfProfileOut(__METHOD__);
     return $comment;
 }
	/**
	 * Handler for action=view requests.
	 */
	public function view() {
		global $wgRequest, $wgOut;

		if ( $wgRequest->getVal( 'diff' ) ) {
			# Ignore comments if diffing.
			return parent::view();
		}

		if ( !$this->mItem ) {
			# There is no wikilog article associated with this discussion
			# page. Act as a normal talk page in this case, leaving
			# everything to the parent class.
			return parent::view();
		}

		# Create our query object.
		$query = new WikilogCommentQuery( $this->mItem );

		if ( ( $feedFormat = $wgRequest->getVal( 'feed' ) ) ) {
			# RSS or Atom feed requested. Ignore all other options.
			global $wgWikilogNumComments;
			$query->setModStatus( WikilogCommentQuery::MS_ACCEPTED );
			$feed = new WikilogCommentFeed( $this->mTitle, $feedFormat, $query,
				$wgRequest->getInt( 'limit', $wgWikilogNumComments ) );
			return $feed->execute();
		}

		if ( $this->mSingleComment ) {
			# Single comment view, show comment followed by its replies.
			$params = $this->mFormatter->getCommentMsgParams( $this->mSingleComment );

			# Display the comment header and other status messages.
			$wgOut->addHtml( $this->mFormatter->formatCommentHeader( $this->mSingleComment, $params ) );

			# Display talk page contents.
			parent::view();

			# Display the comment footer.
			$wgOut->addHtml( $this->mFormatter->formatCommentFooter( $this->mSingleComment, $params ) );
		} else {
			# Normal page view, show talk page contents followed by comments.
			parent::view();

			# Set a more human-friendly title to the comments page.
			# NOTE (MW1.16+): Must come after parent::view().
			# Note: Sorry for the three-level cascade of wfMsg()'s...
			$fullPageTitle = wfMsg( 'wikilog-title-item-full',
				$this->mItem->mName,
				$this->mItem->mParentTitle->getPrefixedText()
			);
			$fullPageTitle = wfMsg( 'wikilog-title-comments', $fullPageTitle );
			$wgOut->setPageTitle( wfMsg( 'wikilog-title-comments', $this->mItem->mName ) );
			$wgOut->setHTMLTitle( wfMsg( 'pagetitle', $fullPageTitle ) );
		}

		# Add a backlink to the original article.
		$link = $this->mSkin->link( $this->mItem->mTitle,
			Sanitizer::escapeHtmlAllowEntities( $this->mItem->mName ) );
		$wgOut->setSubtitle( wfMsg( 'wikilog-backlink', $link ) );

		# Retrieve comments (or replies) from database and display them.
		$this->viewComments( $query );

		# Add feed links.
		$wgOut->setSyndicated();
	}
示例#18
0
					<?php 
    foreach ($content as $item) {
        ?>
						<tr class="insights-list-item">
							<td class="insights-list-item-page insights-list-cell insights-list-first-column">
								<a class="insights-list-item-title <?php 
        echo Sanitizer::encodeAttribute($item['link']['classes']);
        ?>
" title="<?php 
        echo Sanitizer::encodeAttribute($item['link']['title']);
        ?>
" href="<?php 
        echo Sanitizer::cleanUrl($item['link']['url']);
        ?>
"><?php 
        echo Sanitizer::escapeHtmlAllowEntities($item['link']['text']);
        ?>
</a>
								<?php 
        if (isset($item['metadata'])) {
            ?>
									<p class="insights-list-item-metadata">
										<?php 
            if (isset($item['metadata']['lastRevision'])) {
                ?>
											<?php 
                echo wfMessage('insights-last-edit')->rawParams(Xml::element('a', ['href' => $item['metadata']['lastRevision']['userpage']], $item['metadata']['lastRevision']['username']), date('F j, Y', $item['metadata']['lastRevision']['timestamp']))->escaped();
                ?>
										<?php 
            }
            ?>
示例#19
0
    echo wfMessage('swm-label-mode-users-poweruser')->escaped();
    ?>
</label>
							</td>
							<td>
								<?php 
    foreach ($formData['powerUserTypes'] as $powerUserType) {
        $html = '<label for="mPowerUserType_' . Sanitizer::encodeAttribute($powerUserType) . '">';
        $html .= '<input type="checkbox" name="mPowerUserType[]"';
        $html .= 'id="mPowerUserType_' . Sanitizer::encodeAttribute($powerUserType) . '"';
        $html .= 'value="' . Sanitizer::encodeAttribute($powerUserType) . '"';
        if (isset($formData['mPowerUserType']) && in_array($powerUserType, $formData['mPowerUserType'])) {
            $html .= ' checked="checked"';
        }
        $html .= '>';
        $html .= Sanitizer::escapeHtmlAllowEntities($powerUserType) . '</label><br>';
        echo $html;
    }
    ?>
							</td>
							<td class="swm-hint">
								<?php 
    echo wfMessage('swm-label-mode-users-poweruser-hint')->parse();
    ?>
							</td>
						</tr>

						<tr>
							<td>
								<input name="mSendModeUsers" id="mSendModeUsersU" type="radio" value="USER"<?php 
    echo $formData['sendModeUsers'] == 'USER' ? ' checked="checked"' : '';