Exemplo n.º 1
0
 public static function initialize($idF, $idS)
 {
     $OO = AppBlogsFormsPeer::retrieveByPK($idF);
     if (!$OO instanceof AppBlogsForms) {
         $OO = new AppBlogsForms();
         $OO->setSiteId($idS);
         $OO->setActiu(true);
     }
     return new AppBlogsFormsForm($OO, array('IDS' => $idS));
 }
Exemplo n.º 2
0
 public static function getFields($idF, $idS)
 {
     $RET = array();
     $C = new Criteria();
     $C = self::getCriteriaActiu($C, $idS);
     $FORM = AppBlogsFormsPeer::retrieveByPK($idF);
     foreach (explode('@@@', $FORM->getViewfields()) as $E) {
         $RET[$E] = $E;
     }
     return $RET;
 }
Exemplo n.º 3
0
 public function setInactiu()
 {
     $this->setActiu(false);
     $C = new Criteria();
     $C = AppBlogsPagesPeer::getCriteriaActiu($C, $this->getSiteId());
     foreach ($this->getAppBlogsPagess($C) as $OP) {
         $OP->setInactiu();
     }
     $C = new Criteria();
     $C = AppBlogsFormsPeer::getCriteriaActiu($C, $this->getSiteId());
     foreach ($this->getAppBlogsFormss($C) as $OF) {
         $OF->setInactiu();
     }
     $C = new Criteria();
     $C = AppBlogsMenuPeer::getCriteriaActiu($C, $this->getSiteId());
     foreach ($this->getAppBlogsMenus($C) as $OM) {
         $OM->setInactiu();
     }
     $this->save();
 }
Exemplo n.º 4
0
 private function reloadBlog()
 {
     //    echo 'BLOG: '.$this->APP_BLOG;
     //    echo 'MENU: '.$this->APP_MENU;
     //    echo 'PAGE: '.$this->APP_PAGE;
     //    echo 'ENTR: '.$this->APP_ENTRY;
     //    echo 'IDS:'.$this->IDS;
     $this->TREE = AppBlogsMenuPeer::getOptionsMenus($this->APP_BLOG, $this->APP_MENU, false, $this->IDS);
     $this->MENUS_ARRAY = AppBlogsMenuPeer::getOptionsMenus($this->APP_BLOG, $this->APP_MENU, true, $this->IDS);
     $this->PAGES_ARRAY = AppBlogsPagesPeer::getOptionsPages($this->APP_BLOG, $this->APP_MENU, $this->APP_PAGE, $this->IDS);
     $this->ENTRIES_ARRAY = AppBlogsEntriesPeer::getOptionsEntries($this->APP_PAGE, $this->APP_ENTRY, $this->IDS);
     $this->FORMS_ARRAY = AppBlogsFormsPeer::getOptionsForms($this->APP_BLOG, $this->APP_FORM, $this->IDS);
 }
 /**
  * Get the associated AppBlogsForms object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     AppBlogsForms The associated AppBlogsForms object.
  * @throws     PropelException
  */
 public function getAppBlogsForms(PropelPDO $con = null)
 {
     if ($this->aAppBlogsForms === null && $this->form_id !== null) {
         $this->aAppBlogsForms = AppBlogsFormsPeer::retrieveByPk($this->form_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aAppBlogsForms->addAppBlogsFormsEntriess($this);
         		 */
     }
     return $this->aAppBlogsForms;
 }
Exemplo n.º 6
0
 /**
  * Returns the number of related AppBlogsForms objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related AppBlogsForms objects.
  * @throws     PropelException
  */
 public function countAppBlogsFormss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(AppBlogsBlogsPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collAppBlogsFormss === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(AppBlogsFormsPeer::BLOG_ID, $this->id);
             $count = AppBlogsFormsPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(AppBlogsFormsPeer::BLOG_ID, $this->id);
             if (!isset($this->lastAppBlogsFormsCriteria) || !$this->lastAppBlogsFormsCriteria->equals($criteria)) {
                 $count = AppBlogsFormsPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collAppBlogsFormss);
             }
         } else {
             $count = count($this->collAppBlogsFormss);
         }
     }
     return $count;
 }
