PageRenderTime 22ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1
 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
10defined('_JEXEC') or die;
11
12/**
13 * View to edit a template style.
14 *
15 * @package     Joomla.Administrator
16 * @subpackage  com_templates
17 * @since       1.6
18 */
19class TemplatesViewStyle extends JViewLegacy
20{
21	protected $item;
22
23	protected $form;
24
25	protected $state;
26
27	/**
28	 * Display the view
29	 */
30	public function display($tpl = null)
31	{
32		$this->item		= $this->get('Item');
33		$this->state	= $this->get('State');
34		$this->form		= $this->get('Form');
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		$canDo = TemplatesHelper::getActions();
58
59		JToolbarHelper::title(
60			$isNew ? JText::_('COM_TEMPLATES_MANAGER_ADD_STYLE')
61			: JText::_('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'thememanager'
62		);
63
64		// If not checked out, can save the item.
65		if ($canDo->get('core.edit')) {
66			JToolbarHelper::apply('style.apply');
67			JToolbarHelper::save('style.save');
68		}
69
70		// If an existing item, can save to a copy.
71		if (!$isNew && $canDo->get('core.create')) {
72			JToolbarHelper::save2copy('style.save2copy');
73		}
74
75		if (empty($this->item->id))  {
76			JToolbarHelper::cancel('style.cancel');
77		} else {
78			JToolbarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE');
79		}
80		JToolbarHelper::divider();
81		// Get the help information for the template item.
82
83		$lang = JFactory::getLanguage();
84
85		$help = $this->get('Help');
86		if ($lang->hasKey($help->url)) {
87			$debug = $lang->setDebug(false);
88			$url = JText::_($help->url);
89			$lang->setDebug($debug);
90		}
91		else {
92			$url = null;
93		}
94		JToolbarHelper::help($help->key, false, $url);
95	}
96}