public function render() { $view = View::factory('feed/' . $this->type . '_' . $this->action)->bind('lecture', $lecture)->bind('user', $user)->bind('span', $span)->bind('role', $role)->bind('feed_id', $feed_id)->bind('comments', $comments)->bind('url', $url); if ($this->action == 'add') { $lecture = ORM::factory('lecture', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } } else { if ($this->action == 'canceled') { $lecture = Model_Lecture::get_lecture_from_event($this->respective_id); $event = ORM::factory('event', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } $view->bind('event', $event); } } $user = ORM::factory('user', $this->actor_id); $span = Date::fuzzy_span($this->time); $feed_id = $this->id; $curr_user = Auth::instance()->get_user(); $role = $curr_user->role()->name; $comment = ORM::factory('feedcomment'); $comment->where('feed_id', '=', $feed_id)->order_by('date', 'DESC'); $comments = $comment->find_all(); $url = Url::site('profile/view/id/'); return $view->render(); }
public function action_index() { if ($this->request->param('sort')) { $sort = $this->request->param('sort'); } else { $sort = 'name'; } if ($this->request->param('order')) { $order = $this->request->param('order'); } else { $order = 'DESC'; } if ($this->request->param('filter_when')) { $sdate = strtotime($this->request->param('filter_when')); $edate = $sdate + 86400; $filters = array('sdate' => $sdate, 'edate' => $edate); $total = Model_Lecture::lectures_total_when($filters); $count = $total; $pagination = Pagination::factory(array('total_items' => $count, 'items_per_page' => 5)); $filters = array_merge($filters, array('sort' => $sort, 'order' => $order, 'limit' => $pagination->items_per_page, 'offset' => $pagination->offset)); $lectures = Model_Lecture::lectures_when($filters); } else { $filters = array('filter_name' => $this->request->param('filter_name'), 'filter_course' => $this->request->param('filter_course'), 'filter_lecturer' => $this->request->param('filter_lecturer')); $total = Model_Lecture::lectures_total($filters); $count = $total; $pagination = Pagination::factory(array('total_items' => $count, 'items_per_page' => 5)); $filters = array_merge($filters, array('sort' => $sort, 'order' => $order, 'limit' => $pagination->items_per_page, 'offset' => $pagination->offset)); $lectures = Model_Lecture::lectures($filters); } $sorting = new Sort(array('Lecture' => 'name', 'Course' => 'courses.name', 'Lecturer' => 'firstname', 'When' => '', 'Action' => '')); $url = 'lecture/index'; if ($this->request->param('filter_name')) { $url .= '/filter_name/' . $this->request->param('filter_name'); $filter = $this->request->param('filter_name'); $filter_select = 'filter_name'; } if ($this->request->param('filter_course')) { $url .= '/filter_course/' . $this->request->param('filter_course'); $filter = $this->request->param('filter_course'); $filter_select = 'filter_course'; } if ($this->request->param('filter_lecturer')) { $url .= '/filter_lecturer/' . $this->request->param('filter_lecturer'); $filter = $this->request->param('filter_lecturer'); $filter_select = 'filter_lecturer'; } if ($this->request->param('filter_when')) { $url .= '/filter_when/' . $this->request->param('filter_when'); $filter = $this->request->param('filter_when'); $filter_select = 'filter_when'; } $sorting->set_link($url); $sorting->set_order($order); $sorting->set_sort($sort); $heading = $sorting->render(); $table = array('heading' => $heading, 'data' => $lectures); // Render the pagination links $pagination = $pagination->render(); $links = array('add' => Html::anchor('/lecture/add/', 'Create a Lecture', array('class' => 'createButton l')), 'delete' => URL::site('/lecture/delete/')); $filter_url = URL::site('lecture/index'); $view = View::factory('lecture/list')->bind('links', $links)->bind('table', $table)->bind('count', $count)->bind('filter', $filter)->bind('filter_select', $filter_select)->bind('filter_url', $filter_url)->bind('pagination', $pagination); Breadcrumbs::add(array('Lectures', Url::site('lecture'))); $this->content = $view; }