public function index($offset = 0) { $columns = array(); $configs = array($this->get_class(), '%s'); $conditions = conditions($columns, $configs); Work::addConditions($conditions, 'is_enabled = ? AND destroy_user_id IS NULL', Work::ENABLE_YES); $limit = 12; $total = Work::count(array('conditions' => $conditions)); $offset = $offset < $total ? $offset : 0; $this->load->library('pagination'); $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 3, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li class="f">', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li class="p">', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li class="n">', 'next_tag_close' => '</li>', 'last_tag_open' => '<li class="l">', 'last_tag_close' => '</li>'), $configs))->create_links(); $works = Work::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'conditions' => $conditions)); if ($works) { $this->add_meta(array('name' => 'keywords', 'content' => implode(',', column_array($works, 'title')) . ',' . implode(',', Cfg::setting('site', 'site', 'keywords'))))->add_meta(array('name' => 'description', 'content' => $works[0]->mini_content(150)))->add_meta(array('property' => 'og:title', 'content' => '設計作品' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:description', 'content' => $works[0]->mini_content(300)))->add_meta(array('property' => 'og:image', 'tag' => 'larger', 'content' => $img = $works[0]->cover->url('1200x630c'), 'alt' => '設計作品' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:image:type', 'tag' => 'larger', 'content' => 'image/' . pathinfo($img, PATHINFO_EXTENSION)))->add_meta(array('property' => 'og:image:width', 'tag' => 'larger', 'content' => '1200'))->add_meta(array('property' => 'og:image:height', 'tag' => 'larger', 'content' => '630'))->add_meta(array('property' => 'article:modified_time', 'content' => $works[0]->updated_at->format('c')))->add_meta(array('property' => 'article:published_time', 'content' => $works[0]->created_at->format('c'))); if (($tags = column_array($works[0]->tags, 'name')) || ($tags = Cfg::setting('site', 'site', 'keywords'))) { foreach ($tags as $i => $tag) { if (!$i) { $this->add_meta(array('property' => 'article:section', 'content' => $tag))->add_meta(array('property' => 'article:tag', 'content' => $tag)); } else { $this->add_meta(array('property' => 'article:tag', 'content' => $tag)); } } } } return $this->set_title('設計作品' . ' - ' . Cfg::setting('site', 'site', 'title'))->load_view(array('works' => $works, 'pagination' => $pagination, 'columns' => $columns)); }
public function index($tag_id, $offset = 0) { $columns = array(array('key' => 'title', 'title' => '標題', 'sql' => 'title LIKE ?'), array('key' => 'content', 'title' => '內容', 'sql' => 'content LIKE ?')); $configs = array('admin', $this->get_class(), $this->tag->id, 'works', '%s'); $conditions = conditions($columns, $configs); Work::addConditions($conditions, 'destroy_user_id IS NULL'); if ($work_id = column_array(WorkTagMapping::find('all', array('select' => 'work_id', 'conditions' => array('work_tag_id = ?', $this->tag->id))), 'work_id')) { Work::addConditions($conditions, 'id IN (?)', $work_id); } else { Work::addConditions($conditions, 'id = ?', -1); } $limit = 25; $total = Work::count(array('conditions' => $conditions)); $offset = $offset < $total ? $offset : 0; $this->load->library('pagination'); $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 5, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>'), $configs))->create_links(); $works = Work::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'include' => array('pictures'), 'conditions' => $conditions)); return $this->set_tab_index(2)->set_subtitle($this->tag->name . '內的作品列表')->load_view(array('tag' => $this->tag, 'works' => $works, 'pagination' => $pagination, 'columns' => $columns)); }
public function index($offset = 0) { $columns = array(array('key' => 'user_id', 'title' => '作者', 'sql' => 'user_id = ?', 'select' => array_map(function ($user) { return array('value' => $user->id, 'text' => $user->name); }, User::all(array('select' => 'id, name')))), array('key' => 'title', 'title' => '標題', 'sql' => 'title LIKE ?'), array('key' => 'tag_id', 'title' => '分類', 'sql' => '(id != 0 OR id = ?)', 'select' => array_map(function ($tag) { return array('value' => $tag->id, 'text' => $tag->name); }, WorkTag::all(array('select' => 'id, name'))))); $configs = array('admin', $this->get_class(), '%s'); $conditions = conditions($columns, $configs); Work::addConditions($conditions, 'destroy_user_id IS NULL'); if (($tag_id = OAInput::get('tag_id')) && ($ids = column_array(WorkTagMapping::find('all', array('select' => 'work_id', 'conditions' => array('work_tag_id = ?', $tag_id))), 'work_id'))) { Work::addConditions($conditions, 'id IN (?)', $ids); } $limit = 25; $total = Work::count(array('conditions' => $conditions)); $offset = $offset < $total ? $offset : 0; $this->load->library('pagination'); $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 5, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>'), $configs))->create_links(); $works = Work::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'include' => array('user', 'pictures'), 'conditions' => $conditions)); Session::setData('admin_works_index_url', current_url()); return $this->set_tab_index(1)->set_subtitle('作品列表')->add_hidden(array('id' => 'is_enabled_url', 'value' => base_url('admin', $this->get_class(), 'is_enabled')))->load_view(array('works' => $works, 'pagination' => $pagination, 'columns' => $columns)); }
public function index($offset = 0) { $this->breadcrumb->append_crumb('Home', base_url()); $this->breadcrumb->append_crumb('Staff Detail', base_url() . 'index.php/staffs/show/' . $this->staff_id); $this->breadcrumb->append_crumb('Work Histories', base_url() . ''); $work = new Work(); $data['staff_id'] = $this->staff_id; $work->where('staff_id', $this->staff_id)->order_by('history_date', 'ASC'); $total_rows = $work->count(); $data['title'] = "Work Histories"; $data['btn_add'] = anchor('staffs/' . $this->staff_id . '/work_histories/add', 'Add New', "class='btn btn-primary'"); $data['btn_home'] = anchor('staffs', 'Home'); $offset = $this->uri->segment($this->uri_segment); $data['work_histories'] = $work->where('staff_id', $this->staff_id)->get($this->limit, $offset)->all; $config['base_url'] = site_url('staffs/' . $this->staff_id . '/work_histories/index'); $config['total_rows'] = $total_rows; $config['per_page'] = $this->limit; $config['uri_segment'] = $this->uri_segment; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $data['breadcrumb'] = $this->breadcrumb->output(); $this->load->view('staff_work_history/index', $data); }