Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r16408 -r16409 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 16408) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 16409) @@ -1,6 +1,6 @@ InputName($params); - if (!isset($language_code)) { - $language_code = 'en'; // defaut value + $fck_helper = $this->Application->recallObject('FCKHelper'); + /* @var $fck_helper fckFCKHelper */ - if ($this->Application->isAdmin) { - $language_id = $this->Application->Phrases->LanguageId; - } - else { - $language_id = $this->Application->GetDefaultLanguageId(); // $this->Application->GetVar('m_lang'); - } - - $sql = 'SELECT Locale - FROM '. $this->Application->getUnitOption('lang', 'TableName') . ' - WHERE LanguageId = ' . $language_id; - $locale = strtolower( $this->Conn->GetOne($sql) ); - - if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale . '.js')) { - // found language file, that exactly matches locale name (e.g. "en") - $language_code = $locale; - } - else { - $locale = explode('-', $locale); - if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale[0] . '.js')) { - // language file matches first part of locale (e.g. "ru-RU") - $language_code = $locale[0]; - } - } + if ( isset($params['mode']) && $params['mode'] == 'inline' ) { + return $fck_helper->CKEditorInlineTag($editor_name, $params); } - return $language_code; + return $fck_helper->CKEditorTag($editor_name, $this->CKEditorValue($params), $params); } - - function FCKEditor($params) + /** + * Returns value, used by FCKEditor tag + * + * @param array $params + * + * @return string + */ + protected function CKEditorValue($params) { $params['no_special'] = 1; $params['format'] = array_key_exists('format', $params) ? $params['format'] . ';fck_ready' : 'fck_ready'; - $value = $this->Field($params); - $name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params); - /** @var ThemeItem $theme */ - $theme = $this->Application->recallObject('theme.current'); - $stylesheet_file = $theme->getStylesheetFile(true); - - if ( $stylesheet_file ) { - $stylesheet_folder_url = dirname($stylesheet_file) . '/'; - - $url_params = Array ( - 'events[fck]' => 'OnGetsEditorStyles', - 'no_pass_through' => 1, 'pass' => 'm', 'no_amp' => 1 - ); - - $styles_css = $this->Application->HREF('index', '_FRONT_END_', $url_params, 'index.php'); - } - else { - $stylesheet_folder_url = $this->Application->BaseURL(rtrim(EDITOR_PATH, '/')); - $styles_css = $stylesheet_folder_url . 'style.css'; - } - - $styles_js = $stylesheet_folder_url . 'styles.js'; - - /*$page_id = $this->Application->GetVar('c_id'); - $content_id = $this->Application->GetVar('content_id'); - $preview_url = ''; - - if ($page_id && $content_id) { - // editing content block from Front-End, not category in admin - $sql = 'SELECT NamedParentPath - FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' - WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . (int)$page_id; - $template = strtolower( $this->Conn->GetOne($sql) ); - - $url_params = Array ('m_cat_id' => $page_id, 'no_amp' => 1, 'editing_mode' => EDITING_MODE_CONTENT, 'pass' => 'm'); - $preview_url = $this->Application->HREF($template, '_FRONT_END_', $url_params, 'index.php'); - $preview_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $preview_url); - }*/ - - include_once(FULL_PATH . EDITOR_PATH . 'ckeditor.php'); - - $oCKeditor = new CKeditor(BASE_PATH . EDITOR_PATH); - -// $oFCKeditor->FullUrl = $this->Application->BaseURL(); -// $oFCKeditor->BaseUrl = BASE_PATH . '/'; // used by custom document plugin -// $oFCKeditor->PreviewUrl = $preview_url; // used by custom MyPreview plugin - - $oCKeditor->lateLoad = array_key_exists('late_load', $params) && $params['late_load']; - - $width = $params['width']; - $height = $params['height']; - - if ( preg_match('/^[\d]+$/', $width) ) { - $width .= 'px'; - } - - if ( preg_match('/^[\d]+$/', $height) ) { - $height .= 'px'; - } - - $oCKeditor->textareaAttributes = Array ( - 'style' => 'width: ' . $width . '; height: ' . $height . ';' - ); - - if ( file_exists(SYSTEM_PRESET_PATH . DIRECTORY_SEPARATOR . 'inp_ckconfig.js') ) { - $file_helper = $this->Application->recallObject('FileHelper'); - /* @var $file_helper FileHelper */ - - $config_js = $file_helper->pathToUrl(SYSTEM_PRESET_PATH . DIRECTORY_SEPARATOR . 'inp_ckconfig.js'); - } - else { - $config_js = $this->Application->BaseURL() . 'core/admin_templates/js/inp_ckconfig.js'; - } - - $fck_helper = $this->Application->recallObject('FCKHelper'); - /* @var $fck_helper fckFCKHelper */ - - $transit_params = $fck_helper->getTransitParams($params); - - $oCKeditor->config = Array ( - 'toolbar' => $this->Application->isDebugMode() ? 'DebugMode' : 'Default', // $page_id && $content_id ? 'Advanced' : 'Default', - - 'baseHref' => $this->Application->BaseURL( rtrim(EDITOR_PATH, '/') ), - -// 'ProjectPath' => BASE_PATH . '/', // used by custom MyPreview plugin - - 'customConfig' => $config_js, - 'stylesSet' => 'portal:' . $styles_js, - 'contentsCss' => $styles_css, -// 'DefaultStyleLabel' => $this->Application->Phrase('la_editor_default_style'), // not ported to ckeditor - 'Admin' => 1, // for custom file browser to work - 'K4' => 1, // for custom file browser to work -// 'PreviewUrl' => $preview_url, -// 'BaseUrl' => BASE_PATH . '/', // used by custom document plugin & by file browser - 'language' => $this->_getFCKLanguage(), - 'height' => $height, // editor area height - ); - - if ( isset($transit_params['bgcolor']) && $transit_params['bgcolor'] ) { - $oCKeditor->config['extraCss'] = 'body { background-color: ' . $transit_params['bgcolor'] . '; }'; - } - - foreach ($transit_params as $param_name => $param_value) { - if ( !$param_value ) { - continue; - } - - $param_key = str_replace(' ', '', ucwords(str_replace('_', ' ', $param_name))); - $param_key[0] = strtolower($param_key[0]); - - $oCKeditor->config[$param_key] = $param_value; - } - - $oCKeditor->returnOutput = true; - - $events = Array ( - 'configLoaded' => 'function(ev) { CKEDITOR.addCss(ev.editor.config.extraCss); }', - ); - - return $oCKeditor->editor($name, $value, Array (), $events); + return $this->Field($params); } function IsNewItem($params)