You've already forked joomla_test
first commit
This commit is contained in:
11
administrator/components/com_templates/access.xml
Normal file
11
administrator/components/com_templates/access.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<access component="com_templates">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
|
||||
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
|
||||
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
|
||||
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
|
||||
</section>
|
||||
</access>
|
36
administrator/components/com_templates/config.xml
Normal file
36
administrator/components/com_templates/config.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<fieldset
|
||||
name="templates"
|
||||
label="COM_TEMPLATES_SUBMENU_TEMPLATES"
|
||||
description="COM_TEMPLATES_CONFIG_FIELDSET_DESC">
|
||||
|
||||
<field
|
||||
name="template_positions_display"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
label="COM_TEMPLATES_CONFIG_POSITIONS_LABEL"
|
||||
description="COM_TEMPLATES_CONFIG_POSITIONS_DESC">
|
||||
<option
|
||||
value="0">JDISABLED</option>
|
||||
<option
|
||||
value="1">JENABLED</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
description="JCONFIG_PERMISSIONS_DESC"
|
||||
>
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
component="com_templates"
|
||||
section="component" />
|
||||
</fieldset>
|
||||
</config>
|
55
administrator/components/com_templates/controller.php
Normal file
55
administrator/components/com_templates/controller.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Templates manager master display controller.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* @var string The default view.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'styles';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$view = $this->input->get('view', 'styles');
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
if ($view == 'style' && $layout == 'edit' && !$this->checkEditId('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();
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
248
administrator/components/com_templates/controllers/source.php
Normal file
248
administrator/components/com_templates/controllers/source.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Template style controller class.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesControllerSource extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
// Apply, Save & New, and Save As copy should be standard on forms.
|
||||
$this->registerTask('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()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$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'));
|
||||
|
||||
$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'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$data = $this->input->post->get('jform', array(), '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;
|
||||
}
|
||||
}
|
||||
}
|
27
administrator/components/com_templates/controllers/style.php
Normal file
27
administrator/components/com_templates/controllers/style.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Template style controller class.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesControllerStyle extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* @var string The prefix to use with controller messages.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_TEMPLATES_STYLE';
|
||||
|
||||
}
|
132
administrator/components/com_templates/controllers/styles.php
Normal file
132
administrator/components/com_templates/controllers/styles.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Template styles list controller class.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesControllerStyles extends JControllerAdmin
|
||||
{
|
||||
/**
|
||||
* Method to clone and existing template style.
|
||||
*/
|
||||
public function duplicate()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$pks = $this->input->post->get('cid', array(), 'array');
|
||||
|
||||
try
|
||||
{
|
||||
if (empty($pks))
|
||||
{
|
||||
throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED'));
|
||||
}
|
||||
|
||||
JArrayHelper::toInteger($pks);
|
||||
|
||||
$model = $this->getModel();
|
||||
$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'));
|
||||
|
||||
$pks = $this->input->post->get('cid', array(), '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'));
|
||||
|
||||
$pks = $this->input->get->get('cid', array(), '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');
|
||||
}
|
||||
}
|
104
administrator/components/com_templates/controllers/template.php
Normal file
104
administrator/components/com_templates/controllers/template.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JLoader::register('InstallerModelInstall', JPATH_ADMINISTRATOR . '/components/com_installer/models/install.php');
|
||||
|
||||
/**
|
||||
* Template style controller class.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesControllerTemplate extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$this->setRedirect('index.php?option=com_templates&view=templates');
|
||||
}
|
||||
|
||||
public function copy()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$this->input->set('installtype', 'folder');
|
||||
$newName = $this->input->get('new_name');
|
||||
$newNameRaw = $this->input->get('new_name', null, 'string');
|
||||
$templateID = $this->input->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
|
||||
$this->input->set('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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,49 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
*/
|
||||
class JHtmlTemplates
|
||||
{
|
||||
/**
|
||||
* Display the thumb for the template.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*/
|
||||
public static function thumb($template, $clientId = 0)
|
||||
{
|
||||
$client = JApplicationHelper::getClientInfo($clientId);
|
||||
$basePath = $client->path . '/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))
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.modal');
|
||||
|
||||
$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 = '<a href="' . $preview . '" class="thumbnail pull-left modal hasTooltip" title="' . JHtml::tooltipText('COM_TEMPLATES_CLICK_TO_ENLARGE') . '">' . $html . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
169
administrator/components/com_templates/helpers/templates.php
Normal file
169
administrator/components/com_templates/helpers/templates.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Templates component helper.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesHelper
|
||||
{
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_TEMPLATES_SUBMENU_STYLES'),
|
||||
'index.php?option=com_templates&view=styles',
|
||||
$vName == 'styles'
|
||||
);
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_TEMPLATES_SUBMENU_TEMPLATES'),
|
||||
'index.php?option=com_templates&view=templates',
|
||||
$vName == 'templates'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @return JObject
|
||||
*/
|
||||
public static function getActions()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$result = new JObject;
|
||||
|
||||
$actions = JAccess::getActions('com_templates');
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($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')
|
||||
->from('#__extensions')
|
||||
->where('type = ' . $db->quote('template'))
|
||||
->where('enabled = 1')
|
||||
->order('client_id')
|
||||
->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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getPositions($clientId, $templateDir)
|
||||
{
|
||||
$positions = array();
|
||||
|
||||
$templateBaseDir = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
|
||||
$filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');
|
||||
|
||||
if (is_file($filePath))
|
||||
{
|
||||
// Read the file to see if it's a valid component XML file
|
||||
$xml = simplexml_load_file($filePath);
|
||||
if (!$xml)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for a valid XML root tag.
|
||||
|
||||
// Extensions use 'extension' as the root tag. Languages use 'metafile' instead
|
||||
|
||||
if ($xml->getName() != 'extension' && $xml->getName() != 'metafile')
|
||||
{
|
||||
unset($xml);
|
||||
return false;
|
||||
}
|
||||
|
||||
$positions = (array) $xml->positions;
|
||||
|
||||
if (isset($positions['position']))
|
||||
{
|
||||
$positions = $positions['position'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$positions = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $positions;
|
||||
}
|
||||
}
|
1
administrator/components/com_templates/index.html
Normal file
1
administrator/components/com_templates/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="extension_id"
|
||||
type="hidden" />
|
||||
|
||||
<field
|
||||
name="filename"
|
||||
type="hidden" />
|
||||
|
||||
<field
|
||||
name="source"
|
||||
type="editor"
|
||||
editor="codemirror|none"
|
||||
buttons="no"
|
||||
label="COM_TEMPLATES_FIELD_SOURCE_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_SOURCE_DESC"
|
||||
height="500px"
|
||||
rows="20"
|
||||
cols="80"
|
||||
filter="raw" />
|
||||
</fieldset>
|
||||
</form>
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
id="id"
|
||||
name="id"
|
||||
type="text"
|
||||
default="0"
|
||||
readonly="true"
|
||||
class="readonly"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" />
|
||||
|
||||
<field
|
||||
name="template"
|
||||
type="text"
|
||||
label="COM_TEMPLATES_FIELD_TEMPLATE_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_TEMPLATE_DESC"
|
||||
class="readonly"
|
||||
size="30"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="client_id"
|
||||
type="hidden"
|
||||
label="COM_TEMPLATES_FIELD_CLIENT_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_CLIENT_DESC"
|
||||
class="readonly"
|
||||
default="0"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
class="inputbox"
|
||||
size="50"
|
||||
label="COM_TEMPLATES_FIELD_TITLE_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_TITLE_DESC"
|
||||
required="true" />
|
||||
|
||||
<field name="assigned" type="hidden" />
|
||||
|
||||
</fieldset>
|
||||
</form>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="home"
|
||||
type="radio"
|
||||
label="COM_TEMPLATES_FIELD_HOME_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_HOME_ADMINISTRATOR_DESC"
|
||||
class="btn-group"
|
||||
default="0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="home"
|
||||
type="contentlanguage"
|
||||
label="COM_TEMPLATES_FIELD_HOME_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_HOME_SITE_DESC"
|
||||
class="inputbox"
|
||||
default="0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JALL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
1
administrator/components/com_templates/models/index.html
Normal file
1
administrator/components/com_templates/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
256
administrator/components/com_templates/models/source.php
Normal file
256
administrator/components/com_templates/models/source.php
Normal file
@ -0,0 +1,256 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.5
|
||||
*/
|
||||
class TemplatesModelSource extends JModelForm
|
||||
{
|
||||
/**
|
||||
* Cache for the template information.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $_template = null;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
// Load the User state.
|
||||
$id = $app->getUserState('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)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Codemirror or Editor None should be enabled
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__extensions as a')
|
||||
->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();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_templates.source', $data);
|
||||
|
||||
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))
|
||||
{
|
||||
$item->extension_id = $this->getState('extension.id');
|
||||
$item->filename = $this->getState('filename');
|
||||
$item->source = file_get_contents($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()
|
||||
{
|
||||
$pk = $this->getState('extension.id');
|
||||
$db = $this->getDbo();
|
||||
|
||||
// Get the template information.
|
||||
$db->setQuery(
|
||||
'SELECT extension_id, client_id, element' .
|
||||
' FROM #__extensions' .
|
||||
' WHERE extension_id = ' . (int) $pk .
|
||||
' AND type = ' . $db->quote('template')
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->loadObject();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
$this->_template = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($result))
|
||||
{
|
||||
$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 = JEventDispatcher::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;
|
||||
}
|
||||
}
|
629
administrator/components/com_templates/models/style.php
Normal file
629
administrator/components/com_templates/models/style.php
Normal file
@ -0,0 +1,629 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Template style model.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesModelStyle extends JModelAdmin
|
||||
{
|
||||
/**
|
||||
* @var string The help screen key for the module.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $helpKey = 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES_EDIT';
|
||||
|
||||
/**
|
||||
* @var string The help screen base URL for the module.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $helpURL;
|
||||
|
||||
/**
|
||||
* Item cache.
|
||||
*/
|
||||
private $_cache = array();
|
||||
|
||||
/**
|
||||
* 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 = $app->input->getInt('id');
|
||||
$this->setState('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)
|
||||
{
|
||||
$pks = (array) $pks;
|
||||
$user = JFactory::getUser();
|
||||
$table = $this->getTable();
|
||||
|
||||
// Iterate the items to delete each one.
|
||||
foreach ($pks as $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)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// 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)
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_templates.style', $data);
|
||||
|
||||
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)
|
||||
{
|
||||
$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')
|
||||
{
|
||||
$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.path');
|
||||
|
||||
$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, false)
|
||||
|| $lang->load('tpl_'.$template, $client->path.'/templates/'.$template, null, false, false)
|
||||
|| $lang->load('tpl_'.$template, $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_'.$template, $client->path.'/templates/'.$template, $lang->getDefault(), false, false);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$dispatcher = JEventDispatcher::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 ($app->input->get('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)
|
||||
->update('#__menu')
|
||||
->set('template_style_id='.(int) $table->id)
|
||||
->where('id IN ('.implode(',', $data['assigned']).')')
|
||||
->where('template_style_id!='.(int) $table->id)
|
||||
->where('checked_out in (0,'.(int) $user->id.')');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
$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)
|
||||
->update('#__menu')
|
||||
->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)
|
||||
->where('checked_out in (0,'.(int) $user->id.')');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
$n += $db->getAffectedRows();
|
||||
if ($n > 0)
|
||||
{
|
||||
$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 integer The primary key ID for the style.
|
||||
*
|
||||
* @return boolean True if successful.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setHome($id = 0)
|
||||
{
|
||||
$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\''
|
||||
);
|
||||
$db->execute();
|
||||
|
||||
// Set the new home style.
|
||||
$db->setQuery(
|
||||
'UPDATE #__template_styles' .
|
||||
' SET home = \'1\'' .
|
||||
' WHERE id = '.(int) $id
|
||||
);
|
||||
$db->execute();
|
||||
|
||||
// Clean the cache.
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unset a template style as default for a language.
|
||||
*
|
||||
* @param integer The primary key ID for the style.
|
||||
*
|
||||
* @return boolean True if successful.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function unsetHome($id = 0)
|
||||
{
|
||||
$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 (!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
|
||||
);
|
||||
$db->execute();
|
||||
|
||||
// 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');
|
||||
}
|
||||
}
|
165
administrator/components/com_templates/models/styles.php
Normal file
165
administrator/components/com_templates/models/styles.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Methods supporting a list of template style records.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesModelStyles extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'client_id', 'a.client_id',
|
||||
'template', 'a.template',
|
||||
'home', 'a.home',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$template = $this->getUserStateFromRequest($this->context . '.filter.template', 'filter_template');
|
||||
$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')
|
||||
->join('LEFT', '#__menu AS m ON m.template_style_id = a.id')
|
||||
->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')
|
||||
->join('LEFT', '#__extensions AS e ON e.element = a.template')
|
||||
->where('e.enabled = 1')
|
||||
->where('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;
|
||||
}
|
||||
}
|
286
administrator/components/com_templates/models/template.php
Normal file
286
administrator/components/com_templates/models/template.php
Normal file
@ -0,0 +1,286 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesModelTemplate extends JModelLegacy
|
||||
{
|
||||
protected $template = null;
|
||||
|
||||
/**
|
||||
* Internal method to get file properties.
|
||||
*
|
||||
* @param string The base path.
|
||||
* @param string The file name.
|
||||
* @return object
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getFile($path, $name)
|
||||
{
|
||||
$temp = new stdClass;
|
||||
|
||||
if ($template = $this->getTemplate())
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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, false)
|
||||
|| $lang->load('tpl_'.$template->element, $client->path.'/templates/'.$template->element, null, false, false)
|
||||
|| $lang->load('tpl_'.$template->element, $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_'.$template->element, $client->path.'/templates/'.$template->element, $lang->getDefault(), false, false);
|
||||
|
||||
// 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 = $app->input->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))
|
||||
{
|
||||
$pk = $this->getState('extension.id');
|
||||
$db = $this->getDbo();
|
||||
|
||||
// Get the template information.
|
||||
$query = $db->getQuery(true)
|
||||
->select('extension_id, client_id, element')
|
||||
->from('#__extensions')
|
||||
->where($db->quoteName('extension_id') . ' = ' . (int) $pk)
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('template'));
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->loadObject();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
$this->template = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($result))
|
||||
{
|
||||
$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)
|
||||
->select('COUNT(*)')
|
||||
->from('#__extensions')
|
||||
->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 = file_get_contents($xmlFile);
|
||||
$pattern[] = '#<name>\s*' . $oldName . '\s*</name>#i';
|
||||
$replace[] = '<name>'. $newName . '</name>';
|
||||
$pattern[] = '#<language(.*)' . $oldName . '(.*)</language>#';
|
||||
$replace[] = '<language${1}' . $newName . '${2}</language>';
|
||||
$contents = preg_replace($pattern, $replace, $contents);
|
||||
$result = JFile::write($xmlFile, $contents) && $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
162
administrator/components/com_templates/models/templates.php
Normal file
162
administrator/components/com_templates/models/templates.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Methods supporting a list of template extension records.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesModelTemplates extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'id', 'a.id',
|
||||
'name', 'a.name',
|
||||
'folder', 'a.folder',
|
||||
'element', 'a.element',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'state', 'a.state',
|
||||
'enabled', 'a.enabled',
|
||||
'access', 'a.access', 'access_level',
|
||||
'ordering', 'a.ordering',
|
||||
'client_id', 'a.client_id',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent getItems to add extra XML metadata.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$items = parent::getItems();
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$client = JApplicationHelper::getClientInfo($item->client_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)
|
||||
{
|
||||
// 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');
|
||||
}
|
||||
}
|
1
administrator/components/com_templates/tables/index.html
Normal file
1
administrator/components/com_templates/tables/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
123
administrator/components/com_templates/tables/style.php
Normal file
123
administrator/components/com_templates/tables/style.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
*/
|
||||
class TemplatesTableStyle extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver A database connector object
|
||||
*/
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__template_styles', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function to pre-process the params.
|
||||
*
|
||||
* @param array Named array
|
||||
* @return null|string null is operation was satisfactory, otherwise returns an error
|
||||
* @see JTable:bind
|
||||
* @since 1.5
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
if (isset($array['params']) && is_array($array['params']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->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.
|
||||
*/
|
||||
public 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)
|
||||
->update('#__template_styles')
|
||||
->set('home=\'0\'')
|
||||
->where('client_id=' . (int) $this->client_id)
|
||||
->where('home='.$this->_db->quote($this->home));
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
}
|
||||
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)
|
||||
->from('#__template_styles')
|
||||
->select('id')
|
||||
->where('client_id=' . (int) $this->client_id)
|
||||
->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);
|
||||
}
|
||||
}
|
21
administrator/components/com_templates/templates.php
Normal file
21
administrator/components/com_templates/templates.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_templates'))
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
JLoader::register('TemplatesHelper', __DIR__ . '/helpers/templates.php');
|
||||
|
||||
$controller = JControllerLegacy::getInstance('Templates');
|
||||
$controller->execute(JFactory::getApplication()->input->get('task'));
|
||||
$controller->redirect();
|
30
administrator/components/com_templates/templates.xml
Normal file
30
administrator/components/com_templates/templates.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.1" method="upgrade">
|
||||
<name>com_templates</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>April 2006</creationDate>
|
||||
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved. </copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>COM_TEMPLATES_XML_DESCRIPTION</description>
|
||||
<administration>
|
||||
<files folder="admin">
|
||||
<filename>config.xml</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>templates.php</filename>
|
||||
<folder>controllers</folder>
|
||||
<folder>helpers</folder>
|
||||
<folder>models</folder>
|
||||
<folder>tables</folder>
|
||||
<folder>views</folder>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB.com_templates.ini</language>
|
||||
<language tag="en-GB">language/en-GB.com_templates.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
||||
|
1
administrator/components/com_templates/views/index.html
Normal file
1
administrator/components/com_templates/views/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,47 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('behavior.formvalidation');
|
||||
JHtml::_('behavior.keepalive');
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task)
|
||||
{
|
||||
if (task == 'source.cancel' || document.formvalidator.isValid(document.id('source-form')))
|
||||
{
|
||||
<?php echo $this->form->getField('source')->save(); ?>
|
||||
Joomla.submitform(task, document.getElementById('source-form'));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&layout=edit'); ?>" method="post" name="adminForm" id="source-form" class="form-validate">
|
||||
<?php if ($this->ftp) : ?>
|
||||
<?php echo $this->loadTemplate('ftp'); ?>
|
||||
<?php endif; ?>
|
||||
<fieldset class="adminform">
|
||||
<legend><?php echo JText::sprintf('COM_TEMPLATES_TEMPLATE_FILENAME', $this->source->filename, $this->template->element); ?></legend>
|
||||
|
||||
<?php echo $this->form->getLabel('source'); ?>
|
||||
<div class="clr"></div>
|
||||
<div class="editor-border">
|
||||
<?php echo $this->form->getInput('source'); ?>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</fieldset>
|
||||
|
||||
<?php echo $this->form->getInput('extension_id'); ?>
|
||||
<?php echo $this->form->getInput('filename'); ?>
|
||||
|
||||
</form>
|
@ -0,0 +1,41 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
<fieldset class="adminform" title="<?php echo JText::_('COM_TEMPLATES_FTP_TITLE'); ?>">
|
||||
<legend><?php echo JText::_('COM_TEMPLATES_FTP_TITLE'); ?></legend>
|
||||
|
||||
<?php echo JText::_('COM_TEMPLATES_FTP_DESC'); ?>
|
||||
|
||||
<?php if ($this->ftp instanceof Exception) : ?>
|
||||
<p class="error"><?php echo JText::_($this->ftp->message); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="adminform">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="120">
|
||||
<label for="username"><?php echo JText::_('JGLOBAL_USERNAME'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="username" name="username" class="inputbox" size="70" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120">
|
||||
<label for="password"><?php echo JText::_('JGLOBAL_PASSWORD'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" id="password" name="password" class="inputbox" size="70" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,77 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View to edit a template style.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesViewSource extends JViewLegacy
|
||||
{
|
||||
protected $form;
|
||||
|
||||
protected $ftp;
|
||||
|
||||
protected $source;
|
||||
|
||||
protected $state;
|
||||
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->form = $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()
|
||||
{
|
||||
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
111
administrator/components/com_templates/views/style/tmpl/edit.php
Normal file
111
administrator/components/com_templates/views/style/tmpl/edit.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('behavior.formvalidation');
|
||||
JHtml::_('behavior.keepalive');
|
||||
$user = JFactory::getUser();
|
||||
$canDo = TemplatesHelper::getActions();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task)
|
||||
{
|
||||
if (task == 'style.cancel' || document.formvalidator.isValid(document.id('style-form')))
|
||||
{
|
||||
Joomla.submitform(task, document.getElementById('style-form'));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="style-form" class="form-validate form-horizontal">
|
||||
<fieldset>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('JDETAILS', true)); ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('title'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('title'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('template'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('template'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('client_id'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('client_id'); ?>
|
||||
<input type="text" size="35" value="<?php echo $this->item->client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> " class="readonly" readonly="readonly" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('home'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('home'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($this->item->id) : ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('id'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<span class="disabled"><?php echo $this->item->id; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->xml) : ?>
|
||||
<?php if ($text = trim($this->item->xml->description)) : ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_DESCRIPTION'); ?>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<span class="disabled"><?php echo JText::_($text); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<div class="alert alert-error"><?php echo JText::_('COM_TEMPLATES_ERR_XML'); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'options', JText::_('JOPTIONS', true)); ?>
|
||||
<?php //get the menu parameters that are automatically set but may be modified.
|
||||
echo $this->loadTemplate('options'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php if ($user->authorise('core.edit', 'com_menu') && $this->item->client_id == 0):?>
|
||||
<?php if ($canDo->get('core.edit.state')) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'assignment', JText::_('COM_TEMPLATES_MENUS_ASSIGNMENT', true)); ?>
|
||||
<?php echo $this->loadTemplate('assignment'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif;?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
|
||||
</fieldset>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
@ -0,0 +1,44 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Initiasile related data.
|
||||
require_once JPATH_ADMINISTRATOR.'/components/com_menus/helpers/menus.php';
|
||||
$menuTypes = MenusHelper::getMenuLinks();
|
||||
$user = JFactory::getUser();
|
||||
?>
|
||||
<label id="jform_menuselect-lbl" for="jform_menuselect"><?php echo JText::_('JGLOBAL_MENU_SELECTION'); ?></label>
|
||||
<div class="btn-toolbar">
|
||||
<button class="btn" type="button" class="jform-rightbtn" onclick="$$('.chk-menulink').each(function(el) { el.checked = !el.checked; });">
|
||||
<i class="icon-checkbox-partial"></i> <?php echo JText::_('JGLOBAL_SELECTION_INVERT'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div id="menu-assignment">
|
||||
<ul class="menu-links thumbnails">
|
||||
|
||||
<?php foreach ($menuTypes as &$type) : ?>
|
||||
<li class="span3">
|
||||
<div class="thumbnail">
|
||||
<button class="btn" type="button" class="jform-rightbtn" onclick="$$('.<?php echo $type->menutype; ?>').each(function(el) { el.checked = !el.checked; });">
|
||||
<i class="icon-checkbox-partial"></i> <?php echo JText::_('JGLOBAL_SELECTION_INVERT'); ?>
|
||||
</button>
|
||||
<h5><?php echo $type->title ? $type->title : $type->menutype; ?></h5>
|
||||
|
||||
<?php foreach ($type->links as $link) : ?>
|
||||
<label class="checkbox small" for="link<?php echo (int) $link->value;?>" >
|
||||
<input type="checkbox" name="jform[assigned][]" value="<?php echo (int) $link->value;?>" id="link<?php echo (int) $link->value;?>"<?php if ($link->template_style_id == $this->item->id):?> checked="checked"<?php endif;?><?php if ($link->checked_out && $link->checked_out != $user->id):?> disabled="disabled"<?php else:?> class="chk-menulink <?php echo $type->menutype; ?>"<?php endif;?> />
|
||||
<?php echo $link->text; ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
@ -0,0 +1,40 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Load chosen.css
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
?>
|
||||
<?php
|
||||
echo JHtml::_('bootstrap.startAccordion', 'templatestyleOptions', array('active' => 'collapse0'));
|
||||
$fieldSets = $this->form->getFieldsets('params');
|
||||
$i = 0;
|
||||
|
||||
foreach ($fieldSets as $name => $fieldSet) :
|
||||
$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_TEMPLATES_'.$name.'_FIELDSET_LABEL';
|
||||
echo JHtml::_('bootstrap.addSlide', 'templatestyleOptions', JText::_($label), 'collapse' . $i++);
|
||||
if (isset($fieldSet->description) && trim($fieldSet->description)) :
|
||||
echo '<p class="tip">'.$this->escape(JText::_($fieldSet->description)).'</p>';
|
||||
endif;
|
||||
?>
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $field->label; ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $field->input; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
echo JHtml::_('bootstrap.endSlide');
|
||||
endforeach;
|
||||
echo JHtml::_('bootstrap.endAccordion');
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
103
administrator/components/com_templates/views/style/view.html.php
Normal file
103
administrator/components/com_templates/views/style/view.html.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View to edit a template style.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesViewStyle extends JViewLegacy
|
||||
{
|
||||
protected $item;
|
||||
|
||||
protected $form;
|
||||
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->item = $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()
|
||||
{
|
||||
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,149 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the component HTML helpers.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.multiselect');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
$user = JFactory::getUser();
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&view=styles'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if (!empty( $this->sidebar)) : ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
<?php echo $this->sidebar; ?>
|
||||
</div>
|
||||
<div id="j-main-container" class="span10">
|
||||
<?php else : ?>
|
||||
<div id="j-main-container">
|
||||
<?php endif;?>
|
||||
|
||||
<div id="filter-bar" class="btn-toolbar">
|
||||
<div class="filter-search btn-group pull-left">
|
||||
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_STYLES_FILTER_SEARCH_DESC'); ?>" />
|
||||
</div>
|
||||
<div class="btn-group pull-left">
|
||||
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
|
||||
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
|
||||
</div>
|
||||
<div class="btn-group pull-right hidden-phone">
|
||||
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
|
||||
<?php echo $this->pagination->getLimitBox(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5">
|
||||
 
|
||||
</th>
|
||||
<th>
|
||||
<?php echo JHtml::_('grid.sort', 'COM_TEMPLATES_HEADING_STYLE', 'a.title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="5%" class="nowrap center">
|
||||
<?php echo JHtml::_('grid.sort', 'COM_TEMPLATES_HEADING_DEFAULT', 'a.home', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="5%" class="nowrap center">
|
||||
<?php echo JText::_('COM_TEMPLATES_HEADING_ASSIGNED'); ?>
|
||||
</th>
|
||||
<th width="10%" class="nowrap">
|
||||
<?php echo JHtml::_('grid.sort', 'JCLIENT', 'a.client_id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th>
|
||||
<?php echo JHtml::_('grid.sort', 'COM_TEMPLATES_HEADING_TEMPLATE', 'a.template', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="1%" class="nowrap center">
|
||||
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($this->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');
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td width="1%" class="center">
|
||||
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($this->preview && $item->client_id == '0') : ?>
|
||||
<a target="_blank" href="<?php echo JUri::root().'index.php?tp=1&templateStyle='.(int) $item->id ?>" class="jgrid">
|
||||
<i class="icon-eye-open hasTooltip" title="<?php echo JHtml::tooltipText(JText::_('COM_TEMPLATES_TEMPLATE_PREVIEW'), $item->title, 0); ?>" ></i></a>
|
||||
<?php elseif ($item->client_id == '1') : ?>
|
||||
<i class="icon-eye-close disabled hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_TEMPLATE_NO_PREVIEW_ADMIN'); ?>" ></i>
|
||||
<?php else: ?>
|
||||
<i class="icon-eye-close disabled hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_TEMPLATE_NO_PREVIEW'); ?>" ></i>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=style.edit&id='.(int) $item->id); ?>">
|
||||
<?php echo $this->escape($item->title);?></a>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($item->title);?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->home == '0' || $item->home == '1'):?>
|
||||
<?php echo JHtml::_('jgrid.isdefault', $item->home != '0', $i, 'styles.', $canChange && $item->home != '1');?>
|
||||
<?php elseif ($canChange):?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=styles.unsetDefault&cid[]='.$item->id.'&'.JSession::getFormToken().'=1');?>">
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title' => JText::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $item->language_title)), true);?>
|
||||
</a>
|
||||
<?php else:?>
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title' => $item->language_title), true);?>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->assigned > 0) : ?>
|
||||
<i class="icon-ok tip hasTooltip" title="<?php echo JHtml::tooltipText(JText::plural('COM_TEMPLATES_ASSIGNED', $item->assigned), '', 0); ?>"></i>
|
||||
<?php else : ?>
|
||||
 
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="small">
|
||||
<?php echo $item->client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?>
|
||||
</td>
|
||||
<td>
|
||||
<label for="cb<?php echo $i;?>" class="small">
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&view=template&id='.(int) $item->e_id); ?> ">
|
||||
<?php echo ucfirst($this->escape($item->template));?>
|
||||
</a>
|
||||
</label>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,114 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View class for a list of template styles.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesViewStyles extends JViewLegacy
|
||||
{
|
||||
protected $items;
|
||||
|
||||
protected $pagination;
|
||||
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->preview = JComponentHelper::getParams('com_templates')->get('template_positions_display');
|
||||
|
||||
TemplatesHelper::addSubmenu('styles');
|
||||
|
||||
// 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();
|
||||
$this->sidebar = JHtmlSidebar::render();
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
$canDo = TemplatesHelper::getActions();
|
||||
|
||||
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');
|
||||
|
||||
JHtmlSidebar::setAction('index.php?option=com_templates&view=styles');
|
||||
|
||||
JHtmlSidebar::addFilter(
|
||||
JText::_('COM_TEMPLATES_FILTER_TEMPLATE'),
|
||||
'filter_template',
|
||||
JHtml::_('select.options', TemplatesHelper::getTemplateOptions($this->state->get('filter.client_id')), 'value', 'text', $this->state->get('filter.template'))
|
||||
);
|
||||
|
||||
JHtmlSidebar::addFilter(
|
||||
JText::_('JGLOBAL_FILTER_CLIENT'),
|
||||
'filter_client_id',
|
||||
JHtml::_('select.options', TemplatesHelper::getClientOptions(), 'value', 'text', $this->state->get('filter.client_id'))
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,148 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the component HTML helpers.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.modal');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
$canDo = TemplatesHelper::getActions();
|
||||
$input = JFactory::getApplication()->input;
|
||||
?>
|
||||
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&view=template'); ?>" method="post" name="adminForm" id="adminForm" class="form-horizontal">
|
||||
<fieldset id="template-manager">
|
||||
<div class="pull-left">
|
||||
<?php echo JHtml::_('templates.thumb', $this->template->element, $this->template->client_id); ?>
|
||||
</div>
|
||||
<h2><?php echo ucfirst($this->template->element); ?></h2>
|
||||
<?php $client = JApplicationHelper::getClientInfo($this->template->client_id); ?>
|
||||
<p><?php $this->template->xmldata = TemplatesHelper::parseXMLTemplateFile($client->path, $this->template->element);?></p>
|
||||
<p><?php echo JText::_($this->template->xmldata->description); ?></p>
|
||||
<div class="clearfix"></div>
|
||||
<hr />
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<div class="page-header">
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_MASTER_FILES');?>
|
||||
</div>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li>
|
||||
<?php $id = $this->files['main']['index']->id; ?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=source.edit&id='.$id);?>">
|
||||
<i class="icon-edit"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_EDIT_MAIN');?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php if ($this->files['main']['error']->exists) : ?>
|
||||
<li>
|
||||
<?php $id = $this->files['main']['error']->id; ?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=source.edit&id='.$id);?>">
|
||||
<i class="icon-edit"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_EDIT_ERROR');?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->files['main']['offline']->exists) : ?>
|
||||
<li>
|
||||
<?php $id = $this->files['main']['offline']->id; ?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=source.edit&id='.$id);?>">
|
||||
<i class="icon-edit"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_EDIT_OFFLINEVIEW');?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->files['main']['print']->exists) : ?>
|
||||
<li>
|
||||
<?php $id = $this->files['main']['print']->id; ?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=source.edit&id='.$id);?>">
|
||||
<i class="icon-edit"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_EDIT_PRINTVIEW');?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<div class="page-header">
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_CSS');?>
|
||||
</div>
|
||||
<?php if (!empty($this->files['css'])) : ?>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<?php foreach ($this->files['css'] as $file) : ?>
|
||||
<li>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=source.edit&id='.$file->id);?>">
|
||||
<i class="icon-edit"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo JText::sprintf('COM_TEMPLATES_TEMPLATE_EDIT_CSS', $file->name);?>
|
||||
<?php if ($canDo->get('core.edit')) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div>
|
||||
<a href="#" class="modal">
|
||||
<?php echo JText::sprintf('COM_TEMPLATES_TEMPLATE_ADD_CSS');?></a>
|
||||
</div>-->
|
||||
|
||||
</fieldset>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
</form>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&task=template.copy&id=' . $input->getInt('id')); ?>"
|
||||
method="post" name="adminForm" id="adminForm">
|
||||
<div id="collapseModal" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><?php echo JText::_('COM_TEMPLATES_TEMPLATE_COPY');?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="template-manager-css" class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label for="new_name" class="control-label hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_TEMPLATE_NEW_NAME_DESC'); ?>"><?php echo JText::_('COM_TEMPLATES_TEMPLATE_NEW_NAME_LABEL')?></label>
|
||||
<div class="controls">
|
||||
<input class="input-xlarge" type="text" id="new_name" name="new_name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">Close</a>
|
||||
<button class="btn btn-primary" type="submit"><?php echo JText::_('COM_TEMPLATES_TEMPLATE_COPY'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
||||
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,79 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View to edit a template style.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesViewTemplate extends JViewLegacy
|
||||
{
|
||||
protected $files;
|
||||
|
||||
protected $state;
|
||||
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->files = $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()
|
||||
{
|
||||
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||
|
||||
// Get the toolbar object instance
|
||||
$bar = JToolBar::getInstance('toolbar');
|
||||
$user = JFactory::getUser();
|
||||
|
||||
JToolbarHelper::title(JText::_('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE'), 'thememanager');
|
||||
|
||||
JToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE');
|
||||
|
||||
// Add a copy button
|
||||
if ($user->authorise('core.create', 'com_templates'))
|
||||
{
|
||||
$title = JText::_('JLIB_HTML_BATCH_COPY');
|
||||
|
||||
// Instantiate a new JLayoutFile instance and render the batch button
|
||||
$layout = new JLayoutFile('joomla.toolbar.batch');
|
||||
|
||||
$dhtml = $layout->render(array('title' => $title));
|
||||
$bar->appendButton('Custom', $dhtml, 'upload');
|
||||
}
|
||||
|
||||
JToolbarHelper::divider();
|
||||
JToolbarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT');
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,130 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the component HTML helpers.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.modal');
|
||||
JHtml::_('behavior.multiselect');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
$user = JFactory::getUser();
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_templates&view=templates'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if (!empty( $this->sidebar)) : ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
<?php echo $this->sidebar; ?>
|
||||
</div>
|
||||
<div id="j-main-container" class="span10">
|
||||
<?php else : ?>
|
||||
<div id="j-main-container">
|
||||
<?php endif;?>
|
||||
|
||||
<div id="filter-bar" class="btn-toolbar">
|
||||
<div class="filter-search btn-group pull-left">
|
||||
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_TEMPLATES_FILTER_SEARCH_DESC'); ?>" />
|
||||
</div>
|
||||
<div class="btn-group pull-left">
|
||||
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
|
||||
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"> </div>
|
||||
<table class="table table-striped" id="template-mgr">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col1template">
|
||||
 
|
||||
</th>
|
||||
<th>
|
||||
<?php echo JHtml::_('grid.sort', 'COM_TEMPLATES_HEADING_TEMPLATE', 'a.element', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="10%">
|
||||
<?php echo JHtml::_('grid.sort', 'JCLIENT', 'a.client_id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="10%">
|
||||
<?php echo JText::_('JVERSION'); ?>
|
||||
</th>
|
||||
<th width="15%">
|
||||
<?php echo JText::_('JDATE'); ?>
|
||||
</th>
|
||||
<th width="25%" >
|
||||
<?php echo JText::_('JAUTHOR'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td class="center">
|
||||
<?php echo JHtml::_('templates.thumb', $item->element, $item->client_id); ?>
|
||||
</td>
|
||||
<td class="template-name">
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&view=template&id='.(int) $item->extension_id); ?>">
|
||||
<?php echo JText::sprintf('COM_TEMPLATES_TEMPLATE_DETAILS', ucfirst($item->name)); ?></a>
|
||||
<p>
|
||||
<?php if ($this->preview && $item->client_id == '0') : ?>
|
||||
<a href="<?php echo JUri::root().'index.php?tp=1&template='.$item->element; ?>" target="_blank">
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_PREVIEW'); ?></a>
|
||||
<?php elseif ($item->client_id == '1') : ?>
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_NO_PREVIEW_ADMIN'); ?>
|
||||
<?php else: ?>
|
||||
<span class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_TEMPLATES_TEMPLATE_NO_PREVIEW_DESC'); ?>">
|
||||
<?php echo JText::_('COM_TEMPLATES_TEMPLATE_NO_PREVIEW'); ?></span>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</td>
|
||||
<td class="small">
|
||||
<?php echo $item->client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?>
|
||||
</td>
|
||||
<td class="small">
|
||||
<?php echo $this->escape($item->xmldata->get('version')); ?>
|
||||
</td>
|
||||
<td class="small">
|
||||
<?php echo $this->escape($item->xmldata->get('creationDate')); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($author = $item->xmldata->get('author')) : ?>
|
||||
<p><?php echo $this->escape($author); ?></p>
|
||||
<?php else : ?>
|
||||
—
|
||||
<?php endif; ?>
|
||||
<?php if ($email = $item->xmldata->get('authorEmail')) : ?>
|
||||
<p><?php echo $this->escape($email); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($url = $item->xmldata->get('authorUrl')) : ?>
|
||||
<p><a href="<?php echo $this->escape($url); ?>">
|
||||
<?php echo $this->escape($url); ?></a></p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,104 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View class for a list of template styles.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesViewTemplates extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->preview = JComponentHelper::getParams('com_templates')->get('template_positions_display');
|
||||
|
||||
TemplatesHelper::addSubmenu('templates');
|
||||
|
||||
// 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()
|
||||
{
|
||||
$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');
|
||||
|
||||
JHtmlSidebar::setAction('index.php?option=com_templates&view=templates');
|
||||
|
||||
JHtmlSidebar::addFilter(
|
||||
JText::_('JGLOBAL_FILTER_CLIENT'),
|
||||
'filter_client_id',
|
||||
JHtml::_('select.options', TemplatesHelper::getClientOptions(), 'value', 'text', $this->state->get('filter.client_id'))
|
||||
);
|
||||
|
||||
$this->sidebar = JHtmlSidebar::render();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user