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); }
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->setValue("erstelldatum", date("Ymd")); if ($category_id != "") { $sql = new sql(); $sql->setQuery("select template_id from rex_article where category_id={$category_id} and startpage=1"); if ($sql->getRows() == 1) { $AART->setValue("template_id", $sql->getValue("template_id")); } else { $AART->setValue("template_id", 0); } } else { $AART->setValue("template_id", 0); } $AART->insert(); $sql = new sql(); $sql->order_position($Position_New_Category, $AKAT->last_insert_id, "id", "rex_category", "prior", "re_category_id", $category_id); generateCategory($AKAT->last_insert_id); generateArticle($AART->last_insert_id); } // --------------------------------------------- article functions if ($function == "offline_article" && $STRUCTURE_PERM) { $amessage = $I18N->msg("article_status_updated"); $KAT->query("update rex_article set status='0' where id='{$article_id}'"); generateArticle($article_id); } if ($function == "online_article" && $STRUCTURE_PERM) { $amessage = $I18N->msg("article_status_updated"); $KAT->query("update rex_article set status='1' where id='{$article_id}'"); generateArticle($article_id); } if ($function == "edit_article" && ($STRUCTURE_PERM || $REX_USER->isValueOf("rights", "article[{$article_id}]"))) { $amessage = $I18N->msg("article_updated");
// ----------------------------------------------------------- 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); for ($j = 1; $j < 11; $j++) { $LC = new sql(); // $LC->debugsql = 1; $LC->setQuery("select rex_article_slice.article_id,rex_article_slice.id from rex_article_slice\r\n\t\t\t\tleft join rex_article on rex_article_slice.link{$j}=rex_article.id\r\n\t\t\t\twhere\r\n\t\t\t\trex_article_slice.link{$j}>0 and rex_article.id IS NULL"); for ($i = 0; $i < $LC->getRows(); $i++) { $LART[$LC->getValue("rex_article_slice.article_id")] = 1; $LSLI[$LC->getValue("rex_article_slice.article_id")] = $LC->getValue("rex_article_slice.id"); $LC->next(); }
function generateCategory($parentId = 0, $subCategsRows = array()) { global $db; global $pathBuilder; $sql = CMD_SEL_CATEGORIES; $params = array($parentId); $rows =& $db->getAll($sql, $params, DB_FETCHMODE_OBJECT); if (PEAR::isError($rows)) { print $rows->getMessage() . "\n"; return; } print "Generate for " . $parentId . "...\n"; // Сгенерировать блок - "путь к категории" $pathBuilder->build($parentId); FileUtils::mkDirRecursive(OUTPUT_DIR . "/" . $pathBuilder->pathFile); if ($parentId == 0) { $indexRows =& $db->getAll(CMD_SEL_FIRSTCATEGORIES, array(), DB_FETCHMODE_OBJECT); if (PEAR::isError($indexRows)) { print $rows->getMessage() . "\n"; return; } generateIndexFile($indexRows); } else { if (sizeof($rows) > 0) { generateRubricatorFile($rows, $parentId, $pathBuilder->pathFile); } else { generateCatalogFiles($parentId, $pathBuilder->pathFile, $subCategsRows); } /* // Сгенерировать блок - "список категорий" saveContents(OUTPUT_DIR . "/" . $pathBuilder->pathFile . "/categs.html", getCategoriesCode($rows)); */ } // Обработка дочерних разделов foreach ($rows as $row) { generateCategory($row->id, $rows); } }
/** * Генерирование всего каталога */ function generateCatalog($rootNode) { if (!$rootNode->has_child_nodes()) { return; } $chNodes = $rootNode->child_nodes(); for ($i = 0; $i < sizeof($chNodes); $i++) { if ($chNodes[$i]->node_type() != XML_ELEMENT_NODE) { continue; } if (getCategoryData($chNodes[$i]) != null) { generateCategory($chNodes[$i]); } generateCatalog($chNodes[$i]); } }