public function indexAction() { $auth = Zend_Auth::getInstance(); $log = $auth->getIdentity()->NOM_M . " " . $auth->getIdentity()->PRENOM; $this->view->log = $log; $dba = Zend_Registry::get('dba'); $evenements = new Application_Model_Evenement($dba); $evenements_results = $evenements->fetchAll(); $genre_table = new Application_Model_Genre($dba); $genres = $genre_table->fetchAll()->toArray(); $genre_playlist = array(); foreach ($genres as $genre) { $playlist_table = new Application_Model_Playlist($dba); $where = $dba->quoteInto("ID_GENRE = ?", $genre["ID_GENRE"]); $playlists_results = $playlist_table->fetchAll($where)->toArray(); $playlists = array(); foreach ($playlists_results as $playlist) { $playlists[] = array("PLAY_ID" => $playlist["PLAY_ID"], "NOM_PLAY" => $playlist["NOM_PLAY"]); } if (count($playlists) > 0) { $genre_playlist[] = array("ID_GENRE" => $genre["ID_GENRE"], "GENRE" => $genre["NOM_G"], "PLAYLISTS" => $playlists); } } $result = array(); foreach ($evenements_results as $evenement) { $joue_table = new Application_Model_Joue($dba); $select = $joue_table->select()->where("EVENEMENT_ID = ?", $evenement->EVENEMENT_ID); $joue_results = $joue_table->fetchAll($select)->toArray(); $color = "blue"; if ($evenement->ID_EMISSION != NULL) { $color = "red"; } if (count($joue_results) > 0) { $color = "orange"; } $item = array("EVENEMENT_ID" => $evenement->EVENEMENT_ID, "D_H_DEBUT" => $evenement->D_H_DEBUT, "D_H_FIN" => $evenement->D_H_FIN, "NOM_EV" => $evenement->NOM_EV, "COLOR" => $color); $result[] = $item; } $emission_table = new Application_Model_Emission($dba); $select = $emission_table->select()->where("PATH_E IS NOT NULL"); $this->view->podcast = $emission_table->fetchAll($select)->toArray(); $this->view->genre_playlist = $genre_playlist; $this->view->evenements = $result; }
public function indexAction() { $auth = Zend_Auth::getInstance(); $log = $auth->getIdentity()->NOM_M . " " . $auth->getIdentity()->PRENOM; $this->view->log = $log; $dba = Zend_Registry::get('dba'); // On récupère l'instance de la BDD $musiques = new Application_Model_Musique($dba); $this->view->musiques = $musiques->fetchAll(null, "TITRE_M ASC", $this->item_per_page); // On récupère l'ensemble des entrées dans la table MUSIQUE $this->view->indexes = ceil(count($musiques->fetchAll()->toArray()) / $this->item_per_page); $playlists_table = new Application_Model_Playlist($dba); $playlists = $playlists_table->fetchAll()->toArray(); // On récupère l'ensemble des entrées dans la table PLAYLIST $res = array(); foreach ($playlists as $playlist) { $genre_table = new Application_Model_Genre($dba); $genre_row = $genre_table->find($playlist["ID_GENRE"]); $genre = $genre_row->current(); $zic_playlist = new Application_Model_DansPlaylist($dba); $where = $dba->quoteInto("PLAY_ID = ?", $playlist["PLAY_ID"]); $zic_playlist_results = $zic_playlist->fetchAll($where)->toArray(); $zic_list = array(); foreach ($zic_playlist_results as $zic) { $musique_table = new Application_Model_Musique($dba); $musique_row = $musique_table->find($zic["ID_MUSIQUE"]); $current_musique = $musique_row->current(); $zic_list[] = $current_musique->toArray(); } $res[] = array("ID_PLAYLIST" => $playlist["PLAY_ID"], "NOM_PLAYLIST" => $playlist["NOM_PLAY"], "NOM_GENRE" => $genre["NOM_G"], "MUSIQUES" => $zic_list); } $genre_table = new Application_Model_Genre($dba); $genres = $genre_table->fetchAll()->toArray(); $this->view->genres = $genres; usort($res, array('PlaylistController', 'compare')); $this->view->playlist = $res; }
function getfatherAction() { $id = $_GET["id"]; $dba = Zend_Registry::get('dba'); $this->_helper->layout->disableLayout(true); $this->_helper->viewRenderer->setNoRender(true); $genres_table = new Application_Model_Genre($dba); $where = $dba->quoteInto("ID_GENRE = ?", $id); $genre_tab = $genres_table->fetchAll()->toArray(); $genres = $genres_table->fetchAll($where)->toArray(); $res = array(); foreach ($genre_tab as $gt) { if ($gt["ID_GENRE"] == $genres[0]["GEN_ID_GENRE"]) { $res[] = $gt; } } $json = json_encode($res); // On renvoie le tout sous format JSON echo $json; }