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,9 @@
<?php
if (SF_APP == 'backend') {
$dispatcher->connect('stAdminGenerator.generateStProduct', array('smMyTabsPluginListener', 'generate'));
$dispatcher->connect('autoStProductActions.postUpdateFromRequest', array('smMyTabsPluginListener', 'addUpdateMyTabs'));
}
if (SF_APP == 'frontend') {
stPluginHelper::addEnableModule('smMyTabsFrontend', 'frontend');
}

View File

@@ -0,0 +1,26 @@
edit:
display:
"Dodatkowe zakładki": [_my_tabs]
fields:
my_tabs: {name: Dodatkowe zakładki, hide_label: true}
export:
fields:
product_tab1: {name: Zakładka 1, class: smMyTabsImportExport}
product_tab2: {name: Zakładka 2, class: smMyTabsImportExport}
product_tab3: {name: Zakładka 3, class: smMyTabsImportExport}
product_tab4: {name: Zakładka 4, class: smMyTabsImportExport}
my_tab1: {name: Nazwa zakładki 1, sample: Zakładka 1, type: string}
my_tab2: {name: Nazwa zakładki 2, sample: Zakładka 2, type: string}
my_tab3: {name: Nazwa zakładki 3, sample: Zakładka 3, type: string}
my_tab4: {name: Nazwa zakładki 4, sample: Zakładka 4, type: string}
import:
fields:
product_tab1: {class: smMyTabsImportExport}
product_tab2: {class: smMyTabsImportExport}
product_tab3: {class: smMyTabsImportExport}
product_tab4: {class: smMyTabsImportExport}
my_tab1: {name: Nazwa zakładki 1, sample: Zakładka 1, type: custom}
my_tab2: {name: Nazwa zakładki 2, sample: Zakładka 2, type: custom}
my_tab3: {name: Nazwa zakładki 3, sample: Zakładka 3, type: custom}
my_tab4: {name: Nazwa zakładki 4, sample: Zakładka 4, type: custom}

View File

@@ -0,0 +1,97 @@
---
propel:
_attributes:
defaultIdMethod: native
package: plugins.smMyTabsPlugin.lib.model
st_product_has_tab1:
_attributes:
phpName: ProductHasTab1
created_at:
type: timestamp
updated_at:
type: timestamp
id:
type: INTEGER
primaryKey: true
required: true
autoIncrement: true
tab1_id:
type: INTEGER
required: true
foreignTable: st_product
foreignReference: id
onDelete: cascade
product_id:
type: INTEGER
foreignTable: st_product
foreignReference: id
onDelete: cascade
st_product_has_tab2:
_attributes:
phpName: ProductHasTab2
created_at:
type: timestamp
updated_at:
type: timestamp
id:
type: INTEGER
primaryKey: true
required: true
autoIncrement: true
tab2_id:
type: INTEGER
required: true
foreignTable: st_product
foreignReference: id
onDelete: cascade
product_id:
type: INTEGER
foreignTable: st_product
foreignReference: id
onDelete: cascade
st_product_has_tab3:
_attributes:
phpName: ProductHasTab3
created_at:
type: timestamp
updated_at:
type: timestamp
id:
type: INTEGER
primaryKey: true
required: true
autoIncrement: true
tab3_id:
type: INTEGER
required: true
foreignTable: st_product
foreignReference: id
onDelete: cascade
product_id:
type: INTEGER
foreignTable: st_product
foreignReference: id
onDelete: cascade
st_product_has_tab4:
_attributes:
phpName: ProductHasTab4
created_at:
type: timestamp
updated_at:
type: timestamp
id:
type: INTEGER
primaryKey: true
required: true
autoIncrement: true
tab4_id:
type: INTEGER
required: true
foreignTable: st_product
foreignReference: id
onDelete: cascade
product_id:
type: INTEGER
foreignTable: st_product
foreignReference: id
onDelete: cascade

View File

@@ -0,0 +1,21 @@
propel:
st_product:
_attributes:
phpName: Product
isI18N: true
i18nTable: st_product_i18n
st_product_i18n:
_attributes:
phpName: ProductI18n
my_tab1:
type: VARCHAR
size: 255
my_tab2:
type: VARCHAR
size: 255
my_tab3:
type: VARCHAR
size: 255
my_tab4:
type: VARCHAR
size: 255

