first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,197 @@
<?php
/**
* SOTESHOP/stProductComparePlugin
*
* Ten plik należy do aplikacji stProductComparePlugin opartej na licencji (Professional License 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 stProductsComparePlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 16321 2011-12-01 10:54:02Z krzysiek $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stProductsCompareFrontendActions
*
* @package stProductsComparePlugin
* @subpackage actions
*/
class stProductsCompareFrontendActions extends stActions
{
/**
* Porówanie produktów
*/
public function executeIndex()
{
$this->checkTheme();
$this->smarty = new stSmarty($this->getModuleName());
$this->productsWithoutTemplate = array();
$this->productsWithoutTemplateOn = false;
$this->productsWithTemplateOn = false;
if ($this->getUser()->hasAttribute('productsToCompare'))
{
$productsList = $this->getUser()->getAttribute('productsToCompare');
$c = new Criteria();
$c->add(ProductPeer::ID, $productsList, Criteria::IN);
$this->productsWithoutTemplate = ProductPeer::doSelect($c);
if (count($this->productsWithoutTemplate) > 0) $this->productsWithoutTemplateOn = true;
}
$config = stConfig::getInstance(sfContext::getInstance(), array('hide_price' => stConfig::BOOL),'stProduct');
$config->load();
stEventDispatcher::getInstance()->notify(new sfEvent($this, 'stProductsCompareFrontendActions.myExecuteIndex'));
$this->showPrice = true;
if ($config->get('hide_price'))
{
$this->showPrice = false;
}
$stNavigation = stNavigation::getInstance($this->getContext());
$this->lastViewedProduct = $stNavigation->getLastViewedProduct();
$this->hasLastViewedProduct = false;
if (is_array($this->lastViewedProduct)) $this->hasLastViewedProduct = true;
// disable Fast Cache for this session if currency is different that default
stFastCacheController::disable();
}
/**
* Dodawanie produktu do sesji
*
* @param integer $productId Id produktu
*/
private function addProduct($productId)
{
$productsToCompareArray = array();
if($this->getUser()->hasAttribute('productsToCompare'))
{
$productsToCompareArray = $this->getUser()->getAttribute('productsToCompare');
}
$productsToCompareArray[$productId] = $productId;
$this->getUser()->setAttribute('productsToCompare', $productsToCompareArray);
}
/**
* Usuwanie produktu z sesji
*
* @param integer $productId Id produktu
*/
private function removeProduct($productId)
{
$productsToCompareArray = array();
if($this->getUser()->hasAttribute('productsToCompare'))
{
$productsToCompareArray = $this->getUser()->getAttribute('productsToCompare');
}
unset($productsToCompareArray[$productId]);
$this->getUser()->setAttribute('productsToCompare', $productsToCompareArray);
}
/**
* Prezentacja przycisku `dodaj` produktu w karcie produktu
*/
public function executeAddProductToCompare()
{
$this->checkTheme();
$this->smarty = new stSmarty($this->getModuleName());
if($this->getRequest()->hasParameter('id'))
{
$this->addProduct($this->getRequestParameter('id'));
}
stFastCacheController::disable();
}
/**
* Prezentacja przycisku `usuń` produktu w karcie produktu
*/
public function executeRemoveProductFromCompare()
{
$this->checkTheme();
$this->smarty = new stSmarty($this->getModuleName());
if($this->getRequest()->hasParameter('id'))
{
$this->removeProduct($this->getRequestParameter('id'));
}
}
/**
* Prezentacja przycisku `usuń` produktu na liście porównywanych produktów
*/
public function executeRemoveProductInCompare()
{
$this->checkTheme();
if($this->getRequest()->hasParameter('id'))
{
$this->removeProduct($this->getRequestParameter('id'));
}
$this->redirect('@stProductsComparePlugin');
}
/**
* Dodanie produktu do listy porównywanych produktów bez JavaScriptu
*/
public function executeAddFromInfo()
{
$this->checkTheme();
if($this->getRequest()->hasParameter('id'))
{
$this->addProduct($this->getRequestParameter('id'));
$this->redirect('product/show?id='.$this->getRequestParameter('id'));
}
$this->redirect('/');
}
/**
* Usunięcie produktu z listy porównywanych produktów bez JavaScriptu
*/
public function executeRemoveFromInfo()
{
$this->checkTheme();
if($this->getRequest()->hasParameter('id'))
{
$this->removeProduct($this->getRequestParameter('id'));
$this->redirect('product/show?id='.$this->getRequestParameter('id'));
}
$this->redirect('/');
}
private function checkTheme()
{
$theme_version = $this->getController()->getTheme()->getVersion();
if ($theme_version >= 7){
$this->getResponse()->setStatusCode(404);
$this->getResponse()->setHttpHeader('Status', '404 Not Found');
return $this->forward('stErrorFrontend', 'error404');
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* SOTESHOP/stProductComparePlugin
*
* Ten plik należy do aplikacji stProductComparePlugin opartej na licencji (Professional License 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 stProductsComparePlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: components.class.php 15469 2011-10-06 13:51:06Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Komponent stProductsCompareFrontendComponents
*
* @package stProductsComparePlugin
* @subpackage actions
*/
class stProductsCompareFrontendComponents extends sfComponents
{
/**
* Prezentacja przycisku 'dodaj'/'usuń' w karcie produktu
*/
public function executeProductCompareButton()
{
$this->smarty = new stSmarty('stProductsCompareFrontend');
$this->productId = $this->getRequestParameter('id');
if (is_object($this->product))
{
if (!$this->product->isPriceVisible())
{
return sfView::NONE;
}
$this->productId = $this->product->getId();
}
$this->productsToCompareArray = array();
$this->compareProduct = true;
if($this->getUser()->hasAttribute('productsToCompare'))
{
$this->productsToCompareArray = $this->getUser()->getAttribute('productsToCompare');
if (isset($this->productsToCompareArray[$this->productId]))
{
$this->compareProduct = false;
}
}
// disable Fast Cache for this session if currency is different that default
}
}