2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/12/2004 *
4 * =================== Last change: 11/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-theme_import.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Import of new themes *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Importieren von neuen Themes *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
47 if (!isExtensionActive('theme')) {
48 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
52 // Switch to testing mode
53 $GLOBALS['theme_mode'] = 'test';
55 // Import selected theme if not present
56 if (isPostRequestParameterSet('theme')) {
57 // Check if theme is there
58 if (!ifThemeExists(postRequestParameter('theme'))) {
60 $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestParameter('theme')));
62 // Is the theme readable?
63 if (isIncludeReadable($inc)) {
64 // Load the theme header file
67 // Register it ith the exchange
68 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`,`theme_active`,`theme_ver`,`theme_name`)
69 VALUES ('%s','N','%s','%s')",
71 postRequestParameter('theme'),
72 $GLOBALS['theme_data']['version'],
73 $GLOBALS['theme_data']['name']
74 ), __FILE__, __LINE__);
77 rebuildCache('themes', 'them');
80 $message = getMaskedMessage('ADMIN_THEME_IMPORTED', postRequestParameter('theme'));
82 // Include file not found!
83 $message = getMaskedMessage('ADMIN_THEME_INC_404', postRequestParameter('theme'));
86 // Theme already imported
87 $message = getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', postRequestParameter('theme'));
91 loadTemplate('admin_settings_saved', false, $message);
96 'theme_unix' => array(), // Unix name from filesystem
97 'theme_name' => array(), // Title
98 'theme_author' => array(), // Theme author's name
99 'theme_email' => array(), // Author's email address
100 'theme_url' => array(), // URL were you can download it from
101 'theme_ver' => array(), // Version number of theme
104 // Read directory "themes"
105 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
107 // Walk through all entries and add it
108 foreach ($includes as $inc) {
109 // Get directory from it
110 $dir = basename(dirname($inc));
115 // Add found theme to array
116 $THEMES['theme_unix'][] = $dir;
117 $THEMES['theme_name'][] = $GLOBALS['theme_data']['name'];
118 $THEMES['theme_author'][] = $GLOBALS['theme_data']['author'];
119 $THEMES['theme_email'][] = $GLOBALS['theme_data']['email'];
120 $THEMES['theme_url'][] = $GLOBALS['theme_data']['url'];
121 $THEMES['theme_ver'][] = $GLOBALS['theme_data']['version'];
124 // Sort array by Uni* name
125 array_pk_sort($THEMES, array('theme_name'));
127 // Generate output lines for the template
129 foreach ($THEMES['theme_unix'] as $key => $unix) {
130 // Already installed is default
131 $formContent = '<div class="admin_note">' . getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', $unix) . '</div>';
133 // Check if current theme is already imported or not
134 if (!ifThemeExists($unix)) {
135 // Theme not installed
136 $formContent = loadTemplate('admin_theme_import_form', true, $unix);
143 'name' => $THEMES['theme_name'][$key],
144 'email' => $THEMES['theme_email'][$key],
145 'author' => $THEMES['theme_author'][$key],
146 'link' => generateDerefererUrl($THEMES['theme_url'][$key]),
147 'url' => $THEMES['theme_url'][$key],
148 'version' => $THEMES['theme_ver'][$key],
149 'form' => $formContent
153 $OUT .= loadTemplate('admin_theme_import_row', true, $content);
160 // No themes found???
161 $OUT .= loadTemplate('admin_theme_import_none', true, loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_THEMES_FOUND')));
165 loadTemplate('admin_theme_import', false, $OUT);