本文整理汇总了PHP中Paginate::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginate::factory方法的具体用法?PHP Paginate::factory怎么用?PHP Paginate::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginate
的用法示例。
在下文中一共展示了Paginate::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
if ($this->request->method() == HTTP_Request::POST) {
try {
$post = $this->request->post();
if ($post['action'] == 'delete') {
foreach ($post['messages'] as $message) {
$message = ORM::factory('Message')->where('id', '=', $message)->where('receiver_id', '=', $this->user->id)->where('sent', '=', 1)->find();
if ($message->loaded()) {
$message->delete();
}
}
Hint::success('You have deleted the selected messages');
}
$this->redirect(Route::url('message.outbox'));
} catch (ORM_Validation_Exception $e) {
Hint::error($e->errors('models'));
}
}
$this->view = new View_Message_Outbox();
// TODO: Add pagination
$messages = ORM::factory('Message')->where('receiver_id', '=', $this->user->id)->where('sent', '=', 1)->order_by('created', 'DESC');
$paginate = Paginate::factory($messages)->execute();
$this->view->pagination = $paginate->render();
$this->view->messages = $paginate->result();
$this->view->outbox = 1;
}
示例2: action_index
public function action_index()
{
if ($this->request->method() == HTTP_Request::POST) {
try {
if ($this->request->post('active')) {
$pet = ORM::factory('User_Pet')->where('user_pet.id', '=', $this->request->post('active'))->where('user_id', '=', $this->user->id)->find();
$pet->active = time();
$pet->save();
Hint::success($pet->name . ' is now your active pet.');
}
if ($this->request->post('abandon')) {
$pet = ORM::factory('User_Pet')->where('user_pet.id', '=', $this->request->post('abandon'))->where('user_id', '=', $this->user->id)->find();
$pet->user_id = NULL;
$pet->abandoned = time();
$pet->save();
Hint::success('You have abandoned ' . $pet->name . '.');
}
$this->redirect(Route::get('pets')->uri());
} catch (ORM_Validation_Exception $e) {
Hint::error($e->errors('models'));
}
}
$this->view = new View_Pet_Index();
$pets = ORM::factory('User_Pet')->where('user_id', '=', $this->user->id)->order_by('active', 'desc');
$paginate = Paginate::factory($pets)->execute();
$this->view->pagination = $paginate->render();
$this->view->pets = $paginate->result();
$this->view->pets_count = count($pets);
$this->view->href = array('create' => Route::url('pet.create'), 'adopt' => Route::url('pet.adopt'));
}
示例3: action_delete
public function action_delete()
{
$id = (int) $this->request->param('id', 0);
$expert = ORM::factory('Expert_Opinion', $id);
if (!$expert->loaded()) {
$this->redirect('manage/expertopinions');
}
$token = Arr::get($_POST, 'token', false);
if ($this->request->method() == Request::POST && Security::token() === $token) {
$loger = new Loger('delete', $expert->title);
$loger->logThis($expert);
$expert->delete();
$list = ORM::factory('Expert_Opinion');
$paginate = Paginate::factory($list);
$list = $list->find_all();
$last_page = $paginate->page_count();
if ($this->page > $last_page) {
$this->page = $this->page - 1;
}
if ($this->page <= 0) {
$this->page = 1;
}
Message::success(i18n::get('The position of the expert removed'));
$this->redirect('manage/expertopinions/page-' . $this->page);
} else {
$this->set('item', $expert)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/expertopinions/page-' . $this->page));
}
}
示例4: action_index
public function action_index()
{
$type = $this->request->param('type');
$search = Security::xss_clean(Arr::get($_POST, 'search', ''));
if ($post = $this->request->post()) {
$title = Security::xss_clean(Arr::get($post, 'title1', ''));
if ($title != '') {
$titles = ORM::factory('Specprojecttitle', $type);
$titles->title = $title;
$titles->save();
message::success('Успешно изменено');
$this->redirect('manage/specprojects/' . $type);
} else {
message::error('Поле не может быть пустым.');
$this->redirect('manage/specprojects/' . $type);
}
}
if (!empty($search)) {
$this->redirect('manage/specprojects/' . $type . '/search/' . $search);
}
$public = ORM::factory('Publication')->join('spec_projects', 'LEFT')->on('publication.id', '=', 'spec_projects.id_publication')->select('publication.*', 'spec_projects.spec_published', 'spec_projects.in_slider', 'spec_projects.in_middle', 'spec_projects.in_bottom')->where('spec_projects.sproject', '=', $type)->order_by('order', 'desc')->order_by('date', 'DESC');
$paginate = Paginate::factory($public)->paginate(NULL, NULL, 10)->render();
$public = $public->find_all();
$title = ORM::factory('Specprojecttitle', $type)->title;
$this->set('title', $title);
$this->set('list', $public)->set('type', $type);
$this->set('paginate', $paginate);
}
示例5: action_index
public function action_index()
{
$list = ORM::factory('Material')->where('is_journal', '=', 1)->where('is_moderator', '=', 0);
$sort = Security::xss_clean(Arr::get($_GET, 'sort', 'work'));
switch ($sort) {
case "work":
$list->and_where('status', '=', 2);
$this->set('sort', 'work');
break;
case "accept":
$list->where('status', '=', 1);
$this->set('sort', 'accept');
break;
case "reject":
$list->and_where('status', '=', 0);
$this->set('sort', 'reject');
break;
default:
$this->set('sort', 'all');
}
$list->order_by('date', 'DESC');
$paginate = Paginate::factory($list)->paginate(NULL, NULL, 10)->render();
$list = $list->find_all();
$this->set('materials', $list);
$this->set('paginate', $paginate);
}
示例6: action_index
public function action_index()
{
$photosets = ORM::factory('Photoset')->order_by('order', 'ASC');
$paginate = Paginate::factory($photosets)->paginate(NULL, NULL, 10)->render();
$photosets = $photosets->find_all();
//нумерация с 1 для каждого отдельного фотосета
/*$photo = ORM::factory('Photosets_Attachment')->order_by('photoset_id')->find_all();
$i =0;
$photo_id = array();//массив с id фотосетов
foreach ($photo as $var)
{
if (in_array($var->photoset_id,$photo_id))
continue;
else
{
$photo_id[$i]=$var->photoset_id;
$i++;
}
}
foreach ($photo_id as $var)
{
$cat = ORM::factory('Photosets_Attachment')->where('photoset_id','=',$var)->find_all();
$i =1;
foreach ($cat as $val)
{
$val->order = $i;
$val->save();
$i++;
}
}*/
$this->set('photosets', $photosets);
$this->set('paginate', $paginate);
}
示例7: action_index
public function action_index()
{
$comments = ORM::factory('Expert_Comment')->order_by('date', 'desc');
$paginate = Paginate::factory($comments)->set_view('manage/paginate')->paginate()->render();
$comments = $comments->find_all();
$this->set('paginate', $paginate)->set('comments', $comments);
}
示例8: action_index
public function action_index()
{
header('Access-Control-Allow-Origin: *');
$search = Security::xss_clean(isset($_GET['search']) ? $_GET['search'] : '');
if (!empty($search)) {
$query_b = '%' . $search . '%';
$this->searchText = Database::instance()->escape($search);
$query_a = DB::expr(' AGAINST(' . $this->searchText . ') ');
$list = ORM::factory('Publication')->distinct('true')->where(DB::expr('MATCH(title_' . $this->language . ')'), '', $query_a)->or_where(DB::expr('MATCH(desc_' . $this->language . ')'), '', $query_a)->or_where(DB::expr('MATCH(text_' . $this->language . ')'), '', $query_a)->or_where('title_' . $this->language, 'like', $query_b)->and_where('published', '=', 1)->limit($this->limit)->offset($this->offset)->find_all();
} else {
$list = ORM::factory('Publication')->where('title_' . $this->language, '<>', '')->where('published', '=', 1)->order_by('order', 'DESC');
$this->data['page_count'] = Paginate::factory($list)->paginate(NULL, NULL, 10)->page_count();
$list = $list->find_all();
}
$pub = array();
$this->data['search'] = $search;
foreach ($list as $k => $v) {
$pub['id'] = $v->id;
$pub['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartpublications/view/' . $v->id);
$pub['title'] = $v->title;
$pub['desc'] = strip_tags($v->desc);
$pub['image'] = 'http://' . $_SERVER['HTTP_HOST'] . URL::media('/images/w205-h160/' . $v->picture->file_path);
$this->data['publications'][] = $pub;
}
$this->response->body(json_encode($this->data));
}
示例9: action_questions
public function action_questions()
{
$list = ORM::factory('Expert_Question')->where('is_answered', '=', 1);
$search = Security::xss_clean(Arr::get($_POST, 'search', ''));
if (!empty($search)) {
$list->and_where('question', 'LIKE', '%' . $search . '%');
}
$list = $list->order_by('date', 'DESC');
$paginate = Paginate::factory($list)->paginate(NULL, NULL, 10)->render();
$list = $list->find_all();
$this->set('search', $search);
$this->set('list', $list);
$this->set('paginate', $paginate);
if ($this->request->method() == Request::POST) {
if (Auth::instance()->logged_in()) {
try {
$user_id = Auth::instance()->get_user()->id;
$question = ORM::factory('Expert_Question');
$question->user_id = $user_id;
$question->question = Arr::get($_POST, 'question', '');
$question->date = date('Y-m-d H:i:s');
$question->save();
} catch (ORM_Validation_Exception $e) {
}
} else {
Message::success(i18n::get('You have to login'));
}
}
$this->add_cumb('Question-answer', '/');
}
示例10: action_index
public function action_index()
{
header('Access-Control-Allow-Origin: *');
$category = (int) $this->request->param('id', 0);
//SEO. закрываем сортировку
if ($category != 0) {
$sort = 1;
Kotwig_View::set_global('sort', $sort);
}
//end_SEO
$categories = ORM::factory('Photosets_Category')->find_all();
foreach ($categories as $c) {
$this->data['categories'][] = array('id' => $c->id, 'name' => $c->name);
}
$this->data['category'] = $category;
$photosets = ORM::factory('Photoset')->where('published', '=', 1)->where('show_' . $this->language, '=', 1)->order_by('order', 'asc');
if ($category != 0) {
$photosets = $photosets->where('category_id', '=', $category);
}
$photosets = $photosets->order_by('order', 'ASC');
$paginate = Paginate::factory($photosets)->paginate(NULL, NULL, 12)->page_count();
$photosets = $photosets->find_all();
if (count($photosets) < 1) {
$this->data['error'] = 'Error photo';
}
$this->data['pagecount'] = $paginate;
foreach ($photosets as $p) {
$img = $p->isCover() ? 'http://' . $_SERVER['HTTP_HOST'] . URL::media('images/w300-h225-ccc-si/' . $p->pathCover()) : 'http://' . $_SERVER['HTTP_HOST'] . URL::media('images/w300-h225-ccc-si/media/images/nocover.jpg');
$this->data['photosets'][] = array('url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartphoto/view/' . $p->id), 'image' => $img, 'name' => $p->name(), 'category' => $p->category->name);
}
$this->response->body(json_encode($this->data));
}
示例11: action_index
public function action_index()
{
header('Access-Control-Allow-Origin: *');
$id = $this->request->param('id', 0);
//SEO. закрываем сортировку
if ($id != 0) {
$sort = 1;
Kotwig_View::set_global('sort', $sort);
}
//end_SEO
$category = ORM::factory('Category', $id);
$video = ORM::factory('Video')->where('published', '=', 1)->and_where('language', '=', $this->language);
if ($category->loaded()) {
$video = $video->and_where_open()->and_where('category_id', '=', $id);
if ($category->has_children()) {
$video = $video->or_where('category_id', 'IN', $category->children->as_array('id'));
}
$video = $video->and_where_close();
}
$video = $video->order_by('date', 'DESC');
$paginate = Paginate::factory($video)->paginate(NULL, NULL, 12)->page_count();
$video = $video->find_all();
$cat = ORM::factory('Category')->fulltree;
foreach ($cat as $c) {
$this->data['cat'][] = array('id' => $c->id, 'name' => $c->name, 'level' => $c->lvl, 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartvideo/' . $c->id));
}
foreach ($video as $v) {
$this->data['video'][] = array('id' => $v->id, 'link' => $v->link, 'title' => $v->title, 'description' => $v->description, 'preview' => 'http://img.youtube.com/vi/' . $v->link . '/1.jpg', 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartvideo/view/' . $v->id), 'category' => $v->category->name);
}
$this->data['sel_id'] = $id;
$this->data['page_count'] = $paginate;
$this->response->body(json_encode($this->data));
}
示例12: action_index
public function action_index()
{
$scorms = ORM::factory('Education')->where('language', '=', $this->language)->order_by('number');
$paginate = Paginate::factory($scorms)->paginate(null, null, 10)->render();
$scorms = $scorms->find_all();
$this->set('education', $scorms);
$this->set('paginate', $paginate);
}
示例13: action_page
/**
* View topics in category.
*/
public function action_page()
{
$topics = $this->category->topics->with('last_post')->with('last_post:user')->order_by('sticky', 'DESC')->order_by('last_post.created', 'DESC');
$paginate = Paginate::factory($topics)->execute();
$this->view = new View_Forum_Category_View();
$this->view->pagination = $paginate->render();
$this->view->category = $this->category;
$this->view->topics = $paginate->result();
}
示例14: action_index
public function action_index()
{
$infographs = ORM::factory('Infograph')->where('published', '=', 1)->and_where('language', '=', $this->language)->order_by('order', 'asc');
$paginate = Paginate::factory($infographs)->paginate(NULL, NULL, 10)->render();
$infographs = $infographs->find_all();
$this->add_cumb('Infographics', '/');
$this->set('infographs', $infographs);
$this->set('paginate', $paginate);
}
示例15: action_index
public function action_index()
{
$list = ORM::factory('Publication')->where('title_' . $this->language, '<>', '')->where('published', '=', 1)->order_by('order', 'DESC');
$paginate = Paginate::factory($list)->paginate(NULL, NULL, 10)->render();
$list = $list->find_all();
$this->add_cumb('Publications', '/');
$this->set('list', $list);
$this->set('paginate', $paginate);
}