コード例 #1
0
 /**
  * Portal Content browser
  */
 public function channels($view = null, $page = 1)
 {
     if ($view == 'newest' || $view == 'popular') {
         $channels = MyChannel::$view($this->portal->person);
     } else {
         $channels = MyChannel::fetchAll($this->portal->person);
     }
     $data = array();
     foreach ($channels as $channel) {
         if (ChannelAuthZ::_authz($channel->slug)) {
             $data[] = $channel;
         }
     }
     //end foreach
     $per_page = 20;
     $num_records = count($data);
     $data = array_slice($data, ($page - 1) * $per_page, $per_page);
     $overrides = array('last_page' => ceil($num_records / $per_page), 'total_records' => $num_records, 'num_rows' => count($data), 'rows_per_page' => $per_page, 'current_page' => $page);
     $pagination = PSU::paginationResults(PSU::paginationInfo($_GET, $results, $overrides), $data);
     $this->tpl->assign('channels', $pagination['items']);
     $this->tpl->assign('pages', $pagination);
     $this->tpl->assign('user_channels', MyChannel::fetchAll($this->person));
     $this->tpl->display('channels.tpl');
 }