本文整理汇总了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('<p>Replaced short code with this. <a href="home">home</a></p>', $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('<p>Replaced short code with this. <a href="home">home</a></p>', $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('<p>Replaced short code with this. <a href="home">home</a></p>', $field->HTML());
$this->assertEquals('<p>Replaced short code with this. <a href="home">home</a></p>', $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');
}