source: trunk/admin/plugins_new.php @ 2272

Last change on this file since 2272 was 2272, checked in by patdenice, 16 years ago

Corrections in plugins management.
Add "Last revisions" sort order.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | file          : $Id: plugins_new.php 2272 2008-03-10 18:01:17Z patdenice $
7// | last update   : $Date: 2008-03-10 18:01:17 +0000 (Mon, 10 Mar 2008) $
8// | last modifier : $Author: patdenice $
9// | revision      : $Revision: 2272 $
10// +-----------------------------------------------------------------------+
11// | This program is free software; you can redistribute it and/or modify  |
12// | it under the terms of the GNU General Public License as published by  |
13// | the Free Software Foundation                                          |
14// |                                                                       |
15// | This program is distributed in the hope that it will be useful, but   |
16// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
17// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
18// | General Public License for more details.                              |
19// |                                                                       |
20// | You should have received a copy of the GNU General Public License     |
21// | along with this program; if not, write to the Free Software           |
22// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
23// | USA.                                                                  |
24// +-----------------------------------------------------------------------+
25
26if( !defined("PHPWG_ROOT_PATH") )
27{
28  die ("Hacking attempt!");
29}
30
31include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
32
33$template->set_filenames(array('plugins' => 'admin/plugins_new.tpl'));
34
35$order = isset($_GET['order']) ? $_GET['order'] : 'date';
36$base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order;
37
38$plugins = new plugins();
39
40//------------------------------------------------------automatic installation
41if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser())
42{
43  $install_status =
44    $plugins->extract_plugin_files('install', $_GET['install'], $_GET['extension']);
45
46  redirect($base_url.'&installstatus='.$install_status);
47}
48
49//--------------------------------------------------------------install result
50if (isset($_GET['installstatus']))
51{
52  switch ($_GET['installstatus'])
53  {
54    case 'ok':
55      array_push($page['infos'],
56        l10n('plugins_install_ok'),
57        l10n('plugins_install_need_activate'));
58      break;
59
60    case 'temp_path_error':
61      array_push($page['errors'], l10n('plugins_temp_path_error'));
62      break;
63
64    case 'dl_archive_error':
65      array_push($page['errors'], l10n('plugins_dl_archive_error'));
66      break;
67
68    case 'archive_error':
69      array_push($page['errors'], l10n('plugins_archive_error'));
70      break;
71
72    default:
73      array_push($page['errors'],
74        sprintf(l10n('plugins_extract_error'), $_GET['installstatus']),
75        l10n('plugins_check_chmod'));
76  } 
77}
78
79//--------------------------------------------------------------------Tabsheet
80set_plugins_tabsheet($page['page']);
81
82//---------------------------------------------------------------Order options
83$link = get_root_url().'admin.php?page='.$page['page'].'&amp;order=';
84$template->assign('order_options',
85  array(
86    $link.'date' => l10n('Post date'),
87    $link.'revision' => l10n('plugins_revisions'),
88    $link.'name' => l10n('Name'),
89    $link.'author' => l10n('Author')));
90$template->assign('order_selected', $link.$order);
91
92// +-----------------------------------------------------------------------+
93// |                     start template output                             |
94// +-----------------------------------------------------------------------+
95$plugins->get_server_plugins(true);
96
97if (is_array($plugins->server_plugins))
98{
99  $plugins->sort_server_plugins($order);
100
101  foreach($plugins->server_plugins as $plugin)
102  {
103    $ext_desc = nl2br(htmlspecialchars(strip_tags(
104                  utf8_encode($plugin['ext_description']))));
105
106    $ver_desc = sprintf(l10n('plugins_description'),
107            $plugin['version'],
108            date('Y-m-d', $plugin['date']),
109            nl2br(htmlspecialchars(strip_tags(
110              utf8_encode($plugin['description'])))));
111
112    $url_auto_install = htmlentities($base_url)
113      . '&amp;extension=' . $plugin['id_extension']
114      . '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension']
115      . '%2Frevision-' . $plugin['id_revision'] . '%2F'
116      .  str_replace(' ', '%20',$plugin['url']);
117
118    $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
119      . '/revision-' . $plugin['id_revision']
120      . '/' . str_replace(' ', '%20',$plugin['url']);
121
122    $template->append('plugins',
123        array('EXT_NAME' => $plugin['ext_name'],
124          'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'],
125          'EXT_DESC' => $ext_desc,
126          'VERSION' => $plugin['version'],
127          'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'],
128          'DATE' => date('Y-m-d', $plugin['date']),
129          'VER_DESC' => $ver_desc,
130          'AUTHOR' => $plugin['author'],
131          'URL_INSTALL' => $url_auto_install,
132          'URL_DOWNLOAD' => $url_download));
133  }
134}
135else
136{
137  array_push($page['errors'], l10n('plugins_server_error'));
138}
139
140$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
141?>
Note: See TracBrowser for help on using the repository browser.