Fixes for broken order page and themes
[mailer.git] / inc / stylesheet.php
index a341fd599f49262318f0e6db42d1d79a6d5f2455..219918f6b25e32b310880266b7310ea89f22756b 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Style-Sheets werden hier abgelegt                *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
+if (!defined('__SECURITY')) {
+       die();
 }
 
 // Default styles
 $STYLES = array(
-               "general.css",
+               'general.css',
 );
 
 // Add stylesheet for installation
-if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!isBooleanConstantAndTrue('mxchange_installed')) || (isset($_GET['installing']))) $STYLES[] = "install.css";
+if ((isInstallationPhase())) $STYLES[] = 'install.css';
 
 // When no CSS output-mode is set, set it to file-output
-if (empty($_CONFIG['css_php'])) $_CONFIG['css_php'] = "FILE";
+if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', 'FILE');
 
 // Output CSS files or content or link to css.php ?
-if (($CSS == "1") || ($_CONFIG['css_php'] == "DIRECT"))
-{
+if ((getOutputMode() == '1') || (getConfig('css_php') == 'DIRECT')) {
        // Load CSS files
-       if (is_array($EXT_CSS_FILES))
-       {
-               // Load extension's CSS files
-               foreach ($EXT_CSS_FILES as $value) $STYLES[] = $value;
-       }
+       $STYLES = merge_array($STYLES, getExtensionCssFiles());
 
-       // Create missing configuration file
-       if (!function_exists('GET_CURR_THEME')) {
-               // Dummy for e.g. down database links
-               function GET_CURR_THEME () {
-                       return "default";
-               }
-       }
+       // Generate base path
+       $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme());
 
        // Output inclusion lines
-       foreach ($STYLES as $value)
-       {
+       foreach ($STYLES as $value) {
                // Only include found CSS files (to reduce 404 requests)
-               $BASE = PATH."theme/".GET_CURR_THEME()."/css/";
-               $file = $BASE.$value;
+               $FQFN = $basePath . $value;
+
                // Do include only existing files and whose are not empty
-               if ((file_exists($file)) && (filesize($file) > 0))
-               {
-                       switch ($_CONFIG['css_php'])
-                       {
-                       case "DIRECT":
-                               OUTPUT_HTML("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"".URL."/".$BASE."\">");
-                               break;
-
-                       case "FILE":
-                               $load = implode("", file($file));
-                               OUTPUT_HTML($load);
-                               break;
-                       }
-               }
-       }
-}
- else
-{
+               if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
+                       switch (getConfig('css_php')) {
+                               case 'DIRECT': // Just link them (unsupported)
+                                       outputHtml('<link rel="stylesheet" type="text/css" href="{?URL?}/theme/' . getCurrentTheme() . '/' . $value . '" />');
+                                       break;
+
+                               case 'FILE': // Output contents
+                                       outputHtml(readFromFile($FQFN));
+                                       break;
+
+                               default: // Invalid mode!
+                                       debug_report_bug(sprintf("Invalid css_php value %s detected.", getConfig('css_php')));
+                                       break;
+                       } // END - switch
+               } // END - if
+       } // END - foreach
+} elseif ((getOutputMode() == '0') || (getConfig('css_php') == 'INLINE')) {
+       // Load CSS files
+       $STYLES = merge_array($STYLES, getExtensionCssFiles());
+
+       // Generate base path
+       $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme());
+
+       // Output inclusion lines
+       $OUT = '';
+       foreach ($STYLES as $value) {
+               // Only include found CSS files (to reduce 404 requests)
+               $FQFN = $basePath . $value;
+
+               // Do include only existing files and whose are not empty
+               if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
+                       // Load CSS content
+                       $OUT .= readFromFile($FQFN);
+               } // END - if
+       } // END - foreach
+
+       // Load template
+       loadTemplate('css_inline', false, $OUT);
+} else {
        // Now we load all CSS files from css.php!
-       OUTPUT_HTML("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"".URL."/css.php", false);
-       if (isBooleanConstantAndTrue('mxchange_installing'))
-       {
+       outputHtml('<link rel="stylesheet" type="text/css" href="{?URL?}/css.php', false);
+       if ((isInstallationPhase())) {
                // Default theme first
-               $NEW_THEME = "default";
-               if (!empty($_GET['theme'])) $NEW_THEME = $_GET['theme'];
-               if (!empty($_POST['theme'])) $NEW_THEME = $_POST['theme'];
-               OUTPUT_HTML("?theme=".$NEW_THEME."&amp;installing=1", false);
+               $newTheme = 'default';
+               if (isGetRequestElementSet('theme'))  $newTheme = getRequestElement('theme');
+               if (isPostRequestElementSet('theme')) $newTheme = SQL_ESCAPE(postRequestElement('theme'));
+               outputHtml('?theme=' . $newTheme . '&amp;installing=1', false);
+       } else {
+               // Add SVN revision to bypass caching problems
+               outputHtml('?rev=' . getConfig('CURR_SVN_REVISION'));
        }
-       OUTPUT_HTML("\">");
+
+       // Close tag
+       outputHtml('" />');
 }
 
-//
+// [EOF]
 ?>