english/administrator/components/com_categories/models/category.php
/**
	 * Method to save the form data.
	 *
	 * @param	array	The form data.
	 * @return	boolean	True on success.
	 * @since	1.6
	 */
Method to save the form data.
@param       array   The form data.
@return      boolean True on success.
Method to save the form data . @param array The form data . @return boolean True on success .
public function save($data)
	{
		$dispatcher = JDispatcher::getInstance();
		$table		= $this->getTable();
		$pk			= (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id');
		$isNew		= true;
		JPluginHelper::importPlugin('content');
		if ($pk > 0) {
			$table->load($pk);
			$isNew = false;
		}
		if ($table->parent_id != $data['parent_id'] || $data['id'] == 0) {
			$table->setLocation($data['parent_id'], 'last-child');
		}
		if (JRequest::getVar('task') == 'save2copy') {
			list($title,$alias) = $this->generateNewTitle($data['parent_id'], $data['alias'], $data['title']);
			$data['title']	= $title;
			$data['alias']	= $alias;
		}
		if (!$table->bind($data)) {
			$this->setError($table->getError());
			return false;
		}
		if (isset($data['rules'])) {
			$rules = new JRules($data['rules']);
			$table->setRules($rules);
		}
		if (!$table->check()) {
			$this->setError($table->getError());
			return false;
		}
		$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, &$table, $isNew));
		if (in_array(false, $result, true)) {
			$this->setError($table->getError());
			return false;
		}
		if (!$table->store()) {
			$this->setError($table->getError());
			return false;
		}
		$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, &$table, $isNew));
		if (!$table->rebuildPath($table->id)) {
			$this->setError($table->getError());
			return false;
		}
		if (!$table->rebuild($table->id, $table->lft, $table->level, $table->path)) {
			$this->setError($table->getError());
			return false;
		}
		$this->setState($this->getName().'.id', $table->id);
		$this->cleanCache();
		return true;
	}
public function save ( $ data ) { $ dispatcher = JDispatcher :: getInstance ( ) ; $ table = $ this -> getTable ( ) ; $ pk = ( ! empty ( $ data [ 'id' ] ) ) ? $ data [ 'id' ] : ( int ) $ this -> getState ( $ this -> getName ( ) . '.id' ) ; $ isNew = true ; JPluginHelper :: importPlugin ( 'content' ) ; if ( $ pk > 0 ) { $ table -> load ( $ pk ) ; $ isNew = false ; } if ( $ table -> parent_id != $ data [ 'parent_id' ] || $ data [ 'id' ] == 0 ) { $ table -> setLocation ( $ data [ 'parent_id' ] , 'last-child' ) ; } if ( JRequest :: getVar ( 'task' ) == 'save2copy' ) { list ( $ title , $ alias ) = $ this -> generateNewTitle ( $ data [ 'parent_id' ] , $ data [ 'alias' ] , $ data [ 'title' ] ) ; $ data [ 'title' ] = $ title ; $ data [ 'alias' ] = $ alias ; } if ( ! $ table -> bind ( $ data ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } if ( isset ( $ data [ 'rules' ] ) ) { $ rules = new JRules ( $ data [ 'rules' ] ) ; $ table -> setRules ( $ rules ) ; } if ( ! $ table -> check ( ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } $ result = $ dispatcher -> trigger ( $ this -> event_before_save , array ( $ this -> option . '.' . $ this -> name , & $ table , $ isNew ) ) ; if ( in_array ( false , $ result , true ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } if ( ! $ table -> store ( ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } $ dispatcher -> trigger ( $ this -> event_after_save , array ( $ this -> option . '.' . $ this -> name , & $ table , $ isNew ) ) ; if ( ! $ table -> rebuildPath ( $ table -> id ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } if ( ! $ table -> rebuild ( $ table -> id , $ table -> lft , $ table -> level , $ table -> path ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } $ this -> setState ( $ this -> getName ( ) . '.id' , $ table -> id ) ; $ this -> cleanCache ( ) ; return true ; }
Method to save the form data.
Method to save the form data .
// Initialise variables; // Include the content plugins for the on save events. // Load the row if saving an existing category. // Set the new parent id if parent id not matched OR while New/Save as Copy . // Alter the title for save as copy // Bind the data. // Bind the rules. // Check the data. // Trigger the onContentBeforeSave event. // Store the data. // Trigger the onContentAfterSave event. // Rebuild the path for the category: // Rebuild the paths of the category's children: // Clear the cache