Joomla! Discussion Forums



It is currently Thu Nov 26, 2009 9:01 pm (All times are UTC )

 


Forum rules

Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: doubt on JTable::reset
Posted: Thu May 29, 2008 3:14 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Sat Jan 27, 2007 6:04 pm
Posts: 98
Location: Turin - Italy
On JTable we have:
/**
* Resets the default properties
* @return void
*/
function reset()
{
$k = $this->_tbl_key;
foreach ($this->getProperties() as $name => $value)
{
if($name != $k)
{
$this->$name = $value;
}
}
}

The getProperties() take the list from JObject:
function getProperties( $public = true )
{
$vars = get_object_vars($this);
if($public)
{
foreach ($vars as $key => $value)
{
if ('_' == substr($key, 0, 1)) {
unset($vars[$key]);
}
}
}
return $vars;
}

Now my doubt: I thought that "reset" method meant to set variables at default values(the initial values). Is this true?
If the answer is yes, I think we've a problem on get_object_vars that gives the values of the object. Probably we should use get_class_vars.
Thank you,
Claudio

_________________
Unglücklich das Land, das Helden nötig hat.
[Unlucky the nation that needs heroes.]
Galilei in Brecht's Leben des Galilei


Top
   
 
Posted: Tue Jun 10, 2008 5:21 am 
Joomla! Intern
Joomla! Intern
Offline

Joined: Sat Jan 27, 2007 6:04 pm
Posts: 98
Location: Turin - Italy
I tested it. The reset has no effect because the get_object_vars on getProperties() gives exactly how the variables are set. So can somebody explain me what is the target of this method (reset)?

I've some proposal,
on JObject:
Code:
   function getProperties( $public = true, $object=true )
   {
      if( $object )
      {
         $vars  = get_object_vars($this);
      }
      else
      {
         $vars  = get_class_vars(get_class($this));
      }

      if($public)
      {
         foreach ($vars as $key => $value)
         {
            if ('_' == substr($key, 0, 1)) {
               unset($vars[$key]);
            }
         }
      }

      return $vars;
   }



on JTable:
Code:
   /**
    * Resets the default properties
    * @return   void
    */
   function reset($reset_tab_key=false)
   {
      if( $reset_tab_key ){
         $k = '';
      }
      else {
         $k = $this->_tbl_key;
      }
            
      foreach ($this->getProperties(false,false) as $name => $value)
      {
         if($name != $k)
         {
            $this->$name   = $value;
         }
      }
   }

_________________
Unglücklich das Land, das Helden nötig hat.
[Unlucky the nation that needs heroes.]
Galilei in Brecht's Leben des Galilei


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group