function recursionAddMenuItem($parent = 0, $values, $new_parent = 0) { //skopirovanie menu $sourceMenu = dibi::fetchAll("SELECT * FROM [menu_item] WHERE lang = %s", $values['sourceLang'], "AND parent = %i", $parent, "ORDER BY sequence"); foreach ($sourceMenu as $sm) { $tmp_id_menu_item = $sm['id_menu_item']; unset($sm['id_menu_item']); $sm['parent'] = $new_parent; $menuInstance = new MenuItem($sm['id_menu'], $values['destLang']); $dest_new_parent = $menuInstance->AddItemToSql($sm); $id_file_node = FilesNode::getFileNode('menu', $tmp_id_menu_item); if ($id_file_node) { FilesNode::copyTo($id_file_node, 'menu', $dest_new_parent); } self::duplicateNode($tmp_id_menu_item, $dest_new_parent); self::recursionAddMenuItem($tmp_id_menu_item, $values, $dest_new_parent); unset($menuInstance); } }
public static function duplicate($id_node, $new_id_node) { // nacitanie, co ma skopirovat $values = dibi::fetch("SELECT * FROM [module_product] WHERE id_node = %i", $id_node); //vytvorenie self::add($new_id_node); self::saveProduct($values, $new_id_node); $id_file_node = FilesNode::getFileNode(self::MODULE_NAME, $id_node); if ($id_file_node) { FilesNode::copyTo($id_file_node, self::MODULE_NAME, $new_id_node); } }