First batch of removal of the headers needed for revision-functions.php
[mailer.git] / inc / stylesheet.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/29/2003 *
4  * ===================                          Last change: 12/03/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : stylesheet.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Stylesheets are stored here                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Style-Sheets werden hier abgelegt                *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         die();
36 }
37
38 // Default styles
39 $stylesList = array(
40                 'general.css',
41                 'ajax.css',
42 );
43
44 // Add stylesheet for installation
45 if ((isInstaller())) {
46         array_push($stylesList, 'install.css');
47 } // END - if
48
49 // When no CSS output-mode is set, set it to file-output
50 if (!isConfigEntrySet('css_php')) {
51         setConfigEntry('css_php', 'FILE');
52 } // END - if
53
54 // Get current theme
55 $currentTheme = getCurrentTheme();
56
57 // Has the theme changed?
58 if ($currentTheme != getSession('mailer_theme')) {
59         // Then set it
60         setMailerTheme($currentTheme);
61 } // END - if
62
63 // Output CSS files or content or link to css.php ?
64 if ((isCssOutputMode()) || (getCssPhp() == 'DIRECT')) {
65         // Load CSS files
66         $stylesList = merge_array($stylesList, getExtensionCssFiles());
67
68         // Generate base path
69         $basePath = getBasePathFromTheme($currentTheme);
70
71         // Output inclusion lines
72         foreach ($stylesList as $value) {
73                 // Only include found CSS files (to reduce 404 requests)
74                 $FQFN = $basePath . '/' . $value;
75
76                 // Do include only existing files and whose are not empty
77                 if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
78                         switch (getCssPhp()) {
79                                 case 'DIRECT': // Just link them (unsupported)
80                                         $GLOBALS['__page_header'] .= '<link rel="stylesheet" type="text/css" href="{%url=theme/' . getCurrentTheme() . '/' . $value . '%}" />';
81                                         break;
82
83                                 case 'FILE': // Output contents
84                                         $GLOBALS['__page_header'] .= removeDeprecatedComment(readFromFile($FQFN));
85                                         break;
86
87                                 default: // Invalid mode!
88                                         reportBug(__FILE__, __LINE__, sprintf('Invalid css_php value %s detected.', getCssPhp()));
89                                         break;
90                         } // END - switch
91                 } // END - if
92         } // END - foreach
93 } elseif ((isHtmlOutputMode()) || (getCssPhp() == 'INLINE')) {
94         // Load CSS files
95         $stylesList = merge_array($stylesList, getExtensionCssFiles());
96
97         // Generate base path
98         $basePath = getBasePathFromTheme(getCurrentTheme());
99
100         // Output inclusion lines
101         $OUT = '';
102         foreach ($stylesList as $value) {
103                 // Only include found CSS files (to reduce 404 requests)
104                 $FQFN = $basePath . '/' . $value;
105
106                 // Do include only existing files and whose are not empty
107                 if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
108                         // Load CSS content
109                         $OUT .= readFromFile($FQFN);
110                 } // END - if
111         } // END - foreach
112
113         // Load template
114         $GLOBALS['__page_header'] .= loadTemplate('css_inline', TRUE, removeDeprecatedComment($OUT));
115 } else {
116         // Now we load all CSS files from css.php!
117         $OUT = '<link rel="stylesheet" type="text/css" href="{%url=css.php';
118
119         if ((isInstaller())) {
120                 // Default theme first
121                 $OUT .= '?theme=' . getCurrentTheme() . '&amp;installing=1';
122         } else {
123                 // Add version + a number to bypass caching problems
124                 $OUT .= '?ver={?FULL_VERSION?}&amp;cb={?CACHE_BUSTER?}';
125         }
126
127         // Close tag
128         $GLOBALS['__page_header'] .= $OUT . '%}{%ext,version=sql_patches%}" />';
129 }
130
131 // [EOF]
132 ?>