diff options
-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 | ||||
-rw-r--r-- | themes/default/views/photo.html.php | 46 |
5 files changed, 69 insertions, 45 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 --> diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php index ffa22991..1d54fe7d 100644 --- a/themes/default/views/photo.html.php +++ b/themes/default/views/photo.html.php @@ -8,48 +8,6 @@ height="<?= $item->resize_height ?>" /> <h1><?= $item->title_edit ?></h1> <div><?= $item->description_edit ?></div> - - <div id="gComments"> - <h2>Comments</h2> - - <ul id="gCommentThread"> - <li id="gComment-1" class="gComment odd"> - <p><a href="#" class="gAuthor">Andy</a> said 2 hours ago <span class="understate">(October 23, 2008 11:30am)</span></p> - <div> - Lorem ipsum dolor sit amet. - </div> - </li> - <li id="gComment-2" class="gComment even"> - <p> - <a href="#" class="gAuthor">Other user</a> said 30 minutes ago <span class="understate">(October 23, 2008 1:00pm)</span> - </p> - <div> - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard - dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. - It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It - was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with - desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. - </div> - </li> - </ul> - - <form id="gCommentAdd" class="gExpandedForm"> - <fieldset> - <legend>Add comment</legend> - <div class="row"> - <label for="gCommentAuthor">Your Name</label> - <input type="text" id="gCommentAuthor" class="text" /> - </div> - <div> - <label for="gCommentEmail">Your Email (not displayed)</label> - <input type="text" id="gCommentEmail" class="text" /> - </div> - <div class="row"> - <label for="gCommentText">Comment</label> - <textarea id="gCommentText"></textarea> - </div> - <input type="submit" class="button" value="Add" /> - </fieldset> - </form> - </div><!-- END #gComments --> + + <? comment::show_comments($item->id); ?> </div> |