AAAAPKa>\Vtemplates/index.htmlnuW+A PKa>\5W!  templates/default.phpnuW+Aescape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
items as $i => $item) : ?>
 
element, $item->client_id); ?> name) ;?>

preview && $item->client_id == '0'): ?> client_id == '1'): ?>

client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> escape($item->xmldata->get('version')); ?> escape($item->xmldata->get('creationDate')); ?> xmldata->get('author')) : ?>

escape($author); ?>

xmldata->get('authorEmail')) : ?>

escape($email); ?>

xmldata->get('authorUrl')) : ?>

escape($url); ?>

pagination->getListFooter(); ?>
PKa>\)templates/.htaccessnuW+A Order allow,deny Deny from all PKa>\) .htaccessnuW+A Order allow,deny Deny from all PKa>\)styles/.htaccessnuW+A Order allow,deny Deny from all PKa>\o$|styles/default.phpnuW+Aescape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_templates'); $canEdit = $user->authorise('core.edit', 'com_templates'); $canChange = $user->authorise('core.edit.state', 'com_templates'); ?>
 
id); ?> preview && $item->client_id == '0'): ?> client_id == '1'): ?> escape($item->title);?> escape($item->title);?> client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> home=='0' || $item->home=='1'):?> home!='0', $i, 'styles.', $canChange && $item->home!='1');?> image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $item->language_title)), true);?> image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?> assigned > 0) : ?> assigned), array('title'=>JText::plural('COM_TEMPLATES_ASSIGNED', $item->assigned)), true); ?>   id; ?>
pagination->getListFooter(); ?>
PKa>\Vstyles/index.htmlnuW+A PKa>\V index.htmlnuW+A PKK>\H config.xmlnuW+A
PKK>\/ access.xmlnuW+A
PKK>\jcontroller.phpnuW+AcheckEditId('com_templates.edit.style', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_templates&view=styles', false)); return false; } parent::display(); } /** * Preview Template */ function preview() { JRequest::setVar('view', 'prevuuw'); parent::display(); } } PKK>\)views/.htaccessnuW+A Order allow,deny Deny from all PKK>\}4WWviews/prevuuw/view.html.phpnuW+Aclient = JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); $this->id = JRequest::getVar('id', '', 'method', 'int'); $this->option = JRequest::getCmd('option'); $this->template = TemplatesHelper::getTemplateName($this->id); $this->tp = true; $this->url = $client->id ? JURI::base() : JURI::root(); if (!$this->template) { return JError::raiseWarning(500, JText::_('COM_TEMPLATES_TEMPLATE_NOT_SPECIFIED')); } // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); parent::display($tpl); $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JToolBarHelper::title(JText::_('COM_TEMPLATES_MANAGER'), 'thememanager'); JToolBarHelper::custom('edit', 'back.png', 'back_f2.png', 'Back', false, false); } } PKK>\)views/prevuuw/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/prevuuw/index.htmlnuW+A PKK>\)views/prevuuw/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/prevuuw/tmpl/index.htmlnuW+A PKK>\! N..views/prevuuw/tmpl/default.phpnuW+A

url.'index.php?tp='.$this->tp.'&template='.$this->id, JText::_('JBROWSERTARGET_NEW'), array('target' => '_blank')); ?>

url.'index.php?tp='.$this->tp.'&template='.$this->id, 'previewframe', array('class' => 'previewframe')) ?>
PKK>\Vviews/templates/tmpl/index.htmlnuW+A PKK>\)views/templates/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\Г7"TT views/templates/tmpl/default.phpnuW+Aescape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
items as $i => $item) : ?>
 
pagination->getListFooter(); ?>
element, $item->client_id); ?> name)) ;?>

preview && $item->client_id == '0'): ?> client_id == '1'): ?>

client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> escape($item->xmldata->get('version')); ?> escape($item->xmldata->get('creationDate')); ?> xmldata->get('author')) : ?>

escape($author); ?>

xmldata->get('authorEmail')) : ?>

escape($email); ?>

xmldata->get('authorUrl')) : ?>

escape($url); ?>

PKK>\Vviews/templates/index.htmlnuW+A PKK>\ 5views/templates/view.html.phpnuW+Aitems = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->preview = JComponentHelper::getParams('com_templates')->get('template_positions_display'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Check if there are no matching items if(!count($this->items)) { JFactory::getApplication()->enqueueMessage( JText::_('COM_TEMPLATES_MSG_MANAGE_NO_TEMPLATES') , 'warning' ); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * @since 1.6 */ protected function addToolbar() { $state = $this->get('State'); $canDo = TemplatesHelper::getActions(); JToolBarHelper::title(JText::_('COM_TEMPLATES_MANAGER_TEMPLATES'), 'thememanager'); if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_templates'); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES'); } } PKK>\)views/templates/.htaccessnuW+A Order allow,deny Deny from all PKK>\Uviews/style/view.html.phpnuW+Aitem = $this->get('Item'); $this->state = $this->get('State'); $this->form = $this->get('Form'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $isNew = ($this->item->id == 0); $canDo = TemplatesHelper::getActions(); JToolBarHelper::title( $isNew ? JText::_('COM_TEMPLATES_MANAGER_ADD_STYLE') : JText::_('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'thememanager' ); // If not checked out, can save the item. if ($canDo->get('core.edit')) { JToolBarHelper::apply('style.apply'); JToolBarHelper::save('style.save'); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::save2copy('style.save2copy'); } if (empty($this->item->id)) { JToolBarHelper::cancel('style.cancel'); } else { JToolBarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); // Get the help information for the template item. $lang = JFactory::getLanguage(); $help = $this->get('Help'); if ($lang->hasKey($help->url)) { $debug = $lang->setDebug(false); $url = JText::_($help->url); $lang->setDebug($debug); } else { $url = null; } JToolBarHelper::help($help->key, false, $url); } } PKK>\)views/style/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/style/index.htmlnuW+A PKK>\/W views/style/tmpl/edit.phpnuW+A
  • form->getLabel('title'); ?> form->getInput('title'); ?>
  • form->getLabel('template'); ?> form->getInput('template'); ?> form->getLabel('client_id'); ?> form->getInput('client_id'); ?>
  • form->getLabel('home'); ?> form->getInput('home'); ?>
  • item->id) : ?>
  • form->getLabel('id'); ?> item->id; ?>
item->xml) : ?> item->xml->description)) : ?>

