diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment/helpers/comment.php | 23 | ||||
-rw-r--r-- | modules/comment/views/comment_form.html.php | 21 | ||||
-rw-r--r-- | modules/comment/views/comment_list.html.php | 15 | ||||
-rw-r--r-- | modules/comment/views/show_comments.html.php | 9 |
4 files changed, 67 insertions, 1 deletions
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index 36a07106..a768bdcf 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -47,4 +47,25 @@ class Comment_Core { return $comment->save(); } -} + + static function show_comments($item_id) { + $v = new View('show_comments.html'); + $v->comment_list = Comment::show_comment_list($item_id); + $v->comment_form = Comment::show_comment_form($item_id); + $v->render(true); + } + + static function show_comment_list($item_id) { + $v = new View('comment_list.html'); + $v->item_id = $item_id; + $v->comments = ORM::factory('comment')->where('item_id', $item_id) + ->orderby('datetime', 'desc') + ->find_all()->as_array(); + return $v; + } + + static function show_comment_form($item_id) { + $v = new View('comment_form.html'); + $v->item_id = $item_id; + return $v; + }} diff --git a/modules/comment/views/comment_form.html.php b/modules/comment/views/comment_form.html.php new file mode 100644 index 00000000..418f0027 --- /dev/null +++ b/modules/comment/views/comment_form.html.php @@ -0,0 +1,21 @@ +<? defined("SYSPATH") or die("No direct script access."); ?> +<form id="gCommentAdd" class="gExpandedForm"> + <fieldset> + <legend>Add comment</legend> + <div class="row"> + <label for="gCommentAuthor">Your Name</label> + <input type="text" name="author" id="gCommentAuthor" class="text" /> + </div> + <div class="row"> + <label for="gCommentEmail">Your Email (not displayed)</label> + <input type="text" name="email" id="gCommentEmail" class="text" /> + </div> + <div class="row"> + <label for="gCommentText">Comment</label> + <textarea name="text" id="gCommentText"></textarea> + </div> + <input type="hidden" id="gItemId" name="item_id" value="<?= $item_id ?>" /> + <input type="submit" id="gCommentSubmit" value="Add" /> + </fieldset> +</form> + diff --git a/modules/comment/views/comment_list.html.php b/modules/comment/views/comment_list.html.php new file mode 100644 index 00000000..2196af1c --- /dev/null +++ b/modules/comment/views/comment_list.html.php @@ -0,0 +1,15 @@ +<? defined("SYSPATH") or die("No direct script access."); ?> +<ul id="gCommentThread"> + <? foreach (array_reverse($comments) as $index => $comment): ?> + <li id="gComment-<?= $index; ?>" class="gComment <?= $index % 2 ? 'odd' : 'even' ?>"> + <p> + <a href="#" class="gAuthor"><?= $comment->author ?></a> + said <?= round((time() - $comment->datetime)/60) ?> minutes ago + <span class="understate"><?= strftime('%c', $comment->datetime) ?></span> + </p> + <div> + <?= $comment->text ?> + </div> + </li> + <? endforeach; ?> +</ul> diff --git a/modules/comment/views/show_comments.html.php b/modules/comment/views/show_comments.html.php new file mode 100644 index 00000000..9726364f --- /dev/null +++ b/modules/comment/views/show_comments.html.php @@ -0,0 +1,9 @@ +<? defined("SYSPATH") or die("No direct script access."); ?> +<div id="gComments"><!-- BEGIN #gComments --> + <? if ($comment_list): ?> + <h2>Comments</h2> + <?= $comment_list ?> + <? endif ?> + + <?= $comment_form ?> +</div><!-- END #gComments --> |