/**
  * 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');
 }
 /**
  *
  */
 public function index()
 {
     $this->_force_admin();
     $tabs = MyTab::fetchAll();
     $channels = MyChannel::fetchAll();
     foreach ($channels as $channel) {
         $targets = MyChannel::targetNames($channel->id);
         if (ChannelAuthZ::_has_authz($channel->slug)) {
             $targets[] = '<strong>custom</strong>';
         }
         if (count($targets) > 0) {
             $channel->target_names = implode(', ', $targets);
         }
     }
     $this->tpl->assign_by_ref('tabs', $tabs);
     $this->tpl->assign_by_ref('channels', $channels);
     $this->display('admin-index.tpl');
 }