From 395b09de3d1dfc40411df71c8752dcc368ab4ea9 Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 15 Mar 2010 13:35:35 +0000 Subject: feature 1507: ability to install themes directly from piwigo.org/ext. The theme manager backend for installation is the plugin manager backend, because they are very close. thanks to feature:1502, installing a theme and installing a plugin are very similare operations. The only differences are the installation directory and the main file to find in the archive. This is only the very first step, the "add new theme" screen needs many improvements, to begin with display style. git-svn-id: http://piwigo.org/svn/trunk@5143 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes_new.php | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 admin/themes_new.php (limited to 'admin/themes_new.php') diff --git a/admin/themes_new.php b/admin/themes_new.php new file mode 100644 index 000000000..c606f97b1 --- /dev/null +++ b/admin/themes_new.php @@ -0,0 +1,133 @@ +extract_plugin_files( + 'install', + $_GET['revision'], + $_GET['extension'], + 'theme' + ); + + redirect($base_url.'&installstatus='.$install_status); +} + +// +-----------------------------------------------------------------------+ +// | installation result | +// +-----------------------------------------------------------------------+ + +if (isset($_GET['installstatus'])) +{ + switch ($_GET['installstatus']) + { + case 'ok': + array_push( + $page['infos'], + l10n('Theme has been successfully installed') + ); + 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).'), $_GET['installstatus']) + ); + } +} + +// +-----------------------------------------------------------------------+ +// | template output | +// +-----------------------------------------------------------------------+ + +$template->set_filenames(array('themes' => 'themes_new.tpl')); + +if ($themes->get_server_plugins(true, 'theme')) +{ + foreach($themes->server_plugins as $theme) + { + $url_auto_install = htmlentities($base_url) + . '&revision=' . $theme['revision_id'] + . '&extension=' . $theme['extension_id'] + ; + + $template->append( + 'new_themes', + array( + 'name' => $theme['extension_name'], + 'src' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/thumbnail.jpg', + 'install_url' => $url_auto_install, + ) + ); + } +} +else +{ + array_push($page['errors'], l10n('Can\'t connect to server.')); +} + +$template->assign_var_from_handle('ADMIN_CONTENT', 'themes'); +?> \ No newline at end of file -- cgit v1.2.3