Exemplo n.º 7
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = AppBlogsBlogsPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related AppBlogsForms objects
         $criteria = new Criteria(AppBlogsFormsPeer::DATABASE_NAME);
         $criteria->add(AppBlogsFormsPeer::BLOG_ID, $obj->getId());
         $affectedRows += AppBlogsFormsPeer::doDelete($criteria, $con);
         // delete related AppBlogsMenu objects
         $criteria = new Criteria(AppBlogsMenuPeer::DATABASE_NAME);
         $criteria->add(AppBlogsMenuPeer::BLOG_ID, $obj->getId());
         $affectedRows += AppBlogsMenuPeer::doDelete($criteria, $con);
         // delete related AppBlogsPages objects
         $criteria = new Criteria(AppBlogsPagesPeer::DATABASE_NAME);
         $criteria->add(AppBlogsPagesPeer::BLOG_ID, $obj->getId());
         $affectedRows += AppBlogsPagesPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Exemplo n.º 8
0
 /**
  * Selects a collection of AppBlogsFormsEntries objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of AppBlogsFormsEntries objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     AppBlogsFormsEntriesPeer::addSelectColumns($criteria);
     $startcol2 = AppBlogsFormsEntriesPeer::NUM_COLUMNS - AppBlogsFormsEntriesPeer::NUM_LAZY_LOAD_COLUMNS;
     AppBlogsFormsPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (AppBlogsFormsPeer::NUM_COLUMNS - AppBlogsFormsPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(AppBlogsFormsEntriesPeer::FORM_ID, AppBlogsFormsPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseAppBlogsFormsEntriesPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = AppBlogsFormsEntriesPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = AppBlogsFormsEntriesPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = AppBlogsFormsEntriesPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             AppBlogsFormsEntriesPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined AppBlogsForms rows
         $key2 = AppBlogsFormsPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = AppBlogsFormsPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = AppBlogsFormsPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 AppBlogsFormsPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (AppBlogsFormsEntries) to the collection in $obj2 (AppBlogsForms)
             $obj2->addAppBlogsFormsEntries($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
 /**
  * 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(AppBlogsFormsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(AppBlogsFormsPeer::DATABASE_NAME);
         $criteria->add(AppBlogsFormsPeer::ID, $pks, Criteria::IN);
         $objs = AppBlogsFormsPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 10
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeNoticiesculturals(sfWebRequest $request)
 {
     $this->IDS = 1;
     $this->PAGE_ID_QUE_ESTA_PASSANT = 1;
     $this->PAGE_ID_QUE_PASSARA = 2;
     $this->PAGE_ID_QUE_HA_PASSAT = 3;
     $this->FORM_ID = 2;
     $this->BLOG_ID = 4;
     $this->setLayout('blank');
     $this->PAGE_ID = $this->ParReqSesForm($request, 'PAGE_ID', $this->PAGE_ID_QUE_ESTA_PASSANT);
     $this->NOTICIA_ID = $this->ParReqSesForm($request, 'NOTICIA_ID', -1);
     $this->PAGINA = $request->getParameter('PAGINA', 1);
     $this->MODE = $this->ParReqSesForm($request, 'MODE', 'CONTINGUT');
     $this->ERRORS = "";
     if ($this->MODE == 'CONTINGUT' && $request->hasParameter('NOTICIA_ID')) {
         $this->NOTICIA = AppBlogsEntriesPeer::retrieveByPK($request->getParameter('NOTICIA_ID'));
         $this->MODE = 'CONTINGUT';
     } elseif ($this->MODE == 'CONTINGUT') {
         $order = $this->PAGE_ID == $this->PAGE_ID_QUE_HA_PASSAT ? false : true;
         $this->NOTICIES = AppBlogsEntriesPeer::getEntries($this->PAGE_ID, $this->PAGINA, $order, $this->IDS);
         $this->MODE = 'CONTINGUT';
     } elseif ($this->MODE == 'FORM1') {
         $this->FORM1 = array('nom_entitat' => '', 'nom_cognoms' => '', 'lloc_ocupa' => '', 'nom_cognoms_contacte' => '', 'adreca' => '', 'codi_postal' => '', 'municipi' => '', 'comarca' => '', 'telefons' => '', 'email' => '');
     } elseif ($this->MODE == 'FORM2') {
         $this->DADES = $request->getParameter('dades');
         $this->getUser()->setAttribute('dades', $this->DADES);
         $this->FORM2 = array('titol' => '', 'subtitol1' => '', 'ciutat_acte' => '', 'dia_acte' => '', 'web' => '', 'imatge' => '', 'tipus' => '', 'resum' => '');
     } elseif ($this->MODE == 'ENVIA_FINALITZA') {
         if (!$this->getUser()->hasAttribute('dades')) {
             $this->redirect('@noticies_culturals?MODE=FORM1');
         }
         $this->getUser()->setAttribute('dades2', $request->getParameter('dades'));
         $this->DADES = $this->getUser()->getAttribute('dades');
         $this->DADES2 = $this->getUser()->getAttribute('dades2');
         foreach ($this->DADES2 as $K => $E) {
             $this->DADES[$K] = $E;
         }
         AppBlogsFormsPeer::save($this->FORM_ID, $this->DADES, $request->getFiles(), $this->IDS);
         $this->MODE = 'FORM_OK';
     } elseif ($this->MODE == 'ACTUALITZA') {
         $next_two_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) + 2, date('d', time()), date('Y', time())));
         $next_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) + 1, date('d', time()), date('Y', time())));
         $today = date('Y-m-d', time());
         $previous_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) - 1, date('d', time()), date('Y', time())));
         $previous_two_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) - 2, date('d', time()), date('Y', time())));
         //Captem els que s'han de migrar del formulari
         $C = new Criteria();
         $C = AppBlogsFormsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsFormsEntriesPeer::FORM_ID, $this->FORM_ID);
         $C->add(AppBlogsFormsEntriesPeer::ESTAT, AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_MIGRAT_WAIT);
         //Treballem i migrem els camps que hem marcat com "Per publicar"
         foreach (AppBlogsFormsEntriesPeer::doSelect($C) as $OO) {
             $RET = array();
             foreach (explode("@@@", $OO->getDades()) as $E) {
                 $EX = explode("###", $E);
                 if (isset($EX[0]) && isset($EX[1])) {
                     list($EXCAMP, $TEXT) = explode("###", $E);
                     $RET[$EX[0]] = $EX[1];
                 }
             }
             try {
                 $ON = AppBlogsEntriesPeer::initialize(0, 'CA', 1, 1, $this->IDS)->getObject();
                 $ON->setTitle($RET['titol']);
                 $ON->setSubtitle1($RET['subtitol1']);
                 $ON->setSubtitle2($RET['ciutat_acte'] . ', ' . $this->dataText($RET['dia_acte']));
                 $ON->setBody($RET['text']);
                 $ON->setTags($RET['tipus']);
                 echo stripos($RET['web'], 'http://');
                 if (!stripos($RET['web'], 'http://')) {
                     $ON->setUrl('http://' . $RET['web']);
                 } else {
                     $ON->setUrl($RET['web']);
                 }
                 $ON->setDate($RET['dia_acte']);
                 $dia = $RET['dia_acte'];
                 if ($dia >= $today && $dia < $next_month) {
                     $ON->setPageId($this->PAGE_ID_QUE_ESTA_PASSANT);
                 } elseif ($dia < $today) {
                     $ON->setPageId($this->PAGE_ID_QUE_HA_PASSAT);
                 } elseif ($dia > $next_month) {
                     $ON->setPageId($this->PAGE_ID_QUE_PASSARA);
                 }
                 $ON->save();
                 //Guardem la notícia
                 //Guardem les imatges
                 if (isset($RET['file'])) {
                     $WEBSYSROOT = OptionsPeer::getString('SF_WEBSYSROOT', $this->IDS);
                     //Mirem l'extensió de l'arxiu
                     $path_info = pathinfo($WEBSYSROOT . 'uploads/formularis/' . $RET['file']);
                     //Si l'arxiu és una imatge, el tractem i el posem com a imatge
                     if (strtolower($path_info['extension']) == 'jpg' || strtolower($path_info['extension']) == 'png') {
                         try {
                             $img = new sfImage($WEBSYSROOT . 'uploads/formularis/' . $RET['file'], 'image/jpeg');
                             $img->resize(200, null);
                             $img->saveAs($WEBSYSROOT . 'images/blogs/' . $RET['file']);
                             $OM = AppBlogsMultimediaPeer::initialize(0, $this->IDS)->getObject();
                             $OM->setName($RET['file']);
                             $OM->setUrl($RET['file']);
                             $OM->save();
                             echo 'ONID:' . $ON->getId();
                             $OME = AppBlogMultimediaEntriesPeer::initialize($ON->getId(), $OM->getId(), $this->IDS)->getObject()->save();
                         } catch (Exception $e) {
                             echo 'hail';
                             echo $e->getMessage();
                             echo $e->getCode();
                         }
                     }
                 }
                 $OO->setEstat(AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_MIGRAT);
                 $OO->save();
             } catch (Exception $e) {
                 echo 'fiodaf';
                 echo $e->getMessage();
                 echo $e->getCode();
             }
         }
         /**
          * Captem els valors que han estat marcats com "Per arxivar" i els passem a "arxivats"
          */
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsFormsEntriesPeer::FORM_ID, $this->FORM_ID);
         $C->add(AppBlogsFormsEntriesPeer::ESTAT, AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_EMMAGATZEMAT_WAIT);
         foreach (AppBlogsFormsEntriesPeer::doSelect($C) as $OO) {
             $OO->setEstat(AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_EMMAGATZEMAT);
             $OO->save();
         }
         /**
          * Procès de canvi de lloc les notícies que ja han passat a una altra pàgina
          */
         //Captem les notícies que han de canviar de pàgina... (Actual->Passades)
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsEntriesPeer::PAGE_ID, $this->PAGE_ID_QUE_ESTA_PASSANT);
         $C->add(AppBlogsEntriesPeer::DATE, $today, CRITERIA::LESS_THAN);
         foreach (AppBlogsEntriesPeer::doSelect($C) as $OO) {
             $OO->setPageid($this->PAGE_ID_QUE_HA_PASSAT);
             $OO->save();
         }
         //Captem les notícies que han de canviar de pàgina... (Futures->actual)
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsEntriesPeer::PAGE_ID, $this->PAGE_ID_QUE_PASSARA);
         $C->add(AppBlogsEntriesPeer::DATE, $today, CRITERIA::GREATER_THAN);
         $C->add(AppBlogsEntriesPeer::DATE, $next_month, CRITERIA::LESS_THAN);
         foreach (AppBlogsEntriesPeer::doSelect($C) as $OO) {
             $OO->setPageid($this->PAGE_ID_QUE_ESTA_PASSANT);
             $OO->save();
         }
         //  		$this->redirect('blogs/noticiesculturals?MODE=CONTINGUT&PAGE_ID='.$this->PAGE_ID_QUE_ESTA_PASSANT);
     }
 }
Exemplo n.º 11
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 = AppBlogsFormsPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setBlogId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setViewFields($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setSiteId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setActiu($arr[$keys[5]]);
     }
 }