Main Page | Directories | File List | File Members

theme.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: theme.php 5187 2005-12-01 16:22:29Z yeupou $
00006 #
00007 #  Copyright 2002-2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 # 
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 # theme value is fetched by getting the cookie. But we keep in the
00024 # database the setting, so someone using another computer can easily
00025 # remember the theme he previously chose.
00026 
00027 # Jump to the next theme available and set cookie appropriately
00028 function theme_rotate_jump($num) 
00029 {
00030 
00031   utils_get_content("forbidden_theme");
00032   $theme = theme_list(1);
00033  
00034   $num++;
00035         
00036   # if the num is a value superior of the number of themes
00037   # we reset to 0
00038   if ($num == count($theme)) 
00039     { $num = "0"; }
00040   
00041   # keep in mind the new number
00042   setcookie("SV_THEME_ROTATE_NUMERIC", $num, time() + 60*60*24*365, $GLOBALS['sys_home']);
00043 
00044   # associate this number with a theme
00045   setcookie("SV_THEME_ROTATE", $theme[$num], time() + 60*60*24, $GLOBALS['sys_home']);
00046 }
00047 
00048 # Return an array with all the themes, but not the special case "rotate" 
00049 # and "random"
00050 # By default, it does not skip forbidden themes (strict=0), in order to
00051 # avoid doing too many unrequired tests.
00052 function theme_list ($strict=0) 
00053 {
00054   if ($strict)
00055     { utils_get_content("forbidden_theme"); }
00056 
00057   # Feed the array
00058   $theme = array();
00059   $dir = opendir($GLOBALS['sys_www_topdir']."/css/");
00060   while ($file = readdir($dir)) 
00061     {
00062       # take only correct css files
00063       if (preg_match("/^(.*)\.css$/", $file, $matches)) 
00064         {
00065           # base.css and printer.css are always ignored
00066           if ($matches[1] != "base" && $matches[1] != "printer") {
00067             if (!$strict)
00068               {
00069                 $theme[] = $matches[1];
00070               }
00071             elseif (!preg_match($GLOBALS['forbid_theme_regexp'], $matches[1]))
00072               {
00073                 $theme[] = $matches[1];
00074               }
00075           }
00076         }
00077     }
00078   closedir($dir);
00079   
00080   # Sort themes
00081   asort($theme);
00082 
00083   # No result? Return only the default theme. 
00084   # (If there were no result, there is a problem anyway somewhere in the
00085   # installation)
00086   if (!count($theme))
00087     {
00088       $theme[] = $GLOBALS['sys_themedefault'];
00089     }
00090   return $theme;
00091 }
00092 
00093 
00094 
00095 ##### THEME SELECTION
00096 
00169 

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4