source: trunk/admin/plugins_list.php @ 10101

Last change on this file since 10101 was 10101, checked in by patdenice, 13 years ago

feature:2250
Add languages keys.

  • Property svn:eol-style set to LF
File size: 5.3 KB
RevLine 
[2242]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[8728]5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
[2297]6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
[2242]23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
[2263]29include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
[2255]30
[2530]31$template->set_filenames(array('plugins' => 'plugins_list.tpl'));
[2255]32
[5475]33$base_url = get_root_url().'admin.php?page='.$page['page'];
[5195]34$action_url = $base_url.'&amp;plugin='.'%s'.'&amp;pwg_token='.get_pwg_token();
[2255]35
[2264]36$plugins = new plugins();
37
[2263]38//--------------------------------------------------perform requested actions
[8126]39if (isset($_GET['action']) and isset($_GET['plugin']))
[2255]40{
[9995]41  if (in_array($_GET['action'], array('install', 'uninstall')) AND !is_webmaster())
[9994]42  {
43    array_push($page['errors'], l10n('Webmaster status is required.'));
44  }
45  else
46  {
47    check_pwg_token();
[5691]48
[9994]49    $page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']);
[2264]50
[9994]51    if (empty($page['errors']))
[3950]52    {
[9994]53      if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate')
54      {
55        $template->delete_compiled_templates();
56      }
57      redirect($base_url);
[3950]58    }
59  }
[2255]60}
61
[2264]62//--------------------------------------------------------------------Tabsheet
[5367]63$plugins->set_tabsheet($page['page']);
[2264]64
[2255]65// +-----------------------------------------------------------------------+
66// |                     start template output                             |
67// +-----------------------------------------------------------------------+
[5474]68
[5475]69$plugins->sort_fs_plugins('name');
[10098]70$plugins->get_merged_extensions();
71$plugins->get_incompatible_plugins();
[10100]72$merged_plugins = false;
[2264]73
[2263]74foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
[2242]75{
[10098]76  if (isset($_SESSION['incompatible_plugins'][$plugin_id])
77    and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id])
78  {
79    // Incompatible plugins must be reinitilized
80    unset($_SESSION['incompatible_plugins']);
81    $plugins->get_incompatible_plugins();
82  }
83
[5474]84  $tpl_plugin = array(
85    'NAME' => $fs_plugin['name'],
86    'VISIT_URL' => $fs_plugin['uri'],
87    'VERSION' => $fs_plugin['version'],
88    'DESC' => $fs_plugin['description'],
89    'AUTHOR' => $fs_plugin['author'],
[5691]90    'AUTHOR_URL' => @$fs_plugin['author uri'],
[10098]91    'U_ACTION' => sprintf($action_url, $plugin_id),
92    'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]),
[5474]93    );
[2242]94
[2263]95  if (isset($plugins->db_plugins_by_id[$plugin_id]))
[2293]96  {
97    $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state'];
[2242]98  }
99  else
100  {
[2631]101    $tpl_plugin['STATE'] = 'uninstalled';
[2242]102  }
[5474]103
[10100]104  if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
105  {
106    switch($tpl_plugin['STATE'])
107    {
108      case 'active': $plugins->perform_action('deactivate', $plugin_id);
109      case 'inactive': $plugins->perform_action('uninstall', $plugin_id);
110    }
111    $tpl_plugin['STATE'] = 'merged';
[10101]112    $tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.');
[10100]113    $merged_plugins = true;
114  }
115
[2242]116  $template->append('plugins', $tpl_plugin);
117}
118
[10098]119$template->append('plugin_states', 'active');
120$template->append('plugin_states', 'inactive');
121$template->append('plugin_states', 'uninstalled');
122
[10100]123if ($merged_plugins)
124{
125  $template->append('plugin_states', 'merged');
126}
127
[2242]128$missing_plugin_ids = array_diff(
[5474]129  array_keys($plugins->db_plugins_by_id),
130  array_keys($plugins->fs_plugins)
131  );
[2242]132
[10098]133if (count($missing_plugin_ids) > 0)
[2242]134{
[10098]135  foreach($missing_plugin_ids as $plugin_id)
136  {
137    $template->append(
138      'plugins',
139      array(
140        'NAME' => $plugin_id,
141        'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
[10101]142        'DESC' => l10n('ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.'),
[10098]143        'U_ACTION' => sprintf($action_url, $plugin_id),
144        'STATE' => 'missing',
145        )
146      );
147  }
148  $template->append('plugin_states', 'missing');
[2242]149}
150
[2255]151$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
[2242]152?>
Note: See TracBrowser for help on using the repository browser.