/** * Register Antispam to Nette Forms * @return void */ public static function register() { Form::extensionMethod('addAntispam', function (Form $form, $name = 'spam', $label = 'Toto pole vymažte', $msg = 'Byl detekován pokus o spam.') { // "All filled" protection $form[$name] = new AntispamControl($label, NULL, NULL, $msg); // "Send delay" protection $form->addHidden('form_created', strtr(time(), '0123456789', 'jihgfedcba'))->addRule(function ($item) { if (AntispamControl::$minDelay <= 0) { return TRUE; } // turn off "Send delay protection" $value = (int) strtr($item->value, 'jihgfedcba', '0123456789'); return $value <= time() - AntispamControl::$minDelay; }, $msg); return $form; }); }
/** * Adds addTag() method to \Nette\Forms\Form */ public static function register() { Form::extensionMethod('addTag', callback(__CLASS__, 'addTag')); }
// Configure application $configurator = new Nette\Configurator(); // Enable Nette Debugger for error visualisation & logging //$configurator->setDebugMode(TRUE); $configurator->enableDebugger(__DIR__ . '/../log'); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register(); // Create Dependency Injection container from config.neon file $environment = Nette\Configurator::detectDebugMode('127.0.0.1') ? $configurator::DEVELOPMENT : $configurator::PRODUCTION; $configurator->addConfig(__DIR__ . '/config/config.neon', $environment); $container = $configurator->createContainer(); $container->application->errorPresenter = 'Error'; // DatePicker \Nette\Forms\Form::extensionMethod('addDatePicker', function (Nette\Forms\Form $_this, $name, $label = NULL, $cols = NULL, $maxLength = NULL) { return $_this[$name] = new RadekDostal\NetteComponents\DateTimePicker\DatePicker($label, $cols, $maxLength); }); // Setup router // Admin Router $container->router[] = $adminRouter = new RouteList(); $adminRouter[] = new Route('admin/<presenter>/<action>/<id>', array('module' => 'Admin', 'presenter' => 'Default', 'action' => 'default')); $adminRouter[] = new Route('admin/<presenter>/<action>', array('module' => 'Admin', 'presenter' => 'Default', 'action' => 'default', 'id' => NULL)); // Front Router $container->router[] = $frontRouter = new RouteList(); $frontRouter[] = new Route('index.php', array('presenter' => 'Default'), Route::ONE_WAY); $frontRouter[] = new Route('', array('lang' => 'cs', 'presenter' => 'Default'), Route::ONE_WAY); $frontRouter[] = new Route('files/vydavatele/certifikat.html', array('presenter' => 'Default', 'action' => 'disclaimer', 'lang' => 'cs'), Route::ONE_WAY); $frontRouter[] = new Route('certifikat', array('presenter' => 'Default', 'action' => 'graphics', 'lang' => 'cs'), Route::ONE_WAY); $frontRouter[] = new Route('<lang en|cs>', array('presenter' => 'Default', 'action' => 'default', 'id' => NULL)); /*$frontRouter[] = new Route('cs/klicove-slovo/<keyword>', array( 'presenter' => 'Default',