Merge pull request #133 from vkdimitrov/master
add module (AllComments) that shows all comments in public page
This commit is contained in:
commit
959c710775
45
3.0/modules/allcomments/controllers/allcomments.php
Normal file
45
3.0/modules/allcomments/controllers/allcomments.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
18
3.0/modules/allcomments/css/allcomments.css
Normal file
18
3.0/modules/allcomments/css/allcomments.css
Normal 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;
|
||||||
|
}
|
||||||
|
|
10
3.0/modules/allcomments/helpers/allcomments_theme.php
Normal file
10
3.0/modules/allcomments/helpers/allcomments_theme.php
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
6
3.0/modules/allcomments/module.info
Normal file
6
3.0/modules/allcomments/module.info
Normal 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"
|
38
3.0/modules/allcomments/views/allcomments.html.php
Normal file
38
3.0/modules/allcomments/views/allcomments.html.php
Normal 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>
|
Reference in New Issue
Block a user