当前位置: 首页>>代码示例>>PHP>>正文


PHP Linker::makeMediaLinkObj方法代码示例

本文整理汇总了PHP中Linker::makeMediaLinkObj方法的典型用法代码示例。如果您正苦于以下问题:PHP Linker::makeMediaLinkObj方法的具体用法?PHP Linker::makeMediaLinkObj怎么用?PHP Linker::makeMediaLinkObj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Linker的用法示例。


在下文中一共展示了Linker::makeMediaLinkObj方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     $nt = Title::makeTitle($result->namespace, $result->title);
     $text = $wgContLang->convert($nt->getText());
     $plink = Linker::link(Title::newFromText($nt->getPrefixedText()), htmlspecialchars($text));
     $download = Linker::makeMediaLinkObj($nt, wfMsgHtml('download'));
     $lang = $this->getLanguage();
     $bytes = htmlspecialchars($lang->formatSize($result->img_size));
     $dimensions = htmlspecialchars(wfMsg('widthheight', $lang->formatNum($result->img_width), $lang->formatNum($result->img_height)));
     $user = Linker::link(Title::makeTitle(NS_USER, $result->img_user_text), htmlspecialchars($result->img_user_text));
     $time = htmlspecialchars($lang->timeanddate($result->img_timestamp));
     return "({$download}) {$plink} . . {$dimensions} . . {$bytes} . . {$user} . . {$time}";
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:SpecialMIMEsearch.php

示例2: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     $nt = Title::makeTitle($result->namespace, $result->title);
     $text = $wgContLang->convert($nt->getText());
     $plink = Linker::link(Title::newFromText($nt->getPrefixedText()), htmlspecialchars($text));
     $download = Linker::makeMediaLinkObj($nt, $this->msg('download')->escaped());
     $download = $this->msg('parentheses')->rawParams($download)->escaped();
     $lang = $this->getLanguage();
     $bytes = htmlspecialchars($lang->formatSize($result->img_size));
     $dimensions = $this->msg('widthheight')->numParams($result->img_width, $result->img_height)->escaped();
     $user = Linker::link(Title::makeTitle(NS_USER, $result->img_user_text), htmlspecialchars($result->img_user_text));
     $time = htmlspecialchars($lang->userTimeAndDate($result->img_timestamp, $this->getUser()));
     return "{$download} {$plink} . . {$dimensions} . . {$bytes} . . {$user} . . {$time}";
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:15,代码来源:SpecialMIMEsearch.php

示例3: 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. WARNING! Since the output of this
     *	function is html, $comment must be sanitized for use as html. You probably want
     *	to pass $comment through Sanitizer::escapeHtmlAllowEntities() before calling
     *	this function.
     * @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] = strtr(rawurldecode($match[1]), array('<' => '&lt;', '>' => '&gt;'));
            }
            # 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;
                    }
                    $thelink = Linker::makeCommentLink($target, $linkText . $inside, $wikiId) . $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);
    }
开发者ID:paladox,项目名称:2,代码行数:84,代码来源:Linker.php

示例4: makeMediaLinkObj

 public function makeMediaLinkObj($title, $html = '', $time = false)
 {
     return Linker::makeMediaLinkObj($title, $html, $time);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:DummyLinker.php

示例5: getFileLink

 /**
  * Generates a media, external or file link for a given result
  * @param object $oDocument Apache_Solr_Document
  * @param object $oTitle Title of wiki page
  * @return string Anchor media, external or file link
  */
 private function getFileLink($oDocument, $oTitle)
 {
     if ($oDocument->overall_type == 'repo') {
         $sSearchLink = Linker::makeMediaLinkObj($oTitle);
     } elseif ($oDocument->overall_type == 'special-linked') {
         $sTitle = $oDocument->title;
         $sLink = $oDocument->path;
         $sSearchLink = Linker::makeExternalLink($sLink, $sTitle, '');
         $sSearchLink = str_replace('<a', '<a target="_blank"', $sSearchLink);
     } else {
         $sTitle = $oDocument->title;
         $sLink = $oDocument->path;
         $sSearchLink = '<a target="_blank" href="file:///' . $sLink . '">' . $sTitle . '</a>';
     }
     return $sSearchLink;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:22,代码来源:SearchResult.class.php


注:本文中的Linker::makeMediaLinkObj方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。