/** * Static initializer for User_Agent that loads capabilities from the cookie * into a static object via self::parse_capabilities. If a cookie is not * set, this returns false. * * @return bool */ public static function init() { /** * If initialized, return initialized value without reprocessing. */ if (self::$_init !== null) { return self::$_init; } /** * Define name of the cookie set by asets/js/core/server.js. */ self::$_name = 'classification'; /** * If cookie is set, extract contents and parse the JSON into a PHP * object, then setting initialized value to true. Otherwise, set it * false, as initialization has failed since no cookie is defined. */ self::$_cookie = Cookie::get(self::$_name); if (isset(self::$_cookie)) { $capabilities = self::$_cookie; self::$_capabilities = self::parse($capabilities); self::$_init = true; } else { self::$_init = false; } /** * Return whether initialization succeeded or failed. */ return self::$_init; }