Index: branches/RC/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r11592 -r11610
--- branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11592)
+++ branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11610)
@@ -295,7 +295,7 @@
$module_info = $category_helper->getCategoryModule($params, $category_path);
// In-Edit & Proj-CMS module prefixes doesn't have custom field with item template
- if ($module_info && $module_info['Var'] != 'cms' && $module_info['Var'] != 'st') {
+ if ($module_info && $module_info['Var'] != 'adm' && $module_info['Var'] != 'st') {
// 2. get item template by current category & module prefix
$mod_rewrite_helper = $this->Application->recallObject('ModRewriteHelper');
@@ -561,7 +561,7 @@
static $root_category = null;
if (!isset($root_category)) {
- $root_category = $this->Application->findModule('Name', 'Proj-CMS', 'RootCat');
+ $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
}
return $root_category;
@@ -1087,18 +1087,20 @@
$page_id = $page->GetID();
- $data = Array ('PageId' => $page_id, 'ContentNum' => $num);
$content =& $this->Application->recallObject('content.-block', null, Array ('skip_autoload' => true));
/* @var $content kDBItem */
+ $data = Array ('PageId' => $page_id, 'ContentNum' => $num);
$content->Load($data);
+
if (!$content->isLoaded()) {
// bug: missing content blocks are created even if user have no SMS-management rights
$content->SetFieldsFromHash($data);
$content->Create();
}
- $edit_code = '';
+ $edit_code_before = $edit_code_after = '';
+
if (EDITING_MODE == EDITING_MODE_CMS) {
$bg_color = isset($params['bgcolor']) ? $params['bgcolor'] : '#ffffff';
$url_params = Array (
@@ -1116,38 +1118,41 @@
// '__FORCE_SID__' => 1
);
+ $additional_css = '';
+
if (isset($params['float'])) {
- $pos_float = 'position: relative; float: '.$params['float'].';';
+ $additional_css .= 'position: relative; width: 100%; float: ' . $params['float'] . ';';
}
- else {
- $pos_float = 'width: auto; position: absolute;';
- }
// link from Front-End to admin, don't remove "index.php"
$edit_url = $this->Application->HREF('categories/edit_content', ADMIN_DIRECTORY, $url_params, 'index.php');
+ $edit_code_before = '
+
+
+
+
+
+
Edit '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
+
+
';
- $button_image = '
';
- $button_css = 'vertical-align: middle; font-family: Arial, Verdana; font-size: 13px; '.$pos_float.' z-index: 99; background-color: #FFCC00; color: black; border: 2px solid #FF6E00; padding: 2px 10px; margin-top: -5px; margin-left: -5px; cursor: pointer;';
- $edit_code = '
' . $button_image . '
Edit '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
';
+ $edit_form = '
';
- if (isset($params['forms_later']) && $params['forms_later']) {
- $tmp = $edit_code;
- $edit_code = '';
- }
+ $edit_code_after = '
';
- $edit_code .= '
';
- if (isset($params['forms_later']) && $params['forms_later']) {
+ if (array_key_exists('forms_later', $params) && $params['forms_later']) {
$all_forms = $this->Application->GetVar('all_forms');
- $all_forms .= $edit_code;
- $this->Application->SetVar('all_forms', $all_forms);
- $edit_code = $tmp;
+ $this->Application->SetVar('all_forms', $all_forms . $edit_form);
}
+ else {
+ $edit_code_after .= $edit_form;
+ }
}
if ($this->Application->GetVar('_editor_preview_') == 1) {
@@ -1156,12 +1161,19 @@
$data = $content->GetField('Content');
}
- $data = $edit_code . $this->_replacePageIds($data);
+ $data = $this->_transformContentBlockData($data, $params);
- if (EDITING_MODE == EDITING_MODE_CMS) {
- $data .= '
';
- }
+ return $edit_code_before . $this->_replacePageIds($data) . $edit_code_after;
+ }
+ /**
+ * Apply all kinds of content block data transformations without rewriting ContentBlock tag
+ *
+ * @param string $data
+ * @return string
+ */
+ function _transformContentBlockData(&$data, $params)
+ {
return $data;
}
@@ -1289,70 +1301,41 @@
}
/**
- * Prints "Edit Page" button on cms page
+ * Includes admin css and js, that are required for cms usage on Front-Edn
*
+ *
* @param Array $params
* @return string
*/
- function EditPage($params)
+ function EditingScripts($params)
{
- if (!EDITING_MODE) {
- return '';
+ if ($this->Application->GetVar('admin_scripts_included') || !EDITING_MODE) {
+ return ;
}
- $page =& $this->_getPage($params);
+ $this->Application->SetVar('admin_scripts_included', 1);
- $url_params = Array(
- 'pass' => 'm,c',
- 'm_opener' => 'd',
- 'c_id' => $page->GetID(),
- 'c_mode' => 't',
- 'c_event' => 'OnEdit',
- 'front' => 1,
- '__URLENCODE__' => 1,
- '__NO_REWRITE__'=> 1,
- 'escape' => 1,
- 'index_file' => 'index.php',
- );
+ $js_url = $this->Application->BaseURL() . 'core/admin_templates/js';
- $edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params);
- $button_image = '';
- $button_css = 'position: absolute; z-index: 1; top: 1; left 1; font-family: Arial, Verdana; font-size: 13px; background-color: #CCFF00; color: black; border: 2px solid #A1D0A1; width: auto; padding: 2px 10px; cursor: pointer;';
- $edit_code = '' . $button_image . '
Section Properties
';
-// $title = $this->PageInfo(array('type' => 'htmlhead_title'));
+ $ret = '
' . "\n";
+ $ret .= '
' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
+ $ret .= '' . "\n";
- $edit_code .= '' . "\n";
- $edit_code .= '' . "\n";
- $edit_code .= '' . "\n";
- $edit_code .= '' . "\n";
- $edit_code .= '' . "\n";
- $edit_code .= '' . "\n";
- }
-
$url_params = Array('m_theme' => '', 'pass' => 'm', 'm_opener' => 'r', 'no_amp' => 1);
$browse_url = $this->Application->HREF('catalog/catalog', ADMIN_DIRECTORY, $url_params, 'index.php');
$browse_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $browse_url);
- $edit_code .= '
-
'."\n";
+ ';
+ $ret .= '' . "\n";
+
+ // add form, so admin scripts could work
+ $ret .= '';
+
+ return $ret;
+ }
+
+ /**
+ * Prints "Edit Page" button on cms page
+ *
+ * @param Array $params
+ * @return string
+ */
+ function EditPage($params)
+ {
+ if (!EDITING_MODE) {
+ return '';
+ }
+
+ $display_mode = array_key_exists('mode', $params) ? $params['mode'] : false;
+ $edit_code = '';
+
+ if ($display_mode != 'end') {
+ $page =& $this->_getPage($params);
+
+ $url_params = Array(
+ 'pass' => 'm,c',
+ 'm_opener' => 'd',
+ 'c_id' => $page->GetID(),
+ 'c_mode' => 't',
+ 'c_event' => 'OnEdit',
+ 'front' => 1,
+ '__URLENCODE__' => 1,
+ '__NO_REWRITE__'=> 1,
+ 'escape' => 1,
+ 'index_file' => 'index.php',
+ );
+
+ $edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params);
+
+ $edit_btn = '
+
+
+
+
+
Section Properties
+
' . "\n";
+
+ if ($display_mode == 'start') {
+ // button with border around the page
+ $edit_code .= '' . $edit_btn . '
';
+
+ }
+ else {
+ // button without border around the page
+ $edit_code .= $edit_btn;
+ }
+ }
+
+ if ($display_mode == 'end') {
+ // draw border around the page
+ $edit_code .= '
';
+ }
+
+ if ($display_mode != 'end') {
+ $edit_code .= '';
+
+ // when "EditingScripts" tag is not used, make sure, that scripts are also included
+ $edit_code .= $this->EditingScripts($params);
+ }
+
return $edit_code;
}
@@ -1379,7 +1436,7 @@
static $root_path = null;
if (!$root_cat) {
- $root_cat = $this->Application->ModuleInfo['Proj-CMS']['RootCat'];
+ $root_cat = $this->Application->ModuleInfo['Core']['RootCat'];
$root_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$root_cat);
}
@@ -1417,7 +1474,7 @@
$cat = $this_category->GetDBField('ParentId');
}
else if ($cat == 0) {
- $cat = $this->Application->ModuleInfo['Proj-CMS']['RootCat'];
+ $cat = $this->Application->ModuleInfo['Core']['RootCat'];
}
return $cat;
@@ -1938,7 +1995,9 @@
$ret = Array ();
foreach ($prefixes as $prefix) {
- $ret[$prefix] = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/export';
+ if ($this->Application->prefixRegistred($prefix)) {
+ $ret[$prefix] = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/export';
+ }
}
$json_helper =& $this->Application->recallObject('JSONHelper');