Esempio n. 1
0
        flash();
    }
    $cache->updateTypes();
}
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (!empty($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == 'search') {
        if (isset($_GET['newstype']['name'])) {
            $conditions[] = "Newstype.name like '%" . trim($_GET['newstype']['name']) . "%'";
        }
    }
    if ($do == "del" && !empty($id)) {
        $newstype->del($id);
    }
    if ($do == "edit") {
        setvar("NewstypeOptions", $newstype->getTypeOptions());
        if (!empty($id)) {
            $res = $newstype->read("*", $id);
            setvar("item", $res);
        }
        $tpl_file = "newstype.edit";
        template($tpl_file);
        exit;
    }
}
$amount = $newstype->findCount(null, $conditions);
$page->setPagenav($amount);
$sql = "SELECT nt.*,(SELECT count(n.id)) AS news_amount FROM " . $tb_prefix . "newstypes nt LEFT JOIN " . $tb_prefix . "newses n ON n.type_id=nt.id GROUP BY nt.id ORDER BY nt.id DESC LIMIT {$page->firstcount},{$page->displaypg}";