예제 #1
0
function getViewFields($categoryId = null)
{
    global $db;
    if (!isset($categoryId)) {
        require_once "../parsers/IContentGrabber.php";
        $parser =& new IContentGrabber();
        $viewFields = array_keys($parser->getAllFields());
        return array(removeFields($viewFields, $parser->getRemoveFields()), $parser->getHiddenFields());
    } else {
        // Получить имя парсера для категории
        $parserName =& $db->getOne("SELECT sites.keyname FROM site_categories, sites\n\t\t\t\tWHERE (site_categories.id = ?)\n\t\t\t\t\tAND (sites.id = site_categories.site_id)", array($categoryId), DB_FETCHMODE_OBJECT);
        if (PEAR::isError($parserName)) {
            printError($parserName);
            exit;
        }
        $parserName = $parserName . "ContentGrabber";
        require_once "../parsers/{$parserName}.php";
        $parser =& new $parserName();
        $viewFields = array_merge($parser->getSupportedFields(), $parser->getHiddenFields(), $parser->getViewFields());
        return array(removeFields($viewFields, $parser->getRemoveFields()), $parser->getHiddenFields());
    }
}
예제 #2
0
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);
}