Example #1
0
 private function applyTo(Query $query)
 {
     if ($this->sortFields !== null) {
         $query->sort($this->sortFields);
     }
     if ($this->page !== null) {
         $query->skip($this->pageSize * $this->page)->limit($this->pageSize);
     }
     return $query;
 }
Example #2
0
 /**
  * @param Query $query
  */
 public function __construct(Query $query)
 {
     $this->query = $query;
     $this->models = [];
     $this->start = $query->getStart();
     $this->limit = $query->getLimit();
     $this->pointer = $this->start;
     $sort = $query->getSort();
     if (empty($sort)) {
         $model = $query->getModel();
         $idProperties = $model::getIDProperties();
         foreach ($idProperties as &$property) {
             $property .= ' asc';
         }
         $query->sort(implode(',', $idProperties));
     }
 }
Example #3
0
        return Response::create(new Template('404'), 404);
    }
    if (!empty($record->id_parent)) {
        $QP = new Query('bookz_record');
        $QP->where('id', '=', $record->id_parent);
        if (!user_authed()) {
            $QP->where('is_published', '=', 1);
        }
        $record->parent = $QP->fetch();
    }
    $QCh = new Query('bookz_record');
    $QCh->where('id_parent', '=', $record->id);
    if (!user_authed()) {
        $QCh->where('is_published', '=', 1);
    }
    $QCh->sort('ordkey', 'ASC');
    $QCh->sort('title', 'ASC');
    $record->child = $QCh->get();
    $posts_page->title = $record->title;
    Registry::set('page', $posts_page);
    Registry::set('record', $record);
    return new Template('bookz_record');
});
/**
 * View pages
 */
Route::get('(:all)', function ($uri) {
    if (!($page = Page::slug($slug = basename($uri)))) {
        return Response::create(new Template('404'), 404);
    }
    if ($page->redirect) {