Index: branches/RC/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r11635 -r11646 --- branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11635) +++ branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11646) @@ -1333,7 +1333,7 @@ * @param StructureItem $object * @param string $template */ - function _prepareAutoPage(&$object, $template, $theme_id = null, $system_mode = SMS_MODE_AUTO, $theme_file_id = null) + function _prepareAutoPage(&$object, $template, $theme_id = null, $system_mode = SMS_MODE_AUTO, $template_info = Array ()) { $template = $this->_stripTemplateExtension($template); @@ -1368,7 +1368,6 @@ if ($system) { $design_template = strtolower($template); // leading "/" not added ! - $template_info = $this->_getTemplateInfo($design_template, $theme_id, $theme_file_id); if ($template_info) { if (array_key_exists('name', $template_info) && $template_info['name']) { $page_name = $template_info['name']; @@ -1488,77 +1487,6 @@ } /** - * Returns template information (name, description, path) from it's header comment - * - * @param string $template - * @param int $theme_id - * @return Array - */ - function _getTemplateInfo($template, $theme_id = null, $theme_file_id = null) - { - if (!defined('DBG_NPARSER_FORCE_COMPILE')) { - $this->Application->InitParser(); - define('DBG_NPARSER_FORCE_COMPILE', 1); - } - - if (!isset($theme_id)) { - $theme_id = $this->_getCurrentThemeId(); - } - - $template = 'theme:' . $this->_getThemeName($theme_id) . '/' . $template; - $template_file = $this->Application->TemplatesCache->GetRealFilename($template) . '.tpl'; - - if (!file_exists($template_file)) { - // when template without info it's placed in top category - return Array (); - } - - $template_data = file_get_contents($template_file); - - if (substr($template_data, 0, 6) == '*/ - - $comment_end = strpos($template_data, '##-->'); - if ($comment_end === false) { - // badly formatted comment - return Array (); - } - - $comment = trim( substr($template_data, 6, $comment_end - 6) ); - if (preg_match_all('/<(NAME|DESC|SECTION)>(.*?)<\/(NAME|DESC|SECTION)>/is', $comment, $regs)) { - $ret = Array (); - foreach ($regs[1] as $param_order => $param_name) { - $ret[ strtolower($param_name) ] = trim($regs[2][$param_order]); - } - - if (array_key_exists('section', $ret) && $ret['section']) { - $category_path = explode('||', $ret['section']); - $category_path = array_map('trim', $category_path); - $ret['section'] = implode('||', $category_path); - } - - if (isset($theme_file_id) && array_key_exists('desc', $ret)) { - // copy description from template to if's file record in ThemeFiles table - $fields_hash = Array ( - 'Description' => $ret['desc'], - ); - - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'ThemeFiles', 'FileId = ' . $theme_file_id); - } - - return $ret; - } - } - - return Array (); - } - - /** * Returns theme name by it's id. Used in structure page creation. * * @param int $theme_id @@ -1652,8 +1580,7 @@ $design_folders = array_unique($design_folders); $design_sql = $fields['Template']['options_sql']; - $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')', $design_sql); - $design_sql .= ' AND (t.ThemeId = ' . $theme_id . ')'; + $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); $fields['Template']['options_sql'] = $design_sql; $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); @@ -1801,7 +1728,7 @@ */ function OnAfterRebuildThemes(&$event) { - $sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileId + $sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileMetaInfo FROM '.TABLE_PREFIX.'ThemeFiles AS tf LEFT JOIN '.TABLE_PREFIX.'Theme AS t ON t.ThemeId = tf.ThemeId WHERE t.Enabled = 1 AND tf.FileType = 1 @@ -1821,7 +1748,7 @@ $error_count = 0; foreach ($files as $a_file => $file_info) { - $status = $this->_prepareAutoPage($dummy, $a_file, $file_info['ThemeId'], SMS_MODE_FORCE, $file_info['FileId']); // create system page + $status = $this->_prepareAutoPage($dummy, $a_file, $file_info['ThemeId'], SMS_MODE_FORCE, unserialize($file_info['FileMetaInfo'])); // create system page if (!$status) { $error_count++; }