本文整理汇总了PHP中HtmlEditorConfig::get方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlEditorConfig::get方法的具体用法?PHP HtmlEditorConfig::get怎么用?PHP HtmlEditorConfig::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlEditorConfig
的用法示例。
在下文中一共展示了HtmlEditorConfig::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
// $Lang serves as a "context" which can be inspected by Translatable - hence it
// has the same name as the database property on Translatable.
if ($this->getRequest()->requestVar("Locale")) {
$this->Locale = $this->getRequest()->requestVar("Locale");
} elseif ($this->getRequest()->requestVar("locale")) {
$this->Locale = $this->getRequest()->requestVar("locale");
} else {
$this->Locale = Translatable::default_locale();
}
Translatable::set_current_locale($this->Locale);
// collect languages for TinyMCE spellchecker plugin.
// see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
$langName = i18n::get_locale_name($this->Locale);
HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->Locale}");
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.Tree.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.EditForm.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.Translatable.js');
Requirements::css(CMS_DIR . '/css/CMSMain.css');
CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
}
示例2: init
public function init()
{
// In LeftAndMain::init() the current theme is unset.
// we need to restore the current theme here for make the dropdown of template list.
$theme = SSViewer::current_theme();
parent::init();
if (isset($theme) && $theme) {
SSViewer::set_theme($theme);
}
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/tiny_mce_improvements.js');
//TODO what is going on here? where did that hover.js go? can't find it.
//TODO We need to reimplement a hover.js?
Requirements::javascript(CMS_DIR . '/javascript/hover.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/controls.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_left.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_right.js');
Requirements::javascript(CMS_DIR . '/javascript/CMSMain_left.js');
Requirements::javascript(CMS_DIR . '/javascript/SecurityAdmin.js');
Requirements::javascript(NEWSLETTER_DIR . '/javascript/NewsletterAdmin_left.js');
Requirements::javascript(NEWSLETTER_DIR . '/javascript/NewsletterAdmin_right.js');
Requirements::javascript(NEWSLETTER_DIR . '/javascript/ProgressBar.js');
// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
if (!Director::is_ajax()) {
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
HtmlEditorConfig::get('cms')->setOption('ContentCSS', project() . '/css/editor.css');
HtmlEditorConfig::get('cms')->setOption('Lang', i18n::get_tinymce_lang());
}
// Always block the HtmlEditorField.js otherwise it will be sent with an ajax request
Requirements::block(SAPPHIRE_DIR . '/javascript/HtmlEditorField.js');
Requirements::css(NEWSLETTER_DIR . '/css/NewsletterAdmin.css');
}
示例3: init
function init()
{
HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats', 'p,h1');
HtmlEditorConfig::get('cms')->setButtonsForLine(1, 'undo, redo, separator, cut, copy, pastetext, separator, ssimage, sslink, unlink, separator, fullscreen, advcode, formatselect');
HtmlEditorConfig::get('cms')->setButtonsForLine(2);
HtmlEditorConfig::get('cms')->setButtonsForLine(3);
}
示例4: init
function init()
{
$req = $this->owner->getRequest();
// Ignore being called on LeftAndMain base class,
// which is the case when requests are first routed through AdminRootController
// as an intermediary rather than the endpoint controller
if (!$this->owner->stat('tree_class')) {
return;
}
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
// $Lang serves as a "context" which can be inspected by Translatable - hence it
// has the same name as the database property on Translatable.
$id = $req->param('ID');
if ($req->requestVar("Locale")) {
$this->owner->Locale = $req->requestVar("Locale");
} else {
if ($id && is_numeric($id)) {
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
if ($record && $record->Locale) {
$this->owner->Locale = $record->Locale;
}
} else {
$this->owner->Locale = Translatable::default_locale();
if ($this->owner->class == 'CMSPagesController') {
// the CMSPagesController always needs to have the locale set,
// otherwise page editing will cause an extra
// ajax request which looks weird due to multiple "loading"-flashes
$getVars = $req->getVars();
if (isset($getVars['url'])) {
unset($getVars['url']);
}
return $this->owner->redirect(Controller::join_links($this->owner->Link(), $req->param('Action'), $req->param('ID'), $req->param('OtherID'), ($query = http_build_query($getVars)) ? "?{$query}" : null));
}
}
}
Translatable::set_current_locale($this->owner->Locale);
// If a locale is set, it needs to match to the current record
$requestLocale = $req->requestVar("Locale");
$page = $this->owner->currentPage();
if ($req->httpMethod() == 'GET' && $requestLocale && $page && $page->hasExtension('Translatable') && $page->Locale != $requestLocale && $req->latestParam('Action') != 'EditorToolbar') {
$transPage = $page->getTranslation($requestLocale);
if ($transPage) {
Translatable::set_current_locale($transPage->Locale);
return $this->owner->redirect(Controller::join_links($this->owner->Link('show'), $transPage->ID));
} else {
if ($this->owner->class != 'CMSPagesController') {
// If the record is not translated, redirect to pages overview
return $this->owner->redirect(Controller::join_links(singleton('CMSPagesController')->Link(), '?Locale=' . $requestLocale));
}
}
}
// collect languages for TinyMCE spellchecker plugin.
// see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
$langName = i18n::get_locale_name($this->owner->Locale);
HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->owner->Locale}");
Requirements::javascript('translatable/javascript/CMSMain.Translatable.js');
Requirements::css('translatable/css/CMSMain.Translatable.css');
}
示例5: __construct
public function __construct()
{
parent::__construct();
// This may get called before the schema is created.
if (!DB::getConn()->isSchemaUpdating()) {
HtmlEditorConfig::get('cms')->setOption('viewtemplate', ViewTemplate::get()->map('Title')->toArray());
}
}
示例6: getEditorConfig
/**
* Returns the {@see HtmlEditorConfig} instance to use for sanitisation
*
* @return HtmlEditorConfig
*/
protected function getEditorConfig()
{
$editorConfig = $this->config()->editor_config;
if ($editorConfig) {
return HtmlEditorConfig::get($editorConfig);
}
return HtmlEditorConfig::get_active();
}
示例7: include_js
public static function include_js($configName)
{
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
$config = HtmlEditorConfig::get($configName);
$config->setOption('mode', 'none');
$config->setOption('editor_selector', "htmleditor{$configName}");
Requirements::customScript("\n\t\tBehaviour.register({\n\t\t'textarea.htmleditor{$configName}' : {\n\t\tinitialize : function() {\n\t\tif(typeof tinyMCE != 'undefined'){\n\t\tvar oldsettings = tinyMCE.settings;\n\t\t" . $config->generateJS() . "\n\t\ttinyMCE.execCommand('mceAddControl', true, this.id);\n\t\ttinyMCE.settings = oldsettings;\n\t\tthis.isChanged = function() {\n\t\treturn tinyMCE.getInstanceById(this.id).isDirty();\n\t\t}\n\t\tthis.resetChanged = function() {\n\t\tinst = tinyMCE.getInstanceById(this.id);\n\t\tif (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));\n\t\t}\n\t\t}\n\t\t}\n\t\t}\n\t\t})\n\t\t", "htmlEditorConfig-{$configName}");
}
示例8: testRequireJSIncludesAllConfigs
public function testRequireJSIncludesAllConfigs()
{
$c = HtmlEditorConfig::get('configA');
$c = HtmlEditorConfig::get('configB');
HtmlEditorConfig::require_js();
$js = Requirements::get_custom_scripts();
$this->assertContains('"configA":{', $js);
$this->assertContains('"configB":{', $js);
}
示例9: testRequireJSIncludesAllConfigs
public function testRequireJSIncludesAllConfigs()
{
$a = HtmlEditorConfig::get('configA');
$c = HtmlEditorConfig::get('configB');
$aAttributes = $a->getAttributes();
$cAttributes = $c->getAttributes();
$this->assertNotEmpty($aAttributes['data-config']);
$this->assertNotEmpty($cAttributes['data-config']);
}
示例10: init
public function init()
{
parent::init();
Requirements::css(CMS_DIR . '/css/ReportAdmin.css');
// Set custom options for TinyMCE specific to ReportAdmin
HtmlEditorConfig::get('cms')->setOption('ContentCSS', project() . '/css/editor.css');
HtmlEditorConfig::get('cms')->setOption('Lang', i18n::get_tinymce_lang());
// Always block the HtmlEditorField.js otherwise it will be sent with an ajax request
Requirements::block(SAPPHIRE_DIR . '/javascript/HtmlEditorField.js');
}
示例11: alternateAccessCheck
function alternateAccessCheck()
{
// html display simplification
$lines = array('pastetext', 'ssmedia', 'separator', 'bold', 'italic', 'underline', 'strikethrough', 'hr', 'separator', 'styleselect', 'formatselect', 'separator', 'bullist', 'numlist', 'blockquote', 'sslink', 'unlink', 'anchor', 'separator', 'code');
$config = HtmlEditorConfig::get('cms');
$config->setButtonsForLine(1, $lines);
$config->setButtonsForLine(2, null);
$config->setButtonsForLine(3, null);
HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats', 'p,h1,h2,h3,h4');
}
示例12: testSanitisation
public function testSanitisation()
{
$tests = array(array('p,strong', '<p>Leave Alone</p><div>Strip parent<strong>But keep children</strong> in order</div>', '<p>Leave Alone</p>Strip parent<strong>But keep children</strong> in order', 'Non-whitelisted elements are stripped, but children are kept'), array('p,strong', '<div>A <strong>B <div>Nested elements are still filtered</div> C</strong> D</div>', 'A <strong>B Nested elements are still filtered C</strong> D', 'Non-whitelisted elements are stripped even when children of non-whitelisted elements'), array('p', '<p>Keep</p><script>Strip <strong>including children</strong></script>', '<p>Keep</p>', 'Non-whitelisted script elements are totally stripped, including any children'), array('p[id]', '<p id="keep" bad="strip">Test</p>', '<p id="keep">Test</p>', 'Non-whitelisted attributes are stripped'), array('p[default1=default1|default2=default2|force1:force1|force2:force2]', '<p default1="specific1" force1="specific1">Test</p>', '<p default1="specific1" force1="force1" default2="default2" force2="force2">Test</p>', 'Default attributes are set when not present in input, forced attributes are always set'));
$config = HtmlEditorConfig::get('htmleditorsanitisertest');
foreach ($tests as $test) {
list($validElements, $input, $output, $desc) = $test;
$config->setOptions(array('valid_elements' => $validElements));
$sanitiser = new HtmlEditorSanitiser($config);
$htmlValue = Injector::inst()->create('HTMLValue', $input);
$sanitiser->sanitise($htmlValue);
$this->assertEquals($output, $htmlValue->getContent(), $desc);
}
}
示例13: init
public function init()
{
parent::init();
//set the report we are currently viewing from the URL
$this->reportClass = isset($this->urlParams['ReportClass']) && $this->urlParams['ReportClass'] !== 'index' ? $this->urlParams['ReportClass'] : null;
$allReports = SS_Report::get_reports();
$this->reportObject = isset($allReports[$this->reportClass]) ? $allReports[$this->reportClass] : null;
// Set custom options for TinyMCE specific to ReportAdmin
HtmlEditorConfig::get('cms')->setOption('content_css', project() . '/css/editor.css');
HtmlEditorConfig::get('cms')->setOption('Lang', i18n::get_tinymce_lang());
// Always block the HtmlEditorField.js otherwise it will be sent with an ajax request
Requirements::block(FRAMEWORK_DIR . '/javascript/HtmlEditorField.js');
Requirements::javascript(REPORTS_DIR . '/javascript/ReportAdmin.js');
}
示例14: preRequest
public function preRequest(\SS_HTTPRequest $request, \Session $session, \DataModel $model)
{
// Check languages to set
$languages = array();
foreach (SpellController::get_locales() as $locale) {
$languages[] = i18n::get_locale_name($locale) . '=' . $locale;
}
// Set settings
$editor = Config::inst()->get(__CLASS__, 'editor');
HtmlEditorConfig::get($editor)->enablePlugins('spellchecker');
HtmlEditorConfig::get($editor)->addButtonsToLine(2, 'spellchecker');
$token = SecurityToken::inst();
HtmlEditorConfig::get($editor)->setOption('spellchecker_rpc_url', $token->addToUrl('spellcheck/'));
HtmlEditorConfig::get($editor)->setOption('browser_spellcheck', false);
HtmlEditorConfig::get($editor)->setOption('spellchecker_languages', '+' . implode(', ', $languages));
return true;
}
示例15: init
function init()
{
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
// $Lang serves as a "context" which can be inspected by Translatable - hence it
// has the same name as the database property on Translatable.
$req = $this->owner->getRequest();
$id = $req->param('ID');
if ($req->requestVar("Locale")) {
$this->owner->Locale = $req->requestVar("Locale");
} elseif ($req->requestVar("locale")) {
$this->owner->Locale = $req->requestVar("locale");
} else {
if ($id && is_numeric($id)) {
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
if ($record && $record->Locale) {
$this->owner->Locale = $record->Locale;
}
} else {
$this->owner->Locale = Translatable::default_locale();
}
}
Translatable::set_current_locale($this->owner->Locale);
// if a locale is set, it needs to match to the current record
$requestLocale = $req->requestVar("Locale") ? $req->requestVar("Locale") : $req->requestVar("locale");
$page = $this->owner->currentPage();
if ($requestLocale && $page && $page->Locale != $requestLocale) {
$transPage = $page->getTranslation($requestLocale);
if ($transPage) {
Translatable::set_current_locale($transPage->Locale);
return $this->owner->redirect(Controller::join_links($this->owner->Link('show'), $transPage->ID));
} else {
// If the record is not translated, redirect to pages overview
return $this->owner->redirect(Controller::join_links(singleton('CMSPagesController')->Link(), '?locale=' . $requestLocale));
}
}
// collect languages for TinyMCE spellchecker plugin.
// see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
$langName = i18n::get_locale_name($this->owner->Locale);
HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->owner->Locale}");
Requirements::javascript('translatable/javascript/CMSMain.Translatable.js');
Requirements::css('translatable/css/CMSMain.Translatable.css');
}