function indexAction() { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->setView($this->initView()); $pages = array(array('uri' => '/'), array('controller' => 'liens'), array('controller' => 'citation')); /* Les unités */ $t = new Unites(); foreach ($t->findRacines() as $u) { $spages = array(); foreach ($u->findSousUnites(true, true) as $su) { array_push($spages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $su->slug))); array_push($spages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $su->slug))); array_push($spages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $su->slug))); } array_push($pages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $u->slug), 'pages' => $spages)); array_push($pages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $u->slug))); array_push($pages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $u->slug))); } /* Journaux */ $t = new Journaux(); foreach ($t->fetchAll() as $j) { $articles = array(); foreach ($j->findArticles('article.public IS NOT NULL OR article.public != 0') as $a) { array_push($articles, array('controller' => 'journaux', 'action' => 'consulter', 'params' => array('article' => $a->slug))); } array_push($pages, array('controller' => 'journaux', 'action' => 'lire', 'params' => array('journal' => $j->slug), 'pages' => $articles)); } /* Photos promues */ $t = new Photos(); $s = $t->select()->where('promotion > 0'); foreach ($t->fetchAll($s) as $p) { array_push($pages, array('controller' => 'photos', 'action' => 'voir', 'params' => array('photo' => $p->slug))); } $this->view->nav = new Zend_Navigation($pages); $this->getResponse()->setheader('Content-Type', 'text/xml'); $this->render(); }
function findPhotosAleatoires($annee = null) { // Une photos aléatoire d'une activité où l'unité à participé $t = new Photos(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->distinct()->from('photo'); /* Rechercher les albums ou l'unité a participé */ $s->join('participation', 'participation.activite = photo.activite' . ' AND ' . $db->quoteInto("participation.unite = ?", $this->id), array()); /* Rechercher si l'unité est identifiée sur la photo */ $s->joinLeft(array('identification' => 'photo_identification'), $db->quoteInto('identification.photo = photo.id' . ' AND ' . 'identification.unite = ?', $this->id), array()); /* Préfére les photos où l'unité est identifiée explicitement. */ $s->order('identification.unite DESC'); /* Préfère les photo comm. */ $s->order('photo.promotion DESC'); /* Mélanger les photos comm. et identifie */ $s->order('RANDOM()'); if ($annee) { $s->where("strftime('%Y', activite.debut, '-8 months') = ?", strval($annee)); } $s->limit(6); // paramétrable ? return $t->fetchAll($s); }