/iCagenda/admin/views/category/view.html.php

https://gitlab.com/Alzakath/icagenda · PHP · 115 lines · 69 code · 15 blank · 31 comment · 20 complexity · 77962799748091737b39839b2dc18515 MD5 · raw file

  1. <?php
  2. /**
  3. *------------------------------------------------------------------------------
  4. * iCagenda v3 by Jooml!C - Events Management Extension for Joomla! 2.5 / 3.x
  5. *------------------------------------------------------------------------------
  6. * @package com_icagenda
  7. * @copyright Copyright (c)2012-2015 Cyril Rezé, Jooml!C - All rights reserved
  8. *
  9. * @license GNU General Public License version 3 or later; see LICENSE.txt
  10. * @author Cyril Rezé (Lyr!C)
  11. * @link http://www.joomlic.com
  12. *
  13. * @version 3.2.5 2013-11-09
  14. * @since 1.0
  15. *------------------------------------------------------------------------------
  16. */
  17. // No direct access to this file
  18. defined('_JEXEC') or die();
  19. // iCagenda Class control (Joomla 2.5/3.x)
  20. if(!class_exists('iCJView')) {
  21. if(version_compare(JVERSION,'3.0.0','ge')) {
  22. class iCJView extends JViewLegacy {
  23. };
  24. } else {
  25. jimport('joomla.application.component.view');
  26. class iCJView extends JView {};
  27. }
  28. }
  29. /**
  30. * View class Admin - Edit a Category - iCagenda
  31. */
  32. class iCagendaViewCategory extends iCJView
  33. {
  34. protected $state;
  35. protected $item;
  36. protected $form;
  37. /**
  38. * Display the view
  39. */
  40. public function display($tpl = null)
  41. {
  42. $this->state = $this->get('State');
  43. $this->item = $this->get('Item');
  44. $this->form = $this->get('Form');
  45. // Check for errors.
  46. if (count($errors = $this->get('Errors'))) {
  47. JError::raiseError(500, implode("\n", $errors));
  48. return false;
  49. }
  50. $this->addToolbar();
  51. parent::display($tpl);
  52. }
  53. /**
  54. * Add the page title and toolbar.
  55. */
  56. protected function addToolbar()
  57. {
  58. JRequest::setVar('hidemainmenu', true);
  59. $user = JFactory::getUser();
  60. $isNew = ($this->item->id == 0);
  61. if (isset($this->item->checked_out)) {
  62. $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
  63. } else {
  64. $checkedOut = false;
  65. }
  66. $canDo = iCagendaHelper::getActions();
  67. //JToolBarHelper::title(JText::_('COM_ICAGENDA_TITLE_CATEGORY'), 'category.png');
  68. // Set Title
  69. if(version_compare(JVERSION, '3.0', 'lt')) {
  70. JToolBarHelper::title($isNew ? 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_NEW_CATEGORY') : 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_CATEGORY'), 'category.png');
  71. } else {
  72. JToolBarHelper::title($isNew ? 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_NEW_CATEGORY') . '</span>' : 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_CATEGORY') . '</span>' , $isNew ? 'new' : 'pencil-2');
  73. }
  74. $icTitle = $isNew ? JText::_('COM_ICAGENDA_LEGEND_NEW_CATEGORY') : JText::_('COM_ICAGENDA_LEGEND_EDIT_CATEGORY');
  75. $document = JFactory::getDocument();
  76. $app = JFactory::getApplication();
  77. $sitename = $app->getCfg('sitename');
  78. $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
  79. $document->setTitle($title);
  80. // If not checked out, can save the item.
  81. if (!$checkedOut && ($canDo->get('core.edit')||($canDo->get('core.create'))))
  82. {
  83. JToolBarHelper::apply('category.apply', 'JTOOLBAR_APPLY');
  84. JToolBarHelper::save('category.save', 'JTOOLBAR_SAVE');
  85. }
  86. if (!$checkedOut && ($canDo->get('core.create'))){
  87. JToolBarHelper::custom('category.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
  88. }
  89. // If an existing item, can save to a copy.
  90. if (!$isNew && $canDo->get('core.create')) {
  91. JToolBarHelper::custom('category.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
  92. }
  93. if (empty($this->item->id)) {
  94. JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CANCEL');
  95. }
  96. else {
  97. JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE');
  98. }
  99. }
  100. }