Permalink
Browse files

Initial application import.

  • Loading branch information...
1 parent c7833c9 commit 219774ca75e2dbda18442ecf24e9458e1a3c0d4b @nateabele committed Sep 23, 2010
Showing with 2,058 additions and 0 deletions.
  1. +5 −0 .htaccess
  2. +79 −0 config/bootstrap.php
  3. +55 −0 config/bootstrap/action.php
  4. +44 −0 config/bootstrap/cache.php
  5. +16 −0 config/bootstrap/connections.php
  6. +19 −0 config/bootstrap/console.php
  7. +147 −0 config/bootstrap/g11n.php
  8. +28 −0 config/bootstrap/libraries.php
  9. +63 −0 config/bootstrap/media.php
  10. +48 −0 config/routes.php
  11. +52 −0 controllers/PhotosController.php
  12. 0 extensions/adapter/empty
  13. 0 extensions/command/empty
  14. 0 extensions/data/source/empty
  15. 0 extensions/helper/empty
  16. +11 −0 index.php
  17. 0 libraries/_source/empty
  18. +34 −0 models/Photo.php
  19. 0 models/empty
  20. +258 −0 readme.wiki
  21. 0 resources/g11n/empty
  22. 0 resources/tmp/cache/empty
  23. 0 resources/tmp/cache/templates/empty
  24. 0 resources/tmp/logs/empty
  25. 0 resources/tmp/tests/empty
  26. +16 −0 tests/cases/controllers/PhotosControllerTest.php
  27. 0 tests/cases/controllers/empty
  28. 0 tests/cases/extensions/adapter/empty
  29. 0 tests/cases/extensions/command/empty
  30. +1 −0 tests/cases/extensions/data/source/empty
  31. 0 tests/cases/extensions/helper/empty
  32. +16 −0 tests/cases/models/PhotoTest.php
  33. 0 tests/cases/models/empty
  34. 0 tests/functional/empty
  35. 0 tests/integration/empty
  36. 0 tests/mocks/empty
  37. 0 views/elements/empty
  38. +1 −0 views/hello_world/index.html.php
  39. +31 −0 views/layouts/default.html.php
  40. +10 −0 views/layouts/default.xml.php
  41. +170 −0 views/pages/home.html.php
  42. +9 −0 views/photos/edit.html.php
  43. +8 −0 views/photos/index.html.php
  44. +9 −0 views/photos/view.html.php
  45. +7 −0 webroot/.htaccess
  46. +594 −0 webroot/css/debug.css
  47. +288 −0 webroot/css/lithium.css
  48. BIN webroot/favicon.ico
  49. 0 webroot/img/empty
  50. +38 −0 webroot/index.php
  51. +1 −0 webroot/js/empty
