Пример #1
0
function page_news($home = false, $search = false)
{
    global $db, $fullsite, $cla_cid, $cla_nid, $cla_site, $ts_config;
    $curPage = $_POST['page'];
    if ((int) $curPage <= 0) {
        $curPage = 1;
    }
    $lang = '_' . get_language();
    if ($home) {
        $title_page = get_lang('home');
    }
    if ($search == true && __post('txt_search') != '') {
        $filter_search = " and (keyword_vi like '%" . __post('txt_search') . "%' or keyword_en like '%" . __post('txt_search') . "%'  )";
        if ($search == true && $has_data == false) {
            $title_page = get_lang('search_result');
        }
    }
    if ($home == true || $search == true) {
        echo '<div class="group_area">
			<div style="background-color:#71baf1;" class="lft-title">&nbsp;' . $title_page . '
							</div>
			<div class="group_content">';
    }
    if ((int) $cla_cid > 0 || $home) {
        $PageSize = (int) $ts_config['max_news_page'];
        $from = ($curPage - 1) * $PageSize;
        $limit = $PageSize;
        $sqlTotal = "SELECT count(*) as TotalRecord FROM ntk_news WHERE  status = 1";
        if ((int) $cla_cid > 0) {
            $sqlTotal .= " and cid=" . $cla_cid . " ";
        }
        if ((int) $cla_nid > 0) {
            $sqlTotal .= " AND id<=" . $cla_nid;
        }
        $sqlTotal .= $filter_search;
        if ($home) {
            $sqlTotal .= " AND show_index = 1 ";
        }
        //echo $sqlTotal;
        $result = $db->query($sqlTotal, true, "Query failed");
        $TotalRecord = 0;
        if ($aR = $db->fetchByAssoc($result)) {
            $TotalRecord = (int) $aR['TotalRecord'];
        }
        $has_data = false;
        if ($TotalRecord > 0) {
            $TotalPage = intval($TotalRecord / $PageSize + ($TotalRecord % $PageSize > 0 ? 1 : 0));
            $paging = Paging2($TotalPage, $curPage, 'form1');
            $sql = "SELECT t1.*,t2.menu_name" . $lang . " FROM ntk_news t1\n\t\t\t\t\tleft join ntk_menus t2 on t1.cid = t2.menu_id\n\t\t\t\tWHERE  t1.status = 1";
            if ((int) $cla_cid > 0) {
                $sql .= " and t1.cid=" . $cla_cid . " ";
            }
            if ((int) $cla_nid > 0) {
                $sql .= " AND t1.id = " . $cla_nid;
            }
            if ($home) {
                $sql .= " AND t1.show_index = 1 ";
            }
            $sql .= $filter_search;
            $sql .= "ORDER BY news_order ASC,id ASC \tLIMIT " . $from . "," . $limit . " ";
            //echo $sql;
            $result = $db->query($sql, true, "Query failed");
            echo '<form action="" name="form1" id="form1" method="POST">
				<input type="hidden" value="1" name="page" id="page"/>
				';
            $stt = 0;
            while ($aR = $db->fetchByAssoc($result)) {
                if ($aR['title' . $lang] != '' && $aR['short' . $lang] != '') {
                    if ($stt == 0) {
                        if ($home == false && $search == false) {
                            echo '<div class="group_area"><div style="background-color:#71baf1;" class="lft-title">' . $aR['menu_name' . $lang] . '</div><div class="group_content">';
                        }
                    }
                    $has_data = true;
                    $title_url = '';
                    $title_url = fnStrConvert($aR['title' . $lang]);
                    $title_url = str_replace(" ", '-', $title_url);
                    echo '<div class="news_title"><a href="' . $fullsite . '/' . (int) $aR['cid'] . '/' . (int) $aR['id'] . '/' . $title_url . '.html">' . $aR['title' . $lang] . '</a></div>';
                    echo '<div><div class="news_date">' . date2vndate($aR['create_date']) . '</div><div class="news_download">';
                    $sql = " select t1.*,t2.file_type_name,t2.file_type_icon \n\t\t\t\t\t\t\t\tfrom ntk_new_files t1\n\t\t\t\t\t\t\t\tleft join ntk_file_type t2 on t1.file_type_id = t2.file_type_id\n\t\t\t\t\t\t\t\twhere t1.new_id = " . (int) $aR['id'] . "\n\t\t\t\t\t\t";
                    $result_file = $db->query($sql, true, "Query failed");
                    $i = 0;
                    while ($aR_file = $db->fetchByAssoc($result_file)) {
                        if ($i == 0) {
                            echo '<span class="download_file_title">Tải file tại đây</span> ';
                        }
                        if ($aR_file['require_login'] == 1 && !is_login()) {
                            $href = 'javascript:notLogin();';
                        } else {
                            $href = $ts_config['site_url_download_file'] . $aR_file['file_path'];
                        }
                        if ($i > 0) {
                            echo ' | ';
                        }
                        //$urlre = $sugar_config['site_url_download_file']."/download_file_case.php?fn=".$filePath;
                        //header('location:'.$urlre.'');
                        //die();
                        echo '<a href="' . $href . '"><img src="' . $fullsite . '/images/' . $aR_file['file_type_icon'] . '"></a>';
                        $i++;
                    }
                    echo '</div></div><br>';
                    echo '<div class="news_short"><div style="width:25px; float:left;">&nbsp;</div>' . html_entity_decode($aR['short' . $lang]) . '&nbsp;<a href="' . $fullsite . '/' . (int) $aR['cid'] . '/' . (int) $aR['id'] . '/' . $title_url . '.html">' . get_lang('text_detail') . '</a></div>';
                    echo '<hr size=2 style="color:#cccccc">';
                    $stt++;
                }
            }
            if ($has_data == true) {
                echo '<div style="margin-top:10px;margin-bottom:10px;">' . $paging . '</div>';
            }
        }
        if ($search == true && $has_data == false) {
            echo '<div style="">' . get_lang('search_no_result') . '</div>';
        }
        echo "</form1>";
        echo "</div></div>";
    }
}
Пример #2
0
function page_news($home = false)
{
    global $db, $fullsite, $cla_cid, $cla_nid, $cla_site, $ts_config;
    $lang = '_' . get_language();
    if ((int) $cla_cid > 0 || $home) {
        $sql = "SELECT * FROM ntk_news WHERE  status = 1";
        if ((int) $cla_cid > 0) {
            $sql .= " and cid=" . $cla_cid . " ";
        }
        if ((int) $cla_nid > 0) {
            $sql .= " AND id<=" . $cla_nid;
        }
        if ($home) {
            $sql .= " AND show_index = 1 ";
        }
        $sql .= "ORDER BY news_order ASC,id ASC \tLIMIT 0,10 ";
        //echo $sql;die();
        $result = $db->query($sql, true, "Query failed");
        while ($aR = $db->fetchByAssoc($result)) {
            if ($aR['title' . $lang] != '' && $aR['short' . $lang] != '') {
                $title_url = '';
                $title_url = fnStrConvert($aR['title' . $lang]);
                $title_url = str_replace(" ", '-', $title_url);
                echo '<div class="news_title"><a href="' . $fullsite . '/' . (int) $aR['cid'] . '/' . (int) $aR['id'] . '/' . $title_url . '.html">' . $aR['title' . $lang] . '</a></div>';
                echo '<div><div class="news_date">' . date2vndate($aR['create_date']) . '</div><div class="news_download">';
                $sql = " select t1.*,t2.file_type_name,t2.file_type_icon \n\t\t\t\t\t\t\tfrom ntk_new_files t1\n\t\t\t\t\t\t\tleft join ntk_file_type t2 on t1.file_type_id = t2.file_type_id\n\t\t\t\t\t\t\twhere t1.new_id = " . (int) $aR['id'] . "\n\t\t\t\t\t";
                $result_file = $db->query($sql, true, "Query failed");
                $i = 0;
                while ($aR_file = $db->fetchByAssoc($result_file)) {
                    if ($aR_file['require_login'] == 1 && !is_login()) {
                        $href = 'javascript:notLogin();';
                    } else {
                        $href = $ts_config['site_url_download_file'] . $aR_file['file_path'];
                    }
                    if ($i > 0) {
                        echo ' | ';
                    }
                    //$urlre = $sugar_config['site_url_download_file']."/download_file_case.php?fn=".$filePath;
                    //header('location:'.$urlre.'');
                    //die();
                    echo '<a href="' . $href . '"><img src="' . $fullsite . '/images/' . $aR_file['file_type_icon'] . '"></a>';
                    $i++;
                }
                echo '</div></div><br>';
                echo '<div class="news_short"><div style="width:25px; float:left;">&nbsp;</div>' . $aR['short' . $lang] . '&nbsp;<a href="' . $fullsite . '/' . (int) $aR['cid'] . '/' . (int) $aR['id'] . '/' . $title_url . '.html">' . get_lang('text_detail') . '</a></div>';
                echo '<hr size=2 style="color:#cccccc">';
            }
        }
    }
}