source: trunk/admin/plugins_new.php @ 25785

Last change on this file since 25785 was 25018, checked in by mistic100, 11 years ago

remove all array_push (50% slower than []) + some changes missing for feature:2978

  • 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// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 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_new.tpl'));
[2255]32
[10638]33$base_url = get_root_url().'admin.php?page='.$page['page'].'&tab='.$page['tab'];
[2255]34
[2264]35$plugins = new plugins();
[2242]36
37//------------------------------------------------------automatic installation
[5406]38if (isset($_GET['revision']) and isset($_GET['extension']))
[2242]39{
[5406]40  if (!is_webmaster())
41  {
[25018]42    $page['errors'][] = l10n('Webmaster status is required.');
[5406]43  }
44  else
45  {
46    check_pwg_token();
47   
48    $install_status = $plugins->extract_plugin_files('install', $_GET['revision'], $_GET['extension']);
[2264]49
[5406]50    redirect($base_url.'&installstatus='.$install_status);
51  }
[2242]52}
53
54//--------------------------------------------------------------install result
55if (isset($_GET['installstatus']))
56{
[2264]57  switch ($_GET['installstatus'])
58  {
59    case 'ok':
[25018]60      $page['infos'][] = l10n('Plugin has been successfully copied');
61      $page['infos'][] = l10n('You might go to plugin list to install and activate it.');
[2264]62      break;
63
64    case 'temp_path_error':
[25018]65      $page['errors'][] = l10n('Can\'t create temporary file.');
[2264]66      break;
67
68    case 'dl_archive_error':
[25018]69      $page['errors'][] = l10n('Can\'t download archive.');
[2264]70      break;
71
72    case 'archive_error':
[25018]73      $page['errors'][] = l10n('Can\'t read or extract archive.');
[2264]74      break;
75
76    default:
[25018]77      $page['errors'][] = l10n('An error occured during extraction (%s).', htmlspecialchars($_GET['installstatus']));
78      $page['errors'][] = l10n('Please check "plugins" folder and sub-folders permissions (CHMOD).');
[2264]79  } 
[2242]80}
81
[2264]82//---------------------------------------------------------------Order options
83$template->assign('order_options',
84  array(
[9598]85    'date' => l10n('Post date'),
86    'revision' => l10n('Last revisions'),
87    'name' => l10n('Name'),
88    'author' => l10n('Author'),
89    'downloads' => l10n('Number of downloads')));
[2264]90
[2242]91// +-----------------------------------------------------------------------+
92// |                     start template output                             |
93// +-----------------------------------------------------------------------+
[2880]94if ($plugins->get_server_plugins(true))
[2242]95{
[11222]96  /* order plugins */
97  if (pwg_get_session_var('plugins_new_order') != null)
98  {
99    $order_selected = pwg_get_session_var('plugins_new_order');
100    $plugins->sort_server_plugins($order_selected);
101    $template->assign('order_selected', $order_selected);
102  }
103  else
104  {
105    $plugins->sort_server_plugins('date');
106    $template->assign('order_selected', 'date');
107  }
[2272]108
[2263]109  foreach($plugins->server_plugins as $plugin)
[2243]110  {
[5515]111    $ext_desc = trim($plugin['extension_description'], " \n\r");
112    list($small_desc) = explode("\n", wordwrap($ext_desc, 200));
[2647]113
[2264]114    $url_auto_install = htmlentities($base_url)
[2647]115      . '&amp;revision=' . $plugin['revision_id']
[5195]116      . '&amp;extension=' . $plugin['extension_id']
117      . '&amp;pwg_token='.get_pwg_token()
118    ;
[2245]119
[2647]120    $template->append('plugins', array(
[5515]121      'ID' => $plugin['extension_id'],
[2647]122      'EXT_NAME' => $plugin['extension_name'],
123      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['extension_id'],
[5515]124      'SMALL_DESC' => trim($small_desc, " \r\n"),
125      'BIG_DESC' => $ext_desc,
[2647]126      'VERSION' => $plugin['revision_name'],
[9598]127      'REVISION_DATE' => preg_replace('/[^0-9]/', '', $plugin['revision_date']),
[2647]128      'AUTHOR' => $plugin['author_name'],
[5516]129      'DOWNLOADS' => $plugin['extension_nb_downloads'],
[2647]130      'URL_INSTALL' => $url_auto_install,
131      'URL_DOWNLOAD' => $plugin['download_url'] . '&amp;origin=piwigo_download'));
[2243]132  }
[2242]133}
134else
135{
[25018]136  $page['errors'][] = l10n('Can\'t connect to server.');
[2242]137}
138
[2255]139$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
[2242]140?>
Note: See TracBrowser for help on using the repository browser.