當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。