source: trunk/admin/plugins_new.php @ 2264

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

Corrections in plugins management.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 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 2264 2008-03-07 17:15:46Z patdenice $
7// | last update   : $Date: 2008-03-07 17:15:46 +0000 (Fri, 07 Mar 2008) $
8// | last modifier : $Author: patdenice $
9// | revision      : $Revision: 2264 $
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
80include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
81$link = get_root_url().'admin.php?page=';
82$tabsheet = new tabsheet();
83$tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');
84$tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');
85$tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');
86$tabsheet->select($page['page']);
87$tabsheet->assign();
88
89//---------------------------------------------------------------Order options
90$link .= $page['page'].'&amp;order=';
91$template->assign('order_options',
92  array(
93    $link.'date' => l10n('Post date'),
94    $link.'name' => l10n('Name'),
95    $link.'author' => l10n('Author')));
96$template->assign('order_selected', $link.$order);
97
98// +-----------------------------------------------------------------------+
99// |                     start template output                             |
100// +-----------------------------------------------------------------------+
101$plugins->get_server_plugins(true);
102$plugins->sort_server_plugins($order);
103
104if ($plugins->server_plugins !== false)
105{
106  foreach($plugins->server_plugins as $plugin)
107  {
108    $ext_desc = nl2br(htmlspecialchars(strip_tags(
109                  utf8_encode($plugin['ext_description']))));
110
111    $ver_desc = sprintf(l10n('plugins_description'),
112            $plugin['version'],
113            date('Y-m-d', $plugin['date']),
114            nl2br(htmlspecialchars(strip_tags(
115              utf8_encode($plugin['description'])))));
116
117    $url_auto_install = htmlentities($base_url)
118      . '&amp;extension=' . $plugin['id_extension']
119      . '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension']
120      . '%2Frevision-' . $plugin['id_revision'] . '%2F'
121      .  str_replace(' ', '%20',$plugin['url']);
122
123    $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
124      . '/revision-' . $plugin['id_revision']
125      . '/' . str_replace(' ', '%20',$plugin['url']);
126
127    $template->append('plugins',
128        array('EXT_NAME' => $plugin['ext_name'],
129          'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'],
130          'EXT_DESC' => $ext_desc,
131          'VERSION' => $plugin['version'],
132          'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'],
133          'VER_DESC' => $ver_desc,
134          'AUTHOR' => $plugin['author'],
135          'URL_INSTALL' => $url_auto_install,
136          'URL_DOWNLOAD' => $url_download));
137  }
138}
139else
140{
141  array_push($page['errors'], l10n('plugins_server_error'));
142}
143
144$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
145?>
Note: See TracBrowser for help on using the repository browser.