noalyss Version-9
upgrade-plugin.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * PhpCompta is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PhpCompta; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
20
21if (!defined('ALLOWED'))
22 die('Appel direct ne sont pas permis');
23if (!defined('ALLOWED_ADMIN'))
24{
25 die(_('Non autorisé'));
26}
27
29
30/**
31 * @file
32 * @brief Install new plugin
33 */
36/*
37 * If xml is null , it means it was not possible to get the file , could be
38 * a network problem or a misconfiguration
39 */
40if ( $xml == NULL) {
41 echo '<h2 class="error">';
42 printf (_("Désolé , impossible de se connecter au serveur %s"),
43 NOALYSS_PACKAGE_REPOSITORY);
44 echo '</h2>';
45 return;
46
47}
48
49$a_plugin=$xml->xpath('//plugins/plugin');
51echo _("Les extensions doivent être activées dans le dossier après installation");
52echo '<p>';
53echo _("Recherche").HtmlInput::filter_table("tab_plugin",'0,1,2,3',1);
54echo '</p>';
55?>
56
57<table id="tab_plugin" class="result">
58 <tr>
59 <th>
60 <?= _("Nom") ?>
61 </th>
62 <th>
63 <?= _("Description") ?>
64 </th>
65 <th>
66 <?= _("Auteur") ?>
67 </th>
68 <th>
69 <?= _("Code") ?>
70 </th>
71 <th>
72 Installé ou mettre à jour ???
73 </th>
74
75 </tr>
76 <?php
77 for ($i=0; $i<$nb_plugin; $i++)
78 {
79 ?>
80 <tr>
81 <td>
82 <?= $a_plugin[$i]->name; ?>
83 </td>
84 <td>
85 <?= $a_plugin[$i]->description; ?>
86 </td>
87 <td>
88 <?= $a_plugin[$i]->author; ?>
89 </td>
90 <td>
91 <?= $a_plugin[$i]->code; ?>
92 version [<?= $a_plugin[$i]->version; ?>]
93 </td>
94 <td id="result<?=trim($a_plugin[$i]->code)?>">
95
96 <?php
97 //is installed
98 if (is_file(NOALYSS_PLUGIN."/".trim($a_plugin[$i]->root)."/plugin.xml"))
99 {
100 // plugin is installed take the version and compare with remote one
101 $xml_plugin=$package_repository->read_package_xml(NOALYSS_PLUGIN."/".trim($a_plugin[$i]->root)."/plugin.xml");
102 if (count($xml_plugin->plugin)>1)
103 {
104 echo _("MultiModule");
105 }
106 // Compute js to install or upgrade
107 $js=sprintf("onclick=\"upgradePlugin('%s')\"", trim($a_plugin[$i]->code));
108 // Check if new version is available
109 if (floatval(trim($xml_plugin->plugin->version))<floatval(trim($a_plugin[$i]->version)))
110 {
111 printf (_("Nouvelle version disponible %s , votre version %s"),
112 floatval(trim($a_plugin[$i]->version)),
113 trim($xml_plugin->plugin->version));
114 echo HtmlInput::button("upgrade", _("Mise à jour"), $js);
115 }
116 else
117 {
118 echo _("Dernière version installée");
119 }
120 }
121 else
122 {
123 // It is not installed , propose to install it
124 $js=sprintf("onclick=\"upgradePlugin('%s')\"", trim($a_plugin[$i]->code));
125 echo _("Non installée");
126 echo HtmlInput::button("upgrade", _("Installation"), $js);
127 }
128 ?>
129 </td>
130 </tr>
131 <?php
132 }
133 ?>
134</table>
135
136<script>
137 function upgradePlugin(p_code) {
138 var task_id="<?=uniqid()?>";
139 progress_bar_start(task_id);
140 new Ajax.Updater(
141 "result"+p_code,
142 "ajax_misc.php" ,
143 {
144 method:'POST',
145 parameters:{gDossier:0,op:'upgradePlugin',code_plugin:p_code,"task_id":task_id}
146 });
147 }
148</script>
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static echo_file($msg, $print=true)
display the file
Definition: dbg.php:88
connect to NOALYSS_PACKAGE and fetch the file web.xml , it displays content of this file ,...
$all table
if( $xml==NULL) $a_plugin
$package_repository
$nb_plugin