コード例 #1
0
 public function indexAction()
 {
     //$this->_forward('index', 'index', 'default');
     // set filters and validators for GET input
     $filters = array('page' => array('HtmlEntities', 'StripTags', 'StringTrim'));
     $validators = array('page' => array('Int'));
     $input = new Zend_Filter_Input($filters, $validators);
     $input->setData($this->getRequest()->getParams());
     if ($input->isValid()) {
         $q = Doctrine_Query::create()->from('Webteam_Model_Video i')->where('i.UserName = ?', $this->identity['UserName']);
         //$result = $q->fetchArray();
         //$this->view->records = $result;
         // configure pager
         $perPage = 10;
         $numPageLinks = 9;
         // initialize pager
         $pager = new Doctrine_Pager($q, $input->page, $perPage);
         // execute paged query
         $result = $pager->execute(array(), Doctrine::HYDRATE_ARRAY);
         // initialize pager layout
         $pagerRange = new Doctrine_Pager_Range_Sliding(array('chunk' => $numPageLinks), $pager);
         $pagerUrlBase = $this->view->url(array(), 'user-catalog-index', 1) . "/{%page}";
         $pagerLayout = new Doctrine_Pager_Layout($pager, $pagerRange, $pagerUrlBase);
         // set page link display template
         $pagerLayout->setTemplate('<a href="{%url}">{%page}</a>');
         $pagerLayout->setSelectedTemplate('<span class="current">{%page}</span>');
         $pagerLayout->setSeparatorTemplate('&nbsp;');
         // set view variables
         $this->view->records = $result;
         $this->view->pages = $pagerLayout->display(null, true);
     } else {
         throw new Zend_Controller_Action_Exception('Invalid input');
     }
 }
コード例 #2
0
 public function videoTraceAction()
 {
     // set filters and validators for GET input
     $filters = array('VideoID' => array('HtmlEntities', 'StripTags', 'StringTrim'));
     $validators = array('VideoID' => array('Int'));
     $input = new Zend_Filter_Input($filters, $validators);
     $data = array('VideoID' => $this->getRequest()->getParam('q'));
     $input->setData($data);
     if ($input->isValid()) {
         //check if vidoe id exists
         $q = Doctrine_Query::create()->from('Webteam_Model_Video i')->where('i.VideoID = ?', $input->VideoID);
         $result = $q->fetchArray();
         $count = count($result);
         if ($count >= 1) {
             $q = Doctrine_Query::create()->from('Webteam_Model_Log i')->where('i.VideoID = ?', $input->VideoID);
             $result = $q->fetchArray();
             //$this->view->records = $result;
             //$this->view->VideoID = $input->VideoID;
             $this->view->VideoID = $input->VideoID;
             $filters = array('page' => array('HtmlEntities', 'StripTags', 'StringTrim'));
             $validators = array('page' => array('Int'));
             $input = new Zend_Filter_Input($filters, $validators);
             $page = $this->getRequest()->getParam('page');
             if (!isset($page)) {
                 $data = array('page' => 1);
             } else {
                 $data = array('page' => $this->getRequest()->getParam('page'));
             }
             $input->setData($data);
             if ($input->isValid()) {
                 $perPage = 10;
                 $numPageLinks = 9;
                 // initialize pager
                 $pager = new Doctrine_Pager($q, $input->page, $perPage);
                 // execute paged query
                 $result = $pager->execute(array(), Doctrine::HYDRATE_ARRAY);
                 // initialize pager layout
                 $pagerRange = new Doctrine_Pager_Range_Sliding(array('chunk' => $numPageLinks), $pager);
                 $pagerUrlBase = $this->view->url(array(), 'report-video-trace', 1) . '?q=' . $this->view->VideoID . '&page=' . "{%page}";
                 $pagerLayout = new Doctrine_Pager_Layout($pager, $pagerRange, $pagerUrlBase);
                 // set page link display template
                 $pagerLayout->setTemplate('<a href="{%url}">{%page}</a>');
                 $pagerLayout->setSelectedTemplate('<span class="current">{%page}</span>');
                 $pagerLayout->setSeparatorTemplate('&nbsp;');
                 // set view variables
                 $this->view->records = $result;
                 $this->view->pages = $pagerLayout->display(null, true);
             } else {
                 //invalid page
             }
         } else {
             //die('VideoID does not exits');
             $this->_helper->getHelper('FlashMessenger')->addMessage('Vidoe ID does not exists.');
             $this->_redirect('/report');
         }
     } else {
         //die('invalid user');
         $this->_helper->getHelper('FlashMessenger')->addMessage('Invalid Video ID.');
         $this->_redirect('/report');
     }
 }