These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | * Languages View class for the Localise component |
||
14 | * |
||
15 | * @package Extensions.Components |
||
16 | * @subpackage Localise |
||
17 | * |
||
18 | * @since 1.0 |
||
19 | */ |
||
20 | class LocaliseViewLanguages extends JViewLegacy |
||
21 | { |
||
22 | protected $items; |
||
23 | |||
24 | protected $pagination; |
||
25 | |||
26 | protected $state; |
||
27 | |||
28 | protected $form; |
||
29 | |||
30 | protected $minCmsVersion = '3.8'; |
||
31 | |||
32 | /** |
||
33 | * Display the view |
||
34 | * |
||
35 | * @param string $tpl The name of the template file to parse; automatically searches through the template paths. |
||
36 | * |
||
37 | * @return void |
||
38 | */ |
||
39 | public function display($tpl = null) |
||
40 | { |
||
41 | // Get the data |
||
42 | $this->items = $this->get('Items'); |
||
43 | $this->pagination = $this->get('Pagination'); |
||
44 | $this->state = $this->get('State'); |
||
45 | $this->form = $this->get('Form'); |
||
46 | |||
47 | View Code Duplication | if (version_compare(JVERSION, $this->minCmsVersion, 'lt')) |
|
0 ignored issues
–
show
|
|||
48 | { |
||
49 | JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_LOCALISE_ERROR_INSTALL_JVERSION', $this->minCmsVersion), 'warning'); |
||
50 | |||
51 | return false; |
||
52 | } |
||
53 | |||
54 | LocaliseHelper::addSubmenu('languages'); |
||
55 | |||
56 | // Check for errors. |
||
57 | if (count($errors = $this->get('Errors'))) |
||
58 | { |
||
59 | JError::raiseError(500, implode("\n", $errors)); |
||
60 | |||
61 | return false; |
||
62 | } |
||
63 | |||
64 | // Set the toolbar |
||
65 | $this->addToolbar(); |
||
66 | $this->sidebar = JHtmlSidebar::render(); |
||
67 | |||
68 | // Display the view |
||
69 | parent::display($tpl); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Add the page title and toolbar. |
||
74 | * |
||
75 | * @return void |
||
76 | * |
||
77 | * @since 1.6 |
||
78 | */ |
||
79 | protected function addToolbar() |
||
80 | { |
||
81 | $canDo = JHelperContent::getActions('com_localise', 'component'); |
||
82 | |||
83 | JToolbarHelper::title(JText::sprintf('COM_LOCALISE_HEADER_MANAGER', JText::_('COM_LOCALISE_HEADER_LANGUAGES')), 'comments-2 langmanager'); |
||
84 | |||
85 | if ($canDo->get('localise.create')) |
||
86 | { |
||
87 | JToolbarHelper::addNew('language.add'); |
||
88 | JToolbarHelper::custom('languages.purge', 'purge', 'purge', 'COM_LOCALISE_PURGE', false, false); |
||
89 | JToolbarHelper::divider(); |
||
90 | } |
||
91 | |||
92 | if ($canDo->get('core.admin')) |
||
93 | { |
||
94 | JToolbarHelper::preferences('com_localise'); |
||
95 | JToolbarHelper::divider(); |
||
96 | } |
||
97 | |||
98 | JToolBarHelper::help('screen.languages', true); |
||
99 | |||
100 | JHtmlSidebar::setAction('index.php?option=com_localise&view=languages'); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Returns an array of fields the table can be sorted by |
||
105 | * |
||
106 | * @return array Array containing the field name to sort by as the key and display text as value |
||
107 | * |
||
108 | * @since 3.0 |
||
109 | */ |
||
110 | protected function getSortFields() |
||
111 | { |
||
112 | return array( |
||
113 | 'name' => JText::_('COM_LOCALISE_HEADING_LANGUAGES_NAME'), |
||
114 | 'tag' => JText::_('COM_LOCALISE_HEADING_LANGUAGES_TAG'), |
||
115 | 'client' => JText::_('COM_LOCALISE_HEADING_LANGUAGES_CLIENT'), |
||
116 | ); |
||
117 | } |
||
118 | } |
||
119 |
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.