Exemple #1
0
 public static function getNoticiaActivitat($IDA, $idS)
 {
     $OA = ActivitatsPeer::retrieveByPK($IDA);
     $OH = ActivitatsPeer::getPrimerHorariActivitat($IDA, $idS);
     if ($OH instanceof Horaris) {
         list($Y, $M, $D) = explode('-', $OH->getDia());
     } else {
         $D = date('d', time());
         $M = date('m', time());
         $Y = date('Y', time());
     }
     $diai = mktime(0, 0, 0, $M, $D - 10, $Y);
     $diaf = mktime(0, 0, 0, $M, $D, $Y);
     $FN = NoticiesPeer::initialize(0, $idS);
     $ON = $FN->getObject();
     $ON->setImatge($OA->getImatge());
     $ON->setAdjunt($OA->getPdf());
     $ON->setTitolnoticia($OA->getTmig());
     $ON->setTextnoticia($OA->getDmig());
     $ON->setActiva(false);
     $ON->setIdactivitat($IDA);
     $ON->setDatapublicacio(date('Y-m-d', $diai));
     $ON->setDatadesaparicio(date('Y-m-d', $diaf));
     $ON->save();
     return $ON;
 }
 /**
  * Quan carrego una pàgina de categoria, carrego també la llista corresponent.        
  * */
 private function CarregaInfoNoticies()
 {
     $RET = array();
     $A_ON_PAGER = NoticiesPeer::getNoticies("", 1, true, false, $this->IDS);
     $RET[1]['mode'] = 2;
     $RET[1]['titol'] = "Actualitat a la Casa de Cultura";
     foreach ($A_ON_PAGER->getResults() as $ON) {
         //Mirem si la imatge existeix
         $img = $this->Image_exists('noticies', 'N-' . $ON->getIdnoticia() . '-M') ? '/images/noticies/N-' . $ON->getIdNoticia() . '-M.jpg' : 'color';
         $RET[1]['elements'][] = array('url' => '@web_menu_click_noticies?idNoticia=' . $ON->getIdnoticia() . '&titol=' . $ON->getNomForUrl(), 'titol' => $ON->getTitolnoticia(), 'img' => $img);
     }
     return $RET;
 }
 public function executeGNoticies(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     //Inicialitzem el formulari de cerca
     $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => '', 'select' => 0));
     if (!isset($this->CERCA['select'])) {
         $this->CERCA = array('text' => '', 'select' => 0);
         $this->getUser()->setSessionPar('cerca', $this->CERCA);
     }
     $this->FCerca = new CercaTextChoiceForm();
     $this->FCerca->setChoice(array(0 => 'Actuals', 1 => 'Totes'));
     $this->FCerca->bind($this->CERCA);
     $this->PAGINA = $request->getParameter('p', 1);
     $this->IDN = $request->getParameter('idn');
     $this->accio = $request->getParameter('accio');
     $this->MODE = 'CERCA';
     if ($request->isMethod('POST')) {
         if ($request->hasParameter('BNOU')) {
             $this->accio = 'N';
         }
         if ($request->hasParameter('BSAVE')) {
             $this->accio = 'S';
         } elseif ($request->hasParameter('BDELETE')) {
             $this->accio = 'D';
         } elseif ($request->hasParameter('BEDIT')) {
             $this->accio = 'E';
         }
     }
     switch ($this->accio) {
         case 'CC':
             $this->getUser()->addLogAction('inside', 'gNoticies');
             $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => '', 'select' => 0));
             break;
         case 'N':
             $this->FORMULARI = NoticiesPeer::initialize(0, $this->IDS);
             $this->MODE = 'FORMULARI';
             break;
         case 'E':
             $this->FORMULARI = NoticiesPeer::initialize($this->IDN, $this->IDS);
             $this->MODE = 'FORMULARI';
             break;
         case 'S':
             $RS = $request->getParameter('noticies');
             $this->IDN = $RS['idNoticia'];
             $this->FORMULARI = NoticiesPeer::initialize($this->IDN, $this->IDS);
             $this->FORMULARI->bind($RS, $request->getFiles('noticies'));
             if ($this->FORMULARI->isValid()) {
                 $this->FORMULARI->save();
                 $this->getUser()->addLogAction($this->accio, 'gNoticies', $this->FORMULARI->getObject());
                 $this->redirect('gestio/gNoticies?accio=CC');
             }
             $this->MODE = 'FORMULARI';
             break;
         case 'D':
             $RS = $request->getParameter('noticies');
             $this->IDN = $RS['idNoticia'];
             $this->FORMULARI = NoticiesPeer::initialize($this->IDN, $this->IDS);
             $this->FORMULARI->getObject()->setActiu(false)->save();
             $this->getUser()->addLogAction($this->accio, 'gNoticies', $this->FORMULARI->getObject());
             break;
             //Order Down. Movem la fila un lloc avall.
         //Order Down. Movem la fila un lloc avall.
         case 'O':
             $IDN = $request->getParameter('idN');
             $UP = $request->getParameter('UP', 0);
             NoticiesPeer::setNewOrder($IDN, $UP, $this->IDS);
             break;
     }
     $this->NOTICIES = NoticiesPeer::getNoticies($this->CERCA['text'], $this->PAGINA, false, $this->CERCA['select'], $this->IDS);
 }
 public function LoadWEB(sfWebRequest $request)
 {
     $this->redirect('w/NotFound');
     //Carrego els banners i les fotos que mostraré
     //Si s'entra un menú, carrego el contingut que toca segons el menú
     //Si el menú és només títol, mostro l'estructura de directoris
     //Si el menú té contingut,
     //Si el contingut és automàtic, mostro el contingut automàtic
     //Si el contingut és manual, mostro el contingut manual
     //Si s'entra una cerca, carrego les activitats que corresponen a la cerca i marco el calendari els dies
     //Si s'entra un dia del calendari, cerco les activitats d'aquell dia
     //Si no es cap, carrego les notícies de les últimes activitats...
     $this->setLayout('layout');
     $this->IDS = 1;
     $this->FOTOS = $this->getFotos();
     $this->BANNERS = $this->getBanners();
     $this->MENU = NodesPeer::retornaMenu($this->IDS);
     $this->USUARI = $this->getUser()->getSessionPar('idU', 0);
     $this->SELECCIONAT = 0;
     $this->LLISTAT_ACTIVITATS = array();
     $this->ACTIVITATS_CALENDARI = array();
     $this->MISSATGE = array();
     if ($this->getUser()->isAuthenticated()) {
         $this->TIPUS_MENU = 'ADMIN';
     } else {
         $this->TIPUS_MENU = 'WEB';
     }
     $this->DATACAL = $this->getUser()->ParReqSesForm($request, 'DATACAL', time());
     $this->PAGINA = $this->getUser()->ParReqSesForm($request, 'p', 1);
     //Gestió de menús
     $idN = $request->getParameter('node', 0);
     $this->OBERT = $this->gestionaNodes($idN);
     $this->accio = $request->getParameter('accio');
     if ($request->hasParameter('BCERCA_x') || $request->hasParameter('CERCA') || $this->accio == 'c') {
         $this->CERCA = $this->getUser()->ParReqSesForm($request, 'CERCA', "");
         $this->accio = 'c';
     } else {
         $this->CERCA = "";
     }
     //Carreguem els dies en els que hi ha alguna activitat.
     $this->ACTIVITATS_CALENDARI = ActivitatsPeer::getDiesAmbActivitatsMes($this->DATACAL, $this->IDS);
     switch ($this->accio) {
         //Contingut manual
         case 'mc':
             $this->NODE = NodesPeer::selectPagina($idN);
             $this->ACCIO = 'web';
             break;
             //Contingut automàtic de cicles
         //Contingut automàtic de cicles
         case 'ac':
             $this->NODE = NodesPeer::selectPagina($idN);
             if (!$this->NODE->isNew()) {
                 $cat = $this->NODE->getCategories();
                 $this->LLISTAT_CICLES = ActivitatsPeer::getCiclesCategoria($this->IDS, $cat);
                 $this->ACCIO = 'llistatCiclesCategoria';
                 $ACT = ActivitatsPeer::selectCategories($this->IDS, true);
                 $this->TITOL = "Cicles i activitats a \"" . $ACT[$cat] . '"';
                 $this->CAT = $cat;
             }
             $this->NODE = $idN;
             break;
             //Contingut automàtic d'activitats d'un cicle
         //Contingut automàtic d'activitats d'un cicle
         case 'aca':
             $this->CAT = $request->getParameter('cat', '');
             $this->IDC = $request->getParameter('idc', 1);
             $this->PAGINA = $request->getParameter('p', 1);
             $this->NODE = $request->getParameter('NODE', 0);
             $OC = CiclesPeer::retrieveByPK($this->IDC);
             $this->TITOL = 'Llistat d\'activitats del cicle ' . $OC->getNom();
             $this->LLISTAT_ACTIVITATS = ActivitatsPeer::getActivitatsCicles($this->IDC, $this->IDS, true, $this->PAGINA);
             $this->ACCIO = 'llistatActivitatsCicleCategoria';
             break;
             //Consulta un cicle
         //Consulta un cicle
         case 'cc':
             $this->CICLE = CiclesPeer::retrieveByPK($request->getParameter('idC'));
             $this->ACCIO = 'mostra_cicle';
             $this->TITOL = $this->CICLE->getNom();
             break;
             //Llistat activitats de cicle
         //Llistat activitats de cicle
         case 'ccact':
             $this->IDC = $request->getParameter('idC');
             $this->CICLE = CiclesPeer::retrieveByPK($this->IDC);
             $this->LLISTAT_ACTIVITATS = CiclesPeer::getActivitatsCicleList($this->IDC, $this->IDS, true);
             $this->ACCIO = 'mostra_activitats_cicle';
             $this->TITOL = "Activitats || " . $this->CICLE->getNom();
             break;
             //Cerca
         //Cerca
         case 'c':
             if ($this->CERCA == 'mensual') {
                 $this->CERCA = '';
                 $this->TITOL = 'ACTIVITATS DEL MES';
             } else {
                 $this->TITOL = 'ACTIVITATS TROBADES AMB LA CERCA "' . $this->CERCA . '"';
             }
             $this->LLISTAT_ACTIVITATS = ActivitatsPeer::getActivitatsCerca($this->CERCA, $this->DATACAL, $this->PAGINA, $this->IDS);
             $this->ACCIO = 'llistat_activitats_cerca';
             $this->MODE = 'CERCA';
             break;
             //Cerca un dia
         //Cerca un dia
         case 'ca':
             $this->LLISTAT_ACTIVITATS = ActivitatsPeer::getActivitatsDia($this->IDS, date('Y-m-d', $this->DATACAL), $this->PAGINA);
             $this->ACCIO = 'llistat_activitats';
             $this->TITOL = 'ACTIVITATS EL DIA ' . date('d/m/Y', $this->DATACAL);
             $this->MODE = 'DIA';
             break;
             //Mostra una sola activitat
         //Mostra una sola activitat
         case 'caa':
             $this->LLISTAT_ACTIVITATS = array(ActivitatsPeer::retrieveByPK($request->getParameter('idA')));
             $this->NODE = $request->getParameter('node', 0);
             $this->ACCIO = 'mostra_activitat';
             $this->TITOL = 'Informació de l\'activitat';
             $OA = $this->LLISTAT_ACTIVITATS[0];
             $this->getResponse()->addMeta('facebook', myUser::getFacebookHeaders($OA->getTmig(), sfConfig::get('sf_webdomain') . $this->getController()->genUrl('@web_activitat?idA=' . $OA->getActivitatId() . '&titol=' . $OA->getNomForUrl()), OptionsPeer::getString('SF_WEBROOT', 1) . 'images/activitats/' . $OA->getActivitatId() . '.jpg', 'Casa de Cultura de Girona', '1763108168308'));
             break;
             //Canvi data del calendari
         //Canvi data del calendari
         case 'cdc':
             $this->redirect('web/index?accio=c&CERCA=mensual&DATACAL=' . $this->DATACAL);
             break;
             //Mostrem notícies
         //Mostrem notícies
         default:
             $this->IDN = $request->getParameter('idN', 0);
             $this->PAGINA = $request->getParameter('p', 1);
             if ($this->IDN > 0) {
                 $this->NOTICIA = NoticiesPeer::getNoticia($this->IDN, $this->IDS);
                 $this->getResponse()->addMeta('facebook', myUser::getFacebookHeaders($this->NOTICIA->getTitolnoticia(), sfConfig::get('sf_webdomain') . $this->getController()->genUrl('@web_noticia?idN=' . $this->NOTICIA->getIdnoticia() . '&p=' . $this->PAGINA . '&titol=' . $this->NOTICIA->getNomForUrl()), OptionsPeer::getString('SF_WEBROOT', 1) . 'images/noticies/' . $this->NOTICIA->getIdnoticia() . '.jpg', 'Casa de Cultura de Girona', '1763108168308'));
                 $this->NOTICIES = null;
             } else {
                 $this->NOTICIA = null;
                 $this->NOTICIES = NoticiesPeer::getNoticies('%', $this->PAGINA, true, FALSE, $this->IDS);
             }
             $this->ACCIO = 'noticies';
             $this->getUser()->setSessionPar('NODES', array());
             break;
             break;
     }
 }
Exemple #5
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NoticiesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NoticiesPeer::DATABASE_NAME);
         $criteria->add(NoticiesPeer::IDNOTICIA, $pks, Criteria::IN);
         $objs = NoticiesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #6
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NoticiesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdnoticia($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTitolnoticia($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setTextnoticia($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDatapublicacio($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setActiva($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setImatge($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setAdjunt($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIdactivitat($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setDatadesaparicio($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setOrdre($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setSiteId($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setActiu($arr[$keys[11]]);
     }
 }