item->id); ?> loadTemplate('options'); ?>
authorise('core.edit', 'com_menu') && $this->item->client_id==0):?> get('core.edit.state')) : ?>
loadTemplate('assignment'); ?>
PKK>\)views/style/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/style/tmpl/index.htmlnuW+A PKK>\6++!views/style/tmpl/edit_options.phpnuW+Aform->getFieldsets('params'); foreach ($fieldSets as $name => $fieldSet) : $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_TEMPLATES_'.$name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
PKK>\$views/style/tmpl/edit_assignment.phpnuW+A
PKK>\)views/source/.htaccessnuW+A Order allow,deny Deny from all PKK>\"&DDviews/source/view.html.phpnuW+Aform = $this->get('Form'); $this->ftp = JClientHelper::setCredentialsFromRequest('ftp'); $this->source = $this->get('Source'); $this->state = $this->get('State'); $this->template = $this->get('Template'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $canDo = TemplatesHelper::getActions(); JToolBarHelper::title(JText::_('COM_TEMPLATES_MANAGER_EDIT_FILE'), 'thememanager'); // Can save the item. if ($canDo->get('core.edit')) { JToolBarHelper::apply('source.apply'); JToolBarHelper::save('source.save'); } JToolBarHelper::cancel('source.cancel'); JToolBarHelper::divider(); JToolBarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT_SOURCE'); } } PKK>\38llviews/source/tmpl/edit.phpnuW+A
ftp) : ?> loadTemplate('ftp'); ?>
source->filename, $this->template->element); ?> form->getLabel('source'); ?>
form->getInput('source'); ?>
form->getInput('extension_id'); ?> form->getInput('filename'); ?>
PKK>\)views/source/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/source/tmpl/index.htmlnuW+A PKK>\views/source/tmpl/edit_ftp.phpnuW+A
ftp instanceof Exception): ?>

ftp->message); ?>

PKK>\Vviews/source/index.htmlnuW+A PKK>\4[views/styles/view.html.phpnuW+Aitems = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->preview = JComponentHelper::getParams('com_templates')->get('template_positions_display'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Check if there are no matching items if(!count($this->items)) { JFactory::getApplication()->enqueueMessage( JText::_('COM_TEMPLATES_MSG_MANAGE_NO_STYLES') , 'warning' ); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { $state = $this->get('State'); $canDo = TemplatesHelper::getActions(); $isSite = ($state->get('filter.client_id') == 0); JToolBarHelper::title(JText::_('COM_TEMPLATES_MANAGER_STYLES'), 'thememanager'); if ($canDo->get('core.edit.state')) { JToolBarHelper::makeDefault('styles.setDefault', 'COM_TEMPLATES_TOOLBAR_SET_HOME'); JToolBarHelper::divider(); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('style.edit'); } if ($canDo->get('core.create')) { JToolBarHelper::custom('styles.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); JToolBarHelper::divider(); } if ($canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'styles.delete'); JToolBarHelper::divider(); } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_templates'); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES'); } } PKK>\Vviews/styles/tmpl/index.htmlnuW+A PKK>\-怿views/styles/tmpl/default.phpnuW+Aescape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_templates'); $canEdit = $user->authorise('core.edit', 'com_templates'); $canChange = $user->authorise('core.edit.state', 'com_templates'); ?>
 
pagination->getListFooter(); ?>
id); ?> preview && $item->client_id == '0'): ?> client_id == '1'): ?> escape($item->title);?> escape($item->title);?> client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> home == '0' || $item->home == '1'):?> home!='0', $i, 'styles.', $canChange && $item->home!='1');?> image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $item->language_title)), true);?> image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?> assigned > 0) : ?> assigned), array('title'=>JText::plural('COM_TEMPLATES_ASSIGNED', $item->assigned)), true); ?>   id; ?>
PKK>\)views/styles/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/styles/index.htmlnuW+A PKK>\)views/styles/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vviews/index.htmlnuW+A PKK>\views/template/view.html.phpnuW+Afiles = $this->get('Files'); $this->state = $this->get('State'); $this->template = $this->get('Template'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $canDo = TemplatesHelper::getActions(); JToolBarHelper::title(JText::_('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE'), 'thememanager'); JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); JToolBarHelper::divider(); JToolBarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT'); } } PKK>\Vviews/template/index.htmlnuW+A PKK>\)views/template/.htaccessnuW+A Order allow,deny Deny from all PKK>\ʒ  views/template/tmpl/default.phpnuW+A
template->element, $this->template->client_id); ?>

template->element); ?>

template->client_id); ?>

template->xmldata = TemplatesHelper::parseXMLTemplateFile($client->path, $this->template->element);?>

template->xmldata->description); ?>

