first commit
This commit is contained in:
166
apps/backend/modules/stProductGroup/actions/actions.class.php
Normal file
166
apps/backend/modules/stProductGroup/actions/actions.class.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stProductGroup
|
||||
*
|
||||
* Ten plik należy do aplikacji stProductGroup opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stProductGroup
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: actions.class.php 17601 2012-03-30 11:05:39Z krzysiek $
|
||||
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>, Paweł Byszewski <pawel.byszewski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Akcje grupy produktów.
|
||||
*
|
||||
* @package stProductGroup
|
||||
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>, Paweł Byszewski <pawel.byszewski@sote.pl>
|
||||
*/
|
||||
|
||||
class stProductGroupActions extends autostProductGroupActions
|
||||
{
|
||||
protected $configGroup;
|
||||
|
||||
public function executeDelete()
|
||||
{
|
||||
ProductGroupPeer::cleanCache();
|
||||
parent::executeDelete();
|
||||
}
|
||||
|
||||
public function executeProductAddGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
parent::executeProductAddGroup();
|
||||
}
|
||||
catch (sfStopException $e)
|
||||
{
|
||||
ProductGroupPeer::cleanCache();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function executeProductRemoveGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
parent::executeProductRemoveGroup();
|
||||
}
|
||||
catch (sfStopException $e)
|
||||
{
|
||||
ProductGroupPeer::cleanCache();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addProductFiltersCriteria($c)
|
||||
{
|
||||
parent::addProductFiltersCriteria($c);
|
||||
|
||||
if (isset($this->filters['list_image']) && $this->filters['list_image'] !== '')
|
||||
{
|
||||
$c->add(ProductPeer::OPT_IMAGE, null, $this->filters['list_image'] ? Criteria::ISNOTNULL : Criteria::ISNULL);
|
||||
}
|
||||
|
||||
if (isset($this->filters['list_assigned']) && $this->filters['list_assigned'] !== '')
|
||||
{
|
||||
$c->addJoin(ProductPeer::ID, sprintf("%s AND %s = %d", ProductGroupHasProductPeer::PRODUCT_ID, ProductGroupHasProductPeer::PRODUCT_GROUP_ID, $this->forward_parameters['product_group_id']), Criteria::LEFT_JOIN);
|
||||
|
||||
if ($this->filters['list_assigned'])
|
||||
{
|
||||
$c->add(ProductGroupHasProductPeer::ID, null, Criteria::ISNOTNULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$c->add(ProductGroupHasProductPeer::ID, null, Criteria::ISNULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveConfig()
|
||||
{
|
||||
parent::saveConfig();
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
|
||||
protected function saveProductGroup($product_group)
|
||||
{
|
||||
if (!$this->getRequest()->hasErrors() && $this->hasRequestParameter('product_group[delete_image]'))
|
||||
{
|
||||
$currentFile = sfConfig::get('sf_upload_dir') . "/product_group/" . $product_group->getImage();
|
||||
$product_group->setImage('');
|
||||
if (is_file($currentFile))
|
||||
{
|
||||
unlink($currentFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->getRequest()->hasErrors() && $this->hasRequestParameter('product_group[label]'))
|
||||
{
|
||||
$product_group->setLabel($this->getRequestParameter('product_group[label]'));
|
||||
}
|
||||
|
||||
parent::saveProductGroup($product_group);
|
||||
|
||||
$this->saveProductGroupImage($product_group);
|
||||
|
||||
ProductGroupPeer::cleanCache();
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
|
||||
protected function saveProductGroupImage($product_group)
|
||||
{
|
||||
if ($this->getRequest()->getFileError('product_group[image]') == UPLOAD_ERR_OK)
|
||||
{
|
||||
$filename = $this->getRequest()->getFileName('product_group[image]');
|
||||
|
||||
// dodaj zdjecie
|
||||
if (!$this->getRequest()->hasErrors() && $this->getRequest()->getFileSize('product_group[image]'))
|
||||
{
|
||||
$currentFile = sfConfig::get('sf_upload_dir') . "/product_group/" . $filename;
|
||||
|
||||
if (is_file($currentFile))
|
||||
{
|
||||
unlink($currentFile);
|
||||
}
|
||||
|
||||
$this->getRequest()->moveFile('product_group[image]', sfConfig::get('sf_upload_dir') . "/product_group/" . $filename);
|
||||
|
||||
$product_group->setImage($filename);
|
||||
}
|
||||
|
||||
$product_group->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function executeFixOptProductGroup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function addFiltersCriteria($c)
|
||||
{
|
||||
$c->add(ProductGroupPeer::FROM_BASKET_VALUE, null, Criteria::ISNULL);
|
||||
|
||||
parent::addFiltersCriteria($c);
|
||||
}
|
||||
|
||||
protected function getProductGroupOrCreate($id = 'id')
|
||||
{
|
||||
$productGroup = parent::getProductGroupOrCreate($id);
|
||||
|
||||
if ($productGroup->getProductGroup() != 'NEW')
|
||||
{
|
||||
$this->hideField('new_type');
|
||||
$this->hideField('new_product_date');
|
||||
}
|
||||
|
||||
return $productGroup;
|
||||
}
|
||||
}
|
||||
105
apps/backend/modules/stProductGroup/actions/components.class.php
Normal file
105
apps/backend/modules/stProductGroup/actions/components.class.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stProductGroup
|
||||
*
|
||||
* Ten plik należy do aplikacji stProductGroup opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stProductGroup
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: components.class.php 6385 2010-07-13 13:12:38Z krzysiek $
|
||||
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Komponenty stProductGroup
|
||||
*
|
||||
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>
|
||||
*
|
||||
* @package stProductGroup
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stProductGroupComponents extends autoStProductGroupComponents
|
||||
{
|
||||
/**
|
||||
* Dostarcza tablicę dla wyboru domyślnych wartości grup strony
|
||||
*/
|
||||
public function executeDefaultProductGroup()
|
||||
{
|
||||
$i18n = sfContext::getInstance()->getI18N();
|
||||
|
||||
$configs=array(
|
||||
0=>"default_product_group.yml",
|
||||
1=>"user_product_group.yml"
|
||||
);
|
||||
|
||||
foreach ($configs as $config_id => $config_name){
|
||||
|
||||
// pobiera wartości domyślne dla grup produktu z pliku konfiguracyjnego
|
||||
$fileymlRoot = sfConfig::get('sf_app_module_dir'). DIRECTORY_SEPARATOR. 'stProductGroup' . DIRECTORY_SEPARATOR . sfConfig::get('sf_config_dir_name') . DIRECTORY_SEPARATOR . $config_name;
|
||||
|
||||
$yml = sfYaml::load($fileymlRoot);
|
||||
|
||||
if ($config_id==0){
|
||||
|
||||
$default_product_group = $yml['product_group'];
|
||||
|
||||
}elseif(isset($yml['product_group'])){
|
||||
|
||||
$user_product_group = $yml['product_group'];
|
||||
|
||||
}else{
|
||||
|
||||
$user_product_group = array();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($default_product_group as $system_name=>$name){
|
||||
|
||||
$default_product_group[$system_name] = $i18n->__($name);
|
||||
|
||||
}
|
||||
|
||||
$default_product_group = array_merge($default_product_group,$user_product_group);
|
||||
|
||||
$chosen_default_product_group = $this->getChosenDefaultProductGroup($this->getRequestParameter("id"));
|
||||
|
||||
$this->default_product_group = (array_diff_key($default_product_group, $chosen_default_product_group));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera już wybrane wartości domyślne
|
||||
*
|
||||
* @param integer id edytowanej strony $id
|
||||
* @return array tablicę z wybranymi już wcześniej wartościami
|
||||
*/
|
||||
private function getChosenDefaultProductGroup($id)
|
||||
{
|
||||
$c = new Criteria();
|
||||
if ($id)
|
||||
{
|
||||
$c->add(ProductGroupPeer::ID, $id, Criteria::NOT_EQUAL);
|
||||
}
|
||||
$product_groups = ProductGroupPeer::doSelect($c);
|
||||
$chosen_default_product_group=array();
|
||||
foreach ($product_groups as $product_group)
|
||||
{
|
||||
if($product_group->getProductGroup())
|
||||
{
|
||||
if ($product_group->getProductGroup() != 'NONE')
|
||||
{
|
||||
array_push($chosen_default_product_group,$product_group->getProductGroup());
|
||||
}
|
||||
}
|
||||
}
|
||||
$chosen_default_product_group=array_flip($chosen_default_product_group);
|
||||
return $chosen_default_product_group;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user