1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* EGgroupware admin - custom translations |
4
|
|
|
* |
5
|
|
|
* @link http://www.egroupware.org |
6
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
7
|
|
|
* @package admin |
8
|
|
|
* @copyright (c) 2011-16 by Ralf Becker <[email protected]> |
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
10
|
|
|
* @version $Id$ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use EGroupware\Api; |
14
|
|
|
use EGroupware\Api\Egw; |
15
|
|
|
use EGroupware\Api\Etemplate; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Custom - instance specific - translations |
19
|
|
|
*/ |
20
|
|
|
class admin_customtranslation |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Which methods of this class can be called as menuation |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
public $public_functions = array( |
28
|
|
|
'index' => true, |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Add, modify, delete custom translations |
33
|
|
|
* |
34
|
|
|
* @param array $_content =null |
35
|
|
|
* @param string $msg ='' |
36
|
|
|
*/ |
37
|
|
|
function index(array $_content=null, $msg='') |
38
|
|
|
{ |
39
|
|
|
if (is_array($_content)) |
40
|
|
|
{ |
41
|
|
|
//_debug_array($_content); |
42
|
|
|
if (isset($_content['button'])) |
43
|
|
|
{ |
44
|
|
|
$action = key($_content['button']); |
45
|
|
|
unset($_content['button']); |
46
|
|
|
} |
47
|
|
|
elseif($_content['rows']['delete']) |
48
|
|
|
{ |
49
|
|
|
$action = key($_content['rows']['delete']); |
50
|
|
|
unset($_content['rows']['delete']); |
51
|
|
|
} |
52
|
|
|
switch($action) |
53
|
|
|
{ |
54
|
|
|
case 'save': |
55
|
|
|
case 'apply': |
56
|
|
|
$saved = 0; |
57
|
|
|
foreach($_content['rows'] as $data) |
58
|
|
|
{ |
59
|
|
|
if (!empty($data['phrase'])) |
60
|
|
|
{ |
61
|
|
|
Api\Translation::write('en', 'custom', strtolower(trim($data['phrase'])), $data['translation']); |
62
|
|
|
++$saved; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
if ($saved) $msg = lang('%1 phrases saved.', $saved); |
|
|
|
|
66
|
|
|
if ($action == 'apply') break; |
67
|
|
|
// fall through |
68
|
|
|
case 'cancel': |
69
|
|
|
Egw::redirect_link('/admin/index.php'); |
70
|
|
|
break; |
71
|
|
|
|
72
|
|
|
default: // line to delete; |
73
|
|
|
if (!empty($_content['rows'][$action]['phrase'])) |
74
|
|
|
{ |
75
|
|
|
Api\Translation::write('en', 'custom', strtolower(trim($_content['rows'][$action]['phrase'])), null); |
76
|
|
|
$msg = lang('Phrase deleted'); |
77
|
|
|
} |
78
|
|
|
break; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
$content = array('rows' => array()); |
82
|
|
|
foreach(Api\Translation::load_app('custom', 'en') as $phrase => $translation) |
83
|
|
|
{ |
84
|
|
|
$content['rows'][++$row] = array( |
|
|
|
|
85
|
|
|
'phrase' => $phrase, |
86
|
|
|
'translation' => $translation, |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
// one empty line to add new translations |
90
|
|
|
$content['rows'][++$row] = array( |
91
|
|
|
'phrase' => '', |
92
|
|
|
'translation' => '', |
93
|
|
|
); |
94
|
|
|
$readonlys["delete[$row]"] = true; // no delete for empty row |
|
|
|
|
95
|
|
|
$content['msg'] = $msg; |
96
|
|
|
|
97
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Custom translation'); |
98
|
|
|
$tpl = new Etemplate('admin.customtranslation'); |
99
|
|
|
$tpl->exec('admin.admin_customtranslation.index', $content, array(), $readonlys); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.