1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package Com_Localise |
4
|
|
|
* @subpackage Controller |
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
|
|
|
* Controller class for the localise component |
14
|
|
|
* |
15
|
|
|
* @package Extensions.Components |
16
|
|
|
* @subpackage Localise |
17
|
|
|
* @since 1.0 |
18
|
|
|
*/ |
19
|
|
|
class LocaliseController extends JControllerLegacy |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Method to display a view. |
23
|
|
|
* |
24
|
|
|
* @param boolean $cachable If true, the view output will be cached |
25
|
|
|
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. |
26
|
|
|
* |
27
|
|
|
* @return JController This object to support chaining. |
28
|
|
|
* |
29
|
|
|
* @since 1.5 |
30
|
|
|
*/ |
31
|
|
|
public function display($cachable = false, $urlparams = false) |
32
|
|
|
{ |
33
|
|
|
require_once JPATH_COMPONENT . '/helpers/localise.php'; |
34
|
|
|
$app = JFactory::getApplication('administrator'); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$vName = $this->input->get('view', 'languages'); |
37
|
|
|
$layout = $this->input->get('layout', 'default'); |
38
|
|
|
$id = $this->input->getInt('id'); |
39
|
|
|
|
40
|
|
|
if ($vName == 'translations') |
41
|
|
|
{ |
42
|
|
|
$view = $this->getView('translations', 'html'); |
43
|
|
|
$packages = $this->getModel('Packages', 'LocaliseModel', array('ignore_request' => true)); |
44
|
|
|
$view->setModel($packages); |
45
|
|
|
} |
46
|
|
|
// Check for edit form. |
47
|
|
View Code Duplication |
elseif ($vName == 'language' && $layout == 'edit' |
|
|
|
|
48
|
|
|
&& !$this->checkEditId('com_localise.edit.language', $id)) |
49
|
|
|
{ |
50
|
|
|
// Somehow the person just went to the form - we don't allow that. |
51
|
|
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); |
52
|
|
|
$this->setMessage($this->getError(), 'error'); |
53
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_localise&view=languages', false)); |
54
|
|
|
|
55
|
|
|
return false; |
56
|
|
|
} |
57
|
|
View Code Duplication |
elseif ($vName == 'translation' && ($layout == 'edit' || $layout == 'raw') |
|
|
|
|
58
|
|
|
&& !$this->checkEditId('com_localise.edit.translation', $id)) |
59
|
|
|
{ |
60
|
|
|
// Somehow the person just went to the form - we don't allow that. |
61
|
|
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); |
62
|
|
|
$this->setMessage($this->getError(), 'error'); |
63
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_localise&view=translations', false)); |
64
|
|
|
|
65
|
|
|
return false; |
66
|
|
|
} |
67
|
|
View Code Duplication |
elseif ($vName == 'packagefile' && $layout == 'edit' |
|
|
|
|
68
|
|
|
&& !$this->checkEditId('com_localise.edit.packagefile', $id)) |
69
|
|
|
{ |
70
|
|
|
// Somehow the person just went to the form - we don't allow that. |
71
|
|
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); |
72
|
|
|
$this->setMessage($this->getError(), 'error'); |
73
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_localise&view=packages', false)); |
74
|
|
|
|
75
|
|
|
return false; |
76
|
|
|
} |
77
|
|
View Code Duplication |
elseif ($vName == 'package' && $layout == 'edit' |
|
|
|
|
78
|
|
|
&& !$this->checkEditId('com_localise.edit.package', $id)) |
79
|
|
|
{ |
80
|
|
|
// Somehow the person just went to the form - we don't allow that. |
81
|
|
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); |
82
|
|
|
$this->setMessage($this->getError(), 'error'); |
83
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_localise&view=packages', false)); |
84
|
|
|
|
85
|
|
|
return false; |
86
|
|
|
} |
87
|
|
|
else |
88
|
|
|
{ |
89
|
|
|
$this->input->set('view', $vName); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
parent::display($cachable, $urlparams); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.