_SetBlogId();
$this->_SetPage();
$this->_SetData();
}
function HandlePage()
{
// Determine which function to load
switch($this->_action)
{
case "viewblog":
{
$this->ShowBlog();
break;
}
case "newcomment":
{
$this->NewComment();
break;
}
case "submitcomment":
{
$this->SaveComment();
break;
}
default:
{
$this->ShowBlogs();
break;
}
}
}
function GetTitle()
{
return($this->_data["Title"]);
}
function GetAuthorName()
{
return(sprintf("%s %s", $this->_data["FirstName"], $this->_data["LastName"]));
}
function GetAuthorId()
{
return $this->_data["AuthorID"];
}
function GetDate()
{
return $this->_data["SD"];
}
function GetContent()
{
// Get the content and then escape the glossary words
$output = $this->_data["Content"];
// Get all glossary words
$arrWords = AL_HELPER::GetGlossaryTerms();
if(sizeof($arrWords) > 0)
{
// Make the replacements
for($i = 0; $i < sizeof($arrWords); $i++)
{
$output = str_replace($arrWords[$i]["word"], $arrWords[$i]["token"], $output);
}
}
if(sizeof($arrWords) > 0)
{
// Make the replacements
for($i = 0; $i < sizeof($arrWords); $i++)
{
// Just replace the first instanse of the token
$title = str_replace("'","\'",str_replace("\r\n", "
", str_replace('"', '', $arrWords[$i]["desc"])));
$popup = "" . $arrWords[$i]["word"] . "
" . $title . "'); return false\">" . $arrWords[$i]["word"] . "";
// Replace the rest of the tokens back with the word
$output = str_replace($arrWords[$i]["token"], $popup, $output);
}
}
return $output;
}
function _SetData()
{
$query = sprintf("select *, unix_timestamp(PublishDate) as SD from %sblogs inner join %susers on %sblogs.AuthorID = %susers.UserID where EntryID='%d'", $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $this->GetBlogId());
$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 GetBlogId()
{
return $this->_blogId;
}
function _SetBlogId()
{
$uri = $_SERVER["REQUEST_URI"];
$iPos = strpos($uri, "/blogs/");
$iPos += strlen("/blogs/");
$uri1 = substr($uri, $iPos, 100);
$jPos = strpos($uri1, "/");
$id = substr($uri1, 0, $jPos);
if(is_numeric($id))
$this->_blogId = $id;
else
$this->_blogId = 0;
if(isset($_REQUEST["BlogId"]))
$this->_blogId = $_REQUEST["BlogId"];
}
function _SetPage()
{
$uri = str_replace("?BPage=".$_GET['BPage'], "",$_SERVER["REQUEST_URI"]);
$uri = str_replace("?Page=".$_GET['Page'], "",$uri);
if(eregi("/blogs/?$", $uri))
{
$this->_action = "";
}
else if(is_numeric(strpos($uri, "/newcomment")))
{
$this->_action = "newcomment";
}
else if(is_numeric(strpos($uri, "/submitcomment")))
{
$this->_action = "submitcomment";
}
else
{
$this->_action = "viewblog";
}
}
function GetRSS()
{
ob_end_clean();
header("Content-Type: text/xml");
$arrBlog = $this->GetRecentBlogList();
$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"]["hpBlogs"], $GLOBALS["AL_CFG"]["siteURL"], $GLOBALS["AL_CFG"]["siteURL"], AL_HELPER::GetAdminEmail(), $uDate);
for($i = 0; $i < sizeof($arrBlog); $i++)
{
$title = AL_HELPER::_MakeSafeForRSS($arrBlog[$i]["Title"]);
$desc = AL_HELPER::_MakeSafeForRSS($arrBlog[$i]["Content"]);
$author = AL_HELPER::_MakeSafeForRSS(sprintf("%s %s", $arrBlog[$i]["FirstName"], $arrBlog[$i]["LastName"]));
$date = date("D, d M Y H:i:s T", $arrBlog[$i]["SD"]);
$link = AL_HELPER::BlogLink($arrBlog[$i]["EntryID"], $arrBlog[$i]["Title"]);
$output .= sprintf("
-
%s
%s
%s
%s
%s
", utf8_encode($title), $link, str_replace("©", "", utf8_encode($desc)), $author, $date);
}
$output .= "
";
echo $output;
die();
}
function GetRecentBlogList()
{
// Get a list of recent articles to show
$br = array();
$query = sprintf("select *, unix_timestamp(PublishDate) as SD from %sblogs inner join %susers on %sblogs.AuthorID = %susers.UserID where Visible=1 and %sblogs.Status=1 and unix_timestamp(PublishDate) <= %s order by PublishDate DESC, EntryID DESC limit 10", $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], time());
$blogResult = mysql_query($query);
$NumNews = mysql_num_rows($blogResult);
if(mysql_num_rows($blogResult) > 0)
{
while($blogRow = mysql_fetch_array($blogResult))
{
$br[] = $blogRow;
}
}
return $br;
}
function ShowBlog()
{
// Hide the panels we don't need
$GLOBALS["HidePanels"] = array("ViewBlogsPanel",
"SubmitCommentPanel"
);
// Load the view article page
$GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($this->GetTitle());
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("Blogs");
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
}
function ShowBlogs()
{
// Hide the panels we don't need
$GLOBALS["HidePanels"] = array("ViewBlogEntryPanel",
"SubmitCommentPanel"
);
// Load the view article page
$GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($GLOBALS["AL_CFG"]["siteName"]);
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("Blogs");
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
}
function NewComment()
{
if(isset($_GET["done"]))
$GLOBALS["HideForm"] = "none";
// Hide the panels we don't need
$GLOBALS["HidePanels"] = array("ViewBlogEntryPanel",
"ViewBlogsPanel"
);
if(!isset($_SESSION['CommentMessage'])){
// Load the post comment form
$uri = $_SERVER['REQUEST_URI'];
$ray = explode("?",$uri);
if(is_numeric(str_replace("BlogId=","",$ray[1]))){
$GLOBALS["ContentId"] = str_replace("BlogId=","",$ray[1]);
}else{
$GLOBALS["ContentId"] = $this->GetBlogId();
}
}
$GLOBALS["ContentType"] = 2;
$GLOBALS["AL_CLASS_TEMPLATE"]->SetPageTitle($GLOBALS["AL_LANG"]["artSubmitComment"]);
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("Blogs");
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
}
function SaveComment()
{
// Save the users comment/rating for this article
$blogId = $_POST["ContentId"];
$blogRating = $_POST["ArticleRating"];
if(isset($_POST["ArticleComment"]))
$blogComment = $_POST["ArticleComment"];
else
$blogComment = "";
if(isset($_POST["SendToAuthor"]))
$blogSendToAuthor = true;
else
$blogSendToAuthor = false;
if(isset($_POST["PostOnSite"]))
$blogPost = true;
else
$blogPost = false;
if(isset($_POST["ContentType"]))
$contentType = $_POST["ContentType"];
else
$contentType = 1;
if(isset($_POST["FromName"]))
$fromName = $_POST["FromName"];
else
$fromName = "";
if(isset($_POST["FromEmail"]))
$fromEmail = $_POST["FromEmail"];
else
$fromEmail = "";
if($blogComment != "")
$source = 1;
else
$source = 0;
// Save the comment and then redirect
AL_HELPER::SaveComment($blogId, $blogRating, $blogComment, $blogSendToAuthor, $blogPost, 2, 0, $fromName, $fromEmail, $source);
}
}
?>