當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ShortcodeParser::set_active方法代碼示例

本文整理匯總了PHP中ShortcodeParser::set_active方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShortcodeParser::set_active方法的具體用法?PHP ShortcodeParser::set_active怎麽用?PHP ShortcodeParser::set_active使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ShortcodeParser的用法示例。


在下文中一共展示了ShortcodeParser::set_active方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testShortCodeParsedInTemplateHelpers

 public function testShortCodeParsedInTemplateHelpers()
 {
     $parser = ShortcodeParser::get('HTMLTextTest');
     $parser->register('shortcode', function ($arguments, $content, $parser, $tagName, $extra) {
         return 'Replaced short code with this. <a href="home">home</a>';
     });
     ShortcodeParser::set_active('HTMLTextTest');
     /** @var HTMLText $field */
     $field = DBField::create_field('HTMLText', '<p>[shortcode]</p>');
     $this->assertEquals('&lt;p&gt;Replaced short code with this. &lt;a href=&quot;home&quot;&gt;home&lt;/a&gt;&lt;/p&gt;', $field->HTMLATT());
     $this->assertEquals('%3Cp%3EReplaced+short+code+with+this.+%3Ca+href%3D%22home%22%3Ehome%3C%2Fa%3E%3C%2Fp%3E', $field->URLATT());
     $this->assertEquals('%3Cp%3EReplaced%20short%20code%20with%20this.%20%3Ca%20href%3D%22home%22%3Ehome%3C%2Fa%3E%3C%2Fp%3E', $field->RAWURLATT());
     $this->assertEquals('&lt;p&gt;Replaced short code with this. &lt;a href=&quot;home&quot;&gt;home&lt;/a&gt;&lt;/p&gt;', $field->ATT());
     $this->assertEquals('<p>Replaced short code with this. <a href="home">home</a></p>', $field->RAW());
     $this->assertEquals('\\x3cp\\x3eReplaced short code with this. \\x3ca href=\\"home\\"\\x3ehome\\x3c/a\\x3e\\x3c/p\\x3e', $field->JS());
     $this->assertEquals('&lt;p&gt;Replaced short code with this. &lt;a href=&quot;home&quot;&gt;home&lt;/a&gt;&lt;/p&gt;', $field->HTML());
     $this->assertEquals('&lt;p&gt;Replaced short code with this. &lt;a href=&quot;home&quot;&gt;home&lt;/a&gt;&lt;/p&gt;', $field->XML());
     $this->assertEquals('Repl...', $field->LimitCharacters(4, '...'));
     $this->assertEquals('Replaced...', $field->LimitCharactersToClosestWord(10, '...'));
     $this->assertEquals('Replaced...', $field->LimitWordCount(1, '...'));
     $this->assertEquals('<p>replaced short code with this. <a href="home">home</a></p>', $field->LowerCase());
     $this->assertEquals('<P>REPLACED SHORT CODE WITH THIS. <A HREF="HOME">HOME</A></P>', $field->UpperCase());
     $this->assertEquals('Replaced short code with this. home', $field->NoHTML());
     Config::nest();
     Config::inst()->update('Director', 'alternate_base_url', 'http://example.com/');
     $this->assertEquals('<p>Replaced short code with this. <a href="http://example.com/home">home</a></p>', $field->AbsoluteLinks());
     Config::unnest();
     $this->assertEquals('Replaced short code with this.', $field->LimitSentences(1));
     $this->assertEquals('Replaced short code with this.', $field->FirstSentence());
     $this->assertEquals('Replaced short...', $field->Summary(2));
     $this->assertEquals('Replaced short code with...', $field->BigSummary(4));
     $this->assertEquals('Replaced short code with this. home[home]', $field->FirstParagraph());
     $this->assertEquals('Replaced <span class="highlight">short</span> <span class="highlight">code</span> with this. home', $field->ContextSummary(500, 'short code'));
     ShortcodeParser::set_active('default');
 }
開發者ID:aaronleslie,項目名稱:aaronunix,代碼行數:35,代碼來源:HTMLTextTest.php


注:本文中的ShortcodeParser::set_active方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。