Index: branches/RC/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11661)
+++ branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11682)
@@ -360,7 +360,8 @@
if ($no_special) return $this->Special;
$list_unique_key = $this->getUniqueListKey($params);
- if (!$this->Application->IsAdmin()) {
+ // check for "admin" variable, because we are parsing front-end template from admin when using template editor feature
+ if ($this->Application->GetVar('admin') || !$this->Application->IsAdmin()) {
// add parent category to special, when on Front-End,
// because there can be many category lists on same page
$list_unique_key .= $parent_cat_id;
@@ -1069,15 +1070,7 @@
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
- $sql = 'SELECT ' . $page->IDField . '
- FROM ' . $page->TableName . '
- WHERE
- (
- (NamedParentPath = ' . $this->Conn->qstr('Content/' . $template) . ') OR
- (IsSystem = 1 AND CachedTemplate = ' . $this->Conn->qstr($template) . ')
- )
- AND (ThemeId = ' . $themes_helper->getCurrentThemeId() . ' OR ThemeId = 0)';
- $page_id = $this->Conn->GetOne($sql);
+ $page_id = $themes_helper->getPageByTemplate($template);
$page->Load($page_id);
}
@@ -1224,7 +1217,7 @@
continue;
}
- $text = preg_replace('/@@' . $page_id . '@@/', $this->Application->HREF($templates[$page_id], '', Array ('pass' => 'm')), $text);
+ $text = preg_replace('/@@' . $page_id . '@@/', $this->Application->HREF(strtolower($templates[$page_id]), '', Array ('pass' => 'm')), $text);
}
return $text;
@@ -1409,9 +1402,15 @@
$display_mode = array_key_exists('mode', $params) ? $params['mode'] : false;
$edit_code = '';
- if ($display_mode != 'end') {
- $page =& $this->_getPage($params);
+ $page =& $this->_getPage($params);
+ if (!$page->isLoaded()) {
+ // when "EditingScripts" tag is not used, make sure, that scripts are also included
+ return $this->EditingScripts($params);
+ }
+
+ // show "EditPage" button only for pages, that exists in structure
+ if ($display_mode != 'end') {
$url_params = Array(
'pass' => 'm,c',
'm_opener' => 'd',
Index: branches/RC/core/units/general/helpers/mod_rewrite_helper.php
===================================================================
diff -u -r11520 -r11682
--- branches/RC/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 11520)
+++ branches/RC/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 11682)
@@ -534,6 +534,11 @@
$not_found = $this->Application->ConfigValue('ErrorTemplate');
$vars['t'] = $not_found ? $not_found : 'error_notfound';
+ $themes_helper =& $this->Application->recallObject('ThemesHelper');
+ /* @var $themes_helper kThemesHelper */
+
+ $vars['m_cat_id'] = $themes_helper->getPageByTemplate($vars['t']);
+
header('HTTP/1.0 404 Not Found');
return $vars;
@@ -562,7 +567,5 @@
$this->HTTPQuery->finalizeParsing($passed, $module_params);*/
}
-
-
}
?>
\ No newline at end of file
Index: branches/RC/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r11662 -r11682
--- branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 11662)
+++ branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 11682)
@@ -442,6 +442,13 @@
// object is used inside template parsing, so break out any parsing and return error document
$error_template = $this->Application->ConfigValue('ErrorTemplate');
+
+ $themes_helper =& $this->Application->recallObject('ThemesHelper');
+ /* @var $themes_helper kThemesHelper */
+
+ $this->Application->SetVar('t', $error_template);
+ $this->Application->SetVar('m_cat_id', $themes_helper->getPageByTemplate($error_template));
+
$this->Application->HTML = $this->Application->ParseBlock( Array ('name' => $error_template) );
$this->Application->Done();
exit;
Index: branches/RC/core/units/general/helpers/themes_helper.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/units/general/helpers/themes_helper.php (.../themes_helper.php) (revision 11661)
+++ branches/RC/core/units/general/helpers/themes_helper.php (.../themes_helper.php) (revision 11682)
@@ -347,6 +347,25 @@
// use current theme, because it's available on Front-End
return $this->Application->GetVar('m_theme');
}
+
+ /**
+ * Returns page id based on given template
+ *
+ * @param string $template
+ * @return int
+ */
+ function getPageByTemplate($template)
+ {
+ $sql = 'SELECT ' . $this->Application->getUnitOption('c', 'IDField') . '
+ FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
+ WHERE
+ (
+ (NamedParentPath = ' . $this->Conn->qstr('Content/' . $template) . ') OR
+ (IsSystem = 1 AND CachedTemplate = ' . $this->Conn->qstr($template) . ')
+ )
+ AND (ThemeId = ' . $this->getCurrentThemeId() . ' OR ThemeId = 0)';
+ return $this->Conn->GetOne($sql);
+ }
}
Index: branches/RC/core/units/general/helpers/template_helper.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11661)
+++ branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11682)
@@ -74,7 +74,7 @@
$cms_handler =& $this->Application->recallObject('st_EventHandler');
/* @var $cms_handler StructureEventHandler */
- $t = $cms_handler->GetDesignTemplate($t);
+ $t = ltrim($cms_handler->GetDesignTemplate($t), '/');
}
$this->_sourceTemplate = $t;
@@ -111,7 +111,7 @@
$this->_getSourceTemplate();
// design templates have leading "/" in the beginning
- $this->Application->Parser->Run(ltrim($this->_sourceTemplate, '/') . $append);
+ $this->Application->Parser->Run($this->_sourceTemplate . $append);
// 3. restore original error handler
$this->Application->errorHandlers = $error_handlers;
Index: branches/RC/core/kernel/event_manager.php
===================================================================
diff -u -r11665 -r11682
--- branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 11665)
+++ branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 11682)
@@ -399,8 +399,12 @@
// should do redirect but to no_permissions template
$event->redirect = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
$event->redirect_params['pass'] = 'm';
- $event->redirect_params['m_cat_id'] = 0;
+ $themes_helper =& $this->Application->recallObject('ThemesHelper');
+ /* @var $themes_helper kThemesHelper */
+
+ $event->redirect_params['m_cat_id'] = $themes_helper->getPageByTemplate($event->redirect);
+
// restore stuff, that processOpener() changed
$wid = $this->Application->GetVar('m_wid');
$this->Application->RestoreVar(rtrim('opener_stack_'.$wid, '_'));
@@ -508,7 +512,7 @@
}
/**
- * Used from relationship event handler
+ * Allows to add new element to opener stack
*
* @param string $template
* @param Array $params
@@ -538,6 +542,35 @@
$this->Application->StoreVar($stack_name, serialize($opener_stack));
}
+ /**
+ * Allows to change last element in opener stack
+ *
+ * @param string $template
+ * @param Array $params
+ * @param string $pass
+ */
+ function openerStackChange($params = Array(), $pass_events = true, $wid = null)
+ {
+ if (!isset($wid)) {
+ $wid = $this->Application->GetVar('m_wid');
+ }
+
+ // get opener stack
+ $stack_name = rtrim('opener_stack_' . $wid, '_');
+ $opener_stack = $this->Application->RecallVar($stack_name);
+ $opener_stack = $opener_stack ? unserialize($opener_stack) : Array ();
+
+ // change opener stack
+ list ($index_file, $env) = explode('|', $opener_stack[ count($opener_stack) - 1 ], 2);
+ $vars = $this->Application->HttpQuery->processQueryString($env, 'pass');
+ $vars = array_merge_recursive2($vars, $params);
+
+ // save opener stack
+ $new_level = $this->Application->BuildEnv($vars['t'], $vars, $vars['pass'], $pass_events, false);
+ $opener_stack[ count($opener_stack) - 1 ] = $index_file . '|' . $new_level;
+ $this->Application->StoreVar($stack_name, serialize($opener_stack));
+ }
+
function registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional)
{
if ( !$this->Application->prefixRegistred($hookto_prefix) && $hookto_prefix != '*' ) {
Index: branches/RC/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11661)
+++ branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11682)
@@ -452,21 +452,22 @@
$object =& $this->Application->recallObject($this->Prefix . '.-new', null, Array('skip_autoload' => true));
/* @var $object kDBItem */
- $this->_prepareAutoPage($object, $template); // create virtual page
+ $created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO, false); // create virtual (not system!) page
+ if ($created) {
+ if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->IsAdmin()) {
+ $updater =& $this->Application->recallObject('kPermCacheUpdater');
+ /* @var $updater kPermCacheUpdater */
- if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->IsAdmin()) {
- $updater =& $this->Application->recallObject('kPermCacheUpdater');
- /* @var $updater kPermCacheUpdater */
+ $updater->OneStepRun();
+ }
- $updater->OneStepRun();
- }
+ $event->CallSubEvent('OnResetMenuCache');
- $event->CallSubEvent('OnResetMenuCache');
+ $this->Application->RemoveVar('PermCache_UpdateRequired');
- $this->Application->RemoveVar('PermCache_UpdateRequired');
-
- $page_id = $object->GetID();
- $this->Application->SetVar('m_cat_id', $page_id);
+ $page_id = $object->GetID();
+ $this->Application->SetVar('m_cat_id', $page_id);
+ }
}
if ($page_id) {
@@ -1344,6 +1345,11 @@
$system = $system_mode == SMS_MODE_FORCE ? 1 : 0;
}
+ if ($system && $template_info === false) {
+ // do not autocreate system pages, when browsing through site
+ return false;
+ }
+
if (!isset($theme_id)) {
$theme_id = $this->_getCurrentThemeId();
}
Index: branches/RC/core/kernel/processors/main_processor.php
===================================================================
diff -u -r11648 -r11682
--- branches/RC/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 11648)
+++ branches/RC/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 11682)
@@ -661,12 +661,13 @@
$replace_main = isset($params['replace_m']) && $params['replace_m'];
$skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array();
+ $cms_mode = $this->Application->GetVar('admin');
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
$module_key = mb_strtolower($module_name);
if ($module_name == 'In-Portal') {
- if ($this->Application->IsAdmin()) {
+ if (!$cms_mode && $this->Application->IsAdmin()) {
// don't process In-Portal templates in admin
continue;
}
Index: branches/RC/core/units/structure/structure_config.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/units/structure/structure_config.php (.../structure_config.php) (revision 11661)
+++ branches/RC/core/units/structure/structure_config.php (.../structure_config.php) (revision 11682)
@@ -96,7 +96,7 @@
'Description' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'format'=>'no_default', 'default' => null),
'CreatedOn' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'required' => 1, 'not_null' => 1),
'EditorsPick' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'Status' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 4), // invisible
+ 'Status' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 1),
'Priority' => Array('type' => 'int', 'not_null' => 1, 'formatter' => 'kOptionsFormatter', 'options' => array(), 'required' => 1, 'default' => 0),
'MetaKeywords' => Array('type' => 'string', 'default' => null),
'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => 0),
Index: branches/RC/core/admin_templates/categories/ci_blocks.tpl
===================================================================
diff -u -r11649 -r11682
--- branches/RC/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 11649)
+++ branches/RC/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 11682)
@@ -14,7 +14,7 @@
Index: branches/RC/core/kernel/session/session.php
===================================================================
diff -u -r11661 -r11682
--- branches/RC/core/kernel/session/session.php (.../session.php) (revision 11661)
+++ branches/RC/core/kernel/session/session.php (.../session.php) (revision 11682)
@@ -941,7 +941,7 @@
* @param string $t
* @param Array $params
*/
- function SaveLastTemplate($t, $params)
+ function SaveLastTemplate($t, $params = Array ())
{
$wid = $this->Application->GetVar('m_wid');
Index: branches/RC/core/admin_templates/tree.tpl
===================================================================
diff -u -r11623 -r11682
--- branches/RC/core/admin_templates/tree.tpl (.../tree.tpl) (revision 11623)
+++ branches/RC/core/admin_templates/tree.tpl (.../tree.tpl) (revision 11682)
@@ -1,6 +1,5 @@