【php开源代码栏目提醒】:网学会员为需要php开源代码的朋友们搜集整理了class.BlogInfo.php相关资料,希望对各位网友有所帮助!
<?php
include_once("lib.php");
include_once("class.BlogEntry.php");
include_once("class.BlogUser.php");
class BlogInfo {
// private variables
var $blogId; // blog_list.blog_id
var $blogTitle; // blog_list.title
var $blogTagline; //blog_list.tagline
var $blogAdminUserId; // blog_list.admin
var $blogAdminName; // blog_list.admin -> blog_users.name
var $blogAdminEmail; // blog_list.admin -> blog_users.email
var $blogAdminURL; // blog_list.admin -> blog_users.url
var $blogUsers = array(); // list of BlogUser objects with access to this blog
var $blogURL; // the url where this blog can be reached.
var $blogTemplateId; // id of the template being used for this blog.
var $blogEntries; // an array of entries for this blog. empty by default.
// constructor- used to create the BlogInfo instance
// and populate it with information about the blog.
function BlogInfo ($blogId) {
global $db;
global $baseurl;
global $blogurl;
// general info.
$res = $db->Execute("select * from blog_list where blog_id=$blogId");
$this->blogId = $blogId;
$this->blogTitle = $res->fields['title'];
$this->blogTagline = $res->fields['tagline'];
$this->blogTemplateId = $res->fields['temp_id'];
$this->blogAdminUserId = $res->fields['admin'];
// list of authorized users.
$blogUsers = array();
$res = $db->Execute("select ba.user_id as user_id, ba.admin as admin, bu.login as login, bu.name as name, bu.email as email from blog_acl ba, blog_users bu where ba.blog_id=$blogId and ba.user_id = bu.id");
while (!$res->EOF) {
$blogUsers[] =& new BlogUser($res->fields['user_id'], $res->fields['login'],
$res->fields['email'], $res->fields['name'],
$res->fields['admin']);
$res->MoveNext();
}
$this->blogUsers = $blogUsers;
// build the blog URL, assuming the demo.php page is
$this->blogURL = "$blogurl?blogid=$blogId";
// get the admin user info fields.
$sql = "select * from blog_users where id=$this->blogAdminUserId";
$rs = $db->Execute($sql);
$this->blogAdminName = $rs->fields['name'];
$this->blogAdminEmail = $rs->fields['email'];
$this->blogAdminURL = $rs->fields['url'];
}
// getters and setters
function getBlogId() {
return $this->blogId;
}
// no setter for blog_id, it is immutable.
function getBlogTitle() {
return $this->blogTitle;
}
function setBlogTitle($title) {
global $db;
$sql = "update blog_list set title='$title' where blog_id=$this->blogId";
if ($db->Execute($sql) === true) {
// the update was successful
$this->blogTitle = $title;
}
}
function getBlogTagline() {
return $this->blogTagline;
}
function setBlogTagline($tag) {
global $db;
$sql = "update blog_list set tagline='$tag' where blog_id=$this->blogId";
if ($db->Execute($sql) === true) {
// the update was successful
$this->blogTagline = $tag;
}
}
function getBlogURL() {
return $this->blogURL;
}
// no setter for blog URL, as there is no place to put it.
// it would be nice to upgrade the blog_list table to include
// the blog_url.
#function getLastUpdate() {
# return $this->lastUpdate;
#}
// no setter for last update.
function getBlogTemplateId() {
return $this->blogTemplateId;
}
// more full featured version...
function getBlogTemplate() {
global $db;
$sql = "select template from blog_template where temp_id = $this->blogTemplateId";
$rs = $db->Execute($sql);
return $rs->fields['template'];
}
// no setter for blog template id.
function getBlogAdminName() {
return $this->blogAdminName;
}
function getBlogAdminEmail() {
return $this->blogAdminEmail;
}
function getBlogAdminURL() {
return $this->blogAdminURL;
}
function getBlogUsers() {
return $this->blogUsers;
}
// return the timestamp when this blog was last updated.
function getLastUpdate() {
// last updated.
global $db;
$res = $db->Execute("select max(date) as date from blog_entries where blog_id = $this->blogId");
return date("r", strtotime($res->fields['date']));
}
// use this function to get a single numbered BlogEntry object
// for this blog.
function getBlogEntryById($entryId) {
global $db;
// the sql to grab the speicific entry.
$
sql = "select * from blog_entries where blog_entry_id=$entryId and blog_id = $this->blogId";
$rs = $db->Execute($sql);
// may have zero entries. in that case, return null.
if (!$rs) {
// the result set is empty. return null.
return NULL;
} else {
if (!$rs->EOF) {
// create the new blog entry object...
$blogEntry = new BlogEntry($rs);
}
}
return $blogEntry;
}
// this will remove the blog entry. this will
// perform any