function HandleItemFirstInfo() { global $db; if (!isset($_REQUEST["nodeType"])) { return; } if ($_REQUEST["nodeType"] != NODE_SITE_ITEM) { return; } // Вывод инфы для элемента источника $sql = "SELECT * FROM items WHERE id = ?"; $row =& $db->getRow($sql, array($_REQUEST["nodeId"]), DB_FETCHMODE_OBJECT); if (PEAR::isError($row)) { printError($row); exit; } $ITEM_ID = $_REQUEST["nodeId"]; $NOEDIT = true; $FIELDS = getViewFields($row->category_id); include "tpls/InfoItem.php"; }
function HandleItemInfo() { global $db; if (isset($_REQUEST["nodeType"])) { if ($_REQUEST["nodeType"] == NODE_SITE_CATEGORY) { // Вывод инфы для категории источника $sql = "SELECT * FROM site_categories WHERE id = ?"; $row =& $db->getRow($sql, array($_REQUEST["nodeId"]), DB_FETCHMODE_OBJECT); if (PEAR::isError($row)) { printError($row); exit; } include "tpls/InfoCategory.php"; } else { if ($_REQUEST["nodeType"] == NODE_SITE_ITEM) { // Вывод инфы для элемента источника // Получить id измененых данных $idChanged =& $db->getOne(CMD_SEL_CHANGED_ID, array($_REQUEST["nodeId"])); if (PEAR::isError($idChanged)) { printError($idChanged); exit; } // Есть изменения if (isset($idChanged)) { // Вывод изменений $sql = "SELECT our_items.*, items.status as pstatus\n\t\t\t\t\tFROM our_items, items WHERE our_items.id = ?\n\t\t\t\t\t\tAND our_items.item_id = items.id"; $row =& $db->getRow($sql, array($idChanged), DB_FETCHMODE_OBJECT); if (PEAR::isError($row)) { printError($row); exit; } $categId =& $db->getOne("SELECT category_id FROM items\n\t\t\t\t\t\tWHERE id = ?", array($_REQUEST["nodeId"])); if (PEAR::isError($categId)) { $FIELDS = getViewFields(); } else { $FIELDS = getViewFields($categId); } $STATUS = $row->pstatus != 0 ? "checked" : ""; } else { $sql = "SELECT * FROM items WHERE id = ?"; $row =& $db->getRow($sql, array($_REQUEST["nodeId"]), DB_FETCHMODE_OBJECT); if (PEAR::isError($row)) { printError($row); exit; } $FIELDS = getViewFields($row->category_id); $STATUS = $row->status != 0 ? "checked" : ""; // Сброс флага "Новый" if ($row->existence == "new") { $sql = "UPDATE items SET existence = 'default' WHERE id = ?"; $db->query($sql, array($_REQUEST["nodeId"])); } } $ITEM_ID = $_REQUEST["nodeId"]; $NEW_ITEM = false; $VIEWMODE = $row->viewmode ? "checked" : ""; include "tpls/InfoItem.php"; } else { if ($_REQUEST["nodeType"] == NODE_SITE_OURITEM) { $sql = "SELECT * FROM our_items WHERE id = ?"; $row =& $db->getRow($sql, array($_REQUEST["nodeId"]), DB_FETCHMODE_OBJECT); if (PEAR::isError($row)) { printError($row); exit; } $ITEM_ID = $_REQUEST["nodeId"]; $NEW_ITEM = true; $VIEWMODE = $row->viewmode ? "checked" : ""; $STATUS = ""; $FIELDS = getViewFields(); include "tpls/InfoItem.php"; } } } } else { // Вывод инфы для нашей категории $sql = "SELECT * FROM our_categories WHERE id = ?"; $row =& $db->getRow($sql, array($_REQUEST["nodeId"]), DB_FETCHMODE_OBJECT); $VIEWMODE = $row->viewmode ? "checked" : ""; $COLORSHEME = $row->colorsheme ? "checked" : ""; if (PEAR::isError($row)) { printError($row); exit; } include "tpls/InfoOurCategory.php"; } }
function generateItemFile($itemId, $path, $idx, $itemsData) { global $db; $row =& $db->getRow(CMD_SEL_ITEM, array($itemId), DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { print $row->getMessage() . "\n"; return; } print "Generate item page... {$itemId} \n"; // Новый объект if ($row["item_id"] == 0) { $fields = getViewFields(); $imgUrl = IMAGES_BASE . getNormImagePath("new" . $row["id"]); } else { $categId =& $db->getOne("SELECT category_id FROM items WHERE id = ?", array($row["item_id"])); if (PEAR::isError($categId)) { $fields = getViewFields(); } else { $fields = getViewFields($categId); } $imgUrl = IMAGES_BASE . getNormImagePath($row["item_id"]); } $fields = removeFields($fields[0], $fields[1]); $fields = array_unique($fields); ob_start(); $tpl = new HTML_Template_IT(""); $tpl->loadTemplatefile(ITEM_TPL_FILE, true, true); $params = array("itemData" => $itemsData, "perPage" => 1, "delta" => 3, "append" => false, "expanded" => true, "fileName" => "?popup=[%d]", "mode" => "Sliding", "path" => "", "prevImg" => "<prev", "nextImg" => "next>"); $pager = new ExtendedPager1($params); $pager->ext = BASE_INDEX_URL_POPUP; $pager->infoStr = NAV_INFO_STR; $pager->prev = NAV_PREV; $pager->prevDis = NAV_PREV_DIS; $pager->next = NAV_NEXT; $pager->nextDis = NAV_NEXT_DIS; $pager->prevPages = NAV_PREV_PAGES; $pager->prevPagesDis = NAV_PREV_PAGES_DIS; $pager->nextPages = NAV_NEXT_PAGES; $pager->nextPagesDis = NAV_NEXT_PAGES_DIS; $pager->currentPage = $idx + 1; $navigation = $pager->getLinks(); $navigation = $pager->replaceLinks($navigation); $navigation = str_replace("/http://", "http://", $navigation); $navigation = str_replace(".http://", "http://", $navigation); $tpl->setVariable("NAVIGATION", $navigation); $row["name"] = stripslashes($row["name"]); $tpl->setVariable("name1", $row["name"]); $tpl->setVariable("HTMLTITLE", $row["name"] . START_PATH_TITLE); foreach ($fields as $field) { if (!isset($row[$field])) { continue; } if (strlen(trim($row[$field])) == 0) { continue; } $row[$field] = stripslashes($row[$field]); $tpl->setCurrentBlock($field); $tpl->setVariable($field, $row[$field]); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("image"); $tpl->setVariable("image", $imgUrl); $tpl->parseCurrentBlock(); $tpl->show(); $contents = ob_get_contents(); ob_end_clean(); $fName = str_replace(" ", "-", trim($row['art'])); $fName = str_replace("/", "-", $fName); FileUtils::saveContents(OUTPUT_DIR . "/popup/" . $fName . ".html", $contents); }