Index: trunk/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r4792 -r4806 --- trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4792) +++ trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4806) @@ -93,12 +93,19 @@ $this->HTTPQuery->Set('m_cat_page', $rets[2]); } - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE NamedParentPath = '.$this->Conn->qstr($category_path); - array_push($category_stack, $this->Conn->GetOne($sql) ); + 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) ); + } + $category_found = end($category_stack); - if($category_found) $url_part = array_shift($url_parts); + if ($category_found !== false) $url_part = array_shift($url_parts); }while ($category_found && $url_part); @@ -108,7 +115,7 @@ { $category_id = array_pop($category_stack); } - if($category_id) + if($category_id !== false) { $this->HTTPQuery->Set('m_cat_id', $category_id); } Index: trunk/kernel/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r4792 -r4806 --- trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4792) +++ trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4806) @@ -93,12 +93,19 @@ $this->HTTPQuery->Set('m_cat_page', $rets[2]); } - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE NamedParentPath = '.$this->Conn->qstr($category_path); - array_push($category_stack, $this->Conn->GetOne($sql) ); + 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) ); + } + $category_found = end($category_stack); - if($category_found) $url_part = array_shift($url_parts); + if ($category_found !== false) $url_part = array_shift($url_parts); }while ($category_found && $url_part); @@ -108,7 +115,7 @@ { $category_id = array_pop($category_stack); } - if($category_id) + if($category_id !== false) { $this->HTTPQuery->Set('m_cat_id', $category_id); } Index: trunk/core/units/categories/categories_item.php =================================================================== diff -u -N -r4758 -r4806 --- trunk/core/units/categories/categories_item.php (.../categories_item.php) (revision 4758) +++ trunk/core/units/categories/categories_item.php (.../categories_item.php) (revision 4806) @@ -2,31 +2,21 @@ class CategoriesItem extends kDBItem { - /** - * Use automatic filename generation - * - * @var bool - */ - var $useFilenames = true; - - function Create() + function Create($force_id=false, $system_create=false) { if (!$this->Validate()) return false; $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('CreatedById', $this->Application->GetVar('u_id') ); $this->SetDBField('CreatedOn_date', adodb_mktime() ); $this->SetDBField('CreatedOn_time', adodb_mktime() ); + + $this->checkFilename(); + $this->generateFilename(); - if ($this->useFilenames) { - $this->checkFilename(); - $this->generateFilename(); - } - $this->SetDBField('ParentId', $this->Application->GetVar('m_cat_id') ); - $ret = parent::Create(); - if($ret) - { + $ret = parent::Create($force_id, $system_create); + if ($ret) { $sql = 'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s'; $parent_path = $this->buildParentPath(); $this->Conn->Query( sprintf($sql, $this->TableName, $this->Conn->qstr($parent_path), $this->GetID() ) ); @@ -39,10 +29,9 @@ function Update($id=null, $system_update=false) { - if ($this->useFilenames) { - $this->checkFilename(); - $this->generateFilename(); - } + $this->checkFilename(); + $this->generateFilename(); + $ret = parent::Update($id, $system_update); return $ret; } @@ -61,11 +50,11 @@ } /** - * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result - * - * @param string $string - * @return string - */ + * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result + * + * @param string $string + * @return string + */ function stripDisallowed($string) { $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', @@ -133,10 +122,10 @@ } /** - * Generate item's filename based on it's title field value - * - * @return string - */ + * Generate item's filename based on it's title field value + * + * @return string + */ function generateFilename() { if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false; Index: trunk/kernel/units/categories/categories_item.php =================================================================== diff -u -N -r4758 -r4806 --- trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 4758) +++ trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 4806) @@ -2,31 +2,21 @@ class CategoriesItem extends kDBItem { - /** - * Use automatic filename generation - * - * @var bool - */ - var $useFilenames = true; - - function Create() + function Create($force_id=false, $system_create=false) { if (!$this->Validate()) return false; $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('CreatedById', $this->Application->GetVar('u_id') ); $this->SetDBField('CreatedOn_date', adodb_mktime() ); $this->SetDBField('CreatedOn_time', adodb_mktime() ); + + $this->checkFilename(); + $this->generateFilename(); - if ($this->useFilenames) { - $this->checkFilename(); - $this->generateFilename(); - } - $this->SetDBField('ParentId', $this->Application->GetVar('m_cat_id') ); - $ret = parent::Create(); - if($ret) - { + $ret = parent::Create($force_id, $system_create); + if ($ret) { $sql = 'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s'; $parent_path = $this->buildParentPath(); $this->Conn->Query( sprintf($sql, $this->TableName, $this->Conn->qstr($parent_path), $this->GetID() ) ); @@ -39,10 +29,9 @@ function Update($id=null, $system_update=false) { - if ($this->useFilenames) { - $this->checkFilename(); - $this->generateFilename(); - } + $this->checkFilename(); + $this->generateFilename(); + $ret = parent::Update($id, $system_update); return $ret; } @@ -61,11 +50,11 @@ } /** - * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result - * - * @param string $string - * @return string - */ + * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result + * + * @param string $string + * @return string + */ function stripDisallowed($string) { $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', @@ -133,10 +122,10 @@ } /** - * Generate item's filename based on it's title field value - * - * @return string - */ + * Generate item's filename based on it's title field value + * + * @return string + */ function generateFilename() { if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false;