Пример #1
0
function module_cat_edit()
{
    global $global, $smarty;
    $list = array();
    $obj = new cat_art();
    $obj->set_where('cat_channel_id = ' . $global['channel_id']);
    $arr = $obj->get_list();
    if (count($arr) > 0) {
        $list = $obj->set_cat_order($arr);
        for ($i = 0; $i < count($list); $i++) {
            $list[$i]['parent_name'] = get_data('cat_art', $list[$i]['cat_parent_id'], 'cat_name');
            $obj->set_where('');
            $obj->set_where('cat_parent_id = ' . $list[$i]['cat_id']);
            if ($obj->get_count() > 0) {
                $list[$i]['exist_child'] = 1;
            } else {
                $list[$i]['exist_child'] = 0;
            }
            $list[$i]['show'] = 1;
        }
    }
    $family = get_cat_family('cat_art', $global['id']);
    for ($i = 0; $i < count($family); $i++) {
        for ($j = 0; $j < count($list); $j++) {
            if ($family[$i] == $list[$j]['cat_id']) {
                $list[$j]['show'] = 0;
            }
        }
    }
    $smarty->assign('cat_list', $list);
    $obj = new cat_art();
    $obj->set_where('cat_id = ' . $global['id']);
    $one = $obj->get_one();
    $smarty->assign('cat', $one);
}
Пример #2
0
function module_article_list()
{
    global $smarty;
    $obj = new cat_art();
    $obj->set_where('cat_best = 1');
    $best_cat = $obj->get_list();
    $art_list = array();
    if (count($best_cat) > 0) {
        $smarty->assign('show_all_art', 0);
        $list_len = get_varia('index_art_list_len');
        for ($i = 0; $i < count($best_cat); $i++) {
            $cat_id = $best_cat[$i]['cat_id'];
            $best_cat[$i]['channel'] = get_data('channel', $best_cat[$i]['cat_channel_id'], 'cha_code');
            $family = implode(',', get_cat_family('cat_art', $cat_id));
            $obj = new article();
            $obj->set_field('art_id,art_title,art_add_time');
            $obj->set_where("art_cat_id in ({$family})");
            $obj->set_page_size($list_len ? $list_len : 5);
            $list = $obj->get_list();
            for ($j = 0; $j < count($list); $j++) {
                $list[$j]['short_title'] = cut_str($list[$j]['art_title'], 22);
            }
            $art_list[$cat_id] = $list;
            unset($obj);
        }
        $smarty->assign('best_art_cat', $best_cat);
        $smarty->assign('art_list', $art_list);
    } else {
        $smarty->assign('show_all_art', 1);
    }
}
Пример #3
0
function module_article_main()
{
    global $global, $smarty;
    if (!$global['id']) {
        $art_best = get_global('best');
        $prefix = get_data('channel', $global['channel_id'], 'cha_code');
        $list_len = get_varia('art_list_len');
        $obj = new article();
        $obj->set_where('art_channel_id = ' . $global['channel_id']);
        if ($global['cat']) {
            $family = implode(',', get_cat_family('cat_art', $global['cat']));
            $obj->set_where("art_cat_id in ({$family})");
            $prefix .= '/cat-' . $global['cat'];
        }
        if ($art_best) {
            $obj->set_where('art_best = 1');
            $prefix .= '/best-1';
        }
        $obj->set_page_size($list_len ? $list_len : 20);
        $obj->set_page_num($global['page']);
        $sheet = $obj->get_sheet();
        for ($i = 0; $i < count($sheet); $i++) {
            $sheet[$i]['short_title'] = cut_str($sheet[$i]['art_title'], 42);
        }
        set_link($obj->get_page_sum());
        $smarty->assign('show_sheet', 1);
        $smarty->assign('article', $sheet);
        $smarty->assign('prefix', $prefix);
    } else {
        $obj = new article();
        $obj->set_field('art_id,art_title,art_author,art_add_time,art_text');
        $obj->set_where('art_channel_id = ' . $global['channel_id']);
        $obj->set_where('art_id = ' . $global['id']);
        $one = $obj->get_one();
        $smarty->assign('article', $one);
        $obj = new article();
        $obj->set_field('art_id,art_title');
        $obj->set_where('art_channel_id = ' . $global['channel_id']);
        $obj->set_where('art_id < ' . $global['id']);
        $one = $obj->get_one();
        if (count($one)) {
            $smarty->assign('next_id', $one['art_id']);
            $smarty->assign('next_title', cut_str($one['art_title'], 15));
        } else {
            $smarty->assign('next_id', '');
            $smarty->assign('next_title', '');
        }
        $obj = new article();
        $obj->set_field('art_id,art_title');
        $obj->set_where('art_channel_id = ' . $global['channel_id']);
        $obj->set_where('art_id > ' . $global['id']);
        $obj->set_order('');
        $obj->set_order('art_top', 'asc');
        $obj->set_order('art_index', 'asc');
        $obj->set_order('art_id', 'asc');
        $one = $obj->get_one();
        if (count($one)) {
            $smarty->assign('prev_id', $one['art_id']);
            $smarty->assign('prev_title', cut_str($one['art_title'], 15));
        } else {
            $smarty->assign('prev_id', '');
            $smarty->assign('prev_title', '');
        }
        $obj = new varia();
        $smarty->assign('share_code', im_filter($obj->get_value('share_code', true)));
        $smarty->assign('show_sheet', 0);
    }
}
Пример #4
0
function set_cat_show($table, $cat_id, $cat_show)
{
    $flag = 1;
    $family = get_cat_family($table, $cat_id);
    $cat_parent_id = get_data($table, intval($cat_id), 'cat_parent_id');
    if ($cat_parent_id != 0) {
        if (get_data($table, $cat_parent_id, 'cat_show') == 0) {
            $flag = 0;
        }
    }
    if ($flag != 0) {
        $len = count($family);
        if ($len == 1) {
            $flag = 1;
        } elseif ($len > 1) {
            for ($i = 1; $i < $len; $i++) {
                if (get_data($table, $family[$i], 'cat_show') == 1) {
                    $flag = 2;
                    break;
                }
            }
        }
    }
    return $flag;
}
Пример #5
0
function step_create_cat_sheet_page($table, $channel, $page_size)
{
    $channel_id = get_id('channel', 'cha_code', $channel);
    $tab = substr($table, 0, 3);
    $step_page = intval(get_cookie('create_static_page'));
    $step_cat = intval(get_cookie('create_static_cat'));
    $page_sum = -1;
    $family = implode(',', get_cat_family('cat_' . $tab, $step_cat));
    $domain = get_domain();
    $obj = new $table();
    $obj->set_where($tab . "_cat_id in ({$family})");
    $obj->set_where($tab . '_show = 1');
    if ($channel_id) {
        $obj->set_where($tab . '_channel_id = ' . $channel_id);
    }
    $record_count = $obj->get_count();
    if ($record_count > 0) {
        $page_sum = get_page_sum($record_count, $page_size);
        if ($page_sum >= $step_page) {
            if ($step_page == 1) {
                $page_url = 'http://' . $domain . S_ROOT . '?/' . $channel . '/cat-' . $step_cat . '/' . S_URL_SUFFIX;
                $html = file_get_contents($page_url);
                set_cookie('create_static_created', get_cookie('create_static_created') + 2);
            } else {
                set_cookie('create_static_created', get_cookie('create_static_created') + 1);
            }
            $page_url = 'http://' . $domain . S_ROOT . '?/' . $channel . '/cat-' . $step_cat . '/page-' . $step_page . '/' . S_URL_SUFFIX;
            $html = file_get_contents($page_url);
        }
    } else {
        $page_url = 'http://' . $domain . S_ROOT . '?/' . $channel . '/cat-' . $step_cat . '/' . S_URL_SUFFIX;
        $html = file_get_contents($page_url);
        set_cookie('create_static_created', get_cookie('create_static_created') + 1);
    }
    $t = 'cat_' . $tab;
    $obj = new $t();
    $obj->set_where('cat_show = 1');
    $obj->set_where("cat_id > {$step_cat}");
    if ($channel_id) {
        $obj->set_where('cat_channel_id = ' . $channel_id);
    }
    $one = $obj->get_one();
    if ($page_sum - $step_page >= 0) {
        return $step_page + 1;
    } else {
        if (count($one) > 0) {
            set_cookie('create_static_cat', $one['cat_id']);
            return 'next_cat';
        } else {
            return 0;
        }
    }
}