View File

@@ -0,0 +1,9 @@
<?php
class ProductHasTab1 extends BaseProductHasTab1
{
public function getCode()
{
if (is_object($this->getProductRelatedByTab1Id())) return $this->getProductRelatedByTab1Id()->getCode();
return null;
}
}

View File

@@ -0,0 +1,19 @@
<?php
class ProductHasTab1Peer extends BaseProductHasTab1Peer
{
public static function doSelectTab1ForTokenInput(Product $product)
{
$c = new Criteria();
$c->add(ProductHasTab1Peer::PRODUCT_ID, $product->getId());
$c->addJoin(ProductPeer::ID, ProductHasTab1Peer::TAB1_ID);
$c->addAscendingOrderByColumn(ProductHasTab1Peer::ID);
return ProductPeer::doSelectTokens($c);
}
}

View File

@@ -0,0 +1,9 @@
<?php
class ProductHasTab2 extends BaseProductHasTab2
{
public function getCode()
{
if (is_object($this->getProductRelatedByTab2Id())) return $this->getProductRelatedByTab2Id()->getCode();
return null;
}
}

View File

@@ -0,0 +1,19 @@
<?php
class ProductHasTab2Peer extends BaseProductHasTab2Peer
{
public static function doSelectTab2ForTokenInput(Product $product)
{
$c = new Criteria();
$c->add(ProductHasTab2Peer::PRODUCT_ID, $product->getId());
$c->addJoin(ProductPeer::ID, ProductHasTab2Peer::TAB2_ID);
$c->addAscendingOrderByColumn(ProductHasTab2Peer::ID);
return ProductPeer::doSelectTokens($c);
}
}

View File

@@ -0,0 +1,9 @@
<?php
class ProductHasTab3 extends BaseProductHasTab3
{
public function getCode()
{
if (is_object($this->getProductRelatedByTab3Id())) return $this->getProductRelatedByTab3Id()->getCode();
return null;
}
}

View File

@@ -0,0 +1,19 @@
<?php
class ProductHasTab3Peer extends BaseProductHasTab3Peer
{
public static function doSelectTab3ForTokenInput(Product $product)
{
$c = new Criteria();
$c->add(ProductHasTab3Peer::PRODUCT_ID, $product->getId());
$c->addJoin(ProductPeer::ID, ProductHasTab3Peer::TAB3_ID);
$c->addAscendingOrderByColumn(ProductHasTab3Peer::ID);
return ProductPeer::doSelectTokens($c);
}
}

View File

@@ -0,0 +1,9 @@
<?php
class ProductHasTab4 extends BaseProductHasTab4
{
public function getCode()
{
if (is_object($this->getProductRelatedByTab4Id())) return $this->getProductRelatedByTab4Id()->getCode();
return null;
}
}

View File

