FEATURE: make overview in content pages little bit cleaner
This commit is contained in:
@@ -39,7 +39,7 @@ class ContentOverview extends Controller
|
||||
}
|
||||
|
||||
// get pages for overview
|
||||
$pages = $this->content->getOverview($moduleFilterHandler, $status, true)
|
||||
$pages = $this->content->getOverview($moduleFilterHandler, $status, true, true)
|
||||
->paginate($perPage);
|
||||
|
||||
// get homepage - for checking if homepage is set and available
|
||||
|
||||
+19
-9
@@ -96,37 +96,41 @@ class Content extends Model
|
||||
|
||||
/**
|
||||
* Is current content draft?
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDraft() {
|
||||
public function isDraft()
|
||||
{
|
||||
return $this->status == self::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible for all visitors?
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPublic() {
|
||||
public function isPublic()
|
||||
{
|
||||
return $this->status == self::STATUS_PUBLIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible only for logged users?
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isProtected() {
|
||||
public function isProtected()
|
||||
{
|
||||
return $this->status == self::STATUS_PROTECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible for logged user OR for everyone?
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible() {
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->isPublic() || $this->isProtected();
|
||||
}
|
||||
|
||||
@@ -157,7 +161,7 @@ class Content extends Model
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public function getOverview($handler = false, $status = false, $joinAuthor = false)
|
||||
public function getOverview($handler = false, $status = false, $joinAuthor = false, $joinParent = false)
|
||||
{
|
||||
$query = DB::table('contents')
|
||||
->select('contents.*', 'modules.name AS module_name')
|
||||
@@ -177,6 +181,12 @@ class Content extends Model
|
||||
->addSelect('users.email AS author_email');
|
||||
}
|
||||
|
||||
if ($joinParent) {
|
||||
$query = $query->join('contents as parent', 'parent.id', '=', 'contents.parent_id')
|
||||
->addSelect('parent.title AS parent_title')
|
||||
->addSelect('parent.url AS parent_url');
|
||||
}
|
||||
|
||||
// add filtering by status
|
||||
if (in_array($status, ContentStatuses::getSimple())) {
|
||||
$query = $query->where('contents.status', $status);
|
||||
|
||||
Reference in New Issue
Block a user