Esempio n. 1
0
 /**
  * Apply settings to the current loaded configuration.
  * If debug is being set, apply the error reporting rules.
  *
  * @access public
  * @param string $key
  * @param mixed $value
  * @return void
  * @static
  */
 public static function set($key, $value)
 {
     if ($key === 'debug') {
         $key = 'Debug.level';
         if ($value == 0) {
             Debugger::errorReporting(Debugger::ERRORS_OFF);
         } else {
             Debugger::errorReporting(Debugger::ERRORS_ON);
         }
     }
     static::$__config = Set::insert(static::$__config, (string) $key, $value);
 }
Esempio n. 2
0
 /**
  * Add a value into the session based on the key/path.
  *
  * @access public
  * @param string $key
  * @param mixed $value
  * @return boolean
  */
 public function set($key, $value)
 {
     $_SESSION = Set::insert($_SESSION, $key, $value);
 }
Esempio n. 3
0
 /**
  * Remove a certain key/path from the cookie. Returns true if successful, else if failure.
  *
  * @access public
  * @param string $key
  * @param array $meta
  * @return boolean
  */
 public function remove($key, array $meta = array())
 {
     if (!empty($key)) {
         $paths = explode('.', $key);
         $index = array_shift($paths);
         if (isset($_COOKIE[$this->namespace][$index])) {
             $cookie = $this->__decrypt($_COOKIE[$this->namespace][$index]);
             $cookie = Set::remove($cookie, implode('.', $paths));
             return $this->set($index, $cookie, $meta);
         }
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Manually store an object into registry, and store the object name to the $__mapping array.
  * The property $__registered contains the object where as $__mapping is just the class name.
  *
  * @access public
  * @param object $object
  * @param string $slug
  * @return object
  * @static
  */
 public static function store($object, $slug = null)
 {
     if (!is_object($object)) {
         throw new Exception('The object passed must be instantiated.');
     }
     $namespace = get_class($object);
     $className = App::baseClass($namespace);
     if (!$slug) {
         $slug = App::toDotNotation($namespace);
     }
     static::$__registered[$slug] = $object;
     static::$__mapping = Set::insert(static::$__mapping, $slug, $className);
     return $object;
 }
Esempio n. 5
0
File: Form.php Progetto: hjr3/titon
 /**
  * Check to see if a value exists in the POST/GET data, if so escape and return.
  *
  * @access public
  * @param string $model
  * @param string $field
  * @return string
  */
 public function value($model, $field)
 {
     $data =& App::$data;
     $value = Set::extract($data, $model . '.' . $field);
     if (!empty($value)) {
         return is_array($value) ? $value : htmlentities($value, ENT_COMPAT, App::charset());
     } else {
         $data = Set::insert($data, $model . '.' . $field, null);
         return null;
     }
 }
Esempio n. 6
0
 /**
  * Return the object as an array.
  *
  * @access public
  * @return string
  */
 public function toArray()
 {
     return Set::toArray($this);
 }
Esempio n. 7
0
 /**
  * Set the flash message to be used in the view. Will use the Session class if its loaded.
  *
  * @access public
  * @param mixed $message
  * @return void
  */
 public final function flash($message)
 {
     if ($this->hasObject('Session')) {
         $this->Session->set('App.flash', $message);
     } else {
         $_SESSION = Set::insert($_SESSION, 'App.flash', $message);
     }
 }