類別Blogs的繼承圖:

公開方法(Public Methods) | |
| getBlogInfo ($blogId, $extendedInfo=false) | |
| getBlogInfoByName ($blogName, $extendedInfo=false) | |
| getBlogCreateDate ($blogId) | |
| getBlogUpdateDate ($blogId) | |
| getBlogViewedTotal ($blogId) | |
| getBlogTotalPosts ($blogId) | |
| getBlogTotalComments ($blogId) | |
| getBlogTotalTrackbacks ($blogId) | |
| getBlogSettingsFromField ($settingsField) | |
| getBlogSettings ($blogId) | |
| updateBlog ($blogId, &$blogInfo) | |
| updateBlogSettings ($blogId, $blogSettings) | |
| updateNotify ($blogInfo) | |
| addBlog (&$blog) | |
| getAllBlogs ($status=BLOG_STATUS_ALL, $page=-1, $itemsPerPage=DEFAULT_ITEMS_PER_PAGE) | |
| getAllBlogIds () | |
| getNumBlogs ($status=BLOG_STATUS_ALL) | |
| deleteBlog ($blogId) | |
| disableBlog ($blogId) | |
私有方法(Private Methods) | |
| _getBlogInfoFromQuery ($query, $extendedInfo=false) | |
| _fillBlogInformation ($query_result, $extended=false) | |
定義在 blogs.class.php 檔案之第 21 行.
|
||||||||||||
|
Private function. 定義在 blogs.class.php 檔案之第 81 行. 參考 $blogInfo. 被參考於 _getBlogInfoFromQuery(), 及 getAllBlogs(). 00082 { 00083 $blogInfo = new BlogInfo( stripslashes($query_result["blog"]), 00084 $query_result["owner_id"], 00085 stripslashes($query_result["about"]), 00086 unserialize($query_result["settings"]), 00087 $query_result["id"] ); 00088 00089 // load information about the blog owner 00090 $blogInfo->setStatus( $query_result["status"] ); 00091 $blogInfo->setMangledBlog( $query_result["mangled_blog"] ); 00092 00093 return $blogInfo; 00094 }
|
|
||||||||||||
|
定義在 blogs.class.php 檔案之第 56 行. 參考 $blogInfo, $query, $result, _fillBlogInformation(), Model::Execute(), 及 getBlogSettingsFromField(). 被參考於 getBlogInfo(), 及 getBlogInfoByName(). 00057 { 00058 $result = $this->Execute( $query ); 00059 00060 if( !$result ) 00061 return false; 00062 00063 if( $result->RecordCount() == 0 ) 00064 return false; 00065 00066 $row = $result->FetchRow( $result ); 00067 $blogInfo = $this->_fillBlogInformation( $row, $extendedInfo ); 00068 $blogSettings = $this->getBlogSettingsFromField( $row["settings"] ); 00069 $blogInfo->setSettings( $blogSettings ); 00070 00071 $result->Close(); 00072 00073 return $blogInfo; 00074 }
|
|
|
Adds a new blog to the database.
定義在 blogs.class.php 檔案之第 390 行. 參考 $query, $result, Model::Execute(), getBlogInfoByName(), 及 Db::qstr(). 00391 { 00392 // ititalize iterator to get unique mangled blog names 00393 $i = 0; 00394 00395 // check if there already is a blog with the same mangled name 00396 while( $this->getBlogInfoByName( $blog->getMangledBlog() ) ) 00397 { 00398 $i++; 00399 00400 // and if so, assign a new one (if we already tried with blogname+"i" we have to strip "i" before adding it again!) 00401 $newMangledName = ( ($i > 1) ? substr( $blog->getMangledBlog(), 0, strlen( $blog->getMangledBlog() )- strlen($i-1) ).$i : $blog->getMangledBlog().$i ); 00402 $blog->setMangledBlog( $newMangledName ); 00403 00404 } 00405 00406 00407 $blogSettings = $blog->getSettings(); 00408 if( !$blogSettings ) 00409 $blogSettings = new BlogSettings(); 00410 00411 $query = "INSERT INTO ".$this->getPrefix()."blogs (blog,owner_id,about,settings,mangled_blog,status) 00412 VALUES ('".Db::qstr($blog->getBlog())."',". 00413 $blog->getOwner().",'". 00414 Db::qstr($blog->getAbout())."', '". 00415 Db::qstr(serialize($blogSettings))."', '". 00416 $blog->getMangledBlog()."', '". 00417 Db::qstr($blog->getStatus())."')"; 00418 00419 $result = $this->Execute( $query ); 00420 00421 if( !$result ) 00422 return false; 00423 00424 00425 $blogId = $this->_db->Insert_ID(); 00426 00427 $blog->setId( $blogId ); 00428 00429 // create the row for the bayesian filter info 00430 $bayesianFilterInfo = new BayesianFilterInfos(); 00431 $bayesianFilterInfo->insert( $blogId ); 00432 00433 // and return the blog identifier 00434 return $blogId; 00435 }
|
|
|
Removes a blog from the database. It also removes all its posts, its posts categories its links, its links categories, its trackbacks and its comments
定義在 blogs.class.php 檔案之第 515 行. 參考 $articles, $query, $result, 及 Model::Execute(). 00516 { 00517 // first of all, delete the posts 00518 $articles = new Articles(); 00519 $articles->deleteBlogPosts( $blogId ); 00520 00521 // next is to remove the article categories 00522 $articleCategories = new ArticleCategories(); 00523 $articleCategories->deleteBlogCategories( $blogId ); 00524 00525 // next, all the links and links categories 00526 $myLinks = new MyLinks(); 00527 $myLinks->deleteBlogMyLinks( $blogId ); 00528 $myLinksCategories = new MyLinksCategories(); 00529 $myLinksCategories->deleteBlogMyLinksCategories( $blogId ); 00530 00531 // the permissions for the blog 00532 $perms = new UserPermissions(); 00533 $perms->revokeBlogPermissions( $blogId ); 00534 00535 // and finally, delete the blog 00536 $query = "DELETE FROM ".$this->getPrefix()."blogs WHERE id = $blogId"; 00537 00538 $result = $this->Execute( $query ); 00539 00540 return $result; 00541 }
|
|
|
disables a blog
定義在 blogs.class.php 檔案之第 548 行. 參考 $query, $result, Model::Execute(), 及 Db::qstr(). 00549 { 00550 $query = "UPDATE ".$this->getPrefix()."blogs 00551 SET status = '".BLOG_STATUS_DISABLED."' 00552 WHERE id = '".Db::qstr($blogId)."'"; 00553 00554 $result = $this->Execute( $query ); 00555 00556 if( !$result ) 00557 return false; 00558 00559 if( $this->_db->Affected_Rows() == 0 ) 00560 return false; 00561 00562 return true; 00563 }
|
|
|
returns only an array with all the blog ids
定義在 blogs.class.php 檔案之第 476 行. 參考 $query, $result, 及 Model::Execute(). 00477 { 00478 $query = "SELECT id FROM ".$this->getPrefix()."blogs"; 00479 00480 $result = $this->Execute( $query ); 00481 if( !$result ) 00482 return Array(); 00483 00484 $blogIds = Array(); 00485 while( $row = $result->FetchRow()) { 00486 $blogIds[] = $row['id']; 00487 } 00488 00489 $result->Close(); 00490 00491 return $blogIds; 00492 }
|
|
||||||||||||||||
|
Returns all the blogs defined for the site in an array, sorted by its blog identifier.
定義在 blogs.class.php 檔案之第 448 行. 參考 $blogs, $query, $result, _fillBlogInformation(), 及 Model::Execute(). 00449 { 00450 if( $status != BLOG_STATUS_ALL ) 00451 $where = "WHERE status = '".Db::qstr($status)."'"; 00452 00453 $query = "SELECT * FROM ".$this->getPrefix()."blogs $where ORDER BY blog $limits"; 00454 00455 $result = $this->Execute( $query, $page, $itemsPerPage ); 00456 00457 if( !$result ) 00458 return false; 00459 00460 $blogs = Array(); 00461 while( $row = $result->FetchRow()) { 00462 $blog = $this->_fillBlogInformation( $row, true ); 00463 $blogs[$blog->getId()] = $blog; 00464 } 00465 00466 $result->Close(); 00467 00468 return $blogs; 00469 }
|
|
|
Retrieves the first article date timestamp
定義在 blogs.class.php 檔案之第 102 行. 00103 { 00104 $query = "SELECT date FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId. " ORDER BY date ASC LIMIT 0,1" ; 00105 00106 $result = $this->_db->Execute( $query ); 00107 00108 if (!$result) 00109 return false; 00110 00111 $row = $result->FetchRow(); 00112 00113 if (!isset($row["date"])) 00114 return false; 00115 00116 return $row["date"]; 00117 }
|
|
||||||||||||
|
Returns information about a blog.
定義在 blogs.class.php 檔案之第 31 行. 參考 $query, _getBlogInfoFromQuery(), 及 Db::qstr(). 00032 { 00033 $query = "SELECT * FROM ".$this->getPrefix()."blogs WHERE id = '".Db::qstr($blogId)."'"; 00034 00035 return $this->_getBlogInfoFromQuery( $query, $extendedInfo ); 00036 }
|
|
||||||||||||
|
Returns information about a blog.
定義在 blogs.class.php 檔案之第 44 行. 參考 $blogName, $query, _getBlogInfoFromQuery(), 及 Db::qstr(). 被參考於 addBlog(), 及 updateBlog(). 00045 { 00046 $query = "SELECT * FROM ".$this->getPrefix()."blogs WHERE mangled_blog = '".Db::qstr($blogName)."';"; 00047 00048 //$this->_db->debug=true; 00049 00050 return $this->_getBlogInfoFromQuery( $query, $extendedInfo ); 00051 }
|
|
|
Retrieves the blog settings given its id
定義在 blogs.class.php 檔案之第 268 行. 參考 $query, $result, Model::Execute(), 及 getBlogSettingsFromField(). 00269 { 00270 $query = "SELECT settings FROM ".$this->getPrefix()."blogs WHERE id = ".$blogId; 00271 00272 $result = $this->Execute( $query ); 00273 00274 $row = $result->FetchRow(); 00275 00276 $result->Close(); 00277 00278 return $this->getBlogSettingsFromField( $row["settings"] ); 00279 }
|
|
|
Retrieves the blog settings
定義在 blogs.class.php 檔案之第 244 行. 被參考於 ArticleComments::_fillCommentInformation(), Trackbacks::_fillTrackbackInformation(), _getBlogInfoFromQuery(), Trackbacks::getArticleTrackBacks(), Trackbacks::getArticleTrackBacksByIds(), getBlogSettings(), ArticleComments::getPostComments(), 及 ArticleComments::getPostCommentsByIds(). 00245 { 00246 if( $settingsField == "" || $settingsField == null ) { 00247 $settings = new BlogSettings(); 00248 } 00249 else { 00250 $settings = unserialize( $settingsField ); 00251 if( !is_object($settings)) { 00252 // if the BlogSettings object is not valid, return a valid one 00253 // with some of the default settings, so that at least 00254 // the blog will keep working! 00255 $settings = new BlogSettings(); 00256 } 00257 } 00258 00259 return $settings; 00260 }
|
|
|
Retrieves the total number of comments in a blog
定義在 blogs.class.php 檔案之第 196 行. 參考 $query, $result, 及 Model::getPrefix(). 00197 { 00198 $query = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."articles_comments AS c, ".$this->getPrefix()."articles AS a WHERE ((a.blog_id = $blogId) AND (a.id = c.article_id)) AND c.status = ".COMMENT_STATUS_NONSPAM; 00199 $result = $this->_db->Execute( $query ); 00200 00201 if (!$result) 00202 return false; 00203 00204 $row = $result->FetchRow(); 00205 00206 if (!isset($row["total"])) 00207 return false; 00208 00209 $comments = intval($row["total"]); 00210 00211 $result->Close(); 00212 00213 return( $comments ); 00214 }
|
|
|
Retrieves the total number of posts in a blog
定義在 blogs.class.php 檔案之第 170 行. 00171 { 00172 $query = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."articles WHERE blog_id = $blogId AND status = ".POST_STATUS_PUBLISHED; 00173 $result = $this->_db->Execute( $query ); 00174 00175 if (!$result) 00176 return false; 00177 00178 $row = $result->FetchRow(); 00179 00180 if (!isset($row["total"])) 00181 return false; 00182 00183 $posts = intval($row["total"]); 00184 00185 $result->Close(); 00186 00187 return( $posts ); 00188 }
|
|
|
Retrieves the total number of trackbacks in a blog
定義在 blogs.class.php 檔案之第 222 行. 參考 $query, $result, 及 Model::getPrefix(). 00223 { 00224 $query = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."trackbacks AS t, ".$this->getPrefix()."articles AS a WHERE ((a.blog_id = $blogId) AND (a.id = t.article_id))"; 00225 $result = $this->_db->Execute( $query ); 00226 00227 if (!$result) 00228 return false; 00229 00230 $row = $result->FetchRow(); 00231 00232 if (!isset($row["total"])) 00233 return false; 00234 00235 return intval($row["total"]); 00236 }
|
|
|
Retrieves the last article date timestamp
定義在 blogs.class.php 檔案之第 125 行. 00126 { 00127 $query = "SELECT date FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId. " ORDER BY date DESC LIMIT 0,1" ; 00128 $result = $this->_db->Execute( $query ); 00129 00130 if (!$result) 00131 return false; 00132 00133 $row = $result->FetchRow(); 00134 00135 if (!isset($row["date"])) 00136 return false; 00137 00138 return $row["date"]; 00139 }
|
|
|
Retrieves the total number of reads of all articles in that blog
定義在 blogs.class.php 檔案之第 147 行. 00148 { 00149 $query = "SELECT SUM(num_reads) as total FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId; 00150 00151 $result = $this->_db->Execute( $query ); 00152 00153 if (!$result) 00154 return false; 00155 00156 $row = $result->FetchRow(); 00157 00158 if (!isset($row["total"])) 00159 return false; 00160 00161 return $row["total"]; 00162 }
|
|
|
returns the total number of blogs in the site
定義在 blogs.class.php 檔案之第 499 行. 參考 Model::getNumItems(), 及 Model::getPrefix(). 00500 { 00501 $prefix = $this->getPrefix(); 00502 $table = "{$prefix}blogs"; 00503 if( $status != BLOG_STATUS_ALL ) 00504 $cond = "status = '".Db::qstr($status)."'"; 00505 00506 return( $this->getNumItems( $table, $cond )); 00507 }
|
|
||||||||||||
|
Updates the configuration of a blog
定義在 blogs.class.php 檔案之第 288 行. 參考 $blogInfo, $query, $result, Model::Execute(), getBlogInfoByName(), 及 Db::qstr(). 00289 { 00290 // ititalize iterator to get unique mangled blog names 00291 $i = 0; 00292 00293 // check if there already is a blog with the same mangled name 00294 while( ($blog = $this->getBlogInfoByName( $blogInfo->getMangledBlog() )) ) 00295 { 00296 $i++; 00297 00298 // and if so, assign a new one but making sure that we are not actually 00299 // seeing ourselves! 00300 if( $blog->getID() != $blogInfo->getID()) { 00301 00302 // if we already tried with blogname+"i" we have to strip "i" before adding it again! 00303 $newMangledName = ( ($i > 1) ? substr( $blogInfo->getMangledBlog(), 0, strlen( $blogInfo->getMangledBlog() ) - strlen($i-1) ).$i : $blogInfo->getMangledBlog().$i ); 00304 $blogInfo->setMangledBlog( $newMangledName ); 00305 } else 00306 { 00307 // break out if we are seeing ourselves, no need to change the mangled name! 00308 break; 00309 } 00310 00311 } 00312 00313 $query = "UPDATE ".$this->getPrefix()."blogs SET 00314 blog = '".Db::qstr($blogInfo->getBlog()). 00315 "', about = '".Db::qstr($blogInfo->getAbout()). 00316 "', settings = '".serialize($blogInfo->getSettings()). 00317 "', owner_id = ".$blogInfo->getOwner(). 00318 ", mangled_blog = '".$blogInfo->getMangledBlog(). 00319 "', status = '".Db::qstr($blogInfo->getStatus()). 00320 "' WHERE id = '".Db::qstr($blogId)."';"; 00321 00322 $result = $this->Execute( $query ); 00323 00324 return $result; 00325 }
|
|
||||||||||||
|
Updates the settings of a blog
定義在 blogs.class.php 檔案之第 334 行. 參考 $query, $result, 及 Model::Execute(). 00335 { 00336 $query = "UPDATE ".$this->getPrefix()."blogs SET settings = '".serialize($blogSettings)."' WHERE id = ".$blogId; 00337 00338 $result = $this->Execute( $query ); 00339 00340 return $result; 00341 }
|
|
|
Sends a weblogsUpdate.ping xmlrpc call to notifiy of changes in this blog
定義在 blogs.class.php 檔案之第 349 行. 參考 $blogInfo, $config, $host, $result, $rg, Config::getConfig(), 及 getValue(). 00350 { 00351 // if this feature is not enabled, we quit 00352 $config =& Config::getConfig(); 00353 if( !$config->getValue( "xmlrpc_ping_enabled" )) 00354 return; 00355 00356 // get the array which contains the hosts 00357 $hosts = $config->getValue( "xmlrpc_ping_hosts" ); 00358 00359 // if it is not an array, quit 00360 if( !is_array($hosts)) 00361 return; 00362 00363 // if no hosts, we can quit too 00364 if( empty($hosts)) 00365 return; 00366 00367 // otherwise, we continue 00368 $xmlrpcPingResult = Array(); 00369 $rg =& RequestGenerator::getRequestGenerator( $blogInfo ); 00370 $blogLink = $rg->blogLink(); 00371 foreach( $hosts as $host ) { 00372 $client = new XmlRpcClient( $host ); 00373 $result = $client->ping( $blogInfo->getBlog(), $blogLink); 00374 //print("result = ".$result. "is Error = ".$client->isError()." message: ".$client->getErrorMessage()."<br/>"); 00375 //$xmlrpcPingResult[$result["host"] 00376 $xmlrpcPingResult=array_merge($xmlrpcPingResult, $result); 00377 } 00378 00379 return $xmlrpcPingResult; 00380 }
|