Example #1
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();
 /**
  * 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 #3
0
<?php

// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
// require LIBS_DIR . '/Nette/loader.php';
require LIBS_DIR . '/Nette/loader.php';
// Step 2: Configure environment
// 2a) enable Debug for better exception and error visualisation
// Debug::enable();
// 2b) load configuration from config.ini file
Environment::loadConfig();
// Step 3: Configure application
$application = Environment::getApplication();
dibi::connect((array) Environment::getConfig('database'));
// Step 4: Setup application router
$router = $application->getRouter();
// mod_rewrite detection
//if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
Route::setStyleProperty('action', Route::FILTER_TABLE, array('nejctenejsich' => 'mostread', 'nejnovejsich' => 'newest', 'editovat' => 'work', 'praci' => 'works', 'autoru' => 'authors', 'hledat' => 'search', 'autora' => 'author'));
Route::setStyleProperty('presenter', Route::FILTER_TABLE, array('seznam' => 'Default', 'autor' => 'Author', 'prace' => 'Work', 'pridat' => 'Editor'));
$router[] = new Route('admin/<presenter>-<action>', array('module' => 'Admin', 'presenter' => 'Default', 'action' => 'default'));
$router[] = new Route('<presenter autor|prace>/<url>', array('module' => 'Front', 'action' => 'default'));
$router[] = new Route('<presenter>-<action>[/maturita/<class>][/rok/<year>][/cena/<award>][/typ/<type>][/rocnik/<grade>][/kategorie/<category>]', array('module' => 'Front', 'presenter' => 'Default', 'action' => 'default'));
//}
//$router[] = new SimpleRouter('Front:Default:default');
// Step 5: Run the application!
$application->run();