@@ -0,0 +1,19 @@
<?php
class ProductHasTab4Peer extends BaseProductHasTab4Peer
{
public static function doSelectTab4ForTokenInput(Product $product)
{
$c = new Criteria();
$c->add(ProductHasTab4Peer::PRODUCT_ID, $product->getId());
$c->addJoin(ProductPeer::ID, ProductHasTab4Peer::TAB4_ID);
$c->addAscendingOrderByColumn(ProductHasTab4Peer::ID);
return ProductPeer::doSelectTokens($c);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_product_has_tab1' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.smMyTabsPlugin.lib.model.map
*/
class ProductHasTab1MapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.smMyTabsPlugin.lib.model.map.ProductHasTab1MapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_product_has_tab1');
$tMap->setPhpName('ProductHasTab1');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('TAB1_ID', 'Tab1Id', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', false, null);
} // doBuild()
} // ProductHasTab1MapBuilder

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_product_has_tab2' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.smMyTabsPlugin.lib.model.map
*/
class ProductHasTab2MapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.smMyTabsPlugin.lib.model.map.ProductHasTab2MapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_product_has_tab2');
$tMap->setPhpName('ProductHasTab2');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('TAB2_ID', 'Tab2Id', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', false, null);
} // doBuild()
} // ProductHasTab2MapBuilder

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_product_has_tab3' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.smMyTabsPlugin.lib.model.map
*/
class ProductHasTab3MapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.smMyTabsPlugin.lib.model.map.ProductHasTab3MapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_product_has_tab3');
$tMap->setPhpName('ProductHasTab3');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('TAB3_ID', 'Tab3Id', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', false, null);
} // doBuild()
} // ProductHasTab3MapBuilder

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_product_has_tab4' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.smMyTabsPlugin.lib.model.map
*/
class ProductHasTab4MapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.smMyTabsPlugin.lib.model.map.ProductHasTab4MapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_product_has_tab4');
$tMap->setPhpName('ProductHasTab4');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('TAB4_ID', 'Tab4Id', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', false, null);
} // doBuild()
} // ProductHasTab4MapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,271 @@
<?php
class smMyTabsImportExport{
public static function getProductTab1(Product $object) {
$tab1 = $object->getProductHasTab1sRelatedByProductId();
if (is_array($tab1)) {
$ids = array();
foreach($tab1 as $item) {
if (is_object($item) && !is_null($item->getCode()))
$ids[] = $item->getCode();
}
return implode(',',$ids);
}
return '';
}
public static function setProductTab1(Product $object, $value) {
$tab1 = $object->getProductHasTab1sRelatedByProductId();
// usuń w przypadku gdy pole puste
if (!strlen(trim($value))) {
if (is_array($tab1)) {
foreach($tab1 as $item) {
$item->delete();
}
}
return ;
}
$idsNew = explode(',',$value);
foreach ($idsNew as $key=>$itemValue) {
if (strlen(trim($itemValue))) {
$idsNew[$key] = trim($itemValue);
} else {
unset($idsNew[$key]);
}
}
$ids = array();
if (is_array($tab1)) {
foreach($tab1 as $item) {
$ids[] = $item->getCode();
}
}
$old = array_diff($ids, $idsNew);
$idsNew = array_unique(array_diff($idsNew, $ids));
foreach($tab1 as $item) {
if (array_search($item->getCode(),$old)!== false) {
$item->delete();
}
}
foreach ($idsNew as $id) {
$c = new Criteria();
$c->add(ProductPeer::CODE,$id);
$tabs1 = ProductPeer::doSelectOne($c);
if (is_object($tabs1) && $object->getId()!=$tabs1->getId()) {
$tmp = new ProductHasTab1();
$tmp->setProductId($object->getId());
$tmp->setTab1Id($tabs1->getId());
$tmp->save();
}
}
}
public static function getProductTab2(Product $object) {
$tab2 = $object->getProductHasTab2sRelatedByProductId();
if (is_array($tab2)) {
$ids = array();
foreach($tab2 as $item) {
if (is_object($item) && !is_null($item->getCode()))
$ids[] = $item->getCode();
}
return implode(',',$ids);
}
return '';
}
public static function setProductTab2(Product $object, $value) {
$tab2 = $object->getProductHasTab2sRelatedByProductId();
// usuń w przypadku gdy pole puste
if (!strlen(trim($value))) {
if (is_array($tab2)) {
foreach($tab2 as $item) {
$item->delete();
}
}
return ;
}
$idsNew = explode(',',$value);
foreach ($idsNew as $key=>$itemValue) {
if (strlen(trim($itemValue))) {
$idsNew[$key] = trim($itemValue);
} else {
unset($idsNew[$key]);
}
}
$ids = array();
if (is_array($tab2)) {
foreach($tab2 as $item) {
$ids[] = $item->getCode();
}
}
$old = array_diff($ids, $idsNew);
$idsNew = array_unique(array_diff($idsNew, $ids));
foreach($tab2 as $item) {
if (array_search($item->getCode(),$old)!== false) {
$item->delete();
}
}
foreach ($idsNew as $id) {
$c = new Criteria();
$c->add(ProductPeer::CODE,$id);
$tabs2 = ProductPeer::doSelectOne($c);
if (is_object($tabs2) && $object->getId()!=$tabs2->getId()) {
$tmp = new ProductHasTab2();
$tmp->setProductId($object->getId());
$tmp->setTab2Id($tabs2->getId());
$tmp->save();
}
}
}
public static function getProductTab3(Product $object) {
$tab3 = $object->getProductHasTab3sRelatedByProductId();
if (is_array($tab3)) {
$ids = array();
foreach($tab3 as $item) {
if (is_object($item) && !is_null($item->getCode()))
$ids[] = $item->getCode();
}
return implode(',',$ids);
}
return '';
}
public static function setProductTab3(Product $object, $value) {
$tab3 = $object->getProductHasTab3sRelatedByProductId();
// usuń w przypadku gdy pole puste
if (!strlen(trim($value))) {
if (is_array($tab3)) {
foreach($tab3 as $item) {
$item->delete();
}
}
return ;
}
$idsNew = explode(',',$value);
foreach ($idsNew as $key=>$itemValue) {
if (strlen(trim($itemValue))) {
$idsNew[$key] = trim($itemValue);
} else {
unset($idsNew[$key]);
}
}
$ids = array();
if (is_array($tab3)) {
foreach($tab3 as $item) {
$ids[] = $item->getCode();
}
}
$old = array_diff($ids, $idsNew);
$idsNew = array_unique(array_diff($idsNew, $ids));
foreach($tab3 as $item) {
if (array_search($item->getCode(),$old)!== false) {
$item->delete();
}
}
foreach ($idsNew as $id) {
$c = new Criteria();
$c->add(ProductPeer::CODE,$id);
$tabs3 = ProductPeer::doSelectOne($c);
if (is_object($tabs3) && $object->getId()!=$tabs3->getId()) {
$tmp = new ProductHasTab3();
$tmp->setProductId($object->getId());
$tmp->setTab3Id($tabs3->getId());
$tmp->save();
}
}
}
public static function getProductTab4(Product $object) {
$tab4 = $object->getProductHasTab4sRelatedByProductId();
if (is_array($tab4)) {
$ids = array();
foreach($tab4 as $item) {
if (is_object($item) && !is_null($item->getCode()))
$ids[] = $item->getCode();
}
return implode(',',$ids);
}
return '';
}
public static function setProductTab4(Product $object, $value) {
$tab4 = $object->getProductHasTab4sRelatedByProductId();
// usuń w przypadku gdy pole puste
if (!strlen(trim($value))) {
if (is_array($tab4)) {
foreach($tab4 as $item) {
$item->delete();
}
}
return ;
}
$idsNew = explode(',',$value);
foreach ($idsNew as $key=>$itemValue) {
if (strlen(trim($itemValue))) {
$idsNew[$key] = trim($itemValue);
} else {
unset($idsNew[$key]);
}
}
$ids = array();
if (is_array($tab4)) {
foreach($tab4 as $item) {
$ids[] = $item->getCode();
}
}
$old = array_diff($ids, $idsNew);
$idsNew = array_unique(array_diff($idsNew, $ids));
foreach($tab4 as $item) {
if (array_search($item->getCode(),$old)!== false) {
$item->delete();
}
}
foreach ($idsNew as $id) {
$c = new Criteria();
$c->add(ProductPeer::CODE,$id);
$tabs4 = ProductPeer::doSelectOne($c);
if (is_object($tabs4) && $object->getId()!=$tabs4->getId()) {
$tmp = new ProductHasTab4();
$tmp->setProductId($object->getId());
$tmp->setTab4Id($tabs4->getId());
$tmp->save();
}
}
}
}

