aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/include/plugins.class.php64
-rw-r--r--admin/plugins_new.php57
-rw-r--r--admin/plugins_update.php76
-rw-r--r--admin/template/goto/plugins_new.tpl5
-rw-r--r--admin/template/goto/plugins_update.tpl7
-rw-r--r--admin/template/goto/theme/roma/themeconf.inc.php2
-rw-r--r--include/constants.php2
7 files changed, 122 insertions, 91 deletions
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index de189ffc9..2d2bd3afe 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -264,6 +264,33 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
*/
function get_server_plugins($new=false)
{
+ // Retrieve PEM versions
+ $version = PHPWG_VERSION;
+ $versions_to_check = array();
+ $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php';
+ if ($source = @file_get_contents($url)
+ and $pem_versions = @unserialize($source))
+ {
+ if (!preg_match('/^\d+\.\d+\.\d+/', $version))
+ {
+ $version = $pem_versions[0]['name'];
+ }
+ $branch = substr($version, 0, strrpos($version, '.'));
+ foreach ($pem_versions as $pem_version)
+ {
+ if (strpos($pem_version['name'], $branch) === 0)
+ {
+ $versions_to_check[] = $pem_version['id'];
+ }
+ }
+ }
+ if (empty($versions_to_check))
+ {
+ return false;
+ }
+
+ // Plugins to check
+ $plugins_to_check = array();
foreach($this->fs_plugins as $fs_plugin)
{
if (isset($fs_plugin['extension']))
@@ -271,12 +298,23 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
$plugins_to_check[] = $fs_plugin['extension'];
}
}
- $url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check);
- $url .= $new ? '&newext=Plugin' : '';
- if (!empty($plugins_to_check) and $source = @file_get_contents($url))
+ // Retrieve PEM plugins infos
+ $url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true';
+ $url .= '&version=' . implode(',', $versions_to_check);
+ if (!empty($plugins_to_check))
+ {
+ $url .= $new ? '&extension_exclude=' : '&extension_include=';
+ $url .= implode(',', $plugins_to_check);
+ }
+ if ($source = @file_get_contents($url)
+ and $pem_plugins = @unserialize($source))
{
- $this->server_plugins = @unserialize($source);
+ foreach ($pem_plugins as $plugin)
+ {
+ $this->server_plugins[$plugin['extension_id']] = $plugin;
+ }
+ return true;
}
}
@@ -306,13 +344,15 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
* Extract plugin files from archive
* @param string - install or upgrade
* @param string - archive URL
- * @param string - destination path
+ * @param string - plugin id or extension id
*/
- function extract_plugin_files($action, $source, $dest)
+ function extract_plugin_files($action, $revision, $dest)
{
if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
{
- if (@copy(PEM_URL . str_replace(' ', '%20', $source), $archive))
+ $url = PEM_URL . '/download.php?rid=' . $revision;
+ $url .= '&origin=piwigo_' . $action;
+ if (@copy($url, $archive))
{
include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
$zip = new PclZip($archive);
@@ -333,7 +373,7 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
$root = dirname($main_filepath); // main.inc.php path in archive
if ($action == 'upgrade')
{
- $extract_path = PHPWG_PLUGINS_PATH.$dest;
+ $extract_path = PHPWG_PLUGINS_PATH . $dest;
}
else
{
@@ -428,25 +468,25 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
$pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
$replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
- $array = preg_replace($pattern, $replacement, array($a['version'], $b['version']));
+ $array = preg_replace($pattern, $replacement, array($a, $b));
return version_compare($array[0], $array[1], '>=');
}
function extension_revision_compare($a, $b)
{
- if ($a['date'] < $b['date']) return 1;
+ if ($a['revision_date'] < $b['revision_date']) return 1;
else return -1;
}
function extension_name_compare($a, $b)
{
- return strcmp(strtolower($a['ext_name']), strtolower($b['ext_name']));
+ return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name']));
}
function extension_author_compare($a, $b)
{
- $r = strcasecmp($a['author'], $b['author']);
+ $r = strcasecmp($a['author_name'], $b['author_name']);
if ($r == 0) return $this->extension_name_compare($a, $b);
else return $r;
}
diff --git a/admin/plugins_new.php b/admin/plugins_new.php
index 19d2be9a4..e86dc0a16 100644
--- a/admin/plugins_new.php
+++ b/admin/plugins_new.php
@@ -36,10 +36,9 @@ $base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order;
$plugins = new plugins();
//------------------------------------------------------automatic installation
-if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser())
+if (isset($_GET['revision']) and isset($_GET['extension']) and !is_adviser())
{
- $install_status =
- $plugins->extract_plugin_files('install', $_GET['install'], $_GET['extension']);
+ $install_status = $plugins->extract_plugin_files('install', $_GET['revision'], $_GET['extension']);
redirect($base_url.'&installstatus='.$install_status);
}
@@ -90,44 +89,38 @@ $template->assign('order_selected', $link.$order);
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-$plugins->get_server_plugins(true);
-
-if (is_array($plugins->server_plugins))
+if ($plugins->get_server_plugins(true))
{
$plugins->sort_server_plugins($order);
foreach($plugins->server_plugins as $plugin)
{
- $ext_desc = nl2br(htmlspecialchars(strip_tags(
- utf8_encode($plugin['ext_description']))));
+ /* Need to remove this lines for final release : piwigo website will be utf8 only */
+ $plugin['extension_description'] = utf8_encode($plugin['extension_description']);
+ $plugin['revision_description'] = utf8_encode($plugin['revision_description']);
+
+ list($date, ) = explode(' ', $plugin['revision_date']);
$ver_desc = sprintf(l10n('plugins_description'),
- $plugin['version'],
- date('Y-m-d', $plugin['date']),
- nl2br(htmlspecialchars(strip_tags(
- utf8_encode($plugin['description'])))));
+ $plugin['revision_name'],
+ $date,
+ $plugin['revision_description']);
$url_auto_install = htmlentities($base_url)
- . '&amp;extension=' . $plugin['id_extension']
- . '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension']
- . '%2Frevision-' . $plugin['id_revision'] . '%2F'
- . str_replace(' ', '%20',$plugin['url']);
-
- $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
- . '/revision-' . $plugin['id_revision']
- . '/' . str_replace(' ', '%20',$plugin['url']);
-
- $template->append('plugins',
- array('EXT_NAME' => $plugin['ext_name'],
- 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'],
- 'EXT_DESC' => $ext_desc,
- 'VERSION' => $plugin['version'],
- 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'],
- 'DATE' => date('Y-m-d', $plugin['date']),
- 'VER_DESC' => $ver_desc,
- 'AUTHOR' => $plugin['author'],
- 'URL_INSTALL' => $url_auto_install,
- 'URL_DOWNLOAD' => $url_download));
+ . '&amp;revision=' . $plugin['revision_id']
+ . '&amp;extension=' . $plugin['extension_id'];
+
+ $template->append('plugins', array(
+ 'EXT_NAME' => $plugin['extension_name'],
+ 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['extension_id'],
+ 'EXT_DESC' => $plugin['extension_description'],
+ 'VERSION' => $plugin['revision_name'],
+ 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['revision_id'],
+ 'DATE' => $date,
+ 'VER_DESC' => $ver_desc,
+ 'AUTHOR' => $plugin['author_name'],
+ 'URL_INSTALL' => $url_auto_install,
+ 'URL_DOWNLOAD' => $plugin['download_url'] . '&amp;origin=piwigo_download'));
}
}
else
diff --git a/admin/plugins_update.php b/admin/plugins_update.php
index 3c274b14f..944fd3b1a 100644
--- a/admin/plugins_update.php
+++ b/admin/plugins_update.php
@@ -35,9 +35,10 @@ $base_url = get_root_url().'admin.php?page='.$page['page'];
$plugins = new plugins();
//-----------------------------------------------------------automatic upgrade
-if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
+if (isset($_GET['plugin']) and isset($_GET['revision']) and !is_adviser())
{
$plugin_id = $_GET['plugin'];
+ $revision = $_GET['revision'];
if (isset($plugins->db_plugins_by_id[$plugin_id])
and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active')
@@ -45,13 +46,12 @@ if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
$plugins->perform_action('deactivate', $plugin_id);
redirect($base_url
- . '&upgrade=' . $_GET['upgrade']
+ . '&revision=' . $revision
. '&plugin=' . $plugin_id
. '&reactivate=true');
}
- $upgrade_status =
- $plugins->extract_plugin_files('upgrade', $_GET['upgrade'], $plugin_id);
+ $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id);
if (isset($_GET['reactivate']))
{
@@ -97,9 +97,7 @@ set_plugins_tabsheet($page['page']);
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-$plugins->get_server_plugins();
-
-if (is_array($plugins->server_plugins))
+if ($plugins->get_server_plugins())
{
foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
{
@@ -108,55 +106,51 @@ if (is_array($plugins->server_plugins))
{
$plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
- $ext_desc = nl2br(htmlspecialchars(strip_tags(
- utf8_encode($plugin_info['ext_description']))));
+ /* Need to remove this lines for final release : piwigo website will be utf8 only */
+ $plugin_info['extension_description'] = utf8_encode($plugin_info['extension_description']);
+ $plugin_info['revision_description'] = utf8_encode($plugin_info['revision_description']);
+
+ list($date, ) = explode(' ', $plugin_info['revision_date']);
$ver_desc = sprintf(l10n('plugins_description'),
- $plugin_info['version'],
- date('Y-m-d', $plugin_info['date']),
- nl2br(htmlspecialchars(strip_tags(
- utf8_encode($plugin_info['description'])))));
+ $plugin_info['revision_name'],
+ $date,
+ $plugin_info['revision_description']);
- if ($plugins->plugin_version_compare($fs_plugin, $plugin_info))
+ if ($plugins->plugin_version_compare($fs_plugin['version'], $plugin_info['revision_name']))
{
// Plugin is up to date
- $template->append('plugins_uptodate',
- array('URL' => $fs_plugin['uri'],
- 'NAME' => $fs_plugin['name'],
- 'EXT_DESC' => $ext_desc,
- 'VERSION' => $fs_plugin['version']));
+ $template->append('plugins_uptodate', array(
+ 'URL' => $fs_plugin['uri'],
+ 'NAME' => $fs_plugin['name'],
+ 'EXT_DESC' => $plugin_info['extension_description'],
+ 'VERSION' => $fs_plugin['version']));
}
else
{
// Plugin need upgrade
$url_auto_update = $base_url
- . '&amp;plugin=' . $plugin_id
- . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
- . '%2Frevision-' . $plugin_info['id_revision']
- . '%2F' . str_replace(' ', '%20',$plugin_info['url']);
-
- $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
- . '/revision-' . $plugin_info['id_revision']
- . '/' . str_replace(' ', '%20',$plugin_info['url']);
-
- $template->append('plugins_not_uptodate',
- array('EXT_NAME' => $fs_plugin['name'],
- 'EXT_URL' => $fs_plugin['uri'],
- 'EXT_DESC' => $ext_desc,
- 'VERSION' => $fs_plugin['version'],
- 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
- 'NEW_VERSION' => $plugin_info['version'],
- 'NEW_VER_DESC' => $ver_desc,
- 'URL_UPDATE' => $url_auto_update,
- 'URL_DOWNLOAD' => $url_download));
+ . '&amp;revision=' . $plugin_info['revision_id']
+ . '&amp;plugin=' . $plugin_id;
+
+ $template->append('plugins_not_uptodate', array(
+ 'EXT_NAME' => $fs_plugin['name'],
+ 'EXT_URL' => $fs_plugin['uri'],
+ 'EXT_DESC' => $plugin_info['extension_description'],
+ 'VERSION' => $fs_plugin['version'],
+ 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['revision_id'],
+ 'NEW_VERSION' => $plugin_info['revision_name'],
+ 'NEW_VER_DESC' => $ver_desc,
+ 'URL_UPDATE' => $url_auto_update,
+ 'URL_DOWNLOAD' => $plugin_info['download_url'] . '&amp;origin=piwigo_download'));
}
}
else
{
// Can't check plugin
- $template->append('plugins_cant_check',
- array('NAME' => $fs_plugin['name'],
- 'VERSION' => $fs_plugin['version']));
+ $template->append('plugins_cant_check', array(
+ 'NAME' => $fs_plugin['name'],
+ 'VERSION' => $fs_plugin['version']));
}
}
}
diff --git a/admin/template/goto/plugins_new.tpl b/admin/template/goto/plugins_new.tpl
index 0d3f4e1ba..bd6339566 100644
--- a/admin/template/goto/plugins_new.tpl
+++ b/admin/template/goto/plugins_new.tpl
@@ -1,3 +1,4 @@
+{* $Id$ *}
{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"}
{known_script id="jquery.dimensions" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.dimensions.packed.js"}
{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.cluetip.packed.js"}
@@ -35,8 +36,8 @@ jQuery().ready(function(){ldelim}
</thead>
{foreach from=$plugins item=plugin name=plugins_loop}
<tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}">
- <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC}">{$plugin.EXT_NAME}</a></td>
- <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.VER_DESC}">{$plugin.VERSION}</a></td>
+ <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.EXT_NAME}</a></td>
+ <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.VER_DESC|htmlspecialchars|nl2br}">{$plugin.VERSION}</a></td>
<td>{$plugin.DATE}</td>
<td>{$plugin.AUTHOR}</td>
<td style="text-align:center;"><a href="{$plugin.URL_INSTALL}" onclick="return confirm('{'plugins_confirm_install'|@translate|@escape:javascript}');">{'plugins_auto_install'|@translate}</a>
diff --git a/admin/template/goto/plugins_update.tpl b/admin/template/goto/plugins_update.tpl
index c21e01e18..c7bdc2865 100644
--- a/admin/template/goto/plugins_update.tpl
+++ b/admin/template/goto/plugins_update.tpl
@@ -1,3 +1,4 @@
+{* $Id$ *}
{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"}
{known_script id="jquery.dimensions" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.dimensions.packed.js"}
{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.cluetip.packed.js"}
@@ -29,9 +30,9 @@ jQuery().ready(function(){ldelim}
</thead>
{foreach from=$plugins_not_uptodate item=plugin name=plugins_loop}
<tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}">
- <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC}">{$plugin.EXT_NAME}</a></td>
+ <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.EXT_NAME}</a></td>
<td style="text-align:center;">{$plugin.VERSION}</td>
- <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.NEW_VER_DESC}">{$plugin.NEW_VERSION}</a></td>
+ <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.NEW_VER_DESC|htmlspecialchars|nl2br}">{$plugin.NEW_VERSION}</a></td>
<td style="text-align:center;"><a href="{$plugin.URL_UPDATE}" onclick="return confirm('{'plugins_confirm_upgrade'|@translate|@escape:javascript}');">{'plugins_auto_update'|@translate}</a>
/ <a href="{$plugin.URL_DOWNLOAD}">{'plugins_download'|@translate}</a></td>
</tr>
@@ -52,7 +53,7 @@ jQuery().ready(function(){ldelim}
</thead>
{foreach from=$plugins_uptodate item=plugin name=plugins_loop}
<tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}">
- <td><a href="{$plugin.URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.NAME}|{$plugin.EXT_DESC}">{$plugin.NAME}</a></td>
+ <td><a href="{$plugin.URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.NAME}</a></td>
<td style="text-align:center;">{$plugin.VERSION}</td>
</tr>
{/foreach}
diff --git a/admin/template/goto/theme/roma/themeconf.inc.php b/admin/template/goto/theme/roma/themeconf.inc.php
index 556c685b3..27bfe7ec1 100644
--- a/admin/template/goto/theme/roma/themeconf.inc.php
+++ b/admin/template/goto/theme/roma/themeconf.inc.php
@@ -41,6 +41,8 @@ function selected_admin_menu()
case 'maintenance':
case 'advanced_feature':
case 'plugins_list':
+ case 'plugins_update':
+ case 'plugins_new':
case 'plugin':
return 5;
}
diff --git a/include/constants.php b/include/constants.php
index 4966c8b59..b921228f3 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -25,7 +25,7 @@
define('PHPWG_VERSION', 'Butterfly');
define('PHPWG_DOMAIN', 'phpwebgallery.net');
define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN);
-define('PEM_URL', 'http://' . PHPWG_DOMAIN . '/ext');
+define('PEM_URL', 'http://' . PHPWG_DOMAIN . '/ext_new'); /* need to be changed on final release */
define('PHPWG_DEFAULT_LANGUAGE', 'en_UK');
define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear');