[Cs-cms-commits] SF.net SVN: cs-cms:[7] trunk/0.1
Status: Alpha
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-20 05:46:34
|
Revision: 7 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=7&view=rev Author: crazedsanity Date: 2009-02-20 05:46:29 +0000 (Fri, 20 Feb 2009) Log Message: ----------- First round of renames... Added Paths: ----------- trunk/0.1/cs_cmsEntry.class.php trunk/0.1/cs_cmsLocation.class.php Removed Paths: ------------- trunk/0.1/csb_blogEntry.class.php trunk/0.1/csb_blogLocation.class.php trunk/0.1/csb_blogUser.class.php Copied: trunk/0.1/cs_cmsEntry.class.php (from rev 5, trunk/0.1/csb_blogEntry.class.php) =================================================================== --- trunk/0.1/cs_cmsEntry.class.php (rev 0) +++ trunk/0.1/cs_cmsEntry.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -0,0 +1,132 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); +require_once(dirname(__FILE__) .'/csb_blogComment.class.php'); + +class csb_blogEntry extends csb_blogAbstract { + + /** Internal name of blog (looks like a permalink) */ + protected $blogName; + + /** Numeric ID of blog */ + protected $blogEntryId=false; + + /** Location of blog */ + protected $blogLocation; + + /** Permalink of current entry (just the title portion) */ + protected $permalink; + + /** Full permalink (location + blogName + permalink) */ + protected $fullPermalink; + + /** csb_blogComment{} object */ + protected $blogCommentObj; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $fullPermalink (str) FULL Permalink. + * @param $dbParams (array) connection options for database + * + * @return exception throws an exception on error. + */ + public function __construct($fullPermalink, array $dbParams=null) { + + //TODO: put these in the constructor args, or require CONSTANTS. + parent::__construct($dbParams); + + if(isset($fullPermalink) && strlen($fullPermalink)) { + + $bits = $this->parse_full_permalink($fullPermalink); + $this->blogLocation = $bits['location']; + $this->blogName = $bits['blogName']; + $this->permalink = $bits['permalink']; + + $data = $this->get_blog_entry($fullPermalink); + $this->blogEntryId = $data['entry_id']; + } + else { + throw new exception(__METHOD__ .": invalid permalink (". $fullPermalink .")"); + } + + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Takes an array for URL, like what contentSystem{} builds, and return the + * contents for the proper blog. + */ + public function display_blog(array $url) { + //TODO: this is very redundant; since this object already has the full permalink, why pass it again? + $fullPermalink = "/". $this->gfObj->string_from_array($url, null, '/'); + $retval = $this->get_blog_entry($fullPermalink); + + return($retval); + }//end display_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Updates a single entry (within a transaction) + * + * @param $blogEntryId (int) entry_id to update. + * @param $updates (array) array of field=>value updates + * + * @return exception throws exception on error. + * @return true returns boolean TRUE on success. + */ + public function update_entry($blogEntryId, array $updates) { + if(is_numeric($blogEntryId) && $blogEntryId > 0 && is_array($updates) && count($updates)) { + $validFields = array( + 'post_timestamp' => 'datetime', + 'content' => 'sql', + 'is_draft' => 'boolean' + ); + $updateThis = array_intersect_key($updates, $validFields); + if(is_array($updateThis) && count($updateThis)) { + + //encode teh content as before. + if(isset($updateThis['content'])) { + $updateThis['content'] = $this->encode_content($updateThis['content']); + } + + $sql = "UPDATE csblog_entry_table SET ". $this->gfObj->string_from_array($updateThis, 'update', NULL, $validFields) + ." WHERE entry_id=". $blogEntryId; + + $this->db->beginTrans(); + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $this->update_blog_last_post_timestamps(); + $this->db->commitTrans(); + $retval = true; + } + else { + $this->db->abortTrans(); + throw new exception(__METHOD__ .": update failed, numrows=(". $numrows ."), dberror"); + } + } + else { + throw new exception(__METHOD__ .": no valid fields in updates array"); + } + } + else { + throw new exception(__METHOD__ .": invalid data passed"); + } + + return($retval); + }//end update_entry() + //------------------------------------------------------------------------- + + + +}// end blog{} +?> Property changes on: trunk/0.1/cs_cmsEntry.class.php ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/0.1/cs_cmsLocation.class.php (from rev 5, trunk/0.1/csb_blogLocation.class.php) =================================================================== --- trunk/0.1/cs_cmsLocation.class.php (rev 0) +++ trunk/0.1/cs_cmsLocation.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -0,0 +1,66 @@ +<?php + + +require_once(dirname(__FILE__) .'/csb_blog.class.php'); + +class csb_blogLocation extends csb_blogAbstract { + + /** An array of blog{} objects. */ + protected $blogObjList; + + /** An array with sub-arrays listing by blog_id, name, etc. */ + protected $blogIndex; + + //------------------------------------------------------------------------- + function __construct($location, array $dbParams=null) { + parent::__construct($dbParams); + + $loc = new csb_location(); + $location = $loc->fix_location($location); + + $criteria = array( + 'is_active' =>"t", + 'bl.location' => $location + ); + + try { + $this->validBlogs = $this->get_blogs($criteria, 'blog_display_name DESC'); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to retrieve any valid blogs for location=(". $location .")... " . + "MORE INFO::: ". $e->getMessage()); + } + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_most_recent_blogs($numPerBlog=1) { + if(is_array($this->validBlogs) && count($this->validBlogs)) { + $retval = array(); + foreach($this->validBlogs as $blogId=>$blogData) { + $blogName = $blogData['blog_name']; + $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); + if(!$this->blogs[$blogName]->is_initialized()) { + $this->blogs[$blogName]->initialize_locals($blogName); + } + $retval[$blogName] = $this->blogs[$blogName]->get_recent_blogs($numPerBlog); + if($numPerBlog == 1) { + $keys = array_keys($retval[$blogName]); + $retval[$blogName] = $retval[$blogName][$keys[0]]; + } + } + } + else { + throw new exception(__METHOD__ .": no valid blogs to handle"); + } + + return($retval); + }//end get_most_recent_blogs() + //------------------------------------------------------------------------- + + + +} +?> \ No newline at end of file Property changes on: trunk/0.1/cs_cmsLocation.class.php ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/0.1/csb_blogEntry.class.php =================================================================== --- trunk/0.1/csb_blogEntry.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogEntry.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,132 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); -require_once(dirname(__FILE__) .'/csb_blogComment.class.php'); - -class csb_blogEntry extends csb_blogAbstract { - - /** Internal name of blog (looks like a permalink) */ - protected $blogName; - - /** Numeric ID of blog */ - protected $blogEntryId=false; - - /** Location of blog */ - protected $blogLocation; - - /** Permalink of current entry (just the title portion) */ - protected $permalink; - - /** Full permalink (location + blogName + permalink) */ - protected $fullPermalink; - - /** csb_blogComment{} object */ - protected $blogCommentObj; - - //------------------------------------------------------------------------- - /** - * The constructor. - * - * @param $fullPermalink (str) FULL Permalink. - * @param $dbParams (array) connection options for database - * - * @return exception throws an exception on error. - */ - public function __construct($fullPermalink, array $dbParams=null) { - - //TODO: put these in the constructor args, or require CONSTANTS. - parent::__construct($dbParams); - - if(isset($fullPermalink) && strlen($fullPermalink)) { - - $bits = $this->parse_full_permalink($fullPermalink); - $this->blogLocation = $bits['location']; - $this->blogName = $bits['blogName']; - $this->permalink = $bits['permalink']; - - $data = $this->get_blog_entry($fullPermalink); - $this->blogEntryId = $data['entry_id']; - } - else { - throw new exception(__METHOD__ .": invalid permalink (". $fullPermalink .")"); - } - - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Takes an array for URL, like what contentSystem{} builds, and return the - * contents for the proper blog. - */ - public function display_blog(array $url) { - //TODO: this is very redundant; since this object already has the full permalink, why pass it again? - $fullPermalink = "/". $this->gfObj->string_from_array($url, null, '/'); - $retval = $this->get_blog_entry($fullPermalink); - - return($retval); - }//end display_blog() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Updates a single entry (within a transaction) - * - * @param $blogEntryId (int) entry_id to update. - * @param $updates (array) array of field=>value updates - * - * @return exception throws exception on error. - * @return true returns boolean TRUE on success. - */ - public function update_entry($blogEntryId, array $updates) { - if(is_numeric($blogEntryId) && $blogEntryId > 0 && is_array($updates) && count($updates)) { - $validFields = array( - 'post_timestamp' => 'datetime', - 'content' => 'sql', - 'is_draft' => 'boolean' - ); - $updateThis = array_intersect_key($updates, $validFields); - if(is_array($updateThis) && count($updateThis)) { - - //encode teh content as before. - if(isset($updateThis['content'])) { - $updateThis['content'] = $this->encode_content($updateThis['content']); - } - - $sql = "UPDATE csblog_entry_table SET ". $this->gfObj->string_from_array($updateThis, 'update', NULL, $validFields) - ." WHERE entry_id=". $blogEntryId; - - $this->db->beginTrans(); - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $this->update_blog_last_post_timestamps(); - $this->db->commitTrans(); - $retval = true; - } - else { - $this->db->abortTrans(); - throw new exception(__METHOD__ .": update failed, numrows=(". $numrows ."), dberror"); - } - } - else { - throw new exception(__METHOD__ .": no valid fields in updates array"); - } - } - else { - throw new exception(__METHOD__ .": invalid data passed"); - } - - return($retval); - }//end update_entry() - //------------------------------------------------------------------------- - - - -}// end blog{} -?> Deleted: trunk/0.1/csb_blogLocation.class.php =================================================================== --- trunk/0.1/csb_blogLocation.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogLocation.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,66 +0,0 @@ -<?php - - -require_once(dirname(__FILE__) .'/csb_blog.class.php'); - -class csb_blogLocation extends csb_blogAbstract { - - /** An array of blog{} objects. */ - protected $blogObjList; - - /** An array with sub-arrays listing by blog_id, name, etc. */ - protected $blogIndex; - - //------------------------------------------------------------------------- - function __construct($location, array $dbParams=null) { - parent::__construct($dbParams); - - $loc = new csb_location(); - $location = $loc->fix_location($location); - - $criteria = array( - 'is_active' =>"t", - 'bl.location' => $location - ); - - try { - $this->validBlogs = $this->get_blogs($criteria, 'blog_display_name DESC'); - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to retrieve any valid blogs for location=(". $location .")... " . - "MORE INFO::: ". $e->getMessage()); - } - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_most_recent_blogs($numPerBlog=1) { - if(is_array($this->validBlogs) && count($this->validBlogs)) { - $retval = array(); - foreach($this->validBlogs as $blogId=>$blogData) { - $blogName = $blogData['blog_name']; - $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); - if(!$this->blogs[$blogName]->is_initialized()) { - $this->blogs[$blogName]->initialize_locals($blogName); - } - $retval[$blogName] = $this->blogs[$blogName]->get_recent_blogs($numPerBlog); - if($numPerBlog == 1) { - $keys = array_keys($retval[$blogName]); - $retval[$blogName] = $retval[$blogName][$keys[0]]; - } - } - } - else { - throw new exception(__METHOD__ .": no valid blogs to handle"); - } - - return($retval); - }//end get_most_recent_blogs() - //------------------------------------------------------------------------- - - - -} -?> \ No newline at end of file Deleted: trunk/0.1/csb_blogUser.class.php =================================================================== --- trunk/0.1/csb_blogUser.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogUser.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,91 +0,0 @@ -<?php - -/* - * This is for displaying blogs for which a user has access. The name is a bit - * of a misnomer, but I couldn't really think of a better name at the time. - */ - - -require_once(dirname(__FILE__) .'/csb_blog.class.php'); - -class csb_blogUser extends csb_blogAbstract { - - /** An array of blog{} objects. */ - protected $blogObjList; - - /** An array with sub-arrays listing by blog_id, name, etc. */ - protected $blogIndex; - - //------------------------------------------------------------------------- - function __construct($user, $location=null, array $dbParams=null) { - if(strlen($user) > 2) { - parent::__construct($dbParams); - - $criteria = array( - 'is_active'=>"t" - ); - - if(is_string($location) && strlen($location)) { - $criteria['bl.location'] = $location; - } - $uid = $this->get_uid($user); - if(is_numeric($uid)) { - $this->validBlogs = $this->get_blogs($criteria, 'last_post_timestamp DESC'); - $permObj = new csb_permission($dbParams); - foreach($this->validBlogs as $blogId=>$data) { - $obj = new csb_blog($data['blog_name']); - if(!$permObj->can_access_blog($blogId, $uid)) { - unset($this->validBlogs[$blogId]); - } - } - } - else { - throw new exception(__METHOD__ .": unable to retrieve uid for (". $user .")"); - } - } - else { - throw new exception(__METHOD__ .": no username set (". $user .")"); - } - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_most_recent_blogs($numPerBlog=1) { - if(is_array($this->validBlogs) && count($this->validBlogs)) { - $retval = array(); - foreach($this->validBlogs as $blogId=>$blogData) { - $blogName = $blogData['blog_name']; - $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); - if(!$this->blogs[$blogName]->is_initialized()) { - $this->blogs[$blogName]->initialize_locals($blogName); - } - - $recentBlogs = array(); - try { - $recentBlogs = $this->blogs[$blogName]->get_recent_blogs($numPerBlog, 0, true); - if($numPerBlog == 1) { - $keys = array_keys($retval[$blogName]); - $recentBlogs = $retval[$blogName][$keys[0]]; - } - } - catch(exception $e) { - $this->gfObj->debug_print(__METHOD__ .": no blogs for (". $blogName .")"); - } - $retval[$blogName] = $recentBlogs; - } - } - else { - throw new exception(__METHOD__ .": no valid blogs to handle"); - } - - return($retval); - }//end get_most_recent_blogs() - //------------------------------------------------------------------------- - - - - -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |