[pLog-svn] r7253 - in plog/branches/lifetype-1.2/class: dao dao/status view/admin
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Thu Oct 15 00:17:09 EDT 2020
Author: jondaley
Date: 2020-10-15 00:17:09 -0400 (Thu, 15 Oct 2020)
New Revision: 7253
Modified:
plog/branches/lifetype-1.2/class/dao/articlecommentstatus.class.php
plog/branches/lifetype-1.2/class/dao/articlestatus.class.php
plog/branches/lifetype-1.2/class/dao/blogstatus.class.php
plog/branches/lifetype-1.2/class/dao/status/genericstatuslist.class.php
plog/branches/lifetype-1.2/class/dao/userstatus.class.php
plog/branches/lifetype-1.2/class/view/admin/adminadduserview.class.php
plog/branches/lifetype-1.2/class/view/admin/adminarticlecommentslistview.class.php
plog/branches/lifetype-1.2/class/view/admin/admineditsiteblogview.class.php
plog/branches/lifetype-1.2/class/view/admin/admineditsiteuserview.class.php
plog/branches/lifetype-1.2/class/view/admin/adminnewpostview.class.php
plog/branches/lifetype-1.2/class/view/admin/adminpostslistview.class.php
plog/branches/lifetype-1.2/class/view/admin/adminsiteblogslistview.class.php
plog/branches/lifetype-1.2/class/view/admin/adminsiteuserslistview.class.php
Log:
this is turning into a bigger deal than I expected. The parent class static function had a different number of parameters than the child classes. That was solved by using a non-static class, but that requires a bunch of changes. The alternative way to fix this would be to make a different GenericStatusList function from the children.
Modified: plog/branches/lifetype-1.2/class/dao/articlecommentstatus.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/articlecommentstatus.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/dao/articlecommentstatus.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -15,7 +15,8 @@
class ArticleCommentStatus extends GenericStatusList
{
- function ArticleCommentStatus(){
+ function __construct(){
+ parent::__construct();
$this->_prefix = "COMMENT_STATUS_";
$this->_statusAllId = "COMMENT_STATUS_ALL";
}
@@ -31,10 +32,19 @@
// check if the status is valid
if( $status == "" )
return false;
-
- $isValid = in_array( $status, ArticleCommentStatus::getStatusList());
-
- return $isValid;
+
+ $statusList = $this->getStatusList();
+ return( in_array( $status, $statusList ));
}
+
+ /**
+ * returns the default status code for this class
+ *
+ * @return The default status
+ */
+ static function getDefaultStatus()
+ {
+ return( COMMENT_STATUS_ALL );
}
-?>
+
+ }
Modified: plog/branches/lifetype-1.2/class/dao/articlestatus.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/articlestatus.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/dao/articlestatus.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -21,8 +21,20 @@
*/
class ArticleStatus extends GenericStatusList
{
- function ArticleStatus(){
+ function __construct(){
+ parent::__construct();
$this->_prefix = "POST_STATUS_";
$this->_statusAllId = "POST_STATUS_ALL";
}
+
+ /**
+ * returns the default status code for this class
+ *
+ * @return The default status
+ */
+ static function getDefaultStatus()
+ {
+ return( POST_STATUS_ALL );
}
+
+ }
Modified: plog/branches/lifetype-1.2/class/dao/blogstatus.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/blogstatus.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/dao/blogstatus.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -16,9 +16,10 @@
class BlogStatus extends GenericStatusList
{
- function BlogStatus(){
- $this->_prefix = "BLOG_STATUS_";
- $this->_statusAllId = "BLOG_STATUS_ALL";
+ function __construct(){
+ parent::__construct();
+ $this->_prefix = "BLOG_STATUS_";
+ $this->_statusAllId = "BLOG_STATUS_ALL";
}
/**
@@ -28,8 +29,8 @@
*/
function isValidStatus( $status )
{
- $statusList = BlogStatus::getStatusList( true );
- return( in_array( $status, $statusList ));
+ $statusList = $this->getStatusList( true );
+ return( in_array( $status, $statusList ));
}
/**
@@ -37,7 +38,7 @@
*
* @return The default status
*/
- function getDefaultStatus()
+ static function getDefaultStatus()
{
return( BLOG_STATUS_ALL );
}
Modified: plog/branches/lifetype-1.2/class/dao/status/genericstatuslist.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/status/genericstatuslist.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/dao/status/genericstatuslist.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -15,10 +15,10 @@
class GenericStatusList
{
- var $_prefix;
- var $_statusAllId;
+ protected $_prefix;
+ protected $_statusAllId;
- function GenericStatusList(){
+ function __construct(){
// child classes should set $_prefix and $_statusAllId
}
@@ -32,25 +32,27 @@
*/
function getStatusList( $includeStatusAll = false )
{
- // get all the constants defined so far
- $constants = get_defined_constants();
- $statusList = Array();
-
- if( $includeStatusAll ) {
- $statusAllLowercase = strtolower( $this->_statusAllId );
- $statusList["$statusAllLowercase"] = -1;
- }
-
- foreach( $constants as $constant => $value ) {
- if( substr( $constant, 0, strlen($this->_prefix)) == $this->_prefix && $constant != $this->_statusAllId ) {
- $constant = strtolower($constant);
- $statusList[ "$constant" ] = $value;
- }
+ // get all the constants defined so far
+ $constants = get_defined_constants();
+ $statusList = Array();
+
+ if( $includeStatusAll ) {
+ $statusAllLowercase = strtolower( $this->_statusAllId );
+ $statusList["$statusAllLowercase"] = -1;
+ }
+
+ foreach( $constants as $constant => $value ) {
+ if( substr( $constant, 0, strlen($this->_prefix)) == $this->_prefix &&
+ $constant != $this->_statusAllId )
+ {
+ $constant = strtolower($constant);
+ $statusList[ "$constant" ] = $value;
}
-
- asort( $statusList );
-
- return $statusList;
+ }
+
+ asort( $statusList );
+
+ return $statusList;
}
/**
@@ -61,7 +63,7 @@
*/
function isValidStatus( $status )
{
- return( true );
+ return( true );
}
/**
@@ -71,7 +73,7 @@
*
* @return The default status
*/
- function getDefaultStatus()
+ static function getDefaultStatus()
{
return( true );
}
Modified: plog/branches/lifetype-1.2/class/dao/userstatus.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/userstatus.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/dao/userstatus.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -16,7 +16,8 @@
class UserStatus extends GenericStatusList
{
- function UserStatus(){
+ function __construct(){
+ parent::__construct();
$this->_prefix = "USER_STATUS_";
$this->_statusAllId = "USER_STATUS_ALL";
}
@@ -28,8 +29,8 @@
*/
function isValidStatus( $status )
{
- $statusList = UserStatus::getStatusList( true );
- return( in_array( $status, $statusList ));
+ $statusList = $this->getStatusList( true );
+ return( in_array( $status, $statusList ));
}
/**
@@ -37,7 +38,7 @@
*
* @return The default status
*/
- function getDefaultStatus()
+ static function getDefaultStatus()
{
return( USER_STATUS_ALL );
}
Modified: plog/branches/lifetype-1.2/class/view/admin/adminadduserview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminadduserview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminadduserview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -22,7 +22,9 @@
function render()
{
- $this->setValue( 'userStatusList', UserStatus::getStatusList());
+ $userStatus = new UserStatus();
+
+ $this->setValue( 'userStatusList', $userStatus->getStatusList());
$perms = new Permissions();
$this->setValue( 'permissions', $perms->getAllPermissions());
parent::render();
Modified: plog/branches/lifetype-1.2/class/view/admin/adminarticlecommentslistview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminarticlecommentslistview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminarticlecommentslistview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -48,8 +48,9 @@
// load the status
if( isset( $params["showStatus"] ))
$this->_commentStatus = $params["showStatus"];
-
- if( !ArticleCommentStatus::isValidStatus( $this->_commentStatus ))
+
+ $articleCommentStatus = new ArticleCommentStatus();
+ if( !$articleCommentStatus->isValidStatus( $this->_commentStatus ))
$this->_commentStatus = COMMENT_STATUS_ALL;
// laod the search terms
@@ -116,8 +117,9 @@
DEFAULT_ITEMS_PER_PAGE );
// get a list with all the different comment status
- $statusList = ArticleCommentStatus::getStatusList( true );
- $statusListWithoutAll = ArticleCommentStatus::getStatusList( false );
+ $articleCommentStatus = new ArticleCommentStatus();
+ $statusList = $articleCommentStatus->getStatusList( true );
+ $statusListWithoutAll = $articleCommentStatus->getStatusList( false );
// and pass all the information to the templates
$this->setValue( "comments", $postComments);
Modified: plog/branches/lifetype-1.2/class/view/admin/admineditsiteblogview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/admineditsiteblogview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/admineditsiteblogview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -44,7 +44,8 @@
// and the list of locale availables
$this->setValue( 'locales', LTLocales::getLocales());
$this->setValue( 'blogStatus', $this->_editBlogInfo->getStatus());
- $this->setValue( 'blogStatusList', BlogStatus::getStatusList());
+ $blogStatus = new BlogStatus();
+ $this->setValue( 'blogStatusList', $blogStatus->getStatusList());
$blogSettings = $this->_editBlogInfo->getSettings();
$this->setValue( 'blogTimeOffset', $blogSettings->getValue( 'time_offset' ));
$this->setValue( 'blogOwnerInfo', $this->_editBlogInfo->getOwnerInfo());
Modified: plog/branches/lifetype-1.2/class/view/admin/admineditsiteuserview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/admineditsiteuserview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/admineditsiteuserview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -55,12 +55,14 @@
$userBlogs = $users->getUsersBlogs( $this->_user->getId());
$this->notifyEvent( EVENT_BLOGS_LOADED, Array( 'blogs' => &$userBlogs ));
+ $userStatus = new UserStatus();
+
// otherwise, transfer it to the template context and let the
// template do the rest
$this->setValue( 'edituser', $this->_user );
$this->setValue( 'edituserblogs', $userBlogs );
// list of available status
- $this->setValue( 'userStatusList', UserStatus::getStatusList());
+ $this->setValue( 'userStatusList', $userStatus->getStatusList());
// list of global permisisons
$perms = new Permissions();
$this->setValue( 'permissions', $perms->getAllPermissions());
Modified: plog/branches/lifetype-1.2/class/view/admin/adminnewpostview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminnewpostview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminnewpostview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -44,6 +44,8 @@
$customFields = new CustomFields();
$blogFields = $customFields->getBlogCustomFields( $this->_blogInfo->getId(), false);
+ $articleStatus = new ArticleStatus();
+
// and put everything in the template
$locale = $this->_blogInfo->getLocale();
$this->setValue( "commentsEnabled", $blogSettings->getValue( "comments_enabled" ));
@@ -56,7 +58,7 @@
$this->setValue( "hours", Timestamp::getAllHours());
$this->setValue( "minutes", Timestamp::getAllMinutes());
$this->setValue( "customfields", $blogFields );
- $this->setValue( "poststatus", ArticleStatus::getStatusList());
+ $this->setValue( "poststatus", $articleStatus->getStatusList());
$this->setValue( "sendPings", $config->getValue( "send_xmlrpc_pings_enabled_by_default", true ));
$this->setValue( "xmlRpcPingEnabled", $config->getValue( "xmlrpc_ping_enabled", false ));
$this->setValue( "autoSaveNewDraftsTimeMillis", $config->getValue( "autosave_new_drafts_time_millis" ));
Modified: plog/branches/lifetype-1.2/class/view/admin/adminpostslistview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminpostslistview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminpostslistview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -180,8 +180,9 @@
$blogUsers = $users->getBlogUsers( $this->_blogInfo->getId());
// and all the post status available
- $postStatusList = ArticleStatus::getStatusList( true );
- $postStatusListWithoutAll = ArticleStatus::getStatusList( false );
+ $articleStatus = new ArticleStatus();
+ $postStatusList = $articleStatus->getStatusList( true );
+ $postStatusListWithoutAll = $articleStatus->getStatusList( false );
$this->setValue( "categories", $blogCategories );
// values for the session, so that we can recover the status
Modified: plog/branches/lifetype-1.2/class/view/admin/adminsiteblogslistview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminsiteblogslistview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminsiteblogslistview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -42,9 +42,10 @@
$val = new IntegerValidator();
if( !$val->validate( $status ))
$status = BlogStatus::getDefaultStatus();
-
+
+ $blogStatus = new BlogStatus();
// if the value validated, check if it is a valid status
- if( !BlogStatus::isValidStatus( $status ))
+ if( !$blogStatus->isValidStatus( $status ))
$status = BlogStatus::getDefaultStatus();
return $status;
@@ -73,10 +74,12 @@
$numBlogs,
DEFAULT_ITEMS_PER_PAGE );
+ $blogStatus = new BlogStatus();
+
$this->setValue( "siteblogs", $siteBlogs );
$this->setValue( "pager", $pager );
$this->setValue( "currentstatus", $this->_status );
- $this->setValue( "blogstatus", BlogStatus::getStatusList( true ));
+ $this->setValue( "blogstatus", $blogStatus->getStatusList( true ));
$this->setValue( "searchTerms", $this->_searchTerms );
// let the parent view do its job
Modified: plog/branches/lifetype-1.2/class/view/admin/adminsiteuserslistview.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/view/admin/adminsiteuserslistview.class.php 2020-10-15 02:32:20 UTC (rev 7252)
+++ plog/branches/lifetype-1.2/class/view/admin/adminsiteuserslistview.class.php 2020-10-15 04:17:09 UTC (rev 7253)
@@ -49,7 +49,8 @@
$status = UserStatus::getDefaultStatus();
// if the value validated, check if it is a valid status
- if( !UserStatus::isValidStatus( $status ))
+ $userStatus = new UserStatus();
+ if( !$userStatus->isValidStatus( $status ))
$status = UserStatus::getDefaultStatus();
return $status;
@@ -83,10 +84,12 @@
$this->_page,
$numUsers,
DEFAULT_ITEMS_PER_PAGE );
-
+
+ $userStatus = new UserStatus();
+
// and generate the view
$this->setValue( "siteusers", $siteUsers );
- $this->setValue( "userstatus", UserStatus::getStatusList( true ));
+ $this->setValue( "userstatus", $userStatus->getStatusList( true ));
$this->setValue( "pager", $pager );
$this->setValue( "currentstatus", $this->_status );
$this->setValue( "searchTerms", $this->_searchTerms );
More information about the pLog-svn
mailing list