} }); $app->post('/modify/:id', function ($id) use($app) { session_start(); $description = $app->request->post('description'); if (isset($_SESSION['fileId']) && array_key_exists("{$id}", $_SESSION['fileId'])) { $app->FileGateway->changeDescription($id, $description); $app->flash('success', 'Описание файла успешно обновлено'); } $app->response->redirect("/f/{$id}", 303); }); $app->get('/search(/:page)', function ($page = 1) use($app) { $queryString = $app->request->get('string'); $searchHandler = new SearchController($app->SearchGateway, $app->config('filesPerPage')); $totalFilesNum = $searchHandler->countResults($queryString); $files = $searchHandler->find($queryString, $page); $last = $searchHandler->countPages(); $message = $searchHandler->getHeaderString($queryString); $app->render('searchResults.phtml', array('files' => $files, 'title' => "Результаты поиска", 'message' => $message, 'query' => $queryString, 'curPage' => $page, 'last' => $last, 'query' => $queryString)); }); $app->post('/comment/async', function () use($app) { $commentHandler = new CommentsController($app->CommentGateway, $app->request->post()); $result = $commentHandler->addComment(true); if (is_array($result)) { list($comment, $relativesNum) = $result; } else { $comment = $result; $relativesNum = null; } if (!$comment) { header("Content-Type: application/json");