View File

@@ -0,0 +1,149 @@
<?php
class smMyTabsPluginListener
{
public static function generate(sfEvent $event) {
$event->getSubject()->attachAdminGeneratorFile('smMyTabsPlugin', 'stProduct.yml');
}
public static function addUpdateMyTabs(sfEvent $event) {
$product = $event['requestParameters'];
$pr = $event['modelInstance'];
if (isset($product['my_tab1'])) {
$pr->setMyTab1($product['my_tab1']);
}
if (isset($product['product_mytabs1'])){
$product_tab1 = $product['product_mytabs1'];
$tokens = stJQueryToolsHelper::parseTokensFromRequest($product_tab1);
$product_id = $pr->getId();
$c = new Criteria();
$c->add(ProductHasTab1Peer::PRODUCT_ID, $product_id);
ProductHasTab1Peer::doDelete($c);
if ($tokens){
foreach ($tokens as $token){
$pa = new ProductHasTab1();
$pa->setProductId($product_id);
$pa->setTab1Id($token['id']);
$pa->save();
}
}
}
if (isset($product['my_tab2'])){
$pr->setMyTab2($product['my_tab2']);
}
if (isset($product['product_mytabs2'])){
$product_tab2 = $product['product_mytabs2'];
$tokens = stJQueryToolsHelper::parseTokensFromRequest($product_tab2);
$product_id = $pr->getId();
$c = new Criteria();
$c->add(ProductHasTab2Peer::PRODUCT_ID, $product_id);
ProductHasTab2Peer::doDelete($c);
if ($tokens){
foreach ($tokens as $token){
$pa = new ProductHasTab2();
$pa->setProductId($product_id);
$pa->setTab2Id($token['id']);
$pa->save();
}
}
}
if (isset($product['my_tab3'])){
$pr->setMyTab3($product['my_tab3']);
}
if (isset($product['product_mytabs3'])){
$product_tab3 = $product['product_mytabs3'];
$tokens = stJQueryToolsHelper::parseTokensFromRequest($product_tab3);
$product_id = $pr->getId();
$c = new Criteria();
$c->add(ProductHasTab3Peer::PRODUCT_ID, $product_id);
ProductHasTab3Peer::doDelete($c);
if ($tokens){
foreach ($tokens as $token){
$pa = new ProductHasTab3();
$pa->setProductId($product_id);
$pa->setTab3Id($token['id']);
$pa->save();
}
}
}
if (isset($product['my_tab4'])){
$pr->setMyTab4($product['my_tab4']);
}
if (isset($product['product_mytabs4'])){
$product_tab4 = $product['product_mytabs4'];
$tokens = stJQueryToolsHelper::parseTokensFromRequest($product_tab4);
$product_id = $pr->getId();
$c = new Criteria();
$c->add(ProductHasTab4Peer::PRODUCT_ID, $product_id);
ProductHasTab4Peer::doDelete($c);
if ($tokens){
foreach ($tokens as $token){
$pa = new ProductHasTab4();
$pa->setProductId($product_id);
$pa->setTab4Id($token['id']);
$pa->save();
}
}
}
}
}

