本文整理汇总了PHP中ShortcodeParser::get_active方法的典型用法代码示例。如果您正苦于以下问题:PHP ShortcodeParser::get_active方法的具体用法?PHP ShortcodeParser::get_active怎么用?PHP ShortcodeParser::get_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShortcodeParser
的用法示例。
在下文中一共展示了ShortcodeParser::get_active方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forTemplate
public function forTemplate()
{
if ($this->processShortcodes) {
return ShortcodeParser::get_active()->parse($this->value);
} else {
return $this->value;
}
}
示例2: parse
public function parse()
{
$parsedown = new RestrictedMarkdownParser();
$html = $parsedown->parse(ShortcodeParser::get_active()->parse($this->content));
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$html = $purifier->purify($html);
return $html;
}
示例3: preview
function preview(SS_HTTPRequest $request)
{
$strValue = $request->requestVar('markdown');
if ($strValue) {
$shortCodeParser = ShortcodeParser::get_active();
$strValue = $shortCodeParser->parse($strValue);
$parseDown = new Parsedown();
$strValue = $parseDown->text($strValue);
}
return $strValue;
}
示例4: ParseMarkdown
/**
* @return string
* parse contents of the markdown field to tempates
*/
function ParseMarkdown($bCache = true, $strValue = '')
{
if ($bCache && $this->parsedContent) {
return $this->parsedContent;
}
$shortCodeParser = ShortcodeParser::get_active();
$strParsed = $shortCodeParser->parse(!empty($strValue) ? $strValue : $this->value);
$parseDown = new Parsedown();
$strParsed = $parseDown->text($strParsed);
if ($bCache) {
$this->parsedContent = $strParsed;
}
return $strParsed;
}
示例5: ParseMarkDown
function ParseMarkDown()
{
$parser = new Parsedown();
$value = $this->value;
$this->extend('onBeforeParseMarkDown', $value);
$value = $parser->text($value);
set_error_handler(array($this, 'onError'));
try {
$value = ShortcodeParser::get_active()->parse($value);
} catch (Exception $e) {
}
restore_error_handler();
$this->extend('onAfterParseMarkDown', $value);
return $value;
}
示例6: forTemplate
public function forTemplate()
{
return ShortcodeParser::get_active()->parse($this->value);
}
示例7: tearDown
public function tearDown()
{
ShortcodeParser::get_active()->unregister('test_shortcode');
parent::tearDown();
}
示例8: getLocalizedValue
/**
* Get the localized value for a given field.
* @param string $fieldName the name of the field without any locale extension. Eg. "Title"
* @param boolean $strict if false, this will fallback to the master version of the field!
* @param boolean $parseShortCodes whether or not the value should be parsed with the shortcode parser
* @return string|DBField
*/
public function getLocalizedValue($fieldName, $strict = true, $parseShortCodes = false)
{
$localizedField = $this->getLocalizedFieldName($fieldName);
// ensure that $strict is a boolean value
$strict = filter_var($strict, FILTER_VALIDATE_BOOLEAN);
/** @var DBField $value */
$value = $this->owner->dbObject($localizedField);
if (!$strict && !$value->exists()) {
$value = $this->owner->dbObject($fieldName);
}
return $parseShortCodes && $value ? ShortcodeParser::get_active()->parse($value->getValue()) : $value;
}
示例9: define
<?php
define('PACKAGISTSHORTCODE_BASE', basename(dirname(__FILE__)));
//Enable the parser
ShortcodeParser::get_active()->register('packagist', array('PackagistShortCode', 'parse'));
示例10: ShortcodeOutput
public function ShortcodeOutput()
{
if ($this->linkmode == 'Shortcode' && ($sc = $this->getShortcode())) {
return ShortcodeParser::get_active()->parse($sc);
}
return null;
}
示例11: getLocalizedValue
/**
* Get the localized value for a given field.
* @param string $fieldName the name of the field without any locale extension. Eg. "Title"
* @param boolean $strict if false, this will fallback to the master version of the field!
* @param boolean $parseShortCodes whether or not the value should be parsed with the shortcode parser
*/
public function getLocalizedValue($fieldName, $strict = true, $parseShortCodes = false)
{
$localizedField = $this->getLocalizedFieldName($fieldName);
$value = $this->owner->dbObject($localizedField);
if (!$strict && $value == '') {
$value = $this->owner->dbObject($fieldName);
}
return $parseShortCodes && $value ? ShortcodeParser::get_active()->parse($value->getValue()) : $value;
}
示例12: forTemplate
function forTemplate()
{
$parser = new Parsedown();
$value = ShortcodeParser::get_active()->parse($this->value);
return $parser->text($value);
}
示例13: define
<?php
define('CB_BUILD_DATE', '@@BUILD_DATE@@');
define('CB_VERSION', '@@VERSION@@');
define('CB_DIR', basename(dirname(__FILE__)));
//Add the include path for the thirdparty folder (fixes zend api's)
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/thirdparty/');
//CMS Menu
CMSMenu::remove_menu_item('CodeBankAddSnippet');
CMSMenu::remove_menu_item('CodeBankEditSnippet');
CMSMenu::remove_menu_item('CodeBankSettings');
CMSMenu::remove_menu_item('CodeBankIPAgreement');
//Inject Menu Styles
LeftAndMain::require_css(CB_DIR . '/css/CodeBankMenu.css');
//Register Short Code
ShortcodeParser::get_active()->register('snippet', array('CodeBankShortCode', 'parse'));
示例14: results
/**
* Overrides the ContentControllerSearchExtension and adds snippets to results.
*
* @param array $data
* @param SearchForm $form
* @param SS_HTTPRequest $request
* @return HTMLText
*/
function results($data, $form, $request)
{
$result = null;
$results = $form->getResults();
$query = $form->getSearchQuery();
// Add context summaries based on the queries.
foreach ($results as $result) {
$contextualTitle = new Text();
$contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
$result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);
if (!$result->Content && $result->ClassName == 'File') {
// Fake some content for the files.
$result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size}).";
} else {
// /(.?)\[embed(.*?)\](.+?)\[\/\s*embed\s*\](.?)/gi
$valueField = $result->obj('Content');
$valueField->setValue(ShortcodeParser::get_active()->parse($valueField->getValue()));
$result->ContextualContent = $valueField->ContextSummary(300, $query);
}
}
$rssLink = HTTP::setGetVar('rss', '1');
// Render the result.
$context = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink);
// Choose the delivery method - rss or html.
if (!$this->owner->request->getVar('rss')) {
// Add RSS feed to normal search.
RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\".");
$result = $this->owner->customise($context)->renderWith(array('Page_results', 'Page'));
} else {
// De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
$fullList = $results->getList()->sort('LastEdited', 'DESC');
// Get some descriptive strings
$siteName = SiteConfig::current_site_config()->Title;
$siteTagline = SiteConfig::current_site_config()->Tagline;
if ($siteName) {
$title = "{$siteName} search results for query \"{$query}\".";
} else {
$title = "Search results for query \"{$query}\".";
}
// Generate the feed content.
$rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
$rss->setTemplate('Page_results_rss');
$result = $rss->outputToBrowser();
}
return $result;
}
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-extensions,代码行数:54,代码来源:SSGuru_ContentController.php
示例15: link_url
static function link_url($value)
{
return ShortcodeParser::get_active()->parse($value);
}