From bedc26c665289fb18b064a4d5bd88180286b4436 Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Thu, 28 May 2015 02:15:45 +0200 Subject: [PATCH 1/2] #1 - Remove 'Install Language' button --- .../components/com_languages/views/installed/view.html.php | 7 +------ .../components/com_languages/views/languages/view.html.php | 5 ----- administrator/language/en-GB/en-GB.com_languages.ini | 1 - .../webdriver/Pages/Extensions/LanguageManagerPage.php | 1 - 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/administrator/components/com_languages/views/installed/view.html.php b/administrator/components/com_languages/views/installed/view.html.php index b7c1cae18e..72a2d90eee 100644 --- a/administrator/components/com_languages/views/installed/view.html.php +++ b/administrator/components/com_languages/views/installed/view.html.php @@ -85,12 +85,7 @@ protected function addToolbar() if ($canDo->get('core.admin')) { - // Add install languages link to the lang installer component - $bar = JToolbar::getInstance('toolbar'); - $bar->appendButton('Link', 'upload', 'COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages'); - JToolbarHelper::divider(); - - JToolbarHelper::preferences('com_languages'); + JToolbarHelper::preferences('com_languages'); JToolbarHelper::divider(); } diff --git a/administrator/components/com_languages/views/languages/view.html.php b/administrator/components/com_languages/views/languages/view.html.php index a55f7b64cb..adf5bdfdcd 100644 --- a/administrator/components/com_languages/views/languages/view.html.php +++ b/administrator/components/com_languages/views/languages/view.html.php @@ -90,11 +90,6 @@ protected function addToolbar() if ($canDo->get('core.admin')) { - // Add install languages link to the lang installer component - $bar = JToolbar::getInstance('toolbar'); - $bar->appendButton('Link', 'upload', 'COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages'); - JToolbarHelper::divider(); - JToolbarHelper::preferences('com_languages'); JToolbarHelper::divider(); } diff --git a/administrator/language/en-GB/en-GB.com_languages.ini b/administrator/language/en-GB/en-GB.com_languages.ini index d92ec4c1a0..cf5b5400be 100644 --- a/administrator/language/en-GB/en-GB.com_languages.ini +++ b/administrator/language/en-GB/en-GB.com_languages.ini @@ -13,7 +13,6 @@ COM_LANGUAGES_FIELD_IMAGE_DESC="Prefix of the image file for this language when COM_LANGUAGES_FIELD_IMAGE_LABEL="Image Prefix" COM_LANGUAGES_FIELD_LANG_TAG_DESC="Enter the language tag – example: en-GB for English (UK). This should be the exact prefix used for the language installed or to be installed." COM_LANGUAGES_FIELD_LANG_TAG_LABEL="Language Tag" -COM_LANGUAGES_INSTALL="Install Language" COM_LANGUAGES_OVERRIDE_FIELD_BOTH_LABEL="For both locations" COM_LANGUAGES_OVERRIDE_FIELD_BOTH_DESC="If this box is checked the override will be stored for both administrator (Backend) and site (Frontend). This is essential for creating language overrides for some plugins because their language files, while stored in backend, are also used in frontend (example: plg_content_vote).
Please note that the two overrides will be completely independent from each other after storing them." COM_LANGUAGES_OVERRIDE_FIELD_CLIENT_LABEL="Location" diff --git a/tests/system/webdriver/Pages/Extensions/LanguageManagerPage.php b/tests/system/webdriver/Pages/Extensions/LanguageManagerPage.php index 3b18ba2fd7..022624718d 100644 --- a/tests/system/webdriver/Pages/Extensions/LanguageManagerPage.php +++ b/tests/system/webdriver/Pages/Extensions/LanguageManagerPage.php @@ -63,7 +63,6 @@ class LanguageManagerPage extends AdminManagerPage 'Publish' => 'toolbar-publish', 'Unpublish' => 'toolbar-unpublish', 'Trash' => 'toolbar-trash', - 'Install Language' => 'toolbar-upload', 'Empty Trash' => 'toolbar-delete', 'Options' => 'toolbar-options', ); From 4ca4a11fc460103707396eafffd231fc39b2c42f Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Fri, 29 May 2015 19:57:47 +0200 Subject: [PATCH 2/2] #102 - Remove the 'template' view and template edit functionality. --- .../components/com_templates/config.xml | 45 - .../com_templates/controllers/template.php | 717 --------- .../com_templates/helpers/template.php | 180 --- .../com_templates/models/forms/source.xml | 25 - .../com_templates/models/template.php | 1279 ----------------- .../views/template/tmpl/default.php | 539 ------- .../template/tmpl/default_description.php | 19 - .../views/template/tmpl/default_folders.php | 25 - .../views/template/tmpl/default_tree.php | 62 - .../views/template/view.html.php | 301 ---- .../views/templates/tmpl/default.php | 3 +- 11 files changed, 1 insertion(+), 3194 deletions(-) delete mode 100644 administrator/components/com_templates/controllers/template.php delete mode 100644 administrator/components/com_templates/helpers/template.php delete mode 100644 administrator/components/com_templates/models/forms/source.xml delete mode 100644 administrator/components/com_templates/models/template.php delete mode 100644 administrator/components/com_templates/views/template/tmpl/default.php delete mode 100644 administrator/components/com_templates/views/template/tmpl/default_description.php delete mode 100644 administrator/components/com_templates/views/template/tmpl/default_folders.php delete mode 100644 administrator/components/com_templates/views/template/tmpl/default_tree.php delete mode 100644 administrator/components/com_templates/views/template/view.html.php diff --git a/administrator/components/com_templates/config.xml b/administrator/components/com_templates/config.xml index 152ed50e86..dd52662071 100644 --- a/administrator/components/com_templates/config.xml +++ b/administrator/components/com_templates/config.xml @@ -16,51 +16,6 @@ - - - - - - - - - - -
registerTask('apply', 'save'); - } - - /** - * Method for closing the template. - * - * @return void. - * - * @since 3.2 - */ - public function cancel() - { - $this->setRedirect(JRoute::_('index.php?option=com_templates&view=templates', false)); - } - - /** - * Method for closing a file. - * - * @return void. - * - * @since 3.2 - */ - public function close() - { - $app = JFactory::getApplication(); - $file = base64_encode('home'); - $id = $app->input->get('id'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method for copying the template. - * - * @return boolean true on success, false otherwise - * - * @since 3.2 - */ - public function copy() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $app = JFactory::getApplication(); - $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); - $file = $this->input->get('file'); - - $this->setRedirect('index.php?option=com_templates&view=template&id=' . $templateID . '&file=' . $file); - $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 - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_CREATE_NOT_PERMITTED'), 'error'); - - return false; - } - - // Set FTP credentials, if given - JClientHelper::setCredentialsFromRequest('ftp'); - - // Check that new name is valid - if (($newNameRaw !== null) && ($newName !== $newNameRaw)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_INVALID_TEMPLATE_NAME'), 'error'); - - return false; - } - - // Check that new name doesn't already exist - if (!$model->checkNewName()) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_DUPLICATE_TEMPLATE_NAME'), 'error'); - - return false; - } - - // Check that from name does exist and get the folder name - $fromName = $model->getFromName(); - - if (!$fromName) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'), 'error'); - - return false; - } - - // Call model's copy method - if (!$model->copy()) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_COULD_NOT_COPY'), 'error'); - - 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()) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_COULD_NOT_INSTALL'), 'error'); - - return false; - } - - $this->setMessage(JText::sprintf('COM_TEMPLATES_COPY_SUCCESS', $newName)); - $model->cleanup(); - - return true; - } - } - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional (note, the empty array is atypical compared to other models). - * - * @return JModelLegacy The model. - * - * @since 3.2 - */ - public function getModel($name = 'Template', $prefix = 'TemplatesModel', $config = array()) - { - $model = parent::getModel($name, $prefix, $config); - - return $model; - } - - /** - * Method to check if you can add a new record. - * - * @return boolean - * - * @since 3.2 - */ - protected function allowEdit() - { - return JFactory::getUser()->authorise('core.edit', 'com_templates'); - } - - /** - * Method to check if you can save a new or existing record. - * - * @return boolean - * - * @since 3.2 - */ - protected function allowSave() - { - return $this->allowEdit(); - } - - /** - * Saves a template source file. - * - * @return void - * - * @since 3.2 - */ - 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'); - $task = $this->getTask(); - $model = $this->getModel(); - $fileName = $app->input->get('file'); - $explodeArray = explode(':', base64_decode($fileName)); - - // Access check. - if (!$this->allowSave()) - { - $app->enqueueMessage(JText::_('JERROR_SAVE_NOT_PERMITTED'), 'error'); - - return false; - } - - // Match the stored id's with the submitted. - if (empty($data['extension_id']) || empty($data['filename'])) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH'), 'error'); - - return false; - } - elseif ($data['extension_id'] != $model->getState('extension.id')) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH'), 'error'); - - return false; - } - elseif ($data['filename'] != end($explodeArray)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_ID_FILENAME_MISMATCH'), 'error'); - - return false; - } - - // Validate the posted data. - $form = $model->getForm(); - - if (!$form) - { - $app->enqueueMessage($model->getError(), 'error'); - - 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'); - } - } - - // Redirect back to the edit screen. - $url = 'index.php?option=com_templates&view=template&id=' . $model->getState('extension.id') . '&file=' . $fileName; - $this->setRedirect(JRoute::_($url, false)); - - return false; - } - - // Attempt to save the data. - if (!$model->save($data)) - { - // Redirect back to the edit screen. - $this->setMessage(JText::sprintf('JERROR_SAVE_FAILED', $model->getError()), 'warning'); - $url = 'index.php?option=com_templates&view=template&id=' . $model->getState('extension.id') . '&file=' . $fileName; - $this->setRedirect(JRoute::_($url, false)); - - return false; - } - - $this->setMessage(JText::_('COM_TEMPLATES_FILE_SAVE_SUCCESS')); - - // Redirect the user based on the chosen task. - switch ($task) - { - case 'apply': - - // Redirect back to the edit screen. - $url = 'index.php?option=com_templates&view=template&id=' . $model->getState('extension.id') . '&file=' . $fileName; - $this->setRedirect(JRoute::_($url, false)); - break; - - default: - - // Redirect to the list screen. - $file = base64_encode('home'); - $id = $app->input->get('id'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - break; - } - } - - /** - * Method for creating override. - * - * @return void - * - * @since 3.2 - */ - public function overrides() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $file = $app->input->get('file'); - $override = base64_decode($app->input->get('folder')); - $id = $app->input->get('id'); - - if ($model->createOverride($override)) - { - $this->setMessage(JText::_('COM_TEMPLATES_OVERRIDE_SUCCESS')); - } - - // Redirect back to the edit screen. - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method for compiling LESS. - * - * @return void - * - * @since 3.2 - * @deprecated - */ - public function less() - { - - } - - /** - * Method for deleting a file. - * - * @return void - * - * @since 3.2 - */ - public function delete() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - - if (base64_decode(urldecode($file)) == 'index.php') - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_INDEX_DELETE'), 'warning'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - - elseif ($model->deleteFile($file)) - { - $this->setMessage(JText::_('COM_TEMPLATES_FILE_DELETE_SUCCESS')); - $file = base64_encode('home'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FILE_DELETE'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for creating a new file. - * - * @return void - * - * @since 3.2 - */ - public function createFile() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $name = $app->input->get('name'); - $location = base64_decode($app->input->get('address')); - $type = $app->input->get('type'); - - if ($type == 'null') - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_INVALID_FILE_TYPE'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif (!preg_match('/^[a-zA-Z0-9-_]+$/', $name)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_INVALID_FILE_NAME'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($model->createFile($name, $type, $location)) - { - $this->setMessage(JText::_('COM_TEMPLATES_FILE_CREATE_SUCCESS')); - $file = urlencode(base64_encode($location . '/' . $name . '.' . $type)); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FILE_CREATE'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for uploading a file. - * - * @return void - * - * @since 3.2 - */ - public function uploadFile() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $upload = $app->input->files->get('files'); - $location = base64_decode($app->input->get('address')); - - if ($return = $model->uploadFile($upload, $location)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UPLOAD_SUCCESS') . $upload['name']); - $redirect = base64_encode($return); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $redirect; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FILE_UPLOAD'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for creating a new folder. - * - * @return void - * - * @since 3.2 - */ - public function createFolder() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $name = $app->input->get('name'); - $location = base64_decode($app->input->get('address')); - - if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $name)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_INVALID_FOLDER_NAME'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($model->createFolder($name, $location)) - { - $this->setMessage(JText::_('COM_TEMPLATES_FOLDER_CREATE_SUCCESS')); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FOLDER_CREATE'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for deleting a folder. - * - * @return void - * - * @since 3.2 - */ - public function deleteFolder() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $location = base64_decode($app->input->get('address')); - - if (empty($location)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_ROOT_DELETE'), 'warning'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($model->deleteFolder($location)) - { - $this->setMessage(JText::_('COM_TEMPLATES_FOLDER_DELETE_SUCCESS')); - - if (stristr(base64_decode($file), $location) != false) - { - $file = base64_encode('home'); - } - - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_DELETE_ERROR'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for renaming a file. - * - * @return void - * - * @since 3.2 - */ - public function renameFile() - { - $app = JFactory::getApplication(); - $model = $this->getModel(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $newName = $app->input->get('new_name'); - - if (base64_decode(urldecode($file)) == 'index.php') - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_RENAME_INDEX'), 'warning'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif (!preg_match('/^[a-zA-Z0-9-_]+$/', $newName)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_INVALID_FILE_NAME'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($rename = $model->renameFile($file, $newName)) - { - $this->setMessage(JText::_('COM_TEMPLATES_FILE_RENAME_SUCCESS')); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $rename; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FILE_RENAME'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for cropping an image. - * - * @return void - * - * @since 3.2 - */ - public function cropImage() - { - $app = JFactory::getApplication(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $x = $app->input->get('x'); - $y = $app->input->get('y'); - $w = $app->input->get('w'); - $h = $app->input->get('h'); - $model = $this->getModel(); - - if (empty($w) && empty($h) && empty($x) && empty($y)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_CROP_AREA_ERROR'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($model->cropImage($file, $w, $h, $x, $y)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_CROP_SUCCESS')); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_CROP_ERROR'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for resizing an image. - * - * @return void - * - * @since 3.2 - */ - public function resizeImage() - { - $app = JFactory::getApplication(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $width = $app->input->get('width'); - $height = $app->input->get('height'); - $model = $this->getModel(); - - if ($model->resizeImage($file, $width, $height)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_RESIZE_SUCCESS')); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_RESIZE_ERROR'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for copying a file. - * - * @return void - * - * @since 3.2 - */ - public function copyFile() - { - $app = JFactory::getApplication(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $newName = $app->input->get('new_name'); - $location = base64_decode($app->input->get('address')); - $model = $this->getModel(); - - if (!preg_match('/^[a-zA-Z0-9-_]+$/', $newName)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_INVALID_FILE_NAME'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - elseif ($model->copyFile($newName, $location, $file)) - { - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_COPY_FAIL'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } - - /** - * Method for extracting an archive file. - * - * @return void - * - * @since 3.2 - */ - public function extractArchive() - { - $app = JFactory::getApplication(); - $id = $app->input->get('id'); - $file = $app->input->get('file'); - $model = $this->getModel(); - - if ($model->extractArchive($file)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_EXTRACT_SUCCESS')); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_EXTRACT_FAIL'), 'error'); - $url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; - $this->setRedirect(JRoute::_($url, false)); - } - } -} diff --git a/administrator/components/com_templates/helpers/template.php b/administrator/components/com_templates/helpers/template.php deleted file mode 100644 index f4c9330f39..0000000000 --- a/administrator/components/com_templates/helpers/template.php +++ /dev/null @@ -1,180 +0,0 @@ -enqueueMessage(JText::_('COM_TEMPLATES_ERROR_UPLOAD_INPUT'), 'error'); - - return false; - } - - // Media file names should never have executable extensions buried in them. - $executable = array( - 'exe', 'phtml','java', 'perl', 'py', 'asp','dll', 'go', 'jar', - 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp', - 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', - 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh' - ); - $explodedFileName = explode('.', $file['name']); - - if (count($explodedFileName > 2)) - { - foreach ($executable as $extensionName) - { - if (in_array($extensionName, $explodedFileName)) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXECUTABLE'), 'error'); - - return false; - } - } - } - - jimport('joomla.filesystem.file'); - - if ($file['name'] !== JFile::makeSafe($file['name']) || preg_match('/\s/', JFile::makeSafe($file['name']))) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILENAME'), 'error'); - - return false; - } - - $format = strtolower(JFile::getExt($file['name'])); - - $imageTypes = explode(',', $params->get('image_formats')); - $sourceTypes = explode(',', $params->get('source_formats')); - $fontTypes = explode(',', $params->get('font_formats')); - $archiveTypes = explode(',', $params->get('compressed_formats')); - - $allowable = array_merge($imageTypes, $sourceTypes, $fontTypes, $archiveTypes); - - if ($format == '' || $format == false || (!in_array($format, $allowable))) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILETYPE'), 'error'); - - return false; - } - - if (in_array($format, $archiveTypes)) - { - $zip = new ZipArchive; - - if ($zip->open($file['tmp_name']) === true) - { - for ($i = 0; $i < $zip->numFiles; $i++) - { - $entry = $zip->getNameIndex($i); - $endString = substr($entry, -1); - - if ($endString != DIRECTORY_SEPARATOR) - { - $explodeArray = explode('.', $entry); - $ext = end($explodeArray); - - if (!in_array($ext, $allowable)) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UNSUPPORTED_ARCHIVE'), 'error'); - - return false; - } - } - } - } - else - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'), 'error'); - - return false; - } - } - - // Max upload size set to 2 MB for Template Manager - $maxSize = (int) ($params->get('upload_limit') * 1024 * 1024); - - if ($maxSize > 0 && (int) $file['size'] > $maxSize) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILETOOLARGE'), 'error'); - - return false; - } - - $xss_check = file_get_contents($file['tmp_name'], false, null, -1, 256); - $html_tags = array( - 'abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote', - 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div', - 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', - 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing', - 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option', - 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike', - 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml', - 'xmp', '!DOCTYPE', '!--' - ); - - foreach ($html_tags as $tag) - { - // A tag is '' - if (stristr($xss_check, '<' . $tag . ' ') || stristr($xss_check, '<' . $tag . '>')) - { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNIEXSS'), 'error'); - - return false; - } - } - - return true; - } -} diff --git a/administrator/components/com_templates/models/forms/source.xml b/administrator/components/com_templates/models/forms/source.xml deleted file mode 100644 index d7f987f44a..0000000000 --- a/administrator/components/com_templates/models/forms/source.xml +++ /dev/null @@ -1,25 +0,0 @@ - -
-
- - - - - -
-
diff --git a/administrator/components/com_templates/models/template.php b/administrator/components/com_templates/models/template.php deleted file mode 100644 index a6a5bb1828..0000000000 --- a/administrator/components/com_templates/models/template.php +++ /dev/null @@ -1,1279 +0,0 @@ -getTemplate()) - { - $temp->name = $name; - $temp->id = urlencode(base64_encode($path . $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'); - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - $lang = JFactory::getLanguage(); - - // Load the core and/or local language file(s). - $lang->load('tpl_' . $template->element, $client->path, null, false, true) || - $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, null, false, true); - $this->element = $path; - - if (!is_writable($path)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_DIRECTORY_NOT_WRITABLE'), 'error'); - } - - if (is_dir($path)) - { - $result = $this->getDirectoryTree($path); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND'), 'error'); - - return false; - } - } - - return $result; - } - - /** - * Get the directory tree. - * - * @param string $dir The path of the directory to scan - * - * @return array - * - * @since 3.2 - */ - public function getDirectoryTree($dir) - { - $result = array(); - - $dirFiles = scandir($dir); - - foreach ($dirFiles as $key => $value) - { - if (!in_array($value, array(".", ".."))) - { - if (is_dir($dir . $value)) - { - $relativePath = str_replace($this->element, '', $dir . $value); - $result['/' . $relativePath] = $this->getDirectoryTree($dir . $value . '/'); - } - else - { - $ext = pathinfo($dir . $value, PATHINFO_EXTENSION); - $params = JComponentHelper::getParams('com_templates'); - $imageTypes = explode(',', $params->get('image_formats')); - $sourceTypes = explode(',', $params->get('source_formats')); - $fontTypes = explode(',', $params->get('font_formats')); - $archiveTypes = explode(',', $params->get('compressed_formats')); - - $types = array_merge($imageTypes, $sourceTypes, $fontTypes, $archiveTypes); - - if (in_array($ext, $types)) - { - $relativePath = str_replace($this->element, '', $dir); - $info = $this->getFile('/' . $relativePath, $value); - $result[] = $info; - } - } - } - } - - return $result; - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - */ - protected function populateState() - { - jimport('joomla.filesystem.file'); - $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(); - $app = JFactory::getApplication(); - - // Get the template information. - $query = $db->getQuery(true) - ->select('extension_id, client_id, element, name') - ->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) - { - $app->enqueueMessage($e->getMessage(), 'warning'); - $this->template = false; - - return false; - } - - if (empty($result)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND'), 'error'); - $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() - { - $app = JFactory::getApplication(); - - 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)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'), 'error'); - - return false; - } - } - - // Copy all files from $fromName template to $newName folder - if (!JFolder::copy($fromPath, $toPath) || !$this->fixTemplateName()) - { - return false; - } - - return true; - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'), 'error'); - - 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[] = '#\s*' . $oldName . '\s*#i'; - $replace[] = '' . $newName . ''; - $pattern[] = '##'; - $replace[] = ''; - $contents = preg_replace($pattern, $replace, $contents); - $result = JFile::write($xmlFile, $contents) && $result; - } - - return $result; - } - - /** - * 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() - { - $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() - { - $app = JFactory::getApplication(); - $item = new stdClass; - - if (!$this->template) - { - $this->getTemplate(); - } - - if ($this->template) - { - $input = JFactory::getApplication()->input; - $fileName = base64_decode($input->get('file')); - $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 = $fileName; - $item->source = file_get_contents($filePath); - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND'), 'error'); - } - } - - return $item; - } - - /** - * Method to store the source file contents. - * - * @param array $data The source 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; - } - - $app = JFactory::getApplication(); - $fileName = base64_decode($app->input->get('file')); - $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'); - - $user = get_current_user(); - chown($filePath, $user); - JPath::setPermissions($filePath, '0644'); - - // Try to make the template file writable. - if (!is_writable($filePath)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE'), 'warning'); - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_PERMISSIONS' . JPath::getPermissions($filePath)), 'warning'); - - if (!JPath::isOwner($filePath)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_CHECK_FILE_OWNERSHIP'), 'warning'); - } - - return false; - } - - $return = JFile::write($filePath, $data['source']); - - // Try to make the template file unwritable. - if (JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0444')) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_UNWRITABLE'), 'error'); - - return false; - } - elseif (!$return) - { - $app->enqueueMessage(JText::sprintf('COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME', $fileName), 'error'); - - return false; - } - - $explodeArray = explode('.', $fileName); - $ext = end($explodeArray); - - if ($ext == 'less') - { - $app->enqueueMessage(JText::sprintf('COM_TEMPLATES_COMPILE_LESS', $fileName)); - } - - return true; - } - - /** - * Get overrides folder. - * - * @param string $name The name of override. - * @param string $path Location of override. - * - * @return object containing override name and path. - * - * @since 3.2 - */ - public function getOverridesFolder($name,$path) - { - $folder = new stdClass; - $folder->name = $name; - $folder->path = base64_encode($path . $name); - - return $folder; - } - - /** - * Get a list of overrides. - * - * @return array containing overrides. - * - * @since 3.2 - */ - public function getOverridesList() - { - if ($template = $this->getTemplate()) - { - $client = JApplicationHelper::getClientInfo($template->client_id); - $componentPath = JPath::clean($client->path . '/components/'); - $modulePath = JPath::clean($client->path . '/modules/'); - $layoutPath = JPath::clean(JPATH_ROOT . '/layouts/joomla/'); - $components = JFolder::folders($componentPath); - - foreach ($components as $component) - { - $viewPath = JPath::clean($componentPath . '/' . $component . '/views/'); - - if (file_exists($viewPath)) - { - $views = JFolder::folders($viewPath); - - foreach ($views as $view) - { - $result['components'][$component][] = $this->getOverridesFolder($view, $viewPath); - } - } - } - - $modules = JFolder::folders($modulePath); - - foreach ($modules as $module) - { - $result['modules'][] = $this->getOverridesFolder($module, $modulePath); - } - - $layouts = JFolder::folders($layoutPath); - - foreach ($layouts as $layout) - { - $result['layouts'][] = $this->getOverridesFolder($layout, $layoutPath); - } - } - - if (!empty($result)) - { - return $result; - } - } - - /** - * Create overrides. - * - * @param string $override The override location. - * - * @return boolean true if override creation is successful, false otherwise - * - * @since 3.2 - */ - public function createOverride($override) - { - jimport('joomla.filesystem.folder'); - - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $explodeArray = explode(DIRECTORY_SEPARATOR, $override); - $name = end($explodeArray); - $client = JApplicationHelper::getClientInfo($template->client_id); - - if (stristr($name, 'mod_') != false) - { - $htmlPath = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $name); - } - elseif (stristr($override, 'com_') != false) - { - $folderExplode = explode(DIRECTORY_SEPARATOR, $override); - $size = count($folderExplode); - - $url = JPath::clean($folderExplode[$size - 3] . '/' . $folderExplode[$size - 1]); - - $htmlPath = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $url); - } - else - { - $htmlPath = JPath::clean($client->path . '/templates/' . $template->element . '/html/layouts/joomla/' . $name); - } - - if (JFolder::exists($htmlPath)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_OVERRIDE_EXISTS'), 'error'); - - return false; - } - - if (!JFolder::create($htmlPath)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_ERROR'), 'error'); - - return false; - } - - if (stristr($name, 'mod_') != false) - { - $return = JFolder::copy($override . '/tmpl', $htmlPath, '', true); - } - elseif (stristr($override, 'com_') != false) - { - $return = JFolder::copy($override . '/tmpl', $htmlPath . '/', '', true); - } - else - { - $return = JFolder::copy($override, $htmlPath, '', true); - } - - if ($return) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_OVERRIDE_CREATED') . str_replace(JPATH_ROOT, '', $htmlPath)); - - return true; - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_OVERRIDE_FAILED'), 'error'); - - return false; - } - } - } - - /** - * Compile less using the less compiler under /build. - * - * @param string $input The relative location of the less file. - * - * @return boolean true if compilation is successful, false otherwise - * - * @since 3.2 - * @deprecated - */ - public function compileLess($input) - { - - } - - /** - * Delete a particular file. - * - * @param string $file The relative location of the file. - * - * @return boolean True if file deletion is successful, false otherwise - * - * @since 3.2 - */ - public function deleteFile($file) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - $filePath = $path . urldecode(base64_decode($file)); - - $return = JFile::delete($filePath); - - if (!$return) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_DELETE_FAIL'), 'error'); - - return false; - } - - return true; - } - } - - /** - * Create new file. - * - * @param string $name The name of file. - * @param string $type The extension of the file. - * @param string $location Location for the new file. - * - * @return boolean true if file created successfully, false otherwise - * - * @since 3.2 - */ - public function createFile($name, $type, $location) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - - if (file_exists(JPath::clean($path . '/' . $location . '/' . $name . '.' . $type))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'), 'error'); - - return false; - } - - if (!fopen(JPath::clean($path . '/' . $location . '/' . $name . '.' . $type), 'x')) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_CREATE_ERROR'), 'error'); - - return false; - } - - return true; - } - } - - /** - * Upload new file. - * - * @param string $file The name of the file. - * @param string $location Location for the new file. - * - * @return boolean True if file uploaded successfully, false otherwise - * - * @since 3.2 - */ - public function uploadFile($file, $location) - { - jimport('joomla.filesystem.folder'); - - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - $fileName = JFile::makeSafe($file['name']); - - $err = null; - JLoader::register('TemplateHelper', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/template.php'); - - if (!TemplateHelper::canUpload($file, $err)) - { - // Can't upload the file - return false; - } - - if (file_exists(JPath::clean($path . '/' . $location . '/' . $file['name']))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'), 'error'); - - return false; - } - - if (!JFile::upload($file['tmp_name'], JPath::clean($path . '/' . $location . '/' . $fileName))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UPLOAD_ERROR'), 'error'); - - return false; - } - - $url = JPath::clean($location . '/' . $fileName); - - return $url; - } - } - - /** - * Create new folder. - * - * @param string $name The name of the new folder. - * @param string $location Location for the new folder. - * - * @return boolean True if override folder is created successfully, false otherwise - * - * @since 3.2 - */ - public function createFolder($name, $location) - { - jimport('joomla.filesystem.folder'); - - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - - if (file_exists(JPath::clean($path . '/' . $location . '/' . $name . '/'))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_EXISTS'), 'error'); - - return false; - } - - if (!JFolder::create(JPath::clean($path . '/' . $location . '/' . $name))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_CREATE_ERROR'), 'error'); - - return false; - } - - return true; - } - } - - /** - * Delete a folder. - * - * @param string $location The name and location of the folder. - * - * @return boolean True if override folder is deleted successfully, false otherwise - * - * @since 3.2 - */ - public function deleteFolder($location) - { - jimport('joomla.filesystem.folder'); - - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $location); - - if (!file_exists($path)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_NOT_EXISTS'), 'error'); - - return false; - } - - $return = JFolder::delete($path); - - if (!$return) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_DELETE_ERROR'), 'error'); - - return false; - } - - return true; - } - } - - /** - * Rename a file. - * - * @param string $file The name and location of the old file - * @param string $name The new name of the file. - * - * @return string Encoded string containing the new file location. - * - * @since 3.2 - */ - public function renameFile($file, $name) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - $fileName = base64_decode($file); - $explodeArray = explode('.', $fileName); - $type = end($explodeArray); - $explodeArray = explode('/', $fileName); - $newName = str_replace(end($explodeArray), $name . '.' . $type, $fileName); - - if (file_exists($path . $newName)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'), 'error'); - - return false; - } - - if (!rename($path . $fileName, $path . $newName)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_RENAME_ERROR'), 'error'); - - return false; - } - - return base64_encode($newName); - } - } - - /** - * Get an image address, height and width. - * - * @return array an associative array containing image address, height and width. - * - * @since 3.2 - */ - public function getImage() - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $fileName = base64_decode($app->input->get('file')); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - - if (stristr($client->path, 'administrator') == false) - { - $folder = '/templates/'; - } - else - { - $folder = '/administrator/templates/'; - } - - $uri = JUri::root(true) . $folder . $template->element; - - if (file_exists(JPath::clean($path . $fileName))) - { - $JImage = new JImage(JPath::clean($path . $fileName)); - $image['address'] = $uri . $fileName; - $image['path'] = $fileName; - $image['height'] = $JImage->getHeight(); - $image['width'] = $JImage->getWidth(); - } - - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_IMAGE_FILE_NOT_FOUND'), 'error'); - - return false; - } - - return $image; - } - } - - /** - * Crop an image. - * - * @param string $file The name and location of the file - * @param string $w width. - * @param string $h height. - * @param string $x x-coordinate. - * @param string $y y-coordinate. - * - * @return boolean true if image cropped successfully, false otherwise. - * - * @since 3.2 - */ - public function cropImage($file, $w, $h, $x, $y) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($file); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $relPath); - $JImage = new JImage($path); - - try - { - $image = $JImage->crop($w, $h, $x, $y, true); - $image->toFile($path); - - return true; - } - catch (Exception $e) - { - $app->enqueueMessage($e->getMessage(), 'error'); - } - } - } - - /** - * Resize an image. - * - * @param string $file The name and location of the file - * @param string $width The new width of the image. - * @param string $height The new height of the image. - * - * @return boolean true if image resize successful, false otherwise. - * - * @since 3.2 - */ - public function resizeImage($file, $width, $height) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($file); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $relPath); - - $JImage = new JImage($path); - - try - { - $image = $JImage->resize($width, $height, true, 1); - $image->toFile($path); - - return true; - } - catch (Exception $e) - { - $app->enqueueMessage($e->getMessage(), 'error'); - } - } - } - - /** - * Template preview. - * - * @return object object containing the id of the template. - * - * @since 3.2 - */ - public function getPreview() - { - $app = JFactory::getApplication(); - $db = $this->getDbo(); - $query = $db->getQuery(true); - - $query->select('id, client_id'); - $query->from('#__template_styles'); - $query->where($db->quoteName('template') . ' = ' . $db->quote($this->template->name)); - - $db->setQuery($query); - - try - { - $result = $db->loadObject(); - } - catch (RuntimeException $e) - { - $app->enqueueMessage($e->getMessage(), 'warning'); - } - - if (empty($result)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND'), 'warning'); - } - else - { - return $result; - } - } - - /** - * Rename a file. - * - * @return mixed array on success, false on failure - * - * @since 3.2 - */ - public function getFont() - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($app->input->get('file')); - $explodeArray = explode('/', $relPath); - $fileName = end($explodeArray); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $relPath); - - if (stristr($client->path, 'administrator') == false) - { - $folder = '/templates/'; - } - else - { - $folder = '/administrator/templates/'; - } - - $uri = JUri::root(true) . $folder . $template->element; - - if (file_exists(JPath::clean($path))) - { - $font['address'] = $uri . $relPath; - - $font['rel_path'] = $relPath; - - $font['name'] = $fileName; - } - - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FONT_FILE_NOT_FOUND'), 'error'); - - return false; - } - - return $font; - } - } - - /** - * Copy a file. - * - * @param string $newName The name of the copied file - * @param string $location The final location where the file is to be copied - * @param string $file The name and location of the file - * - * @return boolean true if image resize successful, false otherwise. - * - * @since 3.2 - */ - public function copyFile($newName, $location, $file) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($file); - $explodeArray = explode('.', $relPath); - $ext = end($explodeArray); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/'); - $newPath = JPath::clean($path . '/' . $location . '/' . $newName . '.' . $ext); - - if (file_exists($newPath)) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'), 'error'); - - return false; - } - - if (JFile::copy($path . $relPath, $newPath)) - { - $app->enqueueMessage(JText::sprintf('COM_TEMPLATES_FILE_COPY_SUCCESS', $newName . '.' . $ext)); - - return true; - } - else - { - return false; - } - } - } - - /** - * Get the compressed files. - * - * @return array if file exists, false otherwise - * - * @since 3.2 - */ - public function getArchive() - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($app->input->get('file')); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $relPath); - - if (file_exists(JPath::clean($path))) - { - $files = array(); - $zip = new ZipArchive; - - if ($zip->open($path) === true) - { - for ($i = 0; $i < $zip->numFiles; $i++) - { - $entry = $zip->getNameIndex($i); - $files[] = $entry; - } - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'), 'error'); - - return false; - } - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FONT_FILE_NOT_FOUND'), 'error'); - - return false; - } - - return $files; - } - } - - /** - * Extract contents of a archive file. - * - * @param string $file The name and location of the file - * - * @return boolean true if image extraction is successful, false otherwise. - * - * @since 3.2 - */ - public function extractArchive($file) - { - if ($template = $this->getTemplate()) - { - $app = JFactory::getApplication(); - $client = JApplicationHelper::getClientInfo($template->client_id); - $relPath = base64_decode($file); - $explodeArray = explode('/', $relPath); - $fileName = end($explodeArray); - $folderPath = stristr($relPath, $fileName, true); - $path = JPath::clean($client->path . '/templates/' . $template->element . '/' . $folderPath . '/'); - - if (file_exists(JPath::clean($path . '/' . $fileName))) - { - $zip = new ZipArchive; - - if ($zip->open(JPath::clean($path . '/' . $fileName)) === true) - { - for ($i = 0; $i < $zip->numFiles; $i++) - { - $entry = $zip->getNameIndex($i); - - if (file_exists(JPath::clean($path . '/' . $entry))) - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_EXISTS'), 'error'); - - return false; - } - } - - $zip->extractTo($path); - - return true; - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'), 'error'); - - return false; - } - } - else - { - $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_NOT_FOUND'), 'error'); - - return false; - } - } - } -} diff --git a/administrator/components/com_templates/views/template/tmpl/default.php b/administrator/components/com_templates/views/template/tmpl/default.php deleted file mode 100644 index d34861f4e7..0000000000 --- a/administrator/components/com_templates/views/template/tmpl/default.php +++ /dev/null @@ -1,539 +0,0 @@ -input; - -if ($this->type == 'image') -{ - JHtml::_('script', 'system/jquery.Jcrop.min.js', false, true); - JHtml::_('stylesheet', 'system/jquery.Jcrop.min.css', array(), true); -} -?> - - - 'editor')); ?> - -
-
- type == 'file'): ?> -

