Mit diesem Code habe ich das gemacht!
In TYPO3 einfach laden und user_isStyle($identifier) kann als condition genommen werden damit man dann auch den Menüs oder generierte Grafiken richtig anpassen kann.
<?php
/**
* StyleSwitcher Klasse zum implimentieren in TYPO3
*
* @author Tim Lochmüller
* @copyright Tim Lochmüller
* @since 2007
* @version 0.1
*
*/
class MyStyleSwitcher {
/**
* The Value of the Default Theme
*
* @var String
*/
var $defaultTheme = 'default';
/**
* The Name of the Session where the Style is storaged
*
* @var unknown_type
*/
var $storename = 'WebseiteStyle';
/**
* Based on 'SESSION' or 'COOKIE'
*
* @var unknown_type
*/
var $storetype = 'COOKIE';
var $lastSet = false;
/**
* TYPO3 Funktion to check the status of the Theme
*
* @return true or false
*/
function isStyle($identifier){
if($this->lastSet){
if($this->lastSet == $identifier)
return true;
return false;
} // if
if($this->storetype == 'SESSION') {
session_start();
global $_SESSION;
if(!isset($_SESSION[$this->storename]))
$this->setStyle($this->defaultTheme);
if($_SESSION[$this->storename] == $identifier)
return true;
return false;
} else {
if(!isset($_COOKIE[$this->storename]))
$this->setStyle($this->defaultTheme);
if($_COOKIE[$this->storename] == $identifier)
return true;
return false;
} // if
} // function - isStyle
/**
* Set the Style to another value
*
* @param String $identifier
*/
function setStyle($identifier){
if($this->storetype == 'SESSION') {
session_start();
global $_SESSION;
$_SESSION[$this->storename] = $identifier;
} else {
setcookie($this->storename, $identifier, time()+60*60*24*30, '/');
} // if
$this->lastSet = $identifier;
} // function - setStyle
} // class - StyleSwitcher
// Start
$myStyle = new MyStyleSwitcher();
$myStyle->sessionname = 'myStyle';
$myStyle->defaultTheme = 'theme-a';
if(isset($_GET['setStyle'])) $myStyle->setStyle($_GET['setStyle']);
function user_isStyle($identifier) {
global $myStyle;
return $myStyle->isStyle($identifier);
}
?> |