Ejemplo n.º 1
0
 public function listeAction()
 {
     // n'est appelé qu'en AJAX...
     $this->_helper->layout->disableLayout();
     $film = new Default_Model_FilmMapper();
     $films = $film->fetchAll();
     //$films = $film->simulateFetchAll();
     //        CFDJ_Debug::vd($films);
     $paginator = Zend_Paginator::factory($films);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     //$paginator->setView($view);
     $paginator->setItemCountPerPage(2);
     $this->view->paginator = $paginator;
     //$this->view->firstLoad = ! $this->_hasParam('page');
 }
Ejemplo n.º 2
0
 /**
  * cherche les films dont les noms ressemblent le plus...
  *
  * @todo: add cache (sqllite?)
  * @return unknown_type
  */
 public function similarAction()
 {
     // retrieve film
     $film = $this->_getParam('film');
     $this->view->film = $film;
     // list all files ...
     $film_mapper = new Default_Model_FilmMapper();
     $t = $film_mapper->fetchAll();
     // compute levenshtein
     $t_similar = array();
     foreach ($t as $xfilm) {
         if ($xfilm->getFileName() == $film) {
             continue;
         }
         // don't compare with itself...
         $t_similar[$xfilm->getFileName()] = levenshtein($film, $xfilm->getFileName());
     }
     // order them
     asort($t_similar);
     // return 5 first ...
     $t = array_chunk($t_similar, 5, true);
     $this->view->similar = $t[0];
 }