source->filename, $this->template->element); ?>

- - type == 'image'): ?> -

image['path'], $this->template->element); ?>

- - type == 'font'): ?> -

font['rel_path'], $this->template->element); ?>

- -
-
-
-
- loadTemplate('tree');?> -
-
- type == 'home'): ?> -
- - -
-

-

-

- - - -

-
-
- - type == 'file'): ?> -
- -

-
-
- form->getInput('source'); ?> -
- - - form->getInput('extension_id'); ?> - form->getInput('filename'); ?> - -
- - type == 'archive'): ?> - -
- - - - -
- - type == 'image'): ?> - -
-
- - - - - - -
-
- - type == 'font'): ?> -
-
-
-

H1

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML

-

H2

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML

-

H3

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML

-

H4

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML

-

H5

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML
-

H6

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML
-

Bold

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML -

Italics

Quickly gaze at Joomla! views from HTML, CSS, JavaScript and XML -

Unordered List

-
    -
  • Item
  • -
  • Item
  • -
  • Item
    -
      -
    • Item
    • -
    • Item
    • -
    • Item
      -
        -
      • Item
      • -
      • Item
      • -
      • Item
      • -
      -
    • -
    -
  • -
-

Ordered List

-
    -
  1. Item
  2. -
  3. Item
  4. -
  5. Item
    -
      -
    • Item
    • -
    • Item
    • -
    • Item
      -
        -
      • Item
      • -
      • Item
      • -
      • Item
      • -
      -
    • -
    -
  6. -
- - -
-
-
- -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - - - loadTemplate('description');?> - - - -
- - -
-type != 'home'): ?> -
- - -
- -type != 'home'): ?> - - - - - -type != 'home'): ?> -
- - -
- diff --git a/administrator/components/com_templates/views/template/tmpl/default_description.php b/administrator/components/com_templates/views/template/tmpl/default_description.php deleted file mode 100644 index cc0b8feb49..0000000000 --- a/administrator/components/com_templates/views/template/tmpl/default_description.php +++ /dev/null @@ -1,19 +0,0 @@ - - -
- template->element, $this->template->client_id); ?> -
-

template->element); ?>

-template->client_id); ?> -

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

-

template->xmldata->description); ?>

\ No newline at end of file diff --git a/administrator/components/com_templates/views/template/tmpl/default_folders.php b/administrator/components/com_templates/views/template/tmpl/default_folders.php deleted file mode 100644 index 1a1470aea7..0000000000 --- a/administrator/components/com_templates/views/template/tmpl/default_folders.php +++ /dev/null @@ -1,25 +0,0 @@ -files, SORT_STRING); -?> - - diff --git a/administrator/components/com_templates/views/template/tmpl/default_tree.php b/administrator/components/com_templates/views/template/tmpl/default_tree.php deleted file mode 100644 index 0f884983be..0000000000 --- a/administrator/components/com_templates/views/template/tmpl/default_tree.php +++ /dev/null @@ -1,62 +0,0 @@ -files, SORT_STRING); -?> - - diff --git a/administrator/components/com_templates/views/template/view.html.php b/administrator/components/com_templates/views/template/view.html.php deleted file mode 100644 index 4276d5f614..0000000000 --- a/administrator/components/com_templates/views/template/view.html.php +++ /dev/null @@ -1,301 +0,0 @@ -file = $app->input->get('file'); - $this->fileName = base64_decode($this->file); - $explodeArray = explode('.', $this->fileName); - $ext = end($explodeArray); - $this->files = $this->get('Files'); - $this->state = $this->get('State'); - $this->template = $this->get('Template'); - $this->preview = $this->get('Preview'); - - $params = JComponentHelper::getParams('com_templates'); - $imageTypes = explode(',', $params->get('image_formats')); - $sourceTypes = explode(',', $params->get('source_formats')); - $fontTypes = explode(',', $params->get('font_formats')); - $archiveTypes = explode(',', $params->get('compressed_formats')); - - if (in_array($ext, $sourceTypes)) - { - $this->form = $this->get('Form'); - $this->form->setFieldAttribute('source', 'syntax', $ext); - $this->source = $this->get('Source'); - $this->type = 'file'; - } - elseif (in_array($ext, $imageTypes)) - { - $this->image = $this->get('Image'); - $this->type = 'image'; - } - elseif (in_array($ext, $fontTypes)) - { - $this->font = $this->get('Font'); - $this->type = 'font'; - } - elseif (in_array($ext, $archiveTypes)) - { - $this->archive = $this->get('Archive'); - $this->type = 'archive'; - } - else - { - $this->type = 'home'; - } - - $this->overridesList = $this->get('OverridesList'); - $this->id = $this->state->get('extension.id'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - $app->enqueueMessage(implode("\n", $errors)); - - return false; - } - - $this->addToolbar(); - - return parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @since 1.6 - * - * @return void - */ - protected function addToolbar() - { - $app = JFactory::getApplication(); - $app->input->set('hidemainmenu', true); - $canDo = JHelperContent::getActions('com_templates'); - - if ($canDo->get('core.edit') && $canDo->get('core.create') && $canDo->get('core.admin')) - { - $showButton = true; - } - else - { - $showButton = false; - } - - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - $explodeArray = explode('.', $this->fileName); - $ext = end($explodeArray); - - JToolbarHelper::title(JText::_('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE'), 'eye thememanager'); - - // Add a Apply and save button - if ($this->type == 'file') - { - if ($showButton) - { - JToolbarHelper::apply('template.apply'); - JToolbarHelper::save('template.save'); - } - } - // Add a Crop and Resize button - elseif ($this->type == 'image') - { - if ($showButton) - { - JToolbarHelper::custom('template.cropImage', 'move', 'move', 'COM_TEMPLATES_BUTTON_CROP', false, false); - - JToolbarHelper::modal('resizeModal', 'icon-refresh', 'COM_TEMPLATES_BUTTON_RESIZE'); - } - } - // Add an extract button - elseif ($this->type == 'archive') - { - if ($showButton) - { - JToolbarHelper::custom('template.extractArchive', 'arrow-down', 'arrow-down', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', false, false); - } - } - - // Add a Template preview button - if ($this->preview->client_id == 0) - { - $bar->appendButton('Link', 'picture', 'COM_TEMPLATES_BUTTON_PREVIEW', JUri::root() . 'index.php?tp=1&templateStyle=' . $this->preview->id); - } - - // Add Manage folders button - if ($showButton) - { - JToolbarHelper::modal('folderModal', 'icon-folder icon white', 'COM_TEMPLATES_BUTTON_FOLDERS'); - } - - // Add a new file button - if ($showButton) - { - JToolbarHelper::modal('fileModal', 'icon-file', 'COM_TEMPLATES_BUTTON_FILE'); - } - - // Add a Delete file Button - if ($showButton && $this->type != 'home') - { - JToolbarHelper::modal('deleteModal', 'icon-remove', 'COM_TEMPLATES_BUTTON_DELETE_FILE'); - } - - // Add a Compile Button - if ($showButton) - { - if ($ext == 'less') - { - JToolbarHelper::custom('template.less', 'play', 'play', 'COM_TEMPLATES_BUTTON_LESS', false, false); - } - } - - if ($this->type == 'home') - { - JToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); - } - else - { - JToolbarHelper::cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE'); - } - - JToolbarHelper::divider(); - JToolbarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT'); - } - - /** - * Method for creating the collapsible tree. - * - * @param array $array The value of the present node for recursion - * - * @return string - * - * @note Uses recursion - * @since 3.2 - */ - protected function directoryTree($array) - { - $temp = $this->files; - $this->files = $array; - $txt = $this->loadTemplate('tree'); - $this->files = $temp; - - return $txt; - } - - /** - * Method for listing the folder tree in modals. - * - * @param array $array The value of the present node for recursion - * - * @return string - * - * @note Uses recursion - * @since 3.2 - */ - protected function folderTree($array) - { - $temp = $this->files; - $this->files = $array; - $txt = $this->loadTemplate('folders'); - $this->files = $temp; - - return $txt; - } -} diff --git a/administrator/components/com_templates/views/templates/tmpl/default.php b/administrator/components/com_templates/views/templates/tmpl/default.php index 09b14a6cfe..1785611fb7 100644 --- a/administrator/components/com_templates/views/templates/tmpl/default.php +++ b/administrator/components/com_templates/views/templates/tmpl/default.php @@ -75,8 +75,7 @@ element, $item->client_id); ?> - - name)); ?> + name)); ?>

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