Index: trunk/admin/editor/FCKeditor/fckeditor.php =================================================================== diff -u -N -r2853 -r5558 --- trunk/admin/editor/FCKeditor/fckeditor.php (.../fckeditor.php) (revision 2853) +++ trunk/admin/editor/FCKeditor/fckeditor.php (.../fckeditor.php) (revision 5558) @@ -6,7 +6,7 @@ * Licensed under the terms of the GNU Lesser General Public License * (http://www.opensource.org/licenses/lgpl-license.php) * - * For further information go to http://www.fredck.com/FCKeditor/ + * For further information go to http://www.fredck.com/FCKeditor/ * or contact fckeditor@fredck.com. * * fckeditor.php: PHP pages integration. @@ -42,20 +42,20 @@ $this->CanUpload = 'none' ; $this->CanBrowse = 'none' ; } - + function CreateFCKeditor($instanceName, $width, $height) { echo $this->ReturnFCKeditor($instanceName, $width, $height) ; } - + function ReturnFCKeditor($instanceName, $width, $height) { // $grstr = htmlentities( $this->Value ) ; $grstr = htmlspecialchars( $this->Value ) ; $strEditor = "" ; - + if ( $this->IsCompatible() ) { global $FCKeditorBasePath ; @@ -87,10 +87,10 @@ { $strEditor .= "" ; } - + return $strEditor; } - + function IsCompatible() { $sAgent = $_SERVER['HTTP_USER_AGENT'] ; Index: trunk/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r5340 -r5558 --- trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5340) +++ trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5558) @@ -8,180 +8,278 @@ $this->HTTPQuery =& $this->Application->recallObject('HTTPQuery'); } - function processRewriteURL() + function SetDefaultValues() { - // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html - - $url = $this->HTTPQuery->Get('_mod_rw_url_'); - if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); - - $url_parts = $url ? explode('/', $url) : Array(); - - $process_module = true; - if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts) + $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); + foreach ($defaults as $default_key => $default_value) { - // set default values - $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); - foreach ($defaults as $default_key => $default_value) - { - if ($this->HTTPQuery->Get($default_key) == null) { - $this->HTTPQuery->Set($default_key, $default_value); - } + if ($this->HTTPQuery->Get($default_key) == null) { + $this->HTTPQuery->Set($default_key, $default_value); } } + } - if(!$url_parts) - { - $this->Application->Phrases = new PhrasesCache(); - $this->Application->VerifyLanguageId(); - $this->Application->Phrases->Init('phrases'); - $this->Application->VerifyThemeId(); - - $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') ); - $this->HTTPQuery->finalizeParsing(Array('m')); - return false; - } - else - { - $this->HTTPQuery->Set('t', ''); - } - + function ProcessLanguage(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; $url_part = array_shift($url_parts); - // match language $sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; $language_id = $this->Conn->GetOne($sql); $this->Application->Phrases = new PhrasesCache(); if($language_id) { $this->HTTPQuery->Set('m_lang', $language_id); - $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing + $res = true; } $this->Application->VerifyLanguageId(); + if (!$res) { + array_unshift($url_parts, $url_part); + } + return $res; + } - // $this->HTTPQuery->Get('m_lang') ); + function ProcessTheme(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; + $url_part = array_shift($url_parts); - // match theme - if($url_part) + $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; + $theme_id = $this->Conn->GetOne($sql); + if($theme_id) { - $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; - $theme_id = $this->Conn->GetOne($sql); - if($theme_id) - { - $this->HTTPQuery->Set('m_theme', $theme_id); - $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing - } + $this->HTTPQuery->Set('m_theme', $theme_id); + $res = true; } $this->Application->VerifyThemeId(); // verify anyway - will set default if not found!!! + if (!$res) { + array_unshift($url_parts, $url_part); + } + return $res; + } - // match category + function ProcessCategory(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; + $url_part = array_shift($url_parts); + $category_id = 0; - if($url_part) + $last_category_id = 0; + $category_path = ''; + do { - $category_stack = Array(); - $category_found = false; - $category_path = ''; - $rets = Array(); // just in case someone has used this variable before - do + $category_path = trim($category_path.'/'.$url_part, '/'); + + if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) { - $category_path = trim($category_path.'/'.$url_part, '/'); + $category_path = $rets[1]; + $this->HTTPQuery->Set('m_cat_page', $rets[2]); + } - if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) - { - $category_path = $rets[1]; - $this->HTTPQuery->Set('m_cat_page', $rets[2]); - } + $category_id = $this->Conn->GetOne( + 'SELECT CategoryId + FROM '.TABLE_PREFIX.'Category + WHERE NamedParentPath = '.$this->Conn->qstr($category_path)); + if ($category_id !== false) { + $last_category_id = $category_id; + $url_part = array_shift($url_parts); + $res = true; + } + } while ($category_id !== false && $url_part); + $this->HTTPQuery->Set('m_cat_id', $last_category_id); - if ($category_path == '') { - // this is "Home" virtual category - array_push($category_stack, 0); - } - else { - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE NamedParentPath = '.$this->Conn->qstr($category_path); - array_push($category_stack, $this->Conn->GetOne($sql) ); - } + if ($url_part) { + array_unshift($url_parts, $url_part); + } + return $res; + } - $category_found = end($category_stack); - if ($category_found !== false) $url_part = array_shift($url_parts); + function ProcessModuleIndex(&$url_parts) + { + if ( count($url_parts) != 0 ) return false; - }while ($category_found && $url_part); + $sql = 'SELECT CachedCategoryTemplate + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'); + $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate( $this->Conn->GetOne($sql) ) ); + return true; + } - if (count($category_stack)) { - $category_id = array_pop($category_stack); // remove last not found category - if($category_id === false) - { - $category_id = array_pop($category_stack); - } - if($category_id !== false) - { - $this->HTTPQuery->Set('m_cat_id', $category_id); - } - } - elseif (!$category_found && getArrayValue($rets, 2)) { + function ProcessModuleItem(&$url_parts) + { + if (!isset($url_parts[0])) return false; + if ( count($url_parts) != 1 ) return false; + $url_part = array_shift($url_parts); + + // match module reviews page + $page = 1; + if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) + { + $url_part = $rets[1]; + $page = $rets[2]; + } + + $cat_item = $this->Conn->GetRow(' + SELECT ci.ItemPrefix, c.ParentPath, ci.CategoryId FORM '.TABLE_PREFIX.'CategoryItems AS ci + LEFT JOIN '.TABLE_PREFIX.'Category AS c + ON c.CategoryId = ci.CategoryId + WHERE + CategoryId = '.$this->Application->GetVar('m_cat_id').' + AND + Filename = '.$this->Conn->qstr($url_part)); + if ($cat_item !== false) { + $module_prefix = $cat_item['ItemPrefix']; + $item_template = $category_data['CachedItemTemplate']; + if ($item_template) { + $url_parts = explode('/', $item_template); + array_push($url_parts, $url_part); // save item's filename as not processed $url_part = array_shift($url_parts); } + $this->Application->SetVar($cat_item['ItemPrefix'].'_id', $item_id); } - if (!$url_part) { - // no more parts left in url - $process_module = false; - $sql = 'SELECT CachedCategoryTemplate - FROM '.TABLE_PREFIX.'Category - WHERE CategoryId = '.$category_id; - $category_template = $this->Conn->GetOne($sql); - if ($category_template) { - $category_template = explode('/', $category_template); - $url_part = array_shift($category_template); - $url_parts = $category_template; + + $this->Application->SetVar( $event->getPrefixSpecial().'_Reviews_Page', $page); + + // only filename left, no other parts + $process_module = false; + $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'); + $category_data = $this->Conn->GetRow($sql); + + + + $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) ); + $module_info = $this->Application->findModule('RootCat', $root_category_id); + if ($module_info) { + $module_prefix = $module_info['Var']; + $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) ); + $this->Application->HandleEvent($module_event); + + if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) { + $item_template = $category_data['CachedItemTemplate']; + if ($item_template) { + $this->HTTPQuery->Set('t', $item_template ); + return true; + } } - else { - $url_part = 'index'; - } } - elseif ($url_part && count($url_parts) <= 1 && $category_id) { - // only filename left, no other parts - $process_module = false; - $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate - FROM '.TABLE_PREFIX.'Category - WHERE CategoryId = '.$category_id; - $category_data = $this->Conn->GetRow($sql); + array_unshift($url_parts, $url_part); + return false; + } - $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) ); - $module_info = $this->Application->findModule('RootCat', $root_category_id); - if ($module_info) { - $module_prefix = $module_info['Var']; - $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) ); - $this->Application->HandleEvent($module_event); + function ProcessPhisycalTemplate(&$url_parts) + { + if (!isset($url_parts[0])) return false; - if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) { - $item_template = $category_data['CachedItemTemplate']; - if ($item_template) { - $url_parts = explode('/', $item_template); - array_push($url_parts, $url_part); // save item's filename as not processed - $url_part = array_shift($url_parts); - } - } - elseif (!$module_event->getEventParam('url_parts')) { - // parseEnv has processed that param - $url_part = ''; - $category_template = $category_data['CachedCategoryTemplate']; - if ($category_template) { - $category_template = explode('/', $category_template); - $url_part = array_shift($category_template); - $url_parts = $category_template; - } - else { - $url_part = 'index'; - } - } + $remaining = array(); + do + { + $template_path = implode('/', $url_parts); + + $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path); + $t_parts['file'] = basename($template_path); + + $sql = 'SELECT FileId + FROM '.TABLE_PREFIX.'ThemeFiles + WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')'; + +// $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); + $template_found = $this->Conn->GetOne($sql); + if(!$template_found) + { + array_unshift($remaining, array_pop($url_parts)); } + } while (!$template_found && $url_parts); + + $url_parts = $remaining; + + if ($template_found) { + $this->HTTPQuery->Set('t', $template_path ); + return true; } + return false; + } - // match module + /** + * Checks if whole url_parts matches a whole In-CMS page + * + * @param array $url_parts + * @return boolean + */ + function ProcessVirtualTemplate(&$url_parts) + { + if (!isset($url_parts[0]) || !$this->Application->isModuleEnabled('In-CMS')) return false; + + $template_path = implode('/', $url_parts); + $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p + LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci + ON ci.ItemResourceId = p.ResourceId + WHERE + Path = '.$this->Conn->qstr($template_path).' + AND + ci.PrimaryCat = 1'; + $template_found = $this->Conn->GetRow($sql); + + if ($template_found) { + $this->Application->SetVar('m_cat_id', $template_found['CategoryId']); + $this->HTTPQuery->Set('t', $template_path ); + return true; + } + + return false; + } + + function processRewriteURL() + { + $url = $this->HTTPQuery->Get('_mod_rw_url_'); + if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); + $url_parts = $url ? explode('/', $url) : Array(); + + $process_module = true; + if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts) + { + $this->SetDefaultValues(); + } + + if(!$url_parts) + { + $this->Application->Phrases = new PhrasesCache(); + $this->Application->VerifyLanguageId(); + $this->Application->Phrases->Init('phrases'); + $this->Application->VerifyThemeId(); + + $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') ); + $this->HTTPQuery->finalizeParsing(Array('m')); + return false; + } + else + { + $this->HTTPQuery->Set('t', ''); + } + + $this->ProcessLanguage($url_parts); + $this->ProcessTheme($url_parts); + + if ( $this->ProcessVirtualTemplate($url_parts) ) { + return true; + } + + $this->ProcessCategory($url_parts); + if ( $this->ProcessModuleIndex($url_parts) ) { + return ; + } + if ( $this->ProcessModuleItem($url_parts) ) { + return ; + } + + /*// match module $next_template = $this->HTTPQuery->Get('next_template'); if($url_part || $next_template) { @@ -203,81 +301,14 @@ break; } } - } + }*/ - // match template - $template_path = ''; - $template_found = false; - if($url_part) - { - // search for template in real template records - array_unshift($url_parts, $url_part); - $template_parts = $url_parts; - $url_parts = Array(); - do - { - $template_path = implode('/', $template_parts); - - $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path); - $t_parts['file'] = basename($template_path); - - $sql = 'SELECT FileId - FROM '.TABLE_PREFIX.'ThemeFiles - WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')'; - - // $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); - $template_found = $this->Conn->GetOne($sql); - if(!$template_found) - { - array_unshift( $url_parts, array_pop($template_parts) ); - } - - }while (!$template_found && $template_parts); - - // try to find template in virtual templates in case if such ability exists - if ($this->Application->isModuleEnabled('In-CMS') && !$template_found) { - - $template_parts = $url_parts; - $url_parts = Array(); - do - { - $template_path = implode('/', $template_parts); - - $sql = 'SELECT PageId FROM '.TABLE_PREFIX.'Pages WHERE Path = '.$this->Conn->qstr($template_path); - $template_found = $this->Conn->GetOne($sql); - if(!$template_found) - { - array_unshift( $url_parts, array_pop($template_parts) ); - } - - }while (!$template_found && $template_parts); + if ( $this->ProcessPhisycalTemplate($url_parts) ) { + if (!$url_parts) { + return true; } } - // guess template if no existing template found - if(!$template_found && isset($module_folder) && $module_folder) - { - // 1. try index template of module - $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$module_folder.'/index.tpl'); - $template_found = $this->Conn->GetOne($sql); - if($template_found) - { - $template_path = $module_folder.'/index'; - array_shift($url_parts); - } - else - { - // 2. return error template then - $template_found = true; - $template_path = $this->Application->ConfigValue('ErrorTemplate'); - if(!$template_path) $template_path = 'error_notfound'; - - header('HTTP/1.0 404 Not Found'); - } - } - - $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate($template_found ? $template_path : '') ); - // pass params left to module $this->Application->Phrases->Init('phrases'); Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -N -r5514 -r5558 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5514) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5558) @@ -211,7 +211,9 @@ function stripDisallowed($filename) { $filenames_helper =& $this->Application->recallObject('FilenamesHelper'); - return $filenames_helper->stripDisallowed(TABLE_PREFIX.'CategoryItems', 'ItemResourceId', $this->GetDBField('ResourceId'), $filename); + $table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; + + return $filenames_helper->stripDisallowed($table, 'ItemResourceId', $this->GetDBField('ResourceId'), $filename); } /* commented out because it's called only from stripDisallowed body, which is moved to helper Index: trunk/kernel/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r5340 -r5558 --- trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5340) +++ trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5558) @@ -8,180 +8,278 @@ $this->HTTPQuery =& $this->Application->recallObject('HTTPQuery'); } - function processRewriteURL() + function SetDefaultValues() { - // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html - - $url = $this->HTTPQuery->Get('_mod_rw_url_'); - if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); - - $url_parts = $url ? explode('/', $url) : Array(); - - $process_module = true; - if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts) + $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); + foreach ($defaults as $default_key => $default_value) { - // set default values - $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); - foreach ($defaults as $default_key => $default_value) - { - if ($this->HTTPQuery->Get($default_key) == null) { - $this->HTTPQuery->Set($default_key, $default_value); - } + if ($this->HTTPQuery->Get($default_key) == null) { + $this->HTTPQuery->Set($default_key, $default_value); } } + } - if(!$url_parts) - { - $this->Application->Phrases = new PhrasesCache(); - $this->Application->VerifyLanguageId(); - $this->Application->Phrases->Init('phrases'); - $this->Application->VerifyThemeId(); - - $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') ); - $this->HTTPQuery->finalizeParsing(Array('m')); - return false; - } - else - { - $this->HTTPQuery->Set('t', ''); - } - + function ProcessLanguage(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; $url_part = array_shift($url_parts); - // match language $sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; $language_id = $this->Conn->GetOne($sql); $this->Application->Phrases = new PhrasesCache(); if($language_id) { $this->HTTPQuery->Set('m_lang', $language_id); - $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing + $res = true; } $this->Application->VerifyLanguageId(); + if (!$res) { + array_unshift($url_parts, $url_part); + } + return $res; + } - // $this->HTTPQuery->Get('m_lang') ); + function ProcessTheme(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; + $url_part = array_shift($url_parts); - // match theme - if($url_part) + $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; + $theme_id = $this->Conn->GetOne($sql); + if($theme_id) { - $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; - $theme_id = $this->Conn->GetOne($sql); - if($theme_id) - { - $this->HTTPQuery->Set('m_theme', $theme_id); - $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing - } + $this->HTTPQuery->Set('m_theme', $theme_id); + $res = true; } $this->Application->VerifyThemeId(); // verify anyway - will set default if not found!!! + if (!$res) { + array_unshift($url_parts, $url_part); + } + return $res; + } - // match category + function ProcessCategory(&$url_parts) + { + if (!isset($url_parts[0])) return false; + $res = false; + $url_part = array_shift($url_parts); + $category_id = 0; - if($url_part) + $last_category_id = 0; + $category_path = ''; + do { - $category_stack = Array(); - $category_found = false; - $category_path = ''; - $rets = Array(); // just in case someone has used this variable before - do + $category_path = trim($category_path.'/'.$url_part, '/'); + + if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) { - $category_path = trim($category_path.'/'.$url_part, '/'); + $category_path = $rets[1]; + $this->HTTPQuery->Set('m_cat_page', $rets[2]); + } - if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) - { - $category_path = $rets[1]; - $this->HTTPQuery->Set('m_cat_page', $rets[2]); - } + $category_id = $this->Conn->GetOne( + 'SELECT CategoryId + FROM '.TABLE_PREFIX.'Category + WHERE NamedParentPath = '.$this->Conn->qstr($category_path)); + if ($category_id !== false) { + $last_category_id = $category_id; + $url_part = array_shift($url_parts); + $res = true; + } + } while ($category_id !== false && $url_part); + $this->HTTPQuery->Set('m_cat_id', $last_category_id); - if ($category_path == '') { - // this is "Home" virtual category - array_push($category_stack, 0); - } - else { - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE NamedParentPath = '.$this->Conn->qstr($category_path); - array_push($category_stack, $this->Conn->GetOne($sql) ); - } + if ($url_part) { + array_unshift($url_parts, $url_part); + } + return $res; + } - $category_found = end($category_stack); - if ($category_found !== false) $url_part = array_shift($url_parts); + function ProcessModuleIndex(&$url_parts) + { + if ( count($url_parts) != 0 ) return false; - }while ($category_found && $url_part); + $sql = 'SELECT CachedCategoryTemplate + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'); + $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate( $this->Conn->GetOne($sql) ) ); + return true; + } - if (count($category_stack)) { - $category_id = array_pop($category_stack); // remove last not found category - if($category_id === false) - { - $category_id = array_pop($category_stack); - } - if($category_id !== false) - { - $this->HTTPQuery->Set('m_cat_id', $category_id); - } - } - elseif (!$category_found && getArrayValue($rets, 2)) { + function ProcessModuleItem(&$url_parts) + { + if (!isset($url_parts[0])) return false; + if ( count($url_parts) != 1 ) return false; + $url_part = array_shift($url_parts); + + // match module reviews page + $page = 1; + if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) + { + $url_part = $rets[1]; + $page = $rets[2]; + } + + $cat_item = $this->Conn->GetRow(' + SELECT ci.ItemPrefix, c.ParentPath, ci.CategoryId FORM '.TABLE_PREFIX.'CategoryItems AS ci + LEFT JOIN '.TABLE_PREFIX.'Category AS c + ON c.CategoryId = ci.CategoryId + WHERE + CategoryId = '.$this->Application->GetVar('m_cat_id').' + AND + Filename = '.$this->Conn->qstr($url_part)); + if ($cat_item !== false) { + $module_prefix = $cat_item['ItemPrefix']; + $item_template = $category_data['CachedItemTemplate']; + if ($item_template) { + $url_parts = explode('/', $item_template); + array_push($url_parts, $url_part); // save item's filename as not processed $url_part = array_shift($url_parts); } + $this->Application->SetVar($cat_item['ItemPrefix'].'_id', $item_id); } - if (!$url_part) { - // no more parts left in url - $process_module = false; - $sql = 'SELECT CachedCategoryTemplate - FROM '.TABLE_PREFIX.'Category - WHERE CategoryId = '.$category_id; - $category_template = $this->Conn->GetOne($sql); - if ($category_template) { - $category_template = explode('/', $category_template); - $url_part = array_shift($category_template); - $url_parts = $category_template; + + $this->Application->SetVar( $event->getPrefixSpecial().'_Reviews_Page', $page); + + // only filename left, no other parts + $process_module = false; + $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'); + $category_data = $this->Conn->GetRow($sql); + + + + $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) ); + $module_info = $this->Application->findModule('RootCat', $root_category_id); + if ($module_info) { + $module_prefix = $module_info['Var']; + $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) ); + $this->Application->HandleEvent($module_event); + + if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) { + $item_template = $category_data['CachedItemTemplate']; + if ($item_template) { + $this->HTTPQuery->Set('t', $item_template ); + return true; + } } - else { - $url_part = 'index'; - } } - elseif ($url_part && count($url_parts) <= 1 && $category_id) { - // only filename left, no other parts - $process_module = false; - $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate - FROM '.TABLE_PREFIX.'Category - WHERE CategoryId = '.$category_id; - $category_data = $this->Conn->GetRow($sql); + array_unshift($url_parts, $url_part); + return false; + } - $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) ); - $module_info = $this->Application->findModule('RootCat', $root_category_id); - if ($module_info) { - $module_prefix = $module_info['Var']; - $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) ); - $this->Application->HandleEvent($module_event); + function ProcessPhisycalTemplate(&$url_parts) + { + if (!isset($url_parts[0])) return false; - if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) { - $item_template = $category_data['CachedItemTemplate']; - if ($item_template) { - $url_parts = explode('/', $item_template); - array_push($url_parts, $url_part); // save item's filename as not processed - $url_part = array_shift($url_parts); - } - } - elseif (!$module_event->getEventParam('url_parts')) { - // parseEnv has processed that param - $url_part = ''; - $category_template = $category_data['CachedCategoryTemplate']; - if ($category_template) { - $category_template = explode('/', $category_template); - $url_part = array_shift($category_template); - $url_parts = $category_template; - } - else { - $url_part = 'index'; - } - } + $remaining = array(); + do + { + $template_path = implode('/', $url_parts); + + $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path); + $t_parts['file'] = basename($template_path); + + $sql = 'SELECT FileId + FROM '.TABLE_PREFIX.'ThemeFiles + WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')'; + +// $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); + $template_found = $this->Conn->GetOne($sql); + if(!$template_found) + { + array_unshift($remaining, array_pop($url_parts)); } + } while (!$template_found && $url_parts); + + $url_parts = $remaining; + + if ($template_found) { + $this->HTTPQuery->Set('t', $template_path ); + return true; } + return false; + } - // match module + /** + * Checks if whole url_parts matches a whole In-CMS page + * + * @param array $url_parts + * @return boolean + */ + function ProcessVirtualTemplate(&$url_parts) + { + if (!isset($url_parts[0]) || !$this->Application->isModuleEnabled('In-CMS')) return false; + + $template_path = implode('/', $url_parts); + $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p + LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci + ON ci.ItemResourceId = p.ResourceId + WHERE + Path = '.$this->Conn->qstr($template_path).' + AND + ci.PrimaryCat = 1'; + $template_found = $this->Conn->GetRow($sql); + + if ($template_found) { + $this->Application->SetVar('m_cat_id', $template_found['CategoryId']); + $this->HTTPQuery->Set('t', $template_path ); + return true; + } + + return false; + } + + function processRewriteURL() + { + $url = $this->HTTPQuery->Get('_mod_rw_url_'); + if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); + $url_parts = $url ? explode('/', $url) : Array(); + + $process_module = true; + if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts) + { + $this->SetDefaultValues(); + } + + if(!$url_parts) + { + $this->Application->Phrases = new PhrasesCache(); + $this->Application->VerifyLanguageId(); + $this->Application->Phrases->Init('phrases'); + $this->Application->VerifyThemeId(); + + $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') ); + $this->HTTPQuery->finalizeParsing(Array('m')); + return false; + } + else + { + $this->HTTPQuery->Set('t', ''); + } + + $this->ProcessLanguage($url_parts); + $this->ProcessTheme($url_parts); + + if ( $this->ProcessVirtualTemplate($url_parts) ) { + return true; + } + + $this->ProcessCategory($url_parts); + if ( $this->ProcessModuleIndex($url_parts) ) { + return ; + } + if ( $this->ProcessModuleItem($url_parts) ) { + return ; + } + + /*// match module $next_template = $this->HTTPQuery->Get('next_template'); if($url_part || $next_template) { @@ -203,81 +301,14 @@ break; } } - } + }*/ - // match template - $template_path = ''; - $template_found = false; - if($url_part) - { - // search for template in real template records - array_unshift($url_parts, $url_part); - $template_parts = $url_parts; - $url_parts = Array(); - do - { - $template_path = implode('/', $template_parts); - - $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path); - $t_parts['file'] = basename($template_path); - - $sql = 'SELECT FileId - FROM '.TABLE_PREFIX.'ThemeFiles - WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')'; - - // $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); - $template_found = $this->Conn->GetOne($sql); - if(!$template_found) - { - array_unshift( $url_parts, array_pop($template_parts) ); - } - - }while (!$template_found && $template_parts); - - // try to find template in virtual templates in case if such ability exists - if ($this->Application->isModuleEnabled('In-CMS') && !$template_found) { - - $template_parts = $url_parts; - $url_parts = Array(); - do - { - $template_path = implode('/', $template_parts); - - $sql = 'SELECT PageId FROM '.TABLE_PREFIX.'Pages WHERE Path = '.$this->Conn->qstr($template_path); - $template_found = $this->Conn->GetOne($sql); - if(!$template_found) - { - array_unshift( $url_parts, array_pop($template_parts) ); - } - - }while (!$template_found && $template_parts); + if ( $this->ProcessPhisycalTemplate($url_parts) ) { + if (!$url_parts) { + return true; } } - // guess template if no existing template found - if(!$template_found && isset($module_folder) && $module_folder) - { - // 1. try index template of module - $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$module_folder.'/index.tpl'); - $template_found = $this->Conn->GetOne($sql); - if($template_found) - { - $template_path = $module_folder.'/index'; - array_shift($url_parts); - } - else - { - // 2. return error template then - $template_found = true; - $template_path = $this->Application->ConfigValue('ErrorTemplate'); - if(!$template_path) $template_path = 'error_notfound'; - - header('HTTP/1.0 404 Not Found'); - } - } - - $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate($template_found ? $template_path : '') ); - // pass params left to module $this->Application->Phrases->Init('phrases'); Index: trunk/kernel/admin_templates/categories/categories_edit_properties.tpl =================================================================== diff -u -N -r5102 -r5558 --- trunk/kernel/admin_templates/categories/categories_edit_properties.tpl (.../categories_edit_properties.tpl) (revision 5102) +++ trunk/kernel/admin_templates/categories/categories_edit_properties.tpl (.../categories_edit_properties.tpl) (revision 5558) @@ -6,7 +6,7 @@ - + @@ -24,9 +24,9 @@ submit_event('c','OnCancelEdit'); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - + a_toolbar.AddButton( new ToolBarButton('prev', '', function() { go_to_id('c', ''); } @@ -35,21 +35,21 @@ go_to_id('c', ''); } ) ); - + a_toolbar.Render(); - + a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); a_toolbar.HideButton('sep1'); - + a_toolbar.DisableButton('next'); a_toolbar.DisableButton('prev'); - + @@ -58,7 +58,7 @@ - +
\ No newline at end of file Index: trunk/admin/editor/inp_fckconfig.js =================================================================== diff -u -N -r1759 -r5558 --- trunk/admin/editor/inp_fckconfig.js (.../inp_fckconfig.js) (revision 1759) +++ trunk/admin/editor/inp_fckconfig.js (.../inp_fckconfig.js) (revision 5558) @@ -2,27 +2,27 @@ * Edited by Kostja * FCKeditor - The text editor for internet * Copyright (C) 2003-2004 Frederico Caldeira Knabben - * + * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php - * + * * For further information visit: * http://www.fckeditor.net/ - * + * * File Name: fckconfig.js * Editor configuration settings. * See the documentation for more info. - * + * * Version: 2.0 RC3 * Modified: 2005-02-27 21:31:48 - * + * * File Authors: * Frederico Caldeira Knabben (fredck@fckeditor.net) */ -FCKConfig.CustomConfigurationsPath = '' ; +//FCKConfig.CustomConfigurationsPath = '' ; -//FCKConfig.EditorAreaCSS = FCKConfig.ProjectPath + 'themes/site/inc/style.css' ; +//FCKConfig.EditorAreaCSS = FCKConfig.ProjectPath + 'themes/inportal_site/inc/inportal.css' ; FCKConfig.BaseHref = '' ; @@ -42,22 +42,17 @@ FCKConfig.EnableXHTML = true ; FCKConfig.EnableSourceXHTML = true ; - FCKConfig.FillEmptyBlocks = true ; - FCKConfig.FormatSource = true ; FCKConfig.FormatOutput = true ; FCKConfig.FormatIndentator = ' ' ; - FCKConfig.GeckoUseSPAN = true ; FCKConfig.StartupFocus = false ; FCKConfig.ForcePasteAsPlainText = true ; FCKConfig.ForceSimpleAmpersand = false ; FCKConfig.TabSpaces = 0; - FCKConfig.ShowBorders = true; FCKConfig.ShowTableBorders = true; - FCKConfig.UseBROnCarriageReturn = false ; FCKConfig.ToolbarStartExpanded = true ; FCKConfig.ToolbarCanCollapse = true ; @@ -73,7 +68,6 @@ '/', ['Style','RemoveFormat'] ] ; - FCKConfig.ToolbarSets["Advanced"] = [ ['Cut','Copy','Paste','PasteText','PasteWord','-','NewPage','SelectAll','-','Find','Replace','-','Print','-','Link','Unlink','Anchor','Rule','-','Image','Document','Table','SpecialChar'], '/', @@ -85,44 +79,32 @@ FCKConfig.ToolbarSets["Basic"] = [ ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About'] ] ; - - FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Select','Document','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','TableCell','Table','Form'] ; - FCKConfig.FontColors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,808080,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF' ; - FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ; FCKConfig.FontSizes = '1/xx-small;2/x-small;3/small;4/medium;5/large;6/x-large;7/xx-large' ; FCKConfig.FontFormats = 'p;div;pre;address;h1;h2;h3;h4;h5;h6' ; - FCKConfig.StylesXmlPath = '../../inp_styles.xml' ; - FCKConfig.SpellChecker = 'ieSpell' ; // 'ieSpell' | 'SpellerPages' FCKConfig.IeSpellDownloadUrl = 'http://www.iespell.com/rel/ieSpellSetup211325.exe' ; - FCKConfig.LinkBrowser = true ; FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ; FCKConfig.LinkBrowserWindowWidth = screen.width * 0.7 ; // 70% FCKConfig.LinkBrowserWindowHeight = screen.height * 0.7 ; // 70% - FCKConfig.ImageBrowser = true ; FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Images&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ; FCKConfig.ImageBrowserWindowWidth = screen.width * 0.7 ; // 70% ; FCKConfig.ImageBrowserWindowHeight = screen.height * 0.7 ; // 70% ; - FCKConfig.DocumentBrowser = true ; FCKConfig.DocumentBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Documents&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ; FCKConfig.ImageBrowserWindowWidth = screen.width * 0.7 ; // 70% ; FCKConfig.ImageBrowserWindowHeight = screen.height * 0.7 ; // 70% ; FCKConfig.DocumentsServerPath = FCKConfig.ProjectPath+'kernel/user_files/Documents' - FCKConfig.StructureBrowser = true ; FCKConfig.StructureBrowserURL = FCKConfig.ProjectPath+'/admin/index.php?t=structure/tree' ; FCKConfig.StructureBrowserWindowWidth = screen.width * 0.5 ; // 50% FCKConfig.StructureBrowserWindowHeight = screen.height * 0.7 ; // 70% - FCKConfig.FilesBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Files&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files/' ; - FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ; FCKConfig.SmileyImages = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ; FCKConfig.SmileyColumns = 8 ; Index: trunk/kernel/units/general/cat_dbitem.php =================================================================== diff -u -N -r5514 -r5558 --- trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5514) +++ trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5558) @@ -211,7 +211,9 @@ function stripDisallowed($filename) { $filenames_helper =& $this->Application->recallObject('FilenamesHelper'); - return $filenames_helper->stripDisallowed(TABLE_PREFIX.'CategoryItems', 'ItemResourceId', $this->GetDBField('ResourceId'), $filename); + $table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; + + return $filenames_helper->stripDisallowed($table, 'ItemResourceId', $this->GetDBField('ResourceId'), $filename); } /* commented out because it's called only from stripDisallowed body, which is moved to helper Index: trunk/core/admin_templates/categories/categories_edit_properties.tpl =================================================================== diff -u -N -r5102 -r5558 --- trunk/core/admin_templates/categories/categories_edit_properties.tpl (.../categories_edit_properties.tpl) (revision 5102) +++ trunk/core/admin_templates/categories/categories_edit_properties.tpl (.../categories_edit_properties.tpl) (revision 5558) @@ -6,7 +6,7 @@ - + @@ -24,9 +24,9 @@ submit_event('c','OnCancelEdit'); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - + a_toolbar.AddButton( new ToolBarButton('prev', '', function() { go_to_id('c', ''); } @@ -35,21 +35,21 @@ go_to_id('c', ''); } ) ); - + a_toolbar.Render(); - + a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); a_toolbar.HideButton('sep1'); - + a_toolbar.DisableButton('next'); a_toolbar.DisableButton('prev'); - + @@ -58,7 +58,7 @@ - +
\ No newline at end of file Index: trunk/admin/editor/inp_styles.xml =================================================================== diff -u -N -r1735 -r5558 --- trunk/admin/editor/inp_styles.xml (.../inp_styles.xml) (revision 1735) +++ trunk/admin/editor/inp_styles.xml (.../inp_styles.xml) (revision 5558) @@ -2,26 +2,26 @@ +