function copyArticle($id, $to_cat_id) { ## ### make new path ## $get_parent_cat = new sql(); $get_parent_cat->setQuery("SELECT path FROM rex_category WHERE id={$to_cat_id}"); $path = $get_parent_cat->getValue("path") . "-" . $to_cat_id; ## ### check if article is firstarticle in the new category ## $get_cat = new sql(); $get_cat->setQuery("SELECT count(*) FROM rex_article WHERE category_id={$to_cat_id}"); if ($get_cat->getValue("count(*)") == 0) { $startarticle = 1; } else { $startarticle = 0; } ## ### copy article ## $get_article = new sql(); $get_article->setQuery("SELECT * FROM rex_article WHERE id={$id}"); $get_article_fields = new sql(); $get_article_fields->setQuery("DESCRIBE rex_article"); $add_article = new sql(); $order_id = $add_article->new_order("rex_article", "prior", "category_id", $to_cat_id); $add_article->setTable("rex_article"); $add_article->setValue('prior', $order_id); for ($i = 0; $i < $get_article_fields->rows; $i++, $get_article_fields->next()) { if ($get_article_fields->getValue("Field") == 'prior') { continue; } if ($get_article_fields->getValue("Field") == "category_id") { $add_article->setValue(category_id, $to_cat_id); } elseif ($get_article_fields->getValue("Field") == "path") { $add_article->setValue(path, $path); } elseif ($get_article_fields->getValue("Field") == "startpage") { $add_article->setValue(startpage, $startarticle); } elseif ($get_article_fields->getValue("Field") != "id") { $add_article->setValue($get_article_fields->getValue("Field"), $get_article->getValue($get_article_fields->getValue("Field"))); } } //$add_article->debugsql=true; $add_article->insert(); $last_id = $add_article->last_insert_id; ## ### copy slices ## $get_slices = new sql(); $get_slices->setQuery("SELECT * FROM rex_article_slice WHERE article_id={$id} ORDER BY re_article_slice_id"); $get_slice_fields = new sql(); $get_slice_fields->setQuery("DESCRIBE rex_article_slice"); $parent_slice = 0; $preparent_slice = 0; // hack: max 100 slices pro article -- noch zu verbessern for ($k = 0; $k < 100; $k++) { $get_slices->counter = 0; for ($i = 0; $i < $get_slices->getRows(); $i++, $get_slices->next()) { if ($preparent_slice == $get_slices->getValue("re_article_slice_id")) { break; } } if ($i >= $get_slices->rows) { break; } $preparent_slice = $get_slices->getValue("id"); // $get_slices-> OBJ mit entsprechenden id $add_new_slice = new sql(); $add_new_slice->setTable("rex_article_slice"); for ($j = 0; $j < $get_slice_fields->rows; $j++, $get_slice_fields->next()) { if ($get_slice_fields->getValue("Field") == "re_article_slice_id") { $add_new_slice->setValue(re_article_slice_id, $parent_slice); } elseif ($get_slice_fields->getValue("Field") == "article_id") { $add_new_slice->setValue(article_id, $last_id); } elseif ($get_slice_fields->getValue("Field") != "id") { $add_new_slice->setValue($get_slice_fields->getValue("Field"), $get_slices->getValue($get_slice_fields->getValue("Field"))); } } // $add_new_slice->debugsql=true; $add_new_slice->insert(); $get_slice_fields->counter = 0; $parent_slice = $add_new_slice->last_insert_id; } // article neu generieren generateArticle($last_id); // catgegoy neu generieren generateCategory($to_cat_id); }
} else { $modultyp->query("insert into rex_modultyp (category_id,name,eingabe,ausgabe) VALUES ('{$category_id}','{$name}','{$eingabe}','{$ausgabe}')"); } $message = "<p class=warning>" . $I18N->msg("module_added") . "</p>"; } else { if ($REX[BARRIEREFREI]) { $modultyp->query("update rex_modultyp set name='{$name}',eingabe='{$eingabe}',ausgabe='{$ausgabe}',bausgabe='{$bausgabe}',php_enable='{$php_enable}',html_enable='{$html_enable}' where id='{$modul_id}'"); } else { $modultyp->query("update rex_modultyp set name='{$name}',eingabe='{$eingabe}',ausgabe='{$ausgabe}',php_enable='{$php_enable}',html_enable='{$html_enable}' where id='{$modul_id}'"); } $message = "<p class=warning>" . $I18N->msg("module_updated") . " | " . $I18N->msg("articel_updated") . "</font></p>"; // article updaten $gc = new sql(); $gc->setQuery("select distinct(rex_article.id) from rex_article \r\n\t\t\t\t\tleft join rex_article_slice on rex_article.id=rex_article_slice.article_id \r\n\t\t\t\t\twhere rex_article_slice.modultyp_id='{$modul_id}'"); for ($i = 0; $i < $gc->getRows(); $i++) { generateArticle($gc->getValue("rex_article.id")); $gc->next(); } } if ($goon != "") { $save = "nein"; } else { $function = ""; } } if ($save != "ja") { echo "<a name=edit><table border=0 cellpadding=5 cellspacing=1 width=770>"; if ($function == "edit") { echo "\t<tr><th colspan=3 align=left>" . $I18N->msg("module_edit") . "</th></tr>"; $hole = new sql(); $hole->setQuery("select * from rex_modultyp where id='{$modul_id}'");
function generateAll() { global $REX, $I18N; // ----------------------------------------------------------- generiere templates deleteDir($REX[INCLUDE_PATH] . "/generated/templates", 0); // mkdir($REX[INCLUDE_PATH]."/generated/templates",0664); $gt = new sql(); $gt->setQuery("select * from rex_template"); for ($i = 0; $i < $gt->getRows(); $i++) { $fp = fopen($REX[INCLUDE_PATH] . "/generated/templates/" . $gt->getValue("rex_template.id") . ".template", "w"); fputs($fp, $gt->getValue("rex_template.content")); fclose($fp); $gt->next(); } // ----------------------------------------------------------- generiere artikel deleteDir($REX[INCLUDE_PATH] . "/generated/articles", 0); // mkdir($REX[INCLUDE_PATH]."/generated/articles",0664); $gc = new sql(); $gc->setQuery("select * from rex_article"); for ($i = 0; $i < $gc->getRows(); $i++) { generateArticle($gc->getValue("id")); $gc->next(); } // ----------------------------------------------------------- generiere categorien deleteDir($REX[INCLUDE_PATH] . "/generated/categories", 0); // mkdir($REX[INCLUDE_PATH]."/generated/categories",0664); $gcc = new sql(); $gcc->setQuery("select * from rex_category"); for ($i = 0; $i < $gcc->getRows(); $i++) { generateCategory($gcc->getValue("id")); $gcc->next(); } // generateCategories(); $MSG = $I18N->msg('articles_generated') . " " . $I18N->msg('old_articles_deleted'); return $MSG; }
$AART->setTable("rex_article"); $AART->setValue("name", $article_name); $AART->setValue("category_id", $category_id); $AART->setValue("prior", $article_prior); $AART->setValue("path", $KATSQLpath); $AART->setValue("startpage", 0); $AART->setValue("status", 0); $AART->setValue("online_von", date("YmdHis")); $AART->setValue("online_bis", "20100101"); $AART->setValue("erstelldatum", date("Ymd")); $AART->setValue("template_id", $template_id); $AART->insert(); // now set right position $sql = new sql(); $sql->order_position($Position_New_Article, $AART->last_insert_id, "id", "rex_article", "prior", "category_id", $category_id); generateArticle($AART->last_insert_id); } // --------------------------------------------- category pfad // echo "-".$path."-"; // --------------------------------------------- category list if ($KATebene < $KatMaxEbenen && ($REX_USER->isValueOf("rights", "structure[all]") || $STRUCTURE_PERM)) { $addc = "<a href=index.php?page=structure&category_id={$category_id}&function=add_cat><img src=pics/folder_plus.gif width=16 height=16 border=0 alt=\"" . $I18N->msg("add_category") . "\"></a>"; } else { $addc = " "; } echo "<table border=0 cellpadding=5 cellspacing=1 width=770>\n\t<tr>\n\t\t<th width=30>{$addc}</th>\n\t\t<th align=left>" . $I18N->msg("header_category") . "</th>\n\t\t<th width=50 align=left>" . $I18N->msg("header_priority") . "</th>\n\t\t<th width=300 align=left>" . $I18N->msg("header_edit_category") . "</th>\n\t\t<th align=left width=153>" . $I18N->msg("header_status") . "</th>\n\t</tr>"; if ($message != "") { echo "<tr><td align=center class=warning><img src=pics/warning.gif width=16 height=16></td><td colspan=4 class=warning><b>{$message}</b></td></tr>"; } if ($category_id != 0) { echo "<tr><td class=grey> </td><td class=grey colspan=4><a href=index.php?page=structure&category_id={$re_category_id}>..</a></td></tr>";
$FILESQL->setTable("rex_file"); $FILESQL->setValue("filetype", ${$FILETYPE}); $FILESQL->setValue("filename", $NFILENAME); $FILESQL->setValue("originalname", ${$FILENAME}); $FILESQL->setValue("filesize", ${$FILESIZE}); $FILESQL->insert(); $meta_sql->setValue("file", $NFILENAME); } } elseif (${$FILEDEL} == "on") { $meta_sql->setValue("file", ''); } // ----------------------------- / FILE UPLOAD $meta_sql->update(); $article->setQuery("select * from rex_article where id='{$article_id}'"); $err_msg = $I18N->msg("metadata_updated") . $message; generateArticle($article_id); } $typesel = new select(); $typesel->set_name("type_id"); $typesel->set_style("width:100%;"); $typesel->set_size(1); $typesql = new sql(); $typesql->setQuery("select * from rex_article_type order by name"); for ($i = 0; $i < $typesql->getRows(); $i++) { $typesel->add_option($typesql->getValue("name"), $typesql->getValue("type_id")); $typesql->next(); } $typesel->set_selected($article->getValue("type_id")); if ($typesql->getRows() == 1) { $out = "<input type=hidden name=type_id value=1>"; } else {
// mkdir($REX[INCLUDE_PATH]."/generated/templates",0664); $gt = new sql(); $gt->setQuery("select * from rex_template"); for ($i = 0; $i < $gt->getRows(); $i++) { $fp = fopen($REX[INCLUDE_PATH] . "/generated/templates/" . $gt->getValue("rex_template.id") . ".template", "w"); fputs($fp, $gt->getValue("rex_template.content")); fclose($fp); $gt->next(); } // ----------------------------------------------------------- generiere artikel deleteDir($REX[INCLUDE_PATH] . "/generated/articles", 0); // mkdir($REX[INCLUDE_PATH]."/generated/articles",0664); $gc = new sql(); $gc->setQuery("select * from rex_article"); for ($i = 0; $i < $gc->getRows(); $i++) { generateArticle($gc->getValue("id")); $gc->next(); } // ----------------------------------------------------------- generiere categorien deleteDir($REX[INCLUDE_PATH] . "/generated/categories", 0); // mkdir($REX[INCLUDE_PATH]."/generated/categories",0664); $gcc = new sql(); $gcc->setQuery("select * from rex_category"); for ($i = 0; $i < $gcc->getRows(); $i++) { generateCategory($gcc->getValue("id")); $gcc->next(); } // generateCategories(); $MSG = $I18N->msg('articles_generated') . " " . $I18N->msg('old_articles_deleted'); } elseif ($func == "linkchecker") { unset($LART);
$AART->setTable("rex_article"); $AART->setValue("name", $article_name); $AART->setValue("category_id", $category_id); $AART->setValue("prior", $article_prior); $AART->setValue("path", $KATSQLpath); $AART->setValue("startpage", 0); $AART->setValue("status", 0); $AART->setValue("online_von", date("YmdHis")); $AART->setValue("online_bis", "20100101"); $AART->setValue("erstelldatum", date("Ymd")); $AART->setValue("template_id", $template_id); $AART->insert(); // now set right position $sql = new sql(); $sql->order_position($Position_New_Article, $AART->last_insert_id, "id", "rex_article", "prior", "category_id", $category_id); generateArticle($aid); } // --------------------------------------------- category pfad // echo "-".$path."-"; // --------------------------------------------- category list if ($KATebene < $KatMaxEbenen && ($REX_USER->isValueOf("rights", "structure[all]") || $STRUCTURE_PERM)) { $addc = "<a href=index.php?page=structure&category_id={$category_id}&function=add_cat><img src=pics/folder_plus.gif width=16 height=16 border=0></a>"; } else { $addc = " "; } echo "<table border=0 cellpadding=5 cellspacing=1 width=770>\r\n\t<tr>\r\n\t\t<th width=30>{$addc}</th>\r\n\t\t<th align=left>" . $I18N->msg("header_category") . "</th>\r\n\t\t<th width=50 align=left>" . $I18N->msg("header_priority") . "</th>\r\n\t\t<th width=300 align=left>" . $I18N->msg("header_edit_category") . "</th>\r\n\t\t<th align=left width=153>" . $I18N->msg("header_status") . "</th>\r\n\t</tr>"; if ($message != "") { echo "<tr><td align=center class=warning><img src=pics/warning.gif width=16 height=16></td><td colspan=4 class=warning><b>{$message}</b></td></tr>"; } if ($category_id != 0) { echo "<tr><td class=grey> </td><td class=grey colspan=4><a href=index.php?page=structure&category_id={$re_category_id}>..</a></td></tr>";