예제 #1
0
파일: index.php 프로젝트: show123456/taiyou
//var
$customer_id = (int) $_SESSION['customer_id'];
$type = Model_InfoCate::exist_type($_REQUEST['type']) ? $_REQUEST['type'] : 'text';
$cate_id = (int) $_REQUEST["cate_id"];
$page = (int) $_REQUEST["p"] > 0 ? (int) $_REQUEST["p"] : 1;
//sql
$filter = array();
$filter['where'] = "customer_id = {$customer_id}";
if ($cate_id) {
    $filter['where'] .= " and cate_id='{$cate_id}'";
}
if ($type == 'multi') {
    $filter['where'] .= " and info_type='3'";
} else {
    if (Model_InfoCate::getTypeName($type) == 'common') {
        $filter['where'] .= " and info_type='" . Model_InfoCommon::get_type($type) . "'";
    }
}
$filter['order'] = "id desc";
//result
$table = 'Model_Info' . ucfirst(Model_InfoCate::getTypeName($type));
$infoModel = new $table();
//echo "<pre>";var_dump($filter);die();
$result = $infoModel->paginate($filter, '*', $page, $size = '20');
$pager = $result['pager'];
//pager
if ($pager['pagenum'] > $pager['size']) {
    $pagerhtml = new SubPages($pager['size'], $pager['count'], $pager['current'], $pager['range'], 2);
    $smarty->assign("pagerhtml", $pagerhtml);
}
//category
예제 #2
0
//delete
if ($act == 'del' && $id) {
    Model_Table::get('InfoCommon')->delete("id='{$id}' and customer_id='{$customer_id}'");
    Model_Table::get('KeywordList')->delete("info_id='{$id}' and customer_id='{$customer_id}' and info_type='{$info_type}'");
    header("location:/home/info/index.php?type=single");
    die;
}
//method:add||modify
if ($id) {
    $data = Model_Table::get('InfoCommon')->findByWhere("id='{$id}' and customer_id='{$customer_id}' and info_type='" . Model_InfoCommon::get_type($info_type) . "'");
    $smarty->assign('infoRow', $data);
}
//submit
if (method_is('post')) {
    $data['customer_id'] = $customer_id;
    $data['info_type'] = Model_InfoCommon::get_type($info_type);
    $data['keyword'] = isset($_POST['keyword']) ? str_inmysql(str_replace(array(';', ','), ',', $_POST['keyword'])) : '';
    $data['state'] = isset($_POST['state']) ? (int) $_POST['state'] : '';
    $data['cate_id'] = isset($_POST['cate_id']) ? (int) $_POST['cate_id'] : '';
    $data['info_title'] = isset($_POST['info_title']) ? str_inmysql($_POST['info_title']) : '';
    $data['pic_showincontent'] = isset($_POST['show']) ? (int) $_POST['show'] : '';
    $data['info_pic'] = isset($_POST['info_pic']) ? str_inmysql($_POST['info_pic']) : '';
    $data['info_desc'] = isset($_POST['info_desc']) ? str_inmysql($_POST['info_desc']) : '';
    $data['info_intro'] = isset($_POST['info_intro']) ? str_inmysql($_POST['info_intro']) : '';
    $data['info_url'] = isset($_POST['info_url']) ? str_inmysql($_POST['info_url']) : '';
    $data['create_date'] = date('Y-m-d H:i:s', $_WGT['TIME']);
    if (!$data['keyword']) {
        ajax_feedback(0, '1201');
    }
    if (!$data['info_intro']) {
        ajax_feedback(0, '1202');