[pLog-svn] r4926 - in plugins/branches/lifetype-1.2: . cookie

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri Mar 2 11:51:26 EST 2007


Author: jondaley
Date: 2007-03-02 11:51:26 -0500 (Fri, 02 Mar 2007)
New Revision: 4926

Added:
   plugins/branches/lifetype-1.2/cookie/
   plugins/branches/lifetype-1.2/cookie/plugincookie.class.php
Log:
I should have added this a long time ago, because maybe it will be useful for someone else

Added: plugins/branches/lifetype-1.2/cookie/plugincookie.class.php
===================================================================
--- plugins/branches/lifetype-1.2/cookie/plugincookie.class.php	                        (rev 0)
+++ plugins/branches/lifetype-1.2/cookie/plugincookie.class.php	2007-03-02 16:51:26 UTC (rev 4926)
@@ -0,0 +1,54 @@
+<?php
+
+lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+class PluginCookie extends PluginBase {
+
+    function PluginCookie(){
+        $this->PluginBase();
+        $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";
+        }
+    }
+}
+
+?>



More information about the pLog-svn mailing list