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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 // Switch to testing mode
47 $GLOBALS['theme_mode'] = 'test';
49 // Import selected theme if not present
50 if (isPostRequestElementSet('theme')) {
51 // Check if theme is there
52 if (!ifThemeExists(postRequestElement('theme'))) {
53 // Is the theme readable?
54 if (isThemeReadable(postRequestElement('theme'))) {
55 // Load the theme header file
56 loadInclude(sprintf('theme/%s/theme.php', sqlEscapeString(postRequestElement('theme'))));
58 // Register it ith the exchange
59 sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`, `theme_active`, `theme_ver`, `theme_name`)
60 VALUES ('%s','N','%s','%s')",
62 postRequestElement('theme'),
63 $GLOBALS['theme_data']['version'],
64 $GLOBALS['theme_data']['name']
65 ), __FILE__, __LINE__);
68 rebuildCache('themes', 'themes');
71 $message = '{%message,ADMIN_THEME_IMPORTED=' . postRequestElement('theme') . '%}';
73 // Include file not found
74 $message = '{%message,ADMIN_THEME_INC_404=' . postRequestElement('theme') . '%}';
77 // Theme already imported
78 $message = '{%message,ADMIN_THEME_ALREADY_INSTALLED=' . postRequestElement('theme') . '%}';
82 displayMessage($message);
87 'theme_unix' => array(), // Unix name from filesystem
88 'theme_name' => array(), // Title
89 'theme_author' => array(), // Theme author's name
90 'theme_email' => array(), // Author's email address
91 'theme_url' => array(), // URL were you can download it from
92 'theme_version' => array(), // Version number of theme
95 // Read directory "themes"
96 $includes = getArrayFromDirectory('theme/', '', FALSE, TRUE, array('css', 'images'));
98 // Walk through all entries and add it
99 foreach ($includes as $inc) {
100 // Get directory from it
101 $dir = basename(dirname($inc));
106 // Add found theme to array
107 array_push($themes['theme_unix'] , $dir);
108 array_push($themes['theme_name'] , $GLOBALS['theme_data']['name']);
109 array_push($themes['theme_author'] , $GLOBALS['theme_data']['author']);
110 array_push($themes['theme_email'] , $GLOBALS['theme_data']['email']);
111 array_push($themes['theme_url'] , $GLOBALS['theme_data']['url']);
112 array_push($themes['theme_version'], $GLOBALS['theme_data']['version']);
115 // Sort array by Uni* name
116 array_pk_sort($themes, array('theme_name'));
118 // Generate output lines for the template
120 foreach ($themes['theme_unix'] as $key => $unix) {
121 // Already installed is default
122 $formContent = '<div class="notice">{%message,ADMIN_THEME_ALREADY_INSTALLED=' . $unix . '%}</div>';
124 // Check if current theme is already imported or not
125 if (!ifThemeExists($unix)) {
126 // Theme not installed
127 $formContent = loadTemplate('admin_import_theme_form', TRUE, $unix);
133 'theme_name' => $themes['theme_name'][$key],
134 'theme_email' => $themes['theme_email'][$key],
135 'theme_author' => $themes['theme_author'][$key],
136 'theme_url' => $themes['theme_url'][$key],
137 'theme_version' => $themes['theme_version'][$key],
138 'form_content' => $formContent
142 $OUT .= loadTemplate('admin_import_theme_row', TRUE, $content);
146 // No themes found???
147 $OUT .= loadTemplate('admin_import_theme_none', TRUE, displayMessage('{--ADMIN_NO_THEMES_FOUND--}', TRUE));
151 loadTemplate('admin_import_theme', FALSE, $OUT);