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


PHP OutputPage::wrapWikiMsg方法代码示例

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


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

示例1: showHtmlPreview

 /**
  * Wraps the provided html code in a div and outputs it to the page
  *
  * @param Title $title
  * @param string $html
  * @param OutputPage $out
  */
 private function showHtmlPreview(Title $title, $html, OutputPage $out)
 {
     $lang = $title->getPageViewLanguage();
     $out->addHTML("<h2>" . $this->msg('expand_templates_preview')->escaped() . "</h2>\n");
     global $wgRawHtml;
     if ($wgRawHtml) {
         $request = $this->getRequest();
         $user = $this->getUser();
         // To prevent cross-site scripting attacks, don't show the preview if raw HTML is
         // allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
         // does not currently provide logged-out users with CSRF protection; in that case,
         // do not show the preview unless anonymous editing is allowed.
         if ($user->isAnon() && !$user->isAllowed('edit')) {
             $error = array('expand_templates_preview_fail_html_anon');
         } elseif (!$user->matchEditToken($request->getVal('wpEditToken'), '', $request)) {
             $error = array('expand_templates_preview_fail_html');
         } else {
             $error = false;
         }
         if ($error) {
             $out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
             return;
         }
     }
     $out->addHTML(Html::openElement('div', array('class' => 'mw-content-' . $lang->getDir(), 'dir' => $lang->getDir(), 'lang' => $lang->getHtmlCode())));
     $out->addHTML($html);
     $out->addHTML(Html::closeElement('div'));
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:35,代码来源:SpecialExpandTemplates.php

示例2: showHtmlPreview

 /**
  * Render the supplied wiki text and append to the page as a preview
  *
  * @param Title $title
  * @param string $text
  * @param OutputPage $out
  */
 private function showHtmlPreview($title, $text, $out)
 {
     global $wgParser;
     $pout = $wgParser->parse($text, $title, new ParserOptions());
     $out->addHTML("<h2>" . wfMsgHtml('expand_templates_preview') . "</h2>\n");
     global $wgRawHtml, $wgRequest, $wgUser;
     if ($wgRawHtml) {
         // To prevent cross-site scripting attacks, don't show the preview if raw HTML is
         // allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
         // does not currently provide logged-out users with CSRF protection; in that case,
         // do not show the preview unless anonymous editing is allowed.
         if ($wgUser->isAnon() && !$wgUser->isAllowed('edit')) {
             $error = array('expand_templates_preview_fail_html_anon');
         } elseif (!$wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
             $error = array('expand_templates_preview_fail_html');
         } else {
             $error = false;
         }
         if ($error) {
             $out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
             return;
         }
     }
     $out->addHTML($pout->getText());
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:ExpandTemplates_body.php


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