1
0

adding allcomments module

This commit is contained in:
vkdimitrov 2012-12-15 22:10:35 +02:00 committed by Mike Miller
parent 9ed8abecb1
commit e15e2a106c
5 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,45 @@
<?php defined("SYSPATH") or die("No direct script access.");
class allcomments_Controller extends Controller
{
public function index()
{
url::redirect('allcomments/page/0');
/*
$this->request->redirect('allcomments/page/0');
$comments = ORM::factory("comment")
->order_by("created", "DESC")
->where("state", "=", "published")
->find_all();
$v = new Theme_View("page.html", "other", "profile");
$v->page_title = t("All comments");
$v->content = new View("allcomments.html", array('comments' => $comments));
print $v;
*/
}
public function page($page_no)
{
$comments = ORM::factory("comment")
->order_by("created", "DESC")
->where("state", "=", "published")
->limit(30)
->offset($page_no*30)
->find_all();
/*
$pagination = new Pagination(array(
'base_url' => 'allcomments/page/', // Set our base URL to controller 'items' and method 'page'
'uri_segment' => 'page', // Our URI will look something like http://domain/items/page/19
'total_items' => 100 // Total number of items.
));
*/
$v = new Theme_View("page.html", "other");
$v->page_title = t("All comments");
$v->content = new View("allcomments.html", array('comments' => $comments, 'page' => $page_no));
print $v;
}
}
?>

View File

@ -0,0 +1,18 @@
#allcomments {
}
#allcomments .allcomments-author {
color: #999;
height: 32px;
line-height: 32px;
}
#allcomments .allcomments-comment {
border-top: 1px solid;
color: #999;
height: 150px;
line-height: 32px;
padding-top: 10px;
padding-bottom: 15px;
}

View File

@ -0,0 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.");
class allcomments_theme
{
static function head($theme) {
return $theme->css("allcomments.css");
}
}
?>

View File

@ -0,0 +1,6 @@
name = "AllComments"
description = "This module shows all comments"
version = 1
author_name = "Vladimir Dimitrov"
author_url = "http://vladko.org"
info_url = "https://github.com/vkdimitrov/allcomments"

View File

@ -0,0 +1,38 @@
<?php defined("SYSPATH") or die("No direct script access."); ?>
<h1>All Comments</h1>
<div id="allcomments">
<ul>
<? foreach ($comments as $comment): ?>
<div class="allcomments-comment">
<li id="g-comment-<?= $comment->id ?>">
<p class="allcomments-author">
<a href="<?= $comment->item()->url() ?>">
<?= t("on %date",
array("date" => gallery::date_time($comment->created),
"title" => $comment->item()->title)); ?></a><br />
<a href="<?= $comment->item()->url() ?>">
<?= $comment->item()->thumb_img(array(), 128) ?></a>
<a href="<?= $comment->author_url() ?>">
<?= nl2br(html::purify($comment->author_name())) ?></a>:
<?= nl2br(html::purify($comment->text)) ?>
</p>
</li>
</div>
<? endforeach ?>
</ul>
<?php
if($page > 0)
{
?>
<a class="g-button ui-icon-right ui-state-default ui-corner-all" href="<?=url::base()?>allcomments/page/<?=$page-1?>">
<span class="ui-icon ui-icon-seek-prev"></span>
prev
</a>
<?}?>
<a class="g-button ui-icon-right ui-state-default ui-corner-all" href="<?=url::base()?>allcomments/page/<?=$page+1?>">
<span class="ui-icon ui-icon-seek-next"></span>
next
</a>
</div>