Пример #1
0
 public function executeIndex(sfWebRequest $request)
 {
     //get request parameters
     $this->selectedBrand = $this->getRequestParameter('brand');
     $this->selectedSeries = $this->getRequestParameter('series');
     $this->selectedModel = $this->getRequestParameter('model');
     $cConfig = new Criteria();
     $cConfig->addJoin(ConfigPeer::MODEL_ID, ModelPeer::ID);
     $cConfig->addJoin(ModelPeer::SERIES_ID, SeriesPeer::ID);
     $cConfig->addJoin(SeriesPeer::BRAND_ID, BrandPeer::ID);
     if ($this->selectedBrand) {
         $cConfig->add(BrandPeer::ID, $this->selectedBrand);
     }
     if ($this->selectedSeries) {
         $cConfig->add(SeriesPeer::SERIES_NAME, $this->selectedSeries, Criteria::LIKE);
     }
     if ($this->selectedModel) {
         $cConfig->add(ModelPeer::MODEL_NAME, $this->selectedModel, Criteria::LIKE);
     }
     //$this->Configs = ConfigPeer::doSelect($cConfig);
     //paginatiom
     $pager = new sfPropelPager('Config', 15);
     $pager->setCriteria($cConfig);
     $pager->setPage($this->getRequestParameter('page'));
     $pager->init();
     $this->pager = $pager;
     //get config columns
     $c = new Criteria();
     $c->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT);
     $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect($c);
     //get brands
     $cBrand = new Criteria();
     $this->brands = BrandPeer::doSelect($cBrand);
 }
Пример #2
0
 public function execute($request)
 {
     /*$this->form = new sfForm();
       $this->form->setWidgets(array(
           'brand'    => new sfWidgetFormInputText(),
           'series'    => new sfWidgetFormInputText(),
           'model'    => new sfWidgetFormInputText(),
           
           
           'id'         => new sfWidgetFormInputHidden(),
           'cpu'        => new sfWidgetFormInputText(),
             'cache'      => new sfWidgetFormInputText(),
             'hdd'        => new sfWidgetFormInputText(),
             'ram'        => new sfWidgetFormInputText(),
             'graphic'    => new sfWidgetFormInputText(),
             'display'    => new sfWidgetFormInputText(),
             'weight'     => new sfWidgetFormInputText(),
             'optic'      => new sfWidgetFormInputText(),
             'network'    => new sfWidgetFormInputText(),
             'wifi'       => new sfWidgetFormInputText(),
             'wwan'       => new sfWidgetFormInputText(),
             'size'       => new sfWidgetFormInputText(),
             'battery'    => new sfWidgetFormInputText(),
             'os'         => new sfWidgetFormInputText(),
             'created_at' => new sfWidgetFormDateTime(),
             'updated_at' => new sfWidgetFormDateTime(),
         ));*/
     $this->isNew = true;
     //load config
     $this->config = new Config();
     $this->configId = null;
     //load model
     $this->model = new Model();
     //load other configuration for this model
     $this->configs = $this->model->getConfigs();
     //load series
     $this->series = new Series();
     //get brands
     $cBrand = new Criteria();
     $this->brands = BrandPeer::doSelect($cBrand);
     $this->selectedBrand = null;
     $cFieldCat = new Criteria();
     $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT);
     $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat);
     $this->setTemplate('config');
 }
Пример #3
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     //tabs array, we add tab items to it
     $this->tabs = array();
     //get available brands
     $this->brands = BrandPeer::doSelect(new Criteria());
     $tabIndex = 1;
     $this->tabs[$tabIndex]['title'] = 'برند';
     $this->tabs[$tabIndex]['content'] = $this->renderBrands($this->brands);
     ++$tabIndex;
     //get field sets
     $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect(new Criteria());
     foreach ($this->configFieldCategories as $configFieldCategory) {
         $this->tabs[$tabIndex]['title'] = $configFieldCategory->getName();
         $this->tabs[$tabIndex]['content'] = $this->renderFieldCategory($configFieldCategory);
         ++$tabIndex;
     }
 }
Пример #4
0
 public function makeConfigName()
 {
     $configName = "C: ";
     $fieldCats = array(1, 2);
     foreach ($fieldCats as $cid) {
         $fieldCat = ConfigFieldCategoryPeer::retrieveByPK($cid);
         $fields = $fieldCat->getFields();
         foreach ($fields as $f) {
             $cFieldValues = new Criteria();
             $cFieldValues->add(FieldValuePeer::CONFIG_ID, $this->getId());
             $cFieldValues->add(FieldValuePeer::FIELD_ID, $f->getId());
             $fieldValues = FieldValuePeer::doSelect($cFieldValues);
             foreach ($fieldValues as $fieldValue) {
                 $configName .= $fieldValue->getValue() . " ";
             }
         }
         $configName .= '-';
     }
     return $configName;
 }
Пример #5
0
 public function execute($request)
 {
     $this->isNew = false;
     //load config
     $this->config = ConfigPeer::retrieveByPK($this->configId = $this->getRequestParameter('id'));
     $this->forward404Unless($this->config);
     $this->configId = $this->config->getId();
     //load model
     $this->model = $this->config->getModel();
     //load other configuration for this model
     $this->configs = $this->model->getConfigs();
     //load series
     $this->series = $this->model->getSeries();
     //get brands
     $cBrand = new Criteria();
     $this->brands = BrandPeer::doSelect($cBrand);
     $this->selectedBrand = $this->series->getBrandId();
     $cFieldCat = new Criteria();
     $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT);
     $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat);
     $this->setTemplate('config');
 }
Пример #6
0
 /**
  * Selects a collection of ConfigField 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 ConfigField 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);
     }
     ConfigFieldPeer::addSelectColumns($criteria);
     $startcol2 = ConfigFieldPeer::NUM_COLUMNS - ConfigFieldPeer::NUM_LAZY_LOAD_COLUMNS;
     ConfigFieldCategoryPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (ConfigFieldCategoryPeer::NUM_COLUMNS - ConfigFieldCategoryPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(ConfigFieldPeer::CATEGORY_ID, ConfigFieldCategoryPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseConfigFieldPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ConfigFieldPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ConfigFieldPeer::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 = ConfigFieldPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ConfigFieldPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined ConfigFieldCategory rows
         $key2 = ConfigFieldCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = ConfigFieldCategoryPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = ConfigFieldCategoryPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 ConfigFieldCategoryPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (ConfigField) to the collection in $obj2 (ConfigFieldCategory)
             $obj2->addConfigField($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(ConfigFieldCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ConfigFieldCategoryPeer::DATABASE_NAME);
         $criteria->add(ConfigFieldCategoryPeer::ID, $pks, Criteria::IN);
         $objs = ConfigFieldCategoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Пример #8
0
 public function getCategory()
 {
     return ConfigFieldCategoryPeer::retrieveByPK($this->getCategoryId());
 }
Пример #9
0
 /**
  * Get the associated ConfigFieldCategory object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     ConfigFieldCategory The associated ConfigFieldCategory object.
  * @throws     PropelException
  */
 public function getConfigFieldCategory(PropelPDO $con = null)
 {
     if ($this->aConfigFieldCategory === null && ($this->category_id !== "" && $this->category_id !== null)) {
         $this->aConfigFieldCategory = ConfigFieldCategoryPeer::retrieveByPk($this->category_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->aConfigFieldCategory->addConfigFields($this);
         		 */
     }
     return $this->aConfigFieldCategory;
 }
Пример #10
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 = ConfigFieldCategoryPeer::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->setWeight($arr[$keys[2]]);
     }
 }
Пример #11
0
 public function executeGetConfigEditor(sfWebRequest $request)
 {
     $cid = $request->getParameter('config_id');
     if ($cid != -1) {
         $config = ConfigPeer::retrieveByPK($cid);
         $this->values = $config->getConfigFieldValues();
     } else {
         $this->values = array();
     }
     $this->cats = ConfigFieldCategoryPeer::doSelect(new Criteria());
 }