Commit: 3a831b69fc9135f94c96f8314e5722f74a4cf21e

Author: Nate Abele | Date: 2010-02-18 10:14:28 -0500
Updating Mongo Viewer for Lithium 0.6 / 0.7. Please run on the 0.7-data branch of Lithium.
diff --git a/config/routes.php b/config/routes.php index 883851c..5493057 100644 --- a/config/routes.php +++ b/config/routes.php @@ -9,12 +9,6 @@ use \lithium\net\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)... diff --git a/config/switchboard.php b/config/switchboard.php new file mode 100644 index 0000000..5b56c65 --- /dev/null +++ b/config/switchboard.php @@ -0,0 +1,77 @@ +<?php +/** + * Lithium Mongo: Interactive MongoDB browser built on the Lithium framework. + * + * @copyright Copyright 2009, Union of RAD (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. + * + * For more information on in the filters system, see `lithium\util\collection\Filters`. + * + * @see lithium\util\collection\Filters + */ + +use \lithium\net\http\Router; +use \lithium\core\Environment; +use \lithium\action\Dispatcher; +use \lithium\g11n\Message; +use \lithium\util\String; + +/** + * 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\net\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); +}); + +/** + * Implements logic for handling cases where `Message::translate()` returns without a result. + * The message specified for the `'default'` option will be used as a fall back. By + * default the value for the options is the message passed to the method. + */ +Message::applyFilter('translate', function($self, $params, $chain) { + $params['options'] += array('default' => $params['id']); + return $chain->next($self, $params, $chain) ?: $params['options']['default']; +}); + +/** + * Placeholders in translated messages. Adds support for `String::insert()`-style placeholders + * to translated messages. Placeholders may be used within the message and replacements provided + * directly within the `options` argument. + * + * Usage: + * {{{ + * Message::translate('Your {:color} paintings are looking just great.', array( + * 'color' => 'silver', + * 'locale' => 'fr' + * )); + * }}} + * + * @see lithium\util\String::insert() + */ +Message::applyFilter('translate', function($self, $params, $chain) { + return String::insert($chain->next($self, $params, $chain), $params['options']); +}); + +?> \ No newline at end of file diff --git a/models/Collection.php b/models/Collection.php index eec35d3..bdc48a0 100644 --- a/models/Collection.php +++ b/models/Collection.php @@ -4,8 +4,8 @@ namespace app\models; class Collection extends \lithium\data\Model { - public static function __init() { - parent::__init(); + public static function __init(array $options = array()) { + parent::__init($options = array()); static::applyFilter('find', function($self, $params, $chain) { if (isset($params['options']['source'])) { diff --git a/views/collections/view.html.php b/views/collections/view.html.php index 019ab2a..ced36c9 100644 --- a/views/collections/view.html.php +++ b/views/collections/view.html.php @@ -1,4 +1,5 @@ <?php + $list = function($data, $topLevel = false) use (&$list, $h) { echo "<ul>"; foreach ($data as $key => $value) {