Index: branches/5.2.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r14748 -r14856 --- branches/5.2.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 14748) +++ branches/5.2.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 14856) @@ -1,6 +1,6 @@ _getPage($params); /* @var $page kDBItem */ - if (!$page->isLoaded()) { + if ( !$page->isLoaded() ) { // page is not created yet => all blocks are empty return ''; } - $page_id = $page->GetID(); + $page_helper =& $this->Application->recallObject('PageHelper'); + /* @var $page_helper PageHelper */ $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(); + if ( !$page_helper->loadContentBlock($content, $page, $num) && EDITING_MODE ) { + $page_helper->createNewContentBlock($page->GetID(), $num); + $page_helper->loadContentBlock($content, $page, $num); } $edit_code_before = $edit_code_after = ''; @@ -1364,7 +1361,7 @@ $js_url . '/../incs/cms.css', ); - $css_compressed = $minify_helper->CompressScriptTag(Array ('files' => implode('|', $to_compress))); + $css_compressed = $minify_helper->CompressScriptTag(Array ('files' => implode('|', $to_compress), 'templates_base' => $js_url . '/../')); $ret = '' . "\n"; @@ -1381,6 +1378,7 @@ $js_url . '/is.js', $js_url . '/application.js', $js_url . '/script.js', + $js_url . '/toolbar.js', $js_url . '/jquery/thickbox/thickbox.js', $js_url . '/template_manager.js', ); @@ -1400,15 +1398,40 @@ $url_params = Array ('theme-file_event' => 'OnSaveLayout', 'source' => $template, 'pass' => 'all,theme-file', '__NO_REWRITE__' => 1, 'no_amp' => 1); $save_layout_url = $this->Application->HREF('index', '', $url_params); - $this_url = $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', '__NO_REWRITE__' => 1, 'no_amp' => 1)); - $ret .= "var aTemplateManager = new TemplateManager('" . $edit_template_url . "', '" . $this_url . "', '" . $save_layout_url . "', " . (int)EDITING_MODE . ");\n"; + $page =& $this->_getPage($params); + + $url_params = Array( + 'pass' => 'm,c', + 'c_id' => $page->GetID(), + 'c_event' => 'OnGetPageInfo', + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'index_file' => 'index.php', + ); + + $page_helper =& $this->Application->recallObject('PageHelper'); + /* @var $page_helper PageHelper */ + + $class_params = Array ( + 'pageId' => $page->GetID(), + 'pageInfo' => $page_helper->getPageInfo( $page->GetID() ), + 'editUrl' => $edit_template_url, + 'browseUrl' => $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', '__NO_REWRITE__' => 1, 'no_amp' => 1)), + 'saveLayoutUrl' => $save_layout_url, + 'editingMode' => (int)EDITING_MODE, + ); + + $ret .= "var aTemplateManager = new TemplateManager(" . json_encode($class_params) . ");\n"; $ret .= "var main_title = '" . addslashes( $this->Application->ConfigValue('Site_Name') ) . "';" . "\n"; $use_popups = (int)$this->Application->ConfigValue('UsePopups'); $ret .= "var \$use_popups = " . ($use_popups > 0 ? 'true' : 'false') . ";\n"; $ret .= "var \$modal_windows = " . ($use_popups == 2 ? 'true' : 'false') . ";\n"; if ( EDITING_MODE != EDITING_MODE_BROWSE ) { + $ret .= 'var $visible_toolbar_buttons = true' . ";\n"; + $ret .= 'var $use_toolbarlabels = ' . ($this->Application->ConfigValue('UseToolbarLabels') ? 'true' : 'false') . ";\n";; + $ret .= "var base_url = '" . $this->Application->BaseURL() . "';" . "\n"; $ret .= 'TB.closeHtml = \'close
\';' . "\n"; @@ -1451,6 +1474,11 @@ */ function EditPage($params) { + if ( $this->Application->GetVar('preview') ) { + // prevents draft preview function to replace last template in session and break page/content block editing process + $this->Application->SetVar('skip_last_template', 1); + } + if (!EDITING_MODE) { return ''; } @@ -1533,6 +1561,77 @@ if ($display_mode == 'start') { // button with border around the page + if ( EDITING_MODE == EDITING_MODE_CONTENT ) { + $tabs = "\n" . str_repeat("\t", 9); + $base_url = $this->Application->BaseURL(); + $toolbar_hidden = $this->Application->GetVar('toolbar_hidden'); + + $edit_code .= ' +
+
+
+ + +
+
+
+ +
+
+
+
+
+ +
+
+ + +
+ +
+
+ + +
+
+ + ' . $publishing_tools . ' +
' . "\n"; + } + $edit_code .= '
' . $edit_btn . '
'; } @@ -1548,6 +1647,29 @@ } if ($display_mode != 'end') { + if ( EDITING_MODE == EDITING_MODE_CONTENT ) { + $url_params = Array( + 'pass' => 'm', + 'm_opener' => 'd', + 'm_cat_id' => $page->GetID(), + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'front' => 1, + 'index_file' => 'index.php', + ); + + $revision = $this->Application->GetVar('revision'); + + if ( $revision ) { + $url_params['revision'] = $revision; + } + + $page_admin_url = $this->Application->HREF('', ADMIN_DIRECTORY, $url_params); + $edit_code .= '
+ +
'; + } + $edit_code .= '
'; // when "EditingScripts" tag is not used, make sure, that scripts are also included @@ -1557,6 +1679,13 @@ return $edit_code; } + function toolbarButton($name, $title, $tabs) + { + $phrase = $this->Application->Phrase($title, false, true); + + return $tabs . 'a_toolbar.AddButton( new ToolBarButton("' . $name . '", "' . htmlspecialchars($phrase) . '") );'; + } + function _getThemeFileId() { $template = $this->Application->GetVar('t');