_SetNewsId(); $this->_SetPage(); $this->_SetData(); } function HandlePage() { // Determine which function to load switch($this->_action) { case 'viewnews': $this->ViewItem(); break; default: { $this->ShowNews(); break; } } } function GetTitle() { return($this->_data["Title"]); } function ViewItem() { // Hide the panels we don't need $GLOBALS["HidePanels"] = array("ViewNewsPanel"); // Load the view article page $GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($GLOBALS["AL_LANG"]["hpNewsArchive"]); $GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("News"); echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate(); } function ShowNews() { $GLOBALS["HidePanels"] = array("ViewNewsItemPanel"); // Load the view page page $GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($GLOBALS["AL_LANG"]["hpNewsArchive"]); $GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("News"); echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate(); } function GetRSS() { ob_end_clean(); header("Content-Type: text/xml"); $arrNews = $this->GetRecentNewsList(); $uDate = date("D, d M Y H:i:s T"); $output = "<"; $output .= sprintf("?xml version=\"1.0\" encoding=\"utf-8\"?> %s - %s %s en-us %s N/A %s %s 20", AL_TPL_HTTP_PATH, $GLOBALS["AL_CFG"]["siteName"], $GLOBALS["AL_LANG"]["hpNews"], $GLOBALS["AL_CFG"]["siteURL"], $GLOBALS["AL_CFG"]["siteURL"], AL_HELPER::GetAdminEmail(), $uDate); for($i = 0; $i < sizeof($arrNews); $i++) { $title = AL_HELPER::_MakeSafeForRSS($arrNews[$i]["Title"]); $desc = AL_HELPER::_MakeSafeForRSS($arrNews[$i]["Content"]); $author = AL_HELPER::_MakeSafeForRSS(sprintf("%s %s", $arrNews[$i]["FirstName"], $arrNews[$i]["LastName"])); $date = date("D, d M Y H:i:s T", $arrNews[$i]["SD"]); if($arrNews[$i]["Link"] != "" && $arrNews[$i]["Link"] != "http://") $link = $arrNews[$i]["Link"]; else $link = $GLOBALS["AL_CFG"]["siteURL"]; $output .= sprintf(" %s %s %s %s %s ", utf8_encode($title), $link, str_replace("©", "", utf8_encode($desc)), $author, $date); } $output .= " "; echo $output; die(); } function GetRecentNewsList() { // Get a list of recent articles to show $nr = array(); $query = sprintf("select *, unix_timestamp(StartDate) as SD from %snews inner join %susers on %snews.AuthorID = %susers.UserID where Visible=1 and %snews.Status=1 and unix_timestamp(StartDate) <= %s and (ExpiryDate >= %s or EnableExpiry=0) order by StartDate DESC, ItemID DESC limit 10", $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], time(), time()); $newsResult = mysql_query($query); $NumNews = mysql_num_rows($newsResult); if(mysql_num_rows($newsResult) > 0) { while($newsRow = mysql_fetch_array($newsResult)) { $nr[] = $newsRow; } } return $nr; } function _SetData() { $query = sprintf("select *, unix_timestamp(StartDate) as SD from %snews inner join %susers on %snews.AuthorID = %susers.UserID where ItemID='%d'", $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $this->GetNewsId()); $result = mysql_query($query); if($row = mysql_fetch_array($result)) $this->_data = $row; $metaKeys = trim($row["MetaKeywords"]); if(!empty($metaKeys)){ $GLOBALS["AL_CFG"]["siteKeywords"] = $row["MetaKeywords"]; } $metaDesc = trim($row["MetaDesc"]); if(!empty($metaDesc)){ $GLOBALS["AL_CFG"]["siteDesc"] = $row["MetaDesc"]; } } function GetNewsId() { return $this->_newsId; } function _SetNewsId() { $uri = $_SERVER["REQUEST_URI"]; $iPos = strpos($uri, "/news/"); $iPos += strlen("/news/"); $uri1 = substr($uri, $iPos, 100); $jPos = strpos($uri1, "/"); $id = substr($uri1, 0, $jPos); if(is_numeric($id)) $this->_newsId = $id; else $this->_newsId = 0; if(isset($_REQUEST["NewsId"])) $this->_newsId = $_REQUEST["NewsId"]; } function _SetPage() { $uri = $_SERVER["REQUEST_URI"]; if($this->_newsId > 0) { $this->_action = "viewnews"; } else { $this->_action = ""; } } } ?>