コード例 #1
0
ファイル: menu.php プロジェクト: aldegtyarev/stelsvelo
 /**
  * Overloaded store function
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  mixed  False on failure, positive integer on success.
  *
  * @see     JTable::store
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $db = JFactory::getDBO();
     // Verify that the alias is unique
     $table = JTable::getInstance('Menu', 'JTable');
     // re-do alias:
     if (!$this->checkAlias($table)) {
         //stAn, this should never be reached
         if ($this->menutype == $table->menutype) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS'));
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT'));
         }
         return false;
     }
     // Verify that the home page for this language is unique
     if ($this->home == '1') {
         $table = JTable::getInstance('Menu', 'JTable');
         if ($table->load(array('home' => '1', 'language' => $this->language))) {
             if ($table->checked_out && $table->checked_out != $this->checked_out) {
                 $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
                 return false;
             }
             $table->home = 0;
             $table->checked_out = 0;
             $table->checked_out_time = $db->getNullDate();
             $table->store();
         }
         // Verify that the home page for this menu is unique.
         if ($table->load(array('home' => '1', 'menutype' => $this->menutype)) && ($table->id != $this->id || $this->id == 0)) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
             return false;
         }
     }
     if (empty($this->parent_id)) {
         var_dump($this);
         die('empty parent_id !');
     }
     if (!parent::store($updateNulls)) {
         return false;
     }
     // Get the new path in case the node was moved
     /*
     $pathNodes = $this->getPath();
     $segments = array();
     foreach ($pathNodes as $node)
     {
     	// Don't include root in path
     	if ($node->alias != 'root')
     	{
     		$segments[] = $node->alias;
     	}
     }
     $newPath = trim(implode('/', $segments), ' /\\');
     */
     $newPath = $this->path;
     // Use new path for partial rebuild of table
     // Rebuild will return positive integer on success, false on failure
     //var_dump("{$this->_tbl_key}");
     //var_dump($this->{$this->_tbl_key}); die();
     //$parent = $this->{$this->_tbl_key};
     $parent = $this->parent_id;
     return $this->rebuild($parent, $this->lft, $this->level, $newPath) > 0;
 }