本文整理汇总了PHP中HtmlEditorConfig::get_active方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlEditorConfig::get_active方法的具体用法?PHP HtmlEditorConfig::get_active怎么用?PHP HtmlEditorConfig::get_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlEditorConfig
的用法示例。
在下文中一共展示了HtmlEditorConfig::get_active方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizeHTML
/**
* Strips out not allowed tags, mainly this is to remove the kapost beacon script so it doesn't conflict with the cms
* @param {string} $str String to be sanitized
* @return {string} HTML to be used
*/
public final function sanitizeHTML($str)
{
$htmlValue = Injector::inst()->create('HTMLValue', $str);
$santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
$santiser->sanitise($htmlValue);
return $htmlValue->getContent();
}
示例2: include_js
/**
* This basically merges HtmlEditorField::include_js() and HTMLEditorConfig::generateJS() to output all
* configuration sets to a customTinyMceConfigs javascript array.
* This is output in addition to the standard ssTinyMceConfig because a) we can't stop the default output
* with extensions; and b) the default setting is still used for any HTMLEditorField that doesn't specify
* it's own config.
*
* Calls Requirements::javascript() to load the scripts.
*/
public static function include_js()
{
require_once 'tinymce/tiny_mce_gzip.php';
$availableConfigs = HtmlEditorConfig::get_available_configs_map();
$pluginsForTag = array();
$languages = array();
//$allConfigs = array();
$settingsJS = '';
$externalPluginsForJS = array();
$activeConfig = HtmlEditorConfig::get_active();
foreach ($availableConfigs as $identifier => $friendlyName) {
$configObj = CustomHtmlEditorConfig::get($identifier);
$internalPluginsForJS = array();
$configObj->getConfig()->setOption('language', i18n::get_tinymce_lang());
if (!$configObj->getConfig()->getOption('content_css')) {
$configObj->getConfig()->setOption('content_css', $activeConfig->getOption('content_css'));
}
$settings = $configObj->getSettings();
foreach ($configObj->getPlugins() as $plugin => $path) {
if (!$path) {
$pluginsForTag[$plugin] = $plugin;
$internalPluginsForJS[$plugin] = $plugin;
} else {
$internalPluginsForJS[$plugin] = '-' . $plugin;
$externalPluginsForJS[$plugin] = sprintf('tinymce.PluginManager.load("%s", "%s");' . "\n", $plugin, $path);
}
}
$language = $configObj->getConfig()->getOption('language');
if ($language) {
$languages[$language] = $language;
}
$settings['plugins'] = implode(',', $internalPluginsForJS);
$buttons = $configObj->getButtons();
foreach ($buttons as $i => $buttons) {
$settings['theme_advanced_buttons' . $i] = implode(',', $buttons);
}
$settingsJS .= "customTinyMceConfigs['" . $identifier . "'] = " . Convert::raw2json($settings) . ";\n";
}
if (Config::inst()->get('HtmlEditorField', 'use_gzip')) {
$tag = TinyMCE_Compressor::renderTag(array('url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php', 'plugins' => implode(',', $pluginsForTag), 'themes' => 'advanced', 'languages' => implode(',', $languages)), true);
preg_match('/src="([^"]*)"/', $tag, $matches);
Requirements::javascript($matches[1]);
} else {
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
}
$externalPluginsJS = implode('', $externalPluginsForJS);
$script = <<<JS
\t\t\tif((typeof tinyMCE != 'undefined')) {
\t\t\t\t{$externalPluginsJS}
\t\t\t\tif (typeof customTinyMceConfigs == 'undefined') {
\t\t\t\t\tvar customTinyMceConfigs = [];
\t\t\t\t}
\t\t\t\t{$settingsJS}
\t\t\t}
JS;
Requirements::customScript($script, 'htmlEditorConfigs');
}
开发者ID:helpfulrobot,项目名称:nathancox-customhtmleditorfield,代码行数:68,代码来源:CustomHTMLEditorLeftAndMainExtension.php
示例3: 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();
}
示例4: init
public function init() {
parent::init();
// Remove all the junk that will break ModelAdmin
$config = HtmlEditorConfig::get_active();
$buttons = array('undo','redo','separator','cut','copy','paste','pastetext','pasteword','spellchecker','separator','sslink','unlink','anchor','separator','advcode','search','replace','selectall','visualaid','separator');
$config->setButtonsForLine(2,$buttons);
Requirements::javascript('remodeladmin/javascript/remodeladmin.js');
Requirements::css('remodeladmin/css/remodeladmin.css');
}
示例5: saveInto
/**
* Implementation directly borrowed from HtmlEditorField
* without the blocking or useless code.
*/
public function saveInto(DataObjectInterface $record)
{
$htmlValue = Injector::inst()->create('HTMLValue', $this->value);
// Sanitise if requested
if ($this->config()->sanitise_server_side) {
$santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
$santiser->sanitise($htmlValue);
}
$this->extend('processHTML', $htmlValue);
$record->{$this->name} = $htmlValue->getContent();
}
示例6: getCMSFields_forPopup
function getCMSFields_forPopup() {
$fields = new FieldSet();
// $tabset = new HorizontalTabSet('Root');
// $tabset->push(new Tab('Main'));
// $tabset->push(new Tab('Formats'));
// $fields->push($tabset);
$fields->push(new TextField('Title', 'Video Title'));
$fields->push($blurbField = new SimpleTinyMCEField('Blurb'));
$config = HtmlEditorConfig::get_active();
$contentCSS = $config->getOption('content_css');
// hack!
$contentCSS = '/'.str_replace(', ', ', /', $contentCSS);
$blurbField->setContentCSS($contentCSS);
$blurbField->setExtraOptions("body_class : 'typography'");
$fields->push(new ImageField('Poster', 'Poster Image'));
$videoManager = new FileDataobjectManager(
$this, // Controller
'VideoFormats', // Source name
'MediaElementVideoFormat', // Source class
'Attachment',
array(
'Type' => 'Type',
'LinkifiedLink' => 'Link'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$videoManager->setPluralTitle('Formats');
$videoManager->setAddTitle('Format');
// $videoManager->setWideMode(true);
$videoManager->setPopupWidth(600);
$videoManager->setDefaultView('list');
$fields->push($videoManager);
// $fields->push($videoManager);
return $fields;
}
示例7: init
/**
* init (called from LeftAndMain extension hook)
**/
public function init()
{
// set the htmleditor "content_css" based on the active site
$htmlEditorConfig = HtmlEditorConfig::get_active();
$site = Multisites::inst()->getActiveSite();
if ($site && ($theme = $site->getSiteTheme())) {
$cssFile = THEMES_DIR . "/{$theme}/css/editor.css";
if (file_exists(BASE_PATH . '/' . $cssFile)) {
$htmlEditorConfig->setOption('content_css', $cssFile);
if ($this->owner->getRequest()->isAjax() && $this->owner->class == 'CMSPageEditController') {
// Add editor css path to header so javascript can update ssTinyMceConfig.content_css
$this->owner->getResponse()->addHeader('X-HTMLEditor_content_css', $cssFile);
}
}
}
}
开发者ID:silverstripe-australia,项目名称:silverstripe-multisites,代码行数:19,代码来源:MultisitesCmsMainExtension.php
示例8: saveInto
public function saveInto(DataObjectInterface $record)
{
if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
throw new Exception('HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.');
}
$htmlValue = Injector::inst()->create('HTMLValue', $this->value);
// Sanitise if requested
if ($this->config()->sanitise_server_side) {
$santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
$santiser->sanitise($htmlValue);
}
// Resample images and add default attributes
if ($images = $htmlValue->getElementsByTagName('img')) {
foreach ($images as $img) {
// strip any ?r=n data from the src attribute
$img->setAttribute('src', preg_replace('/([^\\?]*)\\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
// Resample the images if the width & height have changed.
if ($image = File::find(urldecode(Director::makeRelative($img->getAttribute('src'))))) {
$width = (int) $img->getAttribute('width');
$height = (int) $img->getAttribute('height');
if ($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) {
//Make sure that the resized image actually returns an image:
$resized = $image->ResizedImage($width, $height);
if ($resized) {
$img->setAttribute('src', $resized->getRelativePath());
}
}
}
// Add default empty title & alt attributes.
if (!$img->getAttribute('alt')) {
$img->setAttribute('alt', '');
}
if (!$img->getAttribute('title')) {
$img->setAttribute('title', '');
}
// Use this extension point to manipulate images inserted using TinyMCE, e.g. add a CSS class, change default title
// $image is the image, $img is the DOM model
$this->extend('processImage', $image, $img);
}
}
// optionally manipulate the HTML after a TinyMCE edit and prior to a save
$this->extend('processHTML', $htmlValue);
// Store into record
$record->{$this->name} = $htmlValue->getContent();
}
示例9: saveInto
public function saveInto(DataObjectInterface $record)
{
if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
throw new Exception('HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.');
}
// Resample images
$value = Image::regenerate_html_links($this->value);
$htmlValue = Injector::inst()->create('HTMLValue', $value);
// Sanitise if requested
if ($this->config()->sanitise_server_side) {
$santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
$santiser->sanitise($htmlValue);
}
// optionally manipulate the HTML after a TinyMCE edit and prior to a save
$this->extend('processHTML', $htmlValue);
// Store into record
$record->{$this->name} = $htmlValue->getContent();
}
示例10: include_js
/**
* Includes the JavaScript neccesary for this field to work using the {@link Requirements} system.
*/
public static function include_js()
{
require_once 'tinymce/tiny_mce_gzip.php';
$configObj = HtmlEditorConfig::get_active();
if (self::$use_gzip) {
$internalPlugins = array();
foreach ($configObj->getPlugins() as $plugin => $path) {
if (!$path) {
$internalPlugins[] = $plugin;
}
}
$tag = TinyMCE_Compressor::renderTag(array('url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php', 'plugins' => implode(',', $internalPlugins), 'themes' => 'advanced', 'languages' => $configObj->getOption('language')), true);
preg_match('/src="([^"]*)"/', $tag, $matches);
Requirements::javascript($matches[1]);
} else {
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
}
Requirements::customScript($configObj->generateJS(), 'htmlEditorConfig');
}
示例11: include_js_internal
private static function include_js_internal($configName)
{
require_once 'tinymce/tiny_mce_gzip.php';
$configObj = HtmlEditorConfig::get_active();
if (Config::inst()->get('HtmlEditorField', 'use_gzip')) {
$internalPlugins = array();
foreach ($configObj->getPlugins() as $plugin => $path) {
if (!$path) {
$internalPlugins[] = $plugin;
}
}
$tag = TinyMCE_Compressor::renderTag(array('url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php', 'plugins' => implode(',', $internalPlugins), 'themes' => 'advanced', 'languages' => $configObj->getOption('language')), true);
preg_match('/src="([^"]*)"/', $tag, $matches);
Requirements::javascript(html_entity_decode($matches[1]));
} else {
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\t\t" . str_replace("ssTinyMceConfig", "ssTinyMceConfig" . $configName, $config->generateJS()) . "\n\t\t\t", "htmlEditorConfig-{$configName}");
}
示例12: saveInto
public function saveInto(DataObjectInterface $record)
{
if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
throw new Exception('HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.');
}
$htmlValue = Injector::inst()->create('HTMLValue', $this->value);
// Sanitise if requested
if ($this->config()->sanitise_server_side) {
$santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
$santiser->sanitise($htmlValue);
}
// Resample images and add default attributes
if ($images = $htmlValue->getElementsByTagName('img')) {
foreach ($images as $img) {
// strip any ?r=n data from the src attribute
$img->setAttribute('src', preg_replace('/([^\\?]*)\\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
// Resample the images if the width & height have changed.
// TODO: look for -10x here?
$filename = RetinaImage::removeFilenameAppender(urldecode(Director::makeRelative($img->getAttribute('src'))), '-10x');
$image = File::find($filename);
// try to find it using the legacy way
if (!$image) {
$image = File::find(urldecode(Director::makeRelative($img->getAttribute('src'))));
}
if ($image) {
$imagemap = $image->toMap();
$retinaimage = RetinaImage::create();
foreach ($imagemap as $key => $value) {
$retinaimage->{$key} = $value;
}
$width = $img->getAttribute('width');
$height = $img->getAttribute('height');
if ($width && $height && ($width != $retinaimage->getWidth() || $height != $retinaimage->getHeight()) || !$img->hasAttribute('srcset') && RetinaImage::$forceretina) {
//Make sure that the resized image actually returns an image:
if (!is_numeric($width) || !is_numeric($height)) {
$width = (int) ($retinaimage->getWidth() / 2);
$height = (int) ($retinaimage->getHeight() / 2);
}
$resized = $retinaimage->ResizedImage($width, $height);
$url = $resized->getRelativePath();
$onex10 = $retinaimage->insertFilenameAppender($url, '-10x');
$onex15 = $retinaimage->insertFilenameAppender($url, '-15x');
$onex20 = $retinaimage->insertFilenameAppender($url, '-20x');
if ($resized) {
$img->setAttribute('src', $onex10);
}
// srcset=\"$onex10 1x, $onex15 1.5x, $onex20 2x\"
$img->setAttribute('srcset', "{$onex10} 1x, {$onex15} 1.5x, {$onex20} 2x");
}
}
// Add default empty title & alt attributes.
if (!$img->getAttribute('alt')) {
$img->setAttribute('alt', '');
}
if (!$img->getAttribute('title')) {
$img->setAttribute('title', '');
}
}
}
// Store into record
$record->{$this->name} = $htmlValue->getContent();
}
示例13: init
/**
* @uses LeftAndMainExtension->init()
* @uses LeftAndMainExtension->accessedCMS()
* @uses CMSMenu
*/
function init()
{
parent::init();
SSViewer::setOption('rewriteHashlinks', false);
// set language
$member = Member::currentUser();
if (!empty($member->Locale)) {
i18n::set_locale($member->Locale);
}
if (!empty($member->DateFormat)) {
i18n::set_date_format($member->DateFormat);
}
if (!empty($member->TimeFormat)) {
i18n::set_time_format($member->TimeFormat);
}
// can't be done in cms/_config.php as locale is not set yet
CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), self::$help_link);
// Allow customisation of the access check by a extension
// Also all the canView() check to execute Controller::redirect()
if (!$this->canView() && !$this->response->isFinished()) {
// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
$menu = $this->MainMenu();
foreach ($menu as $candidate) {
if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
return $this->redirect($candidate->Link);
}
}
if (Member::currentUser()) {
Session::set("BackURL", null);
}
// if no alternate menu items have matched, return a permission error
$messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS. If you would like to log in again, enter a username and password below."));
return Security::permissionFailure($this, $messageSet);
}
// Don't continue if there's already been a redirection request.
if ($this->redirectedTo()) {
return;
}
// Audit logging hook
if (empty($_REQUEST['executeForm']) && !$this->request->isAjax()) {
$this->extend('accessedCMS');
}
// Set the members html editor config
HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
// Set default values in the config if missing. These things can't be defined in the config
// file because insufficient information exists when that is being processed
$htmlEditorConfig = HtmlEditorConfig::get_active();
$htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
if (!$htmlEditorConfig->getOption('content_css')) {
$cssFiles = array();
$cssFiles[] = FRAMEWORK_ADMIN_DIR . '/css/editor.css';
// Use theme from the site config
if (class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
$theme = $config->Theme;
} elseif (SSViewer::current_theme()) {
$theme = SSViewer::current_theme();
} else {
$theme = false;
}
if ($theme) {
$cssFiles[] = THEMES_DIR . "/{$theme}/css/editor.css";
} else {
if (project()) {
$cssFiles[] = project() . '/css/editor.css';
}
}
// Remove files that don't exist
foreach ($cssFiles as $k => $cssFile) {
if (!file_exists(BASE_PATH . '/' . $cssFile)) {
unset($cssFiles[$k]);
}
}
$htmlEditorConfig->setOption('content_css', implode(',', $cssFiles));
}
// Using uncompressed files as they'll be processed by JSMin in the Requirements class.
// Not as effective as other compressors or pre-compressed+finetuned files,
// but overall the unified minification into a single file brings more performance benefits
// than a couple of saved bytes (after gzip) in individual files.
// We also re-compress already compressed files through JSMin as this causes weird runtime bugs.
Requirements::combine_files('lib.js', array(THIRDPARTY_DIR . '/jquery/jquery.js', FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js', FRAMEWORK_ADMIN_DIR . '/javascript/lib.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', THIRDPARTY_DIR . '/json-js/json2.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', THIRDPARTY_DIR . '/jquery-query/jquery.query.js', THIRDPARTY_DIR . '/jquery-form/jquery.form.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.adapter.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', FRAMEWORK_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js', FRAMEWORK_DIR . '/javascript/TreeDropdownField.js', FRAMEWORK_DIR . '/javascript/DateField.js', FRAMEWORK_DIR . '/javascript/HtmlEditorField.js', FRAMEWORK_DIR . '/javascript/TabSet.js', FRAMEWORK_DIR . '/javascript/i18n.js', FRAMEWORK_ADMIN_DIR . '/javascript/ssui.core.js', FRAMEWORK_DIR . '/javascript/GridField.js'));
if (Director::isDev()) {
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/leaktools.js');
}
HTMLEditorField::include_js();
Requirements::combine_files('leftandmain.js', array_unique(array_merge(array(FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Panel.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Content.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Menu.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.FieldHelp.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.TreeDropdownField.js'), Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang', true, true), Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/javascript/lang', true, true))));
// TODO Confuses jQuery.ondemand through document.write()
if (Director::isDev()) {
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
}
Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.css');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css');
Requirements::css(THIRDPARTY_DIR . '/jstree/themes/apple/style.css');
Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css');
Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/screen.css');
//.........这里部分代码省略.........
示例14: init
/**
* @uses LeftAndMainDecorator->init()
* @uses LeftAndMainDecorator->accessedCMS()
* @uses CMSMenu
*/
function init()
{
parent::init();
SSViewer::setOption('rewriteHashlinks', false);
// set language
$member = Member::currentUser();
if (!empty($member->Locale)) {
i18n::set_locale($member->Locale);
}
if (!empty($member->DateFormat)) {
i18n::set_date_format($member->DateFormat);
}
if (!empty($member->TimeFormat)) {
i18n::set_time_format($member->TimeFormat);
}
// can't be done in cms/_config.php as locale is not set yet
CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'), self::$help_link);
// set reading lang
if (Object::has_extension('SiteTree', 'Translatable') && !$this->isAjax()) {
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
}
// Allow customisation of the access check by a decorator
// Also all the canView() check to execute Director::redirect()
if (!$this->canView() && !$this->response->isFinished()) {
// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
$menu = $this->MainMenu();
foreach ($menu as $candidate) {
if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
return Director::redirect($candidate->Link);
}
}
if (Member::currentUser()) {
Session::set("BackURL", null);
}
// if no alternate menu items have matched, return a permission error
$messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS. If you would like to log in again, enter a username and password below."));
return Security::permissionFailure($this, $messageSet);
}
// Don't continue if there's already been a redirection request.
if (Director::redirected_to()) {
return;
}
// Audit logging hook
if (empty($_REQUEST['executeForm']) && !$this->isAjax()) {
$this->extend('accessedCMS');
}
// Set the members html editor config
HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
// Set default values in the config if missing. These things can't be defined in the config
// file because insufficient information exists when that is being processed
$htmlEditorConfig = HtmlEditorConfig::get_active();
$htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
if (!$htmlEditorConfig->getOption('content_css')) {
$cssFiles = 'cms/css/editor.css';
// Use theme from the site config
if (($config = SiteConfig::current_site_config()) && $config->Theme) {
$theme = $config->Theme;
} elseif (SSViewer::current_theme()) {
$theme = SSViewer::current_theme();
} else {
$theme = false;
}
if ($theme) {
$cssFiles .= ',' . THEMES_DIR . "/{$theme}/css/editor.css";
} else {
if (project()) {
$cssFiles .= ',' . project() . '/css/editor.css';
}
}
$htmlEditorConfig->setOption('content_css', $cssFiles);
}
Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css(CMS_DIR . '/css/layout.css');
Requirements::css(CMS_DIR . '/css/cms_left.css');
Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
if (isset($_REQUEST['debug_firebug'])) {
// Firebug is a useful console for debugging javascript
// Its available as a Firefox extension or a javascript library
// for easy inclusion in other browsers (just append ?debug_firebug=1 to the URL)
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/firebug-lite/firebug.js');
} else {
// By default, we include fake-objects for all firebug calls
// to avoid javascript errors when referencing console.log() etc in javascript code
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/firebug-lite/firebugx.js');
}
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/intro.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/outro.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
//import all of jquery ui
Requirements::javascript(CMS_DIR . '/thirdparty/jquery-layout/jquery.layout.js');
Requirements::javascript(CMS_DIR . '/thirdparty/jquery-layout/jquery.layout.state.js');
//.........这里部分代码省略.........
示例15: include_js
/**
* Includes the JavaScript neccesary for this field to work using the {@link Requirements} system.
*/
public static function include_js()
{
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
Requirements::customScript(HtmlEditorConfig::get_active()->generateJS(), 'htmlEditorConfig');
}