[pLog-svn] r3180 - in plog/trunk: class/dao class/summary/action
class/summary/view templates/summary
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Apr 4 09:15:44 GMT 2006
Author: mark
Date: 2006-04-04 09:15:43 +0000 (Tue, 04 Apr 2006)
New Revision: 3180
Modified:
plog/trunk/class/dao/blogs.class.php
plog/trunk/class/summary/action/chooseblogtemplateaction.class.php
plog/trunk/class/summary/action/doblogregistration.class.php
plog/trunk/class/summary/action/dofinishregister.class.php
plog/trunk/class/summary/action/registeraction.class.php
plog/trunk/class/summary/view/doblogregistrationview.class.php
plog/trunk/templates/summary/registerstep2.template
plog/trunk/templates/summary/registerstep3.template
plog/trunk/templates/summary/registerstep4.template
Log:
Now, BlogCategory counter works ...
Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/dao/blogs.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -64,6 +64,36 @@
return( "blog LIKE '%".Db::qstr( $searchTerms )."%'" );
}
+ /**
+ * Updates blog category counters
+ *
+ * @private
+ */
+ function updateBlogCategoriesLink( $blogInfo, $oldBlogInfo = null )
+ {
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
+ $blogCategories = new BlogCategories();
+ $blogCategory = $blogInfo->getBlogCategory();
+
+ if( $blogCategory ) {
+ $blogCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$blogCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
+ $blogCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$blogCategory->getId()));
+ $blogCategories->updateBlogCategory( $blogCategory );
+ }
+
+ if( $oldBlogInfo ) {
+ $oldBlogCategory = $oldBlogInfo->getBlogCategory();
+ if ($oldBlogCategory)
+ {
+ $oldBlogCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldBlogCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
+ $oldBlogCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldBlogCategory->getId()));
+ $blogCategories->updateBlogCategory( $oldBlogCategory );
+ }
+ }
+
+ return( true );
+ }
+
/**
* Updates the configuration of a blog
*
@@ -82,27 +112,12 @@
$this->_cache->removeData( $blog->getMangledBlogName(), CACHE_BLOGIDBYNAME );
$this->_cache->removeData( $blog->getId(), CACHE_BLOGINFOS );
- include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
- $blogCategories = new BlogCategories();
-
- // old category
- $oldCategory = $prevVersion->getBlogCategory();
- if( $oldCategory ) {
- $oldCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
- $oldCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$oldCategory->getId()));
- $blogCategories->updateBlogCategory( $oldCategory );
- }
- // new category
- $newCategory = $blog->getBlogCategory();
- if( $newCategory ) {
- $newCategory->setNumActiveBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$newCategory->getId().' AND status = '.BLOG_STATUS_ACTIVE ));
- $newCategory->setNumBlogs($this->getNumItems( $this->getPrefix().'blogs', 'blog_category_id = '.$newCategory->getId()));
- $blogCategories->updateBlogCategory( $newCategory );
- }
+ // update blog categories
+ $this->updateBlogCategoriesLink( $blog, $prevVersion );
}
- // always return true,
- // $result is only false if nothing was changed, but that really isn't an error?
+ // always return true,
+ // $result is only false if nothing was changed, but that really isn't an error?
return true;
}
@@ -125,6 +140,9 @@
$blogSettings = new BlogSettings();
$blogId = $this->add( $blog );
+
+ // update blog categories
+ $this->updateBlogCategoriesLink( $blog );
// create the row for the bayesian filter info
$bayesianFilterInfo = new BayesianFilterInfos();
@@ -271,6 +289,10 @@
// the permissions for the blog
$perms = new UserPermissions();
$perms->revokeBlogPermissions( $blogId );
+
+ // update blog categories
+ $blog = getBlogInfo( $blogId );
+ $this->updateBlogCategoriesLink( $blog );
// and finally, delete the blog
return( $this->delete( "blog_id", $blogId ));
Modified: plog/trunk/class/summary/action/chooseblogtemplateaction.class.php
===================================================================
--- plog/trunk/class/summary/action/chooseblogtemplateaction.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/summary/action/chooseblogtemplateaction.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -31,6 +31,7 @@
// get the data from the request, as it's already been validated
$this->templateId = $this->_request->getValue( "templateId" );
$this->blogName = $this->_request->getValue( "blogName" );
+ $this->blogCategoryId = $this->_request->getValue( "blogCategoryId" );
$this->blogLocale = $this->_request->getValue( "blogLocale" );
$this->userName = $this->_request->getValue( "userName" );
$this->userPassword = $this->_request->getValue( "userPassword" );
Modified: plog/trunk/class/summary/action/doblogregistration.class.php
===================================================================
--- plog/trunk/class/summary/action/doblogregistration.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/summary/action/doblogregistration.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -21,6 +21,7 @@
// data validation
//$this->registerFieldValidator( "userId", new IntegerValidator());
$this->registerFieldValidator( "blogName", new StringValidator());
+ $this->registerFieldValidator( "blogCategoryId", new IntegerValidator());
$this->registerFieldValidator( "blogLocale", new StringValidator());
$view = new doBlogRegistrationView();
$view->setErrorMessage( $this->_locale->tr("register_error_creating_blog"));
Modified: plog/trunk/class/summary/action/dofinishregister.class.php
===================================================================
--- plog/trunk/class/summary/action/dofinishregister.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/summary/action/dofinishregister.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -100,6 +100,7 @@
function createBlog($userId)
{
$this->blogName = stripslashes($this->_request->getValue("blogName"));
+ $this->blogCategoryId = $this->_request->getValue("blogCategoryId");
$this->blogLocale = $this->_request->getValue("blogLocale");
$this->templateId = $this->_request->getValue("templateId");
@@ -116,6 +117,7 @@
$locale = Locales::getLocale( $this->blogLocale );
$blogInfo->setLocale( $locale );
$blogInfo->setTemplate( $this->templateId );
+ $blogInfo->setBlogCategoryId( $this->blogCategoryId );
$newblogId = $blogs->addBlog( $blogInfo );
if( !$newblogId ) {
Modified: plog/trunk/class/summary/action/registeraction.class.php
===================================================================
--- plog/trunk/class/summary/action/registeraction.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/summary/action/registeraction.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -17,6 +17,7 @@
var $userFullName;
var $userEmail;
var $blogName;
+ var $blogCategoryId;
var $blogLocale;
var $templateId;
//}}}
@@ -28,6 +29,7 @@
$tf = new Textfilter();
$this->blogName = $tf->filterAllHTML( $this->_request->getValue( "blogName" ));
+ $this->blogCategoryId = $this->_request->getValue( "blogCategoryId" );
$this->blogLocale = $this->_request->getValue( "blogLocale" );
$this->userName = $tf->filterAllHTML($this->_request->getValue( "userName" ));
$this->userPassword = $tf->filterAllHTML($this->_request->getValue( "userPassword" ));
@@ -52,6 +54,7 @@
$this->_view->setValue( "userPassword", $this->userPassword );
$this->_view->setValue( "userEmail", $this->userEmail );
$this->_view->setValue( "blogName", $this->blogName );
+ $this->_view->setValue( "blogCategoryId", $this->blogCategoryId );
$this->_view->setValue( "blogLocale", $this->blogLocale );
$this->_view->setValue( "templateId", $this->templateId );
}
Modified: plog/trunk/class/summary/view/doblogregistrationview.class.php
===================================================================
--- plog/trunk/class/summary/view/doblogregistrationview.class.php 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/class/summary/view/doblogregistrationview.class.php 2006-04-04 09:15:43 UTC (rev 3180)
@@ -2,6 +2,7 @@
include_once( PLOG_CLASS_PATH."class/summary/view/summaryview.class.php" );
include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
/**
* shows a list with all the locales so that users can choose, too
@@ -23,6 +24,11 @@
$config =& Config::getConfig();
// assign default Local to template
$this->setValue( "defaultLocale", $config->getValue("default_locale" ) );
+
+ // get a list of blog categories, so we can let user to choose
+ $blogCategories = new BlogCategories();
+ $categories = $blogCategories->getBlogCategories();
+ $this->setValue( "blogCategories", $categories );
// and render the rest of the contents of the view
parent::render();
Modified: plog/trunk/templates/summary/registerstep2.template
===================================================================
--- plog/trunk/templates/summary/registerstep2.template 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/templates/summary/registerstep2.template 2006-04-04 09:15:43 UTC (rev 3180)
@@ -9,8 +9,18 @@
<div class="formHelp">{$locale->tr("register_blog_name_help")}</div>
<input type="text" name="blogName" value="{$blogName}" id="blogName" />
{include file="summary/validate.template" field=blogName message=$locale->tr("error_empty_name")}
- </div>
+ </div>
<div class="field">
+ <label for="blogCategoryId">{$locale->tr("blog_category")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blog_category_help")}</div>
+ <select name="blogCategoryId" id="blogCategoryId">
+ {foreach name=blogCategories from=$blogCategories item=blogCategory}
+ <option value="{$blogCategory->getId()}"{if $smarty.foreach.blogCategories.first} selected{/if}>{$blogCategory->getName()}</option>
+ {/foreach}
+ </select>
+ </div>
+ <div class="field">
<label for="blogLocale">{$locale->tr("language")}</label>
<span class="required">*</span>
<div class="formHelp">{$locale->tr("blog_language_help")}</div>
Modified: plog/trunk/templates/summary/registerstep3.template
===================================================================
--- plog/trunk/templates/summary/registerstep3.template 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/templates/summary/registerstep3.template 2006-04-04 09:15:43 UTC (rev 3180)
@@ -35,6 +35,7 @@
<input type="hidden" name="userPassword" value="{$userPassword}"/>
<input type="hidden" name="userEmail" value="{$userEmail}"/>
<input type="hidden" name="blogName" value="{$blogName}"/>
+ <input type="hidden" name="blogCategoryId" value="{$blogCategoryId}"/>
<input type="hidden" name="blogLocale" value="{$blogLocale}"/>
</div>
</form>
Modified: plog/trunk/templates/summary/registerstep4.template
===================================================================
--- plog/trunk/templates/summary/registerstep4.template 2006-04-04 04:16:36 UTC (rev 3179)
+++ plog/trunk/templates/summary/registerstep4.template 2006-04-04 09:15:43 UTC (rev 3180)
@@ -51,6 +51,7 @@
<input type="hidden" name="userPassword" value="{$userPassword}"/>
<input type="hidden" name="userEmail" value="{$userEmail}"/>
<input type="hidden" name="blogName" value="{$blogName}"/>
+ <input type="hidden" name="blogCategoryId" value="{$blogCategoryId}"/>
<input type="hidden" name="blogLocale" value="{$blogLocale}"/>
<input type="hidden" name="templateId" value="{$templateId}"/>
More information about the pLog-svn
mailing list