View
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
+</IfModule>
View
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * 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);
+}
+
+/**
+ * This file contains the loading instructions for all class libraries used in the application,
+ * including the Lithium core, and the application itself. These instructions include library names,
+ * paths to files, and any applicable class-loading rules. Also includes any statically-loaded
+ * classes to improve bootstrap performance.
+ */
+require __DIR__ . '/bootstrap/libraries.php';
+
+/**
+ * Include this file if your application uses a database connection.
+ */
+require __DIR__ . '/bootstrap/connections.php';
+
+/**
+ * This file defines bindings between classes which are triggered during the request cycle, and
+ * allow the framework to automatically configure its environmental settings. You can add your own
+ * behavior and modify the dispatch cycle to suit your needs.
+ */
+require __DIR__ . '/bootstrap/action.php';
+
+/**
+ * This file contains configurations for connecting to external caching resources, as well as
+ * default caching rules for various systems within your application
+ */
+require __DIR__ . '/bootstrap/cache.php';
+
+/**
+ * This file contains your application's globalization rules, including inflections,
+ * transliterations, localized validation, and how localized text should be loaded. Uncomment this
+ * line if you plan to globalize your site.
+ */
+// require __DIR__ . '/bootstrap/g11n.php';
+
+/**
+ * This file contains configurations for handling different content types within the framework,
+ * including converting data to and from different formats, and handling static media assets.
+ */
+require __DIR__ . '/bootstrap/media.php';
+
+/**
+ * This file configures console filters and settings, specifically output behavior and coloring.
+ */
+// require __DIR__ . '/bootstrap/console.php';
+
+?>
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This file contains a series of method filters that allow you to intercept different parts of
+ * Lithium's dispatch cycle. The filters below are used for on-demand loading of routing
+ * configuration, and automatically configuring the correct environment in which the application
+ * runs.
+ *
+ * For more information on in the filters system, see `lithium\util\collection\Filters`.
+ *
+ * @see lithium\util\collection\Filters
+ */
+
+use lithium\core\Libraries;
+use lithium\net\http\Router;
+use lithium\core\Environment;
+use lithium\action\Dispatcher;
+
+/**
+ * This filter intercepts the `run()` of the `Dispatcher`, and first passes the `'request'`
+ * parameter (an instance of the `Request` object) to the `Environment` class to detect which
+ * environment the application is running in. Then, loads all application routes in all plugins,
+ * loading the default application routes last.
+ *
+ * Change this code if plugin routes must be loaded in a specific order (i.e. not the same order as
+ * the plugins are added in your bootstrap configuration), or if application routes must be loaded
+ * first (in which case the default catch-all routes should be removed).
+ *
+ * If `Dispatcher::run()` is called multiple times in the course of a single request, change the
+ * `include`s to `include_once`.
+ *
+ * @see lithium\action\Request
+ * @see lithium\core\Environment
+ * @see lithium\net\http\Router
+ */
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ Environment::set($params['request']);
+
+ foreach (array_reverse(Libraries::get()) as $name => $config) {
+ if ($name === 'lithium') {
+ continue;
+ }
+ $file = "{$config['path']}/config/routes.php";
+ file_exists($file) ? include $file : null;
+ }
+ return $chain->next($self, $params, $chain);
+});
+
+?>
View
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This file creates a default cache configuration using the most optimized adapter available, and
+ * uses it to provide default caching for high-overhead operations.
+ */
+use lithium\storage\Cache;
+use lithium\core\Libraries;
+use lithium\action\Dispatcher;
+use lithium\storage\cache\adapter\Apc;
+
+/**
+ * If APC is not available and the cache directory is not writeable, bail out.
+ */
+if (!$apcEnabled = Apc::enabled() && !is_writable(LITHIUM_APP_PATH . '/resources/tmp/cache')) {
+ return;
+}
+
+Cache::config(array(
+ 'default' => array(
+ 'adapter' => '\lithium\storage\cache\adapter\\' . ($apcEnabled ? 'Apc' : 'File')
+ )
+));
+
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ if ($cache = Cache::read('default', 'core.libraries')) {
+ $cache = (array) unserialize($cache) + Libraries::cache();
+ Libraries::cache($cache);
+ }
+ $result = $chain->next($self, $params, $chain);
+
+ if ($cache != Libraries::cache()) {
+ Cache::write('default', 'core.libraries', serialize(Libraries::cache()), '+1 day');
+ }
+ return $result;
+});
+
+?>
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use lithium\data\Connections;
+
+Connections::add('default', array(
+ 'type' => 'MongoDb',
+ 'database' => 'photoblog'
+));
+
+?>
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use lithium\console\Dispatcher;
+
+Dispatcher::applyFilter('_call', function($self, $params, $chain) {
+ $params['callable']->response->styles(array(
+ 'heading' => '\033[1;30;46m'
+ ));
+ return $chain->next($self, $params, $chain);
+});
+
+
+?>
View
@@ -0,0 +1,147 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium;
+
+use lithium\core\Environment;
+use lithium\g11n\Locale;
+use lithium\g11n\Catalog;
+use lithium\g11n\Message;
+use lithium\util\Inflector;
+use lithium\util\Validator;
+use lithium\net\http\Media;
+use lithium\action\Dispatcher as ActionDispatcher;
+use lithium\console\Dispatcher as ConsoleDispatcher;
+
+/**
+ * Sets the default timezone used by all date/time functions.
+ */
+date_default_timezone_set('UTC');
+
+/**
+ * Adds globalization specific settings to the environment.
+ *
+ * The settings for the current locale, time zone and currency are kept as environment
+ * settings. This allows for _centrally_ switching, _transparently_ setting and retrieving
+ * globalization related settings.
+ *
+ * The environment settings are:
+ * - `'locale'` The effective locale. Defaults to `'en'`.
+ * - `'availableLocales'` Application locales available. Defaults to `array('en')`.
+ */
+Environment::set('production', array(
+ 'locale' => 'en',
+ 'availableLocales' => array('en')
+));
+Environment::set('development', array(
+ 'locale' => 'en',
+ 'availableLocales' => array('en')
+));
+Environment::set('test', array(
+ 'locale' => 'en',
+ 'availableLocales' => array('en')
+));
+
+/**
+ * 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_,
+ * _php_ or _gettext_ adapter which handle this internally.
+ */
+Catalog::config(array(
+ 'runtime' => array(
+ 'adapter' => 'Memory'
+ ),
+// 'app' => array(
+// 'adapter' => 'Gettext',
+// 'path' => LITHIUM_APP_PATH . '/resources/g11n'
+// ),
+ 'lithium' => array(
+ 'adapter' => 'Php',
+ 'path' => LITHIUM_LIBRARY_PATH . '/lithium/g11n/resources/php'
+ )
+) + Catalog::config());
+
+/**
+ * Integration with `Inflector`.
+ */
+// Inflector::rules('transliteration', Catalog::read('inflection.transliteration', 'en'));
+
+/*
+ * Inflector configuration examples. 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.
+ */
+// Inflector::rules('singular', array('rules' => array('/rata/' => '\1ratus')));
+// Inflector::rules('singular', array('irregular' => array('foo' => 'bar')));
+//
+// Inflector::rules('plural', array('rules' => array('/rata/' => '\1ratum')));
+// Inflector::rules('plural', array('irregular' => array('bar' => 'foo')));
+//
+// Inflector::rules('transliteration', array('/É|Ê/' => 'E'));
+//
+// Inflector::rules('uninflected', 'bord');
+// Inflector::rules('uninflected', array('bord', 'baird'));
+
+
+/**
+ * Integration with `View`. Embeds message translation aliases into the `View`
+ * class (or other content handler, if specified) when content is rendered. This
+ * enables translation functions, i.e. `<?=$t("Translated content"); ?>`.
+ */
+Media::applyFilter('_handle', function($self, $params, $chain) {
+ $params['handler'] += array('outputFilters' => array());
+ $params['handler']['outputFilters'] += Message::aliases();
+ return $chain->next($self, $params, $chain);
+});
+
+/**
+ * Integration with `Validator`. You can load locale dependent rules into the `Validator`
+ * by specifying them manually or retrieving them with the `Catalog` class.
+ */
+Validator::add('phone', Catalog::read(true, 'validation.phone', 'en_US'));
+Validator::add('postalCode', Catalog::read(true, 'validation.postalCode', 'en_US'));
+Validator::add('ssn', Catalog::read(true, 'validation.ssn', 'en_US'));
+
+/**
+ * Intercepts dispatching processes in order to set the effective locale by using
+ * the locale of the request or if that is not available retrieving a locale preferred
+ * by the client.
+ */
+ActionDispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ $request = $params['request'];
+ $controller = $chain->next($self, $params, $chain);
+
+ if (!$request->locale) {
+ $request->params['locale'] = Locale::preferred($request);
+ }
+ Environment::set(Environment::get(), array('locale' => $request->locale));
+ return $controller;
+});
+ConsoleDispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ $request = $params['request'];
+ $command = $chain->next($self, $params, $chain);
+
+ if (!$request->locale) {
+ $request->params['locale'] = Locale::preferred($request);
+ }
+ Environment::set(Environment::get(), array('locale' => $request->locale));
+ return $command;
+});
+
+?>
Oops, something went wrong.

0 comments on commit 219774c

Please sign in to comment.