Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit d6418f835165c670dc4ad5cafc5c1a429753bf55 @ccoenraets committed May 16, 2012
Showing with 19,355 additions and 0 deletions.
  1. +10 −0 api/.htaccess
  2. +226 −0 api/Slim/Environment.php
  3. +46 −0 api/Slim/Exception/Pass.php
  4. +47 −0 api/Slim/Exception/RequestSlash.php
  5. +44 −0 api/Slim/Exception/Stop.php
  6. +167 −0 api/Slim/Http/Headers.php
  7. +537 −0 api/Slim/Http/Request.php
  8. +424 −0 api/Slim/Http/Response.php
  9. +381 −0 api/Slim/Http/Util.php
  10. +219 −0 api/Slim/Log.php
  11. +72 −0 api/Slim/LogFileWriter.php
  12. +112 −0 api/Slim/Middleware.php
  13. +158 −0 api/Slim/Middleware/ContentTypes.php
  14. +185 −0 api/Slim/Middleware/Flash.php
  15. +93 −0 api/Slim/Middleware/MethodOverride.php
  16. +108 −0 api/Slim/Middleware/PrettyExceptions.php
  17. +145 −0 api/Slim/Middleware/SessionCookie.php
  18. +400 −0 api/Slim/Route.php
  19. +237 −0 api/Slim/Router.php
  20. +1,229 −0 api/Slim/Slim.php
  21. +164 −0 api/Slim/View.php
  22. +130 −0 api/index.php
  23. +210 −0 client-app/app.js
  24. +808 −0 client-app/css/bootstrap-responsive.css
  25. +9 −0 client-app/css/bootstrap-responsive.min.css
  26. +4,960 −0 client-app/css/bootstrap.css
  27. +9 −0 client-app/css/bootstrap.min.css
  28. +3 −0 client-app/css/styles.css
  29. BIN client-app/img/glyphicons-halflings-white.png
  30. BIN client-app/img/glyphicons-halflings.png
  31. +99 −0 client-app/index.html
  32. +4 −0 client-app/jquery-1.7.2.min.js
  33. +808 −0 server-app/css/bootstrap-responsive.css
  34. +9 −0 server-app/css/bootstrap-responsive.min.css
  35. +4,960 −0 server-app/css/bootstrap.css
  36. +9 −0 server-app/css/bootstrap.min.css
  37. +9 −0 server-app/css/styles.css
  38. BIN server-app/img/blog.png
  39. BIN server-app/img/discuss.png
  40. BIN server-app/img/download.png
  41. BIN server-app/img/glyphicons-halflings-white.png
  42. BIN server-app/img/glyphicons-halflings.png
  43. BIN server-app/img/twitter.png
  44. +58 −0 server-app/index.html
  45. +40 −0 server-app/js/main.js
  46. +23 −0 server-app/js/models/models.js
  47. +21 −0 server-app/js/utils.js
  48. +45 −0 server-app/js/views/employeedetails.js
  49. +38 −0 server-app/js/views/employeelist.js
  50. +19 −0 server-app/js/views/header.js
  51. +38 −0 server-app/lib/backbone-min.js
  52. +100 −0 server-app/lib/bootstrap-dropdown.js
  53. +1,824 −0 server-app/lib/bootstrap.js
  54. +6 −0 server-app/lib/bootstrap.min.js
  55. +4 −0 server-app/lib/jquery-1.7.2.min.js
  56. +32 −0 server-app/lib/underscore-min.js
  57. +3 −0 server-app/tpl/EmployeeListItemView.html
  58. +58 −0 server-app/tpl/EmployeeView.html
  59. +15 −0 server-app/tpl/HeaderView.html
