Example #1
0
 /**
  * Retorna l'arbre de nodes del directori
  **/
 public function getArbre()
 {
     //Variable per assegurar uqe no hi hagi cap error en l'arbre.
     $i = 0;
     $RET = array($this->getIdnodes() => $this);
     $NODE_ACTUAL = NodesPeer::retrieveByPK($this->getIdpare());
     while (!is_null($NODE_ACTUAL) && $i++ < 10) {
         $RET[$NODE_ACTUAL->getIdnodes()] = $NODE_ACTUAL;
         $NODE_ACTUAL = NodesPeer::retrieveByPK($NODE_ACTUAL->getIdpare());
     }
     return $RET;
 }
Example #2
0
 public static function initialize($idN, $idS, $editor = false)
 {
     $ON = NodesPeer::retrieveByPK($idN);
     if (!$ON instanceof Nodes) {
         $ON = new Nodes();
         $ON->setSiteId($idS);
         $ON->setActiu(true);
     }
     if ($editor) {
         return new EditorHtmlForm($ON, array('IDS' => $idS));
     } else {
         return new NodesForm($ON, array('IDS' => $idS));
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->setLayout('web');
     $accio = $request->getParameter('accio', 'home');
     $this->IDS = 1;
     $this->PAGE = $request->getParameter('page', 1);
     // Definim el captcha
     $val1 = rand(0, 9);
     $val2 = rand(0, 9);
     $this->getUser()->setAttribute('CAPTCHA1', $val1);
     $this->getUser()->setAttribute('CAPTCHA2', $val2);
     $this->CAPTCHA = "i la suma de " . $val1 . " + " . $val2;
     $this->SELECCIONAT = "CAP";
     switch ($accio) {
         //Cliquem del menú esquerra, i mostrem els submenús a la dreta. Si no hi ha submenús, mostrem el home
         case 'menu_click':
             $this->A_LLISTA = array();
             $ON = NodesPeer::retrieveByPK($request->getParameter('node'));
             if ($ON instanceof Nodes) {
                 $AON = NodesPeer::getFillsNextLevel($ON);
                 $Arbre = $ON->getArbre();
                 $this->SELECCIONAT = array_pop($Arbre);
                 switch ($ON->getCategories()) {
                     //Si la categoria del node és manual
                     case NodesPeer::CATEGORIA_MANUAL:
                         //Mirem si conté subdirectoris... o bé és de contingut.
                         if (!empty($AON)) {
                             $this->A_LLISTA[1]['mode'] = 1;
                             $this->A_LLISTA[1]['titol'] = "Categories dins aquest menú";
                             foreach ($AON as $ON) {
                                 //Mirem si la imatge existeix
                                 $img = $this->Image_exists('front', $ON->getIdnodes() . '-L') ? '/images/front/' . $ON->getIdnodes() . '-L.jpg' : 'color';
                                 $url = strlen($ON->getUrl()) > 0 ? $ON->getUrl() : '@web_menu_click?node=' . $ON->getIdnodes() . '&titol=' . $ON->getNomForUrl();
                                 $this->A_LLISTA[1]['elements'][] = array('url' => $url, 'titol' => $ON->getTitolmenu(), 'img' => $img);
                             }
                             $this->mode = 'llista';
                             //No té cap més subdirectori, carreguem els continguts
                         } else {
                             //Si el contingut és html, l'interpretem, altrament el mostrem tal com està.
                             if ($ON->getIsphp()) {
                                 $this->CONTINGUT = $ON->getHtml();
                                 $this->IMG = self::Get_Images('front', $ON->getIdnodes() . '-XL');
                                 $this->mode = 'detall';
                             } else {
                                 $this->CONTINGUT = $ON->getHtml();
                                 $this->IMG = self::Get_Images('front', $ON->getIdnodes() . '-XL');
                                 $this->mode = 'detall';
                             }
                         }
                         break;
                         //Si el node és d'exposicions, mostrem un llistat amb les exposicions
                     //Si el node és d'exposicions, mostrem un llistat amb les exposicions
                     case NodesPeer::CATEGORIA_EXPOSICIONS:
                         //Carreguem les exposicions actuals ( Sala Fita i Sala d'exposicions ) i les futures, si hi són.
                         $this->A_LLISTA = $this->CarregaInfoExposicions();
                         $this->mode = 'llista';
                         break;
                     case NodesPeer::CATEGORIA_ACTIVITATS_NORMALS:
                         $this->A_LLISTA = $this->CarregaInfoActivitats();
                         $this->mode = 'llista';
                         break;
                     case NodesPeer::CATEGORIA_FORMACIO:
                         $this->A_LLISTA = $this->CarregaInfoCategories('44', 'CICLES DE FORMACIÓ', null, 1);
                         $this->mode = 'llista';
                         break;
                     case NodesPeer::CATEGORIA_CURSOS:
                         $this->A_LLISTA = $this->CarregaInfoCursos($this->IDS, 0);
                         $this->mode = 'llista';
                         break;
                     case NodesPeer::CATEGORIA_GIROSCOPI:
                         break;
                     case NodesPeer::CATEGORIA_CICLES:
                         $this->A_LLISTA = $this->CarregaInfoCicles();
                         $this->mode = 'llista';
                         break;
                     case NodesPeer::CATEGORIA_MUSICA:
                         $this->redirect('@web_menu_click_cicle?idCicle=394&titol=Musica');
                         break;
                     case NodesPeer::CATEGORIA_CONEIXEMENT:
                         $this->A_LLISTA = $this->CarregaInfoConeixement($this->IDS, 0);
                         $this->mode = 'llista';
                         break;
                 }
             } else {
                 //Entrem a la home
                 $this->mode = 'home';
             }
             break;
             //Quan cliquem l'enllaç d'un curs, mostrem el seu contingut.
         //Quan cliquem l'enllaç d'un curs, mostrem el seu contingut.
         case 'menu_click_cursos':
             $this->SELECCIONAT = NodesPeer::retrieveByPK(62);
             $idC = $request->getParameter('idCurs');
             //Si no hem seleccionat el curs, mostrem els cursos dins una categoria
             if ($idC == 0) {
                 $this->A_LLISTA = $this->CarregaInfoCursos($this->IDS, $request->getParameter('idCategoria'));
                 $this->mode = 'llista';
                 //Hem entrat clicant un curs, mostrem el detall del curs
             } else {
                 $OC = CursosPeer::retrieveByPK($idC);
                 if ($OC instanceof Cursos) {
                     $this->CONTINGUT = $OC->getDescripcio();
                     $this->HORARIS = $OC->getHoraris();
                     $this->TITOL = $OC->getTitolcurs();
                     $this->IMG = self::Get_Images('cursos', 'C-' . $OC->getIdcursos() . '-XL');
                     $this->PDF = $this->PDF_exists('cursos', 'C-' . $OC->getIdcursos() . '-PDF') ? '/images/cursos/C-' . $OC->getIdcursos() . '-PDF.pdf' : '';
                     $this->mode = "detall";
                 } else {
                     $this->mode = "home";
                 }
             }
             break;
             //Quan cliquem l'enllaç d'una activitat mostrem el contingut
         //Quan cliquem l'enllaç d'una activitat mostrem el contingut
         case 'menu_click_activitats':
             $idA = $request->getParameter('idActivitat');
             $OA = ActivitatsPeer::retrieveByPK($idA);
             if ($OA instanceof Activitats) {
                 $this->SELECCIONAT = NodesPeer::retrieveByPK(substr_count($OA->getCategories(), '46') > 0 ? 58 : 61);
                 $OC = CiclesPeer::retrieveByPK($OA->getCiclesCicleid());
                 $this->CONTINGUT = $OA->getDMig();
                 $this->HORARIS = $OA->getHorariss();
                 $this->TITOL = $OA->getTMig();
                 $this->IMG = self::Get_Images('activitats', 'A-' . $OA->getActivitatid() . '-XL');
                 $this->PDF = $this->PDF_exists('activitats', 'A-' . $OA->getActivitatid() . '-PDF') ? '/images/activitats/A-' . $OA->getActivitatid() . '-PDF.pdf' : '';
                 $this->INFO_PRACTICA = $OA->getInfopractica();
                 $this->A_LLISTA = $this->CarregaInfoCategories(null, $OC instanceof Cicles ? 'Altres activitats de: ' . $OC->getTMig() : 'Altres activitats del cicle', $OA->getCiclesCicleid(), 3);
                 $this->mode = "detall";
             } else {
                 $this->mode = "home";
             }
             break;
             //Quan cliquem el botó de cicles, els mostrem tots.
         //Quan cliquem el botó de cicles, els mostrem tots.
         case 'menu_click_cicles':
             $idC = $request->getParameter('idCicle');
             $OC = CiclesPeer::retrieveByPK($idC);
             if ($OC instanceof Cicles) {
                 $this->SELECCIONAT = NodesPeer::retrieveByPK(61);
                 //Miro el primer i últim horari.
                 $PH = "";
                 $PA = $OC->getPrimeraActivitat();
                 if ($PA instanceof Activitats) {
                     $PH = $PA->getPrimerHorari();
                 }
                 $UH = "";
                 $UA = $OC->getUltimaActivitat();
                 if ($UA instanceof Activitats) {
                     $UH = $UA->getUltimHorari();
                 }
                 $HORARIS = array($PH, $UH);
                 $this->CONTINGUT = $OC->getDMig();
                 $this->HORARIS = CiclesPeer::getHorariss($OC->getCicleid(), $OC->getSiteid());
                 $this->TITOL = $OC->getTMig();
                 $this->INFO_PRACTICA = "";
                 $this->IMG = self::Get_Images('cicles', 'C-' . $OC->getCicleid() . '-XL');
                 $this->PDF = $this->PDF_exists('cicles', 'C-' . $OC->getCicleid() . '-PDF') ? '/images/cicles/C-' . $OC->getCicleid() . '-PDF.pdf' : '';
                 $this->A_LLISTA = $this->CarregaInfoCategories(null, 'Activitats del cicle', $OC->getCicleid(), 2);
                 $this->mode = "detall";
             } else {
                 $this->mode = "home";
             }
             break;
             //Quan cliquem l'enllaç d'un curs, mostrem el seu contingut.
         //Quan cliquem l'enllaç d'un curs, mostrem el seu contingut.
         case 'menu_click_noticies':
             $this->SELECCIONAT = NodesPeer::retrieveByPK(60);
             $idN = $request->getParameter('idNoticia', 0);
             //Si no hem escollit una notícia, mostrem les notícies
             if ($idN == 0) {
                 $this->A_LLISTA = $this->CarregaInfoNoticies();
                 $this->mode = 'llista';
                 //Hem entrat clicant un curs, mostrem el detall del curs
             } else {
                 $ON = NoticiesPeer::retrieveByPK($idN);
                 if ($ON instanceof Noticies) {
                     $this->CONTINGUT = $ON->getTextnoticia();
                     $this->HORARIS = "";
                     $this->TITOL = $ON->getTitolnoticia();
                     $this->IMG = self::Get_Images('noticies', 'N-' . $ON->getIdnoticia() . '-XL');
                     $this->PDF = $this->PDF_exists('noticies', 'N-' . $ON->getIdnoticia() . '-PDF') ? '/images/noticies/N-' . $ON->getIdnoticia() . '-PDF.pdf' : '';
                     $this->mode = "detall";
                 } else {
                     $this->mode = "home";
                 }
             }
             break;
         case "cerca":
             $text = $request->getParameter('text', null);
             $data = $request->getParameter('data', null);
             //Convertim la data
             if (!is_null($data)) {
                 list($dia, $mes, $any) = explode('/', $data);
                 $data = mktime(0, 0, 0, $mes, $dia, $any);
             }
             $llista = $this->CarregaInfoActivitats($data, $text, null);
             return $this->renderPartial('llista', array('A_LLISTA' => $llista));
             break;
         default:
             $this->mode = 'home';
             break;
     }
     $this->A_MENU = NodesPeer::retornaMenu(1, false);
     $avui = date('Y-m-d', time());
     //Carreguem per la home... només?
     $this->A_ACTIVITATS_AVUI = ActivitatsPeer::getActivitatsDia($this->IDS, $avui, $this->PAGE, 'activitats');
     $this->A_ACTIVITATS_FUTURES = ActivitatsPeer::getActivitatsProperes($this->IDS, $avui, $this->PAGE, 'horari', 100);
     $this->A_EXPOSICIONS = self::CarregaInfoExposicions();
     $this->A_NOVETATS = NoticiesPeer::getNoticies("", 1, true, false, 1);
 }