View File

@@ -0,0 +1,140 @@
<?php
/*
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>
*/
class smMyTabsFrontendActions extends stActions
{
public function executeTab1()
{
if (!$_SERVER['HTTP_REFERER']){
$this->getResponse()->setStatusCode(404);
$this->getResponse()->setHttpHeader('Status', '404 Not Found');
return sfView::NONE;
}
$this->setLayout(false);
$this->smarty = new stSmarty($this->getModuleName());
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$product_id = $this->getRequestParameter('product_id');
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab1Peer::TAB1_ID);
$c->add(ProductHasTab1Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab1Peer::ID);
$this->products = ProductPeer::doSelectForPager($c);
}
public function executeTab2()
{
if (!$_SERVER['HTTP_REFERER']){
$this->getResponse()->setStatusCode(404);
$this->getResponse()->setHttpHeader('Status', '404 Not Found');
return sfView::NONE;
}
$this->setLayout(false);
$this->smarty = new stSmarty($this->getModuleName());
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$product_id = $this->getRequestParameter('product_id');
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab2Peer::TAB2_ID);
$c->add(ProductHasTab2Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab2Peer::ID);
$this->products = ProductPeer::doSelectForPager($c);
}
public function executeTab3()
{
if (!$_SERVER['HTTP_REFERER']){
$this->getResponse()->setStatusCode(404);
$this->getResponse()->setHttpHeader('Status', '404 Not Found');
return sfView::NONE;
}
$this->setLayout(false);
$this->smarty = new stSmarty($this->getModuleName());
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$product_id = $this->getRequestParameter('product_id');
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab3Peer::TAB3_ID);
$c->add(ProductHasTab3Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab3Peer::ID);
$this->products = ProductPeer::doSelectForPager($c);
}
public function executeTab4()
{
if (!$_SERVER['HTTP_REFERER']){
$this->getResponse()->setStatusCode(404);
$this->getResponse()->setHttpHeader('Status', '404 Not Found');
return sfView::NONE;
}
$this->setLayout(false);
$this->smarty = new stSmarty($this->getModuleName());
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$product_id = $this->getRequestParameter('product_id');
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab4Peer::TAB4_ID);
$c->add(ProductHasTab4Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab4Peer::ID);
$this->products= ProductPeer::doSelectForPager($c);
}
}

