Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/fck_helper.php
Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Line(s) | |||||
* @param array $tag_params Tag params. | * @param array $tag_params Tag params. | ||||
* | * | ||||
* @return CKEditor | * @return CKEditor | ||||
*/ | */ | ||||
protected function prepareConfig(CKEditor $editor, array $tag_params) | protected function prepareConfig(CKEditor $editor, array $tag_params) | ||||
{ | { | ||||
$editor->lateLoad = array_key_exists('late_load', $tag_params) && $tag_params['late_load']; | $editor->lateLoad = array_key_exists('late_load', $tag_params) && $tag_params['late_load']; | ||||
list($styles_css, $styles_js) = $this->getStyles(); | list($styles_css, $styles_js, $templates_js) = $this->getStyles($tag_params); | ||||
if ( isset($tag_params['toolbar']) ) { | if ( isset($tag_params['toolbar']) ) { | ||||
$toolbar = $tag_params['toolbar']; | $toolbar = $tag_params['toolbar']; | ||||
} | } | ||||
elseif ( isset($tag_params['mode']) && $tag_params['mode'] == 'inline' ) { | elseif ( isset($tag_params['mode']) && $tag_params['mode'] == 'inline' ) { | ||||
$toolbar = 'Inline'; | $toolbar = 'Inline'; | ||||
} | } | ||||
else { | else { | ||||
$toolbar = $this->Application->isDebugMode() ? 'DebugMode' : 'Default'; | $toolbar = $this->Application->isDebugMode() ? 'DebugMode' : 'Default'; | ||||
} | } | ||||
$editor->config = Array ( | $editor->config = Array ( | ||||
'toolbar' => $toolbar, | 'toolbar' => $toolbar, | ||||
'baseHref' => $this->Application->BaseURL() . trim(EDITOR_PATH, '/') . '/', | 'baseHref' => $this->Application->BaseURL() . trim(EDITOR_PATH, '/') . '/', | ||||
'customConfig' => $this->getJavaScriptConfig(), | 'customConfig' => $this->getJavaScriptConfig(), | ||||
'stylesSet' => 'portal:' . $styles_js, | 'stylesSet' => 'portal:' . $styles_js, | ||||
'contentsCss' => $styles_css, | 'contentsCss' => $styles_css, | ||||
'Admin' => 1, // for custom file browser to work | 'Admin' => 1, // for custom file browser to work | ||||
'K4' => 1, // for custom file browser to work | 'K4' => 1, // for custom file browser to work | ||||
'language' => $this->getLanguage(), | 'language' => $this->getLanguage(), | ||||
); | ); | ||||
if ( $templates_js ) { | |||||
$editor->config['templates_files'] = array($templates_js); | |||||
} | |||||
$this->injectTransitParams($editor, $this->getTransitParams($tag_params)); | $this->injectTransitParams($editor, $this->getTransitParams($tag_params)); | ||||
return $editor; | return $editor; | ||||
} | } | ||||
/** | /** | ||||
* Transforms transit params into editor config. | * Transforms transit params into editor config. | ||||
* | * | ||||
Show All 23 Lines | |||||
$style_set_parts = explode(':', $editor->config['stylesSet']); | $style_set_parts = explode(':', $editor->config['stylesSet']); | ||||
$style_set_parts[0] = $editor->config['styleSetName']; | $style_set_parts[0] = $editor->config['styleSetName']; | ||||
$editor->config['stylesSet'] = implode(':', $style_set_parts); | $editor->config['stylesSet'] = implode(':', $style_set_parts); | ||||
unset($editor->config['styleSetName']); | unset($editor->config['styleSetName']); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns url to CSS and JS style configuration. | * Returns url to CSS, JS style configuration and HTML templates. | ||||
* | |||||
* @param array $tag_params Tag params (useful during customizations). | |||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
protected function getStyles() | protected function getStyles(array $tag_params) | ||||
{ | { | ||||
/** @var ThemeItem $theme */ | /** @var ThemeItem $theme */ | ||||
$theme = $this->Application->recallObject('theme.current'); | $theme = $this->Application->recallObject('theme.current'); | ||||
$stylesheet_file = $theme->getStylesheetFile(true); | $stylesheet_file = $theme->getStylesheetFile(true); | ||||
if ( $stylesheet_file ) { | if ( $stylesheet_file ) { | ||||
$stylesheet_folder_url = dirname($stylesheet_file) . '/'; | $stylesheet_folder_url = dirname($stylesheet_file) . '/'; | ||||
$url_params = Array ('events[fck]' => 'OnGetsEditorStyles', 'no_pass_through' => 1, 'pass' => 'm'); | $url_params = Array ('events[fck]' => 'OnGetsEditorStyles', 'no_pass_through' => 1, 'pass' => 'm'); | ||||
$prefix = $this->Application->isAdmin ? '_FRONT_END_' : ''; | $prefix = $this->Application->isAdmin ? '_FRONT_END_' : ''; | ||||
$styles_css = $this->Application->HREF('index', $prefix, $url_params, 'index.php'); | $styles_css = $this->Application->HREF('index', $prefix, $url_params, 'index.php'); | ||||
} | } | ||||
else { | else { | ||||
$stylesheet_folder_url = $this->Application->BaseURL() . trim(EDITOR_PATH, '/') . '/'; | $stylesheet_folder_url = $this->Application->BaseURL() . trim(EDITOR_PATH, '/') . '/'; | ||||
$styles_css = $stylesheet_folder_url . 'style.css'; | $styles_css = $stylesheet_folder_url . 'style.css'; | ||||
} | } | ||||
$styles_js = $stylesheet_folder_url . 'styles.js'; | $styles_js = $stylesheet_folder_url . 'styles.js'; | ||||
return array($styles_css, $styles_js); | /** @var FileHelper $file_helper */ | ||||
$file_helper = $this->Application->recallObject('FileHelper'); | |||||
$stylesheet_folder_path = $file_helper->urlToPath($stylesheet_folder_url); | |||||
if ( file_exists($stylesheet_folder_path . 'templates.js') ) { | |||||
$templates_js = $stylesheet_folder_url . 'templates.js'; | |||||
} | |||||
else { | |||||
$templates_js = ''; | |||||
} | |||||
return array($styles_css, $styles_js, $templates_js); | |||||
} | } | ||||
/** | /** | ||||
* Returns url to JavaScript configuration file. | * Returns url to JavaScript configuration file. | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
protected function getJavaScriptConfig() | protected function getJavaScriptConfig() | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |