/administrator/components/com_templates/views/style/view.html.php

https://bitbucket.org/eternaware/joomus · PHP · 96 lines · 55 code · 15 blank · 26 comment · 9 complexity · b9d665325a1f169a2e63afecae10d2b7 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage com_templates
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * View to edit a template style.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_templates
  15. * @since 1.6
  16. */
  17. class TemplatesViewStyle extends JViewLegacy
  18. {
  19. protected $item;
  20. protected $form;
  21. protected $state;
  22. /**
  23. * Display the view
  24. */
  25. public function display($tpl = null)
  26. {
  27. $this->item = $this->get('Item');
  28. $this->state = $this->get('State');
  29. $this->form = $this->get('Form');
  30. // Check for errors.
  31. if (count($errors = $this->get('Errors'))) {
  32. JError::raiseError(500, implode("\n", $errors));
  33. return false;
  34. }
  35. $this->addToolbar();
  36. parent::display($tpl);
  37. }
  38. /**
  39. * Add the page title and toolbar.
  40. *
  41. * @since 1.6
  42. */
  43. protected function addToolbar()
  44. {
  45. JFactory::getApplication()->input->set('hidemainmenu', true);
  46. $user = JFactory::getUser();
  47. $isNew = ($this->item->id == 0);
  48. $canDo = TemplatesHelper::getActions();
  49. JToolbarHelper::title(
  50. $isNew ? JText::_('COM_TEMPLATES_MANAGER_ADD_STYLE')
  51. : JText::_('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'thememanager'
  52. );
  53. // If not checked out, can save the item.
  54. if ($canDo->get('core.edit')) {
  55. JToolbarHelper::apply('style.apply');
  56. JToolbarHelper::save('style.save');
  57. }
  58. // If an existing item, can save to a copy.
  59. if (!$isNew && $canDo->get('core.create')) {
  60. JToolbarHelper::save2copy('style.save2copy');
  61. }
  62. if (empty($this->item->id)) {
  63. JToolbarHelper::cancel('style.cancel');
  64. } else {
  65. JToolbarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE');
  66. }
  67. JToolbarHelper::divider();
  68. // Get the help information for the template item.
  69. $lang = JFactory::getLanguage();
  70. $help = $this->get('Help');
  71. if ($lang->hasKey($help->url)) {
  72. $debug = $lang->setDebug(false);
  73. $url = JText::_($help->url);
  74. $lang->setDebug($debug);
  75. }
  76. else {
  77. $url = null;
  78. }
  79. JToolbarHelper::help($help->key, false, $url);
  80. }
  81. }