*/ /** * Klasa stPriceCompareComponents * * @package stPriceCompare * @subpackage actions */ class stPriceCompareComponents extends sfComponents { /** * Dodawanie produktu do porównywarek w stProduct */ public function executePriceComparesInProduct() { $priceCompares = stPriceCompare::getPriceCompares(); $this->plugin = array(); $this->pluginName = array(); if ($this->hasRequestParameter('product_id')) { $this->product_id = $this->getRequestParameter('product_id'); $this->product = ProductPeer::retrieveByPK($this->product_id); if ($this->getRequest()->getMethod() == sfRequest::POST) { foreach ($priceCompares as $pluginName => $pluginOptions) { if (class_exists($pluginOptions['peer_name'])) { $c = new Criteria(); $c->add(constant($pluginOptions['peer_name']."::PRODUCT_ID"), $this->product_id); $this->obj = call_user_func($pluginOptions['peer_name']."::doSelectOne",$c); if ($this->getRequestParameter('priceCompare['.$pluginOptions['name'].']')) { if (!is_object($this->obj)) { $class = str_replace('Peer', '', $pluginOptions['peer_name']); $this->obj = new $class; $this->obj->setProductId($this->product_id); } $this->obj->setActive($this->getRequestParameter('priceCompare['.$pluginOptions['name'].']')); $this->obj->save(); } else { if (is_object($this->obj)) { $this->obj->delete(); } } $this->setFlash('notice', 'Twoje zmiany zostały zapisane'); } } } foreach ($priceCompares as $pluginName => $pluginOptions) { /** * warunek aby dodac konfiguracje wszykich pluginow poza nie posiadających tabeli w bazie. * * @package stPriceCompare * @subpackage actions */ if (class_exists($pluginOptions['peer_name'])) { $c = new Criteria(); $c->add(constant($pluginOptions['peer_name']."::PRODUCT_ID"), $this->product_id); $this->plugin[$pluginOptions['name']] = call_user_func($pluginOptions['peer_name']."::doSelectOne",$c); $this->pluginName[$pluginOptions['name']] = $pluginName; // $module = str_replace('Plugin','Backend',$pluginName); // // $x = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$module.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true); // if (!empty($x)) // { // require($x); // } // // if ($this->getController()->componentExists($module, 'showInProduct')) // { // $this->plugin[$pluginOptions['name']] = array('moduleName' => $module, 'peer' => $this->plugin[$pluginOptions['name']]); // } } } } } }