define(array(template => 'news.html')); $tpl->define(array(news_row => 'news_row.html', page_manager_tpl => 'page_manager_tpl.html')); if (!isset($pos)) $pos = 0; $maxrows = $NEWS_FRONTEND_MAXROWS; $tpl->assign(array(VAR_CONTENTS_BRIEF => NULL)); $sql = "SELECT * FROM content_tbl WHERE section = '02' AND status = 'E' ORDER BY createdtime DESC "; $rsc = $ado->Execute($sql); $totalRecord = $rsc->RecordCount(); if ($pos >= $totalRecord) $pos -= $maxrows; if ($pos < 0) $pos = 0; $tpl->assign(array(VAR_POS => $pos)); $itemNo = $pos + 1; $tpl->assign(array(VAR_NUM_ROWS => $totalRecord)); if ($totalRecord > 0) { $rs = $ado->SelectLimit($sql, $maxrows, $pos); while ($contentObj = $rs->FetchNextObject()) { $contentImg = NULL; if (!empty($contentObj->THUMBNAIL_IMAGE) && file_exists(BACKEND_FOLDER.CONTENT_FOLDER.$contentObj->THUMBNAIL_IMAGE)) { $imgWidth = 122; $imgHeight = 64; $size = @getimagesize(BACKEND_FOLDER.CONTENT_FOLDER.$contentObj->THUMBNAIL_IMAGE); $width = ($size[0] > $imgWidth) ? $imgWidth : $size[0]; $height = ($size[1] > $imgHeight) ? $imgHeight : $size[1]; $contentImg .= "Click to view detail ..."; } else { $contentImg .= "Click to view detail ..."; } #$tpl->assign(array(VAR_THUMBNAIL => "".$contentImg."")); $tpl->assign(array(VAR_THUMBNAIL => $contentImg)); $tpl->assign(array(VAR_CONTENT_ID => $contentObj->ID)); $topic = ReplaceKeyword(stripslashes($contentObj->TOPIC), $keyword); #$tpl->assign(array(VAR_TOPIC => "".$topic."")); $tpl->assign(array(VAR_TOPIC => $topic)); $brief = ReplaceKeyword(stripslashes($contentObj->BRIEF_DESC), $keyword); $tpl->assign(array(VAR_BRIEF => $brief)); $tpl->assign(array(VAR_LASTUPDATE => date("d M, Y h:i:s a", strtotime($contentObj->LASTUPDATE)))); #$tpl->assign(array(VAR_READ => "Read (".number_format($contentObj->VIEWED).")")); $tpl->parse(VAR_NEWS_ROW, ".news_row"); } //determine to display previous and next link if ($pos != 0) { $previousPos = $pos - $maxrows; $tpl->assign(array(VAR_PREVIOUS_LINK => "<<")); } else { $tpl->assign(array(VAR_PREVIOUS_LINK => "<<")); } if ($totalRecord > $pos + $maxrows ) { $nextPos = $pos + $maxrows; $tpl->assign(array(VAR_NEXT_LINK => ">>")); }else{ $tpl->assign(array(VAR_NEXT_LINK => ">>")); } // Try page number... $numPages = ceil($totalRecord / $maxrows); $tpl->assign(array(VAR_NUM_PAGE => $numPages)); if ($numPages >= 11) $pageShow = 11; else $pageShow = $numPages; $pageNo = ""; if ($pos == 0) { $CurPage = 1; $lLimit = 1; $rLimit = $numPages; } $OverL = $OverR = 0; $CurPage = $pos / $maxrows + 1; $lLimit = $CurPage - 5; $rLimit = $CurPage + 5; if ( $lLimit < 1) $OverL = ((-1) * $lLimit) + 1; if ( $rLimit > $numPages) $OverR = $rLimit - $numPages; $lLimit -= $OverR; $rLimit += $OverL; $lLimit = ($lLimit < 1) ? 1 : $lLimit; $rLimit = ($rLimit > $numPages) ? $numPages : $rLimit; for ($i = $lLimit;$i <= $rLimit;$i++) { $ppos = ($i - 1) * $maxrows; if ($i == $CurPage) $pageNo = $pageNo."".$i." "; else $pageNo = $pageNo."".$i." "; } $tpl->assign(array(VAR_PAGE_NO => $pageNo)); // End page number ... //set endpos to real position ... $endpos = $pos + $maxrows; if ($totalRecord < $endpos) $endpos = $totalRecord; $tpl->assign(array(VAR_START_POS => $pos+1)); $tpl->assign(array(VAR_END_POS => $endpos)); # $tpl->assign(array(VAR_LINE_DISPLAY => "show")); # $tpl->parse(VAR_PAGE_MANAGER_TPL, ".page_manager_tpl"); if ($numPages > 1) { $tpl->assign(array(VAR_LINE_DISPLAY => "show")); $tpl->parse(VAR_PAGE_MANAGER_TPL, ".page_manager_tpl"); } else { $tpl->assign(array(VAR_LINE_DISPLAY => "none")); $tpl->assign(array(VAR_PAGE_MANAGER_TPL => NULL)); } } else { $tpl->assign(array(VAR_NEWS_ROW => "Not found.")); $tpl->assign(array(VAR_LINE_DISPLAY => "none")); $tpl->assign(array(VAR_PAGE_MANAGER_TPL => NULL)); } $tpl->parse(TEMPLATE, "template"); $tpl->FastPrint(TEMPLATE); ?>