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
}
}

View File

@@ -0,0 +1,3 @@
all:
.layout:
name: layout3

View File

@@ -0,0 +1,37 @@
<?php
st_theme_use_stylesheet('stProductsComparePlugin.css');
$smarty->assign("compare_product", $compareProduct);
if($compareProduct)
{
$smarty->assign("add_product_to_compare", content_tag('a', __("Dodaj produkt do porównania"), array('href' => '#', 'class' => 'compare_product_link add')));
}
else
{
$smarty->assign("delete_product_from_compare", content_tag('a', __("Usuń produkt z porównania"), array('href' => '#', 'class' => 'compare_product_link remove')));
}
$smarty->assign("products_compare_array",$productsToCompareArray);
if($productsToCompareArray)
{
$smarty->assign("product_compare", link_to( __('Porównaj produkty', array()).' ('.count($productsToCompareArray).')', 'productsCompare', array() ));
}
$smarty->display("product_compare_button.html");
?>
<script type="text/javascript">
jQuery(function($){
$('.compare_product_link').click(function(event) {
if ($(this).hasClass('add'))
{
$('#st_component-st_products_compare_plugin-product_compare').load('<?php echo url_for('productsCompare/addProductToCompare?id='.$productId) ?>');
}
else
{
$('#st_component-st_products_compare_plugin-product_compare').load('<?php echo url_for('productsCompare/removeProductFromCompare?id='.$productId) ?>');
}
event.preventDefault();
});
});
</script>

View File

@@ -0,0 +1,4 @@
<?php
$smarty->assign("compare_button_add",st_get_component('stProductsCompareFrontend', 'productCompareButton'));
$smarty->display("product_compare_add_product.html");
?>

View File

@@ -0,0 +1,30 @@
<?php
use_helper('stProductImage', 'stCurrency', 'stUrl');
st_theme_use_stylesheet('stProductsComparePlugin.css');
$smarty->assign("products_compare", $productsWithoutTemplate);
$smarty->assign("show_price", $showPrice);
if($productsWithoutTemplateOn)
{
$results = array();
foreach ($productsWithoutTemplate as $product)
{
$row['photo'] = st_link_to(st_product_image_tag($product, 'thumb'), 'stProduct/show?id='.$product->getId());
$row['delete'] = st_link_to(__('usuń'), 'productsCompare/removeProductInCompare?id='.$product->getId());
$row['delete_link'] = st_url_for('productsCompare/removeProductInCompare?id='.$product->getId());
$row['name'] = $product->getName();
is_object($product->getProducer()) ? $row['producer'] = $product->getProducer()->getName() : $row['producer'] = '-';
$row['price_netto'] = $product->getPriceNetto(true);
$row['price_brutto'] = $product->getPriceBrutto(true);
$row['hide_price'] = $product->getHidePrice();
$row['vat'] = $product->getVat();
$row['instance'] = $product;
$results[] = $row;
}
$smarty->assign('results', $results);
}
$smarty->assign("hasLastViewedProduct", $hasLastViewedProduct);
$smarty->assign("lastViewedProduct", st_link_to(__('Wróć do ostatnio oglądanego produktu'), $lastViewedProduct['link']));
$smarty->assign("last_viewed_link", st_url_for($lastViewedProduct['link']));
$smarty->display('product_compare_index.html');
?>

View File

@@ -0,0 +1,4 @@
<?php
$smarty->assign("compare_button_remove",st_get_component('stProductsCompareFrontend', 'productCompareButton'));
$smarty->display("product_compare_remove_product.html");
?>

View File

@@ -0,0 +1,13 @@
<div id="st_component-st_products_compare_plugin-product_compare">
{if $compare_product}
<div id="st_button-product_compare_add" style="overflow:hidden;">
{$add_product_to_compare}
</div>
{/if}
{if $products_compare_array}
<div id="st_button-product_compare_run">
{$product_compare}
</div>
{/if}
</div>

View File