files['css'])) : ?>
PKK>\Vviews/template/tmpl/index.htmlnuW+A PKK>\)views/template/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKK>\z templates.phpnuW+Aauthorise('core.manage', 'com_templates')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Register helper JLoader::register('TemplatesHelper', dirname(__FILE__) . '/helpers/templates.php'); $controller = JControllerLegacy::getInstance('Templates'); $controller->execute(JRequest::getCmd('task')); $controller->redirect(); PKK>\)tables/.htaccessnuW+A Order allow,deny Deny from all PKK>\loadArray($array['params']); $array['params'] = (string)$registry; } // Verify that the default style is not unset if ($array['home']=='0' && $this->home=='1') { $this->setError(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE')); return false; } return parent::bind($array, $ignore); } /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. */ function check() { if (empty($this->title)) { $this->setError(JText::_('COM_TEMPLATES_ERROR_STYLE_REQUIRES_TITLE')); return false; } return true; } /** * Overloaded store method to ensure unicity of default style. * * @param boolean True to update fields even if they are null. * @return boolean True on success. * @since 1.0 * @link http://docs.joomla.org/JTable/store */ public function store($updateNulls = false) { if ($this->home!='0') { $query = $this->_db->getQuery(true); $query->update('#__template_styles'); $query->set('home=\'0\''); $query->where('client_id='.(int)$this->client_id); $query->where('home='.$this->_db->quote($this->home)); $this->_db->setQuery($query); $this->_db->query(); } return parent::store($updateNulls); } /** * Overloaded store method to unsure existence of a default style for a template. * * @param mixed An optional primary key value to delete. If not set the * instance property value is used. * @return boolean True on success. * @since 1.0 * @link http://docs.joomla.org/JTable/delete */ public function delete($pk = null) { $k = $this->_tbl_key; $pk = (is_null($pk)) ? $this->$k : $pk; if (!is_null($pk)) { $query = $this->_db->getQuery(true); $query->from('#__template_styles'); $query->select('id'); $query->where('client_id='.(int)$this->client_id); $query->where('template='.$this->_db->quote($this->template)); $this->_db->setQuery($query); $results = $this->_db->loadColumn(); if (count($results)==1 && $results[0]==$pk) { $this->setError(JText::_('COM_TEMPLATES_ERROR_CANNOT_DELETE_LAST_STYLE')); return false; } } return parent::delete($pk); } } PKK>\Vtables/index.htmlnuW+A PKK>\" templates.xmlnuW+A com_templates Joomla! Project April 2006 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 COM_TEMPLATES_XML_DESCRIPTION config.xml controller.php index.html templates.php controllers helpers models tables views language/en-GB.com_templates.ini PKK>\. controllers/template.phpnuW+AsetRedirect('index.php?option=com_templates&view=templates'); } public function copy() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); JRequest::setVar('installtype', 'folder'); $newName = JRequest::getCmd('new_name'); $newNameRaw = JRequest::getVar('new_name', null, '', 'string'); $templateID = JRequest::getInt('id', 0); $this->setRedirect('index.php?option=com_templates&view=template&id=' . $templateID); $model = $this->getModel('Template', 'TemplatesModel'); $model->setState('new_name', $newName); $model->setState('tmp_prefix', uniqid('template_copy_')); $model->setState('to_path', JFactory::getConfig()->get('tmp_path') . '/' . $model->getState('tmp_prefix')); // Process only if we have a new name entered if (strlen($newName) > 0) { if (!JFactory::getUser()->authorise('core.create', 'com_templates')) { // User is not authorised to delete JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_CREATE_NOT_PERMITTED')); return false; } // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); // Check that new name is valid if (($newNameRaw !== null) && ($newName !== $newNameRaw)) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_INVALID_TEMPLATE_NAME')); return false; } // Check that new name doesn't already exist if (!$model->checkNewName()) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_DUPLICATE_TEMPLATE_NAME')); return false; } // Check that from name does exist and get the folder name $fromName = $model->getFromName(); if (!$fromName) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME')); return false; } // Call model's copy method if (!$model->copy()) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_COULD_NOT_COPY')); return false; } // Call installation model JRequest::setVar('install_directory', JFactory::getConfig()->get('tmp_path') . '/' . $model->getState('tmp_prefix')); $installModel = $this->getModel('Install', 'InstallerModel'); JFactory::getLanguage()->load('com_installer'); if (!$installModel->install()) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_COULD_NOT_INSTALL')); return false; } $this->setMessage(JText::sprintf('COM_TEMPLATES_COPY_SUCCESS', $newName)); $model->cleanup(); return true; } } } PKK>\ controllers/styles.phpnuW+AgetModel(); $model->duplicate($pks); $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_DUPLICATED')); } catch (Exception $e) { JError::raiseWarning(500, $e->getMessage()); } $this->setRedirect('index.php?option=com_templates&view=styles'); } /** * Proxy for getModel. * * @since 1.6 */ public function getModel($name = 'Style', $prefix = 'TemplatesModel', $config = array()) { $model = parent::getModel($name, $prefix, array('ignore_request' => true)); return $model; } /** * Method to set the home template for a client. * * @since 1.6 */ public function setDefault() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $pks = JRequest::getVar('cid', array(), 'post', 'array'); try { if (empty($pks)) { throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED')); } JArrayHelper::toInteger($pks); // Pop off the first element. $id = array_shift($pks); $model = $this->getModel(); $model->setHome($id); $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_HOME_SET')); } catch (Exception $e) { JError::raiseWarning(500, $e->getMessage()); } $this->setRedirect('index.php?option=com_templates&view=styles'); } /** * Method to unset the default template for a client and for a language * * @since 1.6 */ public function unsetDefault() { // Check for request forgeries JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $pks = JRequest::getVar('cid', array(), 'get', 'array'); JArrayHelper::toInteger($pks); try { if (empty($pks)) { throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED')); } // Pop off the first element. $id = array_shift($pks); $model = $this->getModel(); $model->unsetHome($id); $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_HOME_UNSET')); } catch (Exception $e) { JError::raiseWarning(500, $e->getMessage()); } $this->setRedirect('index.php?option=com_templates&view=styles'); } } PKK>\Vcontrollers/index.htmlnuW+A PKK>\WY[[controllers/style.phpnuW+A\ZZcontrollers/source.phpnuW+AregisterTask('apply', 'save'); } /** * Method to check if you can add a new record. * * Extended classes can override this if necessary. * * @param array An array of input data. * @param string The name of the key for the primary key. * * @return boolean */ protected function allowEdit() { return JFactory::getUser()->authorise('core.edit', 'com_templates'); } /** * Method to check if you can save a new or existing record. * * Extended classes can override this if necessary. * * @param array An array of input data. * @param string The name of the key for the primary key. * * @return boolean */ protected function allowSave() { return $this->allowEdit(); } /** * Method to get a model object, loading it if required. * * @param string The model name. Optional. * @param string The class prefix. Optional. * @param array Configuration array for model. Optional (note, the empty array is atypical compared to other models). * * @return object The model. */ public function getModel($name = 'Source', $prefix = 'TemplatesModel', $config = array()) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * This controller does not have a display method. Redirect back to the list view of the component. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $this->setRedirect(JRoute::_('index.php?option=com_templates&view=templates', false)); } /** * Method to edit an existing record. * * @return void */ public function edit() { // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel(); $recordId = JRequest::getVar('id'); $context = 'com_templates.edit.source'; if (preg_match('#\.\.#', base64_decode($recordId))) { return JError::raiseError(500, JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND')); } // Access check. if (!$this->allowEdit()) { return JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED')); } // Check-out succeeded, push the new record id into the session. $app->setUserState($context.'.id', $recordId); $app->setUserState($context.'.data', null); $this->setRedirect('index.php?option=com_templates&view=source&layout=edit'); return true; } /** * Method to cancel an edit * * @return void */ public function cancel() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel(); $context = 'com_templates.edit.source'; $returnId = (int) $model->getState('extension.id'); // Clean the session data and redirect. $app->setUserState($context.'.id', null); $app->setUserState($context.'.data', null); $this->setRedirect(JRoute::_('index.php?option=com_templates&view=template&id='.$returnId, false)); } /** * Saves a template source file. */ public function save() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $data = JRequest::getVar('jform', array(), 'post', 'array'); $context = 'com_templates.edit.source'; $task = $this->getTask(); $model = $this->getModel(); // Access check. if (!$this->allowSave()) { return JError::raiseWarning(403, JText::_('JERROR_SAVE_NOT_PERMITTED')); } // Match the stored id's with the submitted. if (empty($data['extension_id']) || empty($data['filename'])) { return JError::raiseError(500, JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH')); } elseif ($data['extension_id'] != $model->getState('extension.id')) { return JError::raiseError(500, JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH')); } elseif ($data['filename'] != $model->getState('filename')) { return JError::raiseError(500, JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH')); } // Validate the posted data. $form = $model->getForm(); if (!$form) { JError::raiseError(500, $model->getError()); return false; } $data = $model->validate($form, $data); // Check for validation errors. if ($data === 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'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState($context.'.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_templates&view=source&layout=edit', false)); return false; } // Attempt to save the data. if (!$model->save($data)) { // Save the data in the session. $app->setUserState($context.'.data', $data); // Redirect back to the edit screen. $this->setMessage(JText::sprintf('JERROR_SAVE_FAILED', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_templates&view=source&layout=edit', false)); return false; } $this->setMessage(JText::_('COM_TEMPLATES_FILE_SAVE_SUCCESS')); // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Reset the record data in the session. $app->setUserState($context.'.data', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_templates&view=source&layout=edit', false)); break; default: // Clear the record id and data from the session. $app->setUserState($context.'.id', null); $app->setUserState($context.'.data', null); // Redirect to the list screen. $this->setRedirect(JRoute::_('index.php?option=com_templates&view=template&id='.$model->getState('extension.id'), false)); break; } } } PKK>\)controllers/.htaccessnuW+A Order allow,deny Deny from all PKK>\2zmodels/template.phpnuW+AgetTemplate()) { $temp->name = $name; $temp->exists = file_exists($path.$name); $temp->id = urlencode(base64_encode($template->extension_id.':'.$name)); return $temp; } } /** * Method to get a list of all the files to edit in a template. * * @return array A nested array of relevant files. * @since 1.6 */ public function getFiles() { // Initialise variables. $result = array(); if ($template = $this->getTemplate()) { jimport('joomla.filesystem.folder'); $client = JApplicationHelper::getClientInfo($template->client_id); $path = JPath::clean($client->path.'/templates/'.$template->element.'/'); $lang = JFactory::getLanguage(); // Load the core and/or local language file(s). $lang->load('tpl_' . $template->element, $client->path, null, false, true) || $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, null, false, true); // Check if the template path exists. if (is_dir($path)) { $result['main'] = array(); $result['css'] = array(); $result['clo'] = array(); $result['mlo'] = array(); $result['html'] = array(); // Handle the main PHP files. $result['main']['index'] = $this->getFile($path, 'index.php'); $result['main']['error'] = $this->getFile($path, 'error.php'); $result['main']['print'] = $this->getFile($path, 'component.php'); $result['main']['offline'] = $this->getFile($path, 'offline.php'); // Handle the CSS files. $files = JFolder::files($path.'/css', '\.css$', false, false); foreach ($files as $file) { $result['css'][] = $this->getFile($path.'/css/', 'css/'.$file); } } else { $this->setError(JText::_('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND')); return false; } } return $result; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState() { $app = JFactory::getApplication('administrator'); // Load the User state. $pk = (int) JRequest::getInt('id'); $this->setState('extension.id', $pk); // Load the parameters. $params = JComponentHelper::getParams('com_templates'); $this->setState('params', $params); } /** * Method to get the template information. * * @return mixed Object if successful, false if not and internal error is set. * @since 1.6 */ public function &getTemplate() { if (empty($this->template)) { // Initialise variables. $pk = $this->getState('extension.id'); $db = $this->getDbo(); $result = false; // Get the template information. $db->setQuery( 'SELECT extension_id, client_id, element' . ' FROM #__extensions' . ' WHERE extension_id = '.(int) $pk. ' AND type = '.$db->quote('template') ); $result = $db->loadObject(); if (empty($result)) { if ($error = $db->getErrorMsg()) { $this->setError($error); } else { $this->setError(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND')); } $this->template = false; } else { $this->template = $result; } } return $this->template; } /** * Method to check if new template name already exists * * @return boolean true if name is not used, false otherwise * @since 2.5 */ public function checkNewName() { $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__extensions'); $query->where('name = ' . $db->quote($this->getState('new_name'))); $db->setQuery($query); return ($db->loadResult() == 0); } /** * Method to check if new template name already exists * * @return string name of current template * @since 2.5 */ public function getFromName() { return $this->getTemplate()->element; } /** * Method to check if new template name already exists * * @return boolean true if name is not used, false otherwise * @since 2.5 */ public function copy() { if ($template = $this->getTemplate()) { jimport('joomla.filesystem.folder'); $client = JApplicationHelper::getClientInfo($template->client_id); $fromPath = JPath::clean($client->path.'/templates/'.$template->element.'/'); // Delete new folder if it exists $toPath = $this->getState('to_path'); if (JFolder::exists($toPath)) { if (!JFolder::delete($toPath)) { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_COULD_NOT_WRITE')); return false; } } // Copy all files from $fromName template to $newName folder if (!JFolder::copy($fromPath, $toPath) || !$this->fixTemplateName()) { return false; } return true; } else { JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME')); return false; } } /** * Method to delete tmp folder * * @return boolean true if delete successful, false otherwise * @since 2.5 */ public function cleanup() { // Clear installation messages $app = JFactory::getApplication(); $app->setUserState('com_installer.message', ''); $app->setUserState('com_installer.extension_message', ''); // Delete temporary directory return JFolder::delete($this->getState('to_path')); } /** * Method to rename the template in the XML files and rename the language files * * @return boolean true if successful, false otherwise * @since 2.5 */ protected function fixTemplateName() { // Rename Language files // Get list of language files $result = true; $files = JFolder::files($this->getState('to_path'), '.ini', true, true); $newName = strtolower($this->getState('new_name')); $oldName = $this->getTemplate()->element; jimport('joomla.filesystem.file'); foreach ($files as $file) { $newFile = str_replace($oldName, $newName, $file); $result = JFile::move($file, $newFile) && $result; } // Edit XML file $xmlFile = $this->getState('to_path') . '/templateDetails.xml'; if (JFile::exists($xmlFile)) { $contents = JFile::read($xmlFile); $pattern[] = '#\s*' . $oldName . '\s*#i'; $replace[] = ''. $newName . ''; $pattern[] = '##'; $replace[] = ''; $contents = preg_replace($pattern, $replace, $contents); $result = JFile::write($xmlFile, $contents) && $result; } return $result; } } PKK>\Lnmodels/source.phpnuW+AgetUserState('com_templates.edit.source.id'); // Parse the template id out of the compound reference. $temp = explode(':', base64_decode($id)); $this->setState('extension.id', (int) array_shift($temp)); $fileName = array_shift($temp); $this->setState('filename', $fileName); // Save the syntax for later use $app->setUserState('editor.source.syntax', JFile::getExt($fileName)); // Load the parameters. $params = JComponentHelper::getParams('com_templates'); $this->setState('params', $params); } /** * Method to get the record form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * @return JForm A JForm object on success, false on failure * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // Initialise variables. $app = JFactory::getApplication(); // Codemirror or Editor None should be enabled $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__extensions as a'); $query->where('(a.name ='.$db->quote('plg_editors_codemirror').' AND a.enabled = 1) OR (a.name ='.$db->quote('plg_editors_none').' AND a.enabled = 1)'); $db->setQuery($query); $state = $db->loadResult(); if ((int)$state < 1 ) { $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EDITOR_DISABLED'), 'warning'); } // Get the form. $form = $this->loadForm('com_templates.source', 'source', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_templates.edit.source.data', array()); if (empty($data)) { $data = $this->getSource(); } return $data; } /** * Method to get a single record. * * @return mixed Object on success, false on failure. * @since 1.6 */ public function &getSource() { $item = new stdClass; if (!$this->_template) { $this->getTemplate(); } if ($this->_template) { $fileName = $this->getState('filename'); $client = JApplicationHelper::getClientInfo($this->_template->client_id); $filePath = JPath::clean($client->path.'/templates/'.$this->_template->element.'/'.$fileName); if (file_exists($filePath)) { jimport('joomla.filesystem.file'); $item->extension_id = $this->getState('extension.id'); $item->filename = $this->getState('filename'); $item->source = JFile::read($filePath); } else { $this->setError(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND')); } } return $item; } /** * Method to get the template information. * * @return mixed Object if successful, false if not and internal error is set. * @since 1.6 */ public function &getTemplate() { // Initialise variables. $pk = $this->getState('extension.id'); $db = $this->getDbo(); $result = false; // Get the template information. $db->setQuery( 'SELECT extension_id, client_id, element' . ' FROM #__extensions' . ' WHERE extension_id = '.(int) $pk. ' AND type = '.$db->quote('template') ); $result = $db->loadObject(); if (empty($result)) { if ($error = $db->getErrorMsg()) { $this->setError($error); } else { $this->setError(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND')); } $this->_template = false; } else { $this->_template = $result; } return $this->_template; } /** * Method to store the source file contents. * * @param array The souce data to save. * * @return boolean True on success, false otherwise and internal error set. * @since 1.6 */ public function save($data) { jimport('joomla.filesystem.file'); // Get the template. $template = $this->getTemplate(); if (empty($template)) { return false; } $dispatcher = JDispatcher::getInstance(); $fileName = $this->getState('filename'); $client = JApplicationHelper::getClientInfo($template->client_id); $filePath = JPath::clean($client->path.'/templates/'.$template->element.'/'.$fileName); // Include the extension plugins for the save events. JPluginHelper::importPlugin('extension'); // Set FTP credentials, if given. JClientHelper::setCredentialsFromRequest('ftp'); $ftp = JClientHelper::getCredentials('ftp'); // Try to make the template file writeable. if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0644')) { $this->setError(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE')); return false; } // Trigger the onExtensionBeforeSave event. $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_templates.source', &$data, false)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } $return = JFile::write($filePath, $data['source']); // Try to make the template file unwriteable. if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0444')) { $this->setError(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_UNWRITABLE')); return false; } elseif (!$return) { $this->setError(JText::sprintf('COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME', $fileName)); return false; } // Trigger the onExtensionAfterSave event. $dispatcher->trigger('onExtensionAfterSave', array('com_templates.source', &$table, false)); return true; } } PKK>\I>>models/style.phpnuW+AsetState('style.id', $pk); // Load the parameters. $params = JComponentHelper::getParams('com_templates'); $this->setState('params', $params); } /** * Method to delete rows. * * @param array An array of item ids. * * @return boolean Returns true on success, false on failure. */ public function delete(&$pks) { // Initialise variables. $pks = (array) $pks; $user = JFactory::getUser(); $table = $this->getTable(); // Iterate the items to delete each one. foreach ($pks as $i => $pk) { if ($table->load($pk)) { // Access checks. if (!$user->authorise('core.delete', 'com_templates')) { throw new Exception(JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); } // You should not delete a default style if ($table->home != '0'){ JError::raiseWarning(SOME_ERROR_NUMBER, Jtext::_('COM_TEMPLATES_STYLE_CANNOT_DELETE_DEFAULT_STYLE')); return false; } if (!$table->delete($pk)) { $this->setError($table->getError()); return false; } } else { $this->setError($table->getError()); return false; } } // Clean cache $this->cleanCache(); return true; } /** * Method to duplicate styles. * * @param array An array of primary key IDs. * * @return boolean True if successful. * @throws Exception */ public function duplicate(&$pks) { // Initialise variables. $user = JFactory::getUser(); $db = $this->getDbo(); // Access checks. 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)) { // Reset the id to create a new record. $table->id = 0; // Reset the home (don't want dupes of that field). $table->home = 0; // Alter the title. $m = null; $table->title = $this->generateNewTitle(null, null, $table->title); if (!$table->check() || !$table->store()) { throw new Exception($table->getError()); } } else { throw new Exception($table->getError()); } } // Clean cache $this->cleanCache(); return true; } /** * Method to change the title. * * @param integer $category_id The id of the category. * @param string $alias The alias. * @param string $title The title. * * @return string New title. * @since 1.7.1 */ protected function generateNewTitle($category_id, $alias, $title) { // Alter the title $table = $this->getTable(); while ($table->load(array('title'=>$title))) { $title = JString::increment($title); } return $title; } /** * Method to get the record form. * * @param array $data An optional array of data for the form to interogate. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * @return JForm A JForm object on success, false on failure * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // Initialise variables. $app = JFactory::getApplication(); // The folder and element vars are passed when saving the form. if (empty($data)) { $item = $this->getItem(); $clientId = $item->client_id; $template = $item->template; } else { $clientId = JArrayHelper::getValue($data, 'client_id'); $template = JArrayHelper::getValue($data, 'template'); } // These variables are used to add data from the plugin XML files. $this->setState('item.client_id', $clientId); $this->setState('item.template', $template); // Get the form. $form = $this->loadForm('com_templates.style', 'style', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } // Modify the form based on access controls. if (!$this->canEditState((object) $data)) { // Disable fields for display. $form->setFieldAttribute('home', 'disabled', 'true'); // Disable fields while saving. // The controller has already verified this is a record you can edit. $form->setFieldAttribute('home', 'filter', 'unset'); } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_templates.edit.style.data', array()); if (empty($data)) { $data = $this->getItem(); } return $data; } /** * Method to get a single record. * * @param integer The id of the primary key. * * @return mixed Object on success, false on failure. */ public function getItem($pk = null) { // Initialise variables. $pk = (!empty($pk)) ? $pk : (int) $this->getState('style.id'); if (!isset($this->_cache[$pk])) { $false = false; // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $this->_cache[$pk] = JArrayHelper::toObject($properties, 'JObject'); // Convert the params field to an array. $registry = new JRegistry; $registry->loadString($table->params); $this->_cache[$pk]->params = $registry->toArray(); // Get the template XML. $client = JApplicationHelper::getClientInfo($table->client_id); $path = JPath::clean($client->path.'/templates/'.$table->template.'/templateDetails.xml'); if (file_exists($path)) { $this->_cache[$pk]->xml = simplexml_load_file($path); } else { $this->_cache[$pk]->xml = null; } } return $this->_cache[$pk]; } /** * Returns a reference to the a Table object, always creating it. * * @param type The table type to instantiate * @param string A prefix for the table class name. Optional. * @param array Configuration array for model. Optional. * @return JTable A database object */ public function getTable($type = 'Style', $prefix = 'TemplatesTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } /** * @param object A form object. * @param mixed The data expected for the form. * @throws Exception if there is an error in the form event. * @since 1.6 */ protected function preprocessForm(JForm $form, $data, $group = 'content') { // Initialise variables. $clientId = $this->getState('item.client_id'); $template = $this->getState('item.template'); $lang = JFactory::getLanguage(); $client = JApplicationHelper::getClientInfo($clientId); if (!$form->loadFile('style_'.$client->name, true)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $formFile = JPath::clean($client->path.'/templates/'.$template.'/templateDetails.xml'); // Load the core and/or local language file(s). $lang->load('tpl_'.$template, $client->path, null, false, true) || $lang->load('tpl_'.$template, $client->path.'/templates/'.$template, null, false, true); if (file_exists($formFile)) { // Get the template form. if (!$form->loadFile($formFile, false, '//config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } } // Disable home field if it is default style if ((is_array($data) && array_key_exists('home', $data) && $data['home']=='1') || ((is_object($data) && isset($data->home) && $data->home=='1'))){ $form->setFieldAttribute('home', 'readonly', 'true'); } // Attempt to load the xml file. if (!$xml = simplexml_load_file($formFile)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/extension/help'); if (!empty($help)) { $helpKey = trim((string) $help[0]['key']); $helpURL = trim((string) $help[0]['url']); $this->helpKey = $helpKey ? $helpKey : $this->helpKey; $this->helpURL = $helpURL ? $helpURL : $this->helpURL; } // Trigger the default form events. parent::preprocessForm($form, $data, $group); } /** * Method to save the form data. * * @param array The form data. * @return boolean True on success. */ public function save($data) { // Detect disabled extension $extension = JTable::getInstance('Extension'); if ($extension->load(array('enabled' => 0, 'type' => 'template', 'element' => $data['template'], 'client_id' => $data['client_id']))) { $this->setError(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE')); return false; } // Initialise variables; $dispatcher = JDispatcher::getInstance(); $table = $this->getTable(); $pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState('style.id'); $isNew = true; // Include the extension plugins for the save events. JPluginHelper::importPlugin('extension'); // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } if (JRequest::getVar('task') == 'save2copy') { $data['title'] = $this->generateNewTitle(null, null, $data['title']); $data['home'] = 0; $data['assigned'] =''; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the onExtensionBeforeSave event. $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_templates.style', &$table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } $user = JFactory::getUser(); if ($user->authorise('core.edit', 'com_menus') && $table->client_id==0) { $n = 0; $db = JFactory::getDbo(); $user = JFactory::getUser(); if (!empty($data['assigned']) && is_array($data['assigned'])) { JArrayHelper::toInteger($data['assigned']); // Update the mapping for menu items that this style IS assigned to. $query = $db->getQuery(true); $query->update('#__menu'); $query->set('template_style_id='.(int)$table->id); $query->where('id IN ('.implode(',', $data['assigned']).')'); $query->where('template_style_id!='.(int) $table->id); $query->where('checked_out in (0,'.(int) $user->id.')'); $db->setQuery($query); $db->query(); $n += $db->getAffectedRows(); } // Remove style mappings for menu items this style is NOT assigned to. // If unassigned then all existing maps will be removed. $query = $db->getQuery(true); $query->update('#__menu'); $query->set('template_style_id=0'); if (!empty($data['assigned'])) { $query->where('id NOT IN ('.implode(',', $data['assigned']).')'); } $query->where('template_style_id='.(int) $table->id); $query->where('checked_out in (0,'.(int) $user->id.')'); $db->setQuery($query); $db->query(); $n += $db->getAffectedRows(); if ($n > 0) { $app = JFactory::getApplication(); $app->enQueueMessage(JText::plural('COM_TEMPLATES_MENU_CHANGED', $n)); } } // Clean the cache. $this->cleanCache(); // Trigger the onExtensionAfterSave event. $dispatcher->trigger('onExtensionAfterSave', array('com_templates.style', &$table, $isNew)); $this->setState('style.id', $table->id); return true; } /** * Method to set a template style as home. * * @param int The primary key ID for the style. * * @return boolean True if successful. * @throws Exception */ public function setHome($id = 0) { // Initialise variables. $user = JFactory::getUser(); $db = $this->getDbo(); // Access checks. if (!$user->authorise('core.edit.state', 'com_templates')) { throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } $style = JTable::getInstance('Style', 'TemplatesTable'); if (!$style->load((int)$id)) { throw new Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND')); } // Detect disabled extension $extension = JTable::getInstance('Extension'); if ($extension->load(array('enabled' => 0, 'type' => 'template', 'element' => $style->template, 'client_id' => $style->client_id))) { throw new Exception(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE')); } // Reset the home fields for the client_id. $db->setQuery( 'UPDATE #__template_styles' . ' SET home = \'0\'' . ' WHERE client_id = '.(int) $style->client_id . ' AND home = \'1\'' ); if (!$db->query()) { throw new Exception($db->getErrorMsg()); } // Set the new home style. $db->setQuery( 'UPDATE #__template_styles' . ' SET home = \'1\'' . ' WHERE id = '.(int) $id ); if (!$db->query()) { throw new Exception($db->getErrorMsg()); } // Clean the cache. $this->cleanCache(); return true; } /** * Method to unset a template style as default for a language. * * @param int The primary key ID for the style. * * @return boolean True if successful. * @throws Exception */ public function unsetHome($id = 0) { // Initialise variables. $user = JFactory::getUser(); $db = $this->getDbo(); // Access checks. if (!$user->authorise('core.edit.state', 'com_templates')) { throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } // Lookup the client_id. $db->setQuery( 'SELECT client_id, home' . ' FROM #__template_styles' . ' WHERE id = '.(int) $id ); $style = $db->loadObject(); if ($error = $db->getErrorMsg()) { throw new Exception($error); } elseif (!is_numeric($style->client_id)) { throw new Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND')); } elseif ($style->home=='1') { throw new Exception(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE')); } // Set the new home style. $db->setQuery( 'UPDATE #__template_styles' . ' SET home = \'0\'' . ' WHERE id = '.(int) $id ); if (!$db->query()) { throw new Exception($db->getErrorMsg()); } // Clean the cache. $this->cleanCache(); return true; } /** * Get the necessary data to load an item help screen. * * @return object An object with key, url, and local properties for loading the item help screen. * @since 1.6 */ public function getHelp() { return (object) array('key' => $this->helpKey, 'url' => $this->helpURL); } /** * Custom clean cache method * * @since 1.6 */ protected function cleanCache($group = null, $client_id = 0) { parent::cleanCache('com_templates'); parent::cleanCache('_system'); } } PKK>\2%models/templates.phpnuW+Aclient_id); $item->xmldata = TemplatesHelper::parseXMLTemplateFile($client->path, $item->element); } return $items; } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.extension_id, a.name, a.element, a.client_id' ) ); $query->from($db->quoteName('#__extensions').' AS a'); // Filter by extension type. $query->where($db->quoteName('type').' = '.$db->quote('template')); // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = '.(int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } else { $search = $db->Quote('%'.$db->escape($search, true).'%'); $query->where('a.element LIKE '.$search.' OR a.name LIKE '.$search); } } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.folder')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * @return string A store id. * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.client_id'); return parent::getStoreId($id); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', null); $this->setState('filter.client_id', $clientId); // Load the parameters. $params = JComponentHelper::getParams('com_templates'); $this->setState('params', $params); // List state information. parent::populateState('a.element', 'asc'); } } PKK>\Pemodels/styles.phpnuW+AgetUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $template = $this->getUserStateFromRequest($this->context.'.filter.template', 'filter_template', '0', 'cmd'); $this->setState('filter.template', $template); $clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', null); $this->setState('filter.client_id', $clientId); // Load the parameters. $params = JComponentHelper::getParams('com_templates'); $this->setState('params', $params); // List state information. parent::populateState('a.template', 'asc'); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.template'); $id .= ':'.$this->getState('filter.client_id'); return parent::getStoreId($id); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.template, a.title, a.home, a.client_id, l.title AS language_title, l.image as image' ) ); $query->from($db->quoteName('#__template_styles').' AS a'); // Join on menus. $query->select('COUNT(m.template_style_id) AS assigned'); $query->leftjoin('#__menu AS m ON m.template_style_id = a.id'); $query->group('a.id, a.template, a.title, a.home, a.client_id, l.title, l.image, e.extension_id'); // Join over the language $query->join('LEFT', '#__languages AS l ON l.lang_code = a.home'); // Filter by extension enabled $query->select('extension_id AS e_id'); $query->join('LEFT', '#__extensions AS e ON e.element = a.template'); $query->where('e.enabled = 1'); $query->where($db->quoteName('e.type') . '=' . $db->quote('template')); // Filter by template. if ($template = $this->getState('filter.template')) { $query->where('a.template = '.$db->quote($template)); } // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = '.(int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } else { $search = $db->Quote('%'.$db->escape($search, true).'%'); $query->where('a.template LIKE '.$search.' OR a.title LIKE '.$search); } } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.title')).' '.$db->escape($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; } } PKK>\)models/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vmodels/index.htmlnuW+A PKK>\rۖmodels/forms/source.xmlnuW+A
PKK>\G/rrmodels/forms/style.xmlnuW+A
PKK>\Vmodels/forms/index.htmlnuW+A PKK>\ aCSSmodels/forms/style_site.xmlnuW+A
PKK>\)models/forms/.htaccessnuW+A Order allow,deny Deny from all PKK>\8RR$models/forms/style_administrator.xmlnuW+A
PKK>\0&helpers/html/templates.phpnuW+Apath.'/templates/'.$template; $baseUrl = ($clientId == 0) ? JUri::root(true) : JUri::root(true).'/administrator'; $thumb = $basePath.'/template_thumbnail.png'; $preview = $basePath.'/template_preview.png'; $html = ''; if (file_exists($thumb)) { $clientPath = ($clientId == 0) ? '' : 'administrator/'; $thumb = $clientPath.'templates/'.$template.'/template_thumbnail.png'; $html = JHtml::_('image', $thumb, JText::_('COM_TEMPLATES_PREVIEW')); if (file_exists($preview)) { $preview = $baseUrl.'/templates/'.$template.'/template_preview.png'; $html = ''.$html.''; } } return $html; } } PKK>\Vhelpers/html/index.htmlnuW+A PKK>\)helpers/html/.htaccessnuW+A Order allow,deny Deny from all PKK>\Vhelpers/index.htmlnuW+A PKK>\)helpers/.htaccessnuW+A Order allow,deny Deny from all PKK>\i helpers/templates.phpnuW+Aset($action->name, $user->authorise($action->name, 'com_templates')); } return $result; } /** * Get a list of filter options for the application clients. * * @return array An array of JHtmlOption elements. */ public static function getClientOptions() { // Build the filter options. $options = array(); $options[] = JHtml::_('select.option', '0', JText::_('JSITE')); $options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR')); return $options; } /** * Get a list of filter options for the templates with styles. * * @return array An array of JHtmlOption elements. */ public static function getTemplateOptions($clientId = '*') { // Build the filter options. $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($clientId != '*') { $query->where('client_id='.(int) $clientId); } $query->select('element as value, name as text, extension_id as e_id'); $query->from('#__extensions'); $query->where('type='.$db->quote('template')); $query->where('enabled=1'); $query->order('client_id'); $query->order('name'); $db->setQuery($query); $options = $db->loadObjectList(); return $options; } public static function parseXMLTemplateFile($templateBaseDir, $templateDir) { $data = new JObject; // Check of the xml file exists $filePath = JPath::clean($templateBaseDir.'/templates/'.$templateDir.'/templateDetails.xml'); if (is_file($filePath)) { $xml = JInstaller::parseXMLInstallFile($filePath); if ($xml['type'] != 'template') { return false; } foreach ($xml as $key => $value) { $data->set($key, $value); } } return $data; } } PKa>\Vtemplates/index.htmlnuW+APKa>\5W!  ctemplates/default.phpnuW+APKa>\)templates/.htaccessnuW+APKa>\) t.htaccessnuW+APKa>\),styles/.htaccessnuW+APKa>\o$|styles/default.phpnuW+APKa>\V2styles/index.htmlnuW+APKa>\V 3index.htmlnuW+APKK>\H p3config.xmlnuW+APKK>\/ 6access.xmlnuW+APKK>\j9controller.phpnuW+APKK>\)@views/.htaccessnuW+APKK>\}4WW>Aviews/prevuuw/view.html.phpnuW+APKK>\)Gviews/prevuuw/.htaccessnuW+APKK>\VHviews/prevuuw/index.htmlnuW+APKK>\) Iviews/prevuuw/tmpl/.htaccessnuW+APKK>\VIviews/prevuuw/tmpl/index.htmlnuW+APKK>\! N..DJviews/prevuuw/tmpl/default.phpnuW+APKK>\VOviews/templates/tmpl/index.htmlnuW+APKK>\).Pviews/templates/tmpl/.htaccessnuW+APKK>\Г7"TT Pviews/templates/tmpl/default.phpnuW+APKK>\Vdviews/templates/index.htmlnuW+APKK>\ 5eviews/templates/view.html.phpnuW+APKK>\)dlviews/templates/.htaccessnuW+APKK>\U,mviews/style/view.html.phpnuW+APKK>\)wuviews/style/.htaccessnuW+APKK>\V;vviews/style/index.htmlnuW+APKK>\/W vviews/style/tmpl/edit.phpnuW+APKK>\)views/style/tmpl/.htaccessnuW+APKK>\Vviews/style/tmpl/index.htmlnuW+APKK>\6++!views/style/tmpl/edit_options.phpnuW+APKK>\$views/style/tmpl/edit_assignment.phpnuW+APKK>\)ŏviews/source/.htaccessnuW+APKK>\"&DDviews/source/view.html.phpnuW+APKK>\38llviews/source/tmpl/edit.phpnuW+APKK>\)Νviews/source/tmpl/.htaccessnuW+APKK>\Vviews/source/tmpl/index.htmlnuW+APKK>\views/source/tmpl/edit_ftp.phpnuW+APKK>\Vviews/source/index.htmlnuW+APKK>\4[Zviews/styles/view.html.phpnuW+APKK>\V-views/styles/tmpl/index.htmlnuW+APKK>\-怿views/styles/tmpl/default.phpnuW+APKK>\)views/styles/tmpl/.htaccessnuW+APKK>\Vnviews/styles/index.htmlnuW+APKK>\)views/styles/.htaccessnuW+APKK>\Vviews/index.htmlnuW+APKK>\views/template/view.html.phpnuW+APKK>\Vcviews/template/index.htmlnuW+APKK>\)views/template/.htaccessnuW+APKK>\ʒ  views/template/tmpl/default.phpnuW+APKK>\Vviews/template/tmpl/index.htmlnuW+APKK>\)nviews/template/tmpl/.htaccessnuW+APKK>\z :templates.phpnuW+APKK>\)tables/.htaccessnuW+APKK>\\Vtables/index.htmlnuW+APKK>\" Ztemplates.xmlnuW+APKK>\. controllers/template.phpnuW+APKK>\ controllers/styles.phpnuW+APKK>\Vcontrollers/index.htmlnuW+APKK>\WY[[[controllers/style.phpnuW+APKK>\ZZcontrollers/source.phpnuW+APKK>\)1controllers/.htaccessnuW+APKK>\2z_2models/template.phpnuW+APKK>\LneNmodels/source.phpnuW+APKK>\I>>7hmodels/style.phpnuW+APKK>\2%!models/templates.phpnuW+APKK>\Pe|models/styles.phpnuW+APKK>\)Nmodels/.htaccessnuW+APKK>\V models/index.htmlnuW+APKK>\rۖmmodels/forms/source.xmlnuW+APKK>\G/rrJmodels/forms/style.xmlnuW+APKK>\Vmodels/forms/index.htmlnuW+APKK>\ aCSShmodels/forms/style_site.xmlnuW+APKK>\)models/forms/.htaccessnuW+APKK>\8RR$models/forms/style_administrator.xmlnuW+APKK>\0&qhelpers/html/templates.phpnuW+APKK>\Vhelpers/html/index.htmlnuW+APKK>\))helpers/html/.htaccessnuW+APKK>\Vhelpers/index.htmlnuW+APKK>\)Ohelpers/.htaccessnuW+APKK>\i helpers/templates.phpnuW+APKRR