Hallo,
ich habs mal mit einem UDT das ich im Forum gefunden habe umgestzt, kann leider auch kein credit geben da ich nicht mehr weiss wo ich das gefunden habe..
Habe aber leider keine ahnung ob das in de Aktuellen version funktioniert.
Switcher menü im template:
Code: Select all
/***********************************************
* Writes the accessibility menu
************************************************/
echo "<a href=\"switcher.php?set=54\"><img alt='Normal' title='Normal' src='/dein bild.png' /></a>";
echo "<a href=\"switcher.php?set=49\"><img alt='Kontrast' title='Kontrast' src='/dein bildt.png' /></a>";
{set_css} wird nach dem Stylsheet aufruf im template eingesetzt.
Code: Select all
/***********************************************
* reads a cookie to get values for the accessibility options
* these are stored in an array in the cookie as:
* sitestyle('default', 'larger', 'colour_option1') etc...
************************************************/
if(isset($_COOKIE['sitestyle'])){
foreach($_COOKIE['sitestyle'] as $style) {
$css_tag = "<link type=\"text/css\" rel=\"stylesheet\" ";
$css_tag .= "href=\"stylesheet.php?";
$css_tag .= "cssid=$style\" media=\"screen\" />";
echo $css_tag;
}
}
stylesheet.php wird im verzeichnis der cmsms installation gespeichert
Code: Select all
<?php
// Parse pretty URLS
$url = substr($_SERVER['REQUEST_URI'],strlen($_SERVER['PHP_SELF']));
$url = rtrim($url,'/');
$matches = array();
if( preg_match('+^/[0-9]*/.*?$+',$url,$matches) )
{
$tmp = substr($url,1);
list($_GET['cssid'],$_GET['mediatype']) = explode('/',$tmp);
}
else if( preg_match('+^/[0-9]*$+',$url,$matches) )
{
$_GET['cssid'] = (int)substr($url,1);
}
//require('config.php');//default
require('fileloc.php');
require(CONFIG_FILE_LOCATION);
require(dirname(__FILE__).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'misc.functions.php');
$mediatype = '';
if (isset($_GET["mediatype"])) $mediatype = $_GET["mediatype"];
$cssid = '';
if (isset($_GET['cssid'])) $cssid = $_GET['cssid'];
$name = '';
if (isset($_GET['name'])) $name = $_GET['name'];
$stripbackground = false;
if (isset($_GET["stripbackground"])) $stripbackground = true;
if ($name == '' && $cssid == '') return '';
// Get the hash filename
//$hashfile = $config['root_path'].DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'csshash.dat';
$hashfile = TMP_CACHE_LOCATION . DIRECTORY_SEPARATOR . 'csshash.dat';
// Get the cache
$hashmtime = @filemtime($hashfile);
$hash = csscache_csvfile_to_hash($hashfile);
// Get the etag header if set
//print_r( $_SERVER ); echo "\n";
$etag = '';
if( function_exists('getallheaders') )
{
$headers = getallheaders();
if (isset($headers['If-None-Match']) )
{
$etag = trim($headers['If-None-Match'],'"');
}
}
else if( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
{
$etag = trim($_SERVER['HTTP_IF_NONE_MATCH']);
$etag = trim($etag,'"');
}
//echo "DEBUG: cssid = $cssid, hashval = \"{$hash[$cssid]}\" etag = \"$etag\" \n";
//echo "DEBUG: ".strcmp($hash[$cssid],$etag)."\n";
//if( $hash[$cssid] != $etag ) die('uhoh');
if( isset($hash[$cssid]) && strcmp($hash[$cssid],$etag) == 0 &&
$config['debug'] != true )
{
// we have a value
// and it's fine
// just have to output a 304
header('Etag: "'.$etag.'"');
header('HTTP/1.1 304 Not Modified');
exit;
}
//
// Either we don't have a value for this cache
// or the hash is out of date
// so get the styesheets,
//
// connect to the database
require(dirname(__FILE__).DIRECTORY_SEPARATOR.'version.php');
//require(dirname(__FILE__).DIRECTORY_SEPARATOR.'fileloc.php'); //is included in top now
require(cms_join_path(dirname(__FILE__),'lib','config.functions.php'));
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'misc.functions.php');
require(cms_join_path(dirname(__FILE__),'lib','classes','class.global.inc.php'));
require(cms_join_path(dirname(__FILE__),'lib','adodb.functions.php'));
$gCms =& new CmsObject();
load_adodb();
$db =& $gCms->GetDb();
require(cms_join_path(dirname(__FILE__),'lib','page.functions.php'));
// extract the stylesheet(s)
$sql="SELECT css_text, css_name FROM ".$config['db_prefix']."css WHERE css_id = ".$db->qstr($cssid);
$row = $db->GetRow($sql);
// calculate the new etag
$etag = md5($row['css_text']);
// update the hash cache
$hash[$cssid] = $etag;
csscache_hash_to_csvfile($hashfile,$hash);
// add a comment at the start
$css = "/* Start of CMSMS style sheet '{$row['css_name']}' */\n{$row['css_text']}\n/* End of '{$row['css_name']}' */\n\n";
// set encoding
$encoding = '';
if ($config['admin_encoding'] != '')
$encoding = $config['admin_encoding'];
elseif ($config['default_encoding'] != '')
$encoding = $config['default_encoding'];
else
$encoding = 'UTF-8';
//
// Begin output
//
// postprocess
if ($stripbackground)
{
#$css = preg_replace('/(\w*?background-color.*?\:\w*?).*?(;.*?)/', '', $css);
$css = preg_replace('/(\w*?background-color.*?\:\w*?).*?(;.*?)/', '\\1transparent\\2', $css);
$css = preg_replace('/(\w*?background-image.*?\:\w*?).*?(;.*?)/', '', $css);
}
if( isset($config['output_compression']) && $config['debug'] != true )
{
@ob_start('ob_gzhandler');
}
$max_age = (int)get_site_preference('css_max_age',0);
header("Content-Type: text/css; charset=$encoding");
$datestr = gmdate('D, d M Y H:i:s',$hashmtime).' GMT';
header("Last-Modified: ".$datestr);
if( $max_age > 0 )
{
$datestr = gmdate('D, d M Y H:i:s',$hashmtime+$max_age).' GMT';
header("Expires: ".$datestr);
header("Cache-Control: must-revalidate");
// no caching?
//header("Cache-Control: max-age=$max_age, s-max-age=$max_age, must-revalidate");
}
header('Etag: "'.$etag.'"');
echo $css;
// EOF
?>
switcher.php
Code: Select all
<?php
/***********************************************
* sets a cookie with values taken from the accessibility options
************************************************/
// This array lists the "acceptable" styles
$accept = array('54','46', '49', '48'); /*ADD YOUR OPTIONS HERE*/
// add more styles separated by commas
// Get style from a query string (e.g. from a link),
// or from a form.
if(isset($_REQUEST['set'])){
$style = trim(strip_tags($_REQUEST['set']));
} else if(isset($_POST['set'])){
$style = trim(strip_tags($_POST['set']));
} else {
// Unknown request
$style = false;
}
// Check if the requested stylesheet is "acceptable"
if(($style !== false) && (in_array($style, $accept))){
if ($style == '54') {
foreach($_COOKIE['sitestyle'] as $style) {
setcookie("sitestyle[$style]", "", time()-86400, '/');
}
} else {
setcookie("sitestyle[$style]", $style, time()+86400, '/');//day
}
}
if(isset($_REQUEST['ref']) || (isset($_POST['ref']))){
if(isset($_REQUEST['ref'])){
$ref = $_REQUEST['ref'];
}
else {
$ref = $_POST['ref'];
}
header("Location: $ref");
exit;
}
else if(isset($_SERVER['HTTP_REFERER'])){
// Send the user back to the refering page
header("Location: ". $_SERVER['HTTP_REFERER']);
exit;
}
else {
// No HTTP referrer, send them back to the home page
header("Location: http://localhost"); /*ADD YOUR SERVER HERE*/
exit;
}
?>
/************************ End of Code *************************/
Falls ich nix vergessen habe dürfte das alles sein, es funktionierte in der Version 1.4.
Wie das dann so aussieht kannst Du hier sehen
http://www.gnesau.at/