View File

@@ -0,0 +1,102 @@
<?php
class smMyTabsFrontendComponents extends sfComponents
{
public function executeShow()
{
$product = sfContext::getInstance()->getActionStack()->getLastEntry()->getActionInstance()->product;
$product_id = $product->getId();
$this->smarty = new stSmarty('smMyTabsFrontend');
$this->tabs = stTabNavigator::getInstance($this->getContext(), "my_tabs", null);
if($product->getMyTab1()){
$name_tab_1 = $product->getMyTab1();
}else{
$name_tab_1 = "---- 1 ----";
}
if($product->getMyTab2()){
$name_tab_2 = $product->getMyTab2();
}else{
$name_tab_2 = "---- 2 ----";
}
if($product->getMyTab3()){
$name_tab_3 = $product->getMyTab3();
}else{
$name_tab_3 = "---- 3 ----";
}
if($product->getMyTab4()){
$name_tab_4 = $product->getMyTab4();
}else{
$name_tab_4 = "---- 4 ----";
}
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab1Peer::TAB1_ID);
$c->add(ProductHasTab1Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab1Peer::ID);
$products_tab1 = ProductPeer::doSelectForPager($c);
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab2Peer::TAB2_ID);
$c->add(ProductHasTab2Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab2Peer::ID);
$products_tab2 = ProductPeer::doSelectForPager($c);
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab3Peer::TAB3_ID);
$c->add(ProductHasTab3Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab3Peer::ID);
$products_tab3 = ProductPeer::doSelectForPager($c);
$c = new Criteria();
$c->addJoin(ProductPeer::ID, ProductHasTab4Peer::TAB4_ID);
$c->add(ProductHasTab4Peer::PRODUCT_ID, $product_id);
$c->add(ProductPeer::ACTIVE, 1);
$c->addAscendingOrderByColumn(ProductHasTab4Peer::ID);
$products_tab4 = ProductPeer::doSelectForPager($c);
if ($products_tab1){
$this->tabs->addTab($name_tab_1,'smMyTabsFrontend', 'tab1', array("product_id"=>$product->getId()));
}
if ($products_tab2){
$this->tabs->addTab($name_tab_2,'smMyTabsFrontend', 'tab2', array("product_id"=>$product->getId()));
}
if ($products_tab3){
$this->tabs->addTab($name_tab_3,'smMyTabsFrontend', 'tab3', array("product_id"=>$product->getId()));
}
if ($products_tab4){
$this->tabs->addTab($name_tab_4,'smMyTabsFrontend', 'tab4', array("product_id"=>$product->getId()));
}
}
}

View File

