1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package Com_Localise |
4
|
|
|
* @subpackage views |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. |
7
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
defined('_JEXEC') or die; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* View to edit a language. |
14
|
|
|
* |
15
|
|
|
* @package Extensions.Components |
16
|
|
|
* @subpackage Localise |
17
|
|
|
* |
18
|
|
|
* @since 1.0 |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
class LocaliseViewLanguage extends JViewLegacy |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
protected $state; |
23
|
|
|
|
24
|
|
|
protected $item; |
25
|
|
|
|
26
|
|
|
protected $form; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Display the view |
30
|
|
|
* |
31
|
|
|
* @param string $tpl The name of the template file to parse; automatically searches through the template paths. |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function display($tpl = null) |
36
|
|
|
{ |
37
|
|
|
jimport('joomla.client.helper'); |
38
|
|
|
|
39
|
|
|
// Get the data |
40
|
|
|
$this->state = $this->get('State'); |
41
|
|
|
$this->item = $this->get('Item'); |
42
|
|
|
$this->form = $this->get('Form'); |
43
|
|
|
$this->formftp = $this->get('FormFtp'); |
44
|
|
|
$this->ftp = JClientHelper::setCredentialsFromRequest('ftp'); |
45
|
|
|
|
46
|
|
|
// Check for errors. |
47
|
|
|
if (count($errors = $this->get('Errors'))) |
48
|
|
|
{ |
49
|
|
|
JError::raiseError(500, implode("\n", $errors)); |
50
|
|
|
|
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// Set the toolbar |
55
|
|
|
$this->addToolbar(); |
56
|
|
|
|
57
|
|
|
// Display the view |
58
|
|
|
parent::display($tpl); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Add the page title and toolbar. |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
* |
66
|
|
|
* @since 1.6 |
67
|
|
|
*/ |
68
|
|
|
protected function addToolbar() |
69
|
|
|
{ |
70
|
|
|
JFactory::getApplication()->input->set('hidemainmenu', true); |
71
|
|
|
$canDo = JHelperContent::getActions('com_localise', 'component'); |
72
|
|
|
|
73
|
|
|
$user = JFactory::getUser(); |
74
|
|
|
$isNew = empty($this->item->id); |
75
|
|
|
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); |
76
|
|
|
|
77
|
|
|
JToolbarHelper::title( |
78
|
|
|
JText::sprintf( |
79
|
|
|
'COM_LOCALISE_HEADER_MANAGER', |
80
|
|
|
$isNew ? JText::_('COM_LOCALISE_HEADER_LANGUAGE_NEW') : JText::_('COM_LOCALISE_HEADER_LANGUAGE_EDIT') |
81
|
|
|
), |
82
|
|
|
'icon-comments-2 langmanager' |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
// If not checked out, can save the item. |
86
|
|
|
if (!$checkedOut) |
87
|
|
|
{ |
88
|
|
|
JToolbarHelper::apply('language.apply'); |
89
|
|
|
JToolbarHelper::save('language.save'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
JToolBarHelper::cancel('language.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE'); |
93
|
|
|
JToolBarHelper::divider(); |
94
|
|
|
|
95
|
|
|
if ($canDo->get('localise.create') && !$isNew) |
96
|
|
|
{ |
97
|
|
|
JToolbarHelper::custom('language.copy', 'copy.png', 'copy.png', 'COM_LOCALISE_COPY_REF_TO_NEW_LANG', false); |
98
|
|
|
JToolBarHelper::divider(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
JToolBarHelper::help('screen.language', true); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.