Inheritance: extends AppController
Exemple #1
0
 public function view($id)
 {
     $this->Book->recursive = 1;
     // Si le livre recherché n'existe pas
     if (!($book = $this->Book->findById($id))) {
         $this->Session->setFlash(__('Le livre que vous recherchez n\'existe pas.'), 'admin_error');
         $this->redirect($this->referer());
     }
     // Partie pour récupérer la note moyenne du livre afin d'afficher les étoiles
     $starNumber = 0;
     foreach ($book['Comment'] as $k => $v) {
         $starNumber += $v['rating'];
     }
     if (count($book['Comment']) != 0) {
         $starNumber = $starNumber / count($book['Comment']);
     } else {
         $starNumber = 0;
     }
     $this->set('starNumber', $starNumber);
     $Comment = new CommentsController();
     // On instancie l'objet CommentsController
     $book = $Comment->view($id);
     // On appel la fonction souhaité
     $this->set('book', $book);
 }
Exemple #2
0
 function showBook()
 {
     $model = new Books();
     $comment_section = new CommentsController();
     $data = $model->getBookData();
     include 'view/libro/libro.php';
     $comment_section->showComments();
 }
 public function render($action = null, $layout = null, $file = null)
 {
     if (!$this->testView) {
         $this->renderedAction = $action;
     } else {
         return parent::render($action, $layout, $file);
     }
 }
Exemple #4
0
        $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");
        echo json_encode(array('ok' => false));
        exit;
    } else {
        $html = $app->view->fetch('comment.phtml', array('comment' => $comment));
        header("Content-Type: application/json");
        echo json_encode(array('ok' => true, 'relativesNum' => $relativesNum, 'parentId' => $comment->parentId, 'html' => $html, 'id' => $comment->id));
Exemple #5
0
 public function submitComment()
 {
     $controller = new CommentsController();
     $controller->submitComment();
 }
Exemple #6
0
 /**
  * Proxy for getModel.
  */
 public function &getModel($name = 'Thread', $prefix = 'CommentsModel')
 {
     return parent::getModel($name, $prefix, array('ignore_request' => true));
 }
Exemple #7
0
<?php

class CommentsController extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->setModel('Comments');
    }
}
$controller = new CommentsController();
$controller->view(ADMIN_TPLS_DIR . '/header.tpl');
$controller->view(ADMIN_TPLS_DIR . '/comments.tpl');
$controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
Exemple #8
0
Route::post('login', array('uses' => 'HomeController@doLogin'));
// logout
Route::get('logout', array('uses' => 'HomeController@doLogout'));
*/
Route::get('/users', function () {
    return View::make('users');
});
Route::post('users_action', function () {
    $obj = new UsersController();
    return $obj->store();
});
Route::get('/comments', function () {
    return View::make('comments');
});
Route::post('comments_action', function () {
    $obj = new CommentsController();
    return $obj->store();
});
Route::get('/supports', function () {
    return View::make('supports');
});
Route::post('supports_action', function () {
    $obj = new SupportsController();
    return $obj->store();
});
Route::get('/notes', function () {
    return View::make('notes');
});
Route::post('notes_action', function () {
    $obj = new NotesController();
    return $obj->store();