Removed @deprecated from CSS inline/PHP output
[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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                      *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 }
42
43 // Default styles
44 $stylesList = array(
45                 'general.css',
46                 'ajax.css',
47 );
48
49 // Add stylesheet for installation
50 if ((isInstaller())) {
51         array_push($stylesList, 'install.css');
52 } // END - if
53
54 // When no CSS output-mode is set, set it to file-output
55 if (!isConfigEntrySet('css_php')) {
56         setConfigEntry('css_php', 'FILE');
57 } // END - if
58
59 // Get current theme
60 $currentTheme = getCurrentTheme();
61
62 // Has the theme changed?
63 if ($currentTheme != getSession('mailer_theme')) {
64         // Then set it
65         setMailerTheme($currentTheme);
66 } // END - if
67
68 // Output CSS files or content or link to css.php ?
69 if ((isCssOutputMode()) || (getCssPhp() == 'DIRECT')) {
70         // Load CSS files
71         $stylesList = merge_array($stylesList, getExtensionCssFiles());
72
73         // Generate base path
74         $basePath = getBasePathFromTheme($currentTheme);
75
76         // Output inclusion lines
77         foreach ($stylesList as $value) {
78                 // Only include found CSS files (to reduce 404 requests)
79                 $FQFN = $basePath . '/' . $value;
80
81                 // Do include only existing files and whose are not empty
82                 if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
83                         switch (getCssPhp()) {
84                                 case 'DIRECT': // Just link them (unsupported)
85                                         $GLOBALS['__page_header'] .= '<link rel="stylesheet" type="text/css" href="{%url=theme/' . getCurrentTheme() . '/' . $value . '%}" />';
86                                         break;
87
88                                 case 'FILE': // Output contents
89                                         $GLOBALS['__page_header'] .= removeDeprecatedComment(readFromFile($FQFN));
90                                         break;
91
92                                 default: // Invalid mode!
93                                         reportBug(__FILE__, __LINE__, sprintf('Invalid css_php value %s detected.', getCssPhp()));
94                                         break;
95                         } // END - switch
96                 } // END - if
97         } // END - foreach
98 } elseif ((isHtmlOutputMode()) || (getCssPhp() == 'INLINE')) {
99         // Load CSS files
100         $stylesList = merge_array($stylesList, getExtensionCssFiles());
101
102         // Generate base path
103         $basePath = getBasePathFromTheme(getCurrentTheme());
104
105         // Output inclusion lines
106         $OUT = '';
107         foreach ($stylesList as $value) {
108                 // Only include found CSS files (to reduce 404 requests)
109                 $FQFN = $basePath . '/' . $value;
110
111                 // Do include only existing files and whose are not empty
112                 if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
113                         // Load CSS content
114                         $OUT .= readFromFile($FQFN);
115                 } // END - if
116         } // END - foreach
117
118         // Load template
119         $GLOBALS['__page_header'] .= loadTemplate('css_inline', TRUE, removeDeprecatedComment($OUT));
120 } else {
121         // Now we load all CSS files from css.php!
122         $OUT = '<link rel="stylesheet" type="text/css" href="{%url=css.php';
123         if ((isInstaller())) {
124                 // Default theme first
125                 $OUT .= '?theme=' . getCurrentTheme() . '&amp;installing=1';
126         } else {
127                 // Add SVN revision to bypass caching problems
128                 $OUT .= '?rev=' . getCurrentRepositoryRevision();
129         }
130
131         // Close tag
132         $GLOBALS['__page_header'] .= $OUT . '%}{%ext,version=sql_patches%}" />';
133 }
134
135 // [EOF]
136 ?>