当前位置: 首页>>代码示例>>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;未经允许,请勿转载。