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


PHP ParserOptions::setMaxIncludeSize方法代码示例

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


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

示例1: execute

 function execute($subpage)
 {
     global $wgRequest, $wgParser, $wgOut;
     $this->setHeaders();
     $this->isNewParser = is_callable(array($wgParser, 'preprocessToDom'));
     $titleStr = $wgRequest->getText('contexttitle');
     $title = Title::newFromText($titleStr);
     $selfTitle = $this->getTitle();
     if (!$title) {
         $title = $selfTitle;
     }
     $input = $wgRequest->getText('input');
     $this->generateXML = $this->isNewParser ? $wgRequest->getBool('generate_xml') : false;
     if (strlen($input)) {
         $this->removeComments = $wgRequest->getBool('removecomments', false);
         $this->removeNowiki = $wgRequest->getBool('removenowiki', false);
         $options = new ParserOptions();
         $options->setRemoveComments($this->removeComments);
         $options->setTidy(true);
         $options->setMaxIncludeSize(self::MAX_INCLUDE_SIZE);
         if ($this->generateXML) {
             $wgParser->startExternalParse($title, $options, OT_PREPROCESS);
             $dom = $wgParser->preprocessToDom($input);
             if (is_callable(array($dom, 'saveXML'))) {
                 $xml = $dom->saveXML();
             } else {
                 $xml = $dom->__toString();
             }
         }
         $output = $wgParser->preprocess($input, $title, $options);
     } else {
         $this->removeComments = $wgRequest->getBool('removecomments', true);
         $this->removeNowiki = $wgRequest->getBool('removenowiki', false);
         $output = false;
     }
     $wgOut->addWikiText(wfMsg('expand_templates_intro'));
     $wgOut->addHTML($this->makeForm($titleStr, $input));
     if ($output !== false) {
         global $wgUseTidy, $wgAlwaysUseTidy;
         if ($this->generateXML) {
             $wgOut->addHTML($this->makeOutput($xml, 'expand_templates_xml_output'));
         }
         $tmp = $this->makeOutput($output);
         if ($this->removeNowiki) {
             $tmp = preg_replace(array('_<nowiki>_', '_</nowiki>_', '_<nowiki */>_'), '', $tmp);
         }
         if ($wgUseTidy && $options->getTidy() || $wgAlwaysUseTidy) {
             $tmp = MWTidy::tidy($tmp);
         }
         $wgOut->addHTML($tmp);
         $this->showHtmlPreview($title, $output, $wgOut);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:53,代码来源:ExpandTemplates_body.php

示例2: WidgetWikiPage

function WidgetWikiPage($id, $params)
{
    global $wgTitle, $wgParser;
    wfProfileIn(__METHOD__);
    if (!is_object($wgTitle)) {
        $wgTitle = new Title();
    }
    // clean up inputs
    $params['source'] = trim($params['source']);
    $params['name'] = trim($params['name']);
    //stopgap for 67038
    $source = Title::newFromText($params['source']);
    if (is_object($source) && !$source->userCan('read')) {
        wfProfileOut(__METHOD__);
        return array('body' => '', 'title' => $params['name']);
    }
    //
    // parse message and clean it up
    //
    // fixes #2774
    if (isset($params['_widgetTag'])) {
        // work-around for WidgetTag
        $parser = new Parser();
    } else {
        $parser =& $wgParser;
    }
    $options = new ParserOptions();
    $options->setMaxIncludeSize(2048);
    if (empty($params['source'])) {
        // blank source pagename, use default message
        $ret = $parser->parse(wfMsg('widgetwikipage', $params['source']), $wgTitle, $options)->getText();
    } else {
        // has a source value
        // get contents
        $article = WidgetFramework::getArticle($params['source']);
        if ($article == false) {
            // failed to get text, show error message, failed pagename is in $1
            $ret = $parser->parse('<span class="widget-error-wikipage-missing">' . wfMsg('widgetwikipagemissing', $params['source']) . '</span>', $wgTitle, $options)->getText();
            // TODO: change title if page missing?
        } else {
            // got text, parse it!
            $ret = $parser->parse($article, $wgTitle, $options)->getText();
        }
    }
    wfProfileOut(__METHOD__);
    return array('body' => $ret, 'title' => $params['name']);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:47,代码来源:WidgetWikiPage.php

示例3: WidgetShoutBox

function WidgetShoutBox($id, $params)
{
    global $wgUser, $wgTitle, $wgRequest, $wgSitename, $wgLang, $wgEnableWidgetShoutbox;
    wfProfileIn(__METHOD__);
    // check if widget is enabled for this wiki and quit early if not
    if (isset($wgEnableWidgetShoutbox) && !$wgEnableWidgetShoutbox) {
        return wfMsg('widget-shoutbox-disabled');
    }
    // maybe user is trying to add a message to chat
    if ($wgRequest->getVal('message') && $wgRequest->getVal('rs') == 'WidgetFrameworkAjax') {
        $showChat = WidgetShoutBoxAddMessage($wgRequest->getVal('message'));
    } elseif ($wgRequest->getVal('msgid') && $wgRequest->getVal('rs') == 'WidgetFrameworkAjax') {
        //remove a message
        WidgetShoutBoxRemoveMessage($wgRequest->getVal('msgid'));
    }
    $ret = '';
    // should we show "chat" part of widget?
    $showChat = isset($showChat) || isset($_COOKIE[$id . '_showChat']) && intval($_COOKIE[$id . '_showChat']) == 1;
    $online = WidgetShoutBoxGetOnline();
    //WhosOnline is turned on
    if (is_array($online)) {
        // generate HTML for "who's online" part of widget
        $ret .= '<div id="' . $id . '_online"' . ($showChat ? ' style="display:none"' : '') . '>';
        $ret .= '<h5>' . wfMsg('monaco-whos-online') . ' (<a onclick="WidgetShoutboxTabToogle(\'' . $id . '\', 0)" style="cursor: pointer">chat! &raquo;</a>)</h5>' . '<p style="margin:8px 0">Guests: ' . $online['anons'] . ' <span style="margin-left: 10px">Users: ' . $online['users'] . '</span></p>';
        $list = array();
        foreach ($online['whosonline'] as $user) {
            $url = Title::newFromText($user['user'], NS_USER);
            $list[] = array('href' => $url->getLocalURL(), 'name' => $user['user']);
        }
        $more = Title::newFromText('WhosOnline', NS_SPECIAL);
        $ret .= WidgetFramework::wrapLinks($list) . WidgetFramework::moreLink($more->getLocalURL());
        unset($list, $more);
        $ret .= '</div>';
    } else {
        // fallback when WhosOnline is turned off
        $showChat = true;
    }
    // generate HTML for "chat" part of widget
    $ret .= '<div id="' . $id . '_chat" class="WidgetShoutBoxChat"' . (!$showChat ? ' style="display:none"' : '') . '>';
    #temp disable header. (remove hardcoded 'Chat' text + WhosOnline has been disabled forever, and not coming back?)
    #$ret .= '<h5>Chat' . ($online !== false ? ' (<a onclick="WidgetShoutboxTabToogle(\''.$id.'\', 1)" style="cursor: pointer">'.
    #	wfMsg('monaco-whos-online').'? &raquo;</a>)' : '') . '</h5>';
    $msgs = WidgetShoutBoxGetMessages();
    // date limiter - dates after that timestamp will be outputed in HH:mm (9:38) format, before in d M (8 Sep)
    $midnight = strtotime('today 00:00');
    // time offset (set by user in his preferences)
    $time_offset = $wgUser->getOption('timecorrection') ? (int) $wgUser->getOption('timecorrection') * 3600 : 0;
    $count = 0;
    // limit amount of messages
    $limit = intval($params['limit']);
    $limit = $limit <= 0 || $limit > 50 ? 15 : $limit;
    $msgs = array_slice($msgs, 0, $limit);
    // last message author
    $last_msg_author = '';
    $last_msg_time = 0;
    $ret .= '<ul>';
    $id = intval(substr($id, 7));
    if (count($msgs) == 0) {
        $ret .= '<li>&lt;' . htmlspecialchars($wgSitename) . '&gt; ' . wfMsg('wt_shoutbox_initial_message') . '</li>';
    } else {
        // create parser instance
        $options = new ParserOptions();
        $options->setMaxIncludeSize(100);
        // refs #1939
        $parser = new Parser();
        // display messages
        foreach (array_reverse($msgs) as $msg) {
            // trim message
            $msg['message'] = trim($msg['message']);
            // include offset in timestamp
            $msg['time'] += $time_offset;
            //add remove link for privlidged users
            $removeLink = '';
            if (!isset($params['_widgetTag']) && $wgUser->isAllowed('shoutboxremove')) {
                $removeLink = '<a href="#" onclick="WidgetShoutBoxRemoveMsg(' . $id . ', ' . $msg['id'] . '); return false;">x</a> ';
            }
            // time
            //adjust user's timezone
            $msg['time'] = intval($wgLang->sprintfDate('U', $wgLang->userAdjust(wfTimestamp(TS_MW, $msg['time']))));
            $ret .= '<li' . ($count++ % 2 ? ' class="msgOdd"' : '') . '>' . $removeLink . htmlspecialchars('[' . date($msg['time'] < $midnight ? 'j M' : 'G:i', $msg['time']) . ']') . '&nbsp;';
            // user page link
            $userPage = Title::newFromText($msg['user'], NS_USER);
            $userLink = '<a href="' . $userPage->getLocalURL() . '">' . htmlspecialchars($msg['user']) . '</a>';
            // interprete IRC-like command (e.g. /me is going away for a while)
            //
            // @see www.ircbeginner.com/ircinfo/ircc-commands.html
            //
            if (substr($msg['message'], 0, 1) == '/') {
                $cmd = substr($msg['message'], 1, strpos($msg['message'], ' ') - 1);
                $msg['message'] = substr($msg['message'], 2 + strlen($cmd));
            } else {
                $cmd = '';
            }
            // parse message
            $parsedMsg = $parser->parse($msg['message'], $wgTitle, $options)->getText();
            // remove unwanted HTML tags
            $parsedMsg = strip_tags($parsedMsg, '<i><b><a>');
            // remove wrapping <p></p> tags
            $parsedMsg = trim(str_replace(array('<p>', '</p>'), '', $parsedMsg));
            // interpret irc-like command
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:WidgetShoutBox.php


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