public function action_list($all = false, $images = false, $screenshots = false) { if (Auth::check() === false) { Response::Redirect(Uri::Create('login')); } if ($all == 'false' || $all === false) { $all = false; } else { $all = true; } if ($screenshots == "true") { $image = false; $data['screenshots'] = true; } if ($images == "true") { $data['images'] = true; $per_page = Settings::get('images_per_page'); if (empty($per_page) === true) { $per_page = 5; } } else { $per_page = Settings::get('data_per_page'); if (empty($per_page) === true) { $per_page = 25; } } if ($all === false) { // check for admin if (!Auth::member(5)) { Response::Redirect(Uri::Create('user/urls')); } } if (Input::Method() === 'GET' && Input::Get('search')) { $data['total_count'] = Controller_Search::get_urls($all, null, $images); $pagination = Settings::pagination($data['total_count'], $per_page); $data['search'] = Input::GET('search'); $data['my_urls'] = Controller_Search::get_urls($all, $pagination, $images); } else { if ($all === true) { $data['total_count'] = Model_Url::query(); if ($images == "true") { $data['total_count']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%'); } else { $data['total_count']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%'); } $data['total_count'] = $data['total_count']->count(); } else { $data['total_count'] = Model_Url::query()->where('user_id', static::$user_id); if ($images == "true") { $data['total_count']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%'); } else { $data['total_count']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%'); } $data['total_count'] = $data['total_count']->count(); } $pagination = Settings::pagination($data['total_count'], $per_page); $data['my_urls'] = Model_Url::query(); if ($all === false) { $data['my_urls']->where('user_id', static::$user_id); } if ($images == "true") { $data['my_urls']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%'); } else { $data['my_urls']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%'); } $data['my_urls'] = $data['my_urls']->order_by('created_at', 'DESC')->rows_offset($pagination->offset)->rows_limit($per_page)->get(); } $data['pagination'] = $pagination->render(); $this->template->content = View::Forge('url/list', $data); }