]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-theme_import.php
3a9bed37d0696064db6ca87c0fd1731fb1de64ea
[mailer.git] / inc / modules / admin / what-theme_import.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/12/2004 *
4  * ===================                          Last change: 11/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-theme_import.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Import of new themes                             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Importieren von neuen Themes                     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (!isExtensionActive('theme')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
50         return;
51 } // END - if
52
53 // Switch to testing mode
54 $GLOBALS['theme_mode'] = 'test';
55
56 // Import selected theme if not present
57 if (isPostRequestParameterSet('theme')) {
58         // Check if theme is there
59         if (!ifThemeExists(postRequestParameter('theme'))) {
60                 // Import theme
61                 $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestParameter('theme')));
62
63                 // Is the theme readable?
64                 if (isIncludeReadable($inc)) {
65                         // Load the theme header file
66                         loadInclude($inc);
67
68                         // Register it ith the exchange
69                         SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`,`theme_active`,`theme_ver`,`theme_name`)
70 VALUES ('%s','N','%s','%s')",
71                                 array(
72                                         postRequestParameter('theme'),
73                                         $GLOBALS['theme_data']['version'],
74                                         $GLOBALS['theme_data']['name']
75                                 ), __FILE__, __LINE__);
76
77                         // Destroy cache
78                         rebuildCache('themes', 'them');
79
80                         // Prepare message
81                         $message = getMaskedMessage('ADMIN_THEME_IMPORTED', postRequestParameter('theme'));
82                 } else {
83                         // Include file not found!
84                         $message = getMaskedMessage('ADMIN_THEME_INC_404', postRequestParameter('theme'));
85                 }
86         } else {
87                 // Theme already imported
88                 $message = getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', postRequestParameter('theme'));
89         }
90
91         // Output message
92         loadTemplate('admin_settings_saved', false, $message);
93 } // END - if
94
95 // Initialize array
96 $THEMES = array(
97         'theme_unix'    => array(), // Unix name from filesystem
98         'theme_name'    => array(), // Title
99         'theme_author'  => array(), // Theme author's name
100         'theme_email'   => array(), // Author's email address
101         'theme_url'     => array(), // URL were you can download it from
102         'theme_version' => array(), // Version number of theme
103 );
104
105 // Read directory "themes"
106 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
107
108 // Walk through all entries and add it
109 foreach ($includes as $inc) {
110         // Get directory from it
111         $dir = basename(dirname($inc));
112
113         // Load include file
114         loadInclude($inc);
115
116         // Add found theme to array
117         $THEMES['theme_unix'][]   = $dir;
118         $THEMES['theme_name'][]   = $GLOBALS['theme_data']['name'];
119         $THEMES['theme_author'][] = $GLOBALS['theme_data']['author'];
120         $THEMES['theme_email'][]  = $GLOBALS['theme_data']['email'];
121         $THEMES['theme_url'][]    = $GLOBALS['theme_data']['url'];
122         $THEMES['theme_version'][]    = $GLOBALS['theme_data']['version'];
123 } // END - while
124
125 // Sort array by Uni* name
126 array_pk_sort($THEMES, array('theme_name'));
127
128 // Generate output lines for the template
129 $OUT = '';
130 foreach ($THEMES['theme_unix'] as $key => $unix) {
131         // Already installed is default
132         $formContent = '<div class="notice">' . getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', $unix) . '</div>';
133
134         // Check if current theme is already imported or not
135         if (!ifThemeExists($unix)) {
136                 // Theme not installed
137                 $formContent = loadTemplate('admin_import_theme_form', true, $unix);
138         } // END - if
139
140         // Prepare content
141         $content = array(
142                 'unix'          => $unix,
143                 'theme_name'    => $THEMES['theme_name'][$key],
144                 'theme_email'   => $THEMES['theme_email'][$key],
145                 'theme_author'  => $THEMES['theme_author'][$key],
146                 'theme_url'     => $THEMES['theme_url'][$key],
147                 'theme_version' => $THEMES['theme_version'][$key],
148                 'form_content'  => $formContent
149         );
150
151         // Add row template
152         $OUT .= loadTemplate('admin_import_theme_row', true, $content);
153 } // END - foreach
154
155 if (empty($OUT)) {
156         // No themes found???
157         $OUT .= loadTemplate('admin_import_theme_none', true, loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_THEMES_FOUND--}'));
158 } // END - if
159
160 // Load template
161 loadTemplate('admin_import_theme', false, $OUT);
162
163 // [EOF]
164 ?>