@@ -0,0 +1,106 @@
<?php
use_helper('stCurrency', 'stProductImage', 'stText', 'stUrl');
st_theme_use_stylesheet('stProduct.css');
if ($products)
{
$smarty->assign('name', $name);
$smarty->assign("show_name", $config->get('show_name_other'));
$smarty->assign("show_image", $config->get('show_image_other'));
$smarty->assign("show_price", $config->get('show_price_other'));
$smarty->assign("show_description", $config->get('show_description_other'));
$smarty->assign("show_old_price", $config->get('show_old_price_other'));
$smarty->assign("show_discount", $config->get('show_discount_other'));
$smarty->assign("price_view", $config->get('price_view_other'));
$photo_max_height = st_asset_thumbnail_setting('height', 'thumb');
$cut_name = $config->get('cut_name_other');
$max_name_length = $config->get('cut_name_num_other');
$results = array();
foreach ($products as $index => $product)
{
$product_url = st_url_for('stProduct/show?url='.$product->getFriendlyUrl());
$product_name = $product->getName();
$results[$index]['instance'] = $product ;
$results[$index]['id'] = $product->getId();
$results[$index]['photo'] = content_tag('a', st_product_image_tag($product, 'thumb'), array('href' => $product_url));
$results[$index]['photo_small'] = content_tag('a', st_product_image_tag($product, 'small'), array('href' => $product_url));
$results[$index]['photo_max_height'] = $photo_max_height;
if ($cut_name && st_check_strlen($product_name) > $max_name_length)
{
$results[$index]['name'] = "<span title=\"". $product_name ."\">" . content_tag('a', st_truncate_text($product_name, $max_name_length, '...'), array('href' => $product_url, 'class' => 'product_name')) . "</span>";
}
else
{
$results[$index]['name'] = content_tag('a', $product_name, array('href' => $product_url, 'class' => 'product_name'));
}
if ($product->isPriceVisible())
{
$results[$index]['price'] = st_currency_format($product->getPriceBrutto(true));
$results[$index]['price_net'] = st_currency_format($product->getPriceNetto(true));
$old_price_brutto = $product->getOldPriceBrutto(true);
$results[$index]['check_old_price'] = $old_price_brutto != 0;
$results[$index]['old_price'] = st_currency_format($old_price_brutto);
$results[$index]['old_price_net'] = st_currency_format($product->getOldPriceNetto(true));
$results[$index]['discount'] = $product->getDiscountInPercent();
$results[$index]['check_price'] = false;
$results[$index]['basket'] = st_get_component('stBasket', 'add', array('product' => $product));
if ($config->get('show_basic_price_long') && $product->hasBasicPrice() && $product->getBasicPriceBrutto()!=0)
{
$results[$index]['basic_price'] = array(
'netto' => st_currency_format($product->getBasicPriceNetto(true)),
'brutto' => st_currency_format($product->getBasicPriceBrutto(true)),
'quantity' => st_product_basic_price_quantity($product),
'for_quantity' => st_product_basic_price_for_quantity($product),
);
}
}
else
{
$results[$index]['check_price'] = true;
}
$results[$index]['description'] = $product->getShortDescription() ? $product->getShortDescription() : st_truncate_text($product->getDescription(), 140, '...');
$results[$index]['name_without_link'] = $product->getName();
$results[$index]['link'] = $product_url;
$results[$index]['code'] = $product->getCode();
}
$smarty->assign("results", $results);
$smarty->display('products.html');
}

View File

@@ -0,0 +1,5 @@
<?php
use_helper('stTabNavigator');
$smarty->assign('tabs', $tabs);
$smarty->display('tabs.html');
?>

View File

@@ -0,0 +1 @@
<?php echo st_get_partial('products',array('products'=>$products, 'smarty'=>$smarty, 'config'=>$config, 'name'=>'my_tab1'));?>

View File

@@ -0,0 +1 @@
<?php echo st_get_partial('products',array('products'=>$products, 'smarty'=>$smarty, 'config'=>$config, 'name'=>'my_tab2'));?>

View File

@@ -0,0 +1 @@
<?php echo st_get_partial('products',array('products'=>$products, 'smarty'=>$smarty, 'config'=>$config, 'name'=>'my_tab3'));?>

View File

@@ -0,0 +1 @@
<?php echo st_get_partial('products',array('products'=>$products, 'smarty'=>$smarty, 'config'=>$config, 'name'=>'my_tab4'));?>

View File

