/**
  * Filter table test.
  * @return void
  */
 public function testFilterTable()
 {
     Route::addStyle('#xlat', 'presenter');
     Route::setStyleProperty('#xlat', Route::FILTER_TABLE, array('produkt' => 'Product', 'kategorie' => 'Category', 'zakaznik' => 'Customer', 'kosik' => 'Basket'));
     $route = new Route('<presenter #xlat>', array());
     $this->assertRoute($route, '/kategorie/', array('presenter' => 'Category', 'params' => array('test' => 'testvalue')), '/kategorie?test=testvalue');
     $this->assertRoute($route, '/other/', array('presenter' => 'Other', 'params' => array('test' => 'testvalue')), '/other?test=testvalue');
     $route = new Route(' ? action=<presenter #xlat>', array());
     $this->assertRoute($route, '/?action=kategorie', array('presenter' => 'Category', 'params' => array('test' => 'testvalue')), '/?test=testvalue&action=kategorie');
 }
Example #2
0
Environment::setVariable('mediaBaseUri', Environment::expand('%baseUri%/media'));
set_include_path(LIB_DIR . PATH_SEPARATOR . get_include_path());
Html::$xhtml = FALSE;
SafeStream::register();
setlocale(LC_ALL, require Environment::expand('%localeFile%'));
Zend_Search_Lucene::setDefaultSearchField('description');
// configure locale
require_once LIB_DIR . '/tr.php';
$available = array();
foreach (glob(APP_DIR . '/locale/' . '*.php') as $_) {
    $available[substr(substr($_, strlen(APP_DIR . '/locale/')), 0, 2)] = $_;
}
tr::$locale = Environment::getHttpRequest()->detectLanguage(array_keys($available));
if (tr::$locale) {
    list(tr::$plurals[tr::$locale], tr::$table[tr::$locale]) = (require $available[tr::$locale]);
}
// connect to DB
dibi::connect(require Environment::expand('%dbFile%'));
// get app
$app = Environment::getApplication();
// routing
$router = $app->getRouter();
Route::setStyleProperty('action', Route::FILTER_TABLE, array(__('show-cart') => 'showCart', __('fill-data') => 'fillData', __('complete') => 'complete', __('commit') => 'commit'));
$router[] = new Route(__('order') . '/<action>/', array('presenter' => 'Front:Order'));
$router[] = new Route('admin/<presenter>/<action>/', array('module' => 'Back', 'presenter' => 'Dashboard', 'action' => 'default'));
$router[] = new Route(__('search') . ' ? q=<q .*> & ' . __('page') . '=<page \\d+>', array('presenter' => 'Front:Search', 'action' => 'default', 'page' => 1));
Route::addStyle('path', NULL);
Route::setStyleProperty('path', Route::PATTERN, '.*');
$router[] = new Route('<path>/ ? ' . __('page') . '=<page_number \\d+> & ' . __('letter') . '=<letter [A-Z]|#>', array('presenter' => 'Front:Show', 'action' => 'default', 'path' => '', 'page_number' => 1, 'letter' => NULL));
// run!
$app->run();