├── .gitignore ├── app ├── .htaccess ├── bootstrap.php ├── components │ ├── TaskList.latte │ └── TaskList.php ├── config │ └── config.neon ├── models │ ├── Authenticator.php │ └── Model.php ├── presenters │ ├── BasePresenter.php │ ├── ErrorPresenter.php │ ├── HomepagePresenter.php │ ├── SecuredPresenter.php │ ├── SignPresenter.php │ ├── TaskPresenter.php │ └── UserPresenter.php ├── templates │ ├── @layout.latte │ ├── Error │ │ ├── 403.latte │ │ ├── 404.latte │ │ ├── 405.latte │ │ ├── 410.latte │ │ ├── 4xx.latte │ │ └── 500.latte │ ├── Homepage │ │ └── default.latte │ ├── Sign │ │ └── in.latte │ ├── Task │ │ ├── default.latte │ │ └── notFound.latte │ ├── User │ │ └── password.latte │ └── maintenance.phtml └── web.config ├── docs ├── 01_intro.texy ├── 02_start.texy ├── 03_database.texy ├── 04_presenter.texy ├── 05_forms.texy ├── 06_components.texy ├── 07_authentication.texy ├── 08_ajax.texy ├── data │ ├── data.mysql.sql │ └── quickstart.mysql.sql ├── latex.php └── media │ ├── 02_skeleton-start.png │ ├── 03_schema.png │ ├── 04_debug-panel-sql.png │ ├── 04_debugger.png │ ├── 04_lifecycle2.gif │ ├── 04_list-table.png │ ├── 04_not-found.png │ ├── 04_presenter-nav.png │ ├── 05_taskForm-control.png │ ├── 05_taskForm-manual.png │ ├── 06_tasklist.png │ └── 07_logged-in.png ├── libs ├── .htaccess ├── Nette │ ├── Application │ │ ├── Application.php │ │ ├── Diagnostics │ │ │ ├── RoutingPanel.php │ │ │ └── templates │ │ │ │ ├── RoutingPanel.panel.phtml │ │ │ │ └── RoutingPanel.tab.phtml │ │ ├── IPresenter.php │ │ ├── IPresenterFactory.php │ │ ├── IResponse.php │ │ ├── IRouter.php │ │ ├── MicroPresenter.php │ │ ├── PresenterFactory.php │ │ ├── Request.php │ │ ├── Responses │ │ │ ├── FileResponse.php │ │ │ ├── ForwardResponse.php │ │ │ ├── JsonResponse.php │ │ │ ├── RedirectResponse.php │ │ │ └── TextResponse.php │ │ ├── Routers │ │ │ ├── CliRouter.php │ │ │ ├── Route.php │ │ │ ├── RouteList.php │ │ │ └── SimpleRouter.php │ │ ├── UI │ │ │ ├── BadSignalException.php │ │ │ ├── Control.php │ │ │ ├── Form.php │ │ │ ├── IRenderable.php │ │ │ ├── ISignalReceiver.php │ │ │ ├── IStatePersistent.php │ │ │ ├── InvalidLinkException.php │ │ │ ├── Link.php │ │ │ ├── Multiplier.php │ │ │ ├── Presenter.php │ │ │ ├── PresenterComponent.php │ │ │ └── PresenterComponentReflection.php │ │ ├── exceptions.php │ │ └── templates │ │ │ └── error.phtml │ ├── Caching │ │ ├── Cache.php │ │ ├── IStorage.php │ │ ├── OutputHelper.php │ │ └── Storages │ │ │ ├── DevNullStorage.php │ │ │ ├── FileJournal.php │ │ │ ├── FileStorage.php │ │ │ ├── IJournal.php │ │ │ ├── MemcachedStorage.php │ │ │ ├── MemoryStorage.php │ │ │ └── PhpFileStorage.php │ ├── ComponentModel │ │ ├── Component.php │ │ ├── Container.php │ │ ├── IComponent.php │ │ ├── IContainer.php │ │ └── RecursiveComponentIterator.php │ ├── Config │ │ ├── Adapters │ │ │ ├── IniAdapter.php │ │ │ ├── NeonAdapter.php │ │ │ └── PhpAdapter.php │ │ ├── Compiler.php │ │ ├── CompilerExtension.php │ │ ├── Configurator.php │ │ ├── Extensions │ │ │ ├── ConstantsExtension.php │ │ │ ├── NetteExtension.php │ │ │ └── PhpExtension.php │ │ ├── Helpers.php │ │ ├── IAdapter.php │ │ └── Loader.php │ ├── DI │ │ ├── Container.php │ │ ├── ContainerBuilder.php │ │ ├── Helpers.php │ │ ├── IContainer.php │ │ ├── NestedAccessor.php │ │ ├── ServiceDefinition.php │ │ ├── Statement.php │ │ └── exceptions.php │ ├── Database │ │ ├── Connection.php │ │ ├── Diagnostics │ │ │ └── ConnectionPanel.php │ │ ├── Drivers │ │ │ ├── MsSqlDriver.php │ │ │ ├── MySqlDriver.php │ │ │ ├── OciDriver.php │ │ │ ├── OdbcDriver.php │ │ │ ├── PgSqlDriver.php │ │ │ ├── Sqlite2Driver.php │ │ │ └── SqliteDriver.php │ │ ├── IReflection.php │ │ ├── ISupplementalDriver.php │ │ ├── Reflection │ │ │ ├── ConventionalReflection.php │ │ │ └── DiscoveredReflection.php │ │ ├── Row.php │ │ ├── SqlLiteral.php │ │ ├── SqlPreprocessor.php │ │ ├── Statement.php │ │ └── Table │ │ │ ├── ActiveRow.php │ │ │ ├── GroupedSelection.php │ │ │ └── Selection.php │ ├── Diagnostics │ │ ├── Bar.php │ │ ├── BlueScreen.php │ │ ├── Debugger.php │ │ ├── DefaultBarPanel.php │ │ ├── FireLogger.php │ │ ├── Helpers.php │ │ ├── IBarPanel.php │ │ ├── Logger.php │ │ └── templates │ │ │ ├── bar.dumps.panel.phtml │ │ │ ├── bar.dumps.tab.phtml │ │ │ ├── bar.errors.panel.phtml │ │ │ ├── bar.errors.tab.phtml │ │ │ ├── bar.memory.tab.phtml │ │ │ ├── bar.phtml │ │ │ ├── bar.time.tab.phtml │ │ │ ├── bluescreen.phtml │ │ │ ├── error.phtml │ │ │ └── netteQ.js │ ├── Forms │ │ ├── Container.php │ │ ├── ControlGroup.php │ │ ├── Controls │ │ │ ├── BaseControl.php │ │ │ ├── Button.php │ │ │ ├── Checkbox.php │ │ │ ├── HiddenField.php │ │ │ ├── ImageButton.php │ │ │ ├── MultiSelectBox.php │ │ │ ├── RadioList.php │ │ │ ├── SelectBox.php │ │ │ ├── SubmitButton.php │ │ │ ├── TextArea.php │ │ │ ├── TextBase.php │ │ │ ├── TextInput.php │ │ │ └── UploadControl.php │ │ ├── Form.php │ │ ├── IControl.php │ │ ├── IFormRenderer.php │ │ ├── ISubmitterControl.php │ │ ├── Rendering │ │ │ └── DefaultFormRenderer.php │ │ ├── Rule.php │ │ └── Rules.php │ ├── Http │ │ ├── Context.php │ │ ├── FileUpload.php │ │ ├── IRequest.php │ │ ├── IResponse.php │ │ ├── ISessionStorage.php │ │ ├── IUser.php │ │ ├── Request.php │ │ ├── RequestFactory.php │ │ ├── Response.php │ │ ├── Session.php │ │ ├── SessionSection.php │ │ ├── Url.php │ │ ├── UrlScript.php │ │ └── User.php │ ├── Iterators │ │ ├── CachingIterator.php │ │ ├── Filter.php │ │ ├── InstanceFilter.php │ │ ├── Mapper.php │ │ ├── RecursiveFilter.php │ │ └── Recursor.php │ ├── Latte │ │ ├── Engine.php │ │ ├── HtmlNode.php │ │ ├── IMacro.php │ │ ├── MacroNode.php │ │ ├── MacroTokenizer.php │ │ ├── Macros │ │ │ ├── CacheMacro.php │ │ │ ├── CoreMacros.php │ │ │ ├── FormMacros.php │ │ │ ├── MacroSet.php │ │ │ └── UIMacros.php │ │ ├── ParseException.php │ │ ├── Parser.php │ │ └── PhpWriter.php │ ├── Loaders │ │ ├── AutoLoader.php │ │ ├── NetteLoader.php │ │ └── RobotLoader.php │ ├── Localization │ │ └── ITranslator.php │ ├── Mail │ │ ├── IMailer.php │ │ ├── Message.php │ │ ├── MimePart.php │ │ ├── SendmailMailer.php │ │ └── SmtpMailer.php │ ├── Reflection │ │ ├── Annotation.php │ │ ├── AnnotationsParser.php │ │ ├── ClassType.php │ │ ├── Extension.php │ │ ├── GlobalFunction.php │ │ ├── IAnnotation.php │ │ ├── Method.php │ │ ├── Parameter.php │ │ └── Property.php │ ├── Security │ │ ├── AuthenticationException.php │ │ ├── IAuthenticator.php │ │ ├── IAuthorizator.php │ │ ├── IIdentity.php │ │ ├── IResource.php │ │ ├── IRole.php │ │ ├── Identity.php │ │ ├── Permission.php │ │ └── SimpleAuthenticator.php │ ├── Templating │ │ ├── DefaultHelpers.php │ │ ├── FileTemplate.php │ │ ├── FilterException.php │ │ ├── IFileTemplate.php │ │ ├── ITemplate.php │ │ └── Template.php │ ├── Utils │ │ ├── Arrays.php │ │ ├── Finder.php │ │ ├── Html.php │ │ ├── Json.php │ │ ├── LimitedScope.php │ │ ├── MimeTypeDetector.php │ │ ├── Neon.php │ │ ├── Paginator.php │ │ ├── PhpGenerator │ │ │ ├── ClassType.php │ │ │ ├── Helpers.php │ │ │ ├── Method.php │ │ │ ├── Parameter.php │ │ │ ├── PhpLiteral.php │ │ │ └── Property.php │ │ ├── SafeStream.php │ │ ├── Strings.php │ │ ├── Tokenizer.php │ │ └── Validators.php │ ├── common │ │ ├── ArrayHash.php │ │ ├── ArrayList.php │ │ ├── Callback.php │ │ ├── DateTime.php │ │ ├── Environment.php │ │ ├── Framework.php │ │ ├── FreezableObject.php │ │ ├── IFreezable.php │ │ ├── Image.php │ │ ├── Object.php │ │ ├── ObjectMixin.php │ │ └── exceptions.php │ └── loader.php └── web.config ├── log ├── .gitignore ├── .htaccess └── web.config ├── temp ├── .gitignore ├── .htaccess └── web.config └── www ├── .htaccess ├── adminer ├── adminer.css └── index.php ├── css ├── mixins.less ├── print.css ├── screen.css ├── tasklist.css └── tasklist.less ├── favicon.ico ├── images ├── nette-powered1.gif ├── nette-powered2.gif ├── nette-powered3.gif └── spinner.gif ├── index.php ├── js ├── ajax.js └── netteForms.js ├── robots.txt └── web.config /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | -------------------------------------------------------------------------------- /app/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Deny from all -------------------------------------------------------------------------------- /app/bootstrap.php: -------------------------------------------------------------------------------- 1 | setTempDirectory(__DIR__ . '/../temp'); 23 | 24 | // Enable RobotLoader - this will load all classes automatically 25 | $configurator->createRobotLoader() 26 | ->addDirectory(APP_DIR) 27 | ->addDirectory(LIBS_DIR) 28 | ->register(); 29 | 30 | // Create Dependency Injection container from config.neon file 31 | $configurator->addConfig(__DIR__ . '/config/config.neon'); 32 | $container = $configurator->createContainer(); 33 | 34 | // Opens already started session 35 | if ($container->session->exists()) { 36 | $container->session->setExpiration('+30 days'); 37 | $container->session->start(); 38 | } 39 | 40 | // Setup router 41 | $router = $container->router; 42 | $router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY); 43 | $router[] = new Route('/[/]', 'Homepage:default'); 44 | 45 | 46 | // Configure and run the application! 47 | $application = $container->application; 48 | //$application->catchExceptions = TRUE; 49 | $application->errorPresenter = 'Error'; 50 | $application->run(); 51 | -------------------------------------------------------------------------------- /app/components/TaskList.latte: -------------------------------------------------------------------------------- 1 | {snippet} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {if count($tasks) > 0} 14 | {foreach $tasks as $task} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {/foreach} 23 | {else} 24 | 25 | 26 | 27 | {/if} 28 | 29 |
 SeznamÚkolPřiřazeno 
{$task->created|date:'j. n. Y'}{$task->tasklist->title}{$task->text}{$task->user->name}hotovo
V seznamu nejsou žádné úkoly.
30 | {/snippet} -------------------------------------------------------------------------------- /app/components/TaskList.php: -------------------------------------------------------------------------------- 1 | tasks = $tasks; 32 | $this->model = $model; 33 | } 34 | 35 | /** 36 | * Nastaví, zda se má zobrazovat sloupeček se seznamem úkolů. 37 | * @param boolean $displayTaskList 38 | */ 39 | public function setDisplayTaskList($displayTaskList) 40 | { 41 | $this->displayTaskList = (bool)$displayTaskList; 42 | } 43 | 44 | /** 45 | * Nastaví, zda se má zobrazovat sloupeček s uživatelem, kterému je úkol přiřazen. 46 | * @param boolean $displayUser 47 | */ 48 | public function setDisplayUser($displayUser) 49 | { 50 | $this->displayUser = (bool)$displayUser; 51 | } 52 | 53 | 54 | /** 55 | * Vykreslí komponentu. Šablonou komponenty je TaskList.latte. 56 | */ 57 | public function render() 58 | { 59 | $this->template->setFile(__DIR__ . '/TaskList.latte'); 60 | $this->template->tasks = $this->tasks; 61 | $this->template->displayUser = $this->displayUser; 62 | $this->template->displayTaskList = $this->displayTaskList; 63 | $this->template->userId = $this->presenter->getUser()->getId(); 64 | $this->template->render(); 65 | } 66 | 67 | 68 | /** 69 | * Signál, který označí zadaný úkol jako splněný. 70 | * @param $taskId ID úkolu. 71 | */ 72 | public function handleMarkDone($taskId) 73 | { 74 | $task = $this->model->getTasks()->find($taskId)->fetch(); 75 | // ověření, zda je tento úkol uživateli skutečně přiřazen 76 | if ($task !== NULL && $task->user_id === $this->presenter->getUser()->getId()) { 77 | $this->model->getTasks()->where(array('id' => $taskId))->update(array('done' => 1)); 78 | // přesměrování nebo invalidace snippetu 79 | if (!$this->presenter->isAjax()) { 80 | $this->presenter->redirect('this'); 81 | } else { 82 | $this->invalidateControl(); 83 | } 84 | } 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /app/config/config.neon: -------------------------------------------------------------------------------- 1 | # 2 | # SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser! 3 | # 4 | # If you don't protect this directory from direct web access, anybody will be able to see your passwords. 5 | # http://nette.org/security-warning 6 | # 7 | common: 8 | parameters: 9 | database: 10 | driver: mysql 11 | host: localhost 12 | dbname: quickstart 13 | user: quickstart 14 | password: qs 15 | 16 | 17 | php: 18 | date.timezone: Europe/Prague 19 | # session.save_path: "%tempDir%/sessions" 20 | # zlib.output_compression: yes 21 | 22 | 23 | services: 24 | database: 25 | class: Nette\Database\Connection( 26 | '%database.driver%:host=%database.host%;dbname=%database.dbname%' 27 | %database.user% 28 | %database.password% 29 | ) 30 | setup: 31 | - setCacheStorage(...) 32 | #- setDatabaseReflection( Nette\Database\Reflection\DiscoveredReflection() ) 33 | 34 | model: Model( @database ) 35 | 36 | authenticator: Authenticator( @model::getUsers() ) 37 | 38 | 39 | factories: 40 | 41 | 42 | production < common: 43 | 44 | development < common: 45 | -------------------------------------------------------------------------------- /app/models/Authenticator.php: -------------------------------------------------------------------------------- 1 | users = $users; 22 | } 23 | 24 | 25 | 26 | /** 27 | * Provede ověření zadaných přístupových údajů. 28 | * @param $credentials array Pole obsahující klíče IAuthenticator::USERNAME a IAuthenticator::PASSWORD. 29 | * @return Nette\Security\Identity Identita uživatele. 30 | * @throws Nette\Security\AuthenticationException V případě, že zadané údaje nejsou platné. 31 | */ 32 | public function authenticate(array $credentials) 33 | { 34 | list($username, $password) = $credentials; 35 | $row = $this->users->where('username', $username)->fetch(); 36 | 37 | if (!$row) { 38 | throw new NS\AuthenticationException("User '$username' not found.", self::IDENTITY_NOT_FOUND); 39 | } 40 | 41 | if ($row->password !== $this->calculateHash($password)) { 42 | throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL); 43 | } 44 | 45 | unset($row->password); 46 | return new NS\Identity($row->id, NULL, $row->toArray()); 47 | } 48 | 49 | 50 | 51 | /** 52 | * Vypočítá osolený hash hesla. 53 | * @param $password string Heslo v plaintextu. 54 | * @return string Vypočítaný hash. 55 | */ 56 | public function calculateHash($password) 57 | { 58 | return hash('sha512', $password); 59 | } 60 | 61 | 62 | /** 63 | * Změní heslo uživatele. 64 | * @param $user_id string ID uživatele. 65 | * @param $password string Nové heslo. 66 | */ 67 | public function setPassword($id, $password) 68 | { 69 | $this->users->where(array('id' => $id)) 70 | ->update(array('password' => $this->calculateHash($password))); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/models/Model.php: -------------------------------------------------------------------------------- 1 | database = $database; 19 | } 20 | 21 | 22 | /** 23 | * Získá tabulku úkolů. 24 | * @return Nette\Database\Table\Selection 25 | */ 26 | public function getTasks() 27 | { 28 | return $this->database->table('task'); 29 | } 30 | 31 | /** 32 | * Získá tabulku se seznamy úkolů. 33 | * @return Nette\Database\Table\Selection 34 | */ 35 | public function getTaskLists() 36 | { 37 | return $this->database->table('tasklist'); 38 | } 39 | 40 | /** 41 | * Získá tabulku uživatelů. 42 | * @return Nette\Database\Table\Selection 43 | */ 44 | public function getUsers() 45 | { 46 | return $this->database->table('user'); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/presenters/BasePresenter.php: -------------------------------------------------------------------------------- 1 | model = $this->getService('model'); 20 | } 21 | 22 | 23 | /** 24 | * Před vykreslením. Zajišťuje získání seznamů úkolů. 25 | */ 26 | public function beforeRender() 27 | { 28 | $this->template->taskLists = $this->model->getTaskLists()->order('title ASC'); 29 | if ($this->isAjax()) { 30 | $this->invalidateControl('flashMessages'); 31 | } 32 | } 33 | 34 | 35 | /** 36 | * Vytvoří formulář pro založení nového seznamu úkolů. 37 | * @return Nette\Application\UI\Form 38 | */ 39 | protected function createComponentNewTasklistForm() 40 | { 41 | if (!$this->getUser()->isLoggedIn()) { 42 | throw new Nette\Application\ForbiddenRequestException(); 43 | } 44 | 45 | $form = new Form(); 46 | $form->addText('title', 'Název:', 15, 50) 47 | ->addRule(Form::FILLED, 'Musíte zadat název seznamu úkolů.'); 48 | $form->addSubmit('create', 'Vytvořit'); 49 | $form->onSuccess[] = callback($this, 'newTasklistFormSubmitted'); 50 | return $form; 51 | } 52 | 53 | /** 54 | * Zpracování formuláře newTasklistForm. Založí nový seznam úkolů. 55 | * @param Nette\Application\UI\Form $form 56 | */ 57 | public function newTasklistFormSubmitted(Form $form) 58 | { 59 | $this->model->getTaskLists()->insert(array( 60 | 'title' => $form->values->title 61 | )); 62 | $this->flashMessage('Seznam úkolů založen.', 'success'); 63 | $this->redirect('this'); 64 | } 65 | 66 | /** 67 | * Signál na odhlášení uživatele 68 | */ 69 | public function handleSignOut() 70 | { 71 | $this->getUser()->logout(); 72 | $this->redirect('Sign:in'); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/presenters/ErrorPresenter.php: -------------------------------------------------------------------------------- 1 | isAjax()) { // AJAX request? Just note this error in payload. 24 | $this->payload->error = TRUE; 25 | $this->terminate(); 26 | 27 | } elseif ($exception instanceof NA\BadRequestException) { 28 | $code = $exception->getCode(); 29 | $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx'); // load template 403.latte or 404.latte or ... 4xx.latte 30 | 31 | } else { 32 | $this->setView('500'); // load template 500.latte 33 | Debugger::log($exception, Debugger::ERROR); // and log exception 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/presenters/HomepagePresenter.php: -------------------------------------------------------------------------------- 1 | model->getTasks()->where(array('done' => false))->order('created ASC'); 12 | $taskList = new TaskList($tasks, $this->model); 13 | $taskList->setDisplayTaskList(TRUE); 14 | return $taskList; 15 | } 16 | 17 | 18 | public function createComponentUserTasks() 19 | { 20 | $tasks = $this->model->getTasks()->where(array( 21 | 'done' => false, 'user_id' => $this->getUser()->getId() 22 | )); 23 | $taskList = new TaskList($tasks, $this->model); 24 | $taskList->setDisplayTaskList(TRUE); 25 | $taskList->setDisplayUser(FALSE); 26 | return $taskList; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/presenters/SecuredPresenter.php: -------------------------------------------------------------------------------- 1 | getUser()->isLoggedIn()) { 10 | $this->redirect('Sign:in'); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /app/presenters/SignPresenter.php: -------------------------------------------------------------------------------- 1 | addText('username', 'Uživatelské jméno:', 30, 20); 17 | $form->addPassword('password', 'Heslo:', 30); 18 | $form->addCheckbox('persistent', 'Pamatovat si mě na tomto počítači'); 19 | $form->addSubmit('login', 'Přihlásit se'); 20 | $form->onSuccess[] = callback($this, 'signInFormSubmitted'); 21 | return $form; 22 | } 23 | 24 | public function signInFormSubmitted(Form $form) 25 | { 26 | try { 27 | $user = $this->getUser(); 28 | $values = $form->getValues(); 29 | if ($values->persistent) { 30 | $user->setExpiration('+30 days', FALSE); 31 | } 32 | $user->login($values->username, $values->password); 33 | $this->flashMessage('Přihlášení bylo úspěšné.', 'success'); 34 | $this->redirect('Homepage:'); 35 | } catch (NS\AuthenticationException $e) { 36 | $form->addError('Neplatné uživatelské jméno nebo heslo.'); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/presenters/TaskPresenter.php: -------------------------------------------------------------------------------- 1 | taskList = $this->model->getTaskLists()->find($id)->fetch(); 20 | if ($this->taskList === FALSE) { 21 | $this->setView('notFound'); 22 | } 23 | } 24 | 25 | /** 26 | * Výchozí view presenteru. Zajistí zobrazení zadaného seznamu úkolů. 27 | * @param $id int ID seznamu úkolů. 28 | */ 29 | public function renderDefault($id) 30 | { 31 | $this->template->taskList = $this->taskList; 32 | } 33 | 34 | 35 | /** 36 | * Vytvoří komponentu se seznamem úkolů. 37 | * @return TaskList 38 | */ 39 | protected function createComponentTaskList() 40 | { 41 | $tasks = $this->taskList->related('task')->order('done, created'); 42 | return new TaskList($tasks, $this->model); 43 | } 44 | 45 | 46 | /** 47 | * Vytvoří formulář pro zakládání úkolů. 48 | * @return Nette\Application\UI\Form 49 | */ 50 | protected function createComponentTaskForm() 51 | { 52 | $form = new Form(); 53 | $form->addText('text', 'Úkol:', 40, 100) 54 | ->addRule(Form::FILLED, 'Je nutné zadat text úkolu.'); 55 | $form->addSelect('userId', 'Pro:', $this->model->getUsers()->fetchPairs('id', 'name')) 56 | ->setPrompt('- Vyberte -') 57 | ->addRule(Form::FILLED, 'Je nutné vybrat, komu je úkol přiřazen.') 58 | ->setDefaultValue($this->getUser()->getId()); 59 | $form->addSubmit('create', 'Vytvořit'); 60 | $form->onSuccess[] = callback($this, 'taskFormSubmitted'); 61 | return $form; 62 | } 63 | 64 | 65 | /** 66 | * Zpracování odeslaného formuláře taskForm. Vytvoří nový úkol v aktuálním seznamu úkolů. 67 | * @param Nette\Application\UI\Form $form 68 | */ 69 | public function taskFormSubmitted(Form $form) 70 | { 71 | // vložení nového úkolu 72 | $this->model->getTasks()->insert(array( 73 | 'text' => $form->values->text, 74 | 'user_id' => $form->values->userId, 75 | 'created' => new DateTime(), 76 | 'tasklist_id' => $this->taskList->id 77 | )); 78 | // flash zprávička, přesměrování, invalidace. 79 | $this->flashMessage('Úkol přidán.', 'success'); 80 | if (!$this->isAjax()) { 81 | $this->redirect('this'); 82 | } else { 83 | $form->setValues(array('userId' => $form->values->userId), TRUE); 84 | $this->invalidateControl('form'); 85 | $this['taskList']->invalidateControl(); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /app/presenters/UserPresenter.php: -------------------------------------------------------------------------------- 1 | authenticator = $this->getService('authenticator'); 19 | } 20 | 21 | /** 22 | * Továrna na vytvoření formuláře pro změnu hesla. 23 | * @return Nette\Application\UI\Form 24 | */ 25 | protected function createComponentPasswordForm() 26 | { 27 | $form = new Form(); 28 | $form->addPassword('oldPassword', 'Staré heslo:', 30) 29 | ->addRule(Form::FILLED, 'Je nutné zadat staré heslo.'); 30 | $form->addPassword('newPassword', 'Nové heslo:', 30) 31 | ->addRule(Form::MIN_LENGTH, 'Nové heslo musí mít alespoň %d znaků.', 6); 32 | // obě pole se musejí shodovat 33 | $form->addPassword('confirmPassword', 'Potvrzení hesla:', 30) 34 | ->addRule(Form::FILLED, 'Nové heslo je nutné zadat ještě jednou pro potvrzení.') 35 | ->addRule(Form::EQUAL, 'Zadná hesla se musejí shodovat.', $form['newPassword']); 36 | $form->addSubmit('set', 'Změnit heslo'); 37 | $form->onSuccess[] = callback($this, 'passwordFormSubmitted'); 38 | return $form; 39 | } 40 | 41 | 42 | /** 43 | * Zpracuje odeslaný formulář. Mění heslo uživatele. 44 | * @param Nette\Application\UI\Form $form 45 | */ 46 | public function passwordFormSubmitted(Form $form) 47 | { 48 | $values = $form->getValues(); 49 | $user = $this->getUser(); 50 | try { 51 | // ověření správnosti starého hesla 52 | $this->authenticator->authenticate(array($user->getIdentity()->username, $values->oldPassword)); 53 | // změna hesla 54 | $this->authenticator->setPassword($user->getId(), $values->newPassword); 55 | // flash zprávička a přesměrování 56 | $this->flashMessage('Heslo bylo změněno.', 'success'); 57 | $this->redirect('Homepage:'); 58 | } catch (NS\AuthenticationException $e) { 59 | $form->addError('Zadané heslo není správné.'); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /app/templates/@layout.latte: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {ifset $title}{$title} – {/ifset}Úkolníček 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | {block head}{/block} 17 | 18 | 19 | 20 | 21 | 34 | 35 |
36 | 58 | 59 |
60 | {snippet flashMessages} 61 |
{$flash->message}
62 | {/snippet} 63 | 64 | {include #content} 65 |
66 | 67 | 70 |
71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /app/templates/Error/403.latte: -------------------------------------------------------------------------------- 1 | {var $robots = noindex} 2 | {block #content} 3 | 4 |

Access Denied

5 | 6 |

You do not have permission to view this page. Please try contact the web 7 | site administrator if you believe you should be able to view this page.

8 | 9 |

error 403

10 | -------------------------------------------------------------------------------- /app/templates/Error/404.latte: -------------------------------------------------------------------------------- 1 | {var $robots = noindex} 2 | {block #content} 3 | 4 |

Page Not Found

5 | 6 |

The page you requested could not be found. It is possible that the address is 7 | incorrect, or that the page no longer exists. Please use a search engine to find 8 | what you are looking for.

9 | 10 |

error 404

11 | -------------------------------------------------------------------------------- /app/templates/Error/405.latte: -------------------------------------------------------------------------------- 1 | {var $robots = noindex} 2 | {block #content} 3 | 4 |

Method Not Allowed

5 | 6 |

The requested method is not allowed for the URL.

7 | 8 |

error 405

9 | -------------------------------------------------------------------------------- /app/templates/Error/410.latte: -------------------------------------------------------------------------------- 1 | {var $robots = noindex} 2 | {block #content} 3 | 4 |

Page Not Found

5 | 6 |

The page you requested has been taken off the site. We apologize for the inconvenience.

7 | 8 |

error 410

9 | -------------------------------------------------------------------------------- /app/templates/Error/4xx.latte: -------------------------------------------------------------------------------- 1 | {var $robots = noindex} 2 | {block #content} 3 | 4 |

Oops...

5 | 6 |

Your browser sent a request that this server could not understand or process.

7 | -------------------------------------------------------------------------------- /app/templates/Error/500.latte: -------------------------------------------------------------------------------- 1 | {layout none} 2 | 3 | 4 | 5 | 11 | 12 |

Server Error

13 | 14 |

We're sorry! The server encountered an internal error and 15 | was unable to complete your request. Please try again later.

16 | 17 |

error 500

18 | -------------------------------------------------------------------------------- /app/templates/Homepage/default.latte: -------------------------------------------------------------------------------- 1 | {var $title = 'Přehled úkolů'} 2 | 3 | {block content} 4 | 5 |

Přehled úkolů

6 | 7 |

Mé úkoly

8 | {control userTasks} 9 | 10 |

Všechny nesplněné

11 | {control incompleteTasks} 12 | 13 | {/block} -------------------------------------------------------------------------------- /app/templates/Sign/in.latte: -------------------------------------------------------------------------------- 1 | {var $title = 'Přihlášení'} 2 | 3 | {block #content} 4 | 5 |

Přihlášení

6 | 7 | {form signInForm} 8 | {control $form errors} 9 | 10 | 27 | {/form} 28 | -------------------------------------------------------------------------------- /app/templates/Task/default.latte: -------------------------------------------------------------------------------- 1 | {var $title = $taskList->title} 2 | 3 | {block content} 4 | 5 |

{$taskList->title}

6 | 7 | {snippet form} 8 |
9 | Přidat úkol 10 | 11 | {form taskForm class => ajax} 12 |
13 | {control $form errors} 14 | 15 | {label text /} {input text size => 30, autofocus => true} {label userId /} {input userId} {input create} 16 |
17 | {/form} 18 |
19 | {/snippet} 20 | 21 | {control taskList} 22 | 23 | {/block} -------------------------------------------------------------------------------- /app/templates/Task/notFound.latte: -------------------------------------------------------------------------------- 1 | {status 404} 2 | {var $title = 'Nenalezeno'} 3 | 4 | {block #content} 5 | 6 |

Seznam úkolů nenalezen

7 | 8 |

Litujeme, ale Vámi požadovaný seznam úkolů nebyl nalezen.

-------------------------------------------------------------------------------- /app/templates/User/password.latte: -------------------------------------------------------------------------------- 1 | {var $title = 'Změna hesla'} 2 | 3 | {block content} 4 | 5 |

Změna hesla

6 | 7 | {form passwordForm} 8 |
9 | {control $form errors} 10 | 11 |
12 | {label oldPassword /} 13 |
{input oldPassword}
14 |
15 |
16 | {label newPassword /} 17 |
{input newPassword}
18 |
19 |
20 | {label confirmPassword /} 21 |
{input confirmPassword}
22 |
23 |
24 |
{input set}
25 |
26 |
27 | {/form} -------------------------------------------------------------------------------- /app/templates/maintenance.phtml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | Site is temporarily down for maintenance 19 | 20 |

We're Sorry

21 | 22 |

The site is temporarily down for maintenance. Please try again in a few minutes.

23 | 24 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/01_intro.texy: -------------------------------------------------------------------------------- 1 | Vytvořte si první aplikaci! 2 | ########################### 3 | 4 | .[perex] 5 | Tento praktický návod Vás provede tvorbou Vaší první aplikace v Nette Framework. Během **pár minut** vytvoříme **funkční a bezpečnou** aplikaci a ukážeme si některé výhody Nette, například **šablonovací systém**, **plnou podporu AJAXu** nebo **formuláře**. 6 | 7 | -------- 8 | 9 | Námi vytvářená aplikace bude jednoduchý úkolníček. Nejprve si vytvoříme jednoduchý seznam úkolů a postupně budeme 10 | aplikaci rozšiřovat - možnost úkoly organizovat do několika seznamů, přihlašování uživatelů, plánování úkolů a jejich 11 | přiřazování jednotlivým uživatelům. Aplikaci pak také přidáme podporu AJAXu. 12 | 13 | .[note] 14 | Tutoriál je psán pro PHP 5.3. Ověřte, zda si stahujete správnou verzi Nette. 15 | 16 | 17 | **Začínáme!** -------------------------------------------------------------------------------- /docs/data/data.mysql.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `task` (`id`, `text`, `created`, `done`, `user_id`, `tasklist_id`) VALUES 2 | (1, 'Provést analýzu', '2011-12-06 12:30:00', 1, 2, 1), 3 | (2, 'Implementace úkolníčku', '2011-12-06 12:35:50', 0, 3, 1), 4 | (3, 'Sepsání dokumentace', '2011-12-07 16:23:30', 0, 2, 1), 5 | (4, 'Opravit chybu #42', '2011-12-10 16:10:40', 0, 3, 2), 6 | (5, 'Zavolat klientovi', '2011-12-10 17:44:32', 0, 2, 2), 7 | (6, 'SWOT analýza', '2011-12-12 10:42:31', 0, 2, 3), 8 | (7, 'Analýza trhu', '2011-12-12 10:53:13', 0, 3, 3), 9 | (8, 'Opravit chybu #51', '2011-12-12 14:10:05', 0, 3, 2), 10 | (9, 'Nastavení serveru', '2011-12-13 17:52:14', 0, 2, 3), 11 | (10, 'Benchmark nového stroje', '2011-12-15 11:21:52', 1, 2, 3); 12 | 13 | INSERT INTO `tasklist` (`id`, `title`) VALUES 14 | (1, 'Projekt A'), 15 | (2, 'Projekt B'), 16 | (3, 'Projekt C'); 17 | 18 | INSERT INTO `user` (`id`, `username`, `password`, `name`) VALUES 19 | (1, 'admin', 'c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec', 'Administrátor'), 20 | (2, 'pepa', 'decffc27874ea35eb06aa728dd2b9a77197580e7456668ae90aa8db229e59ba4e6aac7b8d5fc1a7dcaee9cee1455044f1396e1cf1f50536604881138d0bea5e9', 'Josef Novák'), 21 | (3, 'franta', '124fff6f6790abdcf629a04108af221614f883f18fced9f14268abdd5465d077f2fed7d620e370ca20dd392fa05dd357dd3d45fa37f226d7621852eec3326f82', 'František Novotný'); -------------------------------------------------------------------------------- /docs/data/quickstart.mysql.sql: -------------------------------------------------------------------------------- 1 | -- Adminer 3.3.1 MySQL dump 2 | 3 | SET NAMES utf8; 4 | SET foreign_key_checks = 0; 5 | SET time_zone = 'SYSTEM'; 6 | SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; 7 | 8 | CREATE TABLE `task` ( 9 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 10 | `text` varchar(100) NOT NULL, 11 | `created` datetime NOT NULL, 12 | `done` tinyint(1) unsigned NOT NULL DEFAULT 0, 13 | `user_id` int(10) unsigned NOT NULL, 14 | `tasklist_id` int(10) unsigned NOT NULL, 15 | PRIMARY KEY (`id`), 16 | KEY `order` (`tasklist_id`,`done`,`created`) 17 | ); 18 | 19 | 20 | CREATE TABLE `tasklist` ( 21 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 22 | `title` varchar(50) NOT NULL, 23 | PRIMARY KEY (`id`) 24 | ); 25 | 26 | 27 | CREATE TABLE `user` ( 28 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 29 | `username` varchar(20) NOT NULL, 30 | `password` char(128) NOT NULL, 31 | `name` varchar(30) NOT NULL, 32 | PRIMARY KEY (`id`), 33 | UNIQUE KEY `username` (`username`) 34 | ); 35 | 36 | 37 | -- 2011-12-09 09:09:50 -------------------------------------------------------------------------------- /docs/latex.php: -------------------------------------------------------------------------------- 1 | '\{', 6 | '}' => '\}', 7 | '_' => '\_', 8 | '%' => '\%', 9 | '\\textbackslash{}' => '\\textbackslash{}\-' 10 | )); 11 | return str_replace('\{\}', '{}', $str); 12 | } 13 | 14 | $code = array(); 15 | 16 | $transform = array( 17 | '~/--+(\w*)(.*?)\\\\--+~s' => function ($m) { 18 | global $code; 19 | $i = count($code); 20 | $code[] = array($m[1], $m[2]); 21 | return 'CODE' . $i; 22 | }, 23 | 24 | // zpětná lomítka 25 | '~\\\\(?!-)~' => '\\textbackslash{}', 26 | 27 | '~----+~' => '', 28 | 29 | '~\\.\[(\w+)\]\r?\n?(.*)(\r?\n\r?\n)~sU' => '\begin{$1}$2'. "\r\n" .'\end{$1}$3', 30 | 31 | // nadpisy 32 | '~([^\n\r]+)\r?\n#+~' => '\section*{$1}', 33 | '~([^\n\r]+)\r?\n\*+~' => '\subsection*{$1}', 34 | '~([^\n\r]+)\r?\n=+~' => '\subsubsection*{$1}', 35 | 36 | '~\\[\\*\s*(\S*)\s*\\*\\]~' => '\begin{figure}\begin{center}\includegraphics[scale=0.5]{media/$1}\end{center}\end{figure}', 37 | 38 | // inline kód 39 | '~`([^`]+?)`~' => function($m) { 40 | return '\texttt{' . escape($m[1]) . '}'; 41 | }, 42 | 43 | '~\\$~' => '\\\\$', 44 | 45 | // formátování textu 46 | '~\*\*(.*?)\*\*~' => '\textbf{$1}', 47 | '~\*(.*?)\*~' => '\textit{$1}', 48 | 49 | // speciální znaky 50 | '~&~' => '\&', 51 | 52 | '~(\r?\n\r?\n)(?=-\s)~' => '$1\begin{my_item}' . "\n", 53 | '~(?<=\n)(-\s.*)(\r?\n\r?\n)~' => '$1\end{my_item}$2', 54 | '~(?<=\n)-\s~' => '\item ', 55 | 56 | '~"(.*)":\[(.*)\]~U' => '\href{$2}{$1}', 57 | 58 | // bloky kódu 59 | 60 | //'~/--+(\s*\n.*?)\\\\--+~s' => '\begin{verbatim}$1\end{verbatim}', 61 | 62 | '~CODE(\d+)~' => function ($m) { 63 | global $code; 64 | 65 | if ($code[$m[1]][0]) { 66 | return '\begin{minted}[startinline=true]{' . $code[$m[1]][0] . '}' . str_replace('\$', '$', $code[$m[1]][1]) . '\end{minted}'; 67 | } else { 68 | return '\begin{verbatim}' . $code[$m[1]][1] . '\end{verbatim}'; 69 | } 70 | } 71 | ); 72 | 73 | foreach (glob('*.texy') as $file) { 74 | echo $file . '... '; 75 | $content = file_get_contents($file); 76 | foreach ($transform as $pattern => $replacement) { 77 | if (is_callable($replacement)) 78 | $content = preg_replace_callback($pattern, $replacement, $content); 79 | else 80 | $content = preg_replace($pattern, $replacement, $content); 81 | } 82 | file_put_contents(str_replace('.texy', '.tex', $file), $content); 83 | echo "ok\n"; 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /docs/media/02_skeleton-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/02_skeleton-start.png -------------------------------------------------------------------------------- /docs/media/03_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/03_schema.png -------------------------------------------------------------------------------- /docs/media/04_debug-panel-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_debug-panel-sql.png -------------------------------------------------------------------------------- /docs/media/04_debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_debugger.png -------------------------------------------------------------------------------- /docs/media/04_lifecycle2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_lifecycle2.gif -------------------------------------------------------------------------------- /docs/media/04_list-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_list-table.png -------------------------------------------------------------------------------- /docs/media/04_not-found.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_not-found.png -------------------------------------------------------------------------------- /docs/media/04_presenter-nav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/04_presenter-nav.png -------------------------------------------------------------------------------- /docs/media/05_taskForm-control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/05_taskForm-control.png -------------------------------------------------------------------------------- /docs/media/05_taskForm-manual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/05_taskForm-manual.png -------------------------------------------------------------------------------- /docs/media/06_tasklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/06_tasklist.png -------------------------------------------------------------------------------- /docs/media/07_logged-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/docs/media/07_logged-in.png -------------------------------------------------------------------------------- /libs/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Deny from all -------------------------------------------------------------------------------- /libs/Nette/Application/Diagnostics/templates/RoutingPanel.tab.phtml: -------------------------------------------------------------------------------- 1 | 9 | request)): ?>no routerequest->getPresenterName() . ':' . (isset($this->request->parameters[Presenter::ACTION_KEY]) ? $this->request->parameters[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION) . (isset($this->request->parameters[Presenter::SIGNAL_KEY]) ? " {$this->request->parameters[Presenter::SIGNAL_KEY]}!" : ''); endif ?> 11 | -------------------------------------------------------------------------------- /libs/Nette/Application/IPresenter.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | interface IPresenterFactory 24 | { 25 | 26 | /** 27 | * @param string presenter name 28 | * @return string class name 29 | * @throws InvalidPresenterException 30 | */ 31 | function getPresenterClass(& $name); 32 | 33 | /** 34 | * Create new presenter instance. 35 | * @param string presenter name 36 | * @return IPresenter 37 | */ 38 | function createPresenter($name); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /libs/Nette/Application/IResponse.php: -------------------------------------------------------------------------------- 1 | request = $request; 38 | } 39 | 40 | 41 | 42 | /** 43 | * @return Nette\Application\Request 44 | */ 45 | final public function getRequest() 46 | { 47 | return $this->request; 48 | } 49 | 50 | 51 | 52 | /** 53 | * Sends response to output. 54 | * @return void 55 | */ 56 | public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) 57 | { 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /libs/Nette/Application/Responses/JsonResponse.php: -------------------------------------------------------------------------------- 1 | payload = $payload; 46 | $this->contentType = $contentType ? $contentType : 'application/json'; 47 | } 48 | 49 | 50 | 51 | /** 52 | * @return array|stdClass 53 | */ 54 | final public function getPayload() 55 | { 56 | return $this->payload; 57 | } 58 | 59 | 60 | 61 | /** 62 | * Returns the MIME content type of a downloaded file. 63 | * @return string 64 | */ 65 | final public function getContentType() 66 | { 67 | return $this->contentType; 68 | } 69 | 70 | 71 | 72 | /** 73 | * Sends response to output. 74 | * @return void 75 | */ 76 | public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) 77 | { 78 | $httpResponse->setContentType($this->contentType); 79 | $httpResponse->setExpiration(FALSE); 80 | echo Nette\Utils\Json::encode($this->payload); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /libs/Nette/Application/Responses/RedirectResponse.php: -------------------------------------------------------------------------------- 1 | url = (string) $url; 44 | $this->code = (int) $code; 45 | } 46 | 47 | 48 | 49 | /** 50 | * @return string 51 | */ 52 | final public function getUrl() 53 | { 54 | return $this->url; 55 | } 56 | 57 | 58 | 59 | /** 60 | * @return int 61 | */ 62 | final public function getCode() 63 | { 64 | return $this->code; 65 | } 66 | 67 | 68 | 69 | /** 70 | * Sends response to output. 71 | * @return void 72 | */ 73 | public function send(Http\IRequest $httpRequest, Http\IResponse $httpResponse) 74 | { 75 | $httpResponse->redirect($this->url, $this->code); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /libs/Nette/Application/Responses/TextResponse.php: -------------------------------------------------------------------------------- 1 | source = $source; 38 | } 39 | 40 | 41 | 42 | /** 43 | * @return mixed 44 | */ 45 | final public function getSource() 46 | { 47 | return $this->source; 48 | } 49 | 50 | 51 | 52 | /** 53 | * Sends response to output. 54 | * @return void 55 | */ 56 | public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) 57 | { 58 | if ($this->source instanceof Nette\Templating\ITemplate) { 59 | $this->source->render(); 60 | 61 | } else { 62 | echo $this->source; 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /libs/Nette/Application/UI/BadSignalException.php: -------------------------------------------------------------------------------- 1 | component = $component; 49 | $this->destination = $destination; 50 | $this->params = $params; 51 | } 52 | 53 | 54 | 55 | /** 56 | * Returns link destination. 57 | * @return string 58 | */ 59 | public function getDestination() 60 | { 61 | return $this->destination; 62 | } 63 | 64 | 65 | 66 | /** 67 | * Changes link parameter. 68 | * @param string 69 | * @param mixed 70 | * @return Link provides a fluent interface 71 | */ 72 | public function setParameter($key, $value) 73 | { 74 | $this->params[$key] = $value; 75 | return $this; 76 | } 77 | 78 | 79 | 80 | /** 81 | * Returns link parameter. 82 | * @param string 83 | * @return mixed 84 | */ 85 | public function getParameter($key) 86 | { 87 | return isset($this->params[$key]) ? $this->params[$key] : NULL; 88 | } 89 | 90 | 91 | 92 | /** 93 | * Returns link parameters. 94 | * @return array 95 | */ 96 | public function getParameters() 97 | { 98 | return $this->params; 99 | } 100 | 101 | 102 | 103 | /** 104 | * Converts link to URL. 105 | * @return string 106 | */ 107 | public function __toString() 108 | { 109 | try { 110 | return $this->component->link($this->destination, $this->params); 111 | 112 | } catch (\Exception $e) { 113 | Nette\Diagnostics\Debugger::toStringException($e); 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /libs/Nette/Application/UI/Multiplier.php: -------------------------------------------------------------------------------- 1 | factory = callback($factory); 33 | } 34 | 35 | 36 | 37 | protected function createComponent($name) 38 | { 39 | return $this->factory->invoke($name, $this); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /libs/Nette/Application/exceptions.php: -------------------------------------------------------------------------------- 1 | 504) { 58 | $code = $this->defaultCode; 59 | } 60 | 61 | { 62 | parent::__construct($message, $code, $previous); 63 | } 64 | } 65 | 66 | } 67 | 68 | 69 | 70 | /** 71 | * Forbidden request exception - access denied. 72 | */ 73 | class ForbiddenRequestException extends BadRequestException 74 | { 75 | /** @var int */ 76 | protected $defaultCode = 403; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /libs/Nette/Application/templates/error.phtml: -------------------------------------------------------------------------------- 1 | array('Oops...', 'Your browser sent a request that this server could not understand or process.'), 12 | 403 => array('Access Denied', 'You do not have permission to view this page. Please try contact the web site administrator if you believe you should be able to view this page.'), 13 | 404 => array('Page Not Found', 'The page you requested could not be found. It is possible that the address is incorrect, or that the page no longer exists. Please use a search engine to find what you are looking for.'), 14 | 405 => array('Method Not Allowed', 'The requested method is not allowed for the URL.'), 15 | 410 => array('Page Not Found', 'The page you requested has been taken off the site. We apologize for the inconvenience.'), 16 | 500 => array('Server Error', 'We\'re sorry! The server encountered an internal error and was unable to complete your request. Please try again later.'), 17 | ); 18 | $message = isset($messages[$code]) ? $messages[$code] : $messages[0]; 19 | 20 | ?> 21 | 22 | 23 | 24 | 25 | 26 | <?php echo $message[0] ?> 27 | 28 |

29 | 30 |

31 | 32 |

error

33 | -------------------------------------------------------------------------------- /libs/Nette/Caching/IStorage.php: -------------------------------------------------------------------------------- 1 | cache = $cache; 39 | $this->key = $key; 40 | ob_start(); 41 | } 42 | 43 | 44 | 45 | /** 46 | * Stops and saves the cache. 47 | * @param array dependencies 48 | * @return void 49 | */ 50 | public function end(array $dp = NULL) 51 | { 52 | if ($this->cache === NULL) { 53 | throw new Nette\InvalidStateException('Output cache has already been saved.'); 54 | } 55 | $this->cache->save($this->key, ob_get_flush(), (array) $dp + (array) $this->dependencies); 56 | $this->cache = NULL; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /libs/Nette/Caching/Storages/DevNullStorage.php: -------------------------------------------------------------------------------- 1 | data[$key]) ? $this->data[$key] : NULL; 38 | } 39 | 40 | 41 | 42 | /** 43 | * Prevents item reading and writing. Lock is released by write() or remove(). 44 | * @param string key 45 | * @return void 46 | */ 47 | public function lock($key) 48 | { 49 | } 50 | 51 | 52 | 53 | /** 54 | * Writes item into the cache. 55 | * @param string key 56 | * @param mixed data 57 | * @param array dependencies 58 | * @return void 59 | */ 60 | public function write($key, $data, array $dp) 61 | { 62 | $this->data[$key] = $data; 63 | } 64 | 65 | 66 | 67 | /** 68 | * Removes item from the cache. 69 | * @param string key 70 | * @return void 71 | */ 72 | public function remove($key) 73 | { 74 | unset($this->data[$key]); 75 | } 76 | 77 | 78 | 79 | /** 80 | * Removes items from the cache by conditions & garbage collector. 81 | * @param array conditions 82 | * @return void 83 | */ 84 | public function clean(array $conds) 85 | { 86 | if (!empty($conds[Nette\Caching\Cache::ALL])) { 87 | $this->data = array(); 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /libs/Nette/Caching/Storages/PhpFileStorage.php: -------------------------------------------------------------------------------- 1 | $meta[self::FILE], 38 | 'handle' => $meta[self::HANDLE], 39 | ); 40 | } 41 | 42 | 43 | 44 | /** 45 | * Returns file name. 46 | * @param string 47 | * @return string 48 | */ 49 | protected function getCacheFile($key) 50 | { 51 | return parent::getCacheFile(substr_replace( 52 | $key, 53 | trim(strtr($this->hint, '\\/@', '.._'), '.') . '-', 54 | strpos($key, Nette\Caching\Cache::NAMESPACE_SEPARATOR) + 1, 55 | 0 56 | )) . '.php'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /libs/Nette/ComponentModel/IComponent.php: -------------------------------------------------------------------------------- 1 | current() instanceof IContainer; 34 | } 35 | 36 | 37 | 38 | /** 39 | * The sub-iterator for the current element. 40 | * @return \RecursiveIterator 41 | */ 42 | public function getChildren() 43 | { 44 | return $this->current()->getComponents(); 45 | } 46 | 47 | 48 | 49 | /** 50 | * Returns the count of elements. 51 | * @return int 52 | */ 53 | public function count() 54 | { 55 | return iterator_count($this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /libs/Nette/Config/Adapters/NeonAdapter.php: -------------------------------------------------------------------------------- 1 | process((array) Neon::decode(file_get_contents($file))); 40 | } 41 | 42 | 43 | 44 | private function process(array $arr) 45 | { 46 | $res = array(); 47 | foreach ($arr as $key => $val) { 48 | if (substr($key, -1) === self::PREVENT_MERGING) { 49 | if (!is_array($val) && $val !== NULL) { 50 | throw new Nette\InvalidStateException("Replacing operator is available only for arrays, item '$key' is not array."); 51 | } 52 | $key = substr($key, 0, -1); 53 | $val[Helpers::EXTENDS_KEY] = Helpers::OVERWRITE; 54 | 55 | } elseif (preg_match('#^(\S+)\s+' . self::INHERITING_SEPARATOR . '\s+(\S+)$#', $key, $matches)) { 56 | if (!is_array($val) && $val !== NULL) { 57 | throw new Nette\InvalidStateException("Inheritance operator is available only for arrays, item '$key' is not array."); 58 | } 59 | list(, $key, $val[Helpers::EXTENDS_KEY]) = $matches; 60 | if (isset($res[$key])) { 61 | throw new Nette\InvalidStateException("Duplicated key '$key'."); 62 | } 63 | } 64 | 65 | if (is_array($val)) { 66 | $val = $this->process($val); 67 | } elseif ($val instanceof Nette\Utils\NeonEntity) { 68 | $val = (object) array('value' => $val->value, 'attributes' => $this->process($val->attributes)); 69 | } 70 | $res[$key] = $val; 71 | } 72 | return $res; 73 | } 74 | 75 | 76 | 77 | /** 78 | * Generates configuration in NEON format. 79 | * @param array 80 | * @return string 81 | */ 82 | public function dump(array $data) 83 | { 84 | $tmp = array(); 85 | foreach ($data as $name => $secData) { 86 | if ($parent = Helpers::takeParent($secData)) { 87 | $name .= ' ' . self::INHERITING_SEPARATOR . ' ' . $parent; 88 | } 89 | $tmp[$name] = $secData; 90 | } 91 | return "# generated by Nette\n\n" . Neon::encode($tmp, Neon::BLOCK); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /libs/Nette/Config/Adapters/PhpAdapter.php: -------------------------------------------------------------------------------- 1 | getConfig() as $name => $value) { 30 | $class->methods['initialize']->addBody('define(?, ?);', array($name, $value)); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /libs/Nette/Config/Extensions/PhpExtension.php: -------------------------------------------------------------------------------- 1 | methods['initialize']; 30 | foreach ($this->getConfig() as $name => $value) { 31 | if (!is_scalar($value)) { 32 | throw new Nette\InvalidStateException("Configuration value for directive '$name' is not scalar."); 33 | 34 | } elseif ($name === 'include_path') { 35 | $initialize->addBody('set_include_path(?);', array(str_replace(';', PATH_SEPARATOR, $value))); 36 | 37 | } elseif ($name === 'ignore_user_abort') { 38 | $initialize->addBody('ignore_user_abort(?);', array($value)); 39 | 40 | } elseif ($name === 'max_execution_time') { 41 | $initialize->addBody('set_time_limit(?);', array($value)); 42 | 43 | } elseif ($name === 'date.timezone') { 44 | $initialize->addBody('date_default_timezone_set(?);', array($value)); 45 | 46 | } elseif (function_exists('ini_set')) { 47 | $initialize->addBody('ini_set(?, ?);', array($name, $value)); 48 | 49 | } elseif (ini_get($name) != $value && !Nette\Framework::$iAmUsingBadHost) { // intentionally == 50 | throw new Nette\NotSupportedException('Required function ini_set() is disabled.'); 51 | } 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /libs/Nette/Config/Helpers.php: -------------------------------------------------------------------------------- 1 | $val) { 38 | if (is_int($key)) { 39 | $right[] = $val; 40 | } else { 41 | if (is_array($val) && isset($val[self::EXTENDS_KEY])) { 42 | if ($val[self::EXTENDS_KEY] === self::OVERWRITE) { 43 | unset($val[self::EXTENDS_KEY]); 44 | } 45 | } elseif (isset($right[$key])) { 46 | $val = static::merge($val, $right[$key]); 47 | } 48 | $right[$key] = $val; 49 | } 50 | } 51 | return $right; 52 | 53 | } elseif ($left === NULL && is_array($right)) { 54 | return $right; 55 | 56 | } else { 57 | return $left; 58 | } 59 | } 60 | 61 | 62 | 63 | /** 64 | * Finds out and removes information about the parent. 65 | * @return mixed 66 | */ 67 | public static function takeParent(& $data) 68 | { 69 | if (is_array($data) && isset($data[self::EXTENDS_KEY])) { 70 | $parent = $data[self::EXTENDS_KEY]; 71 | unset($data[self::EXTENDS_KEY]); 72 | return $parent; 73 | } 74 | } 75 | 76 | 77 | 78 | /** 79 | * @return bool 80 | */ 81 | public static function isOverwriting(& $data) 82 | { 83 | return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] === self::OVERWRITE; 84 | } 85 | 86 | 87 | 88 | /** 89 | * @return bool 90 | */ 91 | public static function isInheriting(& $data) 92 | { 93 | return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] !== self::OVERWRITE; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /libs/Nette/Config/IAdapter.php: -------------------------------------------------------------------------------- 1 | container = $container; 40 | $this->namespace = $namespace . '_'; 41 | $this->parameters = & $container->parameters[$namespace]; 42 | } 43 | 44 | 45 | 46 | /** 47 | * @return object 48 | */ 49 | public function &__get($name) 50 | { 51 | $service = $this->container->getService($this->namespace . $name); 52 | return $service; 53 | } 54 | 55 | 56 | 57 | /** 58 | * @return void 59 | */ 60 | public function __set($name, $service) 61 | { 62 | throw new Nette\NotSupportedException; 63 | } 64 | 65 | 66 | 67 | /** 68 | * @return bool 69 | */ 70 | public function __isset($name) 71 | { 72 | return $this->container->hasService($this->namespace . $name); 73 | } 74 | 75 | 76 | 77 | /** 78 | * @return void 79 | */ 80 | public function __unset($name) 81 | { 82 | throw new Nette\NotSupportedException; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /libs/Nette/DI/ServiceDefinition.php: -------------------------------------------------------------------------------- 1 | class = $class; 54 | if ($args) { 55 | $this->setFactory($class, $args); 56 | } 57 | return $this; 58 | } 59 | 60 | 61 | 62 | public function setFactory($factory, array $args = array()) 63 | { 64 | $this->factory = new Statement($factory, $args); 65 | return $this; 66 | } 67 | 68 | 69 | 70 | public function setArguments(array $args = array()) 71 | { 72 | if ($this->factory) { 73 | $this->factory->arguments = $args; 74 | } else { 75 | $this->setClass($this->class, $args); 76 | } 77 | return $this; 78 | } 79 | 80 | 81 | 82 | public function addSetup($target, $args = NULL) 83 | { 84 | $this->setup[] = new Statement($target, $args); 85 | return $this; 86 | } 87 | 88 | 89 | 90 | public function setParameters(array $params) 91 | { 92 | $this->shared = $this->autowired = FALSE; 93 | $this->parameters = $params; 94 | return $this; 95 | } 96 | 97 | 98 | 99 | public function addTag($tag, $attrs = TRUE) 100 | { 101 | $this->tags[$tag] = $attrs; 102 | return $this; 103 | } 104 | 105 | 106 | 107 | public function setAutowired($on) 108 | { 109 | $this->autowired = $on; 110 | return $this; 111 | } 112 | 113 | 114 | 115 | public function setShared($on) 116 | { 117 | $this->shared = (bool) $on; 118 | return $this; 119 | } 120 | 121 | 122 | 123 | public function setInternal($on) 124 | { 125 | $this->internal = (bool) $on; 126 | return $this; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /libs/Nette/DI/Statement.php: -------------------------------------------------------------------------------- 1 | entity = $entity; 36 | $this->arguments = $arguments; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /libs/Nette/DI/exceptions.php: -------------------------------------------------------------------------------- 1 | $value) { 49 | unset($row[$key]); 50 | if ($key[0] === '[' || $key[0] === '"') { 51 | $key = substr($key, 1, -1); 52 | } 53 | $row[$key] = $value; 54 | } 55 | return $row; 56 | } 57 | 58 | 59 | 60 | /** 61 | * Returns metadata for all foreign keys in a table. 62 | */ 63 | public function getForeignKeys($table) 64 | { 65 | throw new NotSupportedException; // @see http://www.sqlite.org/foreignkeys.html 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /libs/Nette/Database/IReflection.php: -------------------------------------------------------------------------------- 1 | , %2$s for table name 42 | * @param string %1$s stands for key used after ->, %2$s for table name 43 | */ 44 | public function __construct($primary = 'id', $foreign = '%s_id', $table = '%s') 45 | { 46 | $this->primary = $primary; 47 | $this->foreign = $foreign; 48 | $this->table = $table; 49 | } 50 | 51 | 52 | 53 | public function getPrimary($table) 54 | { 55 | return sprintf($this->primary, $this->getColumnFromTable($table)); 56 | } 57 | 58 | 59 | 60 | public function getHasManyReference($table, $key) 61 | { 62 | $table = $this->getColumnFromTable($table); 63 | return array( 64 | sprintf($this->table, $key, $table), 65 | sprintf($this->foreign, $table, $key), 66 | ); 67 | } 68 | 69 | 70 | 71 | public function getBelongsToReference($table, $key) 72 | { 73 | $table = $this->getColumnFromTable($table); 74 | return array( 75 | sprintf($this->table, $key, $table), 76 | sprintf($this->foreign, $key, $table), 77 | ); 78 | } 79 | 80 | 81 | 82 | 83 | public function setConnection(Nette\Database\Connection $connection) 84 | {} 85 | 86 | 87 | 88 | protected function getColumnFromTable($name) 89 | { 90 | if ($this->table !== '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '$)', $name, $match)) { 91 | return $match[1]; 92 | } 93 | 94 | return $name; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /libs/Nette/Database/Row.php: -------------------------------------------------------------------------------- 1 | normalizeRow($this); 29 | } 30 | 31 | 32 | 33 | /** 34 | * Returns a item. 35 | * @param mixed key or index 36 | * @return mixed 37 | */ 38 | public function offsetGet($key) 39 | { 40 | if (is_int($key)) { 41 | $arr = array_values((array) $this); 42 | return $arr[$key]; 43 | } 44 | return $this->$key; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /libs/Nette/Database/SqlLiteral.php: -------------------------------------------------------------------------------- 1 | value = (string) $value; 32 | } 33 | 34 | 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getValue() 40 | { 41 | return $this->value; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/Bar.php: -------------------------------------------------------------------------------- 1 | panels[$id])); 44 | } 45 | $this->panels[$id] = $panel; 46 | return $this; 47 | } 48 | 49 | 50 | 51 | /** 52 | * Renders debug bar. 53 | * @return void 54 | */ 55 | public function render() 56 | { 57 | $obLevel = ob_get_level(); 58 | $panels = array(); 59 | foreach ($this->panels as $id => $panel) { 60 | try { 61 | $panels[] = array( 62 | 'id' => preg_replace('#[^a-z0-9]+#i', '-', $id), 63 | 'tab' => $tab = (string) $panel->getTab(), 64 | 'panel' => $tab ? (string) $panel->getPanel() : NULL, 65 | ); 66 | } catch (\Exception $e) { 67 | $panels[] = array( 68 | 'id' => "error-$id", 69 | 'tab' => "Error: $id", 70 | 'panel' => nl2br(htmlSpecialChars((string) $e)), 71 | ); 72 | while (ob_get_level() > $obLevel) { // restore ob-level if broken 73 | ob_end_clean(); 74 | } 75 | } 76 | } 77 | require __DIR__ . '/templates/bar.phtml'; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/DefaultBarPanel.php: -------------------------------------------------------------------------------- 1 | id = $id; 34 | } 35 | 36 | 37 | 38 | /** 39 | * Renders HTML code for custom tab. 40 | * @return string 41 | */ 42 | public function getTab() 43 | { 44 | ob_start(); 45 | $data = $this->data; 46 | if ($this->id === 'time') { 47 | require __DIR__ . '/templates/bar.time.tab.phtml'; 48 | } elseif ($this->id === 'memory') { 49 | require __DIR__ . '/templates/bar.memory.tab.phtml'; 50 | } elseif ($this->id === 'dumps' && $this->data) { 51 | require __DIR__ . '/templates/bar.dumps.tab.phtml'; 52 | } elseif ($this->id === 'errors' && $this->data) { 53 | require __DIR__ . '/templates/bar.errors.tab.phtml'; 54 | } 55 | return ob_get_clean(); 56 | } 57 | 58 | 59 | 60 | /** 61 | * Renders HTML code for custom panel. 62 | * @return string 63 | */ 64 | public function getPanel() 65 | { 66 | ob_start(); 67 | $data = $this->data; 68 | if ($this->id === 'dumps') { 69 | require __DIR__ . '/templates/bar.dumps.panel.phtml'; 70 | } elseif ($this->id === 'errors') { 71 | require __DIR__ . '/templates/bar.errors.panel.phtml'; 72 | } 73 | return ob_get_clean(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/IBarPanel.php: -------------------------------------------------------------------------------- 1 | directory)) { 54 | throw new Nette\DirectoryNotFoundException("Directory '$this->directory' is not found or is not directory."); 55 | } 56 | 57 | if (is_array($message)) { 58 | $message = implode(' ', $message); 59 | } 60 | $res = error_log(trim($message) . PHP_EOL, 3, $this->directory . '/' . strtolower($priority) . '.log'); 61 | 62 | if (($priority === self::ERROR || $priority === self::CRITICAL) && $this->email && $this->mailer 63 | && @filemtime($this->directory . '/email-sent') + self::$emailSnooze < time() // @ - file may not exist 64 | && @file_put_contents($this->directory . '/email-sent', 'sent') // @ - file may not be writable 65 | ) { 66 | call_user_func($this->mailer, $message, $this->email); 67 | } 68 | return $res; 69 | } 70 | 71 | 72 | 73 | /** 74 | * Default mailer. 75 | * @param string 76 | * @param string 77 | * @return void 78 | */ 79 | private static function defaultMailer($message, $email) 80 | { 81 | $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 82 | (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''); 83 | 84 | $parts = str_replace( 85 | array("\r\n", "\n"), 86 | array("\n", PHP_EOL), 87 | array( 88 | 'headers' => "From: noreply@$host\nX-Mailer: Nette Framework\n", 89 | 'subject' => "PHP: An error occurred on the server $host", 90 | 'body' => "[" . @date('Y-m-d H:i:s') . "] $message", // @ - timezone may not be set 91 | ) 92 | ); 93 | 94 | mail($email, $parts['subject'], $parts['body'], $parts['headers']); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.dumps.panel.phtml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 |

Dumped variables

19 | 20 |
21 | 22 | 23 |

24 | 25 | 26 | 27 | 28 | $dump): ?> 29 | 30 | 31 | 32 | 33 | 34 |
35 | 36 |
37 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.dumps.tab.phtml: -------------------------------------------------------------------------------- 1 | 14 | variables 15 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.errors.panel.phtml: -------------------------------------------------------------------------------- 1 | 14 |

Errors

15 | 16 |
17 | 18 | 19 | $count): list($message, $file, $line) = explode('|', $item) ?> 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.errors.tab.phtml: -------------------------------------------------------------------------------- 1 | 14 | errors 16 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.memory.tab.phtml: -------------------------------------------------------------------------------- 1 | 14 | MB 16 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/bar.time.tab.phtml: -------------------------------------------------------------------------------- 1 | 14 | ms 16 | -------------------------------------------------------------------------------- /libs/Nette/Diagnostics/templates/error.phtml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | Server Error 16 | 17 |

Server Error

18 | 19 |

We're sorry! The server encountered an internal error and was unable to complete your request. Please try again later.

20 | 21 |

error 500

22 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/Button.php: -------------------------------------------------------------------------------- 1 | control->type = 'button'; 33 | } 34 | 35 | 36 | 37 | /** 38 | * Bypasses label generation. 39 | * @return void 40 | */ 41 | public function getLabel($caption = NULL) 42 | { 43 | return NULL; 44 | } 45 | 46 | 47 | 48 | /** 49 | * Generates control's HTML element. 50 | * @param string 51 | * @return Nette\Utils\Html 52 | */ 53 | public function getControl($caption = NULL) 54 | { 55 | $control = parent::getControl(); 56 | $control->value = $this->translate($caption === NULL ? $this->caption : $caption); 57 | return $control; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/Checkbox.php: -------------------------------------------------------------------------------- 1 | control->type = 'checkbox'; 33 | $this->value = FALSE; 34 | } 35 | 36 | 37 | 38 | /** 39 | * Sets control's value. 40 | * @param bool 41 | * @return Checkbox provides a fluent interface 42 | */ 43 | public function setValue($value) 44 | { 45 | $this->value = is_scalar($value) ? (bool) $value : FALSE; 46 | return $this; 47 | } 48 | 49 | 50 | 51 | /** 52 | * Generates control's HTML element. 53 | * @return Nette\Utils\Html 54 | */ 55 | public function getControl() 56 | { 57 | return parent::getControl()->checked($this->value); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/HiddenField.php: -------------------------------------------------------------------------------- 1 | control->type = 'hidden'; 34 | $this->value = (string) $forcedValue; 35 | $this->forcedValue = $forcedValue; 36 | } 37 | 38 | 39 | 40 | /** 41 | * Bypasses label generation. 42 | * @return void 43 | */ 44 | public function getLabel($caption = NULL) 45 | { 46 | return NULL; 47 | } 48 | 49 | 50 | 51 | /** 52 | * Sets control's value. 53 | * @param string 54 | * @return HiddenField provides a fluent interface 55 | */ 56 | public function setValue($value) 57 | { 58 | $this->value = is_scalar($value) ? (string) $value : ''; 59 | return $this; 60 | } 61 | 62 | 63 | 64 | /** 65 | * Generates control's HTML element. 66 | * @return Nette\Utils\Html 67 | */ 68 | public function getControl() 69 | { 70 | return parent::getControl() 71 | ->value($this->forcedValue === NULL ? $this->value : $this->forcedValue) 72 | ->data('nette-rules', NULL); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/ImageButton.php: -------------------------------------------------------------------------------- 1 | control->type = 'image'; 34 | $this->control->src = $src; 35 | $this->control->alt = $alt; 36 | } 37 | 38 | 39 | 40 | /** 41 | * Returns HTML name of control. 42 | * @return string 43 | */ 44 | public function getHtmlName() 45 | { 46 | $name = parent::getHtmlName(); 47 | return strpos($name, '[') === FALSE ? $name : $name . '[]'; 48 | } 49 | 50 | 51 | 52 | /** 53 | * Loads HTTP data. 54 | * @return void 55 | */ 56 | public function loadHttpData() 57 | { 58 | $path = $this->getHtmlName(); // img_x or img['x'] 59 | $path = explode('[', strtr(str_replace(']', '', strpos($path, '[') === FALSE ? $path . '.x' : substr($path, 0, -2)), '.', '_')); 60 | $this->setValue(Nette\Utils\Arrays::get($this->getForm()->getHttpData(), $path, NULL) !== NULL); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/MultiSelectBox.php: -------------------------------------------------------------------------------- 1 | allowed); 34 | if ($this->getPrompt()) { 35 | unset($allowed[0]); 36 | } 37 | return array_intersect($this->getRawValue(), $allowed); 38 | } 39 | 40 | 41 | 42 | /** 43 | * Returns selected keys (not checked). 44 | * @return array 45 | */ 46 | public function getRawValue() 47 | { 48 | if (is_scalar($this->value)) { 49 | $value = array($this->value); 50 | 51 | } elseif (!is_array($this->value)) { 52 | $value = array(); 53 | 54 | } else { 55 | $value = $this->value; 56 | } 57 | 58 | $res = array(); 59 | foreach ($value as $val) { 60 | if (is_scalar($val)) { 61 | $res[] = $val; 62 | } 63 | } 64 | return $res; 65 | } 66 | 67 | 68 | 69 | /** 70 | * Returns selected values. 71 | * @return array 72 | */ 73 | public function getSelectedItem() 74 | { 75 | if (!$this->areKeysUsed()) { 76 | return $this->getValue(); 77 | 78 | } else { 79 | $res = array(); 80 | foreach ($this->getValue() as $value) { 81 | $res[$value] = $this->allowed[$value]; 82 | } 83 | return $res; 84 | } 85 | } 86 | 87 | 88 | 89 | /** 90 | * Returns HTML name of control. 91 | * @return string 92 | */ 93 | public function getHtmlName() 94 | { 95 | return parent::getHtmlName() . '[]'; 96 | } 97 | 98 | 99 | 100 | /** 101 | * Generates control's HTML element. 102 | * @return Nette\Utils\Html 103 | */ 104 | public function getControl() 105 | { 106 | $control = parent::getControl(); 107 | $control->multiple = TRUE; 108 | return $control; 109 | } 110 | 111 | 112 | 113 | /** 114 | * Count/length validator. 115 | * @param MultiSelectBox 116 | * @param array min and max length pair 117 | * @return bool 118 | */ 119 | public static function validateLength(MultiSelectBox $control, $range) 120 | { 121 | if (!is_array($range)) { 122 | $range = array($range, $range); 123 | } 124 | $count = count($control->getSelectedItem()); 125 | return ($range[0] === NULL || $count >= $range[0]) && ($range[1] === NULL || $count <= $range[1]); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/TextArea.php: -------------------------------------------------------------------------------- 1 | control->setName('textarea'); 36 | $this->control->cols = $cols; 37 | $this->control->rows = $rows; 38 | $this->value = ''; 39 | } 40 | 41 | 42 | 43 | /** 44 | * Generates control's HTML element. 45 | * @return Nette\Utils\Html 46 | */ 47 | public function getControl() 48 | { 49 | $control = parent::getControl(); 50 | $control->setText($this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value); 51 | return $control; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /libs/Nette/Forms/Controls/TextInput.php: -------------------------------------------------------------------------------- 1 | control->type = 'text'; 37 | $this->control->size = $cols; 38 | $this->control->maxlength = $maxLength; 39 | $this->filters[] = callback($this, 'sanitize'); 40 | $this->value = ''; 41 | } 42 | 43 | 44 | 45 | /** 46 | * Filter: removes unnecessary whitespace and shortens value to control's max length. 47 | * @return string 48 | */ 49 | public function sanitize($value) 50 | { 51 | if ($this->control->maxlength && Nette\Utils\Strings::length($value) > $this->control->maxlength) { 52 | $value = Nette\Utils\Strings::substring($value, 0, $this->control->maxlength); 53 | } 54 | return Nette\Utils\Strings::trim(strtr($value, "\r\n", ' ')); 55 | } 56 | 57 | 58 | 59 | /** 60 | * Changes control's type attribute. 61 | * @param string 62 | * @return BaseControl provides a fluent interface 63 | */ 64 | public function setType($type) 65 | { 66 | $this->control->type = $type; 67 | return $this; 68 | } 69 | 70 | 71 | 72 | /** @deprecated */ 73 | public function setPasswordMode($mode = TRUE) 74 | { 75 | $this->control->type = $mode ? 'password' : 'text'; 76 | return $this; 77 | } 78 | 79 | 80 | 81 | /** 82 | * Generates control's HTML element. 83 | * @return Nette\Utils\Html 84 | */ 85 | public function getControl() 86 | { 87 | $control = parent::getControl(); 88 | foreach ($this->getRules() as $rule) { 89 | if ($rule->isNegative || $rule->type !== Nette\Forms\Rule::VALIDATOR) { 90 | 91 | } elseif ($rule->operation === Nette\Forms\Form::RANGE && $control->type !== 'text') { 92 | list($control->min, $control->max) = $rule->arg; 93 | 94 | } elseif ($rule->operation === Nette\Forms\Form::PATTERN) { 95 | $control->pattern = $rule->arg; 96 | } 97 | } 98 | if ($control->type !== 'password') { 99 | $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value; 100 | } 101 | return $control; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /libs/Nette/Forms/IControl.php: -------------------------------------------------------------------------------- 1 | request = $request; 40 | $this->response = $response; 41 | } 42 | 43 | 44 | 45 | /** 46 | * Attempts to cache the sent entity by its last modification date. 47 | * @param string|int|DateTime last modified time 48 | * @param string strong entity tag validator 49 | * @return bool 50 | */ 51 | public function isModified($lastModified = NULL, $etag = NULL) 52 | { 53 | if ($lastModified) { 54 | $this->response->setHeader('Last-Modified', $this->response->date($lastModified)); 55 | } 56 | if ($etag) { 57 | $this->response->setHeader('ETag', '"' . addslashes($etag) . '"'); 58 | } 59 | 60 | $ifNoneMatch = $this->request->getHeader('If-None-Match'); 61 | if ($ifNoneMatch === '*') { 62 | $match = TRUE; // match, check if-modified-since 63 | 64 | } elseif ($ifNoneMatch !== NULL) { 65 | $etag = $this->response->getHeader('ETag'); 66 | 67 | if ($etag == NULL || strpos(' ' . strtr($ifNoneMatch, ",\t", ' '), ' ' . $etag) === FALSE) { 68 | return TRUE; 69 | 70 | } else { 71 | $match = TRUE; // match, check if-modified-since 72 | } 73 | } 74 | 75 | $ifModifiedSince = $this->request->getHeader('If-Modified-Since'); 76 | if ($ifModifiedSince !== NULL) { 77 | $lastModified = $this->response->getHeader('Last-Modified'); 78 | if ($lastModified != NULL && strtotime($lastModified) <= strtotime($ifModifiedSince)) { 79 | $match = TRUE; 80 | 81 | } else { 82 | return TRUE; 83 | } 84 | } 85 | 86 | if (empty($match)) { 87 | return TRUE; 88 | } 89 | 90 | $this->response->setCode(IResponse::S304_NOT_MODIFIED); 91 | return FALSE; 92 | } 93 | 94 | 95 | 96 | /** 97 | * @return IRequest 98 | */ 99 | public function getRequest() 100 | { 101 | return $this->request; 102 | } 103 | 104 | 105 | 106 | /** 107 | * @return IResponse 108 | */ 109 | public function getResponse() 110 | { 111 | return $this->response; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /libs/Nette/Http/ISessionStorage.php: -------------------------------------------------------------------------------- 1 | 22 | * http://nette.org/admin/script.php/pathinfo/?name=param#fragment 23 | * \_______________/\________/ 24 | * | | 25 | * scriptPath pathInfo 26 | * 27 | * 28 | * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index) 29 | * - pathInfo: /pathinfo/ (additional path information) 30 | * 31 | * @author David Grudl 32 | * 33 | * @property string $scriptPath 34 | * @property-read string $pathInfo 35 | */ 36 | class UrlScript extends Url 37 | { 38 | /** @var string */ 39 | private $scriptPath = '/'; 40 | 41 | 42 | 43 | /** 44 | * Sets the script-path part of URI. 45 | * @param string 46 | * @return UrlScript provides a fluent interface 47 | */ 48 | public function setScriptPath($value) 49 | { 50 | $this->updating(); 51 | $this->scriptPath = (string) $value; 52 | return $this; 53 | } 54 | 55 | 56 | 57 | /** 58 | * Returns the script-path part of URI. 59 | * @return string 60 | */ 61 | public function getScriptPath() 62 | { 63 | return $this->scriptPath; 64 | } 65 | 66 | 67 | 68 | /** 69 | * Returns the base-path. 70 | * @return string 71 | */ 72 | public function getBasePath() 73 | { 74 | $pos = strrpos($this->scriptPath, '/'); 75 | return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1); 76 | } 77 | 78 | 79 | 80 | /** 81 | * Returns the additional path information. 82 | * @return string 83 | */ 84 | public function getPathInfo() 85 | { 86 | return (string) substr($this->path, strlen($this->scriptPath)); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /libs/Nette/Iterators/Filter.php: -------------------------------------------------------------------------------- 1 | callback = $callback; 38 | } 39 | 40 | 41 | 42 | public function accept() 43 | { 44 | return call_user_func($this->callback, $this); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /libs/Nette/Iterators/InstanceFilter.php: -------------------------------------------------------------------------------- 1 | type = $type; 37 | parent::__construct($iterator); 38 | } 39 | 40 | 41 | 42 | /** 43 | * Expose the current element of the inner iterator? 44 | * @return bool 45 | */ 46 | public function accept() 47 | { 48 | return $this->current() instanceof $this->type; 49 | } 50 | 51 | 52 | 53 | /** 54 | * Returns the count of elements. 55 | * @return int 56 | */ 57 | public function count() 58 | { 59 | return iterator_count($this); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /libs/Nette/Iterators/Mapper.php: -------------------------------------------------------------------------------- 1 | callback = $callback; 38 | } 39 | 40 | 41 | 42 | public function current() 43 | { 44 | return call_user_func($this->callback, parent::current(), parent::key()); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /libs/Nette/Iterators/RecursiveFilter.php: -------------------------------------------------------------------------------- 1 | callback = $callback; 41 | $this->childrenCallback = $childrenCallback; 42 | } 43 | 44 | 45 | 46 | public function accept() 47 | { 48 | return $this->callback === NULL || call_user_func($this->callback, $this); 49 | } 50 | 51 | 52 | 53 | public function hasChildren() 54 | { 55 | return $this->getInnerIterator()->hasChildren() 56 | && ($this->childrenCallback === NULL || call_user_func($this->childrenCallback, $this)); 57 | } 58 | 59 | 60 | 61 | public function getChildren() 62 | { 63 | return new static($this->getInnerIterator()->getChildren(), $this->callback, $this->childrenCallback); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /libs/Nette/Iterators/Recursor.php: -------------------------------------------------------------------------------- 1 | current(); 33 | return ($obj instanceof \IteratorAggregate && $obj->getIterator() instanceof \RecursiveIterator) 34 | || $obj instanceof \RecursiveIterator; 35 | } 36 | 37 | 38 | 39 | /** 40 | * The sub-iterator for the current element. 41 | * @return \RecursiveIterator 42 | */ 43 | public function getChildren() 44 | { 45 | $obj = $this->current(); 46 | return $obj instanceof \IteratorAggregate ? $obj->getIterator() : $obj; 47 | } 48 | 49 | 50 | 51 | /** 52 | * Returns the count of elements. 53 | * @return int 54 | */ 55 | public function count() 56 | { 57 | return iterator_count($this); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /libs/Nette/Latte/Engine.php: -------------------------------------------------------------------------------- 1 | parser = new Parser; 33 | Macros\CoreMacros::install($this->parser); 34 | $this->parser->addMacro('cache', new Macros\CacheMacro($this->parser)); 35 | Macros\UIMacros::install($this->parser); 36 | Macros\FormMacros::install($this->parser); 37 | } 38 | 39 | 40 | 41 | /** 42 | * Invokes filter. 43 | * @param string 44 | * @return string 45 | */ 46 | public function __invoke($s) 47 | { 48 | $this->parser->setContext(Parser::CONTEXT_TEXT); 49 | $this->parser->setDelimiters('\\{(?![\\s\'"{}])', '\\}'); 50 | return $this->parser->parse($s); 51 | } 52 | 53 | 54 | 55 | /** 56 | * @return Parser 57 | */ 58 | public function getParser() 59 | { 60 | return $this->parser; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /libs/Nette/Latte/HtmlNode.php: -------------------------------------------------------------------------------- 1 | name = $name; 46 | $this->isEmpty = isset(Nette\Utils\Html::$emptyElements[strtolower($this->name)]); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /libs/Nette/Latte/IMacro.php: -------------------------------------------------------------------------------- 1 | macro = $macro; 63 | $this->name = (string) $name; 64 | $this->modifiers = (string) $modifiers; 65 | $this->parentNode = $parentNode; 66 | $this->tokenizer = new MacroTokenizer($this->args); 67 | $this->data = new \stdClass; 68 | $this->setArgs($args); 69 | } 70 | 71 | 72 | 73 | public function setArgs($args) 74 | { 75 | $this->args = (string) $args; 76 | $this->tokenizer->tokenize($this->args); 77 | } 78 | 79 | 80 | 81 | public function close($content) 82 | { 83 | $this->closing = TRUE; 84 | $this->content = $content; 85 | return $this->macro->nodeClosed($this); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /libs/Nette/Latte/MacroTokenizer.php: -------------------------------------------------------------------------------- 1 | '\s+', 41 | self::T_COMMENT => '(?s)/\*.*?\*/', 42 | self::T_STRING => Parser::RE_STRING, 43 | self::T_KEYWORD => '(?:true|false|null|and|or|xor|clone|new|instanceof|return|continue|break|[A-Z_][A-Z0-9_]{2,})(?![\w\pL_])', // keyword or const 44 | self::T_CAST => '\((?:expand|string|array|int|integer|float|bool|boolean|object)\)', // type casting 45 | self::T_VARIABLE => '\$[\w\pL_]+', 46 | self::T_NUMBER => '[+-]?[0-9]+(?:\.[0-9]+)?(?:e[0-9]+)?', 47 | self::T_SYMBOL => '[\w\pL_]+(?:-[\w\pL_]+)*', 48 | self::T_CHAR => '::|=>|[^"\']', // =>, any char except quotes 49 | ), 'u'); 50 | $this->ignored = array(self::T_COMMENT, self::T_WHITESPACE); 51 | $this->tokenize($input); 52 | } 53 | 54 | 55 | 56 | /** 57 | * Reads single token (optionally delimited by comma) from string. 58 | * @param string 59 | * @return string 60 | */ 61 | public function fetchWord() 62 | { 63 | $word = $this->fetchUntil(self::T_WHITESPACE, ','); 64 | $this->fetch(','); 65 | $this->fetchAll(self::T_WHITESPACE, self::T_COMMENT); 66 | return $word; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /libs/Nette/Latte/Macros/MacroSet.php: -------------------------------------------------------------------------------- 1 | parser = $parser; 38 | } 39 | 40 | 41 | 42 | public function addMacro($name, $begin, $end = NULL) 43 | { 44 | $this->macros[$name] = array($begin, $end); 45 | $this->parser->addMacro($name, $this); 46 | return $this; 47 | } 48 | 49 | 50 | 51 | public static function install(Latte\Parser $parser) 52 | { 53 | return new static($parser); 54 | } 55 | 56 | 57 | 58 | /** 59 | * Initializes before template parsing. 60 | * @return void 61 | */ 62 | public function initialize() 63 | { 64 | } 65 | 66 | 67 | 68 | /** 69 | * Finishes template parsing. 70 | * @return array(prolog, epilog) 71 | */ 72 | public function finalize() 73 | { 74 | } 75 | 76 | 77 | 78 | /** 79 | * New node is found. 80 | * @return bool|string 81 | */ 82 | public function nodeOpened(MacroNode $node) 83 | { 84 | $node->isEmpty = !isset($this->macros[$node->name][1]); 85 | return $this->compile($node, $this->macros[$node->name][0]); 86 | } 87 | 88 | 89 | 90 | /** 91 | * Node is closed. 92 | * @return string 93 | */ 94 | public function nodeClosed(MacroNode $node) 95 | { 96 | return $this->compile($node, $this->macros[$node->name][1]); 97 | } 98 | 99 | 100 | 101 | /** 102 | * Generates code. 103 | * @return string 104 | */ 105 | private function compile(MacroNode $node, $def) 106 | { 107 | $node->tokenizer->reset(); 108 | $writer = Latte\PhpWriter::using($node, $this->parser->getContext()); 109 | if (is_string($def)) { 110 | $code = $writer->write($def); 111 | } else { 112 | $code = callback($def)->invoke($node, $writer); 113 | if ($code === FALSE) { 114 | return FALSE; 115 | } 116 | } 117 | return ""; 118 | } 119 | 120 | 121 | 122 | /** 123 | * @return Latte\Parser 124 | */ 125 | public function getParser() 126 | { 127 | return $this->parser; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /libs/Nette/Latte/ParseException.php: -------------------------------------------------------------------------------- 1 | setHeader('Subject', NULL); 39 | $tmp->setHeader('To', NULL); 40 | 41 | $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2); 42 | 43 | Nette\Diagnostics\Debugger::tryError(); 44 | $args = array( 45 | str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), 46 | str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), 47 | str_replace(Message::EOL, PHP_EOL, $parts[1]), 48 | str_replace(Message::EOL, PHP_EOL, $parts[0]), 49 | ); 50 | if ($this->commandArgs) { 51 | $args[] = (string) $this->commandArgs; 52 | } 53 | $res = call_user_func_array('mail', $args); 54 | 55 | if (Nette\Diagnostics\Debugger::catchError($e)) { 56 | throw new Nette\InvalidStateException('mail(): ' . $e->getMessage(), 0, $e); 57 | 58 | } elseif (!$res) { 59 | throw new Nette\InvalidStateException('Unable to send email.'); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /libs/Nette/Reflection/Annotation.php: -------------------------------------------------------------------------------- 1 | $v) { 29 | $this->$k = $v; 30 | } 31 | } 32 | 33 | 34 | 35 | /** 36 | * Returns default annotation. 37 | * @return string 38 | */ 39 | public function __toString() 40 | { 41 | return $this->value; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /libs/Nette/Reflection/Extension.php: -------------------------------------------------------------------------------- 1 | getName(); 30 | } 31 | 32 | 33 | 34 | /********************* Reflection layer ****************d*g**/ 35 | 36 | 37 | 38 | public function getClasses() 39 | { 40 | $res = array(); 41 | foreach (parent::getClassNames() as $val) { 42 | $res[$val] = new ClassType($val); 43 | } 44 | return $res; 45 | } 46 | 47 | 48 | 49 | public function getFunctions() 50 | { 51 | foreach ($res = parent::getFunctions() as $key => $val) { 52 | $res[$key] = new GlobalFunction($key); 53 | } 54 | return $res; 55 | } 56 | 57 | 58 | 59 | /********************* Nette\Object behaviour ****************d*g**/ 60 | 61 | 62 | 63 | /** 64 | * @return ClassType 65 | */ 66 | public static function getReflection() 67 | { 68 | return new ClassType(get_called_class()); 69 | } 70 | 71 | 72 | 73 | public function __call($name, $args) 74 | { 75 | return ObjectMixin::call($this, $name, $args); 76 | } 77 | 78 | 79 | 80 | public function &__get($name) 81 | { 82 | return ObjectMixin::get($this, $name); 83 | } 84 | 85 | 86 | 87 | public function __set($name, $value) 88 | { 89 | return ObjectMixin::set($this, $name, $value); 90 | } 91 | 92 | 93 | 94 | public function __isset($name) 95 | { 96 | return ObjectMixin::has($this, $name); 97 | } 98 | 99 | 100 | 101 | public function __unset($name) 102 | { 103 | ObjectMixin::remove($this, $name); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /libs/Nette/Reflection/IAnnotation.php: -------------------------------------------------------------------------------- 1 | password 31 | */ 32 | public function __construct(array $userlist) 33 | { 34 | $this->userlist = $userlist; 35 | } 36 | 37 | 38 | 39 | /** 40 | * Performs an authentication against e.g. database. 41 | * and returns IIdentity on success or throws AuthenticationException 42 | * @param array 43 | * @return IIdentity 44 | * @throws AuthenticationException 45 | */ 46 | public function authenticate(array $credentials) 47 | { 48 | list($username, $password) = $credentials; 49 | foreach ($this->userlist as $name => $pass) { 50 | if (strcasecmp($name, $username) === 0) { 51 | if ((string) $pass === (string) $password) { 52 | return new Identity($name); 53 | } else { 54 | throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL); 55 | } 56 | } 57 | } 58 | throw new AuthenticationException("User '$username' not found.", self::IDENTITY_NOT_FOUND); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /libs/Nette/Templating/FilterException.php: -------------------------------------------------------------------------------- 1 | sourceLine = (int) $sourceLine; 36 | parent::__construct($message, $code); 37 | } 38 | 39 | 40 | 41 | public function setSourceFile($file) 42 | { 43 | $this->sourceFile = (string) $file; 44 | $this->message = rtrim($this->message, '.') . " in " . str_replace(dirname(dirname($file)), '...', $file) 45 | . ($this->sourceLine ? ":$this->sourceLine" : ''); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /libs/Nette/Templating/IFileTemplate.php: -------------------------------------------------------------------------------- 1 | 'The maximum stack depth has been exceeded', 30 | JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON', 31 | JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', 32 | JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', 33 | ); 34 | 35 | 36 | 37 | /** 38 | * Static class - cannot be instantiated. 39 | */ 40 | final public function __construct() 41 | { 42 | throw new Nette\StaticClassException; 43 | } 44 | 45 | 46 | 47 | /** 48 | * Returns the JSON representation of a value. 49 | * @param mixed 50 | * @return string 51 | */ 52 | public static function encode($value) 53 | { 54 | Nette\Diagnostics\Debugger::tryError(); 55 | if (function_exists('ini_set')) { 56 | $old = ini_set('display_errors', 0); // needed to receive 'Invalid UTF-8 sequence' error 57 | $json = json_encode($value); 58 | ini_set('display_errors', $old); 59 | } else { 60 | $json = json_encode($value); 61 | } 62 | if (Nette\Diagnostics\Debugger::catchError($e)) { // needed to receive 'recursion detected' error 63 | throw new JsonException($e->getMessage()); 64 | } 65 | return $json; 66 | } 67 | 68 | 69 | 70 | /** 71 | * Decodes a JSON string. 72 | * @param string 73 | * @param int 74 | * @return mixed 75 | */ 76 | public static function decode($json, $options = 0) 77 | { 78 | $json = (string) $json; 79 | $value = json_decode($json, (bool) ($options & self::FORCE_ARRAY)); 80 | if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' do not clean json_last_error 81 | $error = PHP_VERSION_ID >= 50300 ? json_last_error() : 0; 82 | throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); 83 | } 84 | return $value; 85 | } 86 | 87 | } 88 | 89 | 90 | 91 | /** 92 | * The exception that indicates error of JSON encoding/decoding. 93 | */ 94 | class JsonException extends \Exception 95 | { 96 | } 97 | -------------------------------------------------------------------------------- /libs/Nette/Utils/LimitedScope.php: -------------------------------------------------------------------------------- 1 | 1) { 46 | self::$vars = func_get_arg(1); 47 | extract(self::$vars); 48 | } 49 | $res = eval('?>' . func_get_arg(0)); 50 | if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) { 51 | throw new Nette\FatalErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'], NULL); 52 | } 53 | return $res; 54 | } 55 | 56 | 57 | 58 | /** 59 | * Includes script in a limited scope. 60 | * @param string file to include 61 | * @param array local variables or TRUE meaning include once 62 | * @return mixed the return value of the included file 63 | */ 64 | public static function load(/*$file, array $vars = NULL*/) 65 | { 66 | if (func_num_args() > 1) { 67 | self::$vars = func_get_arg(1); 68 | if (self::$vars === TRUE) { 69 | return include_once func_get_arg(0); 70 | } 71 | extract(self::$vars); 72 | } 73 | return include func_get_arg(0); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /libs/Nette/Utils/MimeTypeDetector.php: -------------------------------------------------------------------------------- 1 | value = (string) $value; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /libs/Nette/Utils/PhpGenerator/Property.php: -------------------------------------------------------------------------------- 1 | $value) { 35 | if ($recursive && is_array($value)) { 36 | $obj->$key = static::from($value, TRUE); 37 | } else { 38 | $obj->$key = $value; 39 | } 40 | } 41 | return $obj; 42 | } 43 | 44 | 45 | 46 | /** 47 | * Returns an iterator over all items. 48 | * @return \RecursiveArrayIterator 49 | */ 50 | public function getIterator() 51 | { 52 | return new \RecursiveArrayIterator($this); 53 | } 54 | 55 | 56 | 57 | /** 58 | * Returns items count. 59 | * @return int 60 | */ 61 | public function count() 62 | { 63 | return count((array) $this); 64 | } 65 | 66 | 67 | 68 | /** 69 | * Replaces or appends a item. 70 | * @param mixed 71 | * @param mixed 72 | * @return void 73 | */ 74 | public function offsetSet($key, $value) 75 | { 76 | if (!is_scalar($key)) { // prevents NULL 77 | throw new InvalidArgumentException("Key must be either a string or an integer, " . gettype($key) ." given."); 78 | } 79 | $this->$key = $value; 80 | } 81 | 82 | 83 | 84 | /** 85 | * Returns a item. 86 | * @param mixed 87 | * @return mixed 88 | */ 89 | public function offsetGet($key) 90 | { 91 | return $this->$key; 92 | } 93 | 94 | 95 | 96 | /** 97 | * Determines whether a item exists. 98 | * @param mixed 99 | * @return bool 100 | */ 101 | public function offsetExists($key) 102 | { 103 | return isset($this->$key); 104 | } 105 | 106 | 107 | 108 | /** 109 | * Removes the element from this list. 110 | * @param mixed 111 | * @return void 112 | */ 113 | public function offsetUnset($key) 114 | { 115 | unset($this->$key); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /libs/Nette/common/ArrayList.php: -------------------------------------------------------------------------------- 1 | list); 38 | } 39 | 40 | 41 | 42 | /** 43 | * Returns items count. 44 | * @return int 45 | */ 46 | public function count() 47 | { 48 | return count($this->list); 49 | } 50 | 51 | 52 | 53 | /** 54 | * Replaces or appends a item. 55 | * @param int 56 | * @param mixed 57 | * @return void 58 | * @throws OutOfRangeException 59 | */ 60 | public function offsetSet($index, $value) 61 | { 62 | if ($index === NULL) { 63 | $this->list[] = $value; 64 | 65 | } elseif ($index < 0 || $index >= count($this->list)) { 66 | throw new OutOfRangeException("Offset invalid or out of range"); 67 | 68 | } else { 69 | $this->list[(int) $index] = $value; 70 | } 71 | } 72 | 73 | 74 | 75 | /** 76 | * Returns a item. 77 | * @param int 78 | * @return mixed 79 | * @throws OutOfRangeException 80 | */ 81 | public function offsetGet($index) 82 | { 83 | if ($index < 0 || $index >= count($this->list)) { 84 | throw new OutOfRangeException("Offset invalid or out of range"); 85 | } 86 | return $this->list[(int) $index]; 87 | } 88 | 89 | 90 | 91 | /** 92 | * Determines whether a item exists. 93 | * @param int 94 | * @return bool 95 | */ 96 | public function offsetExists($index) 97 | { 98 | return $index >= 0 && $index < count($this->list); 99 | } 100 | 101 | 102 | 103 | /** 104 | * Removes the element at the specified position in this list. 105 | * @param int 106 | * @return void 107 | * @throws OutOfRangeException 108 | */ 109 | public function offsetUnset($index) 110 | { 111 | if ($index < 0 || $index >= count($this->list)) { 112 | throw new OutOfRangeException("Offset invalid or out of range"); 113 | } 114 | array_splice($this->list, (int) $index, 1); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /libs/Nette/common/DateTime.php: -------------------------------------------------------------------------------- 1 | frozen = TRUE; 39 | } 40 | 41 | 42 | 43 | /** 44 | * Is the object unmodifiable? 45 | * @return bool 46 | */ 47 | final public function isFrozen() 48 | { 49 | return $this->frozen; 50 | } 51 | 52 | 53 | 54 | /** 55 | * Creates a modifiable clone of the object. 56 | * @return void 57 | */ 58 | public function __clone() 59 | { 60 | $this->frozen = FALSE; 61 | } 62 | 63 | 64 | 65 | /** 66 | * @return void 67 | */ 68 | protected function updating() 69 | { 70 | if ($this->frozen) { 71 | $class = get_class($this); 72 | throw new InvalidStateException("Cannot modify a frozen object $class."); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /libs/Nette/common/IFreezable.php: -------------------------------------------------------------------------------- 1 | register(); 44 | 45 | require_once __DIR__ . '/Diagnostics/Helpers.php'; 46 | require_once __DIR__ . '/Utils/Html.php'; 47 | Nette\Diagnostics\Debugger::_init(); 48 | 49 | Nette\Utils\SafeStream::register(); 50 | 51 | 52 | 53 | /** 54 | * Nette\Callback factory. 55 | * @param mixed class, object, function, callback 56 | * @param string method 57 | * @return Nette\Callback 58 | */ 59 | function callback($callback, $m = NULL) 60 | { 61 | return ($m === NULL && $callback instanceof Nette\Callback) ? $callback : new Nette\Callback($callback, $m); 62 | } 63 | 64 | 65 | 66 | /** 67 | * Nette\Diagnostics\Debugger::dump shortcut. 68 | */ 69 | function dump($var) 70 | { 71 | foreach (func_get_args() as $arg) Nette\Diagnostics\Debugger::dump($arg); 72 | return $var; 73 | } 74 | -------------------------------------------------------------------------------- /libs/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /log/.gitignore: -------------------------------------------------------------------------------- 1 | *.* 2 | !.gitignore 3 | !.htaccess 4 | !web.config 5 | -------------------------------------------------------------------------------- /log/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Deny from all -------------------------------------------------------------------------------- /log/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /temp/.gitignore: -------------------------------------------------------------------------------- 1 | *.* 2 | !.gitignore 3 | !.htaccess 4 | !web.config 5 | -------------------------------------------------------------------------------- /temp/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Deny from all -------------------------------------------------------------------------------- /temp/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/.htaccess: -------------------------------------------------------------------------------- 1 | # Apache configuration file (see httpd.apache.org/docs/2.2/mod/quickreference.html) 2 | 3 | # disable directory listing 4 | Options -Indexes 5 | 6 | # enable cool URL 7 | 8 | RewriteEngine On 9 | # RewriteBase / 10 | 11 | # front controller 12 | RewriteCond %{REQUEST_FILENAME} !-f 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L] 15 | 16 | 17 | # enable gzip compression 18 | 19 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json 20 | 21 | 22 | # allow combined JavaScript & CSS. Inside of script.combined.js you could use 23 | 24 | 25 | Options +Includes 26 | SetOutputFilter INCLUDES 27 | 28 | 29 | -------------------------------------------------------------------------------- /www/css/mixins.less: -------------------------------------------------------------------------------- 1 | 2 | .gradient (@startColor: #555, @endColor: #333) { 3 | background-color: @endColor; 4 | background-repeat: repeat-x; 5 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); 6 | background-image: -webkit-linear-gradient(top, @startColor, @endColor); 7 | background-image: -moz-linear-gradient(top, @startColor, @endColor); 8 | background-image: -o-linear-gradient(top, @startColor, @endColor); 9 | background-image: -ms-linear-gradient(top, @startColor, @endColor); 10 | background-image: linear-gradient(top, @startColor, @endColor); 11 | } 12 | 13 | .border-radius(@radius: 5px) { 14 | -webkit-border-radius: @radius; 15 | -moz-border-radius: @radius; 16 | border-radius: @radius; 17 | } 18 | 19 | .box-shadow(@shadow) { 20 | -webkit-box-shadow: @shadow; 21 | -moz-box-shadow: @shadow; 22 | box-shadow: @shadow; 23 | } -------------------------------------------------------------------------------- /www/css/print.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 12pt/1.4 "Trebuchet MS", "Geneva CE", lucida, sans-serif; 3 | color: black; 4 | background: none; 5 | width: 100%; 6 | } 7 | 8 | a img { border: none; } 9 | 10 | #ajax-spinner { 11 | display: none; 12 | } 13 | -------------------------------------------------------------------------------- /www/css/screen.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 16px/1.5 "Trebuchet MS", "Geneva CE", lucida, sans-serif; 3 | color: #333; 4 | background-color: #fff; 5 | } 6 | 7 | h1 { 8 | font-size: 150%; 9 | color: #3484D2; 10 | } 11 | 12 | #ajax-spinner { 13 | margin: 15px 0 0 15px; 14 | padding: 13px; 15 | background: white url('../images/spinner.gif') no-repeat 50% 50%; 16 | font-size: 0; 17 | z-index: 123456; 18 | display: none; 19 | } 20 | 21 | div.flash { 22 | color: black; 23 | background: #FFF9D7; 24 | border: 1px solid #E2C822; 25 | padding: 1em; 26 | margin: 1em 0; 27 | } 28 | 29 | a[href^="error:"] { 30 | background: red; 31 | color: white; 32 | } 33 | -------------------------------------------------------------------------------- /www/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/www/favicon.ico -------------------------------------------------------------------------------- /www/images/nette-powered1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/www/images/nette-powered1.gif -------------------------------------------------------------------------------- /www/images/nette-powered2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/www/images/nette-powered2.gif -------------------------------------------------------------------------------- /www/images/nette-powered3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/www/images/nette-powered3.gif -------------------------------------------------------------------------------- /www/images/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsmitka/nette-quickstart/801dd87980316fc696769ce50d8212caac57ddf3/www/images/spinner.gif -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | --------------------------------------------------------------------------------