english/administrator/components/com_templates/models/style.php
/**
	 * Method to duplicate styles.
	 *
	 * @param	array	An array of primary key IDs.
	 *
	 * @return	boolean	True if successful.
	 * @throws	Exception
	 */
Method to duplicate styles.
@param       array   An array of primary key IDs.

@return      boolean True if successful.
@throws      Exception
Method to duplicate styles . @param array An array of primary key IDs . @return boolean True if successful . @throws Exception
public function duplicate(&$pks)
	{
		$user	= JFactory::getUser();
		$db		= $this->getDbo();
		if (!$user->authorise('core.create', 'com_templates')) {
			throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED'));
		}
		$table = $this->getTable();
		foreach ($pks as $pk)
		{
			if ($table->load($pk, true)) {
				$table->id = 0;
				$table->home = 0;
				$m = null;
				if (preg_match('#\((\d+)\)$#', $table->title, $m)) {
					$table->title = preg_replace('#\(\d+\)$#', '('.($m[1] + 1).')', $table->title);
				}
				else {
					$table->title .= ' (2)';
				}
				if (!$table->check() || !$table->store()) {
					throw new Exception($table->getError());
				}
			}
			else {
				throw new Exception($table->getError());
			}
		}
		$this->cleanCache();
		return true;
	}
public function duplicate ( & $ pks ) { $ user = JFactory :: getUser ( ) ; $ db = $ this -> getDbo ( ) ; if ( ! $ user -> authorise ( 'core.create' , 'com_templates' ) ) { throw new Exception ( JText :: _ ( 'JERROR_CORE_CREATE_NOT_PERMITTED' ) ) ; } $ table = $ this -> getTable ( ) ; foreach ( $ pks as $ pk ) { if ( $ table -> load ( $ pk , true ) ) { $ table -> id = 0 ; $ table -> home = 0 ; $ m = null ; if ( preg_match ( '#\((\d+)\)$#' , $ table -> title , $ m ) ) { $ table -> title = preg_replace ( '#\(\d+\)$#' , '(' . ( $ m [ 1 ] + 1 ) . ')' , $ table -> title ) ; } else { $ table -> title .= ' (2)' ; } if ( ! $ table -> check ( ) || ! $ table -> store ( ) ) { throw new Exception ( $ table -> getError ( ) ) ; } } else { throw new Exception ( $ table -> getError ( ) ) ; } } $ this -> cleanCache ( ) ; return true ; }
Method to duplicate styles.
Method to duplicate styles .
// Initialise variables. // Access checks. // Reset the id to create a new record. // Reset the home (don't want dupes of that field). // Alter the title. // Clean cache