@@ -0,0 +1,65 @@
<section id="{$name}" class="full-list product-list" style="margin-top: 10px;">
<div class="row" data-equalizer>
{foreach key=row item=product from=$results}
<div class="product col-xs-4 col-sm-4 col-md-3 col-lg-3">
<div class="thumbnail clearfix view-img">
{if $show_image==1}<div data-equalizer-watch="image"><div class="image">{$product.photo_small}</div></div>{/if}
<div class="text-center caption clearfix">
<p class="name" data-equalizer-watch="name">{if $show_name==1}{$product.name}{/if}</p>
<div data-equalizer-watch="info">
{if $show_price==1 && $product.check_price!=1 && $product.points_only!=1}
{if $price_view=='net_gross'}
<div class="double_price price">
{$product.price_net}
<div class="minor_price">({$product.price})</div>
</div>
{elseif $price_view=='only_gross'}
<div class="price">{$product.price}</div>
{elseif $price_view=='only_net'}
<div class="price">{$product.price_net}</div>
{elseif $price_view=='gross_net'}
<div class="double_price price">
{$product.price}
<div class="minor_price">({$product.price_net})</div>
</div>
{/if}
{if $product.basic_price}
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
{/if}
{/if}
<div class="discount-old_price">
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1 && $product.points_only!=1}
<div class="discount">{__ text="Rabat"}: {$product.discount} %</div>
{elseif ($show_old_price==1 && $product.check_price!=1)}
{if $product.check_old_price==1}
<div class="old_price price">
{if ($price_view=='net_gross' || $price_view=='only_net')}
{$product.old_price_net}
{else}
{$product.old_price}
{/if}
</div>
{/if}
{/if}
</div>
</div>
{basket_add_link product=$product.instance namespace="product_list"}
<div class="text-center" data-equalizer-watch="basket">
<a class="product-details" href="{$product.link}">{__ text="szczegóły" langCatalogue="stProduct"}</a>
</div>
</div>
</div>
</div>
{/foreach}
</div>
</section>
{literal}
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$('#{/literal}{$name}{literal} [data-equalizer]').equalizer({ use_tallest: true });
});
});
</script>
{/literal}

View File

@@ -0,0 +1,59 @@
<section id="{$name}" class="full-list product-list" style="margin-top: 10px;">
<div class="row" data-equalizer>
{foreach key=row item=product from=$results}
<div class="product col-xs-4 col-sm-4 col-md-3 col-lg-3">
<div class="thumbnail clearfix view-img">
{if $show_image==1}<div data-equalizer-watch="image"><div class="image">{$product.photo_small}</div></div>{/if}
<div class="text-center caption clearfix" data-equalizer-watch="info">
<p class="name">{if $show_name==1}{$product.name}{/if}</p>
{if $show_price==1 && $product.check_price!=1}
{if $price_view=='net_gross'}
<div class="double_price price">
<span class="nowrap">{$product.price_net}</span>
<div class="minor_price nowrap">({$product.price})</div>
</div>
{elseif $price_view=='only_gross'}
<div class="price nowrap">{$product.price}</div>
{elseif $price_view=='only_net'}
<div class="price nowrap">{$product.price_net}</div>
{elseif $price_view=='gross_net'}
<div class="double_price price">
<span class="nowrap">{$product.price}</span>
<div class="minor_price nowrap">({$product.price_net})</div>
</div>
{/if}
{if $product.basic_price}
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
{/if}
{/if}
<div class="discount-old_price">
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1}
<div class="discount">{__ text="Rabat"}: <span class="nowrap">{$product.discount} %</span></div>
{elseif ($show_old_price==1 && $product.check_price!=1)}
{if $product.check_old_price==1}
<div class="old_price price nowrap">
{if ($price_view=='net_gross' || $price_view=='only_net')}
{$product.old_price_net}
{else}
{$product.old_price}
{/if}
</div>
{/if}
{/if}
</div>
</div>
</div>
</div>
{/foreach}
</div>
</section>
{literal}
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$('#{/literal}{$name}{literal} [data-equalizer]').equalizer({ use_tallest: true });
});
});
</script>
{/literal}

View File

@@ -0,0 +1,47 @@
{if $tabs->getTabs()}
<ul id="tabs" class="nav nav-tabs">
{foreach item=tab from=$tabs->getTabs()}
<li>
<a href="#tabs-{$tab->getIndex()}" data-url="{url_for internal=$tab->getParamsForUrl()}" rel="nofollow">{__ text=$tab->getLabel()}</a>
</li>
{/foreach}
</ul>
<div class="tab-content">
{foreach item=tab from=$tabs->getTabs()}
<div class="tab-pane" id="tabs-{$tab->getIndex()}"></div>
{/foreach}
</div>
{/if}
{literal}
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
var preloader = $('#product-preloader');
$('#tabs').on('click', 'a', function() {
var tab = $(this);
tab.tab('show');
var pane = $(tab.attr('href'));
if (pane.is(':empty')) {
pane.html('<div class="preloader"></div>');
$.get(tab.data('url'), function(html) {
pane.html(html);
});
}
return false;
});
$('#tabs a[href=#tabs-1]').click();
});
//]]>
</script>
{/literal}