function tpl_function_qishi_curriculum_show($params, &$smarty)
{
    global $db, $timestamp, $_CFG;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "¿Î³ÌID":
                $aset['id'] = $a[1];
                break;
            case "ÁбíÃû":
                $aset['listname'] = $a[1];
                break;
            case "ÃèÊö³¤¶È":
                $aset['brieflylen'] = $a[1];
                break;
            case "Ìî²¹×Ö·û":
                $aset['dot'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['id'] = $aset['id'] ? intval($aset['id']) : 0;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    $wheresql = " WHERE id={$aset['id']} ";
    $sql = "select id,subsite_id,uid,setmeal_deadline,add_mode,train_id,contents,refreshtime,teacher_id,teacher_cn,trainname,course_name,addtime,click,favour_expenses,train_expenses,classhour,category_cn,starttime,classtype_cn,district_cn,train_object,train_certificate from " . table('course') . $wheresql . " LIMIT 1";
    $val = $db->getone($sql);
    if (empty($val)) {
        header("HTTP/1.1 404 Not Found");
        $smarty->display("404.htm");
        exit;
    } else {
        check_url($val['subsite_id'], $smarty, $_CFG['train_url']);
        if ($val['setmeal_deadline'] < time() && $val['setmeal_deadline'] != "0" && $val['add_mode'] == "2") {
            $val['deadline'] = $val['setmeal_deadline'];
        }
        $val['course_url'] = url_rewrite('QS_courseshow', array('id' => $val['id']), 1, $val['subsite_id']);
        $profile = GetTainProfile($val['train_id']);
        $val['train'] = $profile;
        $val['expire'] = sub_day($val['deadline'], time());
        $val['countapply'] = $db->get_total("SELECT COUNT(*) AS num FROM " . table('personal_course_apply') . " WHERE course_id= '{$val['id']}'");
        if ($aset['brieflylen'] > 0) {
            $val['briefly'] = cut_str(strip_tags($val['contents']), $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $val['briefly'] = strip_tags($val['contents']);
        }
        $val['refreshtime_cn'] = daterange(time(), $val['refreshtime'], 'Y-m-d', "#FF3300");
        $val['train_url'] = url_rewrite('QS_train_agencyshow', array('id' => $val['train_id']));
        $val['teacher_url'] = url_rewrite('QS_train_lecturershow', array('id' => $val['teacher_id']));
        if ($val['train']['logo']) {
            $val['train']['logo'] = $_CFG['site_dir'] . "data/train_logo/" . $val['train']['logo'];
        } else {
            $val['train']['logo'] = $_CFG['site_dir'] . "data/train_logo/no_logo.gif";
        }
    }
    $smarty->assign($aset['listname'], $val);
}
function tpl_function_qishi_train_lecturer_show($params, &$smarty)
{
    global $db, $timestamp, $_CFG;
    $arr = explode(',', $params['set']);
    foreach ($arr as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "½²Ê¦ID":
                $aset['id'] = $a[1];
                break;
            case "ÁбíÃû":
                $aset['listname'] = $a[1];
                break;
            case "ÃèÊö³¤¶È":
                $aset['brieflylen'] = $a[1];
                break;
            case "Ìî²¹×Ö·û":
                $aset['dot'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['id'] = $aset['id'] ? intval($aset['id']) : 0;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['listname'] = $aset['listname'] ? $aset['listname'] : "list";
    $wheresql = " WHERE id={$aset['id']} ";
    $sql = "select id,train_id,contents,birthdate,refreshtime,photo,photo_img,teachername,education_cn,graduated_school,speciality,work_unit,positionaltitles,district_cn,achievements from " . table('train_teachers') . $wheresql . " LIMIT 1";
    $val = $db->getone($sql);
    if (empty($val)) {
        header("HTTP/1.1 404 Not Found");
        $smarty->display("404.htm");
        exit;
    } else {
        $profile = GetTainProfile($val['train_id']);
        $val['train'] = $profile;
        if ($aset['brieflylen'] > 0) {
            $val['briefly'] = cut_str(strip_tags($val['contents']), $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $val['briefly'] = strip_tags($val['contents']);
        }
        $val['age'] = date('Y') + 1 - $val['birthdate'];
        $val['refreshtime_cn'] = daterange(time(), $val['refreshtime'], 'Y-m-d', "#FF3300");
        $val['train_url'] = url_rewrite('QS_train_agencyshow', array('id' => $val['train_id']));
        $val['teacher_url'] = url_rewrite('QS_train_lecturer', array('id' => $val['id']));
        if ($val['photo'] == "1") {
            $val['photosrc'] = $_CFG['teacher_photo_dir'] . $val['photo_img'];
        } else {
            $val['photosrc'] = $_CFG['teacher_photo_dir'] . "no_photo.gif";
        }
    }
    $smarty->assign($aset['listname'], $val);
}
function tpl_function_qishi_train_news_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "机构ID":
                $aset['train_id'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "标题长度":
                $aset['titlelen'] = $a[1];
                break;
            case "摘要长度":
                $aset['infolen'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['paged'] = $a[1];
                break;
            case "页面":
                $aset['showname'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : "QS_train_agency_news";
    $aset['row'] = isset($aset['row']) ? intval($aset['row']) : 30;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['titlelen'] = isset($aset['titlelen']) ? intval($aset['titlelen']) : 15;
    $aset['infolen'] = isset($aset['infolen']) ? intval($aset['infolen']) : 25;
    $aset['showname'] = isset($aset['showname']) ? $aset['showname'] : 'QS_train_newsshow';
    if ($aset['displayorder']) {
        if (strpos($aset['displayorder'], '>')) {
            $arr = explode('>', $aset['displayorder']);
            // 排序字段
            if ($arr[0] == 'order') {
                $arr[0] = "order";
            } elseif ($arr[0] == "id") {
                $arr[0] = "id";
            } elseif ($arr[0] == "click") {
                $arr[0] = "click";
            } else {
                $arr[0] = "";
            }
            // 排序方式
            if ($arr[1] == 'desc') {
                $arr[1] = "desc";
            } elseif ($arr[1] == "asc") {
                $arr[1] = "asc";
            } else {
                $arr[1] = "";
            }
            if ($arr[0] && $arr[1]) {
                $orderbysql = " ORDER BY `" . $arr[0] . "` " . $arr[1];
            }
            if ($arr[0] == "order") {
                $orderbysql .= " ,id DESC ";
            }
        }
    }
    if (isset($aset['train_id']) && $aset['train_id'] != '') {
        $wheresql = " WHERE train_id='" . intval($aset['train_id']) . "' AND audit=1";
    } else {
        $wheresql = " WHERE audit=1";
    }
    if (isset($aset['paged'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('train_news') . $wheresql;
        $total_count = $db->get_total($total_sql);
        $pagelist = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $pagelist->nowindex;
        $aset['start'] = ($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $pagelist->show(3));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT " . abs($aset['start']) . ',' . $aset['row'];
    $result = $db->query("SELECT id,train_id,title,content,click,addtime FROM " . table('train_news') . " " . $wheresql . $orderbysql . $limit);
    $list = array();
    while ($row = $db->fetch_array($result)) {
        $profile = GetTainProfile($row['train_id']);
        if (empty($profile)) {
            continue;
        }
        $row['train'] = $profile;
        $row['title_'] = $row['title'];
        $row['title'] = cut_str($row['title'], $aset['titlelen'], 0, $aset['dot']);
        $row['url'] = url_rewrite($aset['showname'], array('id' => $row['id']));
        $row['train_url'] = url_rewrite('QS_train_agencyshow', array('id' => $row['train']['id']));
        $row['content'] = str_replace('&nbsp;', '', $row['content']);
        $row['briefly_'] = strip_tags($row['content']);
        if ($aset['infolen'] > 0) {
            $row['briefly'] = cut_str(strip_tags($row['content']), $aset['infolen'], 0, $aset['dot']);
        }
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}