/** * @return obj|boolen new cat object or false */ function ©($target_idcat, $title = '', $options = array()) { global $cfg_cms, $perm; //option values are: default, yes, no //special: 'set_startflag': if_first //'set_online' (default|yes|no) default is copy flag from source //'set_copy' (default|yes|no) default is copy flag from source //'set_startflag' (default|from_source) default set the startflag if page in category haven't a valid startpage, // from_source copys flag from source //'perms' bool (true|false) $options_default = array('set_online' => 'default', 'set_protected' => 'default', 'set_startflag' => 'from_source', 'perms' => true); $options = array_merge($options_default, $options); $target_idcat = (int) $target_idcat; $return = false; if ($target_idcat < 0) { return $return; } $catinfos = sf_factoryGetObjectCache('PAGE', 'Catinfos'); //copy rootcat $cat_copy = sf_factoryGetObject('PAGE', 'Cat'); $cat_copy->data = $this->data; $cat_copy->data['sql']['cat_lang']['idcatlang'] = false; $cat_copy->data['sql']['cat_lang']['idcat'] = false; $cat_copy->data['sql']['cat']['idcat'] = false; $cat_copy->data['sql']['cat']['parent'] = $target_idcat; $cat_copy->data['sql']['cat']['sortindex'] = false; //name if ($title != '') { $cat_copy->data['sql']['cat_lang']['name'] = $title; } else { $title = $cat_copy->data['sql']['cat_lang']['name']; } //online $visible = $cat_copy->data['sql']['cat_lang']['visible']; //print_r($options); //echo $visible.'<br>'; if ($options['set_online'] == 'yes') { $visible = $visible | 0x1; } else { if ($options['set_online'] == 'no') { $visible = $visible & 0xfe; } } //echo $visible.'<br>'; //protected if ($options['set_protected'] == 'yes') { $visible = $visible | 0x4; } else { if ($options['set_protected'] == 'no') { $visible = $visible & 0xfb; } } $cat_copy->data['sql']['cat_lang']['visible'] = $visible; //set langprefix on other langs then the default lang $cat_copy->_set_langprefix_on_save_if_new = true; $cat_copy->dirty = true; $cat_copy->save(); //copy templates $copy_idtplconf = $this->_copyTemplateConfig($this->getIdcat(), $cat_copy->getIdcat()); //echo "$target_idcat $title";exit; $cat_copy->data['sql']['cat_lang']['idtplconf'] = $copy_idtplconf; $cat_copy->dirty = true; //rewrite url include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . "inc/fnc.mod_rewrite.php"; rewriteGenerateMapping(); $rewrite_url = rewriteGenerateUrlString($title); $rewrite_url = rewriteMakeUniqueStringForLang('idcat', $cat_copy->getIdcat(), $rewrite_url, '', $cat_copy->getParent()); $cat_copy->data['sql']['cat_lang']['rewrite_use_automatic'] = 1; $cat_copy->data['sql']['cat_lang']['rewrite_alias'] = $rewrite_url; $cat_copy->save(); //copy rootcat perms if ($options['perms']) { $arr_langs = $this->_getLangInfoArray(); foreach ($arr_langs['order'] as $current_lang) { $perm->xcopy_perm($this->getIdcat(), 'cat', $cat_copy->getIdcat(), 'cat', 4294967295.0, 0, $current_lang, false); $perm->xcopy_perm($this->getIdcat(), 'frontendcat', $cat_copy->getIdcat(), 'frontendcat', 4294967295.0, 0, $current_lang, false); } } //copy pages of rotcat include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . "inc/fnc.con.php"; $arr_idcatsides = $this->_getIdcatsides($this->getIdcat()); foreach ($arr_idcatsides as $v) { //echo '<br>---X'.$cat_copy->getIdcat(); con_copy_page($this->_getIdclient(), $this->getIdlang(), $v, '', $cat_copy->getIdcat(), $options['perms'], $options); } //copy childcats $cattree = sf_factoryGetObjectCache('PAGE', 'Cattree'); $cattree->setIdclient($this->_getIdclient()); $cattree->generate(); $this_idcat = $this->getIdcat(); $new_parent = $cat_copy->getIdcat(); $arr_childs = $cattree->getChilds($this_idcat); //print_r($arr_childs); foreach ($arr_childs as $v) { $cat_child = sf_factoryGetObject('PAGE', 'Cat'); if ($cat_child->loadByIdcatIdlang($v, $this->getIdlang())) { $cat_child->copy($new_parent, '', $options); } } return $cat_copy; }
$idside_from = $db->f('idside'); $sortindex_from = $db->f('sortindex'); } else { header('Location:' . $sess->url("main.php?area=con")); exit; } $sql = "SELECT * FROM " . $cms_db['side_lang'] . " WHERE idside='{$idside_from}' AND idlang='{$lang}'"; $db->query($sql); if ($db->next_record()) { $title_from = $db->f('title'); } // Seitenkonfiguration speichern switch ($action) { case 'save': $title = empty($title) ? 'Kopie von ' . $title_from : $title; $idcatside = con_copy_page($client, $lang, $idcatside, $title, -1, true, array('set_online' => 'no')); con_delete_cache($lang); if (isset($_POST['sf_apply'])) { $sql = "SELECT idside, {$idcat} FROM " . $cms_db['cat_side'] . " WHERE idcatside='{$idcatside}'"; $db->query($sql); $db->next_record(); $idside = $db->f('idside'); $idcat = $db->f('idcat'); $sql = "SELECT\n\t\t\t\t\tSL.idtplconf\n\t\t\t\tFROM \n\t\t\t\t\t" . $cms_db['side_lang'] . " SL\n\t\t\t\tWHERE\n\t\t\t\t\tSL.idlang='{$lang}'\n\t\t\t\t\tAND SL.idside = '{$idside}'"; $db->query($sql); $db->next_record(); $idtplconf = $db->f('idtplconf'); header('Location:' . $sess->urlRaw("main.php?area=con_configside&idside={$idside}&idcat={$idcat}&idcatside={$idcatside}&idtplconf={$idtplconf}")); } else { header('Location:' . $sess->urlRaw("main.php?area=con&idactside={$idcatside}&idcat={$idcat}#sideanchor")); }