Exemple #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);
}
Exemple #2
0
function module_set()
{
    global $global, $smarty;
    $smarty->assign('data_username', get_varia('data_username'));
    $smarty->assign('data_password', get_varia('data_password'));
    $obj = new channel();
    $channel = $obj->get_list();
    $smarty->assign('channel', $channel);
    $obj = new varia();
    $obj->set_where("var_name = 'data_cat'");
    $list = $obj->get_list();
    if (count($list)) {
        for ($i = 0; $i < count($list); $i++) {
            $arr = explode('|', $list[$i]['var_value']);
            $cat_setting[$i]['varia_id'] = $list[$i]['var_id'];
            $cat_setting[$i]['server_id'] = $arr[0];
            $cat_setting[$i]['server_name'] = $arr[1];
            $cat_setting[$i]['channel_id'] = $arr[2];
            $cat_setting[$i]['cat_id'] = $arr[3];
        }
    } else {
        $cat_setting = array();
    }
    $smarty->assign('cat_setting', $cat_setting);
    $cat_list = array();
    for ($i = 0; $i < count($cat_setting); $i++) {
        $obj = new cat_art();
        $obj->set_where('cat_channel_id = ' . $cat_setting[$i]['channel_id']);
        $arr = $obj->get_list();
        if (count($arr) > 0) {
            $cat_list[$cat_setting[$i]['server_id']] = $obj->set_cat_order($arr);
        }
    }
    $smarty->assign('cat_list', $cat_list);
}
Exemple #3
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);
    }
}
Exemple #4
0
function module_cat_add()
{
    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;
            }
        }
    }
    $smarty->assign('cat_list', $list);
}
Exemple #5
0
function module_tailor_cat_add()
{
    global $global, $smarty;
    $obj = new channel();
    $channel = $obj->get_list();
    $smarty->assign('channel', $channel);
    $cat_list = array();
    $obj = new cat_art();
    $obj->set_where('cat_channel_id = 1');
    $arr = $obj->get_list();
    if (count($arr) > 0) {
        $cat_list = $obj->set_cat_order($arr);
    }
    $smarty->assign('cat_list', $cat_list);
}
Exemple #6
0
function module_add()
{
    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);
    }
    $smarty->assign('cat_list', $list);
    $smarty->assign('editor_text', '');
    $smarty->assign('site_keywords', get_varia('site_keywords'));
    $smarty->assign('site_description', get_varia('site_description'));
    $smarty->assign('upl_date', date('Ymd'));
}
Exemple #7
0
function module_edit()
{
    global $global, $smarty;
    $obj = new article();
    $obj->set_where('art_id = ' . $global['id']);
    $one = $obj->get_one();
    $smarty->assign('article', $one);
    $smarty->assign('editor_text', $one['art_text']);
    $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);
    }
    $smarty->assign('cat_list', $list);
    $smarty->assign('upl_date', date('Ymd'));
}
Exemple #8
0
function add_or_edit_cat()
{
    global $global, $smarty, $lang;
    $cat_id = post('cat_id');
    $cat_parent_id = post('cat_parent_id');
    $cat_name = post('cat_name');
    $obj = new cat_art();
    $obj->set_value('cat_parent_id', $cat_parent_id);
    $obj->set_value('cat_name', $cat_name);
    if ($cat_id != '') {
        $obj->set_where("cat_id = {$cat_id}");
        $obj->edit();
        $info_text = $lang['edit_cat_success'];
    } else {
        $obj->set_value('cat_channel_id', $global['channel_id']);
        $obj->set_value('cat_lang', S_LANG);
        $obj->add();
        $info_text = $lang['add_cat_success'];
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', $lang['return_list']);
    $smarty->assign('link_href', url(array('channel' => $global['channel'], 'mod' => 'cat_list')));
}
Exemple #9
0
function do_del_channel($channel_id)
{
    //判断频道是否已存在
    $obj = new channel();
    $obj->set_where('');
    $obj->set_where("cha_id = {$channel_id}");
    $channel = $obj->get_one();
    if (count($channel)) {
        $cha_code = $channel['cha_code'];
        $obj->del();
    } else {
        return 0;
    }
    //删除前台导航(导航管理)
    $obj = new varia();
    $obj->set_where("var_name = 'nav_stage_" . $cha_code . "'");
    $obj->del();
    //删除后台导航(导航管理)
    $obj->set_where('');
    $obj->set_where("var_name = 'nav_admin_" . $cha_code . "'");
    $obj->del();
    //删除后台导航菜单
    $obj = new menu();
    $obj->set_where("men_type = '{$cha_code}'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_header'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-sheet/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-sheet/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-add/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-cat_list/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-att_list/'");
    $obj->del();
    //删除前台导航菜单
    $obj = new menu();
    $obj->set_where("men_type = 'header'");
    $obj->set_where("men_url = '" . $cha_code . "/'");
    $obj->del();
    //删除分类
    $obj = new cat_art();
    $obj->set_where('');
    $obj->set_where("cat_channel_id = {$channel_id}");
    $obj->del();
    //删除内容
    $obj = new article();
    $obj->set_where('');
    $obj->set_where("art_channel_id = {$channel_id}");
    $obj->del();
    //删除属性
    $obj = new att_art();
    $obj->set_where('');
    $obj->set_where("att_channel_id = {$channel_id}");
    $obj->del();
    //删除语言包
    $path = 'languages/' . S_LANG . '/admin/' . $cha_code . '.txt';
    if (file_exists($path)) {
        unlink($path);
    }
    $path = 'languages/' . S_LANG . '/index/' . $cha_code . '.txt';
    if (file_exists($path)) {
        unlink($path);
    }
    //修改伪静态文件
    $path = 'admin/module/basic/htaccess.txt';
    if (file_exists($path)) {
        $str = file_get_contents($path);
        $rule = "\n" . 'RewriteRule ^' . $cha_code . '/(.*)$ index.php?/' . $cha_code . '/$1';
        $str = str_replace($rule, '', $str);
        file_put_contents($path, $str);
    }
    return 1;
}
Exemple #10
0
function get_channel_cat()
{
    $val = post('val');
    if (is_numeric($val)) {
        $list = array();
        $obj = new cat_art();
        $obj->set_where('cat_channel_id = ' . $val);
        $arr = $obj->get_list();
        if (count($arr) > 0) {
            $list = $obj->set_cat_order($arr);
        }
        $str = '';
        for ($i = 0; $i < count($list); $i++) {
            $cat_id = $list[$i]['cat_id'];
            $cat_name = $list[$i]['cat_name'];
            $nbsp = '';
            for ($j = 1; $j < $list[$i]['grade']; $j++) {
                $nbsp .= '&nbsp;';
            }
            $str .= '<option value="' . $cat_id . '">' . $nbsp . $cat_name . '</option>';
        }
        echo $str;
    } else {
        echo '';
    }
}