本文整理汇总了PHP中Linker::makeExternalLink方法的典型用法代码示例。如果您正苦于以下问题:PHP Linker::makeExternalLink方法的具体用法?PHP Linker::makeExternalLink怎么用?PHP Linker::makeExternalLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linker
的用法示例。
在下文中一共展示了Linker::makeExternalLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLicense
/**
* Returns HTML of license link or empty string
* For example:
* "<a title="Wikipedia:Copyright" href="/index.php/Wikipedia:Copyright">CC BY</a>"
*
* @param string $context The context in which the license link appears, e.g. footer,
* editor, talk, or upload.
* @param array $attribs An associative array of extra HTML attributes to add to the link
* @return string
*/
public static function getLicense($context, $attribs = array())
{
$config = MobileContext::singleton()->getConfig();
$rightsPage = $config->get('RightsPage');
$rightsUrl = $config->get('RightsUrl');
$rightsText = $config->get('RightsText');
// Construct the link to the licensing terms
if ($rightsText) {
// Use shorter text for some common licensing strings. See Installer.i18n.php
// for the currently offered strings. Unfortunately, there is no good way to
// comprehensively support localized licensing strings since the license (as
// stored in LocalSettings.php) is just freeform text, not an i18n key.
$commonLicenses = array('Creative Commons Attribution-Share Alike 3.0' => 'CC BY-SA 3.0', 'Creative Commons Attribution Share Alike' => 'CC BY-SA', 'Creative Commons Attribution 3.0' => 'CC BY 3.0', 'Creative Commons Attribution 2.5' => 'CC BY 2.5', 'Creative Commons Attribution' => 'CC BY', 'Creative Commons Attribution Non-Commercial Share Alike' => 'CC BY-NC-SA', 'Creative Commons Zero (Public Domain)' => 'CC0 (Public Domain)', 'GNU Free Documentation License 1.3 or later' => 'GFDL 1.3 or later');
if (isset($commonLicenses[$rightsText])) {
$rightsText = $commonLicenses[$rightsText];
}
if ($rightsPage) {
$title = Title::newFromText($rightsPage);
$link = Linker::linkKnown($title, $rightsText, $attribs);
} elseif ($rightsUrl) {
$link = Linker::makeExternalLink($rightsUrl, $rightsText, true, '', $attribs);
} else {
$link = $rightsText;
}
} else {
$link = '';
}
// Allow other extensions (for example, WikimediaMessages) to override
$msg = 'mobile-frontend-copyright';
Hooks::run('MobileLicenseLink', array(&$link, $context, $attribs, &$msg));
return array('msg' => $msg, 'link' => $link, 'plural' => self::getPluralLicenseInfo($link));
}
示例2: makeForeignLink
/**
* Convenience to get a link to a page on a foreign wiki
*
* @param $wikiID String: wiki'd id (generally database name)
* @param $page String: page name (must be normalised before calling this function!)
* @param $text String: link's text; optional, default to $page
* @return String: HTML link or false if the wiki was not found
*/
public static function makeForeignLink($wikiID, $page, $text = null)
{
if (!$text) {
$text = $page;
}
$url = self::getForeignURL($wikiID, $page);
if ($url === false) {
return false;
}
return Linker::makeExternalLink($url, $text);
}
示例3: efParserCreateLink
/**
* Creates a HTML link that will open in a new browser window or tab.
*
* @param Parser $parser Parser being used
* @param string $target literal URI or a MediaWiki link for linked resource
* @param string $label link text
* @return string HTML
*/
function efParserCreateLink($parser, $target, $label = null)
{
// sanitise the input and set defaults
if (is_null($label)) {
$label = $target;
$label = htmlspecialchars($label, ENT_NOQUOTES, 'UTF-8');
} else {
$label = preg_replace("/\\b({$parser->mUrlProtocols})/", "\$1 ", $label);
// Hack to not parse external links by breaking them
$label = $parser->recursiveTagParse($label);
$label = preg_replace("/\\b({$parser->mUrlProtocols}) /", "\$1", $label);
// Put them back together
}
$attributes = array('target' => '_blank');
// WARNING: the order of the statements below does matter!
//
// Also, the Parser::insertStripItem is used to render the HTML inline.
// See: http://www.mediawiki.org/wiki/Manual:Parser_functions#Parser_interface
// Process (or rule out) external targets (literal URIs)
if (preg_match($parser->mExtLinkBracketedRegex, "[{$target}]")) {
return $parser->insertStripItem(Linker::makeExternalLink($target, $label, false, '', $attributes), $parser->mStripState);
}
// The target is not a literal URI. Create a Title object.
$oTitle = Title::newFromText($target);
// Title::newFromText may occasionally return null, which means something is really wrong with the $target.
if (is_null($oTitle)) {
return $parser->insertStripItem(wfMsg('newwindowlinks-invalid-target'), $parser->mStripState);
}
// Process (or rule out) existing local articles.
if ($oTitle->exists()) {
return $parser->insertStripItem(Linker::link($oTitle, $label, $attributes), $parser->mStripState);
}
// Process (or rule out) interwiki links.
if (true !== $oTitle->isLocal()) {
return $parser->insertStripItem(Linker::makeExternalLink($oTitle->getFullURL(), $label, false, '', $attributes), $parser->mStripState);
}
// Only non existing local articles remain.
return $parser->insertStripItem(Linker::link($oTitle, $label, $attributes), $parser->mStripState);
}
示例4: getList
public function getList($limit = 10, $offset = 0, $wikiName = null, $criteria = array(), $order = 'city_created DESC')
{
$data = array('count' => 0, 'items' => array());
$where = array();
// processing parameters for DB query: the criteria
foreach ($criteria as $v) {
if (isset($this->criteria[$v])) {
$where[$this->criteria[$v]['column']] = 1;
}
}
// display wikis having names starting with $wikiName
if (!empty($wikiName)) {
$where[] = 'city_url >= ' . $this->db->addQuotes('http://' . $wikiName);
}
// check for the number of wikis matching the given criteria
$oRow = $this->db->selectRow('noreptemp.spamwikis', 'count(0) as cnt', $where, __METHOD__, null);
if (is_object($oRow)) {
$data['count'] = $oRow->cnt;
}
// empty set, so let's give up here
if (0 == $data['count']) {
return $data;
}
// if one or more wikis match the given criteria, fetch the actual data
$res = $this->db->select('noreptemp.spamwikis', array('city_id', 'city_url', 'city_title', 'city_created', 'city_founding_user'), $where, __METHOD__, array('LIMIT' => $limit, 'OFFSET' => $offset, 'ORDER BY' => $order));
// process the data
while ($oRow = $this->db->fetchObject($res)) {
// fetch and format the information about the user, who created the wiki
$user = User::newFromId($oRow->city_founding_user);
$mail = $user->getEmail();
if (!empty($mail)) {
$mail = Linker::makeExternalLink('mailto:' . $user->getEmail(), $user->getEmail(), false);
}
// format the output
$data['items'][] = array('<input type="checkbox" name="close[' . $oRow->city_id . ']" value="1" />', '<b>' . $oRow->city_title . '</b><br /><small>' . Linker::makeExternalLink($oRow->city_url, $oRow->city_url, false) . '</small>', $oRow->city_created, Linker::link($user->getUserPage(), $user->getName()), $mail);
}
// return the output
return $data;
}
示例5: getCopyright
/**
* @param string $type
* @return string
*/
function getCopyright($type = 'detect')
{
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
if ($type == 'detect') {
if (!$this->isRevisionCurrent() && !$this->msg('history_copyright')->inContentLanguage()->isDisabled()) {
$type = 'history';
} else {
$type = 'normal';
}
}
if ($type == 'history') {
$msg = 'history_copyright';
} else {
$msg = 'copyright';
}
if ($wgRightsPage) {
$title = Title::newFromText($wgRightsPage);
$link = Linker::linkKnown($title, $wgRightsText);
} elseif ($wgRightsUrl) {
$link = Linker::makeExternalLink($wgRightsUrl, $wgRightsText);
} elseif ($wgRightsText) {
$link = $wgRightsText;
} else {
# Give up now
return '';
}
// Allow for site and per-namespace customization of copyright notice.
// @todo Remove deprecated $forContent param from hook handlers and then remove here.
$forContent = true;
Hooks::run('SkinCopyrightFooter', array($this->getTitle(), $type, &$msg, &$link, &$forContent));
return $this->msg($msg)->rawParams($link)->text();
}
示例6: sysLinks
/**
* @return string
*/
function sysLinks()
{
$s = array($this->getSkin()->mainPageLink(), Linker::linkKnown(Title::newFromText(wfMessage('aboutpage')->inContentLanguage()->text()), wfMessage('about')->text()), Linker::makeExternalLink(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()), wfMessage('help')->text(), false), Linker::linkKnown(Title::newFromText(wfMessage('faqpage')->inContentLanguage()->text()), wfMessage('faq')->text()));
$personalUrls = $this->getPersonalTools();
foreach (array('logout', 'createaccount', 'login') as $key) {
if ($personalUrls[$key]) {
$s[] = $this->makeListItem($key, $personalUrls[$key], array('tag' => 'span'));
}
}
return $this->getSkin()->getLanguage()->pipeList($s);
}
示例7: showIncubatingWiki
/**
* @return String
*/
public function showIncubatingWiki() {
global $wgLang;
$substatus = $this->mSubStatus;
if( $substatus == 'imported' && $this->mIsSister ) {
$substatus = 'closedsister';
}
$portalLink = Linker::makeExternalLink( $this->mPortal, $this->mProjectName );
if( $this->mThisLangData['type'] != 'invalid' ) {
$gotoLink = Linker::link(
IncubatorTest::getMainPage( $this->mLangCode, $this->mPrefix ),
wfMsgNoTrans( 'wminc-infopage-enter' ) );
$gotoMainPage = Html::rawElement( 'span',
array( 'class' => 'wminc-infopage-entertest' ),
$wgLang->getArrow() . ' ' . ( $this->mIsSister ? $portalLink : $gotoLink ) );
}
$subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode );
$subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true );
$content = Html::rawElement( 'div', array( 'class' => 'wminc-infopage-status' ),
wfMsgWikiHtml( 'wminc-infopage-status-' . $substatus, $subdomainLink, $portalLink ) );
if( $this->mSubStatus != 'approved' && $this->mThisLangData['type'] != 'invalid' ) {
$content .= Html::element( 'div',
array( 'class' => 'wminc-infopage-contribute' ),
wfMsg( 'wminc-infopage-contribute' ) );
}
return $this->StandardInfoPage( '', $gotoMainPage, $content );
}
示例8: getCreditsForExtension
/**
* Creates and formats a version line for a single extension.
*
* Information for five columns will be created. Parameters required in the
* $extension array for part rendering are indicated in ()
* - The name of (name), and URL link to (url), the extension
* - Official version number (version) and if available version control system
* revision (path), link, and date
* - If available the short name of the license (license-name) and a linke
* to ((LICENSE)|(COPYING))(\.txt)? if it exists.
* - Description of extension (descriptionmsg or description)
* - List of authors (author) and link to a ((AUTHORS)|(CREDITS))(\.txt)? file if it exists
*
* @param $extension Array
*
* @return string raw HTML
*/
function getCreditsForExtension(array $extension)
{
$out = $this->getOutput();
// We must obtain the information for all the bits and pieces!
// ... such as extension names and links
$extensionName = isset($extension['name']) ? $extension['name'] : '[no name]';
if (isset($extension['url'])) {
$extensionNameLink = Linker::makeExternalLink($extension['url'], $extensionName, true, '', array('class' => 'mw-version-ext-name'));
} else {
$extensionNameLink = $extensionName;
}
// ... and the version information
// If the extension path is set we will check that directory for GIT and SVN
// metadata in an attempt to extract date and vcs commit metadata.
$canonicalVersion = '–';
$extensionPath = null;
$vcsVersion = null;
$vcsLink = null;
$vcsDate = null;
if (isset($extension['version'])) {
$canonicalVersion = $out->parseInline($extension['version']);
}
if (isset($extension['path'])) {
$extensionPath = dirname($extension['path']);
$gitInfo = new GitInfo($extensionPath);
$vcsVersion = $gitInfo->getHeadSHA1();
if ($vcsVersion !== false) {
$vcsVersion = substr($vcsVersion, 0, 7);
$vcsLink = $gitInfo->getHeadViewUrl();
$vcsDate = $gitInfo->getHeadCommitDate();
} else {
$svnInfo = self::getSvnInfo($extensionPath);
if ($svnInfo !== false) {
$vcsVersion = $this->msg('version-svn-revision', $svnInfo['checkout-rev'])->text();
$vcsLink = isset($svnInfo['viewvc-url']) ? $svnInfo['viewvc-url'] : '';
}
}
}
$versionString = Html::rawElement('span', array('class' => 'mw-version-ext-version'), $canonicalVersion);
if ($vcsVersion) {
if ($vcsLink) {
$vcsVerString = Linker::makeExternalLink($vcsLink, $this->msg('version-version', $vcsVersion), true, '', array('class' => 'mw-version-ext-vcs-version'));
} else {
$vcsVerString = Html::element('span', array('class' => 'mw-version-ext-vcs-version'), "({$vcsVersion})");
}
$versionString .= " {$vcsVerString}";
if ($vcsDate) {
$vcsTimeString = Html::element('span', array('class' => 'mw-version-ext-vcs-timestamp'), $this->getLanguage()->timeanddate($vcsDate));
$versionString .= " {$vcsTimeString}";
}
$versionString = Html::rawElement('span', array('class' => 'mw-version-ext-meta-version'), $versionString);
}
// ... and license information; if a license file exists we
// will link to it
$licenseLink = '';
if (isset($extension['license-name'])) {
$licenseLink = Linker::link($this->getPageTitle('License/' . $extensionName), $out->parseInline($extension['license-name']), array('class' => 'mw-version-ext-license'));
} elseif ($this->getExtLicenseFileName($extensionPath)) {
$licenseLink = Linker::link($this->getPageTitle('License/' . $extensionName), $this->msg('version-ext-license'), array('class' => 'mw-version-ext-license'));
}
// ... and generate the description; which can be a parameterized l10n message
// in the form array( <msgname>, <parameter>, <parameter>... ) or just a straight
// up string
if (isset($extension['descriptionmsg'])) {
// Localized description of extension
$descriptionMsg = $extension['descriptionmsg'];
if (is_array($descriptionMsg)) {
$descriptionMsgKey = $descriptionMsg[0];
// Get the message key
array_shift($descriptionMsg);
// Shift out the message key to get the parameters only
array_map("htmlspecialchars", $descriptionMsg);
// For sanity
$description = $this->msg($descriptionMsgKey, $descriptionMsg)->text();
} else {
$description = $this->msg($descriptionMsg)->text();
}
} elseif (isset($extension['description'])) {
// Non localized version
$description = $extension['description'];
} else {
$description = '';
}
//.........这里部分代码省略.........
示例9: makeCommentLink
/**
* Generates a link to the given Title
*
* @note This is only public for technical reasons. It's not intended for use outside Linker.
*
* @param Title $title
* @param string $text
* @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
* as used by WikiMap.
* @param string|string[] $options See the $options parameter in Linker::link.
*
* @return string HTML link
*/
public static function makeCommentLink(Title $title, $text, $wikiId = null, $options = array())
{
if ($wikiId !== null && !$title->isExternal()) {
$link = Linker::makeExternalLink(WikiMap::getForeignURL($wikiId, $title->getPrefixedText(), $title->getFragment()), $text, false);
} else {
$link = Linker::link($title, $text, array(), array(), $options);
}
return $link;
}
示例10: getCopyright
function getCopyright($type = 'detect')
{
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
if ($type == 'detect') {
$diff = $this->getRequest()->getVal('diff');
if (is_null($diff) && !$this->isRevisionCurrent() && wfMsgForContent('history_copyright') !== '-') {
$type = 'history';
} else {
$type = 'normal';
}
}
if ($type == 'history') {
$msg = 'history_copyright';
} else {
$msg = 'copyright';
}
$out = '';
if ($wgRightsPage) {
$title = Title::newFromText($wgRightsPage);
$link = Linker::linkKnown($title, $wgRightsText);
} elseif ($wgRightsUrl) {
$link = Linker::makeExternalLink($wgRightsUrl, $wgRightsText);
} elseif ($wgRightsText) {
$link = $wgRightsText;
} else {
# Give up now
return $out;
}
// Allow for site and per-namespace customization of copyright notice.
$forContent = true;
wfRunHooks('SkinCopyrightFooter', array($this->getTitle(), $type, &$msg, &$link, &$forContent));
if ($forContent) {
$out .= wfMsgForContent($msg, $link);
} else {
$out .= wfMsg($msg, $link);
}
return $out;
}
示例11: makeExternalLink
public function makeExternalLink($url, $text, $escape = true, $linktype = '', $attribs = [], $title = null)
{
return Linker::makeExternalLink($url, $text, $escape, $linktype, $attribs, $title);
}
示例12: getCreditsForExtension
/**
* Creates and formats a version line for a single extension.
*
* Information for five columns will be created. Parameters required in the
* $extension array for part rendering are indicated in ()
* - The name of (name), and URL link to (url), the extension
* - Official version number (version) and if available version control system
* revision (path), link, and date
* - If available the short name of the license (license-name) and a link
* to ((LICENSE)|(COPYING))(\.txt)? if it exists.
* - Description of extension (descriptionmsg or description)
* - List of authors (author) and link to a ((AUTHORS)|(CREDITS))(\.txt)? file if it exists
*
* @param string $type Category name of the extension
* @param array $extension
*
* @return string Raw HTML
*/
public function getCreditsForExtension($type, array $extension)
{
$out = $this->getOutput();
// We must obtain the information for all the bits and pieces!
// ... such as extension names and links
if (isset($extension['namemsg'])) {
// Localized name of extension
$extensionName = $this->msg($extension['namemsg'])->text();
} elseif (isset($extension['name'])) {
// Non localized version
$extensionName = $extension['name'];
} else {
$extensionName = $this->msg('version-no-ext-name')->text();
}
if (isset($extension['url'])) {
$extensionNameLink = Linker::makeExternalLink($extension['url'], $extensionName, true, '', ['class' => 'mw-version-ext-name']);
} else {
$extensionNameLink = $extensionName;
}
// ... and the version information
// If the extension path is set we will check that directory for GIT
// metadata in an attempt to extract date and vcs commit metadata.
$canonicalVersion = '–';
$extensionPath = null;
$vcsVersion = null;
$vcsLink = null;
$vcsDate = null;
if (isset($extension['version'])) {
$canonicalVersion = $out->parseInline($extension['version']);
}
if (isset($extension['path'])) {
global $IP;
$extensionPath = dirname($extension['path']);
if ($this->coreId == '') {
wfDebug('Looking up core head id');
$coreHeadSHA1 = self::getGitHeadSha1($IP);
if ($coreHeadSHA1) {
$this->coreId = $coreHeadSHA1;
}
}
$cache = wfGetCache(CACHE_ANYTHING);
$memcKey = wfMemcKey('specialversion-ext-version-text', $extension['path'], $this->coreId);
list($vcsVersion, $vcsLink, $vcsDate) = $cache->get($memcKey);
if (!$vcsVersion) {
wfDebug("Getting VCS info for extension {$extension['name']}");
$gitInfo = new GitInfo($extensionPath);
$vcsVersion = $gitInfo->getHeadSHA1();
if ($vcsVersion !== false) {
$vcsVersion = substr($vcsVersion, 0, 7);
$vcsLink = $gitInfo->getHeadViewUrl();
$vcsDate = $gitInfo->getHeadCommitDate();
}
$cache->set($memcKey, [$vcsVersion, $vcsLink, $vcsDate], 60 * 60 * 24);
} else {
wfDebug("Pulled VCS info for extension {$extension['name']} from cache");
}
}
$versionString = Html::rawElement('span', ['class' => 'mw-version-ext-version'], $canonicalVersion);
if ($vcsVersion) {
if ($vcsLink) {
$vcsVerString = Linker::makeExternalLink($vcsLink, $this->msg('version-version', $vcsVersion), true, '', ['class' => 'mw-version-ext-vcs-version']);
} else {
$vcsVerString = Html::element('span', ['class' => 'mw-version-ext-vcs-version'], "({$vcsVersion})");
}
$versionString .= " {$vcsVerString}";
if ($vcsDate) {
$vcsTimeString = Html::element('span', ['class' => 'mw-version-ext-vcs-timestamp'], $this->getLanguage()->timeanddate($vcsDate, true));
$versionString .= " {$vcsTimeString}";
}
$versionString = Html::rawElement('span', ['class' => 'mw-version-ext-meta-version'], $versionString);
}
// ... and license information; if a license file exists we
// will link to it
$licenseLink = '';
if (isset($extension['name'])) {
$licenseName = null;
if (isset($extension['license-name'])) {
$licenseName = $out->parseInline($extension['license-name']);
} elseif ($this->getExtLicenseFileName($extensionPath)) {
$licenseName = $this->msg('version-ext-license')->escaped();
}
if ($licenseName !== null) {
//.........这里部分代码省略.........
示例13: formatVersionRow
public function formatVersionRow($arr)
{
$ts = $arr['timestamp'];
$wikis = $arr['wikis'];
$c = $arr['count'];
$hasSelf = in_array($this->mWiki, $wikis);
extract($this->formatConf);
$lang = $this->getLang();
$datime = $lang->timeanddate($ts);
$date = $lang->date($ts);
$time = $lang->time($ts);
## Make user link...
$userLink = '';
if (!$arr['user_wiki'] && !$arr['user_name']) {
$userLink = '';
# Nothing...
$username = '';
} elseif ($arr['user_wiki'] == wfWikiId()) {
$userLink = Linker::link(Title::makeTitle(NS_USER, $arr['user_name']), htmlspecialchars($arr['user_name']));
$username = $arr['user_name'];
} elseif ($wiki = WikiMap::getWiki($arr['user_wiki'])) {
$userLink = Linker::makeExternalLink($wiki->getUrl('User:' . $arr['user_name']), htmlspecialchars($arr['user_name'] . '@' . $arr['user_wiki']));
$username = '';
} else {
## Last-ditch
$userLink = htmlspecialchars($arr['user_name'] . '@' . $arr['user_wiki']);
$username = '';
}
$actions = array();
$view = '';
if ($hasSelf) {
$view .= Linker::linkKnown($self, $this->msg('configure-view')->escaped(), array(), array('version' => $ts));
} elseif ($allowedAll) {
$view .= $this->msg('configure-view')->escaped();
}
if ($allowedAll) {
$viewWikis = array();
foreach ($wikis as $wiki) {
$viewWikis[] = Linker::linkKnown($self, htmlspecialchars($wiki), array(), array('version' => $ts, 'wiki' => $wiki));
}
$view .= ' (' . $lang->commaList($viewWikis) . ')';
}
if ($view) {
$actions[] = $view;
}
$editDone = false;
if ($allowedConfig) {
if ($hasSelf) {
$editCore = $editMsg . Linker::linkKnown($configTitle, $this->msg('configure-edit-core')->escaped(), array(), array('version' => $ts));
} elseif ($allowedConfigAll) {
$editCore = $editMsg . $this->msg('configure-edit-core')->escaped();
} else {
$editCore = $editMsg;
}
if ($allowedConfigAll) {
$viewWikis = array();
foreach ($wikis as $wiki) {
$viewWikis[] = Linker::linkKnown($configTitle, htmlspecialchars($wiki), array(), array('version' => $ts, 'wiki' => $wiki));
}
$editCore .= ' (' . $lang->commaList($viewWikis) . ')';
}
$actions[] = $editCore;
}
if ($allowedExtensions) {
$editExt = '';
if (!$allowedConfig) {
$editExt .= $editMsg;
}
if ($hasSelf) {
$editExt .= Linker::linkKnown($extTitle, $this->msg('configure-edit-ext')->escaped(), array(), array('version' => $ts));
} elseif ($allowedExtensionsAll) {
$editExt .= $this->msg('configure-edit-ext')->escaped();
}
if ($allowedExtensionsAll) {
$viewWikis = array();
foreach ($wikis as $wiki) {
$viewWikis[] = Linker::linkKnown($extTitle, htmlspecialchars($wiki), array(), array('version' => $ts, 'wiki' => $wiki));
}
$editExt .= ' (' . $lang->commaList($viewWikis) . ')';
}
$actions[] = $editExt;
}
if ($showDiff) {
$diffCheck = $c == 2 ? array('checked' => 'checked') : array();
$versionCheck = $c == 1 ? array('checked' => 'checked') : array();
$buttons = Xml::element('input', array_merge(array('type' => 'radio', 'name' => 'diff', 'value' => $ts), $diffCheck)) . Xml::element('input', array_merge(array('type' => 'radio', 'name' => 'version', 'value' => $ts), $versionCheck));
$actions[] = Linker::link($this->getTitle(), $this->msg('configure-viewconfig-default-diff')->escaped(), array(), array('version' => $ts, 'diff' => 'default'));
} else {
$buttons = '';
}
$comment = $arr['reason'] ? Linker::commentBlock($arr['reason']) : '';
$action = $lang->commaList($actions);
$msg = $this->msg('configure-viewconfig-line')->rawParams($buttons)->params($datime)->rawParams($userLink, $action, $comment)->params($date, $time, $username)->parse();
return Xml::tags('li', null, $msg) . "\n";
}
示例14: showRedirectedFromHeader
/**
* If this request is a redirect view, send "redirected from" subtitle to
* $wgOut. Returns true if the header was needed, false if this is not a
* redirect view. Handles both local and remote redirects.
*
* @return boolean
*/
public function showRedirectedFromHeader()
{
global $wgOut, $wgRequest, $wgRedirectSources;
$rdfrom = $wgRequest->getVal('rdfrom');
if (isset($this->mRedirectedFrom)) {
// This is an internally redirected page view.
// We'll need a backlink to the source page for navigation.
if (wfRunHooks('ArticleViewRedirect', array(&$this))) {
# start wikia change
global $wgWikiaUseNoFollow;
$redirAttribs = array();
if (!empty($wgWikiaUseNoFollow)) {
$redirAttribs['rel'] = 'nofollow';
}
# end wikia change
$redir = Linker::linkKnown($this->mRedirectedFrom, null, $redirAttribs, array('redirect' => 'no'));
$wgOut->addSubtitle(wfMessage('redirectedfrom')->rawParams($redir));
// Set the fragment if one was specified in the redirect
if (strval($this->getTitle()->getFragment()) != '') {
$fragment = Xml::escapeJsString($this->getTitle()->getFragmentForURL());
$wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");");
}
/**
* Commented out by christian@wikia-inc.com
* /extensions/wikia/CanonicalHref is used by Wikia to handle redirects and all of these cases:
* http://muppet.wikia.com/wiki/Kermit_the_Frog
* http://muppet.wikia.com/index.php/Kermit_the_Frog
* http://muppet.wikia.com/index.php?title=Kermit_the_Frog
* http://muppet.wikia.com/wiki/Kermit_the_Frog?action=view
*
// Add a <link rel="canonical"> tag
$wgOut->addLink( array( 'rel' => 'canonical',
'href' => $this->getTitle()->getLocalURL() )
);
*/
// Tell $wgOut the user arrived at this article through a redirect
$wgOut->setRedirectedFrom($this->mRedirectedFrom);
return true;
}
} elseif ($rdfrom) {
// This is an externally redirected view, from some other wiki.
// If it was reported from a trusted site, supply a backlink.
if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) {
$redir = Linker::makeExternalLink($rdfrom, $rdfrom);
$wgOut->addSubtitle(wfMessage('redirectedfrom')->rawParams($redir));
return true;
}
}
return false;
}
示例15: formatLinksInComment
/**
* Formats wiki links and media links in text; all other wiki formatting
* is ignored
*
* @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
* @param string $comment Text to format links in
* @param Title|null $title An optional title object used to links to sections
* @param bool $local Whether section links should refer to local page
* @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap
*
* @return string
*/
public static function formatLinksInComment($comment, $title = null, $local = false, $wikiId = null)
{
return preg_replace_callback('/
\\[\\[
:? # ignore optional leading colon
([^\\]|]+) # 1. link target; page names cannot include ] or |
(?:\\|
# 2. a pipe-separated substring; only the last is captured
# Stop matching at | and ]] without relying on backtracking.
((?:]?[^\\]|])*+)
)*
\\]\\]
([^[]*) # 3. link trail (the text up until the next link)
/x', function ($match) use($title, $local, $wikiId) {
global $wgContLang;
$medians = '(?:' . preg_quote(MWNamespace::getCanonicalName(NS_MEDIA), '/') . '|';
$medians .= preg_quote($wgContLang->getNsText(NS_MEDIA), '/') . '):';
$comment = $match[0];
# fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
if (strpos($match[1], '%') !== false) {
$match[1] = str_replace(array('<', '>'), array('<', '>'), rawurldecode($match[1]));
}
# Handle link renaming [[foo|text]] will show link as "text"
if ($match[2] != "") {
$text = $match[2];
} else {
$text = $match[1];
}
$submatch = array();
$thelink = null;
if (preg_match('/^' . $medians . '(.*)$/i', $match[1], $submatch)) {
# Media link; trail not supported.
$linkRegexp = '/\\[\\[(.*?)\\]\\]/';
$title = Title::makeTitleSafe(NS_FILE, $submatch[1]);
if ($title) {
$thelink = Linker::makeMediaLinkObj($title, $text);
}
} else {
# Other kind of link
if (preg_match($wgContLang->linkTrail(), $match[3], $submatch)) {
$trail = $submatch[1];
} else {
$trail = "";
}
$linkRegexp = '/\\[\\[(.*?)\\]\\]' . preg_quote($trail, '/') . '/';
if (isset($match[1][0]) && $match[1][0] == ':') {
$match[1] = substr($match[1], 1);
}
list($inside, $trail) = Linker::splitTrail($trail);
$linkText = $text;
$linkTarget = Linker::normalizeSubpageLink($title, $match[1], $linkText);
$target = Title::newFromText($linkTarget);
if ($target) {
if ($target->getText() == '' && !$target->isExternal() && !$local && $title) {
$newTarget = clone $title;
$newTarget->setFragment('#' . $target->getFragment());
$target = $newTarget;
}
if ($wikiId !== null) {
$thelink = Linker::makeExternalLink(WikiMap::getForeignURL($wikiId, $target->getFullText()), $linkText . $inside, false) . $trail;
} else {
$thelink = Linker::link($target, $linkText . $inside) . $trail;
}
}
}
if ($thelink) {
// If the link is still valid, go ahead and replace it in!
$comment = preg_replace($linkRegexp, StringUtils::escapeRegexReplacement($thelink), $comment, 1);
}
return $comment;
}, $comment);
}