<?php

lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );

class PluginCookie extends PluginBase {

    function PluginCookie($source = ""){
        $this->PluginBase($source);
        $this->desc = "This plugin allows you to access cookie variables from with the templates.";
        $this->author = "Jon Daley";
        $this->id="cookie";
        $this->version="20070302";
    }
    
    function getCookie($name){
        $value = ($this->request_use_auto_globals) ? 
            '$_COOKIE[$name]' : 
            $GLOBALS['HTTP_COOKIE_VARS'][$name];
        return $value;
    }

        // TODO: this should not be in this plugin
    function printAlternateStyleSheets(){
        lt_include( PLOG_CLASS_PATH."class/net/url.class.php" );
      
        $sheets = Array(
            Array("Default", "jondaley.css"),
                //Array("Grey", "grey.css"),
                //Array("Blue", "blueish.css")
            );

        $default_sheet = $this->getCookie("style");

            // commented out until I fix the caching issue
            //if($default_sheet == ""){
        $default_sheet = "Default";
            //}

        foreach($sheets as $sheet){
            if($sheet[0] == $default_sheet){
                print "<link rel=\"stylesheet\" ";
            }
            else{
                print "<link rel=\"alternate stylesheet\" ";
            }
            print "title=\"$sheet[0]\" type=\"text/css\" ";

            $url = $this->blogInfo->getBlogRequestGenerator();
            print "href=\"" . $url->getTemplateFile($sheet[1]) . "\" />\n";
        }
    }
}

?>
