1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of translater, a plugin for Dotclear 2. |
---|
4 | # |
---|
5 | # Copyright (c) 2009 JC Denis and contributors |
---|
6 | # jcdenis@gdwd.com |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | if (!defined('DC_CONTEXT_ADMIN')){return;} |
---|
14 | |
---|
15 | # Additionals locales |
---|
16 | __('translater'); |
---|
17 | __('Translate your Dotclear plugins and themes'); |
---|
18 | |
---|
19 | # Add auth perm |
---|
20 | $core->auth->setPermissionType('translater',__('manage translations')); |
---|
21 | |
---|
22 | # Admin menu |
---|
23 | $_menu['Plugins']->addItem( |
---|
24 | __('Translater'), |
---|
25 | 'plugin.php?p=translater','index.php?pf=translater/icon.png', |
---|
26 | preg_match('/plugin.php\?p=translater(&.*)?$/',$_SERVER['REQUEST_URI']), |
---|
27 | $core->auth->check('admin,translater',$core->blog->id)); |
---|
28 | |
---|
29 | # Plugins tab |
---|
30 | if ($core->blog->settings->translater_plugin_menu) |
---|
31 | $core->addBehavior('pluginsToolsTabs', |
---|
32 | array('translaterBehaviors','pluginsToolsTabs')); |
---|
33 | |
---|
34 | # Themes menu |
---|
35 | if ($core->blog->settings->translater_theme_menu) |
---|
36 | $core->addBehavior('adminCurrentThemeDetails', |
---|
37 | array('translaterBehaviors','adminCurrentThemeDetails')); |
---|
38 | |
---|
39 | # Admin rest for getting translation |
---|
40 | $core->rest->addFunction('getProposal',array('translaterRest','getProposal')); |
---|
41 | |
---|
42 | # Behaviors |
---|
43 | class translaterBehaviors |
---|
44 | { |
---|
45 | public static function pluginsToolsTabs($core) |
---|
46 | { |
---|
47 | echo |
---|
48 | '<div class="multi-part" id="translater" title="'. |
---|
49 | __('Translate extensions'). |
---|
50 | '">'. |
---|
51 | '<table class="clear"><tr>'. |
---|
52 | '<th> </th>'. |
---|
53 | '<th>'.__('Name').'</th>'. |
---|
54 | '<th class="nowrap">'.__('Version').'</th>'. |
---|
55 | '<th class="nowrap">'.__('Details').'</th>'. |
---|
56 | '<th class="nowrap">'.__('Author').'</th>'. |
---|
57 | '</tr>'; |
---|
58 | $modules = $core->plugins->getModules(); |
---|
59 | foreach ($modules as $name => $plugin) { |
---|
60 | echo |
---|
61 | '<tr class="line">'. |
---|
62 | '<td class="nowrap">'. |
---|
63 | '<a href="plugin.php?p=translater&type=plugin&module='.$name.'"'. |
---|
64 | ' title="'.__('Translate this plugin').'">'.__($plugin['name']).'</a></td>'. |
---|
65 | '<td class="nowrap">'.$name.'</td>'. |
---|
66 | '<td class="nowrap">'.$plugin['version'].'</td>'. |
---|
67 | '<td class="maximal">'.$plugin['desc'].'</td>'. |
---|
68 | '<td class="nowrap">'.$plugin['author'].'</td>'. |
---|
69 | '</tr>'; |
---|
70 | } |
---|
71 | echo '</table></div>'; |
---|
72 | } |
---|
73 | |
---|
74 | public static function adminCurrentThemeDetails($core,$id,$infos) |
---|
75 | { |
---|
76 | $root = path::real($infos['root']); |
---|
77 | if ($id != 'default' && is_dir($root.'/locales') |
---|
78 | && $core->auth->check('translater,admin',$core->blog->id)) { |
---|
79 | return |
---|
80 | '<p><a href="plugin.php?p=translater&type=theme&module='.$id.'"'. |
---|
81 | ' class="button">'.__('Translate this theme').'</a></p>'; |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | ?> |
---|