[pLog-svn] r3518 - plog/trunk/class/view

Mark Wu markplace at gmail.com
Sat Jun 3 08:34:29 GMT 2006


But, if we don't write the blogInfo back to db

That means we need update the $blofInfo every time, if the site admin really
delete a template that user used, and user does update his blogInfo by him
self in updateBlogSetting.

For a small site, I think it will be okay ... For a big site, it may casue
some performance loss I guess.

Or we can ignore the performance loss, if it is very small?

Mark

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net 
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of 
> Oscar Renalias
> Sent: Saturday, June 03, 2006 4:28 PM
> To: plog-svn at devel.lifetype.net
> Subject: Re: [pLog-svn] r3518 - plog/trunk/class/view
> 
> Another possibility is not to fix it. Just check if the 
> template exists and if it doesn't, use the default one but 
> not update the blog settings.
> 
> On 3 Jun 2006, at 11:24, Mark Wu wrote:
> 
> > I know, that's why I need you to confirm...
> >
> > Because I have the same feeling as you about updating the 
> blogInfo in 
> > SmartyView.
> >
> > Move to BlogView?? Maybe doable.
> >
> > I will try to fixed it according to the discussion.
> >
> > Mark
> >
> >> -----Original Message-----
> >> From: plog-svn-bounces at devel.lifetype.net
> >> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Oscar 
> >> Renalias
> >> Sent: Saturday, June 03, 2006 4:21 PM
> >> To: plog-svn at devel.lifetype.net
> >> Subject: Re: [pLog-svn] r3518 - plog/trunk/class/view
> >>
> >> I think this is fine as long as the template that was 
> deleted was not 
> >> the default one.
> >>
> >> I haven't checked the code but I think we're not allowing 
> to remove 
> >> the default one...
> >>
> >> The only thing that I don't like too much is that we have a view 
> >> making changes to a blog (!!) Logically speaking it 
> doesn't make too 
> >> much sense and it's a bit confusing, specially if you 
> think that the 
> >> SmartyView class is only there to load templates and show them, 
> >> nothing else :)
> >>
> >> Maybe we could move this code to the constructor of BlogView?
> >>
> >> On 3 Jun 2006, at 10:31, Mark Wu wrote:
> >>
> >>> Hi Oscar:
> >>>
> >>> This commit just fixed the bug list here
> >>> http://bugs.lifetype.net/view.php?id=923
> >>>
> >>> I need your confirmation about the method is doable or not.
> >>>
> >>> If not, I will revert the change.
> >>>
> >>> Mark
> >>>
> >>>> -----Original Message-----
> >>>> From: plog-svn-bounces at devel.lifetype.net
> >>>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of 
> >>>> mark at devel.lifetype.net
> >>>> Sent: Saturday, June 03, 2006 3:00 PM
> >>>> To: plog-svn at devel.lifetype.net
> >>>> Subject: [pLog-svn] r3518 - plog/trunk/class/view
> >>>>
> >>>> Author: mark
> >>>> Date: 2006-06-03 06:59:49 +0000 (Sat, 03 Jun 2006) New
> >> Revision: 3518
> >>>>
> >>>> Modified:
> >>>>    plog/trunk/class/view/smartyview.class.php
> >>>> Log:
> >>>> Fixed bug http://bugs.lifetype.net/view.php?id=923.
> >>>>
> >>>> When site admin delete a site template. I don't think check the 
> >>>> template used by any one is a good idea. It is very time 
> consuming 
> >>>> and waste our cpu resource.
> >>>>
> >>>> The better way is when we trigger the SmartyView, we check the 
> >>>> templateSet that blog used exist or not.
> >>>>
> >>>> If yes, we jusy go ahead and use it. If not, we use the 
> >>>> default_template and write the information back to blogInfo.
> >>>>
> >>>> Modified: plog/trunk/class/view/smartyview.class.php
> >>>> 
> ===================================================================
> >>>> --- plog/trunk/class/view/smartyview.class.php	
> >>>> 2006-06-03 06:44:16 UTC (rev 3517)
> >>>> +++ plog/trunk/class/view/smartyview.class.php	
> >>>> 2006-06-03 06:59:49 UTC (rev 3518)
> >>>> @@ -26,6 +26,7 @@
> >>>>  	
> >>>>  		var $_cachingEnabled;
> >>>>  		var $_templateName;
> >>>> +		var $_templateSetName;
> >>>>  		var $_template;
> >>>>  		var $_data;
> >>>>  		var $_viewId;
> >>>> @@ -60,13 +61,29 @@
> >>>>
> >>>>  			// name of the tepmlate
> >>>>  			$this->_templateName = $templateName;
> >>>> +
> >>>> +			// name of the template set name
> >>>> +			$blogSettings = 
> $this->_blogInfo->getSettings();
> >>>> +			$this->_templateSetName =
> >>>> $blogSettings->getValue( 'template' );
> >>>>  			
> >>>> +			// Check the template exist or not
> >>>> +			// If not, we use the defaule_template
> >>>> and also assign the default_template back to blogInfo
> >>>> +			if ( !$this->isTemplateSetExist(
> >>>> $this->_templateSetName ) )
> >>>> +			{
> >>>> +				$config =& Config::getConfig();	
> >>>> 		
> >>>> +				$this->_templateSetName =
> >>>> $config->getValue( "default_template" );
> >>>> +				$this->_blogInfo->setTemplate(
> >>>> $this->_templateSetName );
> >>>> +
> >>>> +				include_once(
> >>>> PLOG_CLASS_PATH.'class/dao/blogs.class.php' );
> >>>> +				$blogs = new Blogs();
> >>>> +				$blogs->updateBlog( 
> $this->_blogInfo );
> >>>> +			}
> >>>> +						
> >>>>  			// get the right CachedTemplate or
> >> Template object
> >>>> -            $blogSettings = $this->_blogInfo->getSettings();	
> >>>> 		
> >>>>  			$ts = new TemplateService();	
> 		
> >>>>  			if( $this->isCachingEnabled()) {
> >>>>  				// get a CachedTemplate object
> >>>> -				$this->_template =
> >>>> $ts->CachedTemplate( $this->_templateName,
> >> $blogSettings->getValue(
> >>>> 'template' ), $this->_blogInfo );
> >>>> +				$this->_template =
> >>>> $ts->CachedTemplate( $this->_templateName,
> >>>> +$this->_templateSetName, $this->_blogInfo );
> >>>>  				// data used to 
> calculate the view id
> >>>>  				$this->_data = $data;
> >>>>  				// and generate the 
> right cache id for it @@ -102,9 +119,23 @@
> >>>>  			
> >>>>  			return $isCached;
> >>>>  		}		
> >>>> -		
> >>>>
> >>>>  		/**
> >>>> +		 * returns true if the current template set
> >>>> does exist or flase if it does not exist
> >>>> +		 *
> >>>> +		 * @return true if template set exist 
> or false otherwise
> >>>> +		 */
> >>>> +		function isTemplateSetExist( $templateSetName )
> >>>> +		{
> >>>> +			include_once(
> >>>> PLOG_CLASS_PATH.'class/template/templatesets/templatesets.clas
> >>>> s.php' );
> >>>> +			$templateSets = new TemplateSets();
> >>>> +			if( !$templateSets->isTemplate(
> >>>> $templateSetName ) && !$templateSets->isBlogTemplate( 
> >>>> $templateSetName, $this->_blogInfo->getId() ) )
> >>>> +				return false;
> >>>> +			else
> >>>> +				return true;
> >>>> +		}
> >>>> +
> >>>> +		/**
> >>>>  		 * generates a unique identifier for this view.
> >>>> The cache identifier is generated
> >>>>  		 * based on the last parameter passed to the
> >> view constructor
> >>>>  		 *
> >>>>
> >>>> _______________________________________________
> >>>> pLog-svn mailing list
> >>>> pLog-svn at devel.lifetype.net
> >>>> http://devel.lifetype.net/mailman/listinfo/plog-svn
> >>>
> >>> _______________________________________________
> >>> pLog-svn mailing list
> >>> pLog-svn at devel.lifetype.net
> >>> http://devel.lifetype.net/mailman/listinfo/plog-svn
> >>>
> >>
> >> _______________________________________________
> >> pLog-svn mailing list
> >> pLog-svn at devel.lifetype.net
> >> http://devel.lifetype.net/mailman/listinfo/plog-svn
> >
> > _______________________________________________
> > pLog-svn mailing list
> > pLog-svn at devel.lifetype.net
> > http://devel.lifetype.net/mailman/listinfo/plog-svn
> >
> 
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list