first commit
This commit is contained in:
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab1.php
Normal file
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab1.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
class ProductHasTab1 extends BaseProductHasTab1
|
||||
{
|
||||
public function getCode()
|
||||
{
|
||||
if (is_object($this->getProductRelatedByTab1Id())) return $this->getProductRelatedByTab1Id()->getCode();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab1Peer.php
Normal file
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab1Peer.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab2.php
Normal file
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab2.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
class ProductHasTab2 extends BaseProductHasTab2
|
||||
{
|
||||
public function getCode()
|
||||
{
|
||||
if (is_object($this->getProductRelatedByTab2Id())) return $this->getProductRelatedByTab2Id()->getCode();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab2Peer.php
Normal file
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab2Peer.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab3.php
Normal file
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab3.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
class ProductHasTab3 extends BaseProductHasTab3
|
||||
{
|
||||
public function getCode()
|
||||
{
|
||||
if (is_object($this->getProductRelatedByTab3Id())) return $this->getProductRelatedByTab3Id()->getCode();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab3Peer.php
Normal file
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab3Peer.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab4.php
Normal file
9
plugins/smMyTabsPlugin/lib/model/ProductHasTab4.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
class ProductHasTab4 extends BaseProductHasTab4
|
||||
{
|
||||
public function getCode()
|
||||
{
|
||||
if (is_object($this->getProductRelatedByTab4Id())) return $this->getProductRelatedByTab4Id()->getCode();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab4Peer.php
Normal file
19
plugins/smMyTabsPlugin/lib/model/ProductHasTab4Peer.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab1.php
Normal file
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab1.php
Normal file
File diff suppressed because it is too large
Load Diff
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab1Peer.php
Normal file
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab1Peer.php
Normal file
File diff suppressed because it is too large
Load Diff
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab2.php
Normal file
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab2.php
Normal file
File diff suppressed because it is too large
Load Diff
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab2Peer.php
Normal file
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab2Peer.php
Normal file
File diff suppressed because it is too large
Load Diff
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab3.php
Normal file
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab3.php
Normal file
File diff suppressed because it is too large
Load Diff
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab3Peer.php
Normal file
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab3Peer.php
Normal file
File diff suppressed because it is too large
Load Diff
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab4.php
Normal file
1002
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab4.php
Normal file
File diff suppressed because it is too large
Load Diff
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab4Peer.php
Normal file
1137
plugins/smMyTabsPlugin/lib/model/om/BaseProductHasTab4Peer.php
Normal file
File diff suppressed because it is too large
Load Diff
271
plugins/smMyTabsPlugin/lib/smMyTabsImportExport.class.php
Normal file
271
plugins/smMyTabsPlugin/lib/smMyTabsImportExport.class.php
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
149
plugins/smMyTabsPlugin/lib/smMyTabsPluginListener.class.php
Normal file
149
plugins/smMyTabsPlugin/lib/smMyTabsPluginListener.class.php
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user