aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-03-04 11:35:38 +0000
committerpatdenice <patdenice@piwigo.org>2011-03-04 11:35:38 +0000
commit47809c86dfd8bc890a87afcc29c6df69c1627eb0 (patch)
treed3a87a8244bf81de96e305aefeeb78cccfd8f6a3
parent70136f04779c49f230f3d181128bf22920300917 (diff)
feature:2210
Update language from piwigo.org extension repository git-svn-id: http://piwigo.org/svn/trunk@9520 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/languages.class.php36
-rw-r--r--admin/languages_update.php133
-rw-r--r--admin/themes/default/template/languages_update.tpl62
-rw-r--r--install.php2
-rw-r--r--language/en_UK/admin.lang.php2
-rw-r--r--language/fr_FR/admin.lang.php2
6 files changed, 229 insertions, 8 deletions
diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php
index abaef1353..00338fc1e 100644
--- a/admin/include/languages.class.php
+++ b/admin/include/languages.class.php
@@ -32,7 +32,7 @@ class languages
*/
function languages($target_charset = null)
{
- $this->fs_languages = $this->get_fs_languages($target_charset);
+ $this->get_fs_languages($target_charset);
}
/**
@@ -47,6 +47,7 @@ class languages
$tabsheet = new tabsheet();
$tabsheet->add('languages_installed', l10n('Installed Languages'), $link.'languages_installed');
+ $tabsheet->add('languages_update', l10n('Check for updates'), $link.'languages_update');
$tabsheet->add('languages_new', l10n('Add New Language'), $link.'languages_new');
$tabsheet->select($selected);
$tabsheet->assign();
@@ -170,6 +171,7 @@ UPDATE '.USER_INFOS_TABLE.'
)
{
$language = array(
+ 'name'=>$file,
'code'=>$file,
'version'=>'0',
'uri'=>'',
@@ -211,8 +213,6 @@ UPDATE '.USER_INFOS_TABLE.'
}
closedir($dir);
@uasort($this->fs_languages, 'name_compare');
-
- return $this->fs_languages;
}
function get_db_languages()
@@ -282,6 +282,7 @@ UPDATE '.USER_INFOS_TABLE.'
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => $user['language'],
+ 'get_nb_downloads' => 'true',
)
);
if (!empty($languages_to_check))
@@ -307,10 +308,10 @@ UPDATE '.USER_INFOS_TABLE.'
{
if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name']))
{
- $this->server_languages[$language['extension_name']] = $language;
+ $this->server_languages[$language['extension_id']] = $language;
}
}
- @ksort($this->server_languages);
+ @uasort($this->server_languages, array($this, 'extension_name_compare'));
return true;
}
return false;
@@ -378,8 +379,11 @@ UPDATE '.USER_INFOS_TABLE.'
}
if ($status == 'ok')
{
- $this->fs_languages = $this->get_fs_languages();
- $this->perform_action('activate', $dest);
+ $this->get_fs_languages();
+ if ($action == 'install')
+ {
+ $this->perform_action('activate', $dest);
+ }
}
if (file_exists($extract_path.'/obsolete.list')
and $old_files = file($extract_path.'/obsolete.list', FILE_IGNORE_NEW_LINES)
@@ -471,5 +475,23 @@ UPDATE '.USER_INFOS_TABLE.'
}
}
}
+
+ /**
+ * Sort functions
+ */
+ function language_version_compare($a, $b)
+ {
+ $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
+ $replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
+
+ $array = preg_replace($pattern, $replacement, array($a, $b));
+
+ return version_compare($array[0], $array[1], '>=');
+ }
+
+ function extension_name_compare($a, $b)
+ {
+ return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name']));
+ }
}
?> \ No newline at end of file
diff --git a/admin/languages_update.php b/admin/languages_update.php
new file mode 100644
index 000000000..238113049
--- /dev/null
+++ b/admin/languages_update.php
@@ -0,0 +1,133 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+
+if( !defined("PHPWG_ROOT_PATH") )
+{
+ die ("Hacking attempt!");
+}
+
+include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
+
+$base_url = get_root_url().'admin.php?page='.$page['page'];
+
+$languages = new languages();
+
+$languages->set_tabsheet($page['page']);
+
+//-----------------------------------------------------------automatic upgrade
+if (isset($_GET['language']) and isset($_GET['revision']))
+{
+ if (!is_webmaster())
+ {
+ array_push($page['errors'], l10n('Webmaster status is required.'));
+ }
+ else
+ {
+ check_pwg_token();
+
+ $language_id = $_GET['language'];
+ $revision = $_GET['revision'];
+
+ $upgrade_status = $languages->extract_language_files('upgrade', $revision, $language_id);
+
+ switch ($upgrade_status)
+ {
+ case 'ok':
+ array_push($page['infos'],
+ sprintf(
+ l10n('%s has been successfully upgraded.'),
+ $languages->fs_languages[$_GET['language']]['name']));
+ break;
+
+ case 'temp_path_error':
+ array_push($page['errors'], l10n('Can\'t create temporary file.'));
+ break;
+
+ case 'dl_archive_error':
+ array_push($page['errors'], l10n('Can\'t download archive.'));
+ break;
+
+ case 'archive_error':
+ array_push($page['errors'], l10n('Can\'t read or extract archive.'));
+ break;
+
+ default:
+ array_push($page['errors'],
+ sprintf(l10n('An error occured during extraction (%s).'), $upgrade_status)
+ );
+ }
+
+ $languages->languages();
+ $template->delete_compiled_templates();
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | start template output |
+// +-----------------------------------------------------------------------+
+$template->set_filenames(array('languages' => 'languages_update.tpl'));
+
+if ($languages->get_server_languages())
+{
+ foreach($languages->fs_languages as $language_id => $fs_language)
+ {
+ if (isset($fs_language['extension'])
+ and isset($languages->server_languages[$fs_language['extension']]))
+ {
+ $language_info = $languages->server_languages[$fs_language['extension']];
+
+ if (!$languages->language_version_compare($fs_language['version'], $language_info['revision_name']))
+ {
+ $url_auto_update = $base_url
+ . '&amp;revision=' . $language_info['revision_id']
+ . '&amp;language=' . $language_id
+ . '&amp;pwg_token='.get_pwg_token()
+ ;
+
+ $template->append('update_languages', array(
+ 'ID' => $language_info['extension_id'],
+ 'EXT_NAME' => $fs_language['name'],
+ 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language_info['extension_id'],
+ 'EXT_DESC' => trim($language_info['extension_description'], " \n\r"),
+ 'REV_DESC' => trim($language_info['revision_description'], " \n\r"),
+ 'CURRENT_VERSION' => $fs_language['version'],
+ 'NEW_VERSION' => $language_info['revision_name'],
+ 'AUTHOR' => $language_info['author_name'],
+ 'DOWNLOADS' => $language_info['extension_nb_downloads'],
+ 'URL_UPDATE' => $url_auto_update,
+ 'URL_DOWNLOAD' => $language_info['download_url'] . '&amp;origin=piwigo_download'
+ )
+ );
+ }
+ }
+ }
+}
+else
+{
+ $template->assign('SERVER_ERROR', true);
+ array_push($page['errors'], l10n('Can\'t connect to server.'));
+}
+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
+?> \ No newline at end of file
diff --git a/admin/themes/default/template/languages_update.tpl b/admin/themes/default/template/languages_update.tpl
new file mode 100644
index 000000000..662a333f2
--- /dev/null
+++ b/admin/themes/default/template/languages_update.tpl
@@ -0,0 +1,62 @@
+{combine_script id='jquery.ui' load='async' require='jquery' path='themes/default/js/jquery.ui.min.js' }
+{combine_script id='jquery.ui.effects' load='async' require='jquery.ui' path='themes/default/js/ui/minified/jquery.effects.core.min.js' }
+{combine_script id='jquery.ui.effects.blind' load='async' require='jquery.ui.effects' path='themes/default/js/ui/minified/jquery.effects.blind.min.js' }
+
+{footer_script require='jquery.ui.effects.blind'}
+jQuery(document).ready(function(){ldelim}
+ jQuery("td[id^='desc_'], p[id^='revdesc_']").click(function() {ldelim}
+ id = this.id.split('_');
+ jQuery("#revdesc_"+id[1]).toggle('blind');
+ jQuery(".button_"+id[1]).toggle();
+ return false;
+ });
+});
+{/footer_script}
+
+<div class="titrePage">
+ <h2>{'Languages'|@translate}</h2>
+</div>
+
+{if not empty($update_languages)}
+<div id="availablePlugins">
+<fieldset>
+<legend>{'Languages which need upgrade'|@translate}</legend>
+{foreach from=$update_languages item=language name=languages_loop}
+<div class="pluginBox">
+ <table>
+ <tr>
+ <td class="pluginBoxNameCell">
+ {$language.EXT_NAME}
+ </td>
+ <td>
+ <a href="{$language.URL_UPDATE}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');">{'Install'|@translate}</a>
+ | <a href="{$language.URL_DOWNLOAD}">{'Download'|@translate}</a>
+ | <a class="externalLink" href="{$language.EXT_URL}">{'Visit language site'|@translate}</a>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {'Version'|@translate} {$language.CURRENT_VERSION}
+ </td>
+ <td class="pluginDesc" id="desc_{$language.ID}">
+ <em>{'Downloads'|@translate}: {$language.DOWNLOADS}</em>
+ <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/plus.gif" alt="" class="button_{$language.ID}">
+ <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/minus.gif" alt="" class="button_{$language.ID}" style="display:none;">
+ {'New Version'|@translate} : {$language.NEW_VERSION}
+ | {'By %s'|@translate|@sprintf:$language.AUTHOR}
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="pluginDesc">
+ <p id="revdesc_{$language.ID}" style="display:none;">{$language.REV_DESC|htmlspecialchars|nl2br}</p>
+ </td>
+ </tr>
+ </table>
+</div>
+{/foreach}
+</fieldset>
+</div>
+{elseif not isset($SERVER_ERROR)}
+<p>{'All languages are up to date.'|@translate}</p>
+{/if}
diff --git a/install.php b/install.php
index c74780dea..fe63248c6 100644
--- a/install.php
+++ b/install.php
@@ -340,7 +340,7 @@ INSERT INTO '.$prefixeTable.'config (param,value,comment)
pwg_query($query);
// fill languages table
- foreach ($languages->get_fs_languages() as $language_code => $fs_language)
+ foreach ($languages->fs_languages as $language_code => $fs_language)
{
$languages->perform_action('activate', $language_code);
}
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index b30cf6d07..ce77be6e9 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -770,8 +770,10 @@ $lang['[%s] Visit album %s'] = "[%s] Visit album %s";
$lang['[NBM] Problems or questions'] = "[NBM] Problems or questions";
$lang['[Simulation]'] = "[Simulation]";
$lang['Themes which need upgrade'] = 'Themes which need upgrade';
+$lang['Languages which need upgrade'] = 'Languages which need upgrade';
$lang['All themes are up to date.'] = 'All themes are up to date.';
$lang['All plugins are up to date.'] = 'All plugins are up to date.';
+$lang['All languages are up to date.'] = 'All languages are up to date.';
$lang['Visit theme site'] = 'Visit theme site';
$lang['New Version'] = 'New Version';
?> \ No newline at end of file
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index a68e5c270..d178b230e 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -781,8 +781,10 @@ $lang['Delete orphan tags'] = 'Supprimer les tags orphelins';
$lang['delete photo'] = 'supprimer la photo';
$lang['Remove from caddie'] = 'Retirer du panier';
$lang['Themes which need upgrade'] = 'Thèmes à mettre à jour';
+$lang['Languages which need upgrade'] = 'Langues à mettre à jour';
$lang['All themes are up to date.'] = 'Tous les thèmes sont à jour.';
$lang['All plugins are up to date.'] = 'Tous les plugins sont à jour.';
+$lang['All languages are up to date.'] = 'Toutes les langues sont à jour.';
$lang['Visit theme site'] = 'Visitez le site du thème';
$lang['New Version'] = 'Nouvelle version';
?>