예제 #1
0
파일: Unite.php 프로젝트: bersace/strass
 function direct($throw = true)
 {
     $slug = $this->getRequest()->getParam('unite');
     $t = new Unites();
     try {
         if ($slug) {
             $unite = $t->findBySlug($slug);
         } else {
             $unite = $t->findRacine();
         }
     } catch (Strass_Db_Table_NotFound $e) {
         if ($throw) {
             if ($slug) {
                 throw new Strass_Controller_Action_Exception_NotFound("Unité " . $slug . " inconnue");
             } else {
                 $url = $this->_actionController->_helper->Url('fonder', 'unites', null, null, true);
                 $aide = "Vous devez [" . $url . " enregistrer une unité] pour commencer.";
                 throw new Strass_Controller_Action_Exception_Notice("Pas d'unité !", 404, $aide);
             }
         } else {
             return null;
         }
     }
     $this->liensConnexes($unite);
     $page = Zend_Registry::get('page');
     $fn = $unite->getFullname();
     if (!$page->metas->get('DC.Title')) {
         $page->metas->set('DC.Title', $fn);
     }
     $page->metas->set('DC.Creator', $fn);
     return $unite;
 }