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


PHP Call::convertTableToTemplateCalls方法代码示例

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


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

示例1: execute


//.........这里部分代码省略.........
         // this is the case if [[Call,a=b]] syntax is used
         $wikitext = str_replace(",", "|", $par);
         $wikitext = str_replace("_", " ", $wikitext);
     }
     // check if the result shall be saved as a wiki article
     $saveAsPageLink = '';
     $saveAsPage = '';
     $saveAsTitle = null;
     $wikitextS = preg_replace('/^.*\\|\\s*saveAsPage\\s*=\\s*/s', '', $wikitext);
     if ($wikitextS != $wikitext) {
         $saveAsPageLink = preg_replace('/\\s*\\|.*/s', '', $wikitextS);
         $saveAsTitle = Title::newFromText($saveAsPageLink);
         $saveAsPage = $saveAsTitle->getText();
         if ($saveAsTitle->getNamespace() == 14) {
             $saveAsPageLink = ':' . $saveAsPageLink;
         }
     }
     // check if we want to execute a built-in command
     $cmd = preg_replace('/^.*\\|\\s*cmd\\s*=\\s*/s', '', $wikitext);
     if ($cmd == $wikitext) {
         $cmd = '';
     } else {
         $cmd = preg_replace('/\\s*\\|.*/s', '', $cmd);
     }
     // in both cases we need the raw text of the called page
     $rawText = '';
     if ($cmd != '' || $saveAsPage != '') {
         $template = preg_replace('/\\|.*/', '', $wikitext);
         if (strpos(':', $template) === false) {
             $template = 'Template:' . $template;
         } elseif ($template[0] == ':') {
             $template = substr($template, 1);
         }
         $title = Title::newFromText($template);
         if ($title != null && !$title->exists()) {
             $rawText = "'{$template}' not found.";
         } else {
             $article = new Article($title);
             $rawText = $article->getContent();
         }
     }
     if ($wikitext == '' || $wikitext == 'Special:Call') {
         // Called without parameters: dump explanation
         $wgOut->addHTML(wfMsg('call-text'));
     } elseif ($debug) {
         // Called with DebuG target: dump parameter list
         $wgOut->addHTML("<pre>\n{{" . $wikitext . "}}\n</pre>");
         if ($saveAsPage != '') {
             $wgOut->addHTML(wfMsg('call-save', $saveAsPageLink));
         }
     } else {
         $parm = array();
         foreach (split('\\|', $wikitext) as $parmArg) {
             $pp = split('=', $parmArg, 2);
             if (count($pp) == 2) {
                 $parm[$pp[0]] = $pp[1];
             } else {
                 $parm[$pp[0]] = '';
             }
         }
         if ($cmd == 'convertTableToTemplateCalls') {
             // execute command
             $rawText = Call::convertTableToTemplateCalls($rawText, $parm);
         }
         if ($saveAsPage != '') {
             // replace literals in text
             foreach ($parm as $arg => $value) {
                 $rawText = str_replace($arg, $value, $rawText);
             }
             // do not save if article is already present
             if (!$saveAsTitle->exists()) {
                 $article = new Article($saveAsTitle);
                 $article->doEdit($rawText, $saveAsPage, EDIT_NEW | EDIT_FORCE_BOT);
                 $wgOut->addHTML($wgOut->parse(wfMsg('call-save-success', $saveAsPageLink)));
             } else {
                 $wgOut->addHTML($wgOut->parse(wfMsg('call-save-failed', $saveAsPageLink)));
             }
             // output the text we produced as a note to the user
             if ($link1 != '') {
                 $wgOut->addHTML($wgOut->parse("[[Special:Call/{$link1}|{$label1}]]"));
             }
             $link2 = str_replace(',', '&', $link2);
             if ($link2 != '') {
                 $wgOut->addHTML($wgOut->parse("[{$link2} {$label2}]"));
             }
             $wgOut->addHTML("<pre>\n{$rawText}\n</pre>");
         } else {
             // call the template and produce output
             $wgOut->addHTML($wgOut->parse("{{" . $wikitext . "}}"));
         }
     }
     $skin = $wgUser->getSkin();
     $wgRawHtml = $oldRawHtml;
     $newTitle = split("\\,", $par, 2);
     if ($newTitle != null && strlen($newTitle[0]) > 0) {
         $newTitle[0] = str_replace("_", " ", $newTitle[0]);
         $newTitle[0] = preg_replace("/^:/", "", $newTitle[0]);
         $wgOut->setPageTitle($newTitle[0]);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:Call_body.php


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