@@ -0,0 +1,84 @@
{if $products_compare}
<table>
<tr>
<td align="center" id="photo_first"></td>
{foreach key=row item=product from=$results}
<td align="center" id="photo">
<div id="box_photo">
{$product.photo}
</div>
<div id="button_del">
<div id="button_del_middle">
<div id="button_del_right">
{$product.delete}
</div>
</div>
</div>
</td>
{/foreach}
</tr>
<tr onmouseover="this.style.background='#f7f7f7'" onmouseout="this.style.background='#ffffff'">
<td class="name">{__ text="Nazwa"}:</td>
{foreach key=row item=product from=$results}
<td class="value">
{$product.name}
</td>
{/foreach}
</tr>
<tr onmouseover="this.style.background='#f7f7f7'" onmouseout="this.style.background='#ffffff'">
<td class="name">{__ text="Producent"}:</td>
{foreach key=row item=product from=$results}
<td class="value">
{$product.producer}
</td>
{/foreach}
</tr>
{if $show_price}
<tr onmouseover="this.style.background='#f7f7f7'" onmouseout="this.style.background='#ffffff'">
<td class="name">{__ text="Cena netto"}:</td>
{foreach key=row item=product from=$results}
<td class="value">
{if !$product.hide_price}
{$product.price_netto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr onmouseover="this.style.background='#f7f7f7'" onmouseout="this.style.background='#ffffff'">
<td class="name">{__ text="Cena brutto"}:</td>
{foreach key=row item=product from=$results}
<td class="value">
{if !$product.hide_price}
{$product.price_brutto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr onmouseover="this.style.background='#f7f7f7'" onmouseout="this.style.background='#ffffff'">
<td class="name">{__ text="VAT"}:</td>
{foreach key=row item=product from=$results}
<td class="value">
{if !$product.hide_price}
{$product.vat}%
{else}
-
{/if}
</td>
{/foreach}
</tr>
{/if}
</table>
{else}
<h2>{__ text="Brak produktów do porównania."}</h2>
{if $hasLastViewedProduct}
<div id="st_product_compare-back_button" class="st_button st_align-left">
<div class="st_button-left">
{$lastViewedProduct}
</div>
</div>
{/if}
{/if}

View File

@@ -0,0 +1,13 @@
<div id="st_component-st_products_compare_plugin-product_compare">
{if $compare_product}
<div id="st_button-product_compare_add" style="overflow:hidden;">
{$add_product_to_compare}
</div>
{/if}
{if $products_compare_array}
<div id="st_button-product_compare_run">
{$product_compare}
</div>
{/if}
</div>

View File

@@ -0,0 +1,145 @@
{literal}
<script type="text/javascript">
jQuery(function ($)
{
function equalHeight(group)
{
tallest = 0;
group.each(function() {
$(this).css("height","auto");
thisHeight = $(this).height();
if(thisHeight > tallest) {
tallest = thisHeight+16;
}
});
group.height(tallest);
}
$(window).load(function() {
equalHeight($("#products_compare .td_name"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_producer"));
});
$(window).load(function() {
equalHeight($("#products_compare .tr_price_netto"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_price_brutto"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_vat"));
});
});
</script>
{/literal}
{set layout="one_column_layout"}
<div id="product_compare_index" class="box roundies">
<div class="title">
<h2>{__ text="Porównaj produkty"}</h2>
</div>
{if $products_compare}
<div id="products_compare_table_params">
<table id="products_compare">
<tr>
<td id="photo_first"></td>
</tr>
<tr>
<td class="name td_name">{__ text="Nazwa"}</td>
</tr>
<tr>
<td class="name td_producer">{__ text="Producent"}</td>
</tr>
{if $show_price}
<tr>
<td class="name tr_price_netto">{__ text="Cena netto"}</td>
</tr>
<tr>
<td class="name td_price_brutto">{__ text="Cena brutto"}</td>
</tr>
<tr>
<td class="name td_vat">{__ text="VAT"}</td>
</tr>
{/if}
</table>
</div>
<div id="products_compare_table_values">
<table id="products_compare">
<tr>
{foreach key=row item=product from=$results}
<td align="center" id="photo">
<div id="box_photo">
<a class="delete_button" href="{$product.delete_link}"><img src="/images/frontend/theme/default2/stProductsComparePlugin/delete.gif" /></a>
<div class="image">{$product.photo}</div>
</div>
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_name">
{$product.name}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_producer">
{$product.producer}
</td>
{/foreach}
</tr>
{if $show_price}
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value tr_price_netto">
{if !$product.hide_price}
{$product.price_netto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_price_brutto">
{if !$product.hide_price}
{$product.price_brutto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_vat">
{if !$product.hide_price}
{$product.vat}%
{else}
-
{/if}
</td>
{/foreach}
</tr>
{/if}
</table>
</div>
{else}
<p>{__ text="Brak produktów do porównania."}</hp>
{if $hasLastViewedProduct}
<div id="st_product_compare-back_button" class="st_button st_align-left">
<div class="st_button-left buttons">
{$lastViewedProduct}
</div>
</div>
{/if}
{/if}
<div class="clear"></div>
</div>

View File

@@ -0,0 +1,13 @@
<div id="st_component-st_products_compare_plugin-product_compare">
{if $compare_product}
<div id="st_button-product_compare_add" style="overflow:hidden;">
{$add_product_to_compare}
</div>
{/if}
{if $products_compare_array}
<div id="st_button-product_compare_run">
{$product_compare}
</div>
{/if}
</div>

View File

@@ -0,0 +1,145 @@
{literal}
<script type="text/javascript">
jQuery(function ($)
{
function equalHeight(group)
{
tallest = 0;
group.each(function() {
$(this).css("height","auto");
thisHeight = $(this).height();
if(thisHeight > tallest) {
tallest = thisHeight+16;
}
});
group.height(tallest);
}
$(window).load(function() {
equalHeight($("#products_compare .td_name"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_producer"));
});
$(window).load(function() {
equalHeight($("#products_compare .tr_price_netto"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_price_brutto"));
});
$(window).load(function() {
equalHeight($("#products_compare .td_vat"));
});
});
</script>
{/literal}
{set layout="one_column"}
<div id="product_compare_index" class="box roundies">
<div class="title">
<h2>{__ text="Porównaj produkty"}</h2>
</div>
{if $products_compare}
<div id="products_compare_table_params">
<table id="products_compare">
<tr>
<td id="photo_first"></td>
</tr>
<tr>
<td class="name td_name">{__ text="Nazwa"}</td>
</tr>
<tr>
<td class="name td_producer">{__ text="Producent"}</td>
</tr>
{if $show_price}
<tr>
<td class="name tr_price_netto">{__ text="Cena netto"}</td>
</tr>
<tr>
<td class="name td_price_brutto">{__ text="Cena brutto"}</td>
</tr>
<tr>
<td class="name td_vat">{__ text="VAT"}</td>
</tr>
{/if}
</table>
</div>
<div id="products_compare_table_values">
<table id="products_compare">
<tr>
{foreach key=row item=product from=$results}
<td align="center" id="photo">
<div id="box_photo">
<a class="delete_button" href="{$product.delete_link}"><img src="/images/frontend/theme/default2/stProductsComparePlugin/delete.gif" /></a>
<div class="image">{$product.photo}</div>
</div>
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_name">
{$product.name}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_producer">
{$product.producer}
</td>
{/foreach}
</tr>
{if $show_price}
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value tr_price_netto">
{if !$product.hide_price}
{$product.price_netto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_price_brutto">
{if !$product.hide_price}
{$product.price_brutto}
{else}
-
{/if}
</td>
{/foreach}
</tr>
<tr class="rowHover">
{foreach key=row item=product from=$results}
<td class="value td_vat">
{if !$product.hide_price}
{$product.vat}%
{else}
-
{/if}
</td>
{/foreach}
</tr>
{/if}
</table>
</div>
{else}
<p>{__ text="Brak produktów do porównania."}</hp>
{if $hasLastViewedProduct}
<div id="st_product_compare-back_button" class="st_button st_align-left">
<div class="st_button-left buttons">
{$lastViewedProduct}
</div>
</div>
{/if}
{/if}
<div class="clear"></div>
</div>