public function getTargetLang() { $c = new Criteria(); $c->add(CataloguePeer::CAT_ID, $this->getCatId()); $catalogue = CataloguePeer::doSelectOne($c); if ($catalogue) { return $catalogue->getTargetLang(); } }
public static function getTargetLangArray() { $c = new Criteria(); $catalogues = CataloguePeer::doSelect($c); foreach ($catalogues as $catalogue) { $cat_id = $catalogue->getCatId(); $cat[$cat_id] = $catalogue->getNvisible(); } return $cat; }
public function executeEdit() { $this->trans_unit = $this->getTransUnitOrCreate(); $catalogues = CataloguePeer::getCatalogues(); foreach ($catalogues as $catalogue) { $trans_unit_string = 'trans_unit_' . $catalogue->getCatId(); $cat_id = $catalogue->getCatId(); ${$trans_unit_string} = $this->getRequestParameter("trans_unit_{$cat_id}"); if (isset(${$trans_unit_string}['msg_id'])) { $msg_id = ${$trans_unit_string}['msg_id']; $c = new Criteria(); $c->add(TransUnitPeer::MSG_ID, $msg_id); $c->add(TransUnitPeer::CAT_ID, $catalogue->getCatId()); $c->add(TransUnitPeer::SOURCE, $this->trans_unit->getSource()); $trans_unit_cat = TransUnitPeer::doSelectOne($c); } if (isset($trans_unit_cat) && is_object($trans_unit_cat)) { $this->{$trans_unit_string} = $this->getTransUnitByMsgIdOrCreate($trans_unit_cat->getMsgId()); } else { $this->{$trans_unit_string} = $this->getTransUnitOrCreate(); } } if ($this->getRequest()->getMethod() == sfRequest::POST) { foreach ($catalogues as $catalogue) { $this->updateTransUnitCatIdFromRequest($catalogue->getCatId()); $trans_unit_string = 'trans_unit_' . $catalogue->getCatId(); $this->saveTransUnit($this->{$trans_unit_string}); } $this->getUser()->setFlash('notice', 'Your modifications have been saved'); if ($this->getRequestParameter('save_and_add')) { return $this->redirect('sfTransUnit/create'); } else { if ($this->getRequestParameter('save_and_list')) { return $this->redirect('sfTransUnit/list'); } else { return $this->redirect('sfTransUnit/edit?msg_id=' . $this->{$trans_unit_string}->getMsgId()); } } } else { $this->labels = $this->getLabels(); } }
/** * Get the associated Catalogue object * * @param PropelPDO Optional Connection object. * @return Catalogue The associated Catalogue object. * @throws PropelException */ public function getCatalogue(PropelPDO $con = null) { if ($this->aCatalogue === null && ($this->id_idioma !== "" && $this->id_idioma !== null)) { $c = new Criteria(CataloguePeer::DATABASE_NAME); $c->add(CataloguePeer::CAT_ID, $this->id_idioma); $this->aCatalogue = CataloguePeer::doSelectOne($c, $con); /* 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->aCatalogue->addUsuarios($this); */ } return $this->aCatalogue; }
public static function getCatalogues() { $c = new Criteria(); return CataloguePeer::doSelect($c); }
/** * 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 = CataloguePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setCatId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNvisible($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setSourceLang($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setTargetLang($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDateCreated($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setDateModified($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setAuthor($arr[$keys[7]]); } }
/** * Función que devuelve el idioma del usuario actual. * @return string, idioma del usuario actual * @version 16-02-09 * @author Ana Martín */ public static function getIdiomaUsuarioActual() { $cultura = sfContext::getInstance()->getUser()->getCulture(); $c = new Criteria(); $c->add(CataloguePeer::TARGET_LANG, $cultura); $idioma = CataloguePeer::doSelectOne($c); if ($idioma) { return $idioma->getCatId(); } else { return self::IDIOMA_DEFAULT; } /* Ana: 12-11-2008 El idioma por defecto del usuario actual solo se tiene en cuenta la primera vez que entras. Las siguientes tiene que coger la cultura que exista.*/ }
/** * 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(CataloguePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(CataloguePeer::DATABASE_NAME); $criteria->add(CataloguePeer::CAT_ID, $pks, Criteria::IN); $objs = CataloguePeer::doSelect($criteria, $con); } return $objs; }
/** * Selects a collection of TransUnit objects pre-filled with all related objects. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of TransUnit objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { foreach (sfMixer::getCallables('BaseTransUnitPeer:doSelectJoinAll:doSelectJoinAll') as $callable) { call_user_func($callable, 'BaseTransUnitPeer', $c, $con); } $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } TransUnitPeer::addSelectColumns($c); $startcol2 = TransUnitPeer::NUM_COLUMNS - TransUnitPeer::NUM_LAZY_LOAD_COLUMNS; CataloguePeer::addSelectColumns($c); $startcol3 = $startcol2 + (CataloguePeer::NUM_COLUMNS - CataloguePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(TransUnitPeer::CAT_ID), array(CataloguePeer::CAT_ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = TransUnitPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = TransUnitPeer::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 { $omClass = TransUnitPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); TransUnitPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Catalogue rows $key2 = CataloguePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CataloguePeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = CataloguePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CataloguePeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (TransUnit) to the collection in $obj2 (Catalogue) $obj2->addTransUnit($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
protected function addSortCriteria($c) { if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/catalogue/sort')) { $sort_column = CataloguePeer::translateFieldName($sort_column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME); if ($this->getUser()->getAttribute('type', null, 'sf_admin/catalogue/sort') == 'asc') { $c->addAscendingOrderByColumn($sort_column); } else { $c->addDescendingOrderByColumn($sort_column); } } }
/** * Selects a collection of Usuario objects pre-filled with all related objects except Provincia. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Usuario objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptProvincia(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } UsuarioPeer::addSelectColumns($c); $startcol2 = UsuarioPeer::NUM_COLUMNS - UsuarioPeer::NUM_LAZY_LOAD_COLUMNS; CataloguePeer::addSelectColumns($c); $startcol3 = $startcol2 + (CataloguePeer::NUM_COLUMNS - CataloguePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(UsuarioPeer::ID_IDIOMA), array(CataloguePeer::CAT_ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UsuarioPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UsuarioPeer::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 { $omClass = UsuarioPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); UsuarioPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Catalogue rows $key2 = CataloguePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CataloguePeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = CataloguePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CataloguePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Usuario) to the collection in $obj2 (Catalogue) $obj2->addUsuario($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
<?php $catalogues = CataloguePeer::getCatalogues(); echo input_hidden_tag("trans_unit[msg_id]", $trans_unit->getMsgId()); ?> <?php foreach ($catalogues as $catalogue) { $c = new Criteria(); $c->add(TransUnitPeer::CAT_ID, $catalogue->getCatId()); $c->add(TransUnitPeer::SOURCE, $trans_unit->getSource()); $trans_unit_string = 'trans_unit_' . $catalogue->getCatId(); $cat_id = $catalogue->getCatId(); ${$trans_unit_string} = TransUnitPeer::doSelectOne($c); if (${$trans_unit_string}) { $msg_id_string = 'msg_id_' . $catalogue->getCatId(); echo input_hidden_tag("{$trans_unit_string}[msg_id]", ${$trans_unit_string}->getMsgId()); } else { ${$trans_unit_string} = new TransUnit(); } echo '<h2><strong>' . $catalogue->getNvisible() . ' (' . $catalogue->getTargetLang() . ')</strong></h2>'; echo input_tag("{$trans_unit_string}[target]", ${$trans_unit_string}->getTarget(), array('style' => 'width: 480px')); echo checkbox_tag("{$trans_unit_string}[translated]", 1, ${$trans_unit_string}->getTranslated() == 1 ? 1 : 0); echo __("Translated"); echo '<br/>'; echo checkbox_tag("{$trans_unit_string}[default]", 1, ''); echo __("Set translation to source string"); /* Ana: 14-02-09 No se necesita. echo '<br/>'; echo '<br/>'; echo __("Comment");