Fixes lists in miniwiki.
[platal.git] / classes / env.php
index 7a2144f..7d67d4a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -75,6 +75,18 @@ class Env
     {
         return array_map(array('Env', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_REQUEST[$key] =& $value;
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Env::has($key)) {
+            Env::set($key, $value);
+        }
+    }
 }
 
 class Post
@@ -133,6 +145,19 @@ class Post
     {
         return array_map(array('Post', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_POST[$key] =& $value;
+        Env::set($key, $value);
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Post::has($key)) {
+            Post::set($key, $value);
+        }
+    }
 }
 
 class Get
@@ -191,6 +216,19 @@ class Get
     {
         return array_map(array('Get', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_GET[$key] =& $value;
+        Env::set($key, $value);
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Get::has($key)) {
+            Get::set($key, $value);
+        }
+    }
 }
 
 class Cookie
@@ -224,6 +262,7 @@ class Cookie
             setcookie($key, $value, time() + 86400 * $days, $globals->cookie_path, '',
                       $secure, $secure);
             $_COOKIE[$key] = $value;
+            Env::set($key, $value);
         }
     }