Beispiel #1
0
 public function action_index()
 {
     $contenttype = $this->check_contenttype();
     $contents = $contenttype->contents;
     $counter = $contenttype->contents;
     if ((bool) $contenttype->supports('hierarchy')) {
         $contents = $contents->where('parent', '=', 0);
         $counter = $counter->where('parent', '=', 0);
     }
     if ($contenttype->supports('timestamp')) {
         $contents = $contents->order_by('created', 'DESC');
     }
     $contents = $contents->where('splittest', '=', 0);
     $numresults = $counter->count_all();
     $limit = 20;
     $offset = cms::offset($numresults, $limit);
     $contents = $contents->limit($limit)->offset($offset);
     $contents = $this->loop_content_rows($contents->find_all());
     $pagination = cms::pagination($numresults, '#/content/index/' . $contenttype->id, $limit);
     $view = View::factory('Cms/Content/index2');
     $view->contenttype = $contenttype;
     $view->pagination = $pagination;
     $allcontent = DB::select('id', 'title')->from('contents')->where('contenttype_id', '=', $contenttype->id)->execute()->as_array();
     reply::ok($view, 'contenttype-' . $contenttype->id, array('viewModel' => 'viewModels/Content/index', 'contents' => $contents, 'contenttype' => $contenttype->baseinfo(), 'allcontent' => $allcontent));
 }
Beispiel #2
0
 public function action_index()
 {
     $limit = 20;
     $type = arr::get($_GET, 'role', false);
     $usercount = ORM::factory('User')->count_all();
     $numpages = ceil($usercount / $limit);
     $page = arr::get($_GET, 'p', 1);
     if ($page > $numpages) {
         $page = $numpages;
     }
     $page = $page - 1;
     if ($page < 0) {
         $page = 0;
     }
     $offset = $page * $limit;
     $users = ORM::factory('User');
     $counter = ORM::factory('User');
     $currentrole = false;
     if ($type) {
         $currentrole = ORM::factory('Role')->where('name', '=', $type)->find();
         $users = $currentrole->users;
         $counter = $currentrole->users;
     }
     $numresults = $counter->count_all();
     $users = $users->offset($offset)->limit($limit)->find_all();
     $userarr = array();
     if ((bool) $users->count()) {
         foreach ($users as $user) {
             $userarr[] = $user->info();
         }
     }
     $roles = ORM::factory('Role')->find_all();
     $rolesarr = array();
     if ((bool) $roles->count()) {
         foreach ($roles as $role) {
             $rolesarr[] = $role->info();
         }
     }
     $view = View::factory('Cms/Users/index', array('roles' => $roles));
     $view->pagination = cms::pagination($numresults, '#/users', $limit);
     reply::ok($view, 'users', array('viewModel' => 'viewModels/Users/index', 'userCount' => $usercount, 'limit' => $limit, 'users' => $userarr, 'page' => $page, 'roles' => $rolesarr, 'role' => $type));
 }