Permalink
Browse files

enhancements

  • Loading branch information...
1 parent 0a11c81 commit 21f62d3dd81417d1347b69117a8ce75349d46135 @nibsirahsieu committed Apr 9, 2011
Showing with 25 additions and 9 deletions.
  1. +25 −9 lib/behavior/templates/getComments.php
View
34 lib/behavior/templates/getComments.php
@@ -1,45 +1,61 @@
/**
* function to retrieve approved level 1 comments
+ * @param $limit max record to retrieve
* @param $page page number
* @return mixed
*/
-public function getApprovedCommentsLevel1($page = null, $max_per_page = 5)
+public function getApprovedCommentsLevel1($limit = 5, $page = null)
{
$query = <?php echo $foreignModel.'Query' ?>::create()
->approved()
->level(1)
->sortByCreatedAt()
->model($this);
- if (null !== $page) return $query->paginate($page, $max_per_page);
- return $query->find();
+ if (null !== $page) {
+ return $query->paginate($page, $limit);
+ }
+ else {
+ return $query->limit($limit)->find();
+ }
}
/**
* function to retrieve approved comments
+ * @param $limit max record to retrieve
* @param $page page number
* @return mixed
*/
-public function getApprovedComments($page = null, $max_per_page = 5)
+public function getApprovedComments($limit = 5, $page = null)
{
$query = <?php echo $foreignModel.'Query' ?>::create()
->approved()
->sortByCreatedAt()
->model($this);
- if (null !== $page) return $query->paginate($page, $max_per_page);
- return $query->find();
+ if (null !== $page) {
+ return $query->paginate($page, $limit);
+ }
+ else {
+ return $query->limit($limit)->find();
+ }
}
/**
* function to retrieve all comments
+ * @param $limit max record to retrieve
* @param $page page number
* @return mixed
*/
-public function getComments($page = null, $max_per_page = 5)
+public function getComments($limit = 5, $page = null)
{
$query = <?php echo $foreignModel.'Query' ?>::create()
->sortByCreatedAt()
->model($this);
- if (null !== $page) return $query->paginate($page, $max_per_page);
- return $query->find();
+ if (null !== $page) {
+ return $query->paginate($page, $limit);
+ }
+ else {
+ return $query->limit($limit)->find();
+ }
}
+

0 comments on commit 21f62d3

Please sign in to comment.