Commit: 800b5ec3b3033a75a9ace37edb3e01213d1015c5
Author: gwoo | Date: 2010-02-27 09:13:27 -0800
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 52b7ab1..e8d32ba 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -1,16 +1,11 @@
<?php
/**
- * Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
+ * Lithium: the most rad php framework
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @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\Libraries;
-use \lithium\core\Environment;
-
/**
* 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
diff --git a/config/bootstrap/action.php b/config/bootstrap/action.php
index 27883aa..e722100 100644
--- a/config/bootstrap/action.php
+++ b/config/bootstrap/action.php
@@ -52,4 +52,4 @@ Dispatcher::applyFilter('run', function($self, $params, $chain) {
return $chain->next($self, $params, $chain);
});
-?>
+?>
\ No newline at end of file
diff --git a/config/bootstrap/cache.php b/config/bootstrap/cache.php
new file mode 100644
index 0000000..821ec8d
--- /dev/null
+++ b/config/bootstrap/cache.php
@@ -0,0 +1,46 @@
+<?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;
+
+$apcEnabled = Apc::enabled();
+
+Cache::config(array(
+ 'default' => array(
+ 'adapter' => '\lithium\storage\cache\adapter\\' . ($apcEnabled ? 'Apc' : 'File')
+ )
+));
+
+/**
+ * If APC is not available and the cache directory is not writeable, bail out.
+ */
+if (!$apcEnabled && !is_writable(LITHIUM_APP_PATH . '/resources/tmp/cache')) {
+ return;
+}
+
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ if ($cache = Cache::read('default', 'core.libraryCache')) {
+ $cache = (array) unserialize($cache) + Libraries::cache();
+ Libraries::cache($cache);
+ }
+ $result = $chain->next($self, $params, $chain);
+
+ if ($cache != Libraries::cache()) {
+ Cache::write('default', 'core.libraryCache', serialize(Libraries::cache()), '+1 day');
+ }
+ return $result;
+});
+
+?>
\ No newline at end of file
diff --git a/config/bootstrap/g11n.php b/config/bootstrap/g11n.php
new file mode 100644
index 0000000..2f10e11
--- /dev/null
+++ b/config/bootstrap/g11n.php
@@ -0,0 +1,154 @@
+<?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'
+ )
+));
+
+/**
+ * Globalization runtime data. You can add globalized data during runtime utilizing a
+ * configuration set up to use the _memory_ adapter.
+ */
+$data = function($n) { return $n != 1 ? 1 : 0; };
+Catalog::write('message.plural', 'root', $data, array('name' => 'runtime'));
+
+/**
+ * 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('validation.phone', 'en_US'));
+Validator::add('postalCode', Catalog::read('validation.postalCode', 'en_US'));
+Validator::add('ssn', Catalog::read('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;
+});
+
+?>
\ No newline at end of file
diff --git a/config/bootstrap/libraries.php b/config/bootstrap/libraries.php
index 0022efb..b59e56d 100644
--- a/config/bootstrap/libraries.php
+++ b/config/bootstrap/libraries.php
@@ -48,4 +48,11 @@ Libraries::add('lithium');
* 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', array('default' => true));
\ No newline at end of file
+Libraries::add('app', array('default' => true));
+
+/**
+ * Add some plugins
+ */
+// Libraries::add('plugin', 'li3_docs');
+
+?>
\ No newline at end of file
diff --git a/config/bootstrap/media.php b/config/bootstrap/media.php
index 75a304a..eba781b 100644
--- a/config/bootstrap/media.php
+++ b/config/bootstrap/media.php
@@ -56,4 +56,4 @@ Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
});
-?>
+?>
\ No newline at end of file
diff --git a/config/connections.php b/config/connections.php
index 2ec8c54..f77b6b0 100644
--- a/config/connections.php
+++ b/config/connections.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
diff --git a/config/routes.php b/config/routes.php
index 5493057..b116b4a 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
diff --git a/index.php b/index.php
index 357a7af..ea8d520 100644
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
diff --git a/views/layouts/default.html.php b/views/layouts/default.html.php
index a3da708..e4e5bad 100644
--- a/views/layouts/default.html.php
+++ b/views/layouts/default.html.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
diff --git a/views/pages/home.html.php b/views/pages/home.html.php
index 8a21396..bb21a74 100644
--- a/views/pages/home.html.php
+++ b/views/pages/home.html.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
?>
diff --git a/webroot/index.php b/webroot/index.php
index bde13a6..335ef35 100644
--- a/webroot/index.php
+++ b/webroot/index.php
@@ -2,7 +2,7 @@
/**
* Lithium Mongo: Interactive MongoDB browser built on the Lithium framework.
*
- * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/