コード例 #1
0
ファイル: CommentController.php プロジェクト: weleoka/comment
 /**
  * Remove all comments.
  *
  * @return void
  */
 public function removeAllAction()
 {
     $isPosted = $this->request->getPost('doRemoveAll');
     if (!$isPosted) {
         $this->response->redirect($this->request->getPost('redirect'));
     }
     $comments = new \Phpmvc\Comment\CommentsInSession();
     $comments->setDI($this->di);
     $comments->deleteAll();
     $this->response->redirect($this->request->getPost('redirect'));
 }
コード例 #2
0
 /**
  * Updates a comment.
  *
  * @param id of comment to save.
  *
  * @return void
  */
 public function updateAction($id)
 {
     $isPosted = $this->request->getPost('doUpdate');
     $key = $this->request->getPost('key');
     if (!$isPosted) {
         $this->response->redirect($this->request->getPost('redirect'));
     }
     $comment = ['content' => $this->request->getPost('content'), 'name' => $this->request->getPost('name'), 'web' => $this->request->getPost('web'), 'mail' => $this->request->getPost('mail'), 'timestamp' => time(), 'ip' => $this->request->getServer('REMOTE_ADDR')];
     $comments = new \Phpmvc\Comment\CommentsInSession($key);
     $comments->setDI($this->di);
     $comments->update($id, $key, $comment);
     $this->response->redirect($this->request->getPost('redirect'));
 }
コード例 #3
0
ファイル: index - old.php プロジェクト: Kajja/phpmvc
<?php

// Bootstrapping (i.e. configurations, create framework object etc.)
require __DIR__ . '/config_with_app.php';
// Creating a controller service for comments
$di->set('CommentController', function () use($di) {
    $controller = new Phpmvc\Comment\CommentController();
    $controller->setDI($di);
    return $controller;
});
// Creating a model service for comments
$di->set('comments', function () use($di) {
    $comments = new \Phpmvc\Comment\CommentsInSession();
    $comments->setDI($di);
    $comments->setContext($di->request->getCurrentUrl());
    return $comments;
});
// Defining routes
$app->router->add('', function () use($app) {
    $app->theme->setTitle('Lite om mig');
    $app->views->add('me/page', ['content' => $app->textFilter->doFilter($app->fileContent->get('about.md'), 'shortcode, markdown'), 'byline' => $app->textFilter->doFilter($app->fileContent->get('byline.md'), 'shortcode, markdown')]);
    // Adds the possibility to post comments on the page
    \mife\Comment\CommentSetup::initComments($app);
});
$app->router->add('redovisning/kmom1', function () use($app) {
    $app->theme->setTitle('Redovisning');
    $app->views->add('me/page', ['content' => $app->textFilter->doFilter($app->fileContent->get('kmom1.md'), 'shortcode, markdown'), 'byline' => $app->textFilter->doFilter($app->fileContent->get('byline.md'), 'shortcode, markdown')]);
    // Adds the possibility to post comments on the page
    \mife\Comment\CommentSetup::initComments($app);
});
$app->router->add('redovisning/kmom2', function () use($app) {
コード例 #4
0
ファイル: page-with-comments.php プロジェクト: Kajja/phpmvc
/**
 * This is a Anax pagecontroller.
 *
 */
// Include the essential settings.
require __DIR__ . '/config.php';
// Create services and inject into the app.
$di = new \Anax\DI\CDIFactoryDefault();
$di->set('CommentController', function () use($di) {
    $controller = new Phpmvc\Comment\CommentController();
    $controller->setDI($di);
    return $controller;
});
$di->set('comments', function () use($di) {
    $comments = new \Phpmvc\Comment\CommentsInSession();
    $comments->setDI($di);
    $comments->setContext($di->url->create(''));
    return $comments;
});
//Test
echo 'BaseUrl: ' . $di->request->getBaseUrl() . '<br>';
echo 'SiteUrl: ' . $di->request->getSiteUrl() . '<br>';
echo 'Route: ' . $di->request->getRoute() . '<br>';
echo 'CurrentUrl: ' . $di->request->getCurrentUrl() . '<br>';
echo 'Url-asset: ' . $di->url->asset('kommentarssida') . '<br>';
echo 'Url-create: ' . $di->url->create('');
$app = new \Anax\Kernel\CAnax($di);
// Home route
$app->router->add('', function () use($app) {
    $app->theme->setTitle("Welcome to Anax Guestbook");