@@ -0,0 +1,10 @@
+RewriteEngine On
+
+# Some hosts may require you to use the `RewriteBase` directive.
+# If you need to use the `RewriteBase` directive, it should be the
+# absolute physical path to the directory that contains this htaccess file.
+#
+# RewriteBase /
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ index.php [QSA,L]
@@ -0,0 +1,226 @@
+<?php
+/**
+ * Slim - a micro PHP 5 framework
+ *
+ * @author Josh Lockhart <info@slimframework.com>
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 1.6.0
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Environment
+ *
+ * This class creates and returns a key/value array of common
+ * environment variables for the current HTTP request.
+ *
+ * This is a singleton class; derived environment variables will
+ * be common across multiple Slim applications.
+ *
+ * This class matches the Rack (Ruby) specification as closely
+ * as possible. More information available below.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.6.0
+ */
+class Slim_Environment implements ArrayAccess, IteratorAggregate {
+ /**
+ * @var array
+ */
+ protected $properties;
+
+ /**
+ * @var Slim_Environment
+ */
+ protected static $environment;
+
+ /**
+ * Get environment instance (singleton)
+ *
+ * This creates and/or returns an Environment instance (singleton)
+ * derived from $_SERVER variables. You may override the global server
+ * variables by using `Environment::mock()` instead.
+ *
+ * @param bool $refresh Refresh properties using global server variables?
+ * @return Slim_Environment
+ */
+ public static function getInstance( $refresh = false ) {
+ if ( is_null(self::$environment) || $refresh ) {
+ self::$environment = new self();
+ }
+ return self::$environment;
+ }
+
+ /**
+ * Get mock environment instance
+ *
+ * @param array $userSettings
+ * @return Environment
+ */
+ public static function mock( $userSettings = array() ) {
+ self::$environment = new self(array_merge(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'SCRIPT_NAME' => '',
+ 'PATH_INFO' => '',
+ 'QUERY_STRING' => '',
+ 'SERVER_NAME' => 'localhost',
+ 'SERVER_PORT' => 80,
+ 'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+ 'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
+ 'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
+ 'USER_AGENT' => 'Slim Framework',
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'slim.url_scheme' => 'http',
+ 'slim.input' => '',
+ 'slim.errors' => @fopen('php://stderr', 'w')
+ ), $userSettings));
+ return self::$environment;
+ }
+
+ /**
+ * Constructor (private access)
+ *
+ * @param array|null $settings If present, these are used instead of global server variables
+ * @return void
+ */
+ private function __construct( $settings = null ) {
+ if ( $settings ) {
+ $this->properties = $settings;
+ } else {
+ $env = array();
+
+ //The HTTP request method
+ $env['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD'];
+
+ //The IP
+ $env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
+
+ /**
+ * Application paths
+ *
+ * This derives two paths: SCRIPT_NAME and PATH_INFO. The SCRIPT_NAME
+ * is the real, physical path to the application, be it in the root
+ * directory or a subdirectory of the public document root. The PATH_INFO is the
+ * virtual path to the requested resource within the application context.
+ *
+ * With htaccess, the SCRIPT_NAME will be an absolute path (without file name);
+ * if not using htaccess, it will also include the file name. If it is "/",
+ * it is set to an empty string (since it cannot have a trailing slash).
+ *
+ * The PATH_INFO will be an absolute path with a leading slash; this will be
+ * used for application routing.
+ */
+ if ( strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0 ) {
+ $env['SCRIPT_NAME'] = $_SERVER['SCRIPT_NAME']; //Without URL rewrite
+ } else {
+ $env['SCRIPT_NAME'] = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']) ); //With URL rewrite
+ }
+ $env['PATH_INFO'] = substr_replace($_SERVER['REQUEST_URI'], '', 0, strlen($env['SCRIPT_NAME']));
+ if ( strpos($env['PATH_INFO'], '?') !== false ) {
+ $env['PATH_INFO'] = substr_replace($env['PATH_INFO'], '', strpos($env['PATH_INFO'], '?')); //query string is not removed automatically
+ }
+ $env['SCRIPT_NAME'] = rtrim($env['SCRIPT_NAME'], '/');
+ $env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/');
+
+ //The portion of the request URI following the '?'
+ $env['QUERY_STRING'] = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
+
+ //Name of server host that is running the script
+ $env['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
+
+ //Number of server port that is running the script
+ $env['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
+
+ //HTTP request headers
+ $specialHeaders = array('CONTENT_TYPE', 'CONTENT_LENGTH', 'PHP_AUTH_USER', 'PHP_AUTH_PW', 'PHP_AUTH_DIGEST', 'AUTH_TYPE');
+ foreach ( $_SERVER as $key => $value ) {
+ $value = is_string($value) ? trim($value) : $value;
+ if ( strpos($key, 'HTTP_') === 0 ) {
+ $env[substr($key, 5)] = $value;
+ } else if ( strpos($key, 'X_') === 0 || in_array($key, $specialHeaders) ) {
+ $env[$key] = $value;
+ }
+ }
+
+ //Is the application running under HTTPS or HTTP protocol?
+ $env['slim.url_scheme'] = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https';
+
+ //Input stream (readable one time only; not available for mutipart/form-data requests)
+ $rawInput = @file_get_contents('php://input');
+ if ( !$rawInput ) {
+ $rawInput = '';
+ }
+ $env['slim.input'] = $rawInput;
+
+ //Error stream
+ $env['slim.errors'] = fopen('php://stderr', 'w');
+
+ $this->properties = $env;
+ }
+ }
+
+ /**
+ * Array Access: Offset Exists
+ */
+ public function offsetExists( $offset ) {
+ return isset($this->properties[$offset]);
+ }
+
+ /**
+ * Array Access: Offset Get
+ */
+ public function offsetGet( $offset ) {
+ if ( isset($this->properties[$offset]) ) {
+ return $this->properties[$offset];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Array Access: Offset Set
+ */
+ public function offsetSet( $offset, $value ) {
+ $this->properties[$offset] = $value;
+ }
+
+ /**
+ * Array Access: Offset Unset
+ */
+ public function offsetUnset( $offset ) {
+ unset($this->properties[$offset]);
+ }
+
+ /**
+ * IteratorAggregate
+ *
+ * @return ArrayIterator
+ */
+ public function getIterator() {
+ return new ArrayIterator($this->properties);
+ }
+}
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Slim - a micro PHP 5 framework
+ *
+ * @author Josh Lockhart <info@slimframework.com>
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 1.6.0
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Pass Exception
+ *
+ * This Exception will cause the Router::dispatch method
+ * to skip the current matching route and continue to the next
+ * matching route. If no subsequent routes are found, a
+ * HTTP 404 Not Found response will be sent to the client.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class Slim_Exception_Pass extends Exception {}
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Slim - a micro PHP 5 framework
+ *
+ * @author Josh Lockhart <info@slimframework.com>
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 1.6.0
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Request Slash Exception
+ *
+ * This Exception is thrown when Slim detects a matching route
+ * (defined with a trailing slash) and the HTTP request
+ * matches the route but does not have a trailing slash. This
+ * exception will be caught in `Slim::run` and trigger a 301 redirect
+ * to the same resource URI with a trailing slash.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class Slim_Exception_RequestSlash extends Exception {}
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Slim - a micro PHP 5 framework
+ *
+ * @author Josh Lockhart <info@slimframework.com>
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 1.6.0
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Stop Exception
+ *
+ * This Exception is thrown when the Slim application needs to abort
+ * processing and return control flow to the outer PHP script.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class Slim_Exception_Stop extends Exception {}
Oops, something went wrong.

0 comments on commit d6418f8

Please sign in to comment.