コード例 #1
0
ファイル: AppBlogsPages.php プロジェクト: nagiro/intra
 public function setInactiu()
 {
     $this->setActiu(false);
     $C = new Criteria();
     $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->getSiteId());
     foreach ($this->getAppBlogsEntriess($C) as $OE) {
         $OE->setInactiu();
     }
     $this->save();
 }
コード例 #2
0
ファイル: AppBlogsEntriesPeer.php プロジェクト: nagiro/intra
 public static function initialize($entry_id, $lang = 'CA', $page_id, $blog_id, $idS)
 {
     $OO = AppBlogsEntriesPeer::retrieveByPK($entry_id);
     if (!$OO instanceof AppBlogsEntries) {
         $OO = new AppBlogsEntries();
         $OO->setTitle('Títol per defecte');
         $OO->setBody("Cos per defecte");
         $OO->setLang($lang);
         $OO->setPageId($page_id);
         $OO->setDate(date('Y-m-d H:i:s', time()));
         $OO->setSiteId($idS);
         $OO->setActiu(true);
     }
     return new AppBlogsEntriesForm($OO, array('IDS' => $idS, 'APP_BLOG' => $blog_id));
 }
コード例 #3
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(AppBlogsEntriesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(AppBlogsEntriesPeer::DATABASE_NAME);
         $criteria->add(AppBlogsEntriesPeer::ID, $pks, Criteria::IN);
         $objs = AppBlogsEntriesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #4
0
 /**
  * Returns the number of related AppBlogsEntries objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related AppBlogsEntries objects.
  * @throws     PropelException
  */
 public function countAppBlogsEntriess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(AppBlogsPagesPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collAppBlogsEntriess === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(AppBlogsEntriesPeer::PAGE_ID, $this->id);
             $count = AppBlogsEntriesPeer::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(AppBlogsEntriesPeer::PAGE_ID, $this->id);
             if (!isset($this->lastAppBlogsEntriesCriteria) || !$this->lastAppBlogsEntriesCriteria->equals($criteria)) {
                 $count = AppBlogsEntriesPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collAppBlogsEntriess);
             }
         } else {
             $count = count($this->collAppBlogsEntriess);
         }
     }
     return $count;
 }
コード例 #5
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);
 }
コード例 #6
0
 /**
  * Selects a collection of AppBlogMultimediaEntries objects pre-filled with all related objects except AppBlogsMultimedia.
  *
  * @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 AppBlogMultimediaEntries objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptAppBlogsMultimedia(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     AppBlogMultimediaEntriesPeer::addSelectColumns($criteria);
     $startcol2 = AppBlogMultimediaEntriesPeer::NUM_COLUMNS - AppBlogMultimediaEntriesPeer::NUM_LAZY_LOAD_COLUMNS;
     AppBlogsEntriesPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (AppBlogsEntriesPeer::NUM_COLUMNS - AppBlogsEntriesPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(AppBlogMultimediaEntriesPeer::ENTRIES_ID, AppBlogsEntriesPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseAppBlogMultimediaEntriesPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = AppBlogMultimediaEntriesPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = AppBlogMultimediaEntriesPeer::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 = AppBlogMultimediaEntriesPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             AppBlogMultimediaEntriesPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined AppBlogsEntries rows
         $key2 = AppBlogsEntriesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = AppBlogsEntriesPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = AppBlogsEntriesPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 AppBlogsEntriesPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (AppBlogMultimediaEntries) to the collection in $obj2 (AppBlogsEntries)
             $obj2->addAppBlogMultimediaEntries($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #7
0
 /**
  * Get the associated AppBlogsEntries object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     AppBlogsEntries The associated AppBlogsEntries object.
  * @throws     PropelException
  */
 public function getAppBlogsEntries(PropelPDO $con = null)
 {
     if ($this->aAppBlogsEntries === null && $this->entries_id !== null) {
         $this->aAppBlogsEntries = AppBlogsEntriesPeer::retrieveByPk($this->entries_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->aAppBlogsEntries->addAppBlogMultimediaEntriess($this);
         		 */
     }
     return $this->aAppBlogsEntries;
 }
コード例 #8
0
ファイル: BaseAppBlogsEntries.php プロジェクト: nagiro/intra
 /**
  * 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 = AppBlogsEntriesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPageId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setLang($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setTitle($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setSubtitle1($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setSubtitle2($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setBody($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setDate($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setTags($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setUrl($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]]);
     }
 }
コード例 #9
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);
     }
 }
コード例 #10
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 = AppBlogsPagesPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related AppBlogsEntries objects
         $criteria = new Criteria(AppBlogsEntriesPeer::DATABASE_NAME);
         $criteria->add(AppBlogsEntriesPeer::PAGE_ID, $obj->getId());
         $affectedRows += AppBlogsEntriesPeer::doDelete($criteria, $con);
         // delete related AppBlogsMenu objects
         $criteria = new Criteria(AppBlogsMenuPeer::DATABASE_NAME);
         $criteria->add(AppBlogsMenuPeer::PAGE_ID, $obj->getId());
         $affectedRows += AppBlogsMenuPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }