Index: branches/5.2.x/core/units/helpers/recursive_helper.php =================================================================== diff -u -r14244 -r14628 --- branches/5.2.x/core/units/helpers/recursive_helper.php (.../recursive_helper.php) (revision 14244) +++ branches/5.2.x/core/units/helpers/recursive_helper.php (.../recursive_helper.php) (revision 14628) @@ -1,6 +1,6 @@ Conn->Query($sql); $temp_handler =& $this->Application->recallObject($prefix.'_TempHandler', 'kTempTablesHandler'); - + /* @var $temp_handler kTempTablesHandler */ + // 2. delete items this have this category as primary $delete_ids = $this->getCategoryItems($category_id, true); @@ -106,9 +107,10 @@ } /** - * Complete cloning or category with subcategories and subitems + * Complete cloning or category with subcategories and sub-items * * @param int $category_id + * @param string $prefix */ function PasteCategory($category_id, $prefix = 'c') { @@ -117,16 +119,16 @@ $src_parent_path = $this->_getParentPath($category_id); $dst_parent_path = $this->_getParentPath($backup_category_id); - if (substr($dst_parent_path, 0, strlen($src_parent_path)) == $src_parent_path) { + if ( substr($dst_parent_path, 0, strlen($src_parent_path)) == $src_parent_path ) { // target path contains source path -> recursion - return ; + return; } // 1. clone category - $temp_handler =& $this->Application->recallObject($prefix.'_TempHandler', 'kTempTablesHandler'); + $temp_handler =& $this->Application->recallObject($prefix . '_TempHandler', 'kTempTablesHandler'); /* @var $temp_handler kTempTablesHandler*/ - $temp_handler->BuildTables($prefix, Array($category_id)); - $new_category_id = array_pop( $temp_handler->CloneItems($prefix, '', Array($category_id)) ); + $temp_handler->BuildTables($prefix, Array ($category_id)); + $new_category_id = array_pop($temp_handler->CloneItems($prefix, '', Array ($category_id))); $this->Application->SetVar('m_cat_id', $new_category_id); $id_field = $this->Application->getUnitOption($prefix, 'IDField'); @@ -136,12 +138,14 @@ $paste_ids = $this->getCategoryItems($category_id, false); foreach ($paste_ids as $item_prefix => $resource_ids) { - if (!$item_prefix) { + if ( !$item_prefix ) { // not ItemPrefix filled -> old categoryitem linking continue; } - $item_object =& $this->Application->recallObject($item_prefix.'.-item', null, Array('skip_autoload' => true)); + $item_object =& $this->Application->recallObject($item_prefix . '.-item', null, Array ('skip_autoload' => true)); + /* @var $item_object kCatDBItem */ + foreach ($resource_ids as $item_resource_id) { $item_object->Load($item_resource_id, 'ResourceId'); $item_object->assignToCategory($new_category_id, false); @@ -152,7 +156,7 @@ $paste_ids = $this->getCategoryItems($category_id, true); foreach ($paste_ids as $item_prefix => $resource_ids) { - if (!$item_prefix) { + if ( !$item_prefix ) { // not ItemPrefix filled -> old categoryitem linking continue; } @@ -164,12 +168,12 @@ } // 4. do same stuff for each subcategory - $sql = 'SELECT '.$id_field.' - FROM '.$table_name.' - WHERE ParentId = '.$category_id; + $sql = 'SELECT ' . $id_field . ' + FROM ' . $table_name . ' + WHERE ParentId = ' . $category_id; $sub_categories = $this->Conn->GetCol($sql); - if ($sub_categories) { + if ( $sub_categories ) { foreach ($sub_categories as $sub_category_id) { $this->PasteCategory($sub_category_id, $prefix); }