Source for file style.php
Documentation is available at style.php
* @package Joomla.Administrator
* @subpackage com_templates
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Template style controller class.
* @package Joomla.Administrator
* @subpackage com_templates
* @var string The prefix to use with controller messages.
public function save($key =
null, $urlVar =
null)
if ($document->getType() ==
'json')
$table =
$model->getTable();
$data =
$this->input->post->get('params', array(), 'array');
$item =
$model->getItem($app->getTemplate('template')->id);
// Setting received params
$item->set('params', $data);
$data =
$item->getProperties();
$key =
$table->getKeyName();
$recordId =
$this->input->getInt($urlVar);
$app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'error');
// Validate the posted data.
// Sometimes the form needs some posted data, such as for plugins and modules.
$form =
$model->getForm($data, false);
$app->enqueueMessage($model->getError(), 'error');
// Test whether the data is valid.
$validData =
$model->validate($form, $data);
if ($validData ===
false)
// Get the validation messages.
$errors =
$model->getErrors();
// Push up to three validation messages out to the user.
for ($i =
0, $n =
count($errors); $i <
$n &&
$i <
3; $i++
)
if ($errors[$i] instanceof
Exception)
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
$app->enqueueMessage($errors[$i], 'warning');
// Save the data in the session.
$app->setUserState($context .
'.data', $data);
if (!isset
($validData['tags']))
$validData['tags'] =
null;
// Attempt to save the data.
if (!$model->save($validData))
// Save the data in the session.
$app->setUserState($context .
'.data', $validData);
$app->enqueueMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error');
// Save succeeded, so check-in the record.
if ($checkin &&
$model->checkin($validData[$key]) ===
false)
// Save the data in the session.
$app->setUserState($context .
'.data', $validData);
// Check-in failed, so go back to the record and display a notice.
$app->enqueueMessage(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'error');
// Redirect the user and adjust session state
// Set the record data in the session.
$recordId =
$model->getState($this->context .
'.id');
$app->setUserState($context .
'.data', null);
$model->checkout($recordId);
// Invoke the postSave method to allow for the child class to access the model.
parent::save($key, $urlVar);
Documentation generated on Tue, 19 Nov 2013 15:14:38 +0100 by phpDocumentor 1.4.3