Example #1
0
function module_sheet()
{
    global $global, $smarty;
    $prefix = $global['channel'] . '/mod-sheet';
    if (isset($global['field'])) {
        $prefix = $prefix . '/field-' . $global['field'];
    }
    if (isset($global['key'])) {
        $prefix = $prefix . '/key-' . $global['key'];
    }
    $obj = new article();
    $obj->set_where('art_channel_id = ' . $global['channel_id']);
    if (isset($global['key'])) {
        $obj->set_where($global['field'] . " like '%" . url_decode($global['key']) . "%'");
    }
    $obj->set_page_size(10);
    $obj->set_page_num($global['page']);
    $sheet = $obj->get_sheet();
    for ($i = 0; $i < count($sheet); $i++) {
        $sheet[$i]['cat_name'] = get_data('cat_art', $sheet[$i]['art_cat_id'], 'cat_name');
    }
    set_link($obj->get_page_sum());
    $smarty->assign('article', $sheet);
    $smarty->assign('prefix', $prefix);
}
Example #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);
    }
}
Example #3
0
function module_new_article()
{
    global $smarty;
    $obj = new article();
    $obj->set_field('art_id,art_channel_id,art_title,art_add_time');
    $obj->set_page_size(10);
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $list[$i]['channel'] = get_data('channel', $list[$i]['art_channel_id'], 'cha_code');
        $list[$i]['short_title'] = cut_str($list[$i]['art_title'], 16);
    }
    $smarty->assign('new_article', $list);
}
Example #4
0
function module_search_main()
{
    global $global, $smarty;
    $global['key'] = url_decode($global['key']);
    $list_len = get_varia('art_list_len');
    $obj = new article();
    $obj->set_field('art_id,art_channel_id,art_title,art_add_time');
    $obj->set_where("art_title like '%" . $global['key'] . "%'");
    $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]['channel'] = get_data('channel', $sheet[$i]['art_channel_id'], 'cha_code');
        $sheet[$i]['short_title'] = cut_str($sheet[$i]['art_title'], 42);
    }
    set_link($obj->get_page_sum());
    $smarty->assign('search', $sheet);
}
Example #5
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);
    }
}