public static function getFiles($entry_id, $idS) { $C = new Criteria(); $C->addJoin(self::ID, AppBlogMultimediaEntriesPeer::ENTRIES_ID); $C->addJoin(AppBlogMultimediaEntriesPeer::MULTIMEDIA_ID, AppBlogsMultimediaPeer::ID); $C->add(self::ID, $entry_id); return AppBlogsMultimediaPeer::doSelect($C); }
public function setInactiu() { $this->setActiu(false); $C = new Criteria(); $C = AppBlogsMultimediaPeer::getCriteriaActiu($C, $this->getSiteId()); foreach ($this->getAppBlogsMultimedia($C) as $OM) { $OM->setInactiu(); } $this->save(); }
public static function initialize($id, $idS) { $OO = AppBlogsMultimediaPeer::retrieveByPK($id); if (!$OO instanceof AppBlogsMultimedia) { $OO = new AppBlogsMultimedia(); $OO->setDate(date('Y-m-d', time())); $OO->setDesc(""); $OO->setSiteId($idS); $OO->setActiu(true); } return new AppBlogsMultimediaForm($OO, array('IDS' => $idS)); }
public function getImages() { $C = new Criteria(); $C->addJoin(AppBlogsEntriesPeer::ID, AppBlogMultimediaEntriesPeer::ENTRIES_ID); $C->addJoin(AppBlogsMultimediaPeer::ID, AppBlogMultimediaEntriesPeer::MULTIMEDIA_ID); $C->add(AppBlogsEntriesPeer::ID, $this->getId()); $RS = AppBlogsMultimediaPeer::doSelect($C); if (empty($RS)) { return false; } else { return $RS; } }
/** * 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(AppBlogsMultimediaPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(AppBlogsMultimediaPeer::DATABASE_NAME); $criteria->add(AppBlogsMultimediaPeer::ID, $pks, Criteria::IN); $objs = AppBlogsMultimediaPeer::doSelect($criteria, $con); } return $objs; }
/** * 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 = AppBlogsMultimediaPeer::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->setDesc($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setUrl($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDate($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setSiteId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setActiu($arr[$keys[6]]); } }
private function GUARDA_IMATGES($images, $descripcions, $entry_id) { foreach ($images as $K => $I) { if ($I['error'] == 0) { $FOM = AppBlogsMultimediaPeer::initialize(0, $this->IDS); $OO = $FOM->getObject(); $OO->setName($I['name']); $OO->setDate(date('Y-m-d', time())); $OO->setDesc($descripcions[$K]); $OO->setUrl(''); $OO->save(); $extensio = $this->file_extension($I['name']); $nom = $entry_id . '-' . $OO->getId() . $extensio; move_uploaded_file($I['tmp_name'], OptionsPeer::getString('SF_WEBSYSROOT', $this->IDS) . 'images/blogs/' . $nom); $OO->setUrl($nom); $OO->save(); $FOME = AppBlogMultimediaEntriesPeer::initialize($entry_id, $OO->getId()); $FOME->getObject()->save(); } } }
/** * Selects a collection of AppBlogMultimediaEntries objects pre-filled with all related objects except AppBlogsEntries. * * @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 doSelectJoinAllExceptAppBlogsEntries(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; AppBlogsMultimediaPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (AppBlogsMultimediaPeer::NUM_COLUMNS - AppBlogsMultimediaPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(AppBlogMultimediaEntriesPeer::MULTIMEDIA_ID, AppBlogsMultimediaPeer::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 AppBlogsMultimedia rows $key2 = AppBlogsMultimediaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = AppBlogsMultimediaPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = AppBlogsMultimediaPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); AppBlogsMultimediaPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (AppBlogMultimediaEntries) to the collection in $obj2 (AppBlogsMultimedia) $obj2->addAppBlogMultimediaEntries($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Get the associated AppBlogsMultimedia object * * @param PropelPDO Optional Connection object. * @return AppBlogsMultimedia The associated AppBlogsMultimedia object. * @throws PropelException */ public function getAppBlogsMultimedia(PropelPDO $con = null) { if ($this->aAppBlogsMultimedia === null && $this->multimedia_id !== null) { $this->aAppBlogsMultimedia = AppBlogsMultimediaPeer::retrieveByPk($this->multimedia_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->aAppBlogsMultimedia->addAppBlogMultimediaEntriess($this); */ } return $this->aAppBlogsMultimedia; }
/** * 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); } }