PageRenderTime 27ms CodeModel.GetById 23ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_weblinks/views/weblink/view.html.php

https://bitbucket.org/eternaware/joomus
PHP | 87 lines | 49 code | 12 blank | 26 comment | 13 complexity | a6d16786d350f05297001940a54a1c9e MD5 | raw file
Possible License(s): LGPL-2.1
 1<?php
 2/**
 3 * @package     Joomla.Administrator
 4 * @subpackage  com_weblinks
 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 weblink.
14 *
15 * @package     Joomla.Administrator
16 * @subpackage  com_weblinks
17 * @since       1.5
18 */
19class WeblinksViewWeblink extends JViewLegacy
20{
21	protected $state;
22
23	protected $item;
24
25	protected $form;
26
27	/**
28	 * Display the view
29	 */
30	public function display($tpl = null)
31	{
32		$this->state	= $this->get('State');
33		$this->item		= $this->get('Item');
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		$userId		= $user->get('id');
57		$isNew		= ($this->item->id == 0);
58		$checkedOut	= !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
59		// Since we don't track these assets at the item level, use the category id.
60		$canDo		= WeblinksHelper::getActions($this->item->catid, 0);
61
62		JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINK'), 'weblinks.png');
63
64		// If not checked out, can save the item.
65		if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create')))))
66		{
67			JToolbarHelper::apply('weblink.apply');
68			JToolbarHelper::save('weblink.save');
69		}
70		if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')))){
71			JToolbarHelper::save2new('weblink.save2new');
72		}
73		// If an existing item, can save to a copy.
74		if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)) {
75			JToolbarHelper::save2copy('weblink.save2copy');
76		}
77		if (empty($this->item->id)) {
78			JToolbarHelper::cancel('weblink.cancel');
79		}
80		else {
81			JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
82		}
83
84		JToolbarHelper::divider();
85		JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT');
86	}
87}