Пример #1
0
function gantryAjaxSaveTemplate()
{
    // Check for request forgeries
    gantry_checktoken() or jexit('Invalid Token');
    GantryLegacyJModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_gantry/models');
    $model = GantryLegacyJModel::getInstance("Template", 'GantryModel');
    $data = JFactory::getApplication()->input->post->get('jform', array(), 'array');
    if (!$model->save($data)) {
        return 'error';
    }
    // Clear the front end gantry cache after each call
    $cache = GantryCache::getInstance(false);
    $cache->clearGroupCache();
    $task = JFactory::getApplication()->input->getCmd('task');
    if ($task == 'apply') {
        return JText::_('Template settings have been successfully applied.');
    } else {
        return JText::_('Template settings have been successfully saved.');
    }
}
Пример #2
0
 /**
  * Removes an item.
  *
  * @since	1.6
  */
 function delete()
 {
     $language = JFactory::getLanguage();
     $language->load('com_templates');
     $language->load('com_gantry');
     // Check for request forgeries
     gantry_checktoken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural('COM_TEMPLATES_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_templates&view=styles', false));
 }