Manager::getObject()はキャッシュ機構を持つため、Blogクラスのコンストラクタを置き換えることでSQL文による不要な問い合わせを削減することができ、サーバー側の応答速度の改善につながる。
Revision 1860:
CHANGE: use cache machanism of Manager class to generate Blog object
Manager::getBlog() has cache mechanism. This commit replace
constructor of Blog class to Manager::getBlog() to reduce the number of
SQL query.
http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1860
function bc_doConversion() {
- global $HTTP_POST_VARS;
+ global $HTTP_POST_VARS, $manager;
// 1. get all data
$authorcount = intval($HTTP_POST_VARS['authorcount']);
}
// add authors to blog team
- $b = new Blog($nucleus_blogid);
+ $b =& $manager->getBlog($nucleus_blogid);
global $catid;
$catid = $b->getDefaultCategory();
}
function gmc_doConversion() {
- global $HTTP_POST_VARS;
+ global $HTTP_POST_VARS, $manager;
// 1. get all data
}
// add authors to blog team
- $blog = new Blog($nucleus_blogid);
+ $blog =& $manager->getBlog($nucleus_blogid);
global $catid;
$catid = $blog->getDefaultCategory();
for ($i=0;$i<$authorcount;$i++)
function bc_doConversion() {
- global $HTTP_POST_VARS;
+ global $HTTP_POST_VARS, $manager;
// 1. get all data
$authorcount = intval($HTTP_POST_VARS['authorcount']);
}
// add authors to blog team
- $b = new Blog($nucleus_blogid);
+ $b =& $manager->getBlog($nucleus_blogid);
global $catid;
$catid = $b->getDefaultCategory();
public function pingPingomatic()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogUpdates.ping',
array(
public function pingWeblogs()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogupdates.ping',
array(
public function pingTechnorati()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogUpdates.ping',
array(
public function pingBlogRollingDotCom()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogUpdates.ping',
array(
public function pingBloGs()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogUpdates.extendedPing',
array(
public function pingWebloguesDotCom()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'weblogUpdates.extendedPing',
array(
public function pingBloggDe()
{
- $b = new Blog($this->myBlogId);
+ global $manager;
+
+ $b =& $manager->getBlog($this->myBlogId);
$message = new xmlrpcmsg(
'bloggUpdates.ping',
array(
$blogid = getBlogIDFromItemID($itemid);
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$catid = $blog->getCategoryIdFromName($category);
if ($old['draft'] && $publish) {
* Returns a list of recent items
*/
function _getRecentItemsBlogger($blogid, $username, $password, $amount) {
-
+ global $manager;
+
$blogid = intval($blogid);
$amount = intval($amount);
// 3. create and return list of recent items
// Struct returned has dateCreated, userid, blogid and content
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$structarray = array(); // the array in which the structs will be stored
// Structure returned has dateCreated, userid, blogid and content
$item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
// get category
$item['category'] = $blog->getCategoryName($item['catid']);
}
else
{
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$catid = $blog->getCategoryIdFromName($category);
}
}
function _getRecentItemsMetaWeblog($blogid, $username, $password, $amount) {
-
+ global $manager;
+
$blogid = intval($blogid);
$amount = intval($amount);
// 3. create and return list of recent items
// Struct returned has dateCreated, userid, blogid and content
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$structarray = array(); // the array in which the structs will be stored
}
function _newMediaObject($blogid, $username, $password, $info) {
- global $CONF, $DIR_MEDIA, $DIR_LIBS;
+ global $CONF, $DIR_MEDIA, $DIR_LIBS, $manager;
// - login
$mem = new Member();
if (!$mem->teamRights($blogid))
return _error(3,'Not a team member');
- $b = new Blog($blogid);
+ $b =& $manager->getBlog($blogid);
// - decode data
$data = $info['bits']; // decoding was done transparantly by xmlrpclib
}
function _categoryList($blogid, $username, $password) {
+ global $manager;
+
// 1. login
$mem = new Member();
if (!$mem->login($username, $password))
if (!$mem->teamRights($blogid))
return _error(3,"Not a team member");
- $b = new Blog($blogid);
+ $b =& $manager->getBlog($blogid);
$categorystruct = array();
// 3. return the item
$item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
- $b = new Blog($blogid);
+ $b =& $manager->getBlog($blogid);
if ($b->convertBreaks()) {
$item['body'] = removeBreaks($item['body']);
$item['more'] = removeBreaks($item['more']);
return _error(6,"No such item ($itemid)");
$blogid = getBlogIDFromItemID($itemid);
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
if (!$mem->canAlterItem($itemid))
return _error(7,"Not allowed to alter item");
return _error(6,"No such item ($itemid)");
$blogid = getBlogIDFromItemID($itemid);
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
if (!$mem->canAlterItem($itemid))
return _error(7, 'You are not allowed to request this information');
// get item data
$blogid = getBlogIDFromItemID($itemid);
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$old =& $manager->getItem($itemid,1,1);
return _edititem($itemid, $username, $password, $old['catid'], $old['title'], $old['body'], $old['more'], $old['draft'], 1, $old['closed']);
function _mt_categoryList($blogid, $username, $password) {
+ global $manager;
// 1. login
$mem = new Member();
if (!$mem->login($username, $password))
if (!$mem->teamRights($blogid))
return _error(3,"Not a team member");
- $b = new Blog($blogid);
+ $b =& $manager->getBlog($blogid);
$categorystruct = array();
function _mt_getRecentPostTitles($blogid, $username, $password, $iAmount)
{
+ global $manager;
+
$blogid = intval($blogid);
$iAmount = intval($iAmount);
// 3. create and return list of recent items
// Struct returned has dateCreated, userid, postid and title
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$structarray = array(); // the array in which the structs will be stored
$item =& $manager->getItem($itemid,1,1); // (also allow drafts and future items)
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
if ($blog->convertBreaks())
$item['body'] = removeBreaks($item['body']);
* Adds an item to the given blog. Username and password are required to login
*/
function _addItem($blogid, $username, $password, $title, $body, $more, $publish, $closed, $catname = "") {
- $blog = new Blog($blogid);
+ global $manager;
+ $blog =& $manager->getBlog($blogid);
$timestamp = $blog->getCorrectTime();
return _addDatedItem($blogid, $username, $password, $title, $body, $more, $publish, $closed, $timestamp, 0, $catname);
}
* Adds item to blog, with time of item given
*/
function _addDatedItem($blogid, $username, $password, $title, $body, $more, $publish, $closed = '0', $timestamp, $future, $catname = "") {
+ global $manager;
+
// 1. login
$mem = new Member();
return _error(4,"Cannot add empty items!");
// 3. calculate missing vars
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
// get category id (or id for default category when false category)
$catid = $blog->getCategoryIdFromName($catname);
* Returns a template
*/
function _getSkinPart($blogid, $username, $password, $type) {
+ global $manager;
+
// 1. login
$mem = new Member();
if (!$mem->login($username, $password))
return _error(3,"Not a team member");
// 3. return skin part
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$skin = new SKIN($blog->getDefaultSkin());
return new xmlrpcresp(new xmlrpcval($skin->getContentFromDB($type),"string"));
}
function _setSkinPart($blogid, $username, $password, $content, $type) {
+ global $manager;
+
// 1. login
$mem = new Member();
if (!$mem->login($username, $password))
return _error(3,"Not a team member");
// 3. update skin part
- $blog = new Blog($blogid);
+ $blog =& $manager->getBlog($blogid);
$skin = new SKIN($blog->getDefaultSkin());
$skin->update($type, $content);