Skip to content
Browse files

going lithium

  • Loading branch information...
1 parent 4579838 commit e7f3c3137a4c543223b59f61e41b2f5dedbb7bb0 @gwoo gwoo committed Oct 12, 2009
Showing with 19,517 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 .htaccess
  3. +5 −0 app/.htaccess
  4. +208 −0 app/config/bootstrap.php
  5. +78 −0 app/config/connections.php
  6. +57 −0 app/config/environments.php
  7. +31 −0 app/config/environments/development.php
  8. +40 −0 app/config/routes.php
  9. 0 app/config/schema/empty
  10. +63 −0 app/config/switchboard.php
  11. +22 −0 app/controllers/HelloWorldController.php
  12. +30 −0 app/controllers/PagesController.php
  13. 0 app/extensions/adapters/empty
  14. 0 app/extensions/behaviors/empty
  15. 0 app/extensions/commands/empty
  16. 0 app/extensions/components/empty
  17. 0 app/extensions/data/sources/empty
  18. 0 app/extensions/g11n/empty
  19. 0 app/extensions/helpers/empty
  20. +15 −0 app/index.php
  21. 0 app/libraries/empty
  22. 0 app/models/empty
  23. 0 app/tests/cases/controllers/empty
  24. 0 app/tests/cases/extensions/adapters/empty
  25. 0 app/tests/cases/extensions/behaviors/empty
  26. 0 app/tests/cases/extensions/commands/empty
  27. 0 app/tests/cases/extensions/components/empty
  28. 0 app/tests/cases/extensions/data_sources/empty
  29. 0 app/tests/cases/extensions/helpers/empty
  30. 0 app/tests/cases/models/empty
  31. 0 app/tests/fixtures/empty
  32. 0 app/tests/groups/empty
  33. 0 app/tmp/cache/empty
  34. 0 app/tmp/logs/empty
  35. 0 app/views/elements/empty
  36. +1 −0 app/views/hello_world/index.html.php
  37. +15 −0 app/views/layouts/default.ajax.php
  38. +22 −0 app/views/layouts/default.email.html.php
  39. +15 −0 app/views/layouts/default.email.txt.php
  40. +31 −0 app/views/layouts/default.html.php
  41. +14 −0 app/views/layouts/default.xml.php
  42. +33 −0 app/views/layouts/flash.html.php
  43. +27 −0 app/views/pages/home.html.php
  44. +7 −0 app/webroot/.htaccess
  45. +33 −0 app/webroot/css/base.css
  46. +281 −0 app/webroot/css/debug.css
  47. BIN app/webroot/favicon.ico
  48. 0 app/webroot/img/empty
  49. +28 −0 app/webroot/index.php
  50. +1 −0 app/webroot/js/empty
  51. +139 −0 app/webroot/test.php
  52. +25 −0 libraries/lithium/LICENSE.txt
  53. +215 −0 libraries/lithium/action/Controller.php
  54. +172 −0 libraries/lithium/action/Dispatcher.php
  55. +360 −0 libraries/lithium/action/Request.php
  56. +133 −0 libraries/lithium/action/Response.php
  57. +326 −0 libraries/lithium/console/Command.php
  58. +145 −0 libraries/lithium/console/Dispatcher.php
  59. +126 −0 libraries/lithium/console/Request.php
  60. +107 −0 libraries/lithium/console/Response.php
  61. +68 −0 libraries/lithium/console/Router.php
  62. +31 −0 libraries/lithium/console/commands/Docs.php
  63. +104 −0 libraries/lithium/console/commands/G11n.php
  64. +19 −0 libraries/lithium/console/commands/Generate.php
  65. +173 −0 libraries/lithium/console/commands/Test.php
  66. +53 −0 libraries/lithium/console/commands/docs/Generator.php
  67. +80 −0 libraries/lithium/console/commands/docs/Todo.php
  68. +19 −0 libraries/lithium/console/commands/generate/Component.php
  69. +19 −0 libraries/lithium/console/commands/generate/Controller.php
  70. +19 −0 libraries/lithium/console/commands/generate/Model.php
  71. +19 −0 libraries/lithium/console/commands/generate/View.php
  72. +23 −0 libraries/lithium/console/li3
  73. +55 −0 libraries/lithium/console/lithium.php
  74. +10 −0 libraries/lithium/console/templates/docs/header.txt.php
  75. +97 −0 libraries/lithium/core/Adaptable.php
  76. +94 −0 libraries/lithium/core/Environment.php
  77. +496 −0 libraries/lithium/core/Libraries.php
  78. +183 −0 libraries/lithium/core/Object.php
  79. +198 −0 libraries/lithium/core/StaticObject.php
  80. +92 −0 libraries/lithium/data/Connections.php
  81. +405 −0 libraries/lithium/data/Model.php
  82. +65 −0 libraries/lithium/data/Source.php
  83. +130 −0 libraries/lithium/data/model/Query.php
  84. +49 −0 libraries/lithium/data/model/Record.php
  85. +303 −0 libraries/lithium/data/model/RecordSet.php
  86. +485 −0 libraries/lithium/data/source/Database.php
  87. +246 −0 libraries/lithium/data/source/Http.php
  88. +267 −0 libraries/lithium/data/source/database/adapter/MySql.php
  89. +29 −0 libraries/lithium/data/source/http/adapter/Curl.php
  90. +17 −0 libraries/lithium/data/source/http/adapter/Stream.php
  91. +161 −0 libraries/lithium/g11n/Catalog.php
  92. +134 −0 libraries/lithium/g11n/Locale.php
  93. +103 −0 libraries/lithium/g11n/Message.php
  94. +126 −0 libraries/lithium/g11n/catalog/adapters/Base.php
  95. +120 −0 libraries/lithium/g11n/catalog/adapters/Cldr.php
  96. +144 −0 libraries/lithium/g11n/catalog/adapters/Code.php
  97. +355 −0 libraries/lithium/g11n/catalog/adapters/Gettext.php
  98. +79 −0 libraries/lithium/g11n/catalog/adapters/Memory.php
  99. +95 −0 libraries/lithium/http/Base.php
  100. +270 −0 libraries/lithium/http/Media.php
  101. +170 −0 libraries/lithium/http/Request.php
  102. +201 −0 libraries/lithium/http/Response.php
  103. +233 −0 libraries/lithium/http/Route.php
  104. +95 −0 libraries/lithium/http/Router.php
  105. +953 −0 libraries/lithium/http/Socket.php
  106. +174 −0 libraries/lithium/storage/Cache.php
  107. +183 −0 libraries/lithium/storage/Session.php
  108. +92 −0 libraries/lithium/storage/cache/adapters/Apc.php
  109. +100 −0 libraries/lithium/storage/cache/adapters/File.php
  110. +124 −0 libraries/lithium/storage/cache/adapters/Memcache.php
  111. +83 −0 libraries/lithium/storage/cache/adapters/Memory.php
  112. +74 −0 libraries/lithium/storage/session/adapters/Cookie.php
  113. +57 −0 libraries/lithium/storage/session/adapters/Memory.php
  114. +53 −0 libraries/lithium/storage/session/adapters/Php.php
  115. +133 −0 libraries/lithium/template/Helper.php
  116. +91 −0 libraries/lithium/template/View.php
  117. +151 −0 libraries/lithium/template/helpers/Form.php
  118. +343 −0 libraries/lithium/template/helpers/Html.php
  119. +302 −0 libraries/lithium/template/view/Renderer.php
  120. +100 −0 libraries/lithium/template/view/Stream.php
  121. +104 −0 libraries/lithium/template/view/adapters/File.php
  122. +61 −0 libraries/lithium/template/view/adapters/Simple.php
  123. +177 −0 libraries/lithium/test/Dispatcher.php
  124. +79 −0 libraries/lithium/test/Group.php
  125. +19 −0 libraries/lithium/test/Reporter.php
  126. +618 −0 libraries/lithium/test/Unit.php
  127. +291 −0 libraries/lithium/test/filters/Coverage.php
  128. +209 −0 libraries/lithium/test/filters/Profiler.php
  129. +259 −0 libraries/lithium/tests/cases/action/ControllerTest.php
  130. +54 −0 libraries/lithium/tests/cases/action/RequestTest.php
  131. +150 −0 libraries/lithium/tests/cases/action/ResponseTest.php
  132. +223 −0 libraries/lithium/tests/cases/console/CommandTest.php
  133. +95 −0 libraries/lithium/tests/cases/console/DispatcherTest.php
  134. +135 −0 libraries/lithium/tests/cases/console/RequestTest.php
  135. +112 −0 libraries/lithium/tests/cases/console/ResponseTest.php
  136. +81 −0 libraries/lithium/tests/cases/console/RouterTest.php
  137. +22 −0 libraries/lithium/tests/cases/console/commands/GenerateTest.php
  138. +98 −0 libraries/lithium/tests/cases/core/EnvironmentTest.php
  139. +146 −0 libraries/lithium/tests/cases/core/LibrariesTest.php
  140. +179 −0 libraries/lithium/tests/cases/core/ObjectTest.php
  141. +133 −0 libraries/lithium/tests/cases/core/StaticObjectTest.php
  142. +115 −0 libraries/lithium/tests/cases/data/ConnectionsTest.php
  143. +149 −0 libraries/lithium/tests/cases/data/ModelTest.php
  144. +65 −0 libraries/lithium/tests/cases/data/model/QueryTest.php
  145. +63 −0 libraries/lithium/tests/cases/data/model/RecordSetTest.php
  146. +68 −0 libraries/lithium/tests/cases/data/model/RecordTest.php
  147. +87 −0 libraries/lithium/tests/cases/data/source/DatabaseTest.php
  148. +209 −0 libraries/lithium/tests/cases/data/source/HttpTest.php
  149. +115 −0 libraries/lithium/tests/cases/data/source/database/adapter/MySqlTest.php
  150. +73 −0 libraries/lithium/tests/cases/data/source/http/adapter/CurlTest.php
  151. +93 −0 libraries/lithium/tests/cases/data/source/http/adapter/StreamTest.php
  152. +461 −0 libraries/lithium/tests/cases/g11n/CatalogTest.php
  153. +285 −0 libraries/lithium/tests/cases/g11n/LocaleTest.php
  154. +72 −0 libraries/lithium/tests/cases/g11n/MessageTest.php
  155. +67 −0 libraries/lithium/tests/cases/g11n/catalog/adapters/CldrTest.php
  156. +95 −0 libraries/lithium/tests/cases/g11n/catalog/adapters/CodeTest.php
  157. +71 −0 libraries/lithium/tests/cases/g11n/catalog/adapters/GettextTest.php
  158. +84 −0 libraries/lithium/tests/cases/http/BaseTest.php
  159. +145 −0 libraries/lithium/tests/cases/http/RequestTest.php
  160. +96 −0 libraries/lithium/tests/cases/http/ResponseTest.php
  161. +321 −0 libraries/lithium/tests/cases/http/RouteTest.php
  162. +235 −0 libraries/lithium/tests/cases/http/RouterTest.php
  163. +255 −0 libraries/lithium/tests/cases/storage/CacheTest.php
  164. +180 −0 libraries/lithium/tests/cases/storage/SessionTest.php
  165. +263 −0 libraries/lithium/tests/cases/storage/cache/adapters/ApcTest.php
  166. +126 −0 libraries/lithium/tests/cases/storage/cache/adapters/FileTest.php
  167. +265 −0 libraries/lithium/tests/cases/storage/cache/adapters/MemcacheTest.php
  168. +88 −0 libraries/lithium/tests/cases/template/HelperTest.php
  169. +37 −0 libraries/lithium/tests/cases/template/ViewTest.php
  170. +130 −0 libraries/lithium/tests/cases/template/helpers/FormTest.php
Sorry, we could not display the entire diff because it was too big.
View
2 .gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+app/libraries/plugins/*
View
5 .htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ app/webroot/ [L]
+ RewriteRule (.*) app/webroot/$1 [L]
+</IfModule>
View
5 app/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
+ </IfModule>
View
208 app/config/bootstrap.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium;
+
+use \lithium\core\Environment;
+use \lithium\core\Libraries;
+
+/**
+ * This is the path to the class libraries used by your application, and must contain a copy of the
+ * Lithium core. By default, this directory is named 'libraries', and resides in the same
+ * directory as your application. If you use the same libraries in multiple applications, you can
+ * set this to a shared path on your server.
+ */
+define('LITHIUM_LIBRARY_PATH', dirname(dirname(__DIR__)) . '/libraries');
+
+/**
+ * This is the path to your application's directory. It contains all the sub-folders for your
+ * application's classes and files. You don't need to change this unless your webroot folder is
+ * stored outside of your app folder.
+ */
+define('LITHIUM_APP_PATH', dirname(__DIR__));
+
+/**
+ * Locate and load Lithium core library files. Throws a fatal error if the core can't be found.
+ * If your Lithium core directory is named something other than 'lithium', change the string below.
+ */
+if (!include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php') {
+ $message = "Lithium core could not be found. Check the value of LITHIUM_LIBRARY_PATH in ";
+ $message .= "config/bootstrap.php. It should point to the directory containing your ";
+ $message .= "/libraries directory.";
+ trigger_error($message, E_USER_ERROR);
+}
+
+/**
+ * Add the Lithium core library. This sets default paths and initializes the autoloader. You
+ * generally should not need to override any settings.
+ */
+Libraries::add('lithium');
+
+/**
+ * Optimize default request cycle by loading common classes. If you're implementing custom
+ * request/response or dispatch classes, you can safely remove these. Actually, you can safely
+ * remove them anyway, they're just there to give slightly you better out-of-the-box performance.
+ */
+require LITHIUM_LIBRARY_PATH . '/lithium/core/Object.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/core/StaticObject.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/Collection.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/collection/Filters.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/Inflector.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/Set.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/String.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/core/Environment.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/http/Base.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/http/Media.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/http/Request.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/http/Response.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/http/Route.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
+
+/**
+ * Add the application. You can pass a `'path'` key here if this bootstrap file is outside of
+ * your main application, but generally you should not need to change any settings.
+ */
+Libraries::add('app');
+
+/**
+ * Add some plugins
+ */
+// Libraries::add('plugin', 'docs');
+
+/**
+ * This configures your session storage. The Cookie storage adapter must be connected first, since
+ * it intercepts any writes where the `'expires'` key is set in the options array. When creating a
+ * new application, it is suggested that you change the value of `'key'` below.
+ */
+
+/**
+* Session configuration
+*/
+// use \lithium\storage\Session;
+//
+// Session::config(array(
+// 'cookie' => array(
+// 'adapter' => 'Cookie',
+// 'name' => 'AppCookieName',
+// 'expires' => '+5 days',
+// 'domain' => '',
+// 'path' => '/',
+// 'filters' => array(
+// // 'Encryption' => array('key' => '0409448a5206980ab15682c3281c1a3b1fb10c55')
+// )
+// ),
+// 'default' => array('adapter' => 'Php', 'filters' => array())
+// ));
+
+/**
+ * To enable admin or plugin routing, uncomment the following lines, and see `app/config/routes.php`
+ * to enable the admin routing namespace.
+ */
+// use \lithium\action\Dispatcher;
+//
+// Dispatcher::config(array('rules' => array(
+// 'admin' => array('action' => 'admin_{:action}'),
+// 'plugin' => array('controller' => '{:plugin}.{:controller}')
+// )));
+
+/**
+ * Uncomment to set globalization defaults. A locale consists of a language and
+ * an optional territory code i.e. `'en_US'` or `'en'`. For timezone specify
+ * a valid timezone identifier i.e. `'America/New_York'` or `'Etc/UTC'`. You may
+ * also specify additional sources for retrieving translated and messages and
+ * localized data or add rules, formats, messages or lists data right here.
+ */
+// use \lithium\g11n\G11n;
+//
+// G11n::locale('en');
+// G11n::timezone('Etc/UTC');
+// G11n::sources(LITHIUM_APP_PATH . '/extensions/g11n');
+// G11n::rules('plural', array('en' => function($n) { return $n != 1 ? 1 : 0; }));
+
+/*
+ * Inflector configuration example. If your application has custom singular or plural rules, or
+ * extra non-ASCII characters to transliterate, you can configure that by uncommenting the lines
+ * below.
+ */
+// use lithium\util\Inflector;
+//
+// Inflector::rules("plural", array(
+// '/(s)tatus$/i' => '\1\2tatuses',
+// '/^(ox)$/i' => '\1\2en',
+// '/([m|l])ouse$/i' => '\1ice'
+// ));
+//
+// Inflector::rules("uninflectedPlural", array('.*[nrlm]ese', '.*deer', '.*ois', '.*pox'));
+//
+// Inflector::rules("irregularPlural", array('atlas' => 'atlases', 'brother' => 'brothers'));
+//
+// Inflector::rules("singular", array(
+// '/(s)tatuses$/i' => '\1\2tatus',
+// '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i'
+// ));
+
+/**
+ * Globalization (g11n) catalog configuration. The catalog allows for obtaining and
+ * writing globalized data. Each configuration can be adjusted through the following settings:
+ *
+ * - `'adapter' The name of a supported adapter. The builtin adapters are _memory_ (a
+ * simple adapter good for runtime data and testing), _gettext_, _cldr_ (for
+ * interfacing with Unicode's common locale data repository) and _code_ (used mainly for
+ * extracting message templates from source code).
+ *
+ * - `'path'` All adapters with the exception of the _memory_ adapter require a directory
+ * which holds the data.
+ *
+ * - `'scope'` If you plan on using scoping i.e. for accessing plugin data separately you
+ * need to specify a scope for each configuration, except for those using the _memory_ or
+ * _gettext_ adapter which handle this internally.
+ */
+// use lithium\g11n\Catalog;
+//
+// Catalog::config(array(
+// 'runtime' => array('adapter' => 'Memory'),
+// 'app' => array('adapter' => 'Gettext', 'path' => LITHIUM_APP_PATH . '/resources/po'),
+// 'lithium' => array('adapter' => 'Gettext', 'path' => LITHIUM_LIBRARY_PATH . '/lithium/resources/po')
+// ));
+
+/**
+ * Globalization runtime data. You can add globalized data during runtime utilizing a
+ * configuration set up to use the _memory_ adapter.
+ */
+// $data = array('en' => function($n) { return $n != 1 ? 1 : 0; });
+// Catalog::write('message.plural', $data, array('name' => 'runtime'));
+
+/**
+ * Enabling globalization integration. Classes in the framework are designed with
+ * globalization in mind. To enable globalization for these classes we just need to pass
+ * the needed data into them.
+ */
+// use lithium\util\Validator;
+// use lithium\util\Inflector;
+//
+// Validator::add('postalCode',
+// Catalog::read('validation.postalCode', array('en_US'))
+// );
+// Inflector::rules('transliterations',
+// Catalog::read('inflection.transliteration', array('en'))
+// );
+
+/**
+ * Your custom code goes here.
+ */
+
+?>
View
78 app/config/connections.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use \lithium\data\Connections;
+
+/**
+ * Database configuration.
+ * You can specify multiple configurations for production, development and testing.
+ *
+ * adapter => The name of a supported driver; valid options are as follows:
+ * mysql - MySQL 4 & 5,
+ * mysqli - MySQL 4 & 5 Improved Interface (PHP5 only),
+ * sqlite - SQLite (PHP5 only),
+ * postgres - PostgreSQL 7 and higher,
+ * mssql - Microsoft SQL Server 2000 and higher,
+ * db2 - IBM DB2, Cloudscape, and Apache Derby (http://php.net/ibm-db2)
+ * oracle - Oracle 8 and higher
+ * firebird - Firebird/Interbase
+ * sybase - Sybase ASE
+ *
+ * You can add custom database drivers (or override existing drivers) by adding the
+ * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
+ * where 'x' is the name of the database.
+ *
+ * persistent => true / false
+ * Determines whether or not the database should use a persistent connection.
+ *
+ * host =>
+ * the host you connect to the database. To add a socket or port number, use 'port' => #
+ *
+ * prefix =>
+ * Uses the given prefix for all the tables in this database. This setting can be overridden
+ * on a per-table basis with the Model::$_meta['prefix'] property.
+ *
+ * schema =>
+ * For Postgres and DB2, specifies which schema you would like to use the tables in. Postgres
+ * defaults to 'public', DB2 defaults to empty.
+ *
+ * encoding =>
+ * For MySQL, MySQLi, Postgres and DB2, specifies the character encoding to use when connecting
+ * to the database. Defaults to 'UTF-8' for DB2. Uses database default for all others.
+ */
+Connections::add('default', 'Database', array(
+ // 'development' => array(
+ 'adapter' => 'MySql',
+ 'host' => 'localhost',
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'lithium-blog'
+ // 'adapter' => 'sqlite',
+ // 'database' => LITHIUM_APP_PATH . '/tmp/default.db'
+ // ),
+ // 'test' => array(
+ // 'adapter' => 'mysql',
+ // 'host' => 'localhost',
+ // 'login' => 'user',
+ // 'password' => 'password',
+ // 'database' => 'test_database_name'
+ // ),
+ // 'production' => array(
+ // 'adapter' => 'mysql',
+ // 'host' => 'localhost',
+ // 'login' => 'user',
+ // 'password' => 'password',
+ // 'database' => 'test_database_name'
+ // )
+));
+
+?>
View
57 app/config/environments.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use \lithium\core\Libraries;
+use \lithium\core\Environment;
+
+/*
+ * Set up the "development" environment
+ */
+Environment::set("development", array(
+ "Output.varDump" => true, // Writes output from pr() and debug()
+ "Output.sqlDump" => true, // Writes SQL log at the bottom of the page
+ "Output.timestamp.enabled" => true, // Output the page generation time
+ "Output.timestamp.format" => "<!-- %01.4fs -->", // Page generation time output format string
+ "Cache.enabled" => true,
+ "Cache.expires" => "+10 seconds",
+ "Asset.compress" => false,
+ "Asset.timestamp" => true
+));
+
+/*
+ * Set the current environment to "development"
+ */
+
+Environment::set("development");
+
+/*
+ * Inflector configuration example
+ */
+// Inflector::add("plural", array(
+// '/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice'
+// ));
+// Inflector::add("uninflectedPlural", array(
+// '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox'
+// ));
+// Inflector::add("irregularPlural", array(
+// 'atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers'
+// ));
+// Inflector::add("singular", array(
+// '/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i'
+// ));
+
+/*
+ * Paths configuration example
+ */
+// Libraries::addPluginPath("/path/to/more/plugins");
+
+?>
View
31 app/config/environments/development.php
@@ -0,0 +1,31 @@
+<?php
+
+use \lithium\core\Libraries;
+use \lithium\core\Environment;
+
+/*
+ * Set up the "development" environment
+ */
+Environment::set("development", array(
+ "Output.varDump" => true, // Writes output from pr() and debug()
+ "Output.sqlDump" => true, // Writes SQL log at the bottom of the page
+ "Output.timestamp.enabled" => true, // Output the page generation time
+ "Output.timestamp.format" => "<!-- %01.4fs -->", // Page generation time output format string
+ "Cache.enabled" => true,
+ "Cache.expires" => "+10 seconds",
+ "Asset.compress" => false,
+ "Asset.timestamp" => true,
+ // "G11n.locale" => "en",
+ // "G11n.timezone" => "Etc/UTC",
+ // "G11n.currency" => "USD"
+));
+
+/*
+ * Set the current environment to "development"
+ */
+// switch (true) {
+// case
+// }
+Environment::set("development");
+
+?>
View
40 app/config/routes.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use \lithium\http\Router;
+
+/**
+ * Uncomment the line below to enable routing for admin actions.
+ * @todo Implement me.
+ */
+// Router::namespace('/admin', array('admin' => true));
+
+/**
+ * Here, we are connecting '/' (base path) to controller called 'Pages',
+ * its action called 'view', and we pass a param to select the view file
+ * to use (in this case, /app/views/pages/home.html.php)...
+ */
+Router::connect('/', array('controller' => 'pages', 'action' => 'view', 'home'));
+
+/**
+ * ...and connect the rest of 'Pages' controller's urls.
+ */
+Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'view'));
+
+/**
+ * Finally, connect the default routes.
+ */
+Router::connect('/{:controller}/{:action}/{:id:[0-9]+}.{:type}', array('id' => null));
+Router::connect('/{:controller}/{:action}/{:id:[0-9]+}');
+Router::connect('/{:controller}/{:action}/{:args}');
+
+?>
View
0 app/config/schema/empty
No changes.
View
63 app/config/switchboard.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * Welcome to the switchboard. This file contains a series of method filters that allow you to
+ * intercept different parts of Lithium's request cycle as they happen. You can apply filters to
+ * any object method that has a `@filter` flag in its API documentation.
+ *
+ * When applying a filter, you need the name of the method you want to call, along with a *closure*,
+ * that defines what you want the filter to do. All filters take the same 3 parameters: `$self`,
+ * `$params`, and `$chain`.
+ *
+ * - `$self`: If the filter is applied on an object instance, then `$self` will be that instance. If
+ * applied to a static class, then `$self` will be a string containing the fully-namespaced class
+ * name.
+ *
+ * - `$params`: Contains an associative array of the parameters that are passed into the method. You
+ * can modify or inspect these parameters before allowing the method to continue.
+ *
+ * - `$chain`: Finally, `$chain` contains the list of filters in line to be executed. At the bottom
+ * of `$chain` is the method itself. This is why most filters contain a line that looks like
+ * `return $chain->next($self, $params, $chain);`. This passes control to the next filter in the
+ * chain, and finally, to the method itself. This allows you to interact with the return value as
+ * well as the parameters.
+ */
+
+use \lithium\http\Router;
+use \lithium\core\Environment;
+use \lithium\action\Dispatcher;
+
+/**
+ * Loads application routes before the request is dispatched. Change this to `include_once` if
+ * more than one request cycle is executed per HTTP request.
+ *
+ * @see lithium\http\Router
+ */
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ include __DIR__ . '/routes.php';
+ return $chain->next($self, $params, $chain);
+});
+
+/**
+ * Intercepts the `Dispatcher` as it finds a controller object, and passes the `'request'` parameter
+ * to the `Environment` class to detect which environment the application is running in.
+ *
+ * @see lithium\action\Request
+ * @see lithium\core\Environment
+ */
+Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ Environment::set($params['request']);
+ return $chain->next($self, $params, $chain);
+});
+
+?>
View
22 app/controllers/HelloWorldController.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace app\controllers;
+
+class HelloWorldController extends \lithium\action\Controller {
+
+ public $helpers = array();
+
+ public function index() {
+ $this->render(array('layout' => false));
+ }
+
+ public function to_string() {
+ return "Hello World";
+ }
+
+ public function to_json() {
+ $this->render(array('json' => 'Hello World'));
+ }
+}
+
+?>
View
30 app/controllers/PagesController.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Controllers;
+
+use \lithium\util\Inflector;
+
+class PagesController extends \lithium\action\Controller {
+
+ public $helpers = array('Html');
+
+ function view() {
+ $path = func_get_args();
+
+ if (!count($path)) {
+ $path = array('home');
+ }
+
+ $count = count($path);
+ $page = $subpage = $title = null;
+
+ $page = (!empty($path[0]) ? $path[0] : $page);
+ $subpage = (!empty($path[1]) ? $path[1] : $subpage);
+ $title = (!empty($path[$count - 1]) ? Inflector::humanize($path[$count - 1]) : $title);
+
+ $this->set(compact('page', 'subpage', 'title'));
+ $this->render(join('/', $path));
+ }
+}
+
+?>
View
0 app/extensions/adapters/empty
No changes.
View
0 app/extensions/behaviors/empty
No changes.
View
0 app/extensions/commands/empty
No changes.
View
0 app/extensions/components/empty
No changes.
View
0 app/extensions/data/sources/empty
No changes.
View
0 app/extensions/g11n/empty
No changes.
View
0 app/extensions/helpers/empty
No changes.
View
15 app/index.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+require 'webroot/index.php';
+
+?>
View
0 app/libraries/empty
No changes.
View
0 app/models/empty
No changes.
View
0 app/tests/cases/controllers/empty
No changes.
View
0 app/tests/cases/extensions/adapters/empty
No changes.
View
0 app/tests/cases/extensions/behaviors/empty
No changes.
View
0 app/tests/cases/extensions/commands/empty
No changes.
View
0 app/tests/cases/extensions/components/empty
No changes.
View
0 app/tests/cases/extensions/data_sources/empty
No changes.
View
0 app/tests/cases/extensions/helpers/empty
No changes.
View
0 app/tests/cases/models/empty
No changes.
View
0 app/tests/fixtures/empty
No changes.
View
0 app/tests/groups/empty
No changes.
View
0 app/tmp/cache/empty
No changes.
View
0 app/tmp/logs/empty
No changes.
View
0 app/views/elements/empty
No changes.
View
1 app/views/hello_world/index.html.php
@@ -0,0 +1 @@
+Hello World!
View
15 app/views/layouts/default.ajax.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+echo $content_for_layout;
+
+?>
View
22 app/views/layouts/default.email.html.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+?>
+<!doctype html>
+
+<html>
+<head>
+ <title><?=$this->title; ?></title>
+</head>
+<body>
+ <?=@$this->content; ?>
+</body>
+</html>
View
15 app/views/layouts/default.email.txt.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+echo $content_for_layout;
+
+?>
View
31 app/views/layouts/default.html.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+?>
+<!doctype html>
+<html>
+<head>
+ <?=@$this->html->charset(); ?>
+ <title><?=$title; ?></title>
+ <?=@$this->html->style('base'); ?>
+ <?=@$this->scripts(); ?>
+ <?=@$this->html->link('Icon', null, array('type' => 'icon')); ?>
+</head>
+<body>
+ <div id="container">
+ <div id="header"></div>
+ <div id="content">
+ <?=@$this->content; ?>
+ </div>
+ <div id="footer"></div>
+ </div>
+</body>
+</html>
View
14 app/views/layouts/default.xml.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+?>
+<?=@$xml->header(); ?>
+<?=@$content_for_layout; ?>
View
33 app/views/layouts/flash.html.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use \lithium\core\Environment;
+
+?>
+<!doctype html>
+<html>
+<head>
+ <?php echo $this->html->charset(); ?>
+ <title><?php echo $page_title; ?></title>
+ <?php if (Environment::is('production')) { ?>
+ <meta http-equiv="Refresh" content="<?=$pause?>;url=<?=$url?>"/>
+ <?php } ?>
+ <style>
+ p { text-align:center; font:bold 1.1em sans-serif }
+ a { color:#444; text-decoration: none }
+ a:hover { text-decoration: underline; color: #44E }
+ </style>
+</head>
+<body>
+ <p><a href="<?=$url; ?>"><?=$message; ?></a></p>
+</body>
+</html>
View
27 app/views/pages/home.html.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+?>
+<h2>Lithium is coming...</h2>
+
+<p>
+ temporary home page that will eventually be filled with configuration checks.
+</p>
+
+<p>
+ <a href="http://rad-dev.org/lithium/wiki">Lithium Wiki</a>
+</p>
+<p>
+ <a href="http://rad-dev.org/lithium3">Lithium Source</a>
+</p>
+<p>
+ <a href="http://groups.google.com/group/lithium">Lithium Google Group</a>
+</p>
View
7 app/webroot/.htaccess
@@ -0,0 +1,7 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !favicon.ico$
+ RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
+</IfModule>
View
33 app/webroot/css/base.css
@@ -0,0 +1,33 @@
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+* {
+ margin: 0;
+ padding: 0;
+}
+
+body {
+ background-color: #CCC;
+ font-family: Helvetica, Arial, sans-serif;
+ margin: 2em;
+}
+
+a {
+ color: #333;
+}
+
+a:hover {
+ text-decoration: none;
+}
+
+p {
+ margin-top: 1em;
+}
View
281 app/webroot/css/debug.css
@@ -0,0 +1,281 @@
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+h1.test-dashboard {
+ padding: 8px 0 4px 14px;
+ background: #B5B4A4;
+}
+
+/*--- Benchmarking ---*/
+table.metrics {
+ border: 0;
+ border-top: 1px solid #ccc;
+}
+
+td.metric-name {
+ text-align: left;
+ white-space: nowrap;
+ padding: 6px 8px;
+ background: #f4f4f4;
+ width: 35%;
+}
+td.metric {
+ border: 0;
+ font-family: 'Courier New', Courier;
+ font-weight: bold;
+ padding: 6px 8px;
+ text-align: right;
+ width: 65%;
+}
+
+ul.classes, ul.files {
+ list-style-type: none;
+ font-family: 'Andale Mono';
+}
+
+/*--- Test Results ---*/
+div.test-result {
+ margin: 0 0 15px 0;
+ padding: 8px 10px;
+ color: #FFFFFF;
+ border: 2px solid #000000;
+ font-family: Helvetica, Arial, sans-serif;
+ font-weight: bold;
+ font-size: 16px;
+}
+
+div.test-result-success {
+ background-color: #33CC66;
+ border-color: #009933;
+}
+
+div.test-result-fail {
+ background-color: #CC0033;
+ border-color: #990000;
+}
+
+div.test-assert, div.test-exception {
+ margin: 4px 0;
+ padding: 4px 8px;
+ color: #000000;
+ border: 1px solid #000000;
+ font-family: 'Monaco', 'Andale Mono', Helvetica, Arial, sans-serif;
+ line-height: 20px;
+ font-size: 12px;
+}
+
+div.test-assert-passed {
+ border-color: #339966;
+ background-color: #D0F9E0;
+}
+
+div.test-assert-failed, div.test-exception {
+ border-color: #993366;
+ background-color: #F9D0E0;
+}
+
+div.test-assert span.content, div.test-exception span.content, div.test-exception span.trace {
+ display: block;
+ clear: both;
+ white-space: pre;
+}
+
+div.test-exception span.content {
+ font-style: italic;
+}
+
+div.test-exception span.trace {
+ padding: 0 0 0 5px;
+ margin: 2px 0 2px 3px;
+ border-left: 1px solid #C09090;
+}
+
+/*--- SQL Dumps ---*/
+.lithium-sql-log table {
+ background: #f4f4f4;
+}
+
+.lithium-sql-log td {
+ padding: 4px 8px;
+ text-align: left;
+}
+
+
+/*--- Debugger Dumps ---*/
+pre {
+ color: #000;
+ background: #f0f0f0;
+ padding: 1em;
+}
+
+pre.lithium-debug {
+ background: #ffcc00;
+ font-size: 120%;
+ line-height: 140%;
+ margin-top: 1em;
+ overflow: auto;
+ position: relative;
+}
+
+div.lithium-stack-trace {
+ background: #fff;
+ border: 4px dotted #ffcc00;
+ color: #333;
+ margin: 0px;
+ padding: 6px;
+ font-size: 120%;
+ line-height: 140%;
+ overflow: auto;
+ position: relative;
+}
+
+/*--- Code Highlighting ---*/
+div.lithium-code-dump pre {
+ position: relative;
+ overflow: auto;
+}
+
+div.lithium-stack-trace pre, div.lithium-code-dump pre {
+ color: #000;
+ background-color: #F0F0F0;
+ margin: 0px;
+ padding: 1em;
+ overflow: auto;
+}
+
+div.lithium-code-dump pre, div.lithium-code-dump pre code {
+ clear: both;
+ font-size: 12px;
+ line-height: 15px;
+ margin: 4px 2px;
+ padding: 4px;
+ overflow: auto;
+}
+
+div.lithium-code-dump span.code-highlight {
+ background-color: #ff0;
+ padding: 4px;
+}
+
+/*--- Code Coverage Analysis ---*/
+span.filters {
+ float: right;
+ margin-top: -17px;
+}
+
+div.code-coverage-results {
+ color: #000000;
+ font-size: 11px;
+ font-family: 'Andale Mono';
+ background-color: #F0F0F0;
+ border: 1px solid #CCCCCC;
+}
+
+h4.coverage {
+ color: #000000;
+ background-color: #FFFFFF;
+ font-family: Helvetica, Arial;
+ font-weight: bold;
+ margin: 6px 0 3px 3px;
+ padding: 0;
+}
+
+div.code-coverage-results h4.name {
+ color: #666;
+ background-color: #F0F0F0;
+ border-bottom: 1px solid #999;
+ padding: 3px 0;
+ font-size: 12px;
+}
+
+div.code-coverage-results div.code-line {
+ display: block;
+ float: none;
+ clear: both;
+ padding-left: 5px;
+ margin-left: 10px;
+}
+
+div.code-coverage-results span.content {
+ display: block;
+ clear: right;
+ white-space: pre;
+ line-height: 20px;
+}
+
+div.code-coverage-results div.uncovered span.content {
+ color: #B00;
+ background-color: #FEE;
+}
+
+div.code-coverage-results div.covered span.content {
+ color: #080;
+ background-color: #DFD;
+}
+
+div.code-coverage-results div.ignored span.content {
+ color: #aaa;
+}
+
+div.code-coverage-results span.line-num {
+ display: block;
+ float: left;
+ font-family: Helvetica, Arial, sans-serif;
+ width: 20px;
+ color: #A9A9A9;
+ text-align: right;
+ background-color: #ECECEC;
+ border-right: 1px solid #DDDDDD;
+ padding-right: 2px;
+ margin-right: 5px;
+ line-height: 20px;
+}
+
+div.code-coverage-results span.line-num strong {
+ color: #666;
+}
+
+div.code-coverage-results div.start {
+ margin-top: 30px;
+ padding-top: 5px;
+ border: 1px solid #aaa;
+ border-width: 1px 1px 0px 1px;
+}
+
+div.code-coverage-results div.end {
+ margin-bottom: 30px;
+ padding-bottom: 5px;
+ border: 1px solid #aaa;
+ border-width: 0px 1px 1px 1px;
+}
+
+div.code-coverage-results div.realstart {
+ margin-top: 0px;
+}
+
+div.code-coverage-results p.note {
+ color: #bbb;
+ padding: 5px;
+ margin: 5px 0 10px;
+ font-size: 10px;
+}
+
+div.code-coverage-results span.result-bad {
+ color: #a00;
+}
+
+div.code-coverage-results span.result-ok {
+ color: #fa0;
+}
+
+div.code-coverage-results span.result-good {
+ color: #0a0;
+}
View
BIN app/webroot/favicon.ico
Binary file not shown.
View
0 app/webroot/img/empty
No changes.
View
28 app/webroot/index.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * Welcome to Lithium 3! This front-controller file is the gateway to your application. It is
+ * responsible for intercepting requests, and handing them off to the Dispatcher for processing.
+ *
+ * If you're sharing a single Lithium core install or other libraries among multiple
+ * applications, you may need to manually set things like LITHIUM_LIBRARY_PATH. You can do that in
+ * app/config/bootstrap.php, which is loaded below:
+ */
+require dirname(__DIR__) . '/config/bootstrap.php';
+
+/**
+ * Dispatch a new request with the default settings.
+ */
+echo lithium\action\Dispatcher::run();
+
+?>
View
1 app/webroot/js/empty
@@ -0,0 +1 @@
+
View
139 app/webroot/test.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use \lithium\core\Libraries;
+use \lithium\test\Group;
+use \lithium\test\Dispatcher;
+use \lithium\util\Inflector;
+use \lithium\util\reflection\Inspector;
+
+$startBenchmark = microtime(true);
+
+error_reporting(E_ALL | E_STRICT | E_DEPRECATED);
+
+require dirname(__DIR__) . '/config/bootstrap.php';
+$core = dirname(dirname(__DIR__)) . '/libraries/lithium';
+
+$testRun = Dispatcher::run(null, $_GET);
+$stats = Dispatcher::process($testRun['results']);
+
+?>
+<!doctype html>
+<html>
+ <head>
+ <title>Lithium3 Unit Test Dashboard</title>
+ <link rel="stylesheet" href="css/base.css" />
+ <link rel="stylesheet" href="css/debug.css" />
+ </head>
+ <body>
+ <h1 class="test-dashboard">Lithium3 Unit Test Dashboard</h1>
+
+ <div style="float: left; padding: 10px 0 20px 20px; width: 20%;">
+ <h2><a href="?group=\">Tests</a></h2>
+ <?php echo Dispatcher::menu('html'); ?>
+ </div>
+
+ <div style="float:left; padding: 10px; width: 75%">
+ <h2>Stats for <?php echo $testRun['title']; ?></h2>
+
+ <h3>Test results</h3>
+
+ <span class="filters">
+ <?php
+ $filters = Libraries::locate('testFilters');
+ $base = $_SERVER['REQUEST_URI'];
+
+ foreach ($filters as $i => $class) {
+ $url = $base . "&amp;filters[]={$class}";
+ $name = join('', array_slice(explode("\\", $class), -1));
+ $key = Inflector::underscore($name);
+
+ echo "<a class=\"{$key}\" href=\"{$url}\">{$name}</a>";
+
+ if ($i < count($filters) - 1) {
+ echo ' | ';
+ }
+ }
+ ?>
+ </span>
+
+ <?php
+ $passes = count($stats['passes']);
+ $fails = count($stats['fails']);
+ $errors = count($stats['errors']);
+ $exceptions = count($stats['exceptions']);
+ $success = ($passes === $stats['asserts'] && $errors === 0);
+
+ echo '<div class="test-result test-result-' . ($success ? 'success' : 'fail') . '"';
+ echo ">{$passes} / {$stats['asserts']} passes, {$fails} ";
+ echo ((intval($stats['fails']) == 1) ? 'fail' : 'fails') . " and {$exceptions} ";
+ echo ((intval($exceptions) == 1) ? 'exceptions' : 'exceptions');
+ echo '</div>';
+
+ foreach ((array)$stats['errors'] as $error) {
+ switch ($error['result']) {
+ case 'fail':
+ $error += array('class' => 'unknown', 'method' => 'unknown');
+ echo '<div class="test-assert test-assert-failed">';
+ echo "Assertion '{$error['assertion']}' failed in ";
+ echo "{$error['class']}::{$error['method']}() on line ";
+ echo "{$error['line']}: ";
+ echo "<span class=\"content\">{$error['message']}</span>";
+ break;
+ case 'exception':
+ echo '<div class="test-exception">';
+ echo "Exception thrown in {$error['class']}::{$error['method']}() ";
+ echo "on line {$error['line']}: ";
+ echo "<span class=\"content\">{$error['message']}</span>";
+ if (isset($error['trace']) && !empty($error['trace'])) {
+ echo "Trace:<span class=\"trace\">{$error['trace']}</span>";
+ }
+ break;
+ }
+ echo '</div>';
+ }
+
+ foreach ((array)$testRun['filters'] as $class => $data) {
+ echo $class::output('html', $data);
+ }
+
+ $tests = Group::all(array('transform' => true));
+ $exclude = '/\w+Test$|webroot|index$|^app\\\\config|^\w+\\\\views\/|\./';
+ $options = compact('exclude') + array('recursive' => true);
+ $classes = array_diff(Libraries::find('lithium', $options), $tests);
+ sort($classes);
+ ?>
+ <h3>Classes with no test case (<?php echo count($classes); ?>)</h3>
+ <ul class="classes">
+ <?php
+ foreach ($classes as $class) {
+ echo "<li>{$class}</li>";
+ }
+ ?>
+ </ul>
+
+ <h3>Included files (<?php echo count(get_included_files()); ?>)</h3>
+ <ul class="files">
+ <?php
+ $base = dirname(dirname($core));
+ $files = str_replace($base, '', get_included_files());
+ sort($files);
+
+ foreach ($files as $file) {
+ echo "<li>{$file}</li>";
+ }
+ ?>
+ </ul>
+ </div>
+ <div style="clear:both"></div>
+ </body>
+</html>
View
25 libraries/lithium/LICENSE.txt
@@ -0,0 +1,25 @@
+Copyright (c) 2009, Union of Rad, Inc. http://union-of-rad.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Lithium, Union or Rad, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
215 libraries/lithium/action/Controller.php
@@ -0,0 +1,215 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\action;
+
+use \Exception;
+
+/**
+ * The bulk of the controller code in 1.2 that we need to be concerned with can be broken down
+ * into these things:
+ *
+ * - Merging inherited configuration. We might possibly be able to handle this in a more
+ * generalized way and at a higher level. It may be a good use-case for a generic way
+ * to handle object configuration
+ *
+ * - Interacting with the view. This includes passing variables, determining formats and
+ * template/layout locations, and determining helpers.
+ *
+ * - Handling responses and flow control. This includes rendering, redirecting, and
+ * callbacks.
+ *
+ * - Action-oriented caching.
+ *
+ * - Pagination. I don't know how I feel about this. It kind of feels like it needs it's
+ * own object
+ */
+class Controller extends \lithium\core\Object {
+
+ public $request = null;
+
+ public $response = null;
+
+ protected $_render = array(
+ 'type' => 'html',
+ 'data' => array(),
+ 'auto' => true,
+ 'layout' => 'default',
+ 'template' => null,
+ 'hasRendered' => false
+ );
+
+ protected $_classes = array(
+ 'media' => '\lithium\http\Media',
+ 'router' => '\lithium\http\Router',
+ 'response' => '\lithium\action\Response'
+ );
+
+ public function __construct($config = array()) {
+ $defaults = array(
+ 'request' => null, 'response' => array(),
+ 'render' => array(), 'classes' => array()
+ );
+ $config += $defaults;
+
+ if (!empty($config['request'])) {
+ $this->request = $config['request'];
+ }
+
+ foreach (array('render', 'classes') as $key) {
+ if (!empty($config[$key])) {
+ $this->{'_' . $key} = (array)$config[$key] + $this->{'_' . $key};
+ }
+ }
+ parent::__construct($config);
+ }
+
+ /**
+ * Called by the Dispatcher class to invoke an action.
+ *
+ * @param object $request The request object with URL and HTTP info for dispatching this action.
+ * @param array $dispatchParams The array of parameters that will be passed to the action.
+ * @param array $options The dispatch options for this action.
+ * @return object Returns the response object associated with this controller.
+ * @todo Implement proper exception catching/throwing
+ */
+ public function __invoke($request, $dispatchParams, $options = array()) {
+ $classes = $this->_classes;
+ $config = $this->_config;
+ $render =& $this->_render;
+
+ $filter = function($self, $params, $chain) use ($config, $classes, &$render) {
+ extract($params, EXTR_OVERWRITE);
+ $action = $dispatchParams['action'];
+ $args = isset($dispatchParams['args']) ? $dispatchParams['args'] : array();
+ $result = null;
+
+ if (substr($action, 0, 1) == '_' || method_exists(__CLASS__, $action)) {
+ throw new Exception('Private method!');
+ }
+
+ $response = $config['response'] + array('request' => $self->request);
+ $self->response = new $classes['response']($response);
+ $render['template'] = $render['template'] ?: $action;
+
+ try {
+ $result = $self->invokeMethod($action, $args);
+ } catch (Exception $e) {
+ // See todo, temporary alleviating obscure failure
+ throw $e;
+ }
+
+ if (!empty($result)) {
+ if (is_string($result)) {
+ $self->render(array('text' => $result));
+ } elseif (is_array($result)) {
+ $self->set($result);
+ }
+ }
+
+ if (!$render['hasRendered'] && $render['auto']) {
+ $self->render($action);
+ }
+ return $self->response;
+ };
+ return $this->_filter(__METHOD__, compact('dispatchParams', 'request', 'options'), $filter);
+ }
+
+ public function set($data = array()) {
+ $this->_render['data'] += (array)$data;
+ }
+
+ /**
+ * Uses results (typically coming from a controller action) to generate content and headers for
+ * a Response object.
+ *
+ * @param mixed $options A string template name (see the 'template' option below), or an array
+ * of options, as follows:
+ * - 'template': The name of a template, which usually matches the name of the
+ * action. By default, this template is looked for in the views directory of the
+ * current controller, i.e. given a `PostsController` object, if template is set
+ * to `'view'`, the template path would be `views/posts/view.html.php`. Defaults
+ * to the name of the action being rendered.
+ * - 'head': If true, only renders the headers of the response, not the body.
+ * Defaults to false.
+ * - 'data': An associative array of variables to be assigned to the template.
+ * These are merged on top of any variables set in `Controller::set()`.
+ * @return void
+ */
+ public function render($options = array()) {
+ if (is_string($options)) {
+ $options = array('template' => $options);
+ }
+ $defaults = array(
+ 'status' => 200, 'location' => false,
+ 'data' => array(), 'head' => false,
+ );
+ $options += $defaults;
+ $media = $this->_classes['media'];
+
+ if (!empty($options['data'])) {
+ $this->set($options['data']);
+ unset($options['data']);
+ }
+ $options = $options + $this->_render + array('request' => $this->request);
+ $type = key($options);
+ $types = array_flip($media::types());
+
+ if (isset($types[$type])) {
+ $options['type'] = $type;
+ $this->set(current($options));
+ unset($options[$type]);
+ }
+
+ $this->_render['hasRendered'] = true;
+ $this->response->type($options['type']);
+ $this->response->status($options['status']);
+ $this->response->headers('Location', $options['location']);
+
+ if ($options['head']) {
+ return;
+ }
+ $data = $this->_render['data'];
+ $data = (isset($data[0]) && count($data) == 1) ? $data[0] : $data;
+ $media::render($this->response, $data, $options);
+ }
+
+ /**
+ * Creates a redirect response.
+ *
+ * @param mixed $url
+ * @param array $options
+ * @return void
+ */
+ public function redirect($url, $options = array()) {
+ $router = $this->_classes['router'];
+ $defaults = array(
+ 'location' => $router::match($url, $this->request),
+ 'status' => 302,
+ 'head' => true,
+ 'exit' => true
+ );
+ $options += $defaults;
+
+ $this->_filter(__METHOD__, compact('options'), function($self, $params, $chain) {
+ $self->render($params['options']);
+ });
+
+ if ($options['exit']) {
+ $this->response->render();
+ $this->_stop();
+ }
+ return $this->response;
+ }
+}
+
+?>
View
172 libraries/lithium/action/Dispatcher.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\action;
+
+use \Exception;
+use \lithium\util\String;
+use \lithium\util\Inflector;
+use \lithium\core\Libraries;
+use \lithium\core\Environment;
+
+class Dispatcher extends \lithium\core\StaticObject {
+
+ /**
+ * Fully-namespaced router class reference. Class must implement a `parse()` method,
+ * which must return an array with (at a minimum) 'controller' and 'action' keys.
+ *
+ * @see lithium\http\Router::parse()
+ * @var array
+ */
+ protected static $_classes = array(
+ 'request' => '\lithium\action\Request',
+ 'router' => '\lithium\http\Router'
+ );
+
+ /**
+ * Contains pre-process format strings for changing Dispatcher's behavior based on 'rules'.
+ * Each key in the array represents a 'rule'; if a key that matches the rule is present (and
+ * not empty) in a route, (i.e. the result of `lithium\http\Router::parse()`) then the rule's
+ * value will be applied to the route before it is dispatched. When applying a rule, any array
+ * elements array elements of the flag which are present in the route will be modified using a
+ * `lithium\util\String::insert()`-formatted string.
+ *
+ * For example, to implement action prefixes (i.e. `admin_index()`), set a rule named 'admin',
+ * with a value array containing a modifier key for the `action` element of a route, i.e.:
+ * `array('action' => 'admin_{:action}')`. See `Dispatcher::config()` for examples
+ * on setting rules.
+ *
+ * @see lithium\action\Dispatcher::config()
+ * @see lithium\util\String::insert()
+ */
+ protected static $_rules = array();
+
+ /**
+ * Used to set configuration parameters for the Dispatcher.
+ *
+ * @param array $config
+ * @return array|void If no parameters are passed, returns an associative array with the
+ * current configuration, otherwise returns null.
+ */
+ public static function config($config = array()) {
+ if (empty($config)) {
+ return array('rules' => static::$_rules);
+ }
+
+ foreach ($config as $key => $val) {
+ if (isset(static::${'_' . $key})) {
+ static::${'_' . $key} = $val + static::${'_' . $key};
+ }
+ }
+ }
+
+ /**
+ * Dispatches a request based on a request object (an instance of `lithium\http\Request`). If
+ * `$request` is null, a new request object is instantiated based on the value of the
+ * `'request'` key in the `$_classes` array.
+ *
+ * @param object $request An instance of a request object with HTTP request information. If
+ * null, an instance will be created.
+ * @param array $options
+ * @return object
+ * @todo Add exception-handling/error page rendering
+ */
+ public static function run($request = null, $options = array()) {
+ $defaults = array('request' => array());
+ $options += $defaults;
+ $classes = static::$_classes;
+ $params = compact('request', 'options');
+ $m = __METHOD__;
+
+ return static::_filter($m, $params, function($self, $params, $chain) use ($classes) {
+ extract($params);
+
+ $router = $classes['router'];
+ $request = $request ?: new $classes['request']($options['request']);
+ $request->params = $router::parse($request);
+ $params = $self::invokeMethod('_applyRules', array($request->params));
+
+ if (!$params) {
+ throw new Exception('Could not route request');
+ }
+
+ $callable = $self::invokeMethod('_callable', array($request, $params, $options));
+ return $self::invokeMethod('_call', array($callable, $request, $params));
+ });
+ }
+
+ protected static function _callable($request, $params, $options) {
+ $params = compact('request', 'params', 'options');
+ return static::_filter(__METHOD__, $params, function($self, $params, $chain) {
+ extract($params, EXTR_OVERWRITE);
+ $library = '';
+
+ if (strpos($params['controller'], '.')) {
+ list($library, $params['controller']) = explode('.', $params['controller']);
+ $library .= '.';
+ }
+ $controller = $library . Inflector::camelize($params['controller']);
+ $class = Libraries::locate('controllers', $controller);
+
+ if (class_exists($class)) {
+ return new $class(compact('request'));
+ }
+ throw new Exception("Controller {$class} not found");
+ });
+ }
+
+ protected static function _call($callable, $request, $params) {
+ $params = compact('callable', 'request', 'params');
+ return static::_filter(__METHOD__, $params, function($self, $params, $chain) {
+ $callable = $params['callable'];
+ if (is_callable($callable)) {
+ return $callable($params['request'], $params['params']);
+ }
+ throw new Exception('Result not callable');
+ });
+ }
+
+ /**
+ * Attempts to apply a set of formatting rules from `$_rules` to a `$params` array, where each
+ * formatting rule is applied if the key of the rule in `$_rules` is present and not empty in
+ * `$params`. Also performs sanity checking against `$params` to ensure that no value
+ * matching a rule is present unless the rule check passes.
+ *
+ * @param array $params An array of route parameters to which rules will be applied.
+ * @return array Returns the $params array with formatting rules applied to array values.
+ */
+ protected static function _applyRules($params) {
+ $result = array();
+
+ if (!$params) {
+ return false;
+ }
+
+ foreach (static::$_rules as $rule => $value) {
+ foreach ($value as $k => $v) {
+ if (!empty($params[$rule])) {
+ $result[$k] = String::insert($v, $params);
+ }
+
+ $match = preg_replace('/\{:\w+\}/', '@', $v);
+ $match = preg_replace('/@/', '.+', preg_quote($match, '/'));
+
+ if (preg_match('/' . $match . '/i', $params[$k])) {
+ return false;
+ }
+ }
+ }
+ return $result + array_diff_key($params, $result);
+ }
+}
+
+?>
View
360 libraries/lithium/action/Request.php
@@ -0,0 +1,360 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ * Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ *
+ * Licensed under The BSD License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\action;
+
+use \lithium\util\Validator;
+
+class Request extends \lithium\core\Object {
+
+ public $url = null;
+
+ public $params = array();
+
+ public $data = array();
+
+ public $query = array();
+
+ /**
+ * Holds the environment variables for the request. Retrieved with env().
+ *
+ * @var array
+ * @see lithium\http\Request::env()
+ */
+ protected $_env = array();
+
+ protected $_type = 'html';
+
+ protected $_base = null;
+
+ protected $_classes = array('media' => '\lithium\http\Media');
+
+ protected $_detectors = array(
+ 'mobile' => array('HTTP_USER_AGENT', null),
+ 'ajax' => array('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'),
+ 'flash' => array('HTTP_USER_AGENT', 'Shockwave Flash'),
+ 'ssl' => 'HTTPS'
+ );
+
+ /**
+ * Content-types accepted by the client. If extension parsing is enabled in the
+ * Router, and an extension is detected, the corresponding content-type will be
+ * used as the overriding primary content-type accepted.
+ *
+ * @var array
+ */
+ protected $_acceptTypes = array();
+
+ protected $_autoConfig = array('classes' => 'merge', 'detectors' => 'merge', 'base', 'type');
+
+ /**
+ * Pulls request data from superglobals.
+ *
+ * @return void
+ * @todo Replace $_FILES loops with Felix's code (or Marc's?)
+ * @todo Consider disabling magic quotes stripping, or only having it explicitly enabled, since
+ * it's deprecated now.
+ */
+ protected function _init() {
+ parent::_init();
+ $this->_base = $this->_base ?: $this->_base();
+
+ $m = '/(iPhone|MIDP|AvantGo|BlackBerry|J2ME|Opera Mini|DoCoMo|NetFront|Nokia|PalmOS|';
+ $m .= 'PalmSource|portalmmm|Plucker|ReqwirelessWeb|SonyEricsson|Symbian|UP\.Browser|';
+ $m .= 'Windows CE|Xiino)/i';
+ $this->_detectors['mobile'][1] ?: $m;
+
+ $this->url = isset($_GET['url']) ? rtrim($_GET['url'], '/') : '';
+ $this->url = $this->url ?: '/