Index: branches/5.2.x/core/kernel/managers/rewrite_url_processor.php =================================================================== diff -u -N -r15717 -r15805 --- branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15717) +++ branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15805) @@ -1,6 +1,6 @@ _isTemplateAllowed($template_found, $vars['m_cat_id']) ) { + if ( $template_found ) { $template_parts = explode('/', $template_path); $vars['t'] = $template_path . ($index_added ? '/index' : ''); @@ -711,76 +711,6 @@ } /** - * Determines if found template can be used in combination with found category - * - * @param int $file_id - * @param int $category_id - * @return bool - * @access protected - */ - protected function _isTemplateAllowed($file_id, $category_id) - { - if ( $this->_isSectionAwareTemplate($file_id) ) { - // template accepts any category from url - return true; - } - - $allowed_categories = Array (0, $this->Application->getBaseCategory()); - - $sql = 'SELECT t.ThemeId, CONCAT(tf.FilePath, "/", tf.FileName) AS Path - FROM ' . TABLE_PREFIX . 'Themes t - JOIN ' . TABLE_PREFIX . 'ThemeFiles tf ON tf.ThemeId = t.ThemeId - WHERE tf.FileId = ' . $file_id; - $template_info = $this->Conn->GetRow($sql); - - if ( $template_info ) { - // this template isn't added to ".smsignore" - $template = preg_replace('/^[\\/]{0,1}(.*)\.tpl$/', "$1", $template_info['Path']); - - $where_clause = Array ( - 'Template = ' . $this->Conn->qstr($template), - 'ThemeId = ' . $template_info['ThemeId'], - '`Type` = ' . PAGE_TYPE_TEMPLATE, - ); - - $sql = 'SELECT CategoryId - FROM ' . TABLE_PREFIX . 'Categories - WHERE (' . implode(') AND (', $where_clause) . ')'; - $template_category_id = $this->Conn->GetOne($sql); - - if ( $template_category_id ) { - // category found for this template - $allowed_categories[] = $template_category_id; - } - } - - return in_array($category_id, $allowed_categories); - } - - /** - * Determines, that template by given $file_id is in fact section agnostic template - * - * @param int $file_id - * @return bool - * @access protected - */ - protected function _isSectionAwareTemplate($file_id) - { - $sql = 'SELECT FileMetaInfo - FROM ' . TABLE_PREFIX . 'ThemeFiles - WHERE FileId = ' . $file_id; - $meta_info = $this->Conn->GetOne($sql); - - if ( $meta_info ) { - $meta_info = unserialize($meta_info); - - return isset($meta_info['section_aware']); - } - - return false; - } - - /** * Returns environment variable values for given prefix (uses directly given params, when available) * * @param string $prefix_special Index: branches/5.2.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15717 -r15805 --- branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15717) +++ branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15805) @@ -1,6 +1,6 @@
||
- ##-->*/ $comment_end = strpos($template_data, '##-->'); @@ -442,36 +441,21 @@ return Array (); } - $ret = Array (); $comment = trim( substr($template_data, 6, $comment_end - 6) ); - $allowed_settings = Array ('name', 'desc', 'section', 'section_aware'); + 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]); + } - $meta_info = simplexml_load_string('' . $comment . ''); - /* @var $meta_info SimpleXMLElement[] */ - - if ( $meta_info === false ) { - // Malformed XML. SimpleXML will print an error itself. - return Array (); - } - - foreach ($meta_info as $setting) { - $setting_name = strtolower($setting->getName()); - - if ( !in_array($setting_name, $allowed_settings) ) { - trigger_error('Setting "' . $setting_name . '" not supported in "' . $template_file . '" template', E_USER_WARNING); - continue; + 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); } - $ret[$setting_name] = trim($setting); + return $ret; } - - 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); - } - - return $ret; } return Array ();