本文整理汇总了PHP中ShortcodeParser::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ShortcodeParser::get方法的具体用法?PHP ShortcodeParser::get怎么用?PHP ShortcodeParser::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShortcodeParser
的用法示例。
在下文中一共展示了ShortcodeParser::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register_class
public static function register_class($class)
{
if (class_exists($class)) {
if (!singleton($class)->hasMethod('parse_shortcode')) {
user_error("Failed to register \"{$class}\" with shortcodable. {$class} must have the method parse_shortcode(). See /shortcodable/README.md", E_USER_ERROR);
}
ShortcodeParser::get('default')->register($class, array(singleton($class), 'parse_shortcode'));
singleton('ShortcodableParser')->register($class);
}
}
示例2: testShortcodeOperation
public function testShortcodeOperation()
{
$file = 'dms/tests/DMS-test-lorum-file.pdf';
$document = DMS::inst()->storeDocument($file);
$result = ShortcodeParser::get('default')->parse(sprintf('<p><a href="[dms_document_link id=\'%d\']">Document</a></p>', $document->ID));
$value = Injector::inst()->create('HTMLValue', $result);
$link = $value->query('//a')->item(0);
$this->assertStringEndsWith("/dmsdocument/{$document->ID}", $link->getAttribute('href'));
$this->assertEquals($document->getExtension(), $link->getAttribute('data-ext'));
$this->assertEquals($document->getFileSizeFormatted(), $link->getAttribute('data-size'));
}
示例3: setUp
public function setUp()
{
parent::setUp();
Config::inst()->update('Director', 'alternate_base_url', '/');
if (!self::$original_host) {
self::$original_host = $_SERVER['HTTP_HOST'];
}
$_SERVER['HTTP_HOST'] = 'www.example.org';
ShortcodeParser::get('default')->register('test_shortcode', function () {
return 'test shortcode output';
});
}
示例4: array
<?php
ShortcodeParser::get('default')->register('rdfa', array('RDFaExtension', 'RDFaShortcode'));
示例5: define
<?php
if (!defined('RESPONSIVE_WYSIWYG_IMAGES_DIR')) {
define('RESPONSIVE_WYSIWYG_IMAGES_DIR', rtrim(basename(dirname(__FILE__))));
}
HtmlEditorConfig::get('cms')->enablePlugins(array('responsive_wysiwyg_images' => sprintf('../../../%s/javascript/editor_plugin.js', RESPONSIVE_WYSIWYG_IMAGES_DIR)));
ShortcodeParser::get('default')->register('responsiveimage', array('ResponisveWYSIWYGImages', 'shortcode_handler'));
示例6: define
<?php
/**
* - CMS_DIR: Path relative to webroot, e.g. "cms"
* - CMS_PATH: Absolute filepath, e.g. "/var/www/my-webroot/cms"
*/
define('CMS_DIR', 'cms');
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
/**
* Register the default internal shortcodes.
*/
ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'link_shortcode_handler'));
File::add_extension('SiteTreeFileExtension');
// TODO Remove once we can configure CMSMenu through static, nested configuration files
CMSMenu::remove_menu_item('CMSMain');
CMSMenu::remove_menu_item('CMSPageEditController');
CMSMenu::remove_menu_item('CMSPageSettingsController');
CMSMenu::remove_menu_item('CMSPageHistoryController');
CMSMenu::remove_menu_item('CMSPageReportsController');
CMSMenu::remove_menu_item('CMSPageAddController');
CMSMenu::remove_menu_item("SiteConfigLeftAndMain");
示例7: define
<?php
define('SUBSITES_DOMAINS_DIR', ltrim(Director::makeRelative(realpath(__DIR__)), DIRECTORY_SEPARATOR));
Object::add_extension('HtmlEditorField_Toolbar', 'HtmlEditorField_ToolbarExtension');
ShortcodeParser::get('default')->register('subsite_link', array('HtmlEditorField_ToolbarExtension', 'link_shortcode_handler'));
示例8: basename
* @platform CMS SilverStripe 3
* @package cwsoft-shortcode
* @version 2.2.4
* @author cwsoft (http://cwsoft.de)
* @copyright cwsoft
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// ensure module is stored in folder "cwsoft-shortcode"
$moduleName = 'cwsoft-shortcode';
$folderName = basename(dirname(__FILE__));
if ($folderName != $moduleName) {
user_error(_t('_config.WRONG_MODULE_FOLDER', 'Please rename the folder "{folderName}" into "{moduleName}" to get the {moduleName} module working properly.', array('moduleName' => $moduleName, 'folderName' => $folderName)), E_USER_ERROR);
}
// include external files into head section
Requirements::set_write_js_to_body(false);
// register short code tags accessible from pages of type cwsCodePage
ShortcodeParser::get()->register('cwsHideMailto', array('cwsShortCodeHideMailto', 'cwsShortCodeHideMailtoHandler'));
ShortcodeParser::get()->register('cwsRandomImage', array('cwsShortCodeRandomImage', 'cwsShortCodeRandomImageHandler'));
ShortcodeParser::get()->register('cwsRandomQuote', array('cwsShortCodeRandomQuote', 'cwsShortCodeRandomQuoteHandler'));
// increase quality of created thumbnails
if (class_exists('GDBackend')) {
// SilverStripe >= 3.1.0
GDBackend::set_default_quality(95);
} else {
// SilverStripe 3.0.x
GD::set_default_quality(95);
}
// Note: If you see unparsed placeholders like "{#shortcode.dlg_description}" when using the TinyMCE cwsoft-shortcode plugin,
// you need to add a plugin language file for your locale to the folder "./plugins/shortcode/langs". Supported locales: EN, DE.
HtmlEditorConfig::get('cms')->enablePlugins(array('shortcode' => '../../../cwsoft-shortcode/plugins/shortcode/editor_plugin_src.js'));
HtmlEditorConfig::get('cms')->addButtonsToLine(1, 'shortcode');
示例9: basename
<?php
$dir = basename(dirname(__FILE__));
if ($dir === 'shortcodes') {
define('SHORTCODES_DIR', $dir);
} else {
user_error('ShortCodes: Directory name must be "shortcodes" (currently "' . $dir . '")', E_USER_ERROR);
}
ShortcodeParser::get()->register('youtube', array('ShortCodes', 'YouTubeShortCodeHandler'));
ShortcodeParser::get()->register('vimeo', array('ShortCodes', 'VimeoShortCodeHandler'));
HtmlEditorConfig::get('cms')->enablePlugins(array('youtube' => '../../../shortcodes/javascript/youtube.min.js', 'vimeo' => '../../../shortcodes/javascript/vimeo.min.js'));
HtmlEditorConfig::get('cms')->insertButtonsAfter('anchor', 'youtube', 'vimeo');
示例10: define
<?php
define('DMS_DIR', 'dms');
Object::add_extension('SiteTree', 'DMSSiteTreeExtension');
Object::add_extension('HtmlEditorField_Toolbar', 'DocumentHtmlEditorFieldToolbar');
CMSMenu::remove_menu_item('DMSDocumentAddController');
ShortcodeParser::get('default')->register('dms_document_link', array('DMSDocument_Controller', 'dms_link_shortcode_handler'));
if (!file_exists(BASE_PATH . DIRECTORY_SEPARATOR . DMS_DIR)) {
user_error("DMS directory named incorrectly. Please install the DMS module into a folder named: " . DMS_DIR);
}
示例11: define
<?php
define('LINKABLE_DATAOBJECTS_DIR', basename(dirname(__FILE__)));
$linkables = ClassInfo::implementorsOf('Linkable');
foreach ($linkables as $class) {
//die(strtolower($class).'_link');
ShortcodeParser::get('default')->register(strtolower($class) . '_link', array($class, 'link_shortcode_handler'));
}
示例12: array
<?php
/**
* Adds a short-code for [code]. This allows styled code to be included in any SiteTree
* content area by wrapping the content in the [code] tag. An optional 'lang' parameter
* can be used to define a valid GeSHi language set, or a 'ref' parameter can point to
* an exisiting Snippet saved in the system.
*
* <example>
* [code lang='php']
* $example = "Hello, World!";
* echo $example;
* [/code]
*
* [code ref='as12n' /]
*
**/
ShortcodeParser::get('default')->register('code', array('PastieSnippet', 'shortcode_handler'));
示例13: tearDown
public function tearDown()
{
ShortcodeParser::get('test')->unregister('test_shortcode');
parent::tearDown();
}
示例14: array
<?php
// Adding embedcontent button to HtmlEditorConfig
//Need noneditable plugin
HtmlEditorConfig::get('cms')->enablePlugins('noneditable');
HtmlEditorConfig::get('cms')->enablePlugins(array('embedcontent' => 'embedcontent/javascript/editor_plugin.js'));
HtmlEditorConfig::get('cms')->addButtonsToLine(1, 'embedcontent');
ShortcodeParser::get('default')->register('EmbedContent', array('EmbedContentController', 'get_embed_content'));
示例15: getParser
/**
* Calls the parser, should only need it instantiated once.
*
* @return null|ShortcodeParser
*/
protected function getParser()
{
if (!$this->parser) {
$parser = ShortcodeParser::get('LightboxTracking');
$parser->register('lightbox', array($this, 'parse_callback'));
$this->parser = $parser;
}
return $this->parser;
}
开发者ID:silverstripe-terraformers,项目名称:silverstripe-lightbox,代码行数:14,代码来源:DataObjectLightboxExtension.php