Response:
+
+
+ Additional Template Data:
+ +Restler v
+"; + print_r($r); + echo ""; + */ + if ($dataOnly) + return $r; + if (isset($p->rules['form'])) + return Emmet::make($p->rules['form'], $r); + $m = static::$info->metadata; + $t = Emmet::make(static::style($type, $m, $p->type) ? : static::style($tag, $m, $p->type), $r); + return $t; + } + + protected static function guessFieldType(ValidationInfo $p, $type = 'type') + { + if (in_array($p->$type, static::$inputTypes)) + return $p->$type; + if ($p->choice) + return $p->type == 'array' ? 'checkbox' : 'select'; + switch ($p->$type) { + case 'boolean': + return 'radio'; + case 'int': + case 'number': + case 'float': + return 'number'; + case 'array': + return static::guessFieldType($p, 'contentType'); + } + if ($p->name == 'password') + return 'password'; + return 'text'; + } + + /** + * Get the form key + * + * @param string $method http method for form key + * @param string $action relative path from the web root. When set to null + * it uses the current api method's path + * + * @return string generated form key + */ + public static function key($method = 'POST', $action = null) + { + if (is_null($action)) + $action = Scope::get('Restler')->url; + $target = "$method $action"; + if (empty(static::$key[$target])) + static::$key[$target] = md5($target . User::getIpAddress() . uniqid(mt_rand())); + $_SESSION[static::FORM_KEY] = static::$key; + return static::$key[$target]; + } + + /** + * Access verification method. + * + * API access will be denied when this method returns false + * + * @return boolean true when api access is allowed false otherwise + * + * @throws RestException 403 security violation + */ + public function __isAllowed() + { + if (session_id() == '') { + session_start(); + } + /** @var Restler $restler */ + $restler = $this->restler; + $url = $restler->url; + foreach (static::$excludedPaths as $exclude) { + if (empty($exclude)) { + if ($url == $exclude) + return true; + } elseif (String::beginsWith($url, $exclude)) { + return true; + } + } + $check = static::$filterFormRequestsOnly + ? $restler->requestFormat instanceof UrlEncodedFormat || $restler->requestFormat instanceof UploadFormat + : true; + if (!empty($_POST) && $check) { + if ( + isset($_POST[static::FORM_KEY]) && + ($target = Util::getRequestMethod() . ' ' . $restler->url) && + isset($_SESSION[static::FORM_KEY][$target]) && + $_POST[static::FORM_KEY] == $_SESSION[static::FORM_KEY][$target] + ) { + return true; + } + throw new RestException(403, 'Insecure form submission'); + } + return true; + } +} \ No newline at end of file diff --git a/htdocs/includes/restler/UI/Nav.php b/htdocs/includes/restler/UI/Nav.php new file mode 100644 index 00000000000..7245dbddf8d --- /dev/null +++ b/htdocs/includes/restler/UI/Nav.php @@ -0,0 +1,208 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +class Nav +{ + public static $root = 'home'; + /** + * @var null|callable if the api methods are under access control mechanism + * you can attach a function here that returns true or false to determine + * visibility of a protected api method. this function will receive method + * info as the only parameter. + */ + public static $accessControlFunction = null; + /** + * @var array all paths beginning with any of the following will be excluded + * from documentation. if an empty string is given it will exclude the root + */ + public static $excludedPaths = array(''); + /** + * @var array prefix additional menu items with one of the following syntax + * [$path => $text] + * [$path] + * [$path => ['text' => $text, 'url' => $url]] + */ + public static $prepends = array(); + /** + * @var array suffix additional menu items with one of the following syntax + * [$path => $text] + * [$path] + * [$path => ['text' => $text, 'url' => $url]] + */ + public static $appends = array(); + + public static $addExtension = true; + + protected static $extension = ''; + + public static function get($for = '', $activeUrl = null) + { + if (!static::$accessControlFunction && Defaults::$accessControlFunction) + static::$accessControlFunction = Defaults::$accessControlFunction; + /** @var Restler $restler */ + $restler = Scope::get('Restler'); + if (static::$addExtension) + static::$extension = '.' . $restler->responseFormat->getExtension(); + if (is_null($activeUrl)) + $activeUrl = $restler->url; + + $tree = array(); + foreach (static::$prepends as $path => $text) { + $url = null; + if (is_array($text)) { + if (isset($text['url'])) { + $url = $text['url']; + $text = $text['text']; + } else { + $url = current(array_keys($text)); + $text = current($text); + } + } + if (is_numeric($path)) { + $path = $text; + $text = null; + } + if (empty($for) || 0 === strpos($path, "$for/")) + static::build($tree, $path, $url, $text, $activeUrl); + } + $routes = Routes::toArray(); + $routes = $routes['v' . $restler->getRequestedApiVersion()]; + foreach ($routes as $value) { + foreach ($value as $httpMethod => $route) { + if ($httpMethod != 'GET') { + continue; + } + $path = $route['url']; + if (false !== strpos($path, '{')) + continue; + if ($route['accessLevel'] > 1 && !Util::$restler->_authenticated) + continue; + foreach (static::$excludedPaths as $exclude) { + if (empty($exclude)) { + if (empty($path)) + continue 2; + } elseif (0 === strpos($path, $exclude)) { + continue 2; + } + } + if ($restler->_authenticated + && static::$accessControlFunction + && (!call_user_func( + static::$accessControlFunction, $route['metadata'])) + ) { + continue; + } + $text = Util::nestedValue( + $route, + 'metadata', + CommentParser::$embeddedDataName, + 'label' + ); + if (empty($for) || 0 === strpos($path, "$for/")) + static::build($tree, $path, null, $text, $activeUrl); + } + } + foreach (static::$appends as $path => $text) { + $url = null; + if (is_array($text)) { + if (isset($text['url'])) { + $url = $text['url']; + $text = $text['text']; + } else { + $url = current(array_keys($text)); + $text = current($text); + } + } + if (is_numeric($path)) { + $path = $text; + $text = null; + } + if (empty($for) || 0 === strpos($path, "$for/")) + static::build($tree, $path, $url, $text, $activeUrl); + } + if (!empty($for)) { + $for = explode('/', $for); + $p = & $tree; + foreach ($for as $f) { + if (isset($p[$f]['children'])) { + $p = & $p[$f]['children']; + } else { + return array(); + } + } + return $p; + } + return $tree; + } + + protected static function build(&$tree, $path, + $url = null, $text = null, $activeUrl = null) + { + $parts = explode('/', $path); + if (count($parts) == 1 && empty($parts[0])) + $parts = array(static::$root); + $p = & $tree; + $end = end($parts); + foreach ($parts as $part) { + if (!isset($p[$part])) { + $p[$part] = array( + 'href' => '#', + 'text' => static::title($part) + ); + if ($part == $end) { + $p[$part]['class'] = $part; + if ($text) + $p[$part]['text'] = $text; + if (is_null($url)) { + if (empty($path) && !empty(static::$extension)) + $path = 'index'; + $p[$part]['href'] = Util::$restler->getBaseUrl() + . '/' . $path . static::$extension; + } else { + if (empty($url) && !empty(static::$extension)) + $url = 'index'; + $p[$part]['href'] = $url . static::$extension; + } + if ($path == $activeUrl) { + $p[$part]['active'] = true; + } + } + $p[$part]['children'] = array(); + + } + $p = & $p[$part]['children']; + } + + } + + protected static function title($name) + { + if (empty($name)) { + $name = static::$root; + } else { + $name = ltrim($name, '#'); + } + return ucfirst(preg_replace(array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/'), ' $0', $name)); + } + +} \ No newline at end of file diff --git a/htdocs/includes/restler/UI/Tags.php b/htdocs/includes/restler/UI/Tags.php new file mode 100644 index 00000000000..b6302a28236 --- /dev/null +++ b/htdocs/includes/restler/UI/Tags.php @@ -0,0 +1,282 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + * + * ============================ magic properties ============================== + * @property Tags parent parent tag + * ============================== magic methods =============================== + * @method Tags name(string $value) name attribute + * @method Tags action(string $value) action attribute + * @method Tags placeholder(string $value) placeholder attribute + * @method Tags value(string $value) value attribute + * @method Tags required(boolean $value) required attribute + * @method Tags class(string $value) required attribute + * + * =========================== static magic methods ============================ + * @method static Tags form() creates a html form + * @method static Tags input() creates a html input element + * @method static Tags button() creates a html button element + * + */ +class Tags implements ArrayAccess, Countable +{ + public static $humanReadable = true; + public static $initializer = null; + protected static $instances = array(); + public $prefix = ''; + public $indent = ' '; + public $tag; + protected $attributes = array(); + protected $children = array(); + protected $_parent; + + public function __construct($name = null, array $children = array()) + { + $this->tag = $name; + $c = array(); + foreach ($children as $child) { + is_array($child) + ? $c = array_merge($c, $child) + : $c [] = $child; + } + $this->markAsChildren($c); + $this->children = $c; + if (static::$initializer) + call_user_func_array(static::$initializer, array(& $this)); + } + + /** + * Get Tag by id + * + * Retrieve a tag by its id attribute + * + * @param string $id + * + * @return Tags|null + */ + public static function byId($id) + { + return Util::nestedValue(static::$instances, $id); + } + + /** + * @param $name + * @param array $children + * + * @return Tags + */ + public static function __callStatic($name, array $children) + { + return new static($name, $children); + } + + public function toString($prefix = '', $indent = ' ') + { + $this->prefix = $prefix; + $this->indent = $indent; + return $this->__toString(); + } + + public function __toString() + { + $children = ''; + if (static::$humanReadable) { + $lineBreak = false; + foreach ($this->children as $key => $child) { + $prefix = $this->prefix; + if (!is_null($this->tag)) + $prefix .= $this->indent; + if ($child instanceof $this) { + $child->prefix = $prefix; + $child->indent = $this->indent; + $children .= PHP_EOL . $child; + $lineBreak = true; + } else { + $children .= $child; + } + } + if ($lineBreak) + $children .= PHP_EOL . $this->prefix; + } else { + $children = implode('', $this->children); + } + if (is_null($this->tag)) + return $children; + $attributes = ''; + foreach ($this->attributes as $attribute => &$value) + $attributes .= " $attribute=\"$value\""; + + if (count($this->children)) + return static::$humanReadable + ? "$this->prefix<{$this->tag}{$attributes}>" + . "$children" + . "{$this->tag}>" + : "<{$this->tag}{$attributes}>$children{$this->tag}>"; + + return "$this->prefix<{$this->tag}{$attributes}/>"; + } + + public function toArray() + { + $r = array(); + $r['attributes'] = $this->attributes; + $r['tag'] = $this->tag; + $children = array(); + foreach ($this->children as $key => $child) { + $children[$key] = $child instanceof $this + ? $child->toArray() + : $child; + } + $r['children'] = $children; + return $r; + } + + /** + * Set the id attribute of the current tag + * + * @param string $value + * + * @return string + */ + public function id($value) + { + $this->attributes['id'] = isset($value) + ? (string)$value + : Util::nestedValue($this->attributes, 'name'); + static::$instances[$value] = $this; + return $this; + } + + public function __get($name) + { + if ('parent' == $name) + return $this->_parent; + if (isset($this->attributes[$name])) + return $this->attributes[$name]; + return; + } + + public function __set($name, $value) + { + if ('parent' == $name) { + if ($this->_parent) { + unset($this->_parent[array_search($this, $this->_parent->children)]); + } + if (!empty($value)) { + $value[] = $this; + } + } + } + + public function __isset($name) + { + return isset($this->attributes[$name]); + } + + /** + * @param $attribute + * @param $value + * + * @return Tags + */ + public function __call($attribute, $value) + { + if (is_null($value)) { + return isset($this->attributes[$attribute]) + ? $this->attributes[$attribute] + : null; + } + $value = $value[0]; + if (is_null($value)) { + unset($this->attributes[$attribute]); + return $this; + } + $this->attributes[$attribute] = is_bool($value) + ? ($value ? 'true' : 'false') + : @(string)$value; + return $this; + } + + public function offsetGet($index) + { + if ($this->offsetExists($index)) { + return $this->children[$index]; + } + return false; + } + + public function offsetExists($index) + { + return isset($this->children[$index]); + } + + public function offsetSet($index, $value) + { + if ($index) { + $this->children[$index] = $value; + } elseif (is_array($value)) { + $c = array(); + foreach ($value as $child) { + is_array($child) + ? $c = array_merge($c, $child) + : $c [] = $child; + } + $this->markAsChildren($c); + $this->children += $c; + } else { + $c = array($value); + $this->markAsChildren($c); + $this->children[] = $value; + } + return true; + } + + public function offsetUnset($index) + { + $this->children[$index]->_parent = null; + unset($this->children[$index]); + return true; + } + + public function getContents() + { + return $this->children; + } + + public function count() + { + return count($this->children); + } + + private function markAsChildren(& $children) + { + foreach ($children as $i => $child) { + if (is_string($child)) + continue; + if (!is_object($child)) { + unset($children[$i]); + continue; + } + //echo $child; + if (isset($child->_parent) && $child->_parent != $this) { + //remove from current parent + unset($child->_parent[array_search($child, $child->_parent->children)]); + } + $child->_parent = $this; + } + } +} \ No newline at end of file diff --git a/htdocs/includes/restler/User.php b/htdocs/includes/restler/User.php new file mode 100644 index 00000000000..ea7ff79d603 --- /dev/null +++ b/htdocs/includes/restler/User.php @@ -0,0 +1,100 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +class User implements iIdentifyUser +{ + private static $initialized = false; + public static $id = null; + public static $cacheId = null; + public static $ip; + public static $browser = ''; + public static $platform = ''; + + public static function init() + { + static::$initialized = true; + static::$ip = static::getIpAddress(); + } + + public static function getUniqueIdentifier($includePlatform = false) + { + if (!static::$initialized) static::init(); + return static::$id ? : base64_encode('ip:' . ($includePlatform + ? static::$ip . '-' . static::$platform + : static::$ip + )); + } + + public static function getIpAddress($ignoreProxies = false) + { + foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', + 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', + 'REMOTE_ADDR') as $key) { + if (array_key_exists($key, $_SERVER) === true) { + foreach (explode(',', $_SERVER[$key]) as $ip) { + $ip = trim($ip); // just to be safe + + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 + | FILTER_FLAG_NO_PRIV_RANGE + | FILTER_FLAG_NO_RES_RANGE) !== false + ) { + return $ip; + } + } + } + } + } + + /** + * Authentication classes should call this method + * + * @param string $id user id as identified by the authentication classes + * + * @return void + */ + public static function setUniqueIdentifier($id) + { + static::$id = $id; + } + + /** + * User identity to be used for caching purpose + * + * When the dynamic cache service places an object in the cache, it needs to + * label it with a unique identifying string known as a cache ID. This + * method gives that identifier + * + * @return string + */ + public static function getCacheIdentifier() + { + return static::$cacheId ?: static::$id; + } + + /** + * User identity for caching purpose + * + * In a role based access control system this will be based on role + * + * @param $id + * + * @return void + */ + public static function setCacheIdentifier($id) + { + static::$cacheId = $id; + } +} diff --git a/htdocs/includes/restler/Util.php b/htdocs/includes/restler/Util.php new file mode 100644 index 00000000000..0a1fc8a40ea --- /dev/null +++ b/htdocs/includes/restler/Util.php @@ -0,0 +1,201 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +class Util +{ + /** + * @var Restler instance injected at runtime + */ + public static $restler; + + /** + * verify if the given data type string is scalar or not + * + * @static + * + * @param string $type data type as string + * + * @return bool true or false + */ + public static function isObjectOrArray($type) + { + if (is_array($type)) { + foreach ($type as $t) { + if (static::isObjectOrArray($t)) { + return true; + } + } + return false; + } + return !(boolean)strpos('|bool|boolean|int|float|string|', $type); + } + + /** + * Get the value deeply nested inside an array / object + * + * Using isset() to test the presence of nested value can give a false positive + * + * This method serves that need + * + * When the deeply nested property is found its value is returned, otherwise + * false is returned. + * + * @param array $from array to extract the value from + * @param string|array $key ... pass more to go deeply inside the array + * alternatively you can pass a single array + * + * @return null|mixed null when not found, value otherwise + */ + public static function nestedValue($from, $key/**, $key2 ... $key`n` */) + { + if (is_array($key)) { + $keys = $key; + } else { + $keys = func_get_args(); + array_shift($keys); + } + foreach ($keys as $key) { + if (is_array($from) && isset($from[$key])) { + $from = $from[$key]; + continue; + } elseif (is_object($from) && isset($from->{$key})) { + $from = $from->{$key}; + continue; + } + return null; + } + return $from; + } + + public static function getResourcePath($className, + $resourcePath = null, + $prefix = '') + { + if (is_null($resourcePath)) { + if (Defaults::$autoRoutingEnabled) { + $resourcePath = strtolower($className); + if (false !== ($index = strrpos($className, '\\'))) + $resourcePath = substr($resourcePath, $index + 1); + if (false !== ($index = strrpos($resourcePath, '_'))) + $resourcePath = substr($resourcePath, $index + 1); + } else { + $resourcePath = ''; + } + } else + $resourcePath = trim($resourcePath, '/'); + if (strlen($resourcePath) > 0) + $resourcePath .= '/'; + return $prefix . $resourcePath; + } + + /** + * Compare two strings and remove the common + * sub string from the first string and return it + * + * @static + * + * @param string $fromPath + * @param string $usingPath + * @param string $char + * optional, set it as + * blank string for char by char comparison + * + * @return string + */ + public static function removeCommonPath($fromPath, $usingPath, $char = '/') + { + if (empty($fromPath)) + return ''; + $fromPath = explode($char, $fromPath); + $usingPath = explode($char, $usingPath); + while (count($usingPath)) { + if (count($fromPath) && $fromPath[0] == $usingPath[0]) { + array_shift($fromPath); + } else { + break; + } + array_shift($usingPath); + } + return implode($char, $fromPath); + } + + /** + * Parses the request to figure out the http request type + * + * @static + * + * @return string which will be one of the following + * [GET, POST, PUT, PATCH, DELETE] + * @example GET + */ + public static function getRequestMethod() + { + $method = $_SERVER['REQUEST_METHOD']; + if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { + $method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; + } elseif ( + !empty(Defaults::$httpMethodOverrideProperty) + && isset($_REQUEST[Defaults::$httpMethodOverrideProperty]) + ) { + // support for exceptional clients who can't set the header + $m = strtoupper($_REQUEST[Defaults::$httpMethodOverrideProperty]); + if ($m == 'PUT' || $m == 'DELETE' || + $m == 'POST' || $m == 'PATCH' + ) { + $method = $m; + } + } + // support for HEAD request + if ($method == 'HEAD') { + $method = 'GET'; + } + return $method; + } + + /** + * Pass any content negotiation header such as Accept, + * Accept-Language to break it up and sort the resulting array by + * the order of negotiation. + * + * @static + * + * @param string $accept header value + * + * @return array sorted by the priority + */ + public static function sortByPriority($accept) + { + $acceptList = array(); + $accepts = explode(',', strtolower($accept)); + if (!is_array($accepts)) { + $accepts = array($accepts); + } + foreach ($accepts as $pos => $accept) { + $parts = explode(';q=', trim($accept)); + $type = array_shift($parts); + $quality = count($parts) ? + floatval(array_shift($parts)) : + (1000 - $pos) / 1000; + $acceptList[$type] = $quality; + } + arsort($acceptList); + return $acceptList; + } + + public static function getShortName($className) + { + $className = explode('\\', $className); + return end($className); + } +} + diff --git a/htdocs/includes/restler/compatibility/iAuthenticate.php b/htdocs/includes/restler/compatibility/iAuthenticate.php new file mode 100644 index 00000000000..0463df948f1 --- /dev/null +++ b/htdocs/includes/restler/compatibility/iAuthenticate.php @@ -0,0 +1,10 @@ +isFile() + && 'php' === $fileInfo->getExtension() + && ctype_lower($fileInfo->getBasename('.php')) + && preg_match( + '/^ *(class|interface|abstract +class)' + . ' +([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/m', + file_get_contents($fileInfo->getPathname()), + $matches + ) + ) + $classMap[$matches[2]] = $fileInfo->getPathname(); + +AutoLoader::seen($classMap); + +//changes in iAuthenticate +Defaults::$authenticationMethod = '__isAuthenticated'; + +include __DIR__ . '/iAuthenticate.php'; + +//changes in auto routing +Defaults::$smartAutoRouting = false; +Defaults::$smartParameterParsing = false; +Defaults::$autoValidationEnabled = false; + +//changes in parsing embedded data in comments +CommentParser::$embeddedDataPattern = '/\((\S+)\)/ms'; +CommentParser::$embeddedDataIndex = 1; \ No newline at end of file diff --git a/htdocs/includes/restler/composer.json b/htdocs/includes/restler/composer.json new file mode 100644 index 00000000000..1e096989b01 --- /dev/null +++ b/htdocs/includes/restler/composer.json @@ -0,0 +1,70 @@ +{ + "name":"restler/framework", + "description":"Just the Restler Framework without the tests and examples", + "type":"library", + "keywords":["server","api","framework","REST"], + "homepage":"http://luracast.com/products/restler/", + "license":"LGPL-2.1", + "authors":[ + { + "name":"Luracast", + "email":"arul@luracast.com" + }, + { + "name":"Nick nickl- Lombard", + "email":"github@jigsoft.co.za" + } + ], + "extra":{ + "branch-alias":{ + "master":"v3.0.x-dev" + } + }, + "suggest":{ + "luracast/explorer":"Restler's very own api explorer (see require-dev for details)", + "rodneyrehm/plist":"Restler supports tho Apple plist xml format (see require-dev for details)", + "zendframework/zendamf":"Support for the amf document format (see require-dev for details)", + "symfony/yaml":"Restler can produce content in yaml format as well (see require-dev for details)", + "twig/twig":"Restler can render HtmlView using twig templates (see require-dev for details)", + "mustache/mustache":"Restler can render HtmlView using mustache/handlebar templates (see require-dev for details)", + "bshaffer/oauth2-server-php":"Restler can provide OAuth2 authentication using this library (see require-dev for details)" + }, + "require":{ + "php":">=5.3.0" + }, + "require-dev":{ + "luracast/explorer":"*", + "rodneyrehm/plist":"dev-master", + "zendframework/zendamf":"dev-master", + "symfony/yaml":"*", + "mustache/mustache": "dev-master", + "twig/twig": "v1.13.0", + "bshaffer/oauth2-server-php":"v1.0" + }, + "repositories":[ + { + "type":"vcs", + "url":"https://github.com/zendframework/ZendAmf.git" + }, + { + "type":"package", + "package":{ + "name":"luracast/explorer", + "version":"v3.0.0", + "dist":{ + "type":"zip", + "url":"https://github.com/Luracast/Restler-API-Explorer/zipball/v3.0.0" + } + } + } + ], + "autoload":{ + "psr-0":{ + "Luracast\\Restler":"" + } + }, + "target-dir": "Luracast/Restler", + "replace": { + "luracast/restler":"3.*" + } +} \ No newline at end of file diff --git a/htdocs/includes/restler/composer.lock b/htdocs/includes/restler/composer.lock new file mode 100644 index 00000000000..914abc5e16d --- /dev/null +++ b/htdocs/includes/restler/composer.lock @@ -0,0 +1,23 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "ee84444dcf34101555d20a813d528c44", + "packages": [], + "packages-dev": null, + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "rodneyrehm/plist": 20, + "zendframework/zendamf": 20, + "mustache/mustache": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [] +} diff --git a/htdocs/includes/restler/iAuthenticate.php b/htdocs/includes/restler/iAuthenticate.php new file mode 100644 index 00000000000..6e71f0fc291 --- /dev/null +++ b/htdocs/includes/restler/iAuthenticate.php @@ -0,0 +1,25 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iAuthenticate extends iFilter +{ + /** + * @return string string to be used with WWW-Authenticate header + * @example Basic + * @example Digest + * @example OAuth + */ + public function __getWWWAuthenticateString(); +} diff --git a/htdocs/includes/restler/iCache.php b/htdocs/includes/restler/iCache.php new file mode 100755 index 00000000000..53a7a9da6a7 --- /dev/null +++ b/htdocs/includes/restler/iCache.php @@ -0,0 +1,63 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iCache +{ + /** + * store data in the cache + * + * @abstract + * + * @param string $name + * @param mixed $data + * + * @return boolean true if successful + */ + public function set($name, $data); + + /** + * retrieve data from the cache + * + * @abstract + * + * @param string $name + * @param bool $ignoreErrors + * + * @return mixed + */ + public function get($name, $ignoreErrors = false); + + /** + * delete data from the cache + * + * @abstract + * + * @param string $name + * @param bool $ignoreErrors + * + * @return boolean true if successful + */ + public function clear($name, $ignoreErrors = false); + + /** + * check if the given name is cached + * + * @abstract + * + * @param string $name + * + * @return boolean true if cached + */ + public function isCached($name); +} + diff --git a/htdocs/includes/restler/iCompose.php b/htdocs/includes/restler/iCompose.php new file mode 100644 index 00000000000..a37d24d867d --- /dev/null +++ b/htdocs/includes/restler/iCompose.php @@ -0,0 +1,36 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iCompose { + /** + * Result of an api call is passed to this method + * to create a standard structure for the data + * + * @param mixed $result can be a primitive or array or object + */ + public function response($result); + + /** + * When the api call results in RestException this method + * will be called to return the error message + * + * @param RestException $exception exception that has reasons for failure + * + * @return + */ + public function message(RestException $exception); +} \ No newline at end of file diff --git a/htdocs/includes/restler/iFilter.php b/htdocs/includes/restler/iFilter.php new file mode 100644 index 00000000000..40205e5def8 --- /dev/null +++ b/htdocs/includes/restler/iFilter.php @@ -0,0 +1,30 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iFilter +{ + /** + * Access verification method. + * + * API access will be denied when this method returns false + * + * @abstract + * @return boolean true when api access is allowed false otherwise + */ + public function __isAllowed(); + +} + diff --git a/htdocs/includes/restler/iIdentifyUser.php b/htdocs/includes/restler/iIdentifyUser.php new file mode 100644 index 00000000000..9ba061d3327 --- /dev/null +++ b/htdocs/includes/restler/iIdentifyUser.php @@ -0,0 +1,63 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iIdentifyUser +{ + /** + * A way to uniquely identify the current api consumer + * + * When his user id is known it should be used otherwise ip address + * can be used + * + * @param bool $includePlatform Should we consider user alone or should + * consider the application/platform/device + * as well for generating unique id + * + * @return string + */ + public static function getUniqueIdentifier($includePlatform = false); + + /** + * User identity to be used for caching purpose + * + * When the dynamic cache service places an object in the cache, it needs to + * label it with a unique identifying string known as a cache ID. This + * method gives that identifier + * + * @return string + */ + public static function getCacheIdentifier(); + + /** + * Authentication classes should call this method + * + * @param string $id user id as identified by the authentication classes + * + * @return void + */ + public static function setUniqueIdentifier($id); + + /** + * User identity for caching purpose + * + * In a role based access control system this will be based on role + * + * @param $id + * + * @return void + */ + public static function setCacheIdentifier($id); +} \ No newline at end of file diff --git a/htdocs/includes/restler/iProvideMultiVersionApi.php b/htdocs/includes/restler/iProvideMultiVersionApi.php new file mode 100644 index 00000000000..ed74dd1b9e6 --- /dev/null +++ b/htdocs/includes/restler/iProvideMultiVersionApi.php @@ -0,0 +1,11 @@ + + * @copyright 2010 Luracast + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://luracast.com/products/restler/ + * @version 3.0.0rc5 + */ +interface iUseAuthentication +{ + /** + * This method will be called first for filter classes and api classes so + * that they can respond accordingly for filer method call and api method + * calls + * + * @abstract + * + * @param bool $isAuthenticated passes true when the authentication is + * done false otherwise + * + * @return mixed + */ + public function __setAuthenticationStatus($isAuthenticated=false); +} + diff --git a/htdocs/includes/restler/vendor/autoload.php b/htdocs/includes/restler/vendor/autoload.php new file mode 100644 index 00000000000..bf60b992d40 --- /dev/null +++ b/htdocs/includes/restler/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano
Restler v
+| t |