PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_modules/views/module/view.html.php

https://bitbucket.org/eternaware/joomus
PHP | 95 lines | 56 code | 13 blank | 26 comment | 16 complexity | e7711c1efa76ad458fdfc749f0bc79e7 MD5 | raw file
Possible License(s): LGPL-2.1
 1<?php
 2/**
 3 * @package     Joomla.Administrator
 4 * @subpackage  com_modules
 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
10defined('_JEXEC') or die;
11
12/**
13 * View to edit a module.
14 *
15 * @package     Joomla.Administrator
16 * @subpackage  com_modules
17 * @since       1.6
18 */
19class ModulesViewModule extends JViewLegacy
20{
21	protected $form;
22
23	protected $item;
24
25	protected $state;
26
27	/**
28	 * Display the view
29	 */
30	public function display($tpl = null)
31	{
32		$this->form		= $this->get('Form');
33		$this->item		= $this->get('Item');
34		$this->state	= $this->get('State');
35
36		// Check for errors.
37		if (count($errors = $this->get('Errors'))) {
38			JError::raiseError(500, implode("\n", $errors));
39			return false;
40		}
41
42		$this->addToolbar();
43		parent::display($tpl);
44	}
45
46	/**
47	 * Add the page title and toolbar.
48	 *
49	 * @since	1.6
50	 */
51	protected function addToolbar()
52	{
53		JFactory::getApplication()->input->set('hidemainmenu', true);
54
55		$user		= JFactory::getUser();
56		$isNew		= ($this->item->id == 0);
57		$checkedOut	= !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
58		$canDo		= ModulesHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
59		$item		= $this->get('Item');
60
61		JToolbarHelper::title(JText::sprintf('COM_MODULES_MANAGER_MODULE', JText::_($this->item->module)), 'module.png');
62
63		// If not checked out, can save the item.
64		if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create') )) {
65			JToolbarHelper::apply('module.apply');
66			JToolbarHelper::save('module.save');
67		}
68		if (!$checkedOut && $canDo->get('core.create')) {
69			JToolbarHelper::save2new('module.save2new');
70		}
71			// If an existing item, can save to a copy.
72		if (!$isNew && $canDo->get('core.create')) {
73			JToolbarHelper::save2copy('module.save2copy');
74		}
75		if (empty($this->item->id))  {
76			JToolbarHelper::cancel('module.cancel');
77		} else {
78			JToolbarHelper::cancel('module.cancel', 'JTOOLBAR_CLOSE');
79		}
80
81		// Get the help information for the menu item.
82		$lang = JFactory::getLanguage();
83
84		$help = $this->get('Help');
85		if ($lang->hasKey($help->url)) {
86			$debug = $lang->setDebug(false);
87			$url = JText::_($help->url);
88			$lang->setDebug($debug);
89		}
90		else {
91			$url = null;
92		}
93		JToolbarHelper::help($help->key, false, $url);
94	}
95}