Example #1
0
 public function executeDelete(sfWebRequest $request)
 {
     //$request->checkCSRFProtection();
     $this->forward404Unless($Config = ConfigPeer::retrieveByPk($request->getParameter('id')), sprintf('Object Config does not exist (%s).', $request->getParameter('id')));
     $Config->delete();
     $this->redirect('config/index');
 }
    public function start($attributes = array())
    {
        if (sfConfig::get('app_parser_skip_toolbar')) {
            $attributes['toolbar'] = false;
            $attributes['north'] = false;
            $attributes['west'] = false;
        }
        /**
         * TOOLBAR
         */
        if (isset($attributes['toolbar']) && is_object($attributes['toolbar']) && get_class($attributes['toolbar']) == 'afExtjsToolbar') {
            $attributes['toolbar']->end();
        } elseif ((!isset($attributes['toolbar']) || isset($attributes['toolbar']) && $attributes['toolbar'] != false) && afExtjs::getInstance()->isDesktop() == false) {
            sfProjectConfiguration::getActive()->loadHelpers(array('afExtjsToolbar'));
        }
        /**
         * NORTH PANEL
         */
        if (isset($attributes['north']) && is_array($attributes['north'])) {
            $this->addPanel('north', $attributes['north']);
        } elseif (!isset($attributes['north']) || isset($attributes['north']) && $attributes['north'] != false) {
            $this->addPanel('north', array('id' => 'north_panel', 'region' => 'north', 'height' => '32', 'border' => false, 'bodyStyle' => 'background-color:#dfe8f6;'));
        }
        /**
         * WEST PANEL
         */
        if (isset($attributes['west']) && is_array($attributes['west'])) {
            $this->addPanel('west', $attributes['west']);
        } elseif (!isset($attributes['west']) || isset($attributes['west']) && $attributes['west'] != false) {
            $logoScript = "";
            if (class_exists('ConfigPeer')) {
                $avatarLogo = ConfigPeer::get("avatar_logo", false);
            } else {
                $avatarLogo = sfConfig::get('app_avatar_logo', false);
            }
            if ($avatarLogo && file_exists(sfConfig::get('sf_web_dir') . $avatarLogo)) {
                $imagesize = getimagesize(sfConfig::get('sf_web_dir') . $avatarLogo);
                $clickAction = 'onClick="var aboutWin = null;if(aboutWin = Ext.getCmp(\'about-window\')){aboutWin.show();aboutWin.center();}" style="cursor:pointer"';
                $logo = '<div style="background-color:#d9e7f8;border-right:1px solid #99bbe8;border-left:1px solid #99bbe8;border-bottom:1px solid #99bbe8; padding:2px 0px 0px 0px; margin:0px;text-align:center;"><img id="avatar_image" ' . $clickAction . ' src="' . $avatarLogo . '"/></div>';
                $logoScript = 'var logoDiv = Ext.DomHelper.insertBefore(comp.bwrap,{tag:"div",html:"' . addslashes($logo) . '"});			
				var resize = function(comp){
					var body = comp.body, bodyHeight = body.getHeight();
					body.setHeight(bodyHeight-' . $imagesize[1] . '-3);					
				}; 
				resize(comp); 
				comp.on("bodyresize",function(comp,w,h){resize(comp);});';
            }
            $attributes_temp = array('id' => 'west_panel', 'stateful' => true, 'stateEvents' => array('afterlayout'), 'getState' => $this->afExtjs->asMethod(array("parameters" => "", "source" => "return { activeItemIndex: this.items.findIndex('id',this.layout.activeItem.id) };")), 'stateId' => 'west_panel', 'region' => 'west', 'title' => 'Navigation', 'width' => '255', 'minWidth' => '255', 'split' => 'true', 'layoutConfig' => array('animate' => 'true'), 'collapsible' => 'true', 'layout' => 'accordion', 'listeners' => '{"beforerender": function(){var state=Ext.state.Manager.get("west_panel");if(!state){this.activeItem = this.findById("profile");}else{this.activeItem = state.activeItemIndex;}},"render":function(comp){' . $logoScript . '}}');
            if (!isset($this->attributes['viewport']['west_panel'])) {
                $this->attributes['viewport']['west_panel'] = $attributes_temp;
            } else {
                $this->attributes['viewport']['west_panel'] = array_merge($attributes_temp, $this->attributes['viewport']['west_panel']);
            }
            unset($attributes_temp);
        } elseif (isset($attributes['west']) && $attributes['west'] == false) {
            $this->attributes['viewport']['west_panel'] = false;
        }
        parent::start($attributes);
    }
 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');
 }
 /**
  * Selects a collection of ShopVitrin objects pre-filled with all related objects except Shop.
  *
  * @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 ShopVitrin objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptShop(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);
     }
     ShopVitrinPeer::addSelectColumns($criteria);
     $startcol2 = ShopVitrinPeer::NUM_COLUMNS - ShopVitrinPeer::NUM_LAZY_LOAD_COLUMNS;
     ConfigPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (ConfigPeer::NUM_COLUMNS - ConfigPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(ShopVitrinPeer::CONFIG_ID, ConfigPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseShopVitrinPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ShopVitrinPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ShopVitrinPeer::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 = ShopVitrinPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ShopVitrinPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Config rows
         $key2 = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = ConfigPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = ConfigPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 ConfigPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (ShopVitrin) to the collection in $obj2 (Config)
             $obj2->addShopVitrin($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Example #5
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(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
         $criteria->add(ConfigPeer::KEY, $pks, Criteria::IN);
         $objs = ConfigPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #6
0
 /**
  * Returns the number of related Config objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Config objects.
  * @throws     PropelException
  */
 public function countConfigs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ModelPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collConfigs === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(ConfigPeer::MODEL_ID, $this->id);
             $count = ConfigPeer::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(ConfigPeer::MODEL_ID, $this->id);
             if (!isset($this->lastConfigCriteria) || !$this->lastConfigCriteria->equals($criteria)) {
                 $count = ConfigPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collConfigs);
             }
         } else {
             $count = count($this->collConfigs);
         }
     }
     return $count;
 }
 public function execute($request)
 {
     //get params
     $this->brand = $this->getRequestParameter('brand');
     $this->series = $this->getRequestParameter('series');
     $this->model = $this->getRequestParameter('model');
     $this->configId = $this->getRequestParameter('config_id');
     //get image files
     $this->mainImage = $this->getRequest()->getFiles('main_image');
     $this->otherImages = $this->getRequest()->getFiles('other_images');
     //print_r($this->otherImages);
     //exit ();
     //load/create series and model
     if (SeriesPeer::isNew($this->series)) {
         //create new series
         $seriesObj = new Series();
         $seriesObj->setSeriesName($this->series);
         $seriesObj->setBrandId($this->brand);
         $seriesObj->save();
         //create new model
         $modelObj = new Model();
         $modelObj->setModelName($this->model);
         $modelObj->setSeries($seriesObj);
         $modelObj->save();
     } else {
         //load series object
         $seriesObj = SeriesPeer::getSeriesByName($this->series);
         if (ModelPeer::isNew($this->model)) {
             //create new model
             $modelObj = new Model();
             $modelObj->setModelName($this->model);
             $modelObj->setSeries($seriesObj);
             $modelObj->save();
         } else {
             $modelObj = ModelPeer::getModelByName($this->model);
         }
     }
     //////////////////////
     if (($this->isNew = $this->getRequestParameter('is_new')) == 'true') {
         //create new config
         $config = new Config();
         $config->setConfigName($this->getRequestParameter('name'));
         $config->setModel($modelObj);
         $config->save();
         //load config fields
         $configFields = ConfigFieldPeer::doSelect(new Criteria());
         foreach ($configFields as $configField) {
             //get param
             if ($this->hasRequestParameter("field_" . $configField->getId())) {
                 //if (strlen($this->getRequestParameter("field_".$configField->getId())) > 0 )
                 //{
                 $fieldValue = new FieldValue();
                 $fieldValue->setConfig($config);
                 $fieldValue->setFieldId($configField->getId());
                 $fieldValue->setValue($this->getRequestParameter("field_" . $configField->getId()));
                 $fieldValue->save();
                 //}
             }
         }
     } else {
         //load config
         $config = ConfigPeer::retrieveByPK($this->configId);
         //$config->setConfigName($this->getRequestParameter('name'));
         $config->setModel($modelObj);
         $config->save();
         //load config fields
         $configFields = ConfigFieldPeer::doSelect(new Criteria());
         foreach ($configFields as $configField) {
             //get param
             if ($this->hasRequestParameter("field_" . $configField->getId())) {
                 //if (strlen($this->getRequestParameter("field_".$configField->getId())) > 0 )
                 //{
                 $fieldValue = FieldValuePeer::getFieldValue($configField->getId(), $config->getId());
                 $fieldValue->setValue($this->getRequestParameter("field_" . $configField->getId()));
                 $fieldValue->save();
                 //}
             }
         }
     }
     //save main image
     MediaPeer::saveMedia($this->mainImage, $modelObj->getId(), MediaPeer::IMAGE, 'Model', true);
     //save other images
     foreach ($this->otherImages as $image) {
         MediaPeer::saveMedia($image, $modelObj->getId(), MediaPeer::IMAGE, 'Model', false);
     }
     if (($saveAndNew = $this->getRequestParameter('save_and_new')) == 'true') {
         $this->redirect('config/newconfig');
     } else {
         $this->redirect('config/editconfig?id=' . $config->getId());
     }
 }
 public function executeShow(sfWebRequest $request)
 {
     $this->config = ConfigPeer::retrieveByPk($request->getParameter('id'));
     $this->forward404Unless($this->config);
 }
 /**
  * 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 = ConfigPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setParam($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setValue($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setIsActive($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setId($arr[$keys[5]]);
     }
 }
Example #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 = ConfigPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setKey($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setValue($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setModified($arr[$keys[2]]);
     }
 }
Example #11
0
 public function executeProcessConfigForm(sfWebRequest $request)
 {
     $data = $request->getGetParameters();
     $config = new Config();
     if ($data['cid'] == '-1') {
         // New Config
         $config->setModelId($data['mid']);
         $config->save();
         foreach ($data as $field => $value) {
             if ($field != 'cid' && $field != 'mid') {
                 $fv = new FieldValue();
                 $fv->setConfigId($config->getId());
                 $fv->setFieldId(intval($field));
                 $fv->setValue($value);
                 //echo intval($field)."\n";
                 $fv->save();
             }
         }
     } else {
         $config = ConfigPeer::retrieveByPK($data['cid']);
         foreach ($data as $field => $value) {
             if ($field != 'cid' && $field != 'mid') {
                 $c = new Criteria();
                 $c->add(FieldValuePeer::FIELD_ID, intval($field));
                 $c->add(FieldValuePeer::CONFIG_ID, $config->getId());
                 $fv = FieldValuePeer::doSelectOne($c);
                 if (!is_object($fv)) {
                     $fv = new FieldValue();
                     $fv->setConfigId($config->getId());
                     $fv->setFieldId(intval($field));
                 }
                 $fv->setValue($value);
                 //echo intval($fv->getValue())."#";
                 //print_r($fv, FALSE);
                 $fv->save();
             }
         }
     }
     $this->res = $config->getId();
 }
Example #12
0
 /**
  * Get the associated Config object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Config The associated Config object.
  * @throws     PropelException
  */
 public function getConfig(PropelPDO $con = null)
 {
     if ($this->aConfig === null && ($this->config_id !== "" && $this->config_id !== null)) {
         $this->aConfig = ConfigPeer::retrieveByPk($this->config_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->aConfig->addAdss($this);
         		 */
     }
     return $this->aConfig;
 }
Example #13
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 = ConfigPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setModelId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setConfigName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setWeight($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setUpdatedAt($arr[$keys[5]]);
     }
 }