Commit: bac9e55d7bca7b7693b20a6577a540a5fe78de51

Author: David Persson | Date: 2010-08-10 16:04:36 +0200
Making library more self contained. Adding g11n dependencies.
diff --git a/config/routes.php b/config/routes.php index 31185c4..3ebf339 100644 --- a/config/routes.php +++ b/config/routes.php @@ -1,24 +1,20 @@ <?php use \lithium\net\http\Router; -// use \app\extensions\route\Locale; +use \li3_docs\extensions\route\Locale; Router::connect('/docs', array('library' => 'li3_docs', 'controller' => 'api_browser')); Router::connect('/docs/{:lib}/{:args}', array( 'library' => 'li3_docs', 'controller' => 'api_browser', 'action' => 'view' )); -// Router::connect(new Locale(array( -// 'template' => '/docs', -// 'params' => array( -// 'plugin' => 'li3_docs', -// 'controller' => 'browser' -// )))); -// Router::connect(new Locale(array( -// 'template' => '/docs/{:library}/{:args}', -// 'params' => array( -// 'plugin' => 'li3_docs', -// 'controller' => 'browser', 'action' => 'view', -// 'args' => null -// )))); + +Router::connect(new Locale(array( + 'template' => '/docs', + 'params' => array('library' => 'li3_docs', 'controller' => 'api_browser') +))); +Router::connect(new Locale(array( + 'template' => '/docs/{:lib}/{:args}', + 'params' => array('library' => 'li3_docs', 'controller' => 'api_browser', 'action' => 'view') +))); ?> \ No newline at end of file diff --git a/extensions/route/Locale.php b/extensions/route/Locale.php new file mode 100644 index 0000000..5737e30 --- /dev/null +++ b/extensions/route/Locale.php @@ -0,0 +1,27 @@ +<?php +/** + * Lithium: the most rad php framework + * + * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org) + * @license http://opensource.org/licenses/bsd-license.php The BSD License + */ + +namespace li3_docs\extensions\route; + +use \lithium\core\Environment; + +class Locale extends \lithium\net\http\Route { + + protected function _init() { + $this->_config['template'] = '/{:locale:[a-z]+[a-z]+}' . $this->_config['template']; + $this->_config['params'] += array('locale' => null); + parent::_init(); + } + + public function match(array $options = array(), $context = null) { + $locale = Environment::get('locale'); + return parent::match($options + compact('locale'), $context); + } +} + +?> \ No newline at end of file diff --git a/views/elements/locale_navigation.html.php b/views/elements/locale_navigation.html.php new file mode 100644 index 0000000..4223653 --- /dev/null +++ b/views/elements/locale_navigation.html.php @@ -0,0 +1,20 @@ +<?php +/** + * Lithium: the most rad php framework + * + * @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; + +?> +<div id="locale-navigation"> + <ul> + <?php foreach (Environment::get('locales') as $locale => $name): + $url = compact('locale') + $this->_request->params; + ?> + <li><?=$this->Html->link($name, $url); ?></li> + <?php endforeach; ?> + </ul> +</div> \ No newline at end of file diff --git a/views/layouts/default.html.php b/views/layouts/default.html.php index 9c7968c..11e8e2a 100644 --- a/views/layouts/default.html.php +++ b/views/layouts/default.html.php @@ -24,7 +24,11 @@ use lithium\core\Environment; <body class="docs"> <div id="wrapper"> - <?php //$this->_view->render(array('element' => 'locale_navigation')); ?> + <?=$this->view()->render( + array('element' => 'locale_navigation'), + array(), + array('library' => 'li3_docs') + ); ?> <div id="container"> <div id="header"> <h1><?=$this->html->link($t('Lithium API', array('scope' => 'li3_docs')), array( diff --git a/webroot/css/li3_docs.css b/webroot/css/li3_docs.css index f0c9bb7..fd2a977 100644 --- a/webroot/css/li3_docs.css +++ b/webroot/css/li3_docs.css @@ -63,6 +63,16 @@ a { -webkit-border-radius: 10px; } +#locale-navigation { + position: absolute; + right: 20px; + top: 60px; + z-index: 2000; +} +#locale-navigation ul { + list-style-type: none; +} + #footer-spacer { height: 100px; }