example.php
<?php
error_reporting
(E_ALL E_STRICT);
ini_set('display_errors'true);
ini_set('error_log''/home/.becker/anarion/php.log');
ini_set('log_errors'true);
ob_start('ob_gzhandler');
date_default_timezone_set('America/Chicago');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <title>PHP Styleswitcher, version 2</title>
 <?php
 
// BEGIN STYLESWITCHER CODE
 
if(!isset($reqPath)){ $reqPath "./"; }
 require_once(
$reqPath ."Styleswitcher.php");
 
$ss = new Styleswitcher();
 
$ss->addStyle("basic""basic.css"""""true);
 
 
$ss->addStyle("blue""blue.css");
 
$ss->addStyle("green""green.css");
 
$ss->addStyle("large""large.css");
 
$ss->addStyle("normal""small.css");

 
$ss->createSet("fonts");
 
$ss->addStyleToSet("fonts""large");
 
$ss->addStyleToSet("fonts""normal"true);

 
$ss->createSet("style");
 
$ss->addStyleToSet("style""blue"true);
 
$ss->addStyleToSet("style""green");

 
$ss->cookieDomain "."$_SERVER['HTTP_HOST'];
 
$ss->cookieName "cwStyle";
 
 
$ss->printStyles();
 
// End Styleswitcher code
 
?>
 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
  </script>
  <script type="text/javascript">
  _uacct = "UA-1853623-1";
  urchinTracker();
  </script>
</head>
<body>
 <div>
  <h1>PHP Styleswitcher, version 2</h1>
 
  <h2>Example page</h2>
  
  <div id="navigation">
  <ul>
   <li> <a href="../">Home</a></li>
   <li> <a href="../v2/">What's New</a></li>
   <li> <a href="../v2/download.php">Download</a></li>
   <li> <a href="../v2/example.php" class="selected">Example</a></li>
   <li> <a href="../v2/docs.php">Documentation</a></li>
   <li> <a href="../v2/sites.php">Sites</a></li>
   <li> <a href="../v1/">Old Tutorial</a></li>
  </ul>
 </div>
 
  <p>This page shows how the styleswitcher works, as well as giving an example for how multiple styles can be changed. This page has <strong>five</strong> stylesheets. They break done like this:</p>
  
  <ol>
   <li> <strong>basic.css</strong> - This stylesheet is set up as "static" which means it is always present.</li>
   <li> <strong>blue.css</strong> - The first of the "visual" aspects of this page (the default blue theme).</li>
   <li> <strong>green.css</strong> - The second theme.</li>
   <li> <strong>small.css</strong> - The default font size.</li>
   <li> <strong>large.css</strong> - A larger font stylesheet.</li>
  </ol>
  
  <p>The stylesheets, except for the "basic.css" file, are broken into two sets: fonts and style.</p>
 
  <?php
  
if($ss->styleCookieSet()){ print "<p>You currently have a style cookie for this page.</p>"; }
  else { print 
"<p>You do not have a style cookie set for this page.</p>"; } 
  
?>
  
  <p><a href="source.php">View source</a></p>
  
  <hr />
  
  <form action="switcher.php" method="post">
   <!-- Automatically redirect to the referer -->
   <input type="hidden" name="referer" id="referer" value="<?php print $_SERVER['PHP_SELF']; ?>" />
   <input type="hidden" name="inputStyle1" id="inputStyle1" value="fonts" />
   <input type="hidden" name="inputStyle2" id="inputStyle2" value="style" />
   
   <p>Use this form to change the style of this page:</p>
   
   <strong>Font Style:</strong><br />
   <input type="radio" name="fonts" id="fontStyle1" value="normal" <?php $ss->printSetInputChecked("fonts""normal"); ?>/> <label for="fontStyle1">Normal text (smaller)</label>
   <input type="radio" name="fonts" id="fontStyle2" value="large" <?php $ss->printSetInputChecked("fonts""large"); ?>/> <label for="fontStyle2">Large text</label><br />
   
   <br />
   
   <strong>Page Style:</strong><br />
   <input type="radio" name="style" id="pageStyle1" value="blue" <?php $ss->printSetInputChecked("style""blue"); ?>/> <label for="pageStyle1">Blue</label>
   <input type="radio" name="style" id="pageStyle2" value="green" <?php $ss->printSetInputChecked("style""green"); ?>/> <label for="pageStyle2">Green</label><br />
   
   <br />
   
   <input type="submit" name="setChanges" value="Change styles" />
  </form>
  
  <hr />
  
  <p>Copyright &copy; 2003 <a href="http://www.contrastsweb.com/">Rob Ballou</a>. All Rights Reserved.<br />
  Last updated: <?php echo date"F d, Y H:i"getlastmod() );  ?></p>

 <p>This page's <a href="http://jigsaw.w3.org/css-validator/validator?uri=http://contrastsweb.com/css/docs/base.css"><acronym title="Cascading Stylesheets">CSS</acronym></a> and <a href="http://validator.w3.org/check/referer"><acronym title="Extensible Hypertext Markup Language">XHTML</acronym></a> validate. Does yours?</p>
 </div>
</body>
</html>

switcher.php
<?php
require_once("Styleswitcher.php");

$ss = new Styleswitcher('/switcher/v2/');

$ss->addStyle("blue""blue.css");
$ss->addStyle("green""green.css");
$ss->addStyle("large""large.css");
$ss->addStyle("normal""small.css");

$ss->createSet("fonts");
$ss->addStyleToSet("fonts""large");
$ss->addStyleToSet("fonts""normal"true);

$ss->createSet("style");
$ss->addStyleToSet("style""blue"true);
$ss->addStyleToSet("style""green");

$ss->cookieDomain "."$_SERVER['HTTP_HOST'];
$ss->cookieName "cwStyle";

$ss->start();
?>