@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | "services" => [ |
| 7 | 7 | "router" => [ |
| 8 | 8 | "shared" => true, |
| 9 | - "callback" => function () { |
|
| 9 | + "callback" => function() { |
|
| 10 | 10 | $router = new \Anax\Route\Router(); |
| 11 | 11 | $router->setDI($this); |
| 12 | 12 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $config = $cfg->load("router"); |
| 16 | 16 | |
| 17 | 17 | // Set DEVELOPMENT/PRODUCTION mode, if defined |
| 18 | - $mode = $config["config"]["mode"] ?? null; |
|
| 18 | + $mode = $config[ "config" ][ "mode" ] ?? null; |
|
| 19 | 19 | if (isset($mode)) { |
| 20 | 20 | $router->setMode($mode); |
| 21 | 21 | } else if (defined("ANAX_PRODUCTION")) { |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | // Add routes from configuration file |
| 26 | 26 | $file = null; |
| 27 | 27 | try { |
| 28 | - $file = $config["file"] ?? null; |
|
| 29 | - $router->addRoutes($config["config"] ?? []); |
|
| 30 | - foreach ($config["items"] ?? [] as $routes) { |
|
| 31 | - $file = $routes["file"]; |
|
| 32 | - $router->addRoutes($routes["config"]); |
|
| 28 | + $file = $config[ "file" ] ?? null; |
|
| 29 | + $router->addRoutes($config[ "config" ] ?? [ ]); |
|
| 30 | + foreach ($config[ "items" ] ?? [ ] as $routes) { |
|
| 31 | + $file = $routes[ "file" ]; |
|
| 32 | + $router->addRoutes($routes[ "config" ]); |
|
| 33 | 33 | } |
| 34 | 34 | } catch (Exception $e) { |
| 35 | 35 | throw new Exception( |
@@ -16,22 +16,22 @@ discard block |
||
| 16 | 16 | [ |
| 17 | 17 | "info" => "Just say hi with a string.", |
| 18 | 18 | "path" => "hi", |
| 19 | - "handler" => function () { |
|
| 19 | + "handler" => function() { |
|
| 20 | 20 | return "Hi."; |
| 21 | 21 | }, |
| 22 | 22 | ], |
| 23 | 23 | [ |
| 24 | 24 | "info" => "Say No! with status code 500.", |
| 25 | 25 | "path" => "no", |
| 26 | - "handler" => function () { |
|
| 27 | - return ["No!", 500]; |
|
| 26 | + "handler" => function() { |
|
| 27 | + return [ "No!", 500 ]; |
|
| 28 | 28 | }, |
| 29 | 29 | ], |
| 30 | 30 | [ |
| 31 | 31 | "info" => "Say Hi through JSON.", |
| 32 | 32 | "path" => "json", |
| 33 | - "handler" => function () { |
|
| 34 | - return [["message" => "Hi JSON"]]; |
|
| 33 | + "handler" => function() { |
|
| 34 | + return [ [ "message" => "Hi JSON" ] ]; |
|
| 35 | 35 | }, |
| 36 | 36 | ], |
| 37 | 37 | [ |
@@ -47,28 +47,28 @@ discard block |
||
| 47 | 47 | [ |
| 48 | 48 | "info" => "Throw standard exception.", |
| 49 | 49 | "path" => "exception", |
| 50 | - "handler" => function () { |
|
| 50 | + "handler" => function() { |
|
| 51 | 51 | throw new \Exception("Standard \Exception"); |
| 52 | 52 | }, |
| 53 | 53 | ], |
| 54 | 54 | [ |
| 55 | 55 | "info" => "Try internal 403.", |
| 56 | 56 | "path" => "403", |
| 57 | - "handler" => function () { |
|
| 57 | + "handler" => function() { |
|
| 58 | 58 | throw new ForbiddenException("Detailed error message."); |
| 59 | 59 | }, |
| 60 | 60 | ], |
| 61 | 61 | [ |
| 62 | 62 | "info" => "Try internal 404.", |
| 63 | 63 | "path" => "404", |
| 64 | - "handler" => function () { |
|
| 64 | + "handler" => function() { |
|
| 65 | 65 | throw new NotFoundException("Detailed error message."); |
| 66 | 66 | }, |
| 67 | 67 | ], |
| 68 | 68 | [ |
| 69 | 69 | "info" => "Try internal 500.", |
| 70 | 70 | "path" => "500", |
| 71 | - "handler" => function () { |
|
| 71 | + "handler" => function() { |
|
| 72 | 72 | throw new InternalErrorException("Detailed error message."); |
| 73 | 73 | }, |
| 74 | 74 | ], |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | <pre><?= var_dump($session) ?></pre> |
| 22 | 22 | |
| 23 | 23 | <p> |
| 24 | - <a href="<?= url($mount."session") ?>">Back to session<a> |
|
| 24 | + <a href="<?= url($mount . "session") ?>">Back to session<a> |
|
| 25 | 25 | </p> |
@@ -21,33 +21,42 @@ |
||
| 21 | 21 | <h3>Questions asked: </h3> |
| 22 | 22 | <?php if (empty($questions)) : ?> |
| 23 | 23 | <p>This user hasen't posted any questions yet.</p> |
| 24 | -<?php else : ?> |
|
| 24 | +<?php else { |
|
| 25 | + : ?> |
|
| 25 | 26 | <?php foreach ($questions as $question) : ?> |
| 26 | 27 | <p> |
| 27 | 28 | <a href="../../forum/question/<?= $question->id ?>"><?= $question->title ?></a> |
| 28 | 29 | </p> |
| 29 | - <?php endforeach; ?> |
|
| 30 | + <?php endforeach; |
|
| 31 | +} |
|
| 32 | +?> |
|
| 30 | 33 | <?php endif; ?> |
| 31 | 34 | <h3>Answers posted: </h3> |
| 32 | 35 | <?php if (empty($answers)) : ?> |
| 33 | 36 | <p>This user hasn't posted any answers yet.</p> |
| 34 | -<?php else: ?> |
|
| 37 | +<?php else { |
|
| 38 | + : ?> |
|
| 35 | 39 | <?php foreach ($answers as $answer) : ?> |
| 36 | 40 | <p> |
| 37 | 41 | <a href="../../forum/question/<?= $answer->question_id ?>"><?= $answer->content ?></a> |
| 38 | 42 | </p> |
| 39 | - <?php endforeach; ?> |
|
| 43 | + <?php endforeach; |
|
| 44 | +} |
|
| 45 | +?> |
|
| 40 | 46 | <?php endif; ?> |
| 41 | 47 | <?php if (empty($comments)) : ?> |
| 42 | 48 | <h3>Comments this user have posted: </h3> |
| 43 | 49 | <p>This user have not posted any comments yet.</p> |
| 44 | -<?php else : ?> |
|
| 50 | +<?php else { |
|
| 51 | + : ?> |
|
| 45 | 52 | <h3>Comments you have posted: </h3> |
| 46 | 53 | <?php foreach ($comments as $comment) : ?> |
| 47 | 54 | <p> |
| 48 | 55 | <a href="../../forum/question/<?= $answer->question_id ?>"><?= $comment->content ?></a> |
| 49 | 56 | </p> |
| 50 | - <?php endforeach; ?> |
|
| 57 | + <?php endforeach; |
|
| 58 | +} |
|
| 59 | +?> |
|
| 51 | 60 | <?php endif; ?> |
| 52 | 61 | <h3>Comments on answers you have posted: </h3> |
| 53 | 62 | <?php foreach ($anscomments as $anscomment) : ?> |
@@ -26,40 +26,52 @@ |
||
| 26 | 26 | <h3>Questions you have asked: </h3> |
| 27 | 27 | <?php if (empty($posts)) : ?> |
| 28 | 28 | <p>You have not made any posts yet.</p> |
| 29 | -<?php else : ?> |
|
| 29 | +<?php else { |
|
| 30 | + : ?> |
|
| 30 | 31 | <?php foreach ($posts as $post) : ?> |
| 31 | 32 | <p> |
| 32 | 33 | <a href="forum/question/<?= $post->id ?>"><?= $post->title ?></a> |
| 33 | 34 | </p> |
| 34 | - <?php endforeach; ?> |
|
| 35 | + <?php endforeach; |
|
| 36 | +} |
|
| 37 | +?> |
|
| 35 | 38 | <?php endif; ?> |
| 36 | 39 | <h3>Answers you have posted: </h3> |
| 37 | 40 | <?php if (empty($answers)) : ?> |
| 38 | 41 | <p>You have not posted any answers yet.</p> |
| 39 | -<?php else : ?> |
|
| 42 | +<?php else { |
|
| 43 | + : ?> |
|
| 40 | 44 | <?php foreach ($answers as $answer) : ?> |
| 41 | 45 | <p> |
| 42 | 46 | <a href="forum/question/<?= $answer->question_id ?>"><?= $answer->content ?></a> |
| 43 | 47 | </p> |
| 44 | - <?php endforeach; ?> |
|
| 48 | + <?php endforeach; |
|
| 49 | +} |
|
| 50 | +?> |
|
| 45 | 51 | <?php endif; ?> |
| 46 | 52 | <h3>Comments you have posted: </h3> |
| 47 | 53 | <?php if (empty($comments)) : ?> |
| 48 | 54 | <p>You have not posted any comments yet.</p> |
| 49 | -<?php else : ?> |
|
| 55 | +<?php else { |
|
| 56 | + : ?> |
|
| 50 | 57 | <?php foreach ($comments as $comment) : ?> |
| 51 | 58 | <p> |
| 52 | 59 | <a href="forum/question/<?= $answer->question_id ?>"><?= $comment->content ?></a> |
| 53 | 60 | </p> |
| 54 | - <?php endforeach; ?> |
|
| 61 | + <?php endforeach; |
|
| 62 | +} |
|
| 63 | +?> |
|
| 55 | 64 | <?php endif; ?> |
| 56 | 65 | <h3>Comments on answers you have posted: </h3> |
| 57 | 66 | <?php if (empty($anscomments)) : ?> |
| 58 | 67 | <p>You have not made any comments on answers yet.</p> |
| 59 | -<?php else : ?> |
|
| 68 | +<?php else { |
|
| 69 | + : ?> |
|
| 60 | 70 | <?php foreach ($anscomments as $anscomment) : ?> |
| 61 | 71 | <p> |
| 62 | 72 | <a href="forum/question/<?= $answer->question_id ?>"><?= $anscomment->content ?></a> |
| 63 | 73 | </p> |
| 64 | - <?php endforeach; ?> |
|
| 74 | + <?php endforeach; |
|
| 75 | +} |
|
| 76 | +?> |
|
| 65 | 77 | <?php endif; ?> |
@@ -40,9 +40,12 @@ |
||
| 40 | 40 | <p> |
| 41 | 41 | <a href="../answer/<?= $item->id ?>">Answer this post</a> |
| 42 | 42 | </p> |
| 43 | - <?php else : ?> |
|
| 43 | + <?php else { |
|
| 44 | + : ?> |
|
| 44 | 45 | <p>You have to be logged in to answer on a post!</p> |
| 45 | - <?php endif; ?> |
|
| 46 | + <?php endif; |
|
| 47 | +} |
|
| 48 | +?> |
|
| 46 | 49 | <h2>Comments: </h2> |
| 47 | 50 | <?php foreach ($comments as $comment) : ?> |
| 48 | 51 | <div class="comments"> |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | "submit" => [ |
| 51 | 51 | "type" => "submit", |
| 52 | 52 | "value" => "Answer", |
| 53 | - "callback" => [$this, "callbackSubmit"] |
|
| 53 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 54 | 54 | ], |
| 55 | 55 | ] |
| 56 | 56 | ); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | "submit" => [ |
| 51 | 51 | "type" => "submit", |
| 52 | 52 | "value" => "Answer", |
| 53 | - "callback" => [$this, "callbackSubmit"] |
|
| 53 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 54 | 54 | ], |
| 55 | 55 | ] |
| 56 | 56 | ); |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | class Comment extends ActiveRecordModel |
| 7 | 7 | { |
| 8 | 8 | /** |
| 9 | - * @var string $tableName name of the database table. |
|
| 10 | - */ |
|
| 9 | + * @var string $tableName name of the database table. |
|
| 10 | + */ |
|
| 11 | 11 | protected $tableName = "Comment"; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Columns in the table. |
|
| 15 | - * |
|
| 16 | - * @var integer $id primary key auto incremented. |
|
| 17 | - */ |
|
| 14 | + * Columns in the table. |
|
| 15 | + * |
|
| 16 | + * @var integer $id primary key auto incremented. |
|
| 17 | + */ |
|
| 18 | 18 | public $id; |
| 19 | 19 | public $content; |
| 20 | 20 | public $question_id; |