Niveus_ProductVideo - Version 1.0.0

Version Notes

Installation steps

Download this release

Release Info

Developer Niveus Solutions
Extension Niveus_ProductVideo
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (103) hide show
  1. app/code/community/Niveus/ProductVideo/Block/Adminhtml/Catalog/Product/Edit/Tab/Videos.php +1 -0
  2. app/code/community/Niveus/ProductVideo/Block/Adminhtml/Catalog/Product/Edit/Tab/Videos.php~ +1 -0
  3. app/code/community/Niveus/ProductVideo/Block/Product/View/Attribute.php~ +15 -0
  4. app/code/community/Niveus/ProductVideo/Block/Product/View/List.php~ +15 -0
  5. app/code/community/Niveus/ProductVideo/Block/Product/View/Media.php +31 -0
  6. app/code/community/Niveus/ProductVideo/Block/Product/View/Media.php~ +17 -0
  7. app/code/community/Niveus/ProductVideo/Block/Rewrite/AdminhtmlCatalogProductEditTabs.php +46 -0
  8. app/code/community/Niveus/ProductVideo/Block/Rewrite/AdminhtmlCatalogProductEditTabs.php~ +46 -0
  9. app/code/community/Niveus/ProductVideo/Block/Video.php +62 -0
  10. app/code/community/Niveus/ProductVideo/Block/Video.php~ +47 -0
  11. app/code/community/Niveus/ProductVideo/Helper/Data.php +20 -0
  12. app/code/community/Niveus/ProductVideo/Helper/Data.php~ +20 -0
  13. app/code/community/Niveus/ProductVideo/Model/Config/Source/Scrolling.php +35 -0
  14. app/code/community/Niveus/ProductVideo/Model/Config/Source/Scrolling.php~ +21 -0
  15. app/code/community/Niveus/ProductVideo/Model/Config/Source/Titleposition.php +35 -0
  16. app/code/community/Niveus/ProductVideo/Model/Config/Source/Titleposition.php~ +21 -0
  17. app/code/community/Niveus/ProductVideo/Model/Config/Source/Transition.php +35 -0
  18. app/code/community/Niveus/ProductVideo/Model/Config/Source/Transition.php~ +21 -0
  19. app/code/community/Niveus/ProductVideo/Model/Observer.php +103 -0
  20. app/code/community/Niveus/ProductVideo/Model/Observer.php~ +103 -0
  21. app/code/community/Niveus/ProductVideo/Model/Resource/Eav/Mysql4/Setup.php +25 -0
  22. app/code/community/Niveus/ProductVideo/Model/Resource/Eav/Mysql4/Setup.php~ +11 -0
  23. app/code/community/Niveus/ProductVideo/Model/Resource/Videos.php +24 -0
  24. app/code/community/Niveus/ProductVideo/Model/Resource/Videos.php~ +10 -0
  25. app/code/community/Niveus/ProductVideo/Model/Resource/Videos/Collection.php +35 -0
  26. app/code/community/Niveus/ProductVideo/Model/Resource/Videos/Collection.php~ +21 -0
  27. app/code/community/Niveus/ProductVideo/Model/Videos.php +25 -0
  28. app/code/community/Niveus/ProductVideo/Model/Videos.php~ +11 -0
  29. app/code/community/Niveus/ProductVideo/controllers/Adminhtml/VideosController.php +1 -0
  30. app/code/community/Niveus/ProductVideo/controllers/Adminhtml/VideosController.php~ +1 -0
  31. app/code/community/Niveus/ProductVideo/etc/adminhtml.xml +24 -0
  32. app/code/community/Niveus/ProductVideo/etc/adminhtml.xml~ +24 -0
  33. app/code/community/Niveus/ProductVideo/etc/config.xml +117 -0
  34. app/code/community/Niveus/ProductVideo/etc/config.xml~ +118 -0
  35. app/code/community/Niveus/ProductVideo/etc/system.xml +45 -0
  36. app/code/community/Niveus/ProductVideo/etc/system.xml~ +49 -0
  37. app/code/community/Niveus/ProductVideo/sql/productvideo_setup/mysql4-install-0.1.0.php +43 -0
  38. app/code/community/Niveus/ProductVideo/sql/productvideo_setup/mysql4-install-0.1.0.php~ +29 -0
  39. app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit.php +57 -0
  40. app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Form.php +18 -0
  41. app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Tab/Css.php +51 -0
  42. app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Tabs.php +24 -0
  43. app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Fieldset.php +83 -0
  44. app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Fieldsetcss.php +57 -0
  45. app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Form.php +18 -0
  46. app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Formcss.php +18 -0
  47. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels.php +38 -0
  48. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit.php +59 -0
  49. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Form.php +20 -0
  50. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Tab/Form.php +164 -0
  51. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Tabs.php +24 -0
  52. app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Grid.php +116 -0
  53. app/code/community/Niveus/Productlabels/Block/Css.php +36 -0
  54. app/code/community/Niveus/Productlabels/Block/Productlabels.php +28 -0
  55. app/code/community/Niveus/Productlabels/Helper/Data.php +98 -0
  56. app/code/community/Niveus/Productlabels/Model/Attribute.php +44 -0
  57. app/code/community/Niveus/Productlabels/Model/Config/Listlabel.php +28 -0
  58. app/code/community/Niveus/Productlabels/Model/Css.php +53 -0
  59. app/code/community/Niveus/Productlabels/Model/Filter.php +112 -0
  60. app/code/community/Niveus/Productlabels/Model/Mysql4/Attribute.php +10 -0
  61. app/code/community/Niveus/Productlabels/Model/Mysql4/Attribute/Collection.php +10 -0
  62. app/code/community/Niveus/Productlabels/Model/Mysql4/Css.php +10 -0
  63. app/code/community/Niveus/Productlabels/Model/Mysql4/Css/Collection.php +23 -0
  64. app/code/community/Niveus/Productlabels/Model/Mysql4/Productlabels.php +10 -0
  65. app/code/community/Niveus/Productlabels/Model/Mysql4/Productlabels/Collection.php +104 -0
  66. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Int.php +10 -0
  67. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Int/Collection.php +10 -0
  68. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Text.php +10 -0
  69. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Text/Collection.php +10 -0
  70. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Varchar.php +10 -0
  71. app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Varchar/Collection.php +10 -0
  72. app/code/community/Niveus/Productlabels/Model/Productlabels.php +59 -0
  73. app/code/community/Niveus/Productlabels/Model/Productrule.php +314 -0
  74. app/code/community/Niveus/Productlabels/Model/Rule.php +14 -0
  75. app/code/community/Niveus/Productlabels/Model/Rule/Combine.php +58 -0
  76. app/code/community/Niveus/Productlabels/Model/Rule/Condition/Product.php +325 -0
  77. app/code/community/Niveus/Productlabels/Model/Status.php +15 -0
  78. app/code/community/Niveus/Productlabels/Model/Type/Int.php +10 -0
  79. app/code/community/Niveus/Productlabels/Model/Type/Text.php +10 -0
  80. app/code/community/Niveus/Productlabels/Model/Type/Varchar.php +10 -0
  81. app/code/community/Niveus/Productlabels/controllers/Adminhtml/CssController.php +76 -0
  82. app/code/community/Niveus/Productlabels/controllers/Adminhtml/ProductlabelsController.php +490 -0
  83. app/code/community/Niveus/Productlabels/controllers/IndexController.php +47 -0
  84. app/code/community/Niveus/Productlabels/etc/config.xml +183 -0
  85. app/code/community/Niveus/Productlabels/sql/productlabels_setup/mysql4-install-0.1.0.php +123 -0
  86. app/code/community/Niveus/Requestproduct/Block/Adminhtml/Requestnewproduct.php +16 -0
  87. app/code/community/Niveus/Requestproduct/Block/Adminhtml/Requestnewproduct/Grid.php +85 -0
  88. app/code/community/Niveus/Requestproduct/Block/Requestnewproduct.php +8 -0
  89. app/code/community/Niveus/Requestproduct/Helper/Data.php +7 -0
  90. app/code/community/Niveus/Requestproduct/Model/Mysql4/Requestnewproduct.php +11 -0
  91. app/code/community/Niveus/Requestproduct/Model/Mysql4/Requestnewproduct/Collection.php +11 -0
  92. app/code/community/Niveus/Requestproduct/Model/Requestnewproduct.php +11 -0
  93. app/code/community/Niveus/Requestproduct/controllers/Adminhtml/RequestnewproductController.php +44 -0
  94. app/code/community/Niveus/Requestproduct/controllers/IndexController.php +47 -0
  95. app/code/community/Niveus/Requestproduct/etc/adminhtml.xml +40 -0
  96. app/code/community/Niveus/Requestproduct/etc/config.xml +99 -0
  97. app/code/community/Niveus/Requestproduct/sql/niveus_requestproduct_setup/mysql4-install-1.0.0.php +37 -0
  98. app/design/adminhtml/default/default/layout/niveusproductvideo.xml +1 -0
  99. app/design/adminhtml/default/default/template/niveusproductvideo/tab/videos.phtml +1 -0
  100. app/design/frontend/default/default/layout/niveusproductvideo.xml +23 -0
  101. app/design/frontend/default/default/template/niveusproductvideo/video.phtml +37 -0
  102. app/etc/modules/Niveus_ProductVideo.xml +10 -0
  103. package.xml +18 -0
app/code/community/Niveus/ProductVideo/Block/Adminhtml/Catalog/Product/Edit/Tab/Videos.php ADDED
@@ -0,0 +1 @@
 
0
  * Video Plugin for Magento
1
  *
2
  * This source file is subject to the Open Software License (OSL 3.0)
3
  * that is bundled with this package in the file LICENSE.txt.
4
  * It is also available through the world-wide-web at this URL:
5
  * http://opensource.org/licenses/osl-3.0.php
6
  *
7
  * @category Niveus
8
  * @package Niveus_ProductVideo
9
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
10
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
  * @author Niveus Solutions <support@niveussolutions.com>
12
  */
13
  * Widget displays the vedio plugin list
14
  */
15
 
16
  /**
17
  * List of all videos collection
18
  * @var type
19
  */
20
  protected $videosCollection = null;
21
  /**
22
  * Initialization
23
  */
24
  {
25
  $this->setTemplate('niveusproductvideo/tab/videos.phtml');
26
  /**
27
  * Loads the product
28
  * @return type
29
  */
30
  {
31
  $productId = (int) $this->getRequest()->getParam('id', false);
32
  return Mage::getModel('catalog/product')->load($productId);
33
  }
34
  /**
35
  * Get the list of videos
36
  * @return type
37
  */
38
  {
39
  $storeId = (int) $this->getRequest()->getParam('store', false);
40
  if (is_null($this->videosCollection))
41
  {
42
  $this->videosCollection = Mage::getModel('productvideo/videos')
43
  ->getCollection()
44
  ->addFieldToFilter('product_id', $this->getProduct()->getId())
45
  ->addFieldToFilter('store_id', $storeId);
46
  }
47
 
48
  return $this->videosCollection;
49
  }
1
+ <?php
2
  * Video Plugin for Magento
3
  *
4
  * This source file is subject to the Open Software License (OSL 3.0)
5
  * that is bundled with this package in the file LICENSE.txt.
6
  * It is also available through the world-wide-web at this URL:
7
  * http://opensource.org/licenses/osl-3.0.php
8
  *
9
  * @category Niveus
10
  * @package Niveus_ProductVideo
11
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
12
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
  * @author Niveus Solutions <support@niveussolutions.com>
14
  */
15
  * Widget displays the vedio plugin list
16
  */
17
 
18
  /**
19
  * List of all videos collection
20
  * @var type
21
  */
22
  protected $videosCollection = null;
23
  /**
24
  * Initialization
25
  */
26
  {
27
  $this->setTemplate('niveusproductvideo/tab/videos.phtml');
28
  /**
29
  * Loads the product
30
  * @return type
31
  */
32
  {
33
  $productId = (int) $this->getRequest()->getParam('id', false);
34
  return Mage::getModel('catalog/product')->load($productId);
35
  }
36
  /**
37
  * Get the list of videos
38
  * @return type
39
  */
40
  {
41
  $storeId = (int) $this->getRequest()->getParam('store', false);
42
  if (is_null($this->videosCollection))
43
  {
44
  $this->videosCollection = Mage::getModel('productvideo/videos')
45
  ->getCollection()
46
  ->addFieldToFilter('product_id', $this->getProduct()->getId())
47
  ->addFieldToFilter('store_id', $storeId);
48
  }
49
 
50
  return $this->videosCollection;
51
  }
app/code/community/Niveus/ProductVideo/Block/Adminhtml/Catalog/Product/Edit/Tab/Videos.php~ ADDED
@@ -0,0 +1 @@
 
0
  protected $videosCollection = null;
1
  {
2
  $this->setTemplate('niveusproductvideo/tab/videos.phtml');
3
  {
4
  $productId = (int) $this->getRequest()->getParam('id', false);
5
  return Mage::getModel('catalog/product')->load($productId);
6
  }
7
  {
8
  $storeId = (int) $this->getRequest()->getParam('store', false);
9
  if (is_null($this->videosCollection))
10
  {
11
  $this->videosCollection = Mage::getModel('productvideo/videos')
12
  ->getCollection()
13
  ->addFieldToFilter('product_id', $this->getProduct()->getId())
14
  ->addFieldToFilter('store_id', $storeId);
15
  }
16
 
17
  return $this->videosCollection;
18
  }
1
+ <?php
2
  protected $videosCollection = null;
3
  {
4
  $this->setTemplate('niveusproductvideo/tab/videos.phtml');
5
  {
6
  $productId = (int) $this->getRequest()->getParam('id', false);
7
  return Mage::getModel('catalog/product')->load($productId);
8
  }
9
  {
10
  $storeId = (int) $this->getRequest()->getParam('store', false);
11
  if (is_null($this->videosCollection))
12
  {
13
  $this->videosCollection = Mage::getModel('productvideo/videos')
14
  ->getCollection()
15
  ->addFieldToFilter('product_id', $this->getProduct()->getId())
16
  ->addFieldToFilter('store_id', $storeId);
17
  }
18
 
19
  return $this->videosCollection;
20
  }
app/code/community/Niveus/ProductVideo/Block/Product/View/Attribute.php~ ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Niveus_ProductVideo_Block_Product_View_Attribute extends Mage_Catalog_Block_Product_View_Attribute
5
+ {
6
+ protected function _toHtml()
7
+ {
8
+ if(Mage::getStoreConfig('niveus_productvideo/settings/enable'))
9
+ {
10
+ $html = parent::_toHtml();
11
+ $html .= $this->getChildHtml('media_video');
12
+ return $html;
13
+ }
14
+ }
15
+ }
app/code/community/Niveus/ProductVideo/Block/Product/View/List.php~ ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Niveus_ProductVideo_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
5
+ {
6
+ protected function _toHtml()
7
+ {
8
+ if(Mage::getStoreConfig('niveus_productvideo/settings/enable'))
9
+ {
10
+ $html = parent::_toHtml();
11
+ $html .= $this->getChildHtml('media_video');
12
+ return $html;
13
+ }
14
+ }
15
+ }
app/code/community/Niveus/ProductVideo/Block/Product/View/Media.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
18
+ {
19
+ public function _toHtml()
20
+ {
21
+ if(Mage::getStoreConfig('niveus_productvideo/settings/enable'))
22
+ {
23
+ $html = parent::_toHtml();
24
+ $html .= $this->getChildHtml('media_video');
25
+ return $html;
26
+ }
27
+ else
28
+ $html = parent::_toHtml();
29
+ return $html;
30
+ }
31
+ }
app/code/community/Niveus/ProductVideo/Block/Product/View/Media.php~ ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_ProductVideo_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
4
+ {
5
+ public function _toHtml()
6
+ {
7
+ if(Mage::getStoreConfig('niveus_productvideo/settings/enable'))
8
+ {
9
+ $html = parent::_toHtml();
10
+ $html .= $this->getChildHtml('media_video');
11
+ return $html;
12
+ }
13
+ else
14
+ $html = parent::_toHtml();
15
+ return $html;
16
+ }
17
+ }
app/code/community/Niveus/ProductVideo/Block/Rewrite/AdminhtmlCatalogProductEditTabs.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+
19
+
20
+
21
+ class Niveus_ProductVideo_Block_Rewrite_AdminhtmlCatalogProductEditTabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
22
+ {
23
+ protected function _prepareLayout()
24
+ {$product = $this->getProduct();
25
+
26
+ if (!($setId = $product->getAttributeSetId())) {
27
+ $return = parent::_prepareLayout();
28
+
29
+
30
+ }
31
+ if ($setId) {
32
+ $return = parent::_prepareLayout();
33
+
34
+ $this->addTab('niveus_youtube_videos', array(
35
+ 'label' => Mage::helper('productvideo')->__('Videos'),
36
+ 'url' => $this->getUrl('productvideo_admin/adminhtml_videos', array('_current' => true)),
37
+ 'class' => 'ajax',
38
+ 'after' => 'custom_option',
39
+ ));
40
+
41
+ return $return;
42
+ }
43
+ return false;
44
+
45
+ }
46
+ }
app/code/community/Niveus/ProductVideo/Block/Rewrite/AdminhtmlCatalogProductEditTabs.php~ ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+ <?php
19
+
20
+
21
+ class Niveus_ProductVideo_Block_Rewrite_AdminhtmlCatalogProductEditTabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
22
+ {
23
+ protected function _prepareLayout()
24
+ {$product = $this->getProduct();
25
+
26
+ if (!($setId = $product->getAttributeSetId())) {
27
+ $return = parent::_prepareLayout();
28
+
29
+
30
+ }
31
+ if ($setId) {
32
+ $return = parent::_prepareLayout();
33
+
34
+ $this->addTab('niveus_youtube_videos', array(
35
+ 'label' => Mage::helper('productvideo')->__('Videos'),
36
+ 'url' => $this->getUrl('productvideo_admin/adminhtml_videos', array('_current' => true)),
37
+ 'class' => 'ajax',
38
+ 'after' => 'custom_option',
39
+ ));
40
+
41
+ return $return;
42
+ }
43
+ return false;
44
+
45
+ }
46
+ }
app/code/community/Niveus/ProductVideo/Block/Video.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+ class Niveus_ProductVideo_Block_Video extends Mage_Catalog_Block_Product_View_Abstract
19
+ {
20
+ protected $_videosCollection = null;
21
+
22
+
23
+ public function getCode($video)
24
+ {
25
+ return $video->getVideoCode();
26
+ }
27
+
28
+ public function getTitle($video)
29
+ {
30
+ if ($video->getVideoTitle())
31
+ {
32
+ return $video->getVideoTitle();
33
+ }
34
+ else
35
+ {
36
+ return $this->getProduct()->getName();
37
+ }
38
+ }
39
+
40
+
41
+ protected function _getProductVideos()
42
+ {
43
+ $storeId = Mage::app()->getStore()->getId();
44
+
45
+ if (is_null($this->_videosCollection))
46
+ {
47
+ $this->_videosCollection = $this->_getVideosCollection($storeId)->getSize() ? $this->_getVideosCollection($storeId) : $this->_getVideosCollection();
48
+ }
49
+
50
+ return $this->_videosCollection;
51
+ }
52
+
53
+
54
+ protected function _getVideosCollection($storeId = 0)
55
+ {
56
+ return Mage::getModel('productvideo/videos')
57
+ ->getCollection()
58
+ ->addFieldToFilter('product_id', $this->getProduct()->getId())
59
+ ->addFieldToFilter('store_id', $storeId);
60
+ }
61
+
62
+ }
app/code/community/Niveus/ProductVideo/Block/Video.php~ ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_ProductVideo_Block_Video extends Mage_Catalog_Block_Product_View_Abstract
4
+ {
5
+ protected $_videosCollection = null;
6
+
7
+
8
+ public function getCode($video)
9
+ {
10
+ return $video->getVideoCode();
11
+ }
12
+
13
+ public function getTitle($video)
14
+ {
15
+ if ($video->getVideoTitle())
16
+ {
17
+ return $video->getVideoTitle();
18
+ }
19
+ else
20
+ {
21
+ return $this->getProduct()->getName();
22
+ }
23
+ }
24
+
25
+
26
+ protected function _getProductVideos()
27
+ {
28
+ $storeId = Mage::app()->getStore()->getId();
29
+
30
+ if (is_null($this->_videosCollection))
31
+ {
32
+ $this->_videosCollection = $this->_getVideosCollection($storeId)->getSize() ? $this->_getVideosCollection($storeId) : $this->_getVideosCollection();
33
+ }
34
+
35
+ return $this->_videosCollection;
36
+ }
37
+
38
+
39
+ protected function _getVideosCollection($storeId = 0)
40
+ {
41
+ return Mage::getModel('productvideo/videos')
42
+ ->getCollection()
43
+ ->addFieldToFilter('product_id', $this->getProduct()->getId())
44
+ ->addFieldToFilter('store_id', $storeId);
45
+ }
46
+
47
+ }
app/code/community/Niveus/ProductVideo/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Helper_Data extends Mage_Core_Helper_Abstract
18
+ {
19
+
20
+ }
app/code/community/Niveus/ProductVideo/Helper/Data.php~ ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Helper_Data extends Mage_Core_Helper_Abstract
18
+ {
19
+
20
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Scrolling.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Model_Config_Source_Scrolling extends Varien_Object
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $vals = array(
22
+ 'auto' => 'auto',
23
+ 'yes' => 'yes',
24
+ 'no' => 'no',
25
+ );
26
+ $options = array();
27
+ foreach ($vals as $k => $v)
28
+ $options[] = array(
29
+ 'value' => $k,
30
+ 'label' => $v
31
+ );
32
+
33
+ return $options;
34
+ }
35
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Scrolling.php~ ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_ProductVideo_Model_Config_Source_Scrolling extends Varien_Object
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $vals = array(
8
+ 'auto' => 'auto',
9
+ 'yes' => 'yes',
10
+ 'no' => 'no',
11
+ );
12
+ $options = array();
13
+ foreach ($vals as $k => $v)
14
+ $options[] = array(
15
+ 'value' => $k,
16
+ 'label' => $v
17
+ );
18
+
19
+ return $options;
20
+ }
21
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Titleposition.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Model_Config_Source_Titleposition extends Varien_Object
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $vals = array(
22
+ 'outside' => 'outside',
23
+ 'inside' => 'inside',
24
+ 'over' => 'over',
25
+ );
26
+ $options = array();
27
+ foreach ($vals as $k => $v)
28
+ $options[] = array(
29
+ 'value' => $k,
30
+ 'label' => $v
31
+ );
32
+
33
+ return $options;
34
+ }
35
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Titleposition.php~ ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_ProductVideo_Model_Config_Source_Titleposition extends Varien_Object
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $vals = array(
8
+ 'outside' => 'outside',
9
+ 'inside' => 'inside',
10
+ 'over' => 'over',
11
+ );
12
+ $options = array();
13
+ foreach ($vals as $k => $v)
14
+ $options[] = array(
15
+ 'value' => $k,
16
+ 'label' => $v
17
+ );
18
+
19
+ return $options;
20
+ }
21
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Transition.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Model_Config_Source_Transition extends Varien_Object
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $vals = array(
22
+ 'elastic' => 'elastic',
23
+ 'fade' => 'fade',
24
+ 'none' => 'none',
25
+ );
26
+ $options = array();
27
+ foreach ($vals as $k => $v)
28
+ $options[] = array(
29
+ 'value' => $k,
30
+ 'label' => $v
31
+ );
32
+
33
+ return $options;
34
+ }
35
+ }
app/code/community/Niveus/ProductVideo/Model/Config/Source/Transition.php~ ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_ProductVideo_Model_Config_Source_Transition extends Varien_Object
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $vals = array(
8
+ 'elastic' => 'elastic',
9
+ 'fade' => 'fade',
10
+ 'none' => 'none',
11
+ );
12
+ $options = array();
13
+ foreach ($vals as $k => $v)
14
+ $options[] = array(
15
+ 'value' => $k,
16
+ 'label' => $v
17
+ );
18
+
19
+ return $options;
20
+ }
21
+ }
app/code/community/Niveus/ProductVideo/Model/Observer.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Model_Observer
18
+ {
19
+ public function catalog_product_save_after($observer)
20
+ {
21
+ $product = $observer->getProduct();
22
+
23
+ $videos = Mage::getModel('productvideo/videos')
24
+ ->getCollection()
25
+ ->addFieldToFilter('product_id', $product->getId())
26
+ ->addFieldToFilter('store_id', $product->getStoreId());
27
+
28
+ foreach ($videos as $video)
29
+ {
30
+ $video->delete();
31
+ }
32
+
33
+
34
+ // Video 1
35
+
36
+ $video1 = $this->_getRequest()->getPost('video1');
37
+ $model = Mage::getModel('productvideo/videos');
38
+
39
+ try
40
+ {
41
+
42
+ if(!is_null($video1) && isset($video1) && $video1!='')
43
+ {
44
+ $model->setProductId($product->getId());
45
+ $model->setStoreId($product->getStoreId());
46
+ $model->setVideoCode($video1);
47
+ $model->save();
48
+ }
49
+ }
50
+ catch (Exception $e)
51
+ {
52
+ Mage::logException($e);
53
+ }
54
+
55
+
56
+
57
+ // Video 2
58
+
59
+ $video2 = $this->_getRequest()->getPost('video2');
60
+ $model = Mage::getModel('productvideo/videos');
61
+ try
62
+ {
63
+
64
+ if(!is_null($video2) && isset($video2) && $video2!='')
65
+ {
66
+ $model->setProductId($product->getId());
67
+ $model->setStoreId($product->getStoreId());
68
+ $model->setVideoCode($video2);
69
+ $model->save();
70
+ }
71
+ }
72
+ catch (Exception $e)
73
+ {
74
+ Mage::logException($e);
75
+ }
76
+
77
+ // Video 3
78
+
79
+ $video3 = $this->_getRequest()->getPost('video3');
80
+ $model = Mage::getModel('productvideo/videos');
81
+ try
82
+ {
83
+ if(!is_null($video3) && isset($video3) && $video3!='')
84
+ {
85
+ $model->setProductId($product->getId());
86
+ $model->setStoreId($product->getStoreId());
87
+ $model->setVideoCode($video3);
88
+ $model->save();
89
+ }
90
+ }
91
+ catch (Exception $e)
92
+ {
93
+ Mage::logException($e);
94
+ }
95
+
96
+ }
97
+
98
+ protected function _getRequest()
99
+ {
100
+ return Mage::app()->getRequest();
101
+ }
102
+
103
+ }
app/code/community/Niveus/ProductVideo/Model/Observer.php~ ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ class Niveus_ProductVideo_Model_Observer
18
+ {
19
+ public function catalog_product_save_after($observer)
20
+ {
21
+ $product = $observer->getProduct();
22
+
23
+ $videos = Mage::getModel('productvideo/videos')
24
+ ->getCollection()
25
+ ->addFieldToFilter('product_id', $product->getId())
26
+ ->addFieldToFilter('store_id', $product->getStoreId());
27
+
28
+ foreach ($videos as $video)
29
+ {
30
+ $video->delete();
31
+ }
32
+
33
+
34
+ // Video 1
35
+
36
+ $video1 = $this->_getRequest()->getPost('video1');
37
+ $model = Mage::getModel('productvideo/videos');
38
+
39
+ try
40
+ {
41
+
42
+ if(!is_null($video1) && isset($video1) && $video1!='')
43
+ {
44
+ $model->setProductId($product->getId());
45
+ $model->setStoreId($product->getStoreId());
46
+ $model->setVideoCode($video1);
47
+ $model->save();
48
+ }
49
+ }
50
+ catch (Exception $e)
51
+ {
52
+ Mage::logException($e);
53
+ }
54
+
55
+
56
+
57
+ // Video 2
58
+
59
+ $video2 = $this->_getRequest()->getPost('video2');
60
+ $model = Mage::getModel('productvideo/videos');
61
+ try
62
+ {
63
+
64
+ if(!is_null($video2) && isset($video2) && $video2!='')
65
+ {
66
+ $model->setProductId($product->getId());
67
+ $model->setStoreId($product->getStoreId());
68
+ $model->setVideoCode($video2);
69
+ $model->save();
70
+ }
71
+ }
72
+ catch (Exception $e)
73
+ {
74
+ Mage::logException($e);
75
+ }
76
+
77
+ // Video 3
78
+
79
+ $video3 = $this->_getRequest()->getPost('video3');
80
+ $model = Mage::getModel('productvideo/videos');
81
+ try
82
+ {
83
+ if(!is_null($video3) && isset($video3) && $video3!='')
84
+ {
85
+ $model->setProductId($product->getId());
86
+ $model->setStoreId($product->getStoreId());
87
+ $model->setVideoCode($video3);
88
+ $model->save();
89
+ }
90
+ }
91
+ catch (Exception $e)
92
+ {
93
+ Mage::logException($e);
94
+ }
95
+
96
+ }
97
+
98
+ protected function _getRequest()
99
+ {
100
+ return Mage::app()->getRequest();
101
+ }
102
+
103
+ }
app/code/community/Niveus/ProductVideo/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+
19
+ class Niveus_ProductVideo_Model_Resource_Eav_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
20
+ {
21
+
22
+ public function getDefaultEntities()
23
+ {
24
+ }
25
+ }
app/code/community/Niveus/ProductVideo/Model/Resource/Eav/Mysql4/Setup.php~ ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ class Niveus_ProductVideo_Model_Resource_Eav_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
6
+ {
7
+
8
+ public function getDefaultEntities()
9
+ {
10
+ }
11
+ }
app/code/community/Niveus/ProductVideo/Model/Resource/Videos.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+ class Niveus_ProductVideo_Model_Resource_Videos extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ $this->_init('productvideo/videos', 'video_id');
23
+ }
24
+ }
app/code/community/Niveus/ProductVideo/Model/Resource/Videos.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Niveus_ProductVideo_Model_Resource_Videos extends Mage_Core_Model_Mysql4_Abstract
5
+ {
6
+ public function _construct()
7
+ {
8
+ $this->_init('productvideo/videos', 'video_id');
9
+ }
10
+ }
app/code/community/Niveus/ProductVideo/Model/Resource/Videos/Collection.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+ class Niveus_ProductVideo_Model_Resource_Videos_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('productvideo/videos');
24
+ }
25
+ }
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
app/code/community/Niveus/ProductVideo/Model/Resource/Videos/Collection.php~ ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Niveus_ProductVideo_Model_Resource_Videos_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
5
+ {
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('productvideo/videos');
10
+ }
11
+ }
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
app/code/community/Niveus/ProductVideo/Model/Videos.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+
18
+ class Niveus_ProductVideo_Model_Videos extends Mage_Core_Model_Abstract
19
+ {
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('productvideo/videos');
24
+ }
25
+ }
app/code/community/Niveus/ProductVideo/Model/Videos.php~ ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Niveus_ProductVideo_Model_Videos extends Mage_Core_Model_Abstract
5
+ {
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('productvideo/videos');
10
+ }
11
+ }
app/code/community/Niveus/ProductVideo/controllers/Adminhtml/VideosController.php ADDED
@@ -0,0 +1 @@
 
0
  * Video Plugin for Magento
1
  *
2
  * This source file is subject to the Open Software License (OSL 3.0)
3
  * that is bundled with this package in the file LICENSE.txt.
4
  * It is also available through the world-wide-web at this URL:
5
  * http://opensource.org/licenses/osl-3.0.php
6
  *
7
  * @category Niveus
8
  * @package Niveus_ProductVideo
9
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
10
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
  * @author Niveus Solutions <support@niveussolutions.com>
12
  */
13
  {
14
  $this->loadLayout();
15
  $this->renderLayout();
16
  }
1
+ <?php
2
  * Video Plugin for Magento
3
  *
4
  * This source file is subject to the Open Software License (OSL 3.0)
5
  * that is bundled with this package in the file LICENSE.txt.
6
  * It is also available through the world-wide-web at this URL:
7
  * http://opensource.org/licenses/osl-3.0.php
8
  *
9
  * @category Niveus
10
  * @package Niveus_ProductVideo
11
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
12
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
  * @author Niveus Solutions <support@niveussolutions.com>
14
  */
15
  {
16
  $this->loadLayout();
17
  $this->renderLayout();
18
  }
app/code/community/Niveus/ProductVideo/controllers/Adminhtml/VideosController.php~ ADDED
@@ -0,0 +1 @@
 
0
  {
1
  $this->loadLayout();
2
  $this->renderLayout();
3
  }
1
+ <?php
2
  {
3
  $this->loadLayout();
4
  $this->renderLayout();
5
  }
app/code/community/Niveus/ProductVideo/etc/adminhtml.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <niveus_productvideo translate="title" module="productvideo">
13
+ <title>Niveus</title>
14
+ <sort_order>1005000</sort_order>
15
+ </niveus_productvideo>
16
+ </children>
17
+ </config>
18
+ </children>
19
+ </system>
20
+ </children>
21
+ </admin>
22
+ </resources>
23
+ </acl>
24
+ </config>
app/code/community/Niveus/ProductVideo/etc/adminhtml.xml~ ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <niveus_productvideo translate="title" module="productvideo">
13
+ <title>Niveus</title>
14
+ <sort_order>1005000</sort_order>
15
+ </niveus_productvideo>
16
+ </children>
17
+ </config>
18
+ </children>
19
+ </system>
20
+ </children>
21
+ </admin>
22
+ </resources>
23
+ </acl>
24
+ </config>
app/code/community/Niveus/ProductVideo/etc/config.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Niveus_ProductVideo>
6
+ <version>0.1.0</version>
7
+ </Niveus_ProductVideo>
8
+ </modules>
9
+
10
+ <global>
11
+ <models>
12
+ <productvideo>
13
+ <class>Niveus_ProductVideo_Model</class>
14
+ <resourceModel>productvideo_resource</resourceModel>
15
+ </productvideo>
16
+ <productvideo_resource>
17
+ <class>Niveus_ProductVideo_Model_Resource</class>
18
+ <entities>
19
+ <videos>
20
+ <table>niveus_youtube_videos</table>
21
+ </videos>
22
+ </entities>
23
+ </productvideo_resource>
24
+ </models>
25
+
26
+ <resources>
27
+ <productvideo_setup>
28
+ <setup>
29
+ <module>Niveus_ProductVideo</module>
30
+ <class>Niveus_ProductVideo_Model_Resource_Eav_Mysql4_Setup</class>
31
+ </setup>
32
+ <connection>
33
+ <use>core_setup</use>
34
+ </connection>
35
+ </productvideo_setup>
36
+ <productvideo_write>
37
+ <connection>
38
+ <use>core_write</use>
39
+ </connection>
40
+ </productvideo_write>
41
+ <productvideo_read>
42
+ <connection>
43
+ <use>core_read</use>
44
+ </connection>
45
+ </productvideo_read>
46
+ </resources>
47
+
48
+ <helpers>
49
+ <productvideo>
50
+ <class>Niveus_ProductVideo_Helper</class>
51
+ </productvideo>
52
+ </helpers>
53
+
54
+ <blocks>
55
+ <productvideo>
56
+ <class>Niveus_ProductVideo_Block</class>
57
+ </productvideo>
58
+
59
+ <catalog>
60
+ <rewrite>
61
+ <product_view_media>Niveus_ProductVideo_Block_Product_View_Media</product_view_media>
62
+ </rewrite>
63
+ </catalog>
64
+
65
+ <adminhtml>
66
+ <rewrite>
67
+ <catalog_product_edit_tabs>Niveus_ProductVideo_Block_Rewrite_AdminhtmlCatalogProductEditTabs</catalog_product_edit_tabs>
68
+ </rewrite>
69
+ </adminhtml>
70
+ </blocks>
71
+
72
+ <events>
73
+ <catalog_product_save_after>
74
+ <observers>
75
+ <productvideo>
76
+ <type>singleton</type>
77
+ <class>productvideo/observer</class>
78
+ <method>catalog_product_save_after</method>
79
+ </productvideo>
80
+ </observers>
81
+ </catalog_product_save_after>
82
+ </events>
83
+ </global>
84
+
85
+ <frontend>
86
+ <layout>
87
+ <updates>
88
+ <productvideo>
89
+ <file>niveusproductvideo.xml</file>
90
+ </productvideo>
91
+ </updates>
92
+ </layout>
93
+ </frontend>
94
+
95
+ <admin>
96
+ <routers>
97
+ <productvideo_admin>
98
+ <use>admin</use>
99
+ <args>
100
+ <module>Niveus_ProductVideo</module>
101
+ <frontName>productvideo</frontName>
102
+ </args>
103
+ </productvideo_admin>
104
+ </routers>
105
+ </admin>
106
+
107
+ <adminhtml>
108
+ <layout>
109
+ <updates>
110
+ <productvideo>
111
+ <file>niveusproductvideo.xml</file>
112
+ </productvideo>
113
+ </updates>
114
+ </layout>
115
+ </adminhtml>
116
+
117
+ </config>
app/code/community/Niveus/ProductVideo/etc/config.xml~ ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Niveus_ProductVideo>
6
+ <version>0.1.0</version>
7
+ </Niveus_ProductVideo>
8
+ </modules>
9
+
10
+ <global>
11
+
12
+ <models>
13
+ <productvideo>
14
+ <class>Niveus_ProductVideo_Model</class>
15
+ <resourceModel>productvideo_resource</resourceModel>
16
+ </productvideo>
17
+ <productvideo_resource>
18
+ <class>Niveus_ProductVideo_Model_Resource</class>
19
+ <entities>
20
+ <videos>
21
+ <table>niveus_youtube_videos</table>
22
+ </videos>
23
+ </entities>
24
+ </productvideo_resource>
25
+ </models>
26
+
27
+ <resources>
28
+ <productvideo_setup>
29
+ <setup>
30
+ <module>Niveus_ProductVideo</module>
31
+ <class>Niveus_ProductVideo_Model_Resource_Eav_Mysql4_Setup</class>
32
+ </setup>
33
+ <connection>
34
+ <use>core_setup</use>
35
+ </connection>
36
+ </productvideo_setup>
37
+ <productvideo_write>
38
+ <connection>
39
+ <use>core_write</use>
40
+ </connection>
41
+ </productvideo_write>
42
+ <productvideo_read>
43
+ <connection>
44
+ <use>core_read</use>
45
+ </connection>
46
+ </productvideo_read>
47
+ </resources>
48
+
49
+ <helpers>
50
+ <productvideo>
51
+ <class>Niveus_ProductVideo_Helper</class>
52
+ </productvideo>
53
+ </helpers>
54
+
55
+ <blocks>
56
+ <productvideo>
57
+ <class>Niveus_ProductVideo_Block</class>
58
+ </productvideo>
59
+
60
+ <catalog>
61
+ <rewrite>
62
+ <product_view_media>Niveus_ProductVideo_Block_Product_View_Media</product_view_media>
63
+ </rewrite>
64
+ </catalog>
65
+
66
+ <adminhtml>
67
+ <rewrite>
68
+ <catalog_product_edit_tabs>Niveus_ProductVideo_Block_Rewrite_AdminhtmlCatalogProductEditTabs</catalog_product_edit_tabs>
69
+ </rewrite>
70
+ </adminhtml>
71
+ </blocks>
72
+
73
+ <events>
74
+ <catalog_product_save_after>
75
+ <observers>
76
+ <productvideo>
77
+ <type>singleton</type>
78
+ <class>productvideo/observer</class>
79
+ <method>catalog_product_save_after</method>
80
+ </productvideo>
81
+ </observers>
82
+ </catalog_product_save_after>
83
+ </events>
84
+ </global>
85
+
86
+ <frontend>
87
+ <layout>
88
+ <updates>
89
+ <productvideo>
90
+ <file>niveusproductvideo.xml</file>
91
+ </productvideo>
92
+ </updates>
93
+ </layout>
94
+ </frontend>
95
+
96
+ <admin>
97
+ <routers>
98
+ <productvideo_admin>
99
+ <use>admin</use>
100
+ <args>
101
+ <module>Niveus_ProductVideo</module>
102
+ <frontName>productvideo</frontName>
103
+ </args>
104
+ </productvideo_admin>
105
+ </routers>
106
+ </admin>
107
+
108
+ <adminhtml>
109
+ <layout>
110
+ <updates>
111
+ <productvideo>
112
+ <file>niveusproductvideo.xml</file>
113
+ </productvideo>
114
+ </updates>
115
+ </layout>
116
+ </adminhtml>
117
+
118
+ </config>
app/code/community/Niveus/ProductVideo/etc/system.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <niveus_tab>
5
+ <label>Niveus Extensions</label>
6
+ <sort_order>1005001</sort_order>
7
+ </niveus_tab>
8
+ </tabs>
9
+ <sections>
10
+ <niveus_productvideo translate="label" module="productvideo">
11
+ <label>Product Video</label>
12
+ <tab>niveus_tab</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>200</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+
19
+ <groups>
20
+ <settings translate="label">
21
+ <label>Settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+
28
+ <fields>
29
+ <enable translate="label comment">
30
+ <label>Enable Module</label>
31
+ <comment><![CDATA[]]></comment>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>0</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </enable>
39
+ </fields>
40
+ </settings>
41
+ </groups>
42
+
43
+ </niveus_productvideo>
44
+ </sections>
45
+ </config>
app/code/community/Niveus/ProductVideo/etc/system.xml~ ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <niveus_tab>
5
+ <label>Niveus Extensions</label>
6
+ <sort_order>1005001</sort_order>
7
+ </niveus_tab>
8
+ </tabs>
9
+ <sections>
10
+ <niveus_productvideo translate="label" module="productvideo">
11
+ <label>Product Video</label>
12
+ <tab>niveus_tab</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>200</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+
19
+ <groups>
20
+ <settings translate="label">
21
+
22
+ <label>Settings</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+
29
+ <fields>
30
+
31
+ <enable translate="label comment">
32
+ <label>Enable Module</label>
33
+ <comment><![CDATA[]]></comment>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>0</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </enable>
41
+
42
+
43
+ </fields>
44
+ </settings>
45
+ </groups>
46
+
47
+ </niveus_productvideo>
48
+ </sections>
49
+ </config>
app/code/community/Niveus/ProductVideo/sql/productvideo_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+
17
+ $installer = $this;
18
+ $installer->startSetup();
19
+
20
+ try
21
+ {
22
+ $installer->run("SELECT * FROM {$this->getTable('niveus_youtube_videos')}");
23
+ }
24
+ catch (Exception $e)
25
+ {
26
+ $installer->run("
27
+ CREATE TABLE IF NOT EXISTS {$this->getTable('niveus_youtube_videos')} (
28
+ `video_id` int(10) NOT NULL AUTO_INCREMENT,
29
+ `product_id` int(10) UNSIGNED NOT NULL,
30
+ `store_id` smallint(5) unsigned NOT NULL default '0',
31
+ `video_code` varchar(256) DEFAULT NULL,
32
+ `video_title` text,
33
+ PRIMARY KEY (`video_id`),
34
+ KEY `NIVEUS_YOUTUBE_VIDEO_PRODUCT_ID_PRODUCT_ENTITY_ID` (`product_id`),
35
+ KEY `NIVEUS_YOUTUBE_VIDEO_STORE_ID_STORE_ID` (`store_id`),
36
+ CONSTRAINT `NIVEUS_YOUTUBE_VIDEO_PRODUCT_ID_PRODUCT_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES {$this->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
37
+ CONSTRAINT `NIVEUS_YOUTUBE_VIDEO_STORE_ID_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
38
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
39
+ ");
40
+
41
+ }
42
+
43
+ $installer->endSetup();
app/code/community/Niveus/ProductVideo/sql/productvideo_setup/mysql4-install-0.1.0.php~ ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ try
7
+ {
8
+ $installer->run("SELECT * FROM {$this->getTable('niveus_youtube_videos')}");
9
+ }
10
+ catch (Exception $e)
11
+ {
12
+ $installer->run("
13
+ CREATE TABLE IF NOT EXISTS {$this->getTable('niveus_youtube_videos')} (
14
+ `video_id` int(10) NOT NULL AUTO_INCREMENT,
15
+ `product_id` int(10) UNSIGNED NOT NULL,
16
+ `store_id` smallint(5) unsigned NOT NULL default '0',
17
+ `video_code` varchar(256) DEFAULT NULL,
18
+ `video_title` text,
19
+ PRIMARY KEY (`video_id`),
20
+ KEY `NIVEUS_YOUTUBE_VIDEO_PRODUCT_ID_PRODUCT_ENTITY_ID` (`product_id`),
21
+ KEY `NIVEUS_YOUTUBE_VIDEO_STORE_ID_STORE_ID` (`store_id`),
22
+ CONSTRAINT `NIVEUS_YOUTUBE_VIDEO_PRODUCT_ID_PRODUCT_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES {$this->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
23
+ CONSTRAINT `NIVEUS_YOUTUBE_VIDEO_STORE_ID_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
25
+ ");
26
+
27
+ }
28
+
29
+ $installer->endSetup();
app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Css_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('niveus_productlabels/form/container.phtml');
9
+ $this->_objectId = Mage::registry('productlabels_css_data')->getId();
10
+ $this->_blockGroup = 'productlabels';
11
+ $this->_controller = 'adminhtml_css';
12
+ $this->_removeButton('back');
13
+ $this->_removeButton('reset');
14
+ $this->_removeButton('delete');
15
+ $this->_addButton('cancel', array(
16
+ 'label' => Mage::helper('adminhtml')->__('Cancel'),
17
+ 'onclick' => 'setLocation(\'' . $this->getCancelUrl() . '\')',
18
+ 'class' => 'back',
19
+ ), -1);
20
+ $this->_updateButton('save', 'label', Mage::helper('productlabels')->__('Save Css'));
21
+
22
+ $this->_addButton('saveandcontinue', array(
23
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
24
+ 'onclick' => 'saveAndContinueEdit()',
25
+ 'class' => 'save',
26
+ ), -100);
27
+
28
+ $this->_formScripts[] = "
29
+
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('productlabels_css_data') && Mage::registry('productlabels_css_data')->getId() ) {
40
+ return Mage::helper('productlabels')->__("Edit Css");
41
+ } else {
42
+ return Mage::helper('productlabels')->__('Add Item');
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Get URL for cancel button
48
+ *
49
+ * @return string
50
+ */
51
+ public function getCancelUrl()
52
+ {
53
+ return $this->getUrl('*/adminhtml_productlabels',array('store' => $this->getRequest()->getParam('store',0)));
54
+ }
55
+
56
+
57
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Form.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Css_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
9
+ 'method' => 'post',
10
+ 'enctype' => 'multipart/form-data'
11
+ )
12
+ );
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Tab/Css.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Css_Edit_Tab_Css extends Niveus_Productlabels_Block_Adminhtml_Element_Formcss
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ $form = new Varien_Data_Form();
9
+ $this->setForm($form);
10
+ $form->setDataObject(Mage::registry('productlabels_css_data'));
11
+ $fieldset = $form->addFieldset('productlabels_css', array('legend'=>Mage::helper('productlabels')->__('Css information')));
12
+ //$fieldsetRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_fieldset');
13
+ $element = $fieldset->addField('content', 'editor', array(
14
+ 'name' => 'content',
15
+ 'label' => Mage::helper('productlabels')->__('Content'),
16
+ 'title' => Mage::helper('productlabels')->__('Content'),
17
+ 'style' => 'width:500px; height:200px;',
18
+ ))->setEntityAttribute(Mage::registry('productlabels_css_data'));
19
+
20
+ $curStore = $this->getRequest()->getParam('store',0);
21
+
22
+ $fieldset->addField('cur_store', 'hidden', array(
23
+ 'name' => 'cur_store',
24
+ ));
25
+
26
+
27
+
28
+
29
+ if($id = Mage::registry('productlabels_css_data')->getId() && Mage::registry('productlabels_css_data')->getStore() == $curStore)
30
+ {
31
+ $fieldset->addField('id', 'hidden', array(
32
+ 'name' => 'id',
33
+ 'value' => Mage::registry('productlabels_css_data')->getId()
34
+ ));
35
+ }
36
+
37
+ if ( Mage::getSingleton('adminhtml/session')->getProductlabelsCssData() )
38
+ {
39
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductlabelsCssData());
40
+ Mage::getSingleton('adminhtml/session')->setProductlabelsCssData(null);
41
+ } elseif ( Mage::registry('productlabels_css_data') ) {
42
+ $form->setValues(Mage::registry('productlabels_css_data')->getData());
43
+ }
44
+ return parent::_prepareForm();
45
+ }
46
+
47
+ public function getStoreCode()
48
+ {
49
+ return $this->getRequest()->getParam('store', '');
50
+ }
51
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Css/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Css_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('css_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('productlabels')->__('Css Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('productlabels')->__('Css Information'),
18
+ 'title' => Mage::helper('productlabels')->__('Css Information'),
19
+ 'content' => $this->getLayout()->createBlock('productlabels/adminhtml_css_edit_tab_css')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Fieldset.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Element_Fieldset extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
3
+ {
4
+ /*public function getScopeLabel()
5
+ {
6
+ $html = '';
7
+ $attribute_code = $this->getElement()->getName();
8
+ $attribute = Mage::getModel('productlabels/attribute')->getCollection()
9
+ ->addFieldToFilter('name_attribute',$attribute_code)->setPageSize(1)
10
+ ->getFirstItem();
11
+ $this->setData('attribute',$attribute);
12
+ if (!$attribute || Mage::app()->isSingleStoreMode()) {
13
+ return $html;
14
+ }
15
+ if ($attribute->isScopeGlobal()) {
16
+ $html.= '[GLOBAL]';
17
+ }
18
+ elseif ($attribute->isScopeWebsite()) {
19
+ $html.= '[WEBSITE]';
20
+ }
21
+ elseif ($attribute->isScopeStore()) {
22
+ $html.= '[STORE VIEW]';
23
+ }
24
+
25
+ return $html;
26
+ }*/
27
+
28
+ /*public function getAttribute()
29
+ {
30
+ return $this->getData('attribute');
31
+ }*/
32
+
33
+ public function getAttributeCode()
34
+ {
35
+ return $this->getAttribute()->getNameAttribute();
36
+ }
37
+
38
+ /*public function getDataObject()
39
+ {
40
+ return Mage::registry('productlabels_data');
41
+ }*/
42
+
43
+ public function usedDefault()
44
+ {
45
+ $store = $this->getRequest()->getParam('store');
46
+ if(!$store)
47
+ return false;
48
+ $attribute = $this->getAttribute();
49
+ if(!$attribute->getType())
50
+ return false;
51
+ $storeIn = Mage::registry('productlabels_data')->getData($attribute->getNameAttribute().'_in_store');
52
+ //if($attribute->getId() == 6){echo $storeIn;exit;}
53
+ if($storeIn == $this->_getDefaultStoreId() || !$storeIn)
54
+ return true;
55
+ return false;
56
+
57
+ //return in_array($attribute->getId(), Mage::registry('attribute_default'));
58
+ //return !$storeIn || ($storeIn != $this->_getDefaultStoreId());
59
+ /*$collection = Mage::getModel('productlabels/type_'.$attribute->getType())->getCollection()
60
+ ->addFieldToFilter('label_id',$this->getRequest()->getParam('id'))
61
+ ->addFieldToFilter('attribute_id',$attribute->getId())
62
+ ->addFieldToFilter('store_id',$this->getRequest()->getParam('store'));
63
+ /* if($collection->count() == 0)
64
+ $this->getElement()->setDisabled(true);*/
65
+ //return $collection->count() == 0;
66
+ }
67
+
68
+ /**
69
+ * Default sore ID getter
70
+ *
71
+ * @return integer
72
+ */
73
+ protected function _getDefaultStoreId()
74
+ {
75
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
76
+ }
77
+
78
+
79
+
80
+
81
+ }
82
+
83
+ ?>
app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Fieldsetcss.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Element_Fieldsetcss extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
3
+ {
4
+ /*public function getScopeLabel()
5
+ {
6
+ $html = '';
7
+ $attribute_code = $this->getElement()->getName();
8
+ $attribute = Mage::getModel('productlabels/attribute')->getCollection()
9
+ ->addFieldToFilter('name_attribute',$attribute_code)->setPageSize(1)
10
+ ->getFirstItem();
11
+ $this->setData('attribute',$attribute);
12
+ if (!$attribute || Mage::app()->isSingleStoreMode()) {
13
+ return $html;
14
+ }
15
+ if ($attribute->isScopeGlobal()) {
16
+ $html.= '[GLOBAL]';
17
+ }
18
+ elseif ($attribute->isScopeWebsite()) {
19
+ $html.= '[WEBSITE]';
20
+ }
21
+ elseif ($attribute->isScopeStore()) {
22
+ $html.= '[STORE VIEW]';
23
+ }
24
+
25
+ return $html;
26
+ }*/
27
+
28
+ /*public function getAttribute()
29
+ {
30
+ return $this->getData('attribute');
31
+ }*/
32
+
33
+ public function getAttributeCode()
34
+ {
35
+ return $this->getAttribute()->getNameAttribute();
36
+ }
37
+
38
+ /*public function getDataObject()
39
+ {
40
+ return Mage::registry('productlabels_data');
41
+ }*/
42
+
43
+ public function usedDefault()
44
+ {
45
+ $store = $this->getRequest()->getParam('store');
46
+ if(!$store)
47
+ return false;
48
+
49
+ return Mage::registry('productlabels_css_data')->getStore() == 0;
50
+ }
51
+
52
+
53
+
54
+
55
+ }
56
+
57
+ ?>
app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Form.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Element_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareLayout()
5
+ {
6
+ Varien_Data_Form::setElementRenderer(
7
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
8
+ );
9
+ Varien_Data_Form::setFieldsetRenderer(
10
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')
11
+ );
12
+ Varien_Data_Form::setFieldsetElementRenderer(
13
+ $this->getLayout()->createBlock('productlabels/adminhtml_element_fieldset')
14
+ );
15
+ }
16
+ }
17
+
18
+ ?>
app/code/community/Niveus/Productlabels/Block/Adminhtml/Element/Formcss.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Element_Formcss extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareLayout()
5
+ {
6
+ Varien_Data_Form::setElementRenderer(
7
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
8
+ );
9
+ Varien_Data_Form::setFieldsetRenderer(
10
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')
11
+ );
12
+ Varien_Data_Form::setFieldsetElementRenderer(
13
+ $this->getLayout()->createBlock('productlabels/adminhtml_element_fieldsetcss')
14
+ );
15
+ }
16
+ }
17
+
18
+ ?>
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_productlabels';
7
+ $this->_blockGroup = 'productlabels';
8
+ $this->_headerText = Mage::helper('productlabels')->__('Product labels Manager');
9
+ $this->_addButtonLabel = Mage::helper('productlabels')->__('Add New Label');
10
+ parent::__construct();
11
+ $this->setTemplate('niveus_productlabels/grid/container.phtml');
12
+ $this->_addButton('css', array(
13
+ 'label' => $this->__('CSS Editor'),
14
+ 'onclick' => 'setLocation(\'' . $this->getCssUrl() .'\')',
15
+ 'class' => 'css',
16
+ ));
17
+ }
18
+
19
+ public function _prepareLayout()
20
+ {
21
+ /**
22
+ * Display store switcher if system has more one store
23
+ */
24
+ if (!Mage::app()->isSingleStoreMode()) {
25
+ $this->setChild('store_switcher',
26
+ $this->getLayout()->createBlock('adminhtml/store_switcher')
27
+ ->setUseConfirm(false)
28
+ ->setSwitchUrl($this->getUrl('*/*/*', array('store'=>null)))
29
+ );
30
+ }
31
+ parent::_prepareLayout();
32
+ }
33
+
34
+ public function getCssUrl()
35
+ {
36
+ return $this->getUrl('*/adminhtml_css/edit');
37
+ }
38
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('niveus_productlabels/form/container.phtml');
9
+
10
+ $this->_objectId = 'id';
11
+ $this->_blockGroup = 'productlabels';
12
+ $this->_controller = 'adminhtml_productlabels';
13
+
14
+ $this->_updateButton('save', 'label', Mage::helper('productlabels')->__('Save Label'));
15
+ $this->_updateButton('delete', 'label', Mage::helper('productlabels')->__('Delete Label'));
16
+
17
+ $this->_addButton('saveandcontinue', array(
18
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
19
+ 'onclick' => 'saveAndContinueEdit()',
20
+ 'class' => 'save',
21
+ ), -100);
22
+
23
+ $this->_formScripts[] = "
24
+ function toggleEditor() {
25
+ if (tinyMCE.getInstanceById('productlabels_content') == null) {
26
+ tinyMCE.execCommand('mceAddControl', false, 'productlabels_content');
27
+ } else {
28
+ tinyMCE.execCommand('mceRemoveControl', false, 'productlabels_content');
29
+ }
30
+ }
31
+
32
+ function saveAndContinueEdit(){
33
+ editForm.submit($('edit_form').action+'back/edit/');
34
+ }
35
+
36
+ function deletePicture(id)
37
+ {
38
+ $(id + '-pic').setStyle({'display':'none'});
39
+ $('no' + id).value = 1;
40
+ }
41
+ ";
42
+ }
43
+
44
+
45
+
46
+ public function getBackUrl()
47
+ {
48
+ return $this->getUrl('*/*/',array('store' => $this->getRequest()->getParam('store',0)));
49
+ }
50
+
51
+ public function getHeaderText()
52
+ {
53
+ if( Mage::registry('productlabels_data') && Mage::registry('productlabels_data')->getId() ) {
54
+ return Mage::helper('productlabels')->__("Edit Label '%s'", $this->htmlEscape(Mage::registry('productlabels_data')->getName()));
55
+ } else {
56
+ return Mage::helper('productlabels')->__('Add Label');
57
+ }
58
+ }
59
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+
20
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Tab/Form.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels_Edit_Tab_Form extends Niveus_Productlabels_Block_Adminhtml_Element_Form
4
+ {
5
+
6
+ /**
7
+ * Class constructor
8
+ *
9
+ */
10
+ protected function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->setTemplate('niveus_productlabels/edit/form.phtml');
14
+ }
15
+
16
+
17
+
18
+ protected function _prepareForm()
19
+ {
20
+ $form = new Varien_Data_Form();
21
+ $this->setForm($form);
22
+ $form->setDataObject(Mage::registry('productlabels_data'));
23
+ $fieldset = $form->addFieldset('productlabels_form', array('legend'=>Mage::helper('productlabels')->__('General information')));
24
+
25
+
26
+
27
+ $fieldset->addField('store', 'hidden', array(
28
+ 'name' => 'store',
29
+ ));
30
+
31
+ $fieldset->addField('id', 'hidden', array(
32
+ 'name' => 'id',
33
+ ));
34
+
35
+ $this->_setFieldset($fieldset);
36
+
37
+
38
+ $this->initFormCondition($form);
39
+
40
+
41
+ if ( Mage::getSingleton('adminhtml/session')->getProductlabelsData() )
42
+ {
43
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductlabelsData());
44
+ Mage::getSingleton('adminhtml/session')->setProductlabelsData(null);
45
+ } elseif ( Mage::registry('productlabels_data') ) {
46
+ $form->setValues(Mage::registry('productlabels_data')->getData());
47
+ }
48
+ return parent::_prepareForm();
49
+ }
50
+
51
+ public function _setFieldset($fieldset)
52
+ {
53
+ $attributes = Mage::getModel('productlabels/attribute')->getCollection();
54
+
55
+ foreach($attributes as $a)
56
+ {
57
+ $atrName = $a->getNameAttribute();
58
+ $data = array(
59
+ 'label' => Mage::helper('productlabels')->__($a->getTitle()),
60
+ 'title' => Mage::helper('productlabels')->__($a->getTitle()),
61
+ 'name' => $atrName,
62
+ 'required' => $a->getRequire()
63
+ );
64
+ if($a->getClass())
65
+ $data['class'] = $a->getClass();
66
+ if($atrName == 'texthtml')
67
+ {
68
+ $data['style'] = 'width:300px; height:200px;';
69
+ $data['wysiwyg'] = false;
70
+ }
71
+ elseif($atrName == 'enable')
72
+ {
73
+ $data['checked'] = (Mage::registry('productlabels_data')->getEnable()=="1") ? true : false;
74
+ $data['onclick'] = 'this.value = this.checked ? 1 : 2;';
75
+ }
76
+ $element = $fieldset->addField($atrName, $a->getTypeBackend(), $data)
77
+ ->setEntityAttribute($a);
78
+ if($atrName == 'texthtml')
79
+ $this->addInsertVariableButton($fieldset);
80
+ if($a->getTypeBackend() == 'file')
81
+ {
82
+ $pathImage = Mage::registry('productlabels_data')->getData($atrName);
83
+ if($pathImage && $pathImage != 'nopic')
84
+ {
85
+
86
+ $imageHtml = "<div>
87
+ <img id='$atrName-pic' src='".Mage::helper('productlabels')->resizeImage($pathImage,50,50,"niveus_productlabels/".$atrName,'admin')."'/>
88
+ <input type='hidden' name='no$atrName' value='0' id='no$atrName'/>
89
+ <input type='hidden' name='cur$atrName' value='$pathImage' id='cur$atrName'/>
90
+ <button type='button' onclick='deletePicture(\"$atrName\");return false;'><span><span>Delete Image</span></span></button>
91
+ </div>";
92
+ $element->setAfterElementHtml($imageHtml);
93
+ }
94
+ }
95
+
96
+ }
97
+
98
+
99
+
100
+ }
101
+
102
+ public function addInsertVariableButton($fieldset)
103
+ {
104
+ /* Add Insert Varialbe Button */
105
+ $fieldset->addField('orig_template_variables', 'hidden', array(
106
+ 'name' => 'orig_template_variables',
107
+ ));
108
+
109
+ $fieldset->addField('variables', 'hidden', array(
110
+ 'name' => 'variables'
111
+ ));
112
+
113
+ $fieldset->addField('template_variables', 'hidden', array(
114
+ 'name' => 'template_variables',
115
+ ));
116
+
117
+ $insertVariableButton = $this->getLayout()
118
+ ->createBlock('adminhtml/widget_button', '', array(
119
+ 'type' => 'button',
120
+ 'label' => Mage::helper('adminhtml')->__('Insert Variable...'),
121
+ 'onclick' => 'templateControl.openVariableChooser();return false;'
122
+ ));
123
+
124
+ $fieldset->addField('insert_variable', 'note', array(
125
+ 'text' => $insertVariableButton->toHtml()
126
+ ));
127
+ }
128
+
129
+
130
+
131
+ public function initFormCondition($form)
132
+ {
133
+ $model = Mage::getModel('productlabels/rule');
134
+
135
+ $actionsArr = unserialize(Mage::registry('productlabels_data')->getActions());
136
+
137
+ if (!empty($actionsArr) && is_array($actionsArr)) {
138
+ $model->getActions()->loadArray($actionsArr);
139
+ }
140
+
141
+ $model->getActions()->setJsFormObject('rule_actions_fieldset');
142
+
143
+ $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
144
+ ->setTemplate('promo/fieldset.phtml')
145
+ ->setNewChildUrl(str_replace('productlabels_admin',Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName'),$this->getUrl('*/promo_quote/newActionHtml/form/rule_actions_fieldset')));
146
+
147
+ $fieldset = $form->addFieldset('rule_actions_fieldset', array(
148
+ 'legend'=>Mage::helper('productlabels')->__('Conditions')
149
+ ))->setRenderer($renderer);
150
+
151
+ $element = $fieldset->addField('actions', 'text', array(
152
+ 'name' => 'actions',
153
+ 'label' => Mage::helper('salesrule')->__('Apply To'),
154
+ 'title' => Mage::helper('salesrule')->__('Apply To'),
155
+ 'required' => true,
156
+ ))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
157
+
158
+ $element->setAfterElementHtml('<span class="value scope-label">'.Mage::helper('productlabels')->__('[GLOBAL]').'</span>');
159
+ Mage::dispatchEvent('adminhtml_block_salesrule_actions_prepareform', array('form' => $form));
160
+
161
+ $form->setValues($model->getData());
162
+
163
+ }
164
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('productlabels_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('productlabels')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('productlabels')->__('Item Information'),
18
+ 'title' => Mage::helper('productlabels')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('productlabels/adminhtml_productlabels_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/Niveus/Productlabels/Block/Adminhtml/Productlabels/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Block_Adminhtml_Productlabels_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productlabelsGrid');
9
+ $this->setDefaultSort('id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('productlabels/productlabels')->getCollection();
18
+ $collection->addAttributeToSelect(array('enable'));
19
+
20
+ $this->setCollection($collection);
21
+ return parent::_prepareCollection();
22
+ }
23
+
24
+ protected function _prepareColumns()
25
+ {
26
+ $this->addColumn('id', array(
27
+ 'header' => Mage::helper('productlabels')->__('ID'),
28
+ 'align' =>'right',
29
+ 'width' => '50px',
30
+ 'index' => 'id',
31
+ ));
32
+
33
+ $this->addColumn('name', array(
34
+ 'header' => Mage::helper('productlabels')->__('Title'),
35
+ 'align' =>'left',
36
+ 'index' => 'name',
37
+ ));
38
+
39
+
40
+
41
+ $this->addColumn('enable', array(
42
+ 'header' => Mage::helper('productlabels')->__('Status'),
43
+ 'align' => 'left',
44
+ 'width' => '80px',
45
+ 'index' => 'enable',
46
+ 'type' => 'options',
47
+ //'filter_index' => 'enabletbl.value',
48
+ 'options' => array(
49
+ 1 => 'Enabled',
50
+ 2 => 'Disabled',
51
+ ),
52
+ ));
53
+
54
+ $this->addColumn('action',
55
+ array(
56
+ 'header' => Mage::helper('productlabels')->__('Action'),
57
+ 'width' => '100',
58
+ 'type' => 'action',
59
+ 'getter' => 'getId',
60
+ 'actions' => array(
61
+ array(
62
+ 'caption' => Mage::helper('productlabels')->__('Edit'),
63
+ 'url' => array('base'=> '*/*/edit'),
64
+ 'field' => 'id'
65
+ )
66
+ ),
67
+ 'filter' => false,
68
+ 'sortable' => false,
69
+ 'index' => 'stores',
70
+ 'is_system' => true,
71
+ ));
72
+
73
+ $this->addExportType('*/*/exportCsv', Mage::helper('productlabels')->__('CSV'));
74
+ $this->addExportType('*/*/exportXml', Mage::helper('productlabels')->__('XML'));
75
+
76
+ return parent::_prepareColumns();
77
+ }
78
+
79
+ protected function _prepareMassaction()
80
+ {
81
+ $this->setMassactionIdField('productlabels_id');
82
+ $this->getMassactionBlock()->setFormFieldName('productlabels');
83
+
84
+ $this->getMassactionBlock()->addItem('delete', array(
85
+ 'label' => Mage::helper('productlabels')->__('Delete'),
86
+ 'url' => $this->getUrl('*/*/massDelete'),
87
+ 'confirm' => Mage::helper('productlabels')->__('Are you sure?')
88
+ ));
89
+
90
+ $statuses = Mage::getSingleton('productlabels/status')->getOptionArray();
91
+
92
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
93
+ $this->getMassactionBlock()->addItem('status', array(
94
+ 'label'=> Mage::helper('productlabels')->__('Change status'),
95
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true,'store' => $this->getRequest()->getParam('store',0))),
96
+ 'additional' => array(
97
+ 'visibility' => array(
98
+ 'name' => 'status',
99
+ 'type' => 'select',
100
+ 'class' => 'required-entry',
101
+ 'label' => Mage::helper('productlabels')->__('Status'),
102
+ 'values' => $statuses
103
+ )
104
+ )
105
+ ));
106
+ return $this;
107
+ }
108
+
109
+ public function getRowUrl($row)
110
+ {
111
+ return $this->getUrl('*/*/edit', array('id' => $row->getId(),
112
+ 'store' => $this->getRequest()->getParam('store',0))
113
+ );
114
+ }
115
+
116
+ }
app/code/community/Niveus/Productlabels/Block/Css.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Css extends Mage_Core_Block_Template
3
+ {
4
+ public function _toHtml() {
5
+ $css = $this->getCss();
6
+ if($css)
7
+ echo "<style type='text/css'>$css</style>";
8
+ parent::_toHtml();
9
+ }
10
+
11
+
12
+ public function getCss()
13
+ {
14
+ $store = Mage::app()->getStore()->getId();
15
+ $css = Mage::getModel('productlabels/css')->getCollection()
16
+ ->setStoreId(array($this->_getDefaultStoreId(),$store));
17
+ foreach($css as $c)
18
+ {
19
+ $content = $c->getContent();
20
+ if($c->getStore() == $store)
21
+ break;
22
+ }
23
+ return $content;
24
+ }
25
+
26
+ /**
27
+ * Default sore ID getter
28
+ *
29
+ * @return integer
30
+ */
31
+ protected function _getDefaultStoreId()
32
+ {
33
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
34
+ }
35
+
36
+ }
app/code/community/Niveus/Productlabels/Block/Productlabels.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Block_Productlabels extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getProductlabels()
10
+ {
11
+ if (!$this->hasData('productlabels')) {
12
+ $this->setData('productlabels', Mage::registry('productlabels'));
13
+ }
14
+ return $this->getData('productlabels');
15
+
16
+ }
17
+
18
+ public function addObject($_object)
19
+ {
20
+ $this->setData('object',$_object);
21
+ return $this;
22
+ }
23
+
24
+ public function getObject()
25
+ {
26
+ return $this->getData('object');
27
+ }
28
+ }
app/code/community/Niveus/Productlabels/Helper/Data.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ protected $labels;
5
+ public function resizeImage($imageName, $width=NULL, $height=NULL, $imagePath=NULL,$type)
6
+ {
7
+ $imagePath = str_replace("/", DS, $imagePath);
8
+ $imagePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $imageName;
9
+
10
+ if($width == NULL && $height == NULL) {
11
+ $width = 100;
12
+ $height = 100;
13
+ }
14
+ $resizePath = $width . 'x' . $height;
15
+ $resizePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $type. DS . $resizePath . DS . $imageName;
16
+
17
+ if (file_exists($imagePathFull) && !file_exists($resizePathFull)) {
18
+ $imageObj = new Varien_Image($imagePathFull);
19
+ $imageObj->keepTransparency(true);
20
+ //$imageObj->constrainOnly(TRUE);
21
+ $imageObj->keepAspectRatio(TRUE);
22
+ $imageObj->resize($width,$height);
23
+ $imageObj->save($resizePathFull);
24
+ }
25
+
26
+ $imagePath=str_replace(DS, "/", $imagePath);
27
+ return Mage::getBaseUrl("media") . $imagePath . "/" . $type . "/" . $resizePath . "/" . $imageName;
28
+ }
29
+
30
+ function initLabels()
31
+ {
32
+ if($this->labels)
33
+ return $this->labels;
34
+
35
+ $label = Mage::getModel('productlabels/productlabels');
36
+ $attributes = $label->getAttributes();
37
+ $collection = $label->getCollection();
38
+ foreach($attributes as $a)
39
+ {
40
+ $atrNameTbl = $a->getNameAttribute().'tbl';
41
+ $atrNameTblDefault = $a->getNameAttribute().'tbl_default';
42
+ $collection->getSelect()->joinLeft(array($atrNameTbl => $collection->getTable('productlabels/type_'.$a->getType())),
43
+ "$atrNameTbl.label_id = main_table.id
44
+ AND $atrNameTbl.attribute_id = ".$a->getId()."
45
+ AND $atrNameTbl.store_id = ".Mage::app()->getStore()->getId(), array(
46
+ ))->joinLeft(array($atrNameTblDefault => $collection->getTable('productlabels/type_'.$a->getType())),
47
+ "$atrNameTblDefault.label_id = main_table.id
48
+ AND $atrNameTblDefault.attribute_id = ".$a->getId()."
49
+ AND $atrNameTblDefault.store_id = ".$this->_getDefaultStoreId(), array(
50
+ $a->getNameAttribute() => "if($atrNameTbl.value <> 'NULL',$atrNameTbl.value,$atrNameTblDefault.value)"
51
+ ));
52
+ }
53
+ $this->labels = $collection;
54
+ return $this->labels;
55
+ }
56
+
57
+ function display($_product)
58
+ {
59
+ $labels = $this->initLabels();
60
+ $block = new Niveus_Productlabels_Block_Productlabels();
61
+ $labelShows = array();
62
+ foreach ($labels as $label)
63
+ {
64
+ $catalogRule = Mage::getModel('productlabels/rule');
65
+ $actionsArr = unserialize($label->getActions());
66
+ if (!empty($actionsArr) && is_array($actionsArr)) {
67
+ $catalogRule->getConditions()->loadArray($actionsArr);
68
+ }
69
+ $object = new Varien_Object();
70
+ $object->setData('product', $_product);
71
+ $object->setData('label', $label);
72
+
73
+ if($validate = (bool)$catalogRule->validate($object) && $label->getEnable() == 1)
74
+ {
75
+ $labelShows[] = $label;
76
+
77
+ }
78
+
79
+ }
80
+ if(!empty ($labelShows))
81
+ {
82
+ echo $block->addObject(array('labels'=>$labelShows,'product'=>$_product))->setTemplate('Niveus_productlabels/productlabels.phtml')->toHtml();
83
+ }
84
+
85
+
86
+
87
+ }
88
+
89
+ /**
90
+ * Default sore ID getter
91
+ *
92
+ * @return integer
93
+ */
94
+ protected function _getDefaultStoreId()
95
+ {
96
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
97
+ }
98
+ }
app/code/community/Niveus/Productlabels/Model/Attribute.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Attribute extends Mage_Core_Model_Abstract
3
+ {
4
+ const SCOPE_STORE = 0;
5
+ const SCOPE_GLOBAL = 1;
6
+ const SCOPE_WEBSITE = 2;
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('productlabels/attribute');
11
+ }
12
+
13
+ public function getIsGlobal()
14
+ {
15
+ return $this->getScopeGlobal();
16
+ }
17
+
18
+ /**
19
+ * Retrieve attribute is global scope flag
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isScopeGlobal()
24
+ {
25
+ return $this->getIsGlobal() == self::SCOPE_GLOBAL;
26
+ }
27
+
28
+ /**
29
+ * Retrieve attribute is website scope website
30
+ *
31
+ * @return bool
32
+ */
33
+ public function isScopeWebsite()
34
+ {
35
+ return $this->getIsGlobal() == self::SCOPE_WEBSITE;
36
+ }
37
+
38
+ public function isScopeStore()
39
+ {
40
+ return !$this->isScopeGlobal() && !$this->isScopeWebsite();
41
+ }
42
+
43
+
44
+ }
app/code/community/Niveus/Productlabels/Model/Config/Listlabel.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Config_Listlabel
3
+ {
4
+ protected $_options;
5
+ protected $_list = null;
6
+ public function toOptionArray()
7
+ {
8
+ if (!$this->_options) {
9
+ if($this->_list == null)
10
+ {
11
+ $this->_list = Mage::getModel('productlabels/productlabels')->getCollection();
12
+ }
13
+
14
+ $data = array();
15
+ if($this->_list->count())
16
+ {
17
+ foreach($this->_list as $l)
18
+ {
19
+ $data[] = array('value'=>$l->getId(),'label'=>$l->getName());
20
+ }
21
+ }
22
+
23
+ $this->_options = $data;
24
+ }
25
+ return $this->_options;
26
+ }
27
+ }
28
+
app/code/community/Niveus/Productlabels/Model/Css.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Css extends Mage_Core_Model_Abstract
4
+ {
5
+ const SCOPE_STORE = 0;
6
+ const SCOPE_GLOBAL = 1;
7
+ const SCOPE_WEBSITE = 2;
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productlabels/css');
12
+ }
13
+
14
+ public function getIsGlobal()
15
+ {
16
+ return $this->getScopeGlobal();
17
+ }
18
+
19
+ /**
20
+ * Retrieve attribute is global scope flag
21
+ *
22
+ * @return bool
23
+ */
24
+ public function isScopeGlobal()
25
+ {
26
+ return $this->getIsGlobal() == self::SCOPE_GLOBAL;
27
+ }
28
+
29
+ /**
30
+ * Retrieve attribute is website scope website
31
+ *
32
+ * @return bool
33
+ */
34
+ public function isScopeWebsite()
35
+ {
36
+ return $this->getIsGlobal() == self::SCOPE_WEBSITE;
37
+ }
38
+
39
+ public function isScopeStore()
40
+ {
41
+ return !$this->isScopeGlobal() && !$this->isScopeWebsite();
42
+ }
43
+
44
+ public function hasGlobal()
45
+ {
46
+ return $this->getCollection()->addFieldToFilter('store',0)->count() > 0;
47
+ }
48
+
49
+ public function getStoreId()
50
+ {
51
+ return Mage::app()->getRequest()->getParam('store',0);
52
+ }
53
+ }
app/code/community/Niveus/Productlabels/Model/Filter.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Filter extends Mage_Widget_Model_Template_Filter
3
+ {
4
+ /**
5
+ * Filter the string as template.
6
+ *
7
+ * @param string $value
8
+ * @return string
9
+ */
10
+ public function filter($object)
11
+ {
12
+ if(!is_string($object))
13
+ {
14
+ $value = $object->getText();
15
+ $product = $object->getProduct();
16
+ }
17
+ else
18
+ $value = $object;
19
+ $customVariables = $this->getCustomVariable();
20
+ // "depend" and "if" operands should be first
21
+ foreach (array(
22
+ self::CONSTRUCTION_DEPEND_PATTERN => 'dependDirective',
23
+ self::CONSTRUCTION_IF_PATTERN => 'ifDirective',
24
+ ) as $pattern => $directive) {
25
+ if (preg_match_all($pattern, $value, $constructions, PREG_SET_ORDER)) {
26
+ foreach($constructions as $index => $construction) {
27
+ $replacedValue = '';
28
+ $callback = array($this, $directive);
29
+ if(!is_callable($callback)) {
30
+ continue;
31
+ }
32
+ try {
33
+ $replacedValue = call_user_func($callback, $construction);
34
+ } catch (Exception $e) {
35
+ throw $e;
36
+ }
37
+ $value = str_replace($construction[0], $replacedValue, $value);
38
+ }
39
+ }
40
+ }
41
+
42
+ if(preg_match_all(self::CONSTRUCTION_PATTERN, $value, $constructions, PREG_SET_ORDER)) {
43
+
44
+ foreach($constructions as $index=>$construction) {
45
+ $replacedValue = '';
46
+ $callback = array($this, $construction[1].'Directive');
47
+ if(!is_callable($callback)) {
48
+ continue;
49
+ }
50
+ try {
51
+ $replacedValue = call_user_func($callback, $construction);
52
+
53
+ if(in_array($construction[0], $customVariables))
54
+ {
55
+ $replacedValue = $this->getCustomVariableValue($construction,$product);
56
+ }
57
+ } catch (Exception $e) {
58
+ throw $e;
59
+ }
60
+ $value = str_replace($construction[0], $replacedValue, $value);
61
+ }
62
+ }
63
+ return $value;
64
+ }
65
+
66
+ public function getCustomVariable()
67
+ {
68
+ return array(
69
+ '{{var save_percent}}',
70
+ '{{var save_price}}',
71
+ '{{var product.price}}',
72
+ '{{var product.special_price}}',
73
+ '{{var product.qty}}'
74
+ );
75
+ }
76
+
77
+ public function getCustomVariableValue($construction,$_product)
78
+ {
79
+ $type = trim($construction[2]);
80
+ if($type == 'save_percent')
81
+ {
82
+ $specialPrice = $_product->getSpecialPrice();
83
+ $regularPrice = $_product->getPrice();
84
+ if($specialPrice > 0)
85
+ return number_format(100*(float)($regularPrice-$specialPrice)/$regularPrice,0);
86
+ else
87
+ return 0;
88
+ }
89
+ elseif($type == 'save_price'){
90
+ $specialPrice = $_product->getSpecialPrice();
91
+ $regularPrice = $_product->getPrice();
92
+ if($specialPrice > 0)
93
+ return rtrim(rtrim( number_format(($regularPrice-$specialPrice), 2, ".", ""),'0'),'.');
94
+ else
95
+ return Mage::helper('core')->formatPrice(0, false);
96
+ }
97
+ elseif($type == 'product.price')
98
+ {
99
+ return Mage::helper('core')->formatPrice($_product->getPrice(), false);
100
+ }
101
+ elseif($type == 'product.special_price'){
102
+ return Mage::helper('core')->formatPrice($_product->getSpecialPrice(), false);
103
+ }
104
+ else{
105
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
106
+ $qty = $stock->getQty();
107
+ if($stock->getIsQtyDecimal() == 0)
108
+ $qty = (int)$qty;
109
+ return $qty;
110
+ }
111
+ }
112
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Attribute.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Attribute extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/attribute', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Attribute/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Attribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/attribute');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Css.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Css extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/css', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Css/Collection.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Css_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/css');
9
+ }
10
+
11
+ public function setStoreId($stores)
12
+ {
13
+ if(is_array($stores))
14
+ $this->addFieldToFilter('store',array('in' => $stores));
15
+ else
16
+ $this->addFieldToFilter('store',Mage::app()->getRequest()->getParam('store', 0));
17
+ $this->addOrder('store', 'ASC');
18
+ //echo (string)$this->getSelect();exit;
19
+ return $this;
20
+ }
21
+
22
+
23
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Productlabels.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Productlabels extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/productlabels', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Productlabels/Collection.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Mysql4_Productlabels_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ /**
5
+ * Joined attributes
6
+ *
7
+ * @var array
8
+ */
9
+ protected $_joinAttributes = array();
10
+
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('productlabels/productlabels');
15
+ }
16
+
17
+ public function addAttributesToSelect($label)
18
+ {
19
+
20
+ $attributes = $label->getAttributes();
21
+
22
+ foreach($attributes as $a)
23
+ {
24
+ $atrNameTbl = $a->getNameAttribute().'tbl';
25
+ $atrNameTblDefault = $a->getNameAttribute().'tbl_default';
26
+ $this->getSelect()->joinLeft(array($atrNameTbl => $this->getTable('productlabels/type_'.$a->getType())),
27
+ "$atrNameTbl.label_id = ".$label->getId()."
28
+ AND $atrNameTbl.attribute_id = ".$a->getId()."
29
+ AND $atrNameTbl.store_id = ".$this->getStore(), array(
30
+ ))->joinLeft(array($atrNameTblDefault => $this->getTable('productlabels/type_'.$a->getType())),
31
+ "$atrNameTblDefault.label_id = ".$label->getId()."
32
+ AND $atrNameTblDefault.attribute_id = ".$a->getId()."
33
+ AND $atrNameTblDefault.store_id = ".$this->_getDefaultStoreId(), array(
34
+ $a->getNameAttribute() => "if($atrNameTbl.value <> 'NULL',$atrNameTbl.value,$atrNameTblDefault.value)",
35
+ $a->getNameAttribute().'_in_store' => "if($atrNameTbl.store_id <> 'NULL',$atrNameTbl.store_id,$atrNameTblDefault.store_id)"
36
+ ));
37
+ }
38
+ $this->getSelect()->where('main_table.id='.$label->getId());
39
+
40
+ return $this;
41
+ }
42
+
43
+ public function getStore()
44
+ {
45
+ $urlRoot = Mage::app()->getRequest()->getPathInfo();
46
+ if(strstr($urlRoot, 'adminhtml_productlabels'))
47
+ return Mage::app()->getRequest()->getParam('store',0);
48
+ else
49
+ return Mage::app()->getStore()->getId();
50
+ }
51
+
52
+ public function addAttributeToSelect($arrAttribute = array())
53
+ {
54
+ if(!empty($arrAttribute))
55
+ {
56
+ $attributes = Mage::getModel('productlabels/attribute')->getCollection()
57
+ ->addFieldToFilter('name_attribute',array(
58
+ 'in' => $arrAttribute
59
+ ));
60
+ foreach($attributes as $a)
61
+ {
62
+ $atrNameTbl = $a->getNameAttribute().'tbl';
63
+ $atrNameTblDefault = $a->getNameAttribute().'tbl_default';
64
+ $this->getSelect()->joinLeft(array($atrNameTbl => $this->getTable('productlabels/type_'.$a->getType())),
65
+ "$atrNameTbl.label_id = main_table.id
66
+ AND $atrNameTbl.attribute_id = ".$a->getId()."
67
+ AND $atrNameTbl.store_id = ".Mage::app()->getRequest()->getParam('store',0), array()
68
+ )->joinLeft(array($atrNameTblDefault => $this->getTable('productlabels/type_'.$a->getType())),
69
+ "$atrNameTblDefault.label_id = main_table.id
70
+ AND $atrNameTblDefault.attribute_id = ".$a->getId()."
71
+ AND $atrNameTblDefault.store_id = ".$this->_getDefaultStoreId(), array(
72
+ $a->getNameAttribute() => "if($atrNameTbl.value > 0,$atrNameTbl.value,$atrNameTblDefault.value)"
73
+ ));
74
+ $this->_joinAttributes[$a->getNameAttribute()]['conditions_alias'] = "if($atrNameTbl.value > 0,$atrNameTbl.value,$atrNameTblDefault.value)";
75
+
76
+ }
77
+
78
+ }
79
+
80
+ return $this;
81
+ }
82
+
83
+ public function addFieldToFilter($field, $condition=null)
84
+ {
85
+ $field = $this->_getMappedField($field);
86
+ if($nameSelect = $this->_joinAttributes[$field]['conditions_alias'])
87
+ $this->_select->where($this->_getConditionSql($nameSelect, $condition), null, Varien_Db_Select::TYPE_CONDITION);
88
+ else
89
+ $this->_select->where($this->_getConditionSql($field, $condition), null, Varien_Db_Select::TYPE_CONDITION);
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Default sore ID getter
95
+ *
96
+ * @return integer
97
+ */
98
+ protected function _getDefaultStoreId()
99
+ {
100
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
101
+ }
102
+
103
+
104
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Int.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Int extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/type_int', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Int/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Int_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/type_int');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Text.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Text extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/type_text', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Text/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Text_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/type_text');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Varchar.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Varchar extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productlabels_id refers to the key field in your database table.
8
+ $this->_init('productlabels/type_varchar', 'id');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Mysql4/Type/Varchar/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Mysql4_Type_Varchar_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/type_varchar');
9
+ }
10
+ }
app/code/community/Niveus/Productlabels/Model/Productlabels.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Productlabels extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productlabels/productlabels');
9
+ }
10
+
11
+ public function getStoreId()
12
+ {
13
+ if ($this->hasData('store_id')) {
14
+ return $this->getData('store_id');
15
+ }
16
+ return Mage::app()->getRequest()->getParam('store');
17
+ }
18
+
19
+ public function getAttributes()
20
+ {
21
+ return Mage::getModel('productlabels/attribute')->getCollection()
22
+ ->addFieldToFilter('name_attribute',array(
23
+ 'neq' => 'name'
24
+ ));
25
+
26
+ }
27
+
28
+ public function addAttributeToSelect()
29
+ {
30
+ $collection = $this->getCollection()->addAttributesToSelect($this);
31
+ $this->setData($collection->getFirstItem()->getData());
32
+ return $this;
33
+ }
34
+
35
+ public function getAttributeDefault()
36
+ {
37
+ $attTable = array(
38
+ 'text' => Mage::getModel('productlabels/type_text'),
39
+ 'varchar' => Mage::getModel('productlabels/type_varchar'),
40
+ 'int' => Mage::getModel('productlabels/type_int')
41
+ );
42
+ $attributes = $this->getAttributes();
43
+ foreach($atr as $a)
44
+ {
45
+ if(!$this->getData($a->getNameAttribute()))
46
+ {
47
+ $value = $attTable[$a->getType()]->getCollection()
48
+ ->addFieldToFilter('label_id',$this->getId())
49
+ ->addFieldToFilter('attribute_id',$a->getId())
50
+ ->addFieldToFilter('store_id',0)
51
+ ->getFirstItem()
52
+ ->getValue();
53
+ $this->setData($a->getNameAttribute(),$value);
54
+ }
55
+ }
56
+
57
+ return $this;
58
+ }
59
+ }
app/code/community/Niveus/Productlabels/Model/Productrule.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogRule
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Niveus_Productlabels_Model_Productrule extends Mage_SalesRule_Model_Rule
29
+ {
30
+ const XML_NODE_RELATED_CACHE = 'global/catalogrule/related_cache_types';
31
+
32
+ /**
33
+ * Prefix of model events names
34
+ *
35
+ * @var string
36
+ */
37
+ protected $_eventPrefix = 'catalogrule_rule';
38
+
39
+ /**
40
+ * Parameter name in event
41
+ *
42
+ * In observe method you can use $observer->getEvent()->getRule() in this case
43
+ *
44
+ * @var string
45
+ */
46
+ protected $_eventObject = 'rule';
47
+
48
+ /**
49
+ * Matched product ids array
50
+ *
51
+ * @var array
52
+ */
53
+ protected $_productIds;
54
+
55
+ protected $_now;
56
+
57
+ /**
58
+ * Cached data of prices calculated by price rules
59
+ *
60
+ * @var array
61
+ */
62
+ protected static $_priceRulesData = array();
63
+
64
+ /**
65
+ * Init resource model and id field
66
+ */
67
+ protected function _construct()
68
+ {
69
+ parent::_construct();
70
+ $this->_init('catalogrule/rule');
71
+ $this->setIdFieldName('rule_id');
72
+ }
73
+
74
+ public function getConditionsInstance()
75
+ {
76
+ return Mage::getModel('catalogrule/rule_condition_combine');
77
+ }
78
+
79
+ /*public function getActionsInstance()
80
+ {
81
+ return Mage::getModel('catalogrule/rule_action_collection');
82
+ }*/
83
+
84
+ public function getNow()
85
+ {
86
+ if (!$this->_now) {
87
+ return now();
88
+ }
89
+ return $this->_now;
90
+ }
91
+
92
+ public function setNow($now)
93
+ {
94
+ $this->_now = $now;
95
+ }
96
+
97
+
98
+ public function toString($format='')
99
+ {
100
+ $str = Mage::helper('catalogrule')->__("Name: %s", $this->getName()) ."\n"
101
+ . Mage::helper('catalogrule')->__("Start at: %s", $this->getStartAt()) ."\n"
102
+ . Mage::helper('catalogrule')->__("Expire at: %s", $this->getExpireAt()) ."\n"
103
+ . Mage::helper('catalogrule')->__("Customer Registered: %s", $this->getCustomerRegistered()) ."\n"
104
+ . Mage::helper('catalogrule')->__("Customer is a New Buyer: %s", $this->getCustomerNewBuyer()) ."\n"
105
+ . Mage::helper('catalogrule')->__("Description: %s", $this->getDescription()) ."\n\n"
106
+ . $this->getConditions()->toStringRecursive() ."\n\n"
107
+ . $this->getActions()->toStringRecursive() ."\n\n";
108
+ return $str;
109
+ }
110
+
111
+ /**
112
+ * Returns rule as an array for admin interface
113
+ *
114
+ * Output example:
115
+ * array(
116
+ * 'name'=>'Example rule',
117
+ * 'conditions'=>{condition_combine::toArray}
118
+ * 'actions'=>{action_collection::toArray}
119
+ * )
120
+ *
121
+ * @return array
122
+ */
123
+ public function toArray(array $arrAttributes = array())
124
+ {
125
+ $out = parent::toArray($arrAttributes);
126
+ $out['customer_registered'] = $this->getCustomerRegistered();
127
+ $out['customer_new_buyer'] = $this->getCustomerNewBuyer();
128
+
129
+ return $out;
130
+ }
131
+
132
+ /**
133
+ * Invalidate related cache types
134
+ *
135
+ * @return Mage_CatalogRule_Model_Rule
136
+ */
137
+ protected function _invalidateCache()
138
+ {
139
+ $types = Mage::getConfig()->getNode(self::XML_NODE_RELATED_CACHE);
140
+ if ($types) {
141
+ $types = $types->asArray();
142
+ Mage::app()->getCacheInstance()->invalidateType(array_keys($types));
143
+ }
144
+ return $this;
145
+ }
146
+
147
+ /**
148
+ * Process rule related data after rule save
149
+ *
150
+ * @return Mage_CatalogRule_Model_Rule
151
+ */
152
+ protected function _afterSave()
153
+ {
154
+ $this->_getResource()->updateRuleProductData($this);
155
+ parent::_afterSave();
156
+ }
157
+
158
+ /**
159
+ * Get array of product ids which are matched by rule
160
+ *
161
+ * @return array
162
+ */
163
+ public function getMatchingProductIds()
164
+ {
165
+ if (is_null($this->_productIds)) {
166
+ $this->_productIds = array();
167
+ $this->setCollectedAttributes(array());
168
+ $websiteIds = explode(',', $this->getWebsiteIds());
169
+
170
+ if ($websiteIds) {
171
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
172
+
173
+ $productCollection->addWebsiteFilter($websiteIds);
174
+ $this->getActionsInstance()->collectValidatedAttributes($productCollection);
175
+
176
+ Mage::getSingleton('core/resource_iterator')->walk(
177
+ $productCollection->getSelect(),
178
+ array(array($this, 'callbackValidateProduct')),
179
+ array(
180
+ 'attributes' => $this->getCollectedAttributes(),
181
+ 'product' => Mage::getModel('catalog/product'),
182
+ )
183
+ );
184
+ }
185
+ }
186
+
187
+ return $this->_productIds;
188
+ }
189
+
190
+ /**
191
+ * Callback function for product matching
192
+ *
193
+ * @param $args
194
+ * @return void
195
+ */
196
+ public function callbackValidateProduct($args)
197
+ {
198
+ $product = clone $args['product'];
199
+ $product->setData($args['row']);
200
+
201
+ if ($this->getConditions()->validate($product)) {
202
+ $this->_productIds[] = $product->getId();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Apply rule to product
208
+ *
209
+ * @param int|Mage_Catalog_Model_Product $product
210
+ * @param array $websiteIds
211
+ * @return void
212
+ */
213
+ public function applyToProduct($product, $websiteIds=null)
214
+ {
215
+ if (is_numeric($product)) {
216
+ $product = Mage::getModel('catalog/product')->load($product);
217
+ }
218
+ if (is_null($websiteIds)) {
219
+ $websiteIds = explode(',', $this->getWebsiteIds());
220
+ }
221
+ $this->getResource()->applyToProduct($this, $product, $websiteIds);
222
+ }
223
+
224
+ /**
225
+ * Get array of assigned customer group ids
226
+ *
227
+ * @return array
228
+ */
229
+ public function getCustomerGroupIds()
230
+ {
231
+ $ids = $this->getData('customer_group_ids');
232
+ if (($ids && !$this->getCustomerGroupChecked()) || is_string($ids)) {
233
+ if (is_string($ids)) {
234
+ $ids = explode(',', $ids);
235
+ }
236
+
237
+ $groupIds = Mage::getModel('customer/group')->getCollection()->getAllIds();
238
+ $ids = array_intersect($ids, $groupIds);
239
+ $this->setData('customer_group_ids', $ids);
240
+ $this->setCustomerGroupChecked(true);
241
+ }
242
+ return $ids;
243
+ }
244
+
245
+ /**
246
+ * Apply all price rules, invalidate related cache and refresh price index
247
+ *
248
+ * @return Mage_CatalogRule_Model_Rule
249
+ */
250
+ public function applyAll()
251
+ {
252
+ $this->_getResource()->applyAllRulesForDateRange();
253
+ $this->_invalidateCache();
254
+ $indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
255
+ if ($indexProcess) {
256
+ $indexProcess->reindexAll();
257
+ }
258
+ }
259
+
260
+ /**
261
+ * Apply all price rules to product
262
+ *
263
+ * @param int|Mage_Catalog_Model_Product $product
264
+ * @return Mage_CatalogRule_Model_Rule
265
+ */
266
+ public function applyAllRulesToProduct($product)
267
+ {
268
+ $this->_getResource()->applyAllRulesForDateRange(NULL, NULL, $product);
269
+ $this->_invalidateCache();
270
+ $indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
271
+ if ($indexProcess) {
272
+ $indexProcess->reindexAll();
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Calculate price using catalog price rule of product
278
+ *
279
+ * @param Mage_Catalog_Model_Product $product
280
+ * @param float $price
281
+ * @return float|null
282
+ */
283
+ public function calcProductPriceRule(Mage_Catalog_Model_Product $product, $price)
284
+ {
285
+ $priceRules = null;
286
+ $productId = $product->getId();
287
+ $storeId = $product->getStoreId();
288
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
289
+ $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
290
+ $dateTs = Mage::app()->getLocale()->storeTimeStamp($storeId);
291
+ $cacheKey = date('Y-m-d', $dateTs)."|$websiteId|$customerGroupId|$productId|$price";
292
+
293
+ if (!array_key_exists($cacheKey, self::$_priceRulesData)) {
294
+ $rulesData = $this->_getResource()->getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId);
295
+ if ($rulesData) {
296
+ foreach ($rulesData as $ruleData) {
297
+ $priceRules = Mage::helper('catalogrule')->calcPriceRule(
298
+ $ruleData['simple_action'],
299
+ $ruleData['discount_amount'],
300
+ $priceRules ? $priceRules :$price);
301
+ if ($ruleData['stop_rules_processing']) {
302
+ break;
303
+ }
304
+ }
305
+ return self::$_priceRulesData[$cacheKey] = $priceRules;
306
+ } else {
307
+ self::$_priceRulesData[$cacheKey] = null;
308
+ }
309
+ } else {
310
+ return self::$_priceRulesData[$cacheKey];
311
+ }
312
+ return null;
313
+ }
314
+ }
app/code/community/Niveus/Productlabels/Model/Rule.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Rule extends Mage_SalesRule_Model_Rule
4
+ {
5
+ public function getActionsInstance()
6
+ {
7
+ return Mage::getModel('productlabels/rule_combine');
8
+ }
9
+
10
+ public function getConditionsInstance()
11
+ {
12
+ return Mage::getModel('productlabels/rule_combine');
13
+ }
14
+ }
app/code/community/Niveus/Productlabels/Model/Rule/Combine.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Rule_Combine extends Mage_Rule_Model_Condition_Combine
4
+ {
5
+ public function getNewChildSelectOptions()
6
+ {
7
+ $productCondition = Mage::getModel('salesrule/rule_condition_product');
8
+ $productAttributes = $productCondition->loadAttributeOptions()->getAttributeOption();
9
+ $pAttributes = array();
10
+ $pAttributes[] = array('value'=>'productlabels/rule_condition_product|is_new', 'label'=>'Is New');
11
+ $pAttributes[] = array('value'=>'productlabels/rule_condition_product|is_special', 'label'=>'Is Special Price');
12
+ $pAttributes[] = array('value'=>'productlabels/rule_condition_product|qty', 'label'=>'Qty');
13
+ $pAttributes[] = array('value'=>'productlabels/rule_condition_product|out_of_stock', 'label'=>'Is Out Of Stock');
14
+ $pAttributes[] = array('value'=>'productlabels/rule_condition_product|best_seller', 'label'=>'Amount Best Seller');
15
+ $iAttributes = array();
16
+ foreach ($productAttributes as $code=>$label) {
17
+ if (strpos($code, 'quote_item_')===0) {
18
+ $iAttributes[] = array('value'=>'salesrule/rule_condition_product|'.$code, 'label'=>$label);
19
+ } else {
20
+ $pAttributes[] = array('value'=>'salesrule/rule_condition_product|'.$code, 'label'=>$label);
21
+ }
22
+ }
23
+
24
+ $conditions = parent::getNewChildSelectOptions();
25
+ $conditions = array_merge_recursive($conditions, array(
26
+ array('value'=>'salesrule/rule_condition_product_combine', 'label'=>Mage::helper('catalog')->__('Conditions Combination')),
27
+ //array('label'=>Mage::helper('catalog')->__('Cart Item Attribute'), 'value'=>$iAttributes),
28
+ array('label'=>Mage::helper('catalog')->__('Product Attribute'), 'value'=>$pAttributes),
29
+ ));
30
+ return $conditions;
31
+ }
32
+
33
+ public function loadArray($arr, $key='conditions')
34
+ {
35
+ $this->setAggregator(isset($arr['aggregator']) ? $arr['aggregator']
36
+ : (isset($arr['attribute']) ? $arr['attribute'] : null))
37
+ ->setValue(isset($arr['value']) ? $arr['value']
38
+ : (isset($arr['operator']) ? $arr['operator'] : null));
39
+
40
+ if (!empty($arr[$key]) && is_array($arr[$key])) {
41
+ foreach ($arr[$key] as $condArr) {
42
+ try {
43
+ if(trim($condArr['type']) == 'salesrule/rule_condition_product')
44
+ $cond = Mage::getModel('productlabels/rule_condition_product');
45
+ else
46
+ $cond = @Mage::getModel($condArr['type']);
47
+ if (!empty($cond)) {
48
+ $this->addCondition($cond);
49
+ $cond->loadArray($condArr, $key);
50
+ }
51
+ } catch (Exception $e) {
52
+ Mage::logException($e);
53
+ }
54
+ }
55
+ }
56
+ return $this;
57
+ }
58
+ }
app/code/community/Niveus/Productlabels/Model/Rule/Condition/Product.php ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogRule
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Niveus_Productlabels_Model_Rule_Condition_Product extends Mage_CatalogRule_Model_Rule_Condition_Product
29
+ {
30
+
31
+ protected $bestSelletListId = null;
32
+ protected function _addSpecialAttributes(array &$attributes)
33
+ {
34
+ parent::_addSpecialAttributes($attributes);
35
+ $attributes['quote_item_qty'] = Mage::helper('salesrule')->__('Quantity in cart');
36
+ $attributes['quote_item_price'] = Mage::helper('salesrule')->__('Price in cart');
37
+ $attributes['quote_item_row_total'] = Mage::helper('salesrule')->__('Row total in cart');
38
+ }
39
+
40
+ /**
41
+ * Validate Product Rule Condition
42
+ *
43
+ * @param Varien_Object $object
44
+ * @return bool
45
+ */
46
+ public function validate(Varien_Object $object)
47
+ {
48
+ $op = $this->getOperator();
49
+ $product = false;
50
+ if ($object->getProduct() instanceof Mage_Catalog_Model_Product) {
51
+ $product = $object->getProduct();
52
+ } else {
53
+ $product = Mage::getModel('catalog/product')
54
+ ->load($object->getProductId());
55
+ }
56
+
57
+ $product
58
+ ->setQuoteItemQty($object->getQty())
59
+ ->setQuoteItemPrice($object->getPrice()) // possible bug: need to use $object->getBasePrice()
60
+ ->setQuoteItemRowTotal($object->getBaseRowTotal());
61
+
62
+ //Validate with attribute is is_new
63
+ if($this->getAttribute() == 'is_new')
64
+ {
65
+ $result = true;
66
+ if(!$product->getNewsFromDate() && !$product->getNewsToDate()){
67
+ $result = false;}
68
+ else
69
+ {
70
+ $today = new DateTime(date('Y-m-d 00:00:00'));
71
+ if($from = $product->getNewsFromDate())
72
+ {
73
+ $fromNewDate = new DateTime($from);
74
+ if($today < $fromNewDate)
75
+ $result = false;
76
+ }
77
+ if($to = $product->getNewsToDate())
78
+ {
79
+ $toNewDate = new DateTime($to);
80
+ if($today > $toNewDate)
81
+ $result = false;
82
+ }
83
+ }
84
+
85
+ $value = $this->getValueParsed();
86
+
87
+ if($value == 0)
88
+ $result = !$result;
89
+
90
+ return $result;
91
+ }
92
+
93
+ //validate with attribute is is_special
94
+ if($this->getAttribute() == 'is_special')
95
+ {
96
+ $result = true;
97
+ if(!$product->getSpecialPrice())
98
+ $result = false;
99
+ else
100
+ {
101
+ $today = new DateTime(date('Y-m-d 00:00:00'));
102
+
103
+ if(!$from = $product->getSpecialFromDate())
104
+ $fromNewDate = $today;
105
+ else
106
+ $fromNewDate = new DateTime($from);
107
+
108
+ if(!$to = $product->getSpecialToDate())
109
+ $toNewDate = $today;
110
+ else
111
+ $toNewDate = new DateTime($to);
112
+
113
+ if($today < $fromNewDate || $toNewDate < $today)
114
+ $result = false;
115
+ $value = $this->getValueParsed();
116
+ if($value == 0)
117
+ $result = !$result;
118
+
119
+ return $result;
120
+
121
+ }
122
+
123
+ }
124
+
125
+ //validate with attribute is qty
126
+ if($this->getAttribute() == 'qty')
127
+ {
128
+ $result = true;
129
+
130
+ $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
131
+ $value = $this->getValueParsed();
132
+ switch ($op) {
133
+ case '==': case '!=':
134
+ $result = ($qty == $value);
135
+ break;
136
+ case '>=': case '<':
137
+ $result = ($qty >= $value);
138
+ break;
139
+ case '<=': case '>':
140
+ $result = ($qty <= $value);
141
+ break;
142
+ }
143
+
144
+ if($op == '!=' || $op == '<' || $op == '>')
145
+ $result = !$result;
146
+ return $result;
147
+
148
+ }
149
+
150
+ //validate with attribute is qty
151
+ if($this->getAttribute() == 'out_of_stock')
152
+ {
153
+ $result = true;
154
+
155
+ if($product->isSaleable())
156
+ {
157
+ $result = false;
158
+ }
159
+ if($this->getValueParsed() == 0)
160
+ $result = !$result;
161
+ return $result;
162
+
163
+ }
164
+
165
+ //validate best seller
166
+ if($this->getAttribute() == 'best_seller')
167
+ {
168
+ $result = true;
169
+ $value = $this->getValueParsed();
170
+
171
+ // Get Best Seller product
172
+ $storeId = Mage::app()->getStore()->getId();
173
+
174
+
175
+ if(Mage::registry('bestSelletListId'))
176
+ $bestSellerId = Mage::registry('bestSelletListId');
177
+ else
178
+ {
179
+ $products = Mage::getResourceModel('reports/product_collection')
180
+ ->addOrderedQty()
181
+ //->addAttributeToSelect('*')
182
+ //->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description', 'description')) //edit to suit tastes
183
+ ->setStoreId($storeId)
184
+ ->addStoreFilter($storeId)
185
+ ->setOrder('ordered_qty', 'desc') //best sellers on top
186
+ ->setPageSize($value);
187
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
188
+ //Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
189
+
190
+ $bestSellerId = array();
191
+ foreach($products as $p){
192
+ $bestSellerId[] = $p->getId();
193
+ }
194
+ Mage::register('bestSelletListId',$bestSellerId);
195
+ }
196
+
197
+
198
+
199
+ if(!count($bestSellerId))
200
+ $result = false;
201
+ else{
202
+
203
+
204
+ if($product->getTypeId() == 'configurable'){
205
+ $childProducts = Mage::getModel('catalog/product_type_configurable')
206
+ ->getUsedProducts(null,$product);
207
+ }
208
+ elseif($product->getTypeId() == 'grouped'){
209
+ $childProducts = Mage::getModel('catalog/product_type_grouped')->getAssociatedProducts($product);
210
+ }
211
+ elseif($product->getTypeId() == 'bundle'){
212
+ $childProducts = $product->getTypeInstance(true)->getSelectionsCollection(
213
+ $product->getTypeInstance(true)->getOptionsIds($product), $product
214
+ );
215
+ }
216
+ else{
217
+ if(!in_array($product->getId(), $bestSellerId))
218
+ return false;
219
+ }
220
+ $flag = 0;
221
+ foreach($childProducts as $c){
222
+ if(in_array($c->getId(),$bestSellerId))
223
+ {
224
+ $flag = 1;
225
+ break;
226
+ }
227
+ }
228
+
229
+ if($flag == 0)
230
+ $result = false;
231
+
232
+
233
+ }
234
+
235
+ return $result;
236
+
237
+ }
238
+
239
+ if(!$product->getData($this->getAttribute()) && ('!='==$op || '>'==$op || '<'==$op || '!{}'==$op || '!()'==$op ))
240
+ return false;
241
+ return parent::validate($product);
242
+ }
243
+
244
+
245
+
246
+ public function getAttributeName()
247
+ {
248
+ $attributeName = array('is_new' => 'Is new','is_special' => 'Is special','qty' => 'Qty','out_of_stock' => 'Is Out Of Stock','best_seller' => 'Amount Best seller');
249
+ if(!array_key_exists($this->getAttribute(),$attributeName))
250
+ return parent::getAttributeName ();
251
+ return $attributeName[$this->getAttribute()];
252
+ }
253
+
254
+ public function getValueSelectOptions()
255
+ {
256
+ $attributeName = array('is_new' => 'Is new','is_special' => 'Is special','qty' => 'Qty','out_of_stock' => 'Is Out Of Stock');
257
+ if(!array_key_exists($this->getAttribute(),$attributeName))
258
+ return parent::getValueSelectOptions ();
259
+ return array(
260
+
261
+ array(
262
+ 'label' => 'No',
263
+ 'value' => 0
264
+ ),
265
+ array(
266
+ 'label' => 'Yes',
267
+ 'value' => 1
268
+ ),
269
+ );
270
+ }
271
+
272
+ public function getValueElementType()
273
+ {
274
+ $attributeName = array('is_new' => 'Is new','is_special' => 'Is special','out_of_stock' => 'Is Out Of Stock');
275
+ if($this->getAttribute() == 'qty')
276
+ return 'text';
277
+ elseif(!array_key_exists($this->getAttribute(),$attributeName))
278
+ return parent::getValueElementType ();
279
+ return 'select';
280
+ }
281
+
282
+ public function getOperatorSelectOptions()
283
+ {
284
+ $attributeName = array('is_new' => 'Is new','is_special' => 'Is special','out_of_stock' => 'Is Out Of Stock','best_seller' => 'Amount Best seller');
285
+ if($this->getAttribute() == 'qty')
286
+ return array(
287
+ array(
288
+ 'label' => 'is',
289
+ 'value' => '=='
290
+ ),
291
+ array(
292
+ 'label' => 'is not',
293
+ 'value' => '!='
294
+ ),
295
+ array(
296
+ 'label' => 'equals or greater than',
297
+ 'value' => '>='
298
+ ),
299
+ array(
300
+ 'label' => 'equals or less than',
301
+ 'value' => '<='
302
+ ),
303
+ array(
304
+ 'label' => 'greater than',
305
+ 'value' => '>'
306
+ ),
307
+ array(
308
+ 'label' => 'less than',
309
+ 'value' => '<'
310
+ )
311
+ );
312
+ if(!array_key_exists($this->getAttribute(),$attributeName))
313
+ return parent::getOperatorSelectOptions ();
314
+ return array(
315
+ array(
316
+ 'label' => 'is',
317
+ 'value' => '=='
318
+ )
319
+ /* array(
320
+ 'label' => 'is not',
321
+ 'value' => '!='
322
+ )*/
323
+ );
324
+ }
325
+ }
app/code/community/Niveus/Productlabels/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Niveus_Productlabels_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('productlabels')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('productlabels')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/community/Niveus/Productlabels/Model/Type/Int.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Type_Int extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('productlabels/type_int');
8
+ }
9
+
10
+ }
app/code/community/Niveus/Productlabels/Model/Type/Text.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Type_Text extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('productlabels/type_text');
8
+ }
9
+
10
+ }
app/code/community/Niveus/Productlabels/Model/Type/Varchar.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Model_Type_Varchar extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('productlabels/type_varchar');
8
+ }
9
+
10
+ }
app/code/community/Niveus/Productlabels/controllers/Adminhtml/CssController.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Adminhtml_CssController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function editAction() {
5
+ $this->loadLayout();
6
+ $this->_setActiveMenu('productlabels/items');
7
+ $stores = array(0,$this->getRequest()->getParam('store',0));
8
+ $model = Mage::getModel('productlabels/css')->getCollection()->setStoreId($stores)->getLastItem();
9
+ $model->setData('cur_store',$this->getRequest()->getParam('store',0));
10
+ Mage::register('productlabels_css_data', $model);
11
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Css Manager'), Mage::helper('adminhtml')->__('Css Manager'));
12
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Css News'), Mage::helper('adminhtml')->__('Css News'));
13
+
14
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
15
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('productlabels')->__("Css Editor"));
16
+ $editBlock = $this->getLayout()->createBlock('productlabels/adminhtml_css_edit');
17
+ $editBlock->setChild('form',
18
+ $this->getLayout()->createBlock('productlabels/adminhtml_css_edit_tab_css')
19
+ );
20
+
21
+ if($model->hasGlobal())
22
+ {
23
+ $editBlock->setChild('store_switcher',
24
+ $this->getLayout()->createBlock('adminhtml/store_switcher')
25
+ );
26
+ }
27
+ $this->_addContent($editBlock);
28
+ //->_addLeft($this->getLayout()->createBlock('productlabels/adminhtml_css_edit_tabs'));
29
+
30
+ $this->renderLayout();
31
+ }
32
+
33
+
34
+
35
+ public function saveAction() {
36
+ try {
37
+ if($data = $this->getRequest()->getPost())
38
+ {
39
+ $css = Mage::getModel('productlabels/css');
40
+ $data['store'] = $data['cur_store'];
41
+ $css->setData($data);
42
+ //print_r($css->getData());exit;
43
+ if(!count($data['use_default']))
44
+ $css->save();
45
+ elseif($data['id'])
46
+ {
47
+ $css->setId($data['id']);
48
+ $css->delete();
49
+ }
50
+
51
+
52
+ }
53
+
54
+
55
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productlabels')->__('Css was successfully saved'));
56
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
57
+
58
+ if ($this->getRequest()->getParam('back')) {
59
+ $this->_redirect('*/*/edit', array('store' => $this->getRequest()->getParam('cur_store',0)));
60
+ return;
61
+ }
62
+ $this->_redirect('*/adminhtml_productlabels',array('store' => $this->getRequest()->getParam('cur_store',0)));
63
+ return;
64
+ } catch (Exception $e) {
65
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
66
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
67
+ $this->_redirect('*/*/edit', array('store' => $this->getRequest()->getParam('cur_store',0)));
68
+ return;
69
+ }
70
+
71
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productlabels')->__('Unable to find css to save'));
72
+ $this->_redirect('*/*/',array('store' => $this->getRequest()->getParam('cur_store',0)));
73
+ }
74
+
75
+
76
+ }
app/code/community/Niveus/Productlabels/controllers/Adminhtml/ProductlabelsController.php ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_Adminhtml_ProductlabelsController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ protected function _initAction() {
5
+ $this->loadLayout()
6
+ ->_setActiveMenu('productlabels/items')
7
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Labels Manager'), Mage::helper('adminhtml')->__('Labels Manager'));
8
+
9
+ return $this;
10
+ }
11
+
12
+ public function indexAction() {
13
+ $this->_initAction();
14
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('productlabels')->__('Manage labels'));
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function loadCondition($conditions)
19
+ {
20
+ $rule = Mage::getModel('rule/rule');
21
+ $actionsArr = unserialize($rule->getActionsSerialized());
22
+ if (!empty($actionsArr) && is_array($actionsArr)) {
23
+ $rule->getActions()->loadArray($actionsArr);
24
+ }
25
+ }
26
+
27
+ public function editAction() {
28
+ $id = $this->getRequest()->getParam('id');
29
+ $label = Mage::getModel('productlabels/productlabels');
30
+
31
+ if($id){
32
+ $label->load($id)->addAttributeToSelect();
33
+
34
+ }
35
+ $label->setData('variables',Zend_Json::encode($this->getVariables()));
36
+ $label->setData('store',$this->getRequest()->getParam('store',0));
37
+ if(!$label->getEnable())
38
+ $label->setEnable(1);
39
+
40
+ if ($label->getId() || $id == 0) {
41
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
42
+ if (!empty($data)) {
43
+ $label->setData($data);
44
+ }
45
+
46
+ Mage::register('productlabels_data', $label);
47
+
48
+ $this->loadLayout();
49
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
50
+ if($id)
51
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('productlabels')->__("Edit Label %s",$label->getName()));
52
+ else
53
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('productlabels')->__("Add New Label"));
54
+ $this->_setActiveMenu('productlabels/items');
55
+
56
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
57
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
58
+
59
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
60
+ $editBlock = $this->getLayout()->createBlock('productlabels/adminhtml_productlabels_edit');
61
+ $editBlock->setChild('form',
62
+ $this->getLayout()->createBlock('productlabels/adminhtml_productlabels_edit_tab_form')
63
+ );
64
+ if($id)
65
+ {
66
+ $editBlock->setChild('store_switcher',
67
+ $this->getLayout()->createBlock('adminhtml/store_switcher')
68
+ );
69
+ }
70
+
71
+ $this->_addContent($editBlock);
72
+
73
+ //->_addLeft($this->getLayout()->createBlock('productlabels/adminhtml_productlabels_edit_tabs'));
74
+
75
+ $this->renderLayout();
76
+ } else {
77
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productlabels')->__('Item does not exist'));
78
+ $this->_redirect('*/*/');
79
+ }
80
+ }
81
+
82
+ public function newAction() {
83
+ $this->_forward('edit');
84
+
85
+ }
86
+
87
+
88
+
89
+ public function saveImages()
90
+ {
91
+ $data = array();
92
+ $oldPic = $this->getRequest()->getPost();
93
+ ///////////////Save Image for Label////////////////////
94
+ if(isset($_FILES['image']['name']) && $_FILES['image']['name'] != '') {
95
+ try {
96
+ /* Starting upload */
97
+ $uploader = new Varien_File_Uploader('image');
98
+
99
+ // Any extention would work
100
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
101
+ $uploader->setAllowRenameFiles(true);
102
+
103
+ // Set the file upload mode
104
+ // false -> get the file directly in the specified folder
105
+ // true -> get the file in the product like folders
106
+ // (file.jpg will go in something like /media/f/i/file.jpg)
107
+ $uploader->setFilesDispersion(false);
108
+
109
+ // We set media as the upload dir
110
+ $store = "store_".$this->getRequest()->getParam('store',0);
111
+ $_FILES['image']['name'] = $store.'_'.$_FILES['image']['name'];
112
+ $path = Mage::getBaseDir('media') . DS . 'niveus_productlabels' . DS . 'image' . DS ;
113
+
114
+ //delete old image
115
+ if($oldPic['curimage'] && $oldPic['curimage'] != 'nopic' && strstr($oldPic['curimage'],$store.'_'))
116
+ {
117
+ $width = Mage::getStoreConfig('productlabels/general/thumbnail_width_image');
118
+ $height = Mage::getStoreConfig('productlabels/general/thumbnail_height_image');
119
+ $res = $width."x".$height;
120
+ if(is_file($path.$oldPic['curimage']))
121
+ unlink($path.$oldPic['curimage']);
122
+ if(is_file($path."admin".DS."50x50".DS.$oldPic['curimage']))
123
+ unlink($path."admin".DS."50x50".DS.$oldPic['curimage']);
124
+ if(is_file($path."thumbnail".DS.$res.DS.$oldPic['curimage']))
125
+ unlink($path."thumbnail".DS.$res.DS.$oldPic['curimage']);
126
+ }
127
+
128
+ $uploader->save($path, $_FILES['image']['name'] );
129
+
130
+ } catch (Exception $e) {
131
+
132
+ }
133
+
134
+ //this way the name is saved in DB
135
+ $data['image'] = $_FILES['image']['name'];
136
+ }
137
+ ///////////////End save Image for Label////////////////////
138
+
139
+ ///////////////Save background for Label////////////////////
140
+ if(isset($_FILES['background']['name']) && $_FILES['background']['name'] != '') {
141
+ try {
142
+ /* Starting upload */
143
+ $uploader = new Varien_File_Uploader('background');
144
+
145
+ // Any extention would work
146
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
147
+ $uploader->setAllowRenameFiles(true);
148
+
149
+ // Set the file upload mode
150
+ // false -> get the file directly in the specified folder
151
+ // true -> get the file in the product like folders
152
+ // (file.jpg will go in something like /media/f/i/file.jpg)
153
+ $uploader->setFilesDispersion(false);
154
+
155
+ // We set media as the upload dir
156
+ $store = "store_".$this->getRequest()->getParam('store',0);
157
+ $_FILES['background']['name'] = $store.'_'.$_FILES['background']['name'];
158
+ $path = Mage::getBaseDir('media') . DS . 'niveus_productlabels' . DS . 'background' . DS ;
159
+ //delete old background
160
+ if($oldPic['curbackground'] && $oldPic['curbackground'] != 'nopic' && strstr($oldPic['curbackground'],$store.'_'))
161
+ {
162
+ $width = Mage::getStoreConfig('productlabels/general/thumbnail_width_background');
163
+ $height = Mage::getStoreConfig('productlabels/general/thumbnail_height_background');
164
+ $res = $width."x".$height;
165
+ if(is_file($path.$oldPic['curbackground']))
166
+ unlink($path.$oldPic['curbackground']);
167
+ if(is_file($path."admin".DS."50x50".DS.$oldPic['curbackground']))
168
+ unlink($path."admin".DS."50x50".DS.$oldPic['curbackground']);
169
+ if(is_file($path."thumbnail".DS.$res.DS.$oldPic['curbackground']))
170
+ unlink($path."thumbnail".DS.$res.DS.$oldPic['curbackground']);
171
+ }
172
+ $uploader->save($path, $_FILES['background']['name'] );
173
+
174
+ } catch (Exception $e) {
175
+
176
+ }
177
+
178
+ //this way the name is saved in DB
179
+ $data['background'] = $_FILES['background']['name'];
180
+ }
181
+ ///////////////End save background for Label////////////////////
182
+
183
+ return $data;
184
+ }
185
+
186
+ public function initLabelSave()
187
+ {
188
+ $label = Mage::getModel('productlabels/productlabels');
189
+ if($data = $this->getRequest()->getPost())
190
+ {
191
+ if(!$data['enable'])
192
+ $data['enable'] = 2;
193
+
194
+ $data = array_merge($data,$this->saveImages());
195
+
196
+ //$tmp['actions'] = $data['rule']['actions'];
197
+ //print_r($data);exit;
198
+ //unset($data['rule']);
199
+ $data['actions'] = $this->initCondition($data['rule']);
200
+ if(!$data['id'])
201
+ unset($data['id']);
202
+ /*unset($data['rule']);
203
+ unset($data['id']);
204
+ unset($data['variables']);*/
205
+ //echo $data['actions'];exit;
206
+ //unset($data['name']);
207
+ $label->setData($data);
208
+ }
209
+
210
+ $atrTbl = array('text' => array(),'varchar' => array(),'int' => array());
211
+ $attributes = $label->getAttributes();
212
+
213
+ if (!$useDefaults = $this->getRequest()->getPost('use_default'))
214
+ $useDefaults = array();
215
+ foreach ($attributes as $a) {
216
+ if(in_array($a->getNameAttribute(),$useDefaults))
217
+ {
218
+ $label->setData($a->getNameAttribute(), false);
219
+
220
+ $atrTbl[$a->getType()][] = $a->getId();
221
+ }elseif($a->getNameAttribute() == 'image' || $a->getNameAttribute() == 'background')
222
+ {
223
+ if($data['no'.$a->getNameAttribute()] == 1 && !$data[$a->getNameAttribute()]){
224
+ $label->setData($a->getNameAttribute(),'nopic');
225
+
226
+
227
+ if($data['cur'.$a->getNameAttribute()] && strstr($data['cur'.$a->getNameAttribute()],'store_'.$data['store'].'_'))
228
+ {
229
+ $path = Mage::getBaseDir('media').DS."niveus_productlabels".DS.$a->getNameAttribute().DS;
230
+ $width = Mage::getStoreConfig('productlabels/general/thumbnail_width_'.$a->getNameAttribute());
231
+ $height = Mage::getStoreConfig('productlabels/general/thumbnail_height_'.$a->getNameAttribute());
232
+ $res = $width."x".$height;
233
+ if(is_file($path.$data['cur'.$a->getNameAttribute()]))
234
+ unlink($path.$data['cur'.$a->getNameAttribute()]);
235
+ if(is_file($path."admin".DS."50x50".DS.$data['cur'.$a->getNameAttribute()]))
236
+ unlink($path."admin".DS."50x50".DS.$data['cur'.$a->getNameAttribute()]);
237
+ if(is_file($path."thumbnail".DS.$res.DS.$data['cur'.$a->getNameAttribute()]))
238
+ unlink($path."thumbnail".DS.$res.DS.$data['cur'.$a->getNameAttribute()]);
239
+ }
240
+
241
+ }
242
+ }
243
+
244
+ }
245
+
246
+ //Delete attribute use default at store != default
247
+ if(!empty($useDefaults))
248
+ {
249
+ foreach($atrTbl as $key => $value)
250
+ {
251
+ if(!empty($key))
252
+ {
253
+ $collection = Mage::getModel('productlabels/type_'.$key)->getCollection()
254
+ ->addFieldToFilter('label_id',$data['id'])
255
+ ->addFieldToFilter('store_id',$this->getRequest()->getParam('store'))
256
+ ->addFieldToFilter('attribute_id',array('in' => $value));
257
+
258
+ if($collection->count())
259
+ {
260
+
261
+ foreach($collection as $c)
262
+ {
263
+
264
+ $c->delete();
265
+ }
266
+
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+
273
+
274
+ //print_r($label->getData());exit;
275
+
276
+ //$label->setId($this->getRequest()->getParam('id'));
277
+
278
+ return $label;
279
+
280
+ }
281
+
282
+ public function saveAttribute($label)
283
+ {
284
+ $attributes = $label->getAttributes();
285
+
286
+ $labelId = $label->getId();
287
+ $attTable = array(
288
+ 'text' => Mage::getModel('productlabels/type_text'),
289
+ 'varchar' => Mage::getModel('productlabels/type_varchar'),
290
+ 'int' => Mage::getModel('productlabels/type_int')
291
+ );
292
+ $storeId = $this->getRequest()->getParam('store',0);
293
+
294
+ foreach($attributes as $a)
295
+ {
296
+ $value = $label->getData($a->getNameAttribute());
297
+ $data = array(
298
+ 'label_id'=>$labelId,
299
+ 'attribute_id'=>$a->getId(),
300
+ 'store_id'=>$storeId,
301
+ 'value'=>$value);
302
+
303
+ $attTable[$a->getType()]->setData($data);
304
+
305
+ $attId = $attTable[$a->getType()]->getCollection()
306
+ ->addFieldToFilter('label_id',$labelId)
307
+ ->addFieldToFilter('attribute_id',$a->getId())
308
+ ->addFieldToFilter('store_id',$storeId)
309
+ ->getFirstItem()->getId();
310
+ $attTable[$a->getType()]->setId($attId);
311
+ $attTable[$a->getType()]->save();
312
+ }
313
+ }
314
+
315
+ public function initCondition($actions)
316
+ {
317
+ $rule = Mage::getModel('salesrule/rule');
318
+ $rule->loadPost($actions);
319
+
320
+
321
+ if ($rule->getActions()) {
322
+ $rule->setActionsSerialized(serialize($rule->getActions()->asArray()));
323
+ $rule->unsActions();
324
+ }
325
+ return $rule->getActionsSerialized();
326
+ }
327
+
328
+ public function saveAction() {
329
+ if ($label = $this->initLabelSave()) {
330
+
331
+ try {
332
+
333
+ $label->save();
334
+ $this->saveAttribute($label);
335
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productlabels')->__('Label was successfully saved'));
336
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
337
+
338
+ if ($this->getRequest()->getParam('back')) {
339
+ $this->_redirect('*/*/edit', array('id' => $label->getId(),
340
+ 'store' => $this->getRequest()->getParam('store',0)
341
+ )
342
+ );
343
+ return;
344
+ }
345
+ $this->_redirect('*/*/',array('store' => $this->getRequest()->getParam('store',0)));
346
+ return;
347
+ } catch (Exception $e) {
348
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
349
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
350
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'),
351
+ 'store' => $this->getRequest()->getParam('store',0))
352
+ );
353
+ return;
354
+ }
355
+ }
356
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productlabels')->__('Unable to find label to save'));
357
+ $this->_redirect('*/*/',array('store' => $this->getRequest()->getParam('store',0)));
358
+ }
359
+
360
+ public function deleteAction() {
361
+ if( $this->getRequest()->getParam('id') > 0 ) {
362
+ try {
363
+ $model = Mage::getModel('productlabels/productlabels');
364
+
365
+ $model->setId($this->getRequest()->getParam('id'))
366
+ ->delete();
367
+
368
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Label was successfully deleted'));
369
+ $this->_redirect('*/*/');
370
+ } catch (Exception $e) {
371
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
372
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'),'store' => $this->getRequest()->getParam('store',0)));
373
+ }
374
+ }
375
+ $this->_redirect('*/*/',array('store' => $this->getRequest()->getParam('store',0)));
376
+ }
377
+
378
+ public function massDeleteAction() {
379
+ $productlabelsIds = $this->getRequest()->getParam('productlabels');
380
+ if(!is_array($productlabelsIds)) {
381
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select label(s)'));
382
+ } else {
383
+ try {
384
+ foreach ($productlabelsIds as $productlabelsId) {
385
+ $productlabels = Mage::getModel('productlabels/productlabels')->load($productlabelsId);
386
+ $productlabels->delete();
387
+ }
388
+ Mage::getSingleton('adminhtml/session')->addSuccess(
389
+ Mage::helper('adminhtml')->__(
390
+ 'Total of %d record(s) were successfully deleted', count($productlabelsIds)
391
+ )
392
+ );
393
+ } catch (Exception $e) {
394
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
395
+ }
396
+ }
397
+ $this->_redirect('*/*/index',array('store' => $this->getRequest()->getParam('store',0)));
398
+ }
399
+
400
+ public function massStatusAction()
401
+ {
402
+ $productlabelsIds = $this->getRequest()->getParam('productlabels');
403
+ if(!is_array($productlabelsIds)) {
404
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select label(s)'));
405
+ } else {
406
+ try {
407
+
408
+ foreach ($productlabelsIds as $productlabelsId) {
409
+ $productlabels = Mage::getSingleton('productlabels/productlabels')
410
+ ->load($productlabelsId);
411
+ $productlabels->setEnable($this->getRequest()->getParam('status'));
412
+ $this->saveAttribute($productlabels);
413
+
414
+ }
415
+ $this->_getSession()->addSuccess(
416
+ $this->__('Total of %d record(s) were successfully updated', count($productlabelsIds))
417
+ );
418
+ } catch (Exception $e) {
419
+ $this->_getSession()->addError($e->getMessage());
420
+ }
421
+ }
422
+ $this->_redirect('*/*/index',array('store' => $this->getRequest()->getParam('store',0)));
423
+ }
424
+
425
+ public function exportCsvAction()
426
+ {
427
+ $fileName = 'productlabels.csv';
428
+ $content = $this->getLayout()->createBlock('productlabels/adminhtml_productlabels_grid')
429
+ ->getCsv();
430
+
431
+ $this->_sendUploadResponse($fileName, $content);
432
+ }
433
+
434
+ public function exportXmlAction()
435
+ {
436
+ $fileName = 'productlabels.xml';
437
+ $content = $this->getLayout()->createBlock('productlabels/adminhtml_productlabels_grid')
438
+ ->getXml();
439
+
440
+ $this->_sendUploadResponse($fileName, $content);
441
+ }
442
+
443
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
444
+ {
445
+ $response = $this->getResponse();
446
+ $response->setHeader('HTTP/1.1 200 OK','');
447
+ $response->setHeader('Pragma', 'public', true);
448
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
449
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
450
+ $response->setHeader('Last-Modified', date('r'));
451
+ $response->setHeader('Accept-Ranges', 'bytes');
452
+ $response->setHeader('Content-Length', strlen($content));
453
+ $response->setHeader('Content-type', $contentType);
454
+ $response->setBody($content);
455
+ $response->sendResponse();
456
+ die;
457
+ }
458
+
459
+ public function getVariables()
460
+ {
461
+ $data = array(
462
+ 'label' => 'Variables',
463
+ 'value' => array(
464
+ array(
465
+ 'label' => 'Save Percent',
466
+ 'value' => '{{var save_percent}}'
467
+ ),
468
+ array(
469
+ 'label' => 'Save Price',
470
+ 'value' => '{{var save_price}}'
471
+ ),
472
+ array(
473
+ 'label' => 'Product Price',
474
+ 'value' => '{{var product.price}}'
475
+ ),
476
+ array(
477
+ 'label' => 'Product Special Price',
478
+ 'value' => '{{var product.special_price}}'
479
+ ),
480
+ array(
481
+ 'label' => 'The Quantity Of Product',
482
+ 'value' => '{{var product.qty}}'
483
+ )
484
+ )
485
+ );
486
+ $variables = array($data);
487
+
488
+ return $variables;
489
+ }
490
+ }
app/code/community/Niveus/Productlabels/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Niveus_Productlabels_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/productlabels?id=15
11
+ * or
12
+ * http://site.com/productlabels/id/15
13
+ */
14
+ /*
15
+ $productlabels_id = $this->getRequest()->getParam('id');
16
+
17
+ if($productlabels_id != null && $productlabels_id != '') {
18
+ $productlabels = Mage::getModel('productlabels/productlabels')->load($productlabels_id)->getData();
19
+ } else {
20
+ $productlabels = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($productlabels == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $productlabelsTable = $resource->getTableName('productlabels');
32
+
33
+ $select = $read->select()
34
+ ->from($productlabelsTable,array('productlabels_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $productlabels = $read->fetchRow($select);
39
+ }
40
+ Mage::register('productlabels', $productlabels);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/community/Niveus/Productlabels/etc/config.xml ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Niveus
5
+ * @package Niveus_Productlabels
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Niveus_Productlabels>
13
+ <version>0.1.0</version>
14
+ </Niveus_Productlabels>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <productlabels>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Niveus_Productlabels</module>
22
+ <frontName>productlabels</frontName>
23
+ </args>
24
+ </productlabels>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <productlabels>
29
+ <file>niveus_productlabels.xml</file>
30
+ </productlabels>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <productlabels>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Niveus_Productlabels</module>
40
+ <frontName>productlabels_admin</frontName>
41
+ </args>
42
+ </productlabels>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <menu>
47
+ <productlabels module="productlabels">
48
+ <title>Product Labels</title>
49
+ <sort_order>71</sort_order>
50
+ <children>
51
+ <manage_label module="productlabels">
52
+ <title>Manage Product Labels</title>
53
+ <sort_order>0</sort_order>
54
+ <action>productlabels_admin/adminhtml_productlabels</action>
55
+ </manage_label>
56
+ <css_editor module="productlabels">
57
+ <title>Css Editor</title>
58
+ <sort_order>1</sort_order>
59
+ <action>productlabels_admin/adminhtml_css/edit</action>
60
+ </css_editor>
61
+ </children>
62
+ </productlabels>
63
+ </menu>
64
+ <acl>
65
+ <resources>
66
+ <all>
67
+ <title>Allow Everything</title>
68
+ </all>
69
+ <admin>
70
+ <children>
71
+ <productlabels translate="title" module="productlabels">
72
+ <title>Product Labels</title>
73
+ <sort_order>71</sort_order>
74
+ <children>
75
+ <manage_label translate="title">
76
+ <title>Manage Product Labels</title>
77
+ <sort_order>10</sort_order>
78
+ </manage_label>
79
+ <css_editor translate="title">
80
+ <title>Css Editor</title>
81
+ <sort_order>1</sort_order>
82
+ </css_editor>
83
+ </children>
84
+ </productlabels>
85
+ </children>
86
+ </admin>
87
+ </resources>
88
+ </acl>
89
+ <layout>
90
+ <updates>
91
+ <productlabels>
92
+ <file>niveus_productlabels.xml</file>
93
+ </productlabels>
94
+ </updates>
95
+ </layout>
96
+ </adminhtml>
97
+ <global>
98
+ <models>
99
+ <productlabels>
100
+ <class>Niveus_Productlabels_Model</class>
101
+ <resourceModel>productlabels_mysql4</resourceModel>
102
+ </productlabels>
103
+ <productlabels_mysql4>
104
+ <class>Niveus_Productlabels_Model_Mysql4</class>
105
+ <entities>
106
+ <productlabels>
107
+ <table>label_entity</table>
108
+ </productlabels>
109
+ <css>
110
+ <table>label_css</table>
111
+ </css>
112
+ <attribute>
113
+ <table>label_eav_attribute</table>
114
+ </attribute>
115
+ <type_text>
116
+ <table>label_attribute_value_text</table>
117
+ </type_text>
118
+ <type_varchar>
119
+ <table>label_attribute_value_varchar</table>
120
+ </type_varchar>
121
+ <type_int>
122
+ <table>label_attribute_value_int</table>
123
+ </type_int>
124
+ </entities>
125
+ </productlabels_mysql4>
126
+ </models>
127
+ <resources>
128
+ <productlabels_setup>
129
+ <setup>
130
+ <module>Niveus_Productlabels</module>
131
+ </setup>
132
+ <connection>
133
+ <use>core_setup</use>
134
+ </connection>
135
+ </productlabels_setup>
136
+ <productlabels_write>
137
+ <connection>
138
+ <use>core_write</use>
139
+ </connection>
140
+ </productlabels_write>
141
+ <productlabels_read>
142
+ <connection>
143
+ <use>core_read</use>
144
+ </connection>
145
+ </productlabels_read>
146
+ </resources>
147
+ <blocks>
148
+ <productlabels>
149
+ <class>Niveus_Productlabels_Block</class>
150
+ </productlabels>
151
+ </blocks>
152
+ <helpers>
153
+ <productlabels>
154
+ <class>Niveus_Productlabels_Helper</class>
155
+ </productlabels>
156
+ </helpers>
157
+ <default>
158
+ <productlabels>
159
+ <wysiwyg>
160
+ <enabled>enabled</enabled>
161
+ </wysiwyg>
162
+ </productlabels>
163
+ </default>
164
+ </global>
165
+ <default>
166
+ <productlabels>
167
+ <general>
168
+ <thumbnail_width_image>50</thumbnail_width_image>
169
+ <thumbnail_height_image>50</thumbnail_height_image>
170
+ <thumbnail_width_background>74</thumbnail_width_background>
171
+ <thumbnail_height_background>76</thumbnail_height_background>
172
+ </general>
173
+ <which_show_label>
174
+ <product_list>36</product_list>
175
+ <product_detail>36</product_detail>
176
+ <crossel>36</crossel>
177
+ <upsell>36</upsell>
178
+ <related>36</related>
179
+ <widget>36</widget>
180
+ </which_show_label>
181
+ </productlabels>
182
+ </default>
183
+ </config>
app/code/community/Niveus/Productlabels/sql/productlabels_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ SET FOREIGN_KEY_CHECKS=0;
9
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/css')};
10
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/type_varchar')};
11
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/type_text')};
12
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/type_int')};
13
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/attribute')};
14
+ DROP TABLE IF EXISTS {$this->getTable('productlabels/productlabels')};
15
+
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/productlabels')} (
17
+ `id` int(11) NOT NULL AUTO_INCREMENT,
18
+ `name` varchar(255) NOT NULL,
19
+ `actions` text CHARACTER SET utf8,
20
+ PRIMARY KEY (`id`)
21
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ;
22
+
23
+
24
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/attribute')} (
25
+ `id` int(11) NOT NULL AUTO_INCREMENT,
26
+ `name_attribute` varchar(255) NOT NULL,
27
+ `type` varchar(255) NOT NULL,
28
+ `scope_global` smallint(1) NOT NULL DEFAULT '0',
29
+ `title` varchar(255) NOT NULL,
30
+ `require` tinyint(1) NOT NULL DEFAULT '0',
31
+ `class` varchar(255) NOT NULL,
32
+ `type_backend` varchar(255) NOT NULL,
33
+ PRIMARY KEY (`id`)
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
35
+
36
+
37
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/css')} (
38
+ `id` int(11) NOT NULL AUTO_INCREMENT,
39
+ `content` text NOT NULL,
40
+ `store` smallint(5) NOT NULL,
41
+ `scope_global` smallint(1) NOT NULL DEFAULT '0',
42
+ PRIMARY KEY (`id`),
43
+ KEY `store_id` (`store`)
44
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
45
+
46
+
47
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/type_varchar')} (
48
+ `id` int(11) NOT NULL AUTO_INCREMENT,
49
+ `label_id` int(11) NOT NULL,
50
+ `attribute_id` int(11) NOT NULL,
51
+ `store_id` smallint(5) unsigned NOT NULL,
52
+ `value` varchar(555) NOT NULL,
53
+ PRIMARY KEY (`id`),
54
+ KEY `store_id` (`store_id`),
55
+ KEY `label_id` (`label_id`),
56
+ KEY `attribute_id` (`attribute_id`)
57
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=32 ;
58
+
59
+
60
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/type_text')} (
61
+ `id` int(11) NOT NULL AUTO_INCREMENT,
62
+ `label_id` int(11) NOT NULL,
63
+ `attribute_id` int(11) NOT NULL,
64
+ `store_id` smallint(5) unsigned NOT NULL,
65
+ `value` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
66
+ PRIMARY KEY (`id`),
67
+ KEY `store_id` (`store_id`),
68
+ KEY `label_id` (`label_id`,`attribute_id`)
69
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
70
+
71
+
72
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productlabels/type_int')} (
73
+ `id` int(11) NOT NULL AUTO_INCREMENT,
74
+ `label_id` int(11) NOT NULL,
75
+ `attribute_id` int(11) NOT NULL,
76
+ `store_id` smallint(5) unsigned NOT NULL,
77
+ `value` tinyint(1) NOT NULL,
78
+ PRIMARY KEY (`id`),
79
+ KEY `store_id` (`store_id`),
80
+ KEY `label_id` (`label_id`),
81
+ KEY `attribute_id` (`attribute_id`)
82
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;
83
+
84
+
85
+
86
+
87
+ ALTER TABLE {$this->getTable('productlabels/type_varchar')}
88
+ ADD CONSTRAINT {$this->getTable('productlabels/type_varchar')} FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
89
+ ADD CONSTRAINT `{$this->getTable('productlabels/type_varchar')}_ibfk_1` FOREIGN KEY (`label_id`) REFERENCES {$this->getTable('productlabels/productlabels')} (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
90
+
91
+ ALTER TABLE {$this->getTable('productlabels/type_text')}
92
+ ADD CONSTRAINT {$this->getTable('productlabels/type_text')} FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
93
+ ADD CONSTRAINT `{$this->getTable('productlabels/type_text')}_ibfk_1` FOREIGN KEY (`label_id`) REFERENCES {$this->getTable('productlabels/productlabels')} (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
94
+
95
+ ALTER TABLE {$this->getTable('productlabels/type_int')}
96
+ ADD CONSTRAINT {$this->getTable('productlabels/type_int')} FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
97
+ ADD CONSTRAINT `{$this->getTable('productlabels/type_int')}_ibfk_1` FOREIGN KEY (`label_id`) REFERENCES {$this->getTable('productlabels/productlabels')} (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
98
+
99
+ INSERT INTO {$this->getTable('productlabels/productlabels')} (`id`, `name`, `actions`) VALUES
100
+ (1, 'Sale off', 'a:7:{s:4:\"type\";s:40:\"salesrule/rule_condition_product_combine\";s:9:\"attribute\";N;s:8:\"operator\";N;s:5:\"value\";s:1:\"1\";s:18:\"is_value_processed\";N;s:10:\"aggregator\";s:3:\"all\";s:10:\"conditions\";a:1:{i:0;a:5:{s:4:\"type\";s:32:\"salesrule/rule_condition_product\";s:9:\"attribute\";s:13:\"special_price\";s:8:\"operator\";s:1:\">\";s:5:\"value\";d:0;s:18:\"is_value_processed\";b:0;}}}'),
101
+ (2, 'Hot deal', 'a:7:{s:4:\"type\";s:40:\"salesrule/rule_condition_product_combine\";s:9:\"attribute\";N;s:8:\"operator\";N;s:5:\"value\";s:1:\"1\";s:18:\"is_value_processed\";N;s:10:\"aggregator\";s:3:\"all\";s:10:\"conditions\";a:1:{i:0;a:5:{s:4:\"type\";s:32:\"salesrule/rule_condition_product\";s:9:\"attribute\";s:5:\"price\";s:8:\"operator\";s:2:\">=\";s:5:\"value\";d:50;s:18:\"is_value_processed\";b:0;}}}');
102
+
103
+ INSERT INTO {$this->getTable('productlabels/attribute')} (`id`, `name_attribute`, `type`, `scope_global`, `title`, `require`, `class`, `type_backend`) VALUES
104
+ (1, 'name', '', 1, 'Label Name', 1, 'required-entry', 'text'),
105
+ (2, 'image', 'varchar', 0, 'Image', 0, '', 'file'),
106
+ (3, 'background', 'varchar', 0, 'Background', 0, '', 'file'),
107
+ (4, 'texthtml', 'text', 0, 'Text', 0, '', 'editor'),
108
+ (5, 'css_class', 'varchar', 0, 'Css Class', 0, '', 'text'),
109
+ (6, 'enable', 'int', 2, 'Enable', 0, '', 'checkbox');
110
+
111
+ INSERT INTO {$this->getTable('productlabels/type_varchar')} (`id`, `label_id`, `attribute_id`, `store_id`, `value`) VALUES
112
+ (NULL, 1, 2, 0, 'store_0_saleof.png'),
113
+ (NULL, 2, 2, 0, 'store_0_hotdeal.png');
114
+
115
+ INSERT INTO {$this->getTable('productlabels/type_int')} (`id`, `label_id`, `attribute_id`, `store_id`, `value`) VALUES
116
+ (NULL, 1, 6, 0, 1),
117
+ (NULL, 2, 6, 0, 1);
118
+
119
+ ");
120
+
121
+
122
+
123
+ $installer->endSetup();
app/code/community/Niveus/Requestproduct/Block/Adminhtml/Requestnewproduct.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Block_Adminhtml_Requestnewproduct extends Mage_Adminhtml_Block_Widget_Grid_Container
6
+ {
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'niveus_requestproduct';
10
+ $this->_controller = 'adminhtml_requestnewproduct';
11
+ $this->_headerText = $this->__('Request New Product');
12
+
13
+ parent::__construct();
14
+ $this->_removeButton('add');
15
+ }
16
+ }
app/code/community/Niveus/Requestproduct/Block/Adminhtml/Requestnewproduct/Grid.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Block_Adminhtml_Requestnewproduct_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+
11
+ // Set some defaults for our grid
12
+ $this->setDefaultSort('id');
13
+ $this->setId('niveus_requestproduct_requestnewproduct_grid');
14
+ $this->setDefaultDir('asc');
15
+ $this->setSaveParametersInSession(true);
16
+ }
17
+
18
+ protected function _getCollectionClass()
19
+ {
20
+ // This is the model we are using for the grid
21
+ return 'niveus_requestproduct/requestnewproduct_collection';
22
+ }
23
+
24
+ protected function _prepareCollection()
25
+ {
26
+ // Get and set our collection for the grid
27
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
28
+ $this->setCollection($collection);
29
+
30
+ return parent::_prepareCollection();
31
+ }
32
+
33
+ protected function _prepareColumns()
34
+ {
35
+ // Add the columns that should appear in the grid
36
+ $this->addColumn('id',
37
+ array(
38
+ 'header'=> $this->__('ID'),
39
+ 'align' =>'right',
40
+ 'width' => '50px',
41
+ 'index' => 'id'
42
+ )
43
+ );
44
+
45
+ $this->addColumn('name',
46
+ array(
47
+ 'header'=> $this->__('Name'),
48
+ 'index' => 'name'
49
+ )
50
+ );
51
+ $this->addColumn('email',
52
+ array(
53
+ 'header'=> $this->__('Email'),
54
+ 'index' => 'email'
55
+ )
56
+ );
57
+ $this->addColumn('productname',
58
+ array(
59
+ 'header'=> $this->__('Product Name'),
60
+ 'index' => 'productname'
61
+ )
62
+ );
63
+ $this->addColumn('brand',
64
+ array(
65
+ 'header'=> $this->__('Brand'),
66
+ 'index' => 'brand'
67
+ )
68
+ );
69
+ $this->addColumn('seenproduct',
70
+ array(
71
+ 'header'=> $this->__('where have you seen this product'),
72
+ 'index' => 'seenproduct'
73
+ )
74
+ );
75
+ $this->addColumn('aboutproduct',
76
+ array(
77
+ 'header'=> $this->__('Tell us about this product'),
78
+ 'index' => 'aboutproduct'
79
+ )
80
+ );
81
+ return parent::_prepareColumns();
82
+ }
83
+
84
+
85
+ }
app/code/community/Niveus/Requestproduct/Block/Requestnewproduct.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Block_Requestnewproduct extends Mage_Core_Block_Template
6
+ {
7
+
8
+ }
app/code/community/Niveus/Requestproduct/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ }
app/code/community/Niveus/Requestproduct/Model/Mysql4/Requestnewproduct.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Model_Mysql4_Requestnewproduct extends Mage_Core_Model_Mysql4_Abstract
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->_init('niveus_requestproduct/requestnewproduct', 'id');
10
+ }
11
+ }
app/code/community/Niveus/Requestproduct/Model/Mysql4/Requestnewproduct/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Model_Mysql4_Requestnewproduct_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->_init('niveus_requestproduct/requestnewproduct');
10
+ }
11
+ }
app/code/community/Niveus/Requestproduct/Model/Requestnewproduct.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Model_Requestnewproduct extends Mage_Core_Model_Abstract
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->_init('niveus_requestproduct/requestnewproduct');
10
+ }
11
+ }
app/code/community/Niveus/Requestproduct/controllers/Adminhtml/RequestnewproductController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_Adminhtml_RequestnewproductController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ public function indexAction()
8
+ {
9
+ // Let's call our initAction method which will set some basic params for each action
10
+ $this->_initAction()
11
+ ->renderLayout();
12
+ }
13
+
14
+
15
+
16
+ /**
17
+ * Initialize action
18
+ *
19
+ * Here, we set the breadcrumbs and the active menu
20
+ *
21
+ * @return Mage_Adminhtml_Controller_Action
22
+ */
23
+ protected function _initAction()
24
+ {
25
+ $this->loadLayout()
26
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
27
+ ->_setActiveMenu('sales/niveus_requestproduct_requestnewproduct')
28
+ ->_title($this->__('Sales'))->_title($this->__('Request New Product'))
29
+ ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
30
+ ->_addBreadcrumb($this->__('Request New Product'), $this->__('Request New Product'));
31
+
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Check currently called action by permissions for current user
37
+ *
38
+ * @return bool
39
+ */
40
+ protected function _isAllowed()
41
+ {
42
+ return Mage::getSingleton('admin/session')->isAllowed('sales/niveus_requestproduct_requestnewproduct');
43
+ }
44
+ }
app/code/community/Niveus/Requestproduct/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Niveus Solutoins.
4
+ */
5
+ class Niveus_Requestproduct_IndexController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ /**
8
+ * index method for the controller
9
+ */
10
+ public function indexAction()
11
+ {
12
+ $this->loadLayout(array('default'));
13
+ $this->renderLayout();
14
+ }
15
+
16
+ /**
17
+ * This method save the requested new product
18
+ * into the database
19
+ */
20
+ public function saveRequestedProductAction(){
21
+
22
+ $name = $this->getRequest()->getParam("yourname");
23
+ $email = $this->getRequest()->getParam("youremail");
24
+ $productname= $this->getRequest()->getParam("productname");
25
+ $brand= $this->getRequest()->getParam("brand");
26
+ $seenproduct= $this->getRequest()->getParam("seenproduct");
27
+ $aboutproduct= $this->getRequest()->getParam("aboutproduct");
28
+
29
+ try {
30
+ $model = Mage::getModel('niveus_requestproduct/requestnewproduct');
31
+
32
+ $model->setData(
33
+ array( 'name' => $name,
34
+ 'email' => $email,
35
+ 'productname' => $productname,
36
+ 'brand' => $brand,
37
+ 'seenproduct' => $seenproduct,
38
+ 'aboutproduct' => $aboutproduct
39
+ ))->save();
40
+ Mage::getSingleton('core/session')->addSuccess('Proudct Requested Successfully.');
41
+ $this->_redirect('requestproduct');
42
+ } catch (Exception $e) {
43
+ throw $e;
44
+ }
45
+ }
46
+ }
47
+ ?>
app/code/community/Niveus/Requestproduct/etc/adminhtml.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <!--
5
+ This item will be created in the Admin menu under Sales
6
+ - If you want another section, reference the appropriate adminhtml.xml file in app/code/core/Mage/Modulename/etc
7
+ - For example, we found out this was 'sales' by referencing the config/menu node of app/code/core/Mage/Sales/etc/adminhtml.xml
8
+ -->
9
+ <catalog>
10
+ <children>
11
+ <!-- Here, I like to use the namespacename_modulename_controllername naming convention -->
12
+ <niveus_requestproduct_requestnewproduct translate="title" module="niveus_requestproduct">
13
+ <!-- This is how the menu text will be displayed -->
14
+ <title>Request New Product</title>
15
+ <!-- This is the URL of what we want the menu item to link to -->
16
+ <action>adminhtml/requestnewproduct</action>
17
+ </niveus_requestproduct_requestnewproduct>
18
+ </children>
19
+ </catalog>
20
+ </menu>
21
+
22
+ <acl>
23
+ <resources>
24
+ <admin>
25
+ <children>
26
+ <!-- Same as above, but instead of referencing the config/menu node, you reference the acl/resources node of adminhtml.xml -->
27
+ <catalog>
28
+ <children>
29
+ <!-- Keep the same naming convention as above -->
30
+ <niveus_requestproduct_requestnewproduct>
31
+ <!-- This is how the ACL text will be displayed on System > Permissions > Roles > Role > Role Resources -->
32
+ <title>Request New Product</title>
33
+ </niveus_requestproduct_requestnewproduct>
34
+ </children>
35
+ </catalog>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </config>
app/code/community/Niveus/Requestproduct/etc/config.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Niveus_Requestproduct>
5
+ <version>1.0.0</version>
6
+ </Niveus_Requestproduct>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <requestproduct>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Niveus_Requestproduct</module>
14
+ <frontName>requestnewproduct</frontName>
15
+ </args>
16
+ </requestproduct>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <requestproduct>
21
+ <file>requestproduct.xml</file>
22
+ </requestproduct>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+
27
+ <global>
28
+ <helpers>
29
+ <niveus_requestproduct>
30
+ <!-- This is where we define our helper directory -->
31
+ <class>Niveus_Requestproduct_Helper</class>
32
+ </niveus_requestproduct>
33
+ </helpers>
34
+
35
+ <blocks>
36
+ <niveus_requestproduct>
37
+ <!-- Set a block definition and lookup directory -->
38
+ <class>Niveus_Requestproduct_Block</class>
39
+ </niveus_requestproduct>
40
+ </blocks>
41
+
42
+ <models>
43
+ <niveus_requestproduct>
44
+ <!-- This is where we define our model directory -->
45
+ <class>Niveus_Requestproduct_Model</class>
46
+ <!-- Define a resource to create a custom table -->
47
+ <resourceModel>niveus_requestproduct_mysql4</resourceModel>
48
+ </niveus_requestproduct>
49
+
50
+ <!-- Here's our resource model we'll use to create a database table -->
51
+ <niveus_requestproduct_mysql4>
52
+ <class>Niveus_Requestproduct_Model_Mysql4</class>
53
+ <entities>
54
+ <!-- Let's define our table, we'll call it with the baz name, but the real table is foo_bar_baz -->
55
+ <!-- After we define our entity, we can call it with our model by calling foo_bar/baz -->
56
+ <requestnewproduct>
57
+ <table>niveus_requestproduct_requestnewproduct</table>
58
+ </requestnewproduct>
59
+ </entities>
60
+ </niveus_requestproduct_mysql4>
61
+ </models>
62
+
63
+ <!-- And finally we define our resource setup script -->
64
+ <resources>
65
+ <niveus_requestproduct_setup>
66
+ <setup>
67
+ <module>Niveus_Requestproduct</module>
68
+ </setup>
69
+ </niveus_requestproduct_setup>
70
+ </resources>
71
+ </global>
72
+
73
+ <admin>
74
+ <routers>
75
+ <adminhtml>
76
+ <args>
77
+ <!-- This is how we load our Adminhtml controllers -->
78
+ <modules>
79
+ <Niveus_Requestproduct before="Mage_Adminhtml">Niveus_Requestproduct_Adminhtml</Niveus_Requestproduct>
80
+ </modules>
81
+ </args>
82
+ </adminhtml>
83
+ </routers>
84
+ </admin>
85
+
86
+ <adminhtml>
87
+ <layout>
88
+ <updates>
89
+ <niveus_requestproduct>
90
+ <!--
91
+ We again keep a nice naming convention and make our module upgrade proof by placing it in a separate folder
92
+ - Since we are in the adminhtml node, this will look for the XML file in the app/design/adminhtml/default/default root folder
93
+ -->
94
+ <file>niveus/requestproduct.xml</file>
95
+ </niveus_requestproduct>
96
+ </updates>
97
+ </layout>
98
+ </adminhtml>
99
+ </config>
app/code/community/Niveus/Requestproduct/sql/niveus_requestproduct_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create table 'niveus_requestproduct_requestnewproduct'
8
+ */
9
+ $table = $installer->getConnection()
10
+ ->newTable($installer->getTable('niveus_requestproduct/requestnewproduct'))
11
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
+ 'identity' => true,
13
+ 'unsigned' => true,
14
+ 'nullable' => false,
15
+ 'primary' => true,
16
+ ), 'ID')
17
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
18
+ 'nullable' => false,
19
+ ), 'Name')
20
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_VARCHAR, 0, array(
21
+ 'nullable' => false,
22
+ ), 'Email')
23
+ ->addColumn('productname', Varien_Db_Ddl_Table::TYPE_VARCHAR, 0, array(
24
+ 'nullable' => false,
25
+ ), 'Product Name')
26
+ ->addColumn('brand', Varien_Db_Ddl_Table::TYPE_VARCHAR, 0, array(
27
+ 'nullable' => false,
28
+ ), 'Brand')
29
+ ->addColumn('seenproduct', Varien_Db_Ddl_Table::TYPE_VARCHAR, 0, array(
30
+ 'nullable' => false,
31
+ ), 'Seen Product')
32
+ ->addColumn('aboutproduct', Varien_Db_Ddl_Table::TYPE_VARCHAR, 0, array(
33
+ 'nullable' => false,
34
+ ), 'About Product');
35
+ $installer->getConnection()->createTable($table);
36
+
37
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/niveusproductvideo.xml ADDED
@@ -0,0 +1 @@
 
1
+ <?xml version="1.0"?>
app/design/adminhtml/default/default/template/niveusproductvideo/tab/videos.phtml ADDED
@@ -0,0 +1 @@
 
0
  * Video Plugin for Magento
1
  *
2
  * This source file is subject to the Open Software License (OSL 3.0)
3
  * that is bundled with this package in the file LICENSE.txt.
4
  * It is also available through the world-wide-web at this URL:
5
  * http://opensource.org/licenses/osl-3.0.php
6
  *
7
  * @category Niveus
8
  * @package Niveus_ProductVideo
9
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
10
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
  * @author Niveus Solutions <support@niveussolutions.com>
12
  */
13
  <div class="entry-edit-head">
14
  </div>
15
  <div class="fieldset fieldset-wide" id="group_fields_videos">
16
  <table cellspacing="0" class="form-list" id="table_cataloginventory">
17
  <?php $count=0; ?>
18
  <?php foreach ($this->getVideosCollection() as $video): ?>
19
  <?php $count++ ?>
20
  <?php if($count==1) :?>
21
  <?php $video1_exe =true ;?>
22
  <tr>
23
  <td class="label"><label for="video1"><?php echo Mage::helper('catalog')->__('Video 1') ?></label></td>
24
  <td class="value"><input type="text" class="input-text" id="video1" name="video1" value="<?php echo $video->getVideoCode() ?>"/>
25
  </tr>
26
  <?php elseif($count==2) :?>
27
  <?php $video2_exe =true ;?>
28
  <tr>
29
  <td class="label"><label for="video2"><?php echo Mage::helper('catalog')->__('Video 2') ?></label></td>
30
  <td class="value"><input type="text" class="input-text" id="video2" name="video2" value="<?php echo $video->getVideoCode() ?>"/>
31
  </tr>
32
  <?php else :?>
33
  <?php $video3_exe =true ;?>
34
  <tr>
35
  <td class="label"><label for="video3"><?php echo Mage::helper('catalog')->__('Video 3') ?></label></td>
36
  <td class="value"><input type="text" class="input-text" id="video3" name="video3" value="<?php echo $video->getVideoCode() ?>"/>
37
  </tr>
38
  <?php endif; ?>
39
  <?php endforeach; ?>
40
  <?php if(!$video1_exe) :?>
41
  <tr>
42
  <td class="label"><label for="video1"><?php echo Mage::helper('catalog')->__('Video 1') ?></label></td>
43
  <td class="value"><input type="text" class="input-text" id="video1" name="video1" value=""/>
44
  </tr>
45
  <?php endif; ?>
46
  <?php if(!$video2_exe) :?>
47
  <tr>
48
  <td class="label"><label for="video2"><?php echo Mage::helper('catalog')->__('Video 2') ?></label></td>
49
  <td class="value"><input type="text" class="input-text" id="video2" name="video2" value=""/>
50
  </tr>
51
  <?php endif; ?>
52
  <?php if(!$video3_exe) :?>
53
  <tr>
54
  <td class="label"><label for="video3"><?php echo Mage::helper('catalog')->__('Video 3') ?></label></td>
55
  <td class="value"><input type="text" class="input-text" id="video3" name="video3" value=""/>
56
  </tr>
57
  <?php endif; ?>
58
 
59
  </table>
60
  </div>
1
+ <?php
2
  * Video Plugin for Magento
3
  *
4
  * This source file is subject to the Open Software License (OSL 3.0)
5
  * that is bundled with this package in the file LICENSE.txt.
6
  * It is also available through the world-wide-web at this URL:
7
  * http://opensource.org/licenses/osl-3.0.php
8
  *
9
  * @category Niveus
10
  * @package Niveus_ProductVideo
11
  * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
12
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
  * @author Niveus Solutions <support@niveussolutions.com>
14
  */
15
  <div class="entry-edit-head">
16
  </div>
17
  <div class="fieldset fieldset-wide" id="group_fields_videos">
18
  <table cellspacing="0" class="form-list" id="table_cataloginventory">
19
  <?php $count=0; ?>
20
  <?php foreach ($this->getVideosCollection() as $video): ?>
21
  <?php $count++ ?>
22
  <?php if($count==1) :?>
23
  <?php $video1_exe =true ;?>
24
  <tr>
25
  <td class="label"><label for="video1"><?php echo Mage::helper('catalog')->__('Video 1') ?></label></td>
26
  <td class="value"><input type="text" class="input-text" id="video1" name="video1" value="<?php echo $video->getVideoCode() ?>"/>
27
  </tr>
28
  <?php elseif($count==2) :?>
29
  <?php $video2_exe =true ;?>
30
  <tr>
31
  <td class="label"><label for="video2"><?php echo Mage::helper('catalog')->__('Video 2') ?></label></td>
32
  <td class="value"><input type="text" class="input-text" id="video2" name="video2" value="<?php echo $video->getVideoCode() ?>"/>
33
  </tr>
34
  <?php else :?>
35
  <?php $video3_exe =true ;?>
36
  <tr>
37
  <td class="label"><label for="video3"><?php echo Mage::helper('catalog')->__('Video 3') ?></label></td>
38
  <td class="value"><input type="text" class="input-text" id="video3" name="video3" value="<?php echo $video->getVideoCode() ?>"/>
39
  </tr>
40
  <?php endif; ?>
41
  <?php endforeach; ?>
42
  <?php if(!$video1_exe) :?>
43
  <tr>
44
  <td class="label"><label for="video1"><?php echo Mage::helper('catalog')->__('Video 1') ?></label></td>
45
  <td class="value"><input type="text" class="input-text" id="video1" name="video1" value=""/>
46
  </tr>
47
  <?php endif; ?>
48
  <?php if(!$video2_exe) :?>
49
  <tr>
50
  <td class="label"><label for="video2"><?php echo Mage::helper('catalog')->__('Video 2') ?></label></td>
51
  <td class="value"><input type="text" class="input-text" id="video2" name="video2" value=""/>
52
  </tr>
53
  <?php endif; ?>
54
  <?php if(!$video3_exe) :?>
55
  <tr>
56
  <td class="label"><label for="video3"><?php echo Mage::helper('catalog')->__('Video 3') ?></label></td>
57
  <td class="value"><input type="text" class="input-text" id="video3" name="video3" value=""/>
58
  </tr>
59
  <?php endif; ?>
60
 
61
  </table>
62
  </div>
app/design/frontend/default/default/layout/niveusproductvideo.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+
5
+ <default>
6
+ <reference name="head">
7
+ <action method="addCss"><stylesheet>css/productvideo/style.css</stylesheet></action>
8
+ <action method="addCss" ><stylesheet>css/tinybox2/style.css</stylesheet></action>
9
+ <action method="addJs" ><script>niveus/tinybox2/tinybox.js</script></action>
10
+ </reference>
11
+ </default>
12
+
13
+ <catalog_product_view translate="label">
14
+ <reference name="content">
15
+ <reference name="product.info">
16
+ <reference name="product.info.media">
17
+ <block type="productvideo/video" name="product.info.media.video" as="media_video" template="niveusproductvideo/video.phtml"/>
18
+ </reference>
19
+ </reference>
20
+ </reference>
21
+ </catalog_product_view>
22
+
23
+ </layout>
app/design/frontend/default/default/template/niveusproductvideo/video.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Video Plugin for Magento
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Niveus
11
+ * @package Niveus_ProductVideo
12
+ * @copyright Copyright (c) 2013 Niveus Solutions (http://www.niveussolutions.com)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ * @author Niveus Solutions <support@niveussolutions.com>
15
+ */
16
+ ?>
17
+
18
+ <?php
19
+ $_productVideos = $this->_getProductVideos();
20
+ $a=0;
21
+
22
+ ?>
23
+ <?php if($_productVideos && $_productVideos->count() > 0):?>
24
+ <h3><?php echo $this->__('Product Videos') ?></h3>
25
+
26
+
27
+
28
+ <?php foreach($_productVideos as $video) : ?>
29
+ <?php $video = $this->getCode($video);?>
30
+ <?php $video_code=substr($video,-11,11); ?>
31
+ <?php if($video_code !=''):?>
32
+ <?php echo "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/$video_code\" frameborder=\"0\"></iframe>";?>
33
+ <!-- video from youtube -->
34
+ <?php endif;?>
35
+ <?php endforeach; ?>
36
+
37
+ <?php endif;?>
app/etc/modules/Niveus_ProductVideo.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Niveus_ProductVideo>
6
+ <active>true</active>
7
+ <codePool>community</codePool>
8
+ </Niveus_ProductVideo>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Niveus_ProductVideo</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Niveus Youtube product Video extension</summary>
10
+ <description>Niveus Youtube product Video extension</description>
11
+ <notes>Installation steps</notes>
12
+ <authors><author><name>Niveus Solutions</name><user>niveussolutions</user><email>support@niveussolutions.com</email></author></authors>
13
+ <date>2013-10-23</date>
14
+ <time>08:45:48</time>
15
+ <contents><target name="magecommunity"><dir name="Niveus"><dir name="ProductVideo"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Videos.php" hash="0e4ea8296cdf584cf9756cc086acec13"/><file name="Videos.php~" hash="c21edc574c4c186b23dbccc2d067b503"/></dir></dir></dir></dir></dir><dir name="Product"><dir name="View"><file name="Attribute.php~" hash="629d0759593202ee9d8886d863eff0c1"/><file name="List.php~" hash="9f52ae0257c000b26538daa0a6b5320c"/><file name="Media.php" hash="87141206ee837993560d66872c8f80b1"/><file name="Media.php~" hash="a512858484654f67e015b59def270d13"/></dir></dir><dir name="Rewrite"><file name="AdminhtmlCatalogProductEditTabs.php" hash="d4fcf87e7c895f792927b57dd9af9625"/><file name="AdminhtmlCatalogProductEditTabs.php~" hash="01e2d8cbbee88a7bbc68e5c05e933d54"/></dir><file name="Video.php" hash="234d015965cc9ca9fedac78d5db52ebf"/><file name="Video.php~" hash="77668e1600fbb49e7884167842e1a6a3"/></dir><dir name="Helper"><file name="Data.php" hash="ab2f4060c3e9182f197f075b8e7faf50"/><file name="Data.php~" hash="ab2f4060c3e9182f197f075b8e7faf50"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="Scrolling.php" hash="1d095e7d24d4e640fb3b11baa4027b77"/><file name="Scrolling.php~" hash="29faa4933274ad9848784b751730b7dc"/><file name="Titleposition.php" hash="af43b76604b69f24c58c4bf35bab40a3"/><file name="Titleposition.php~" hash="eca314ba351356270cd362da50f974f4"/><file name="Transition.php" hash="387dfb1df77743b982bb0cd8de7c85a1"/><file name="Transition.php~" hash="974787453cece93a0a85cf0fc3046c65"/></dir></dir><file name="Observer.php" hash="1965676480638ee512c57c03016af894"/><file name="Observer.php~" hash="1965676480638ee512c57c03016af894"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="0b890d0edf9f635c34d84e80410ab230"/><file name="Setup.php~" hash="392ab06b2156327c4a9e8a3d77160f4a"/></dir></dir><dir name="Videos"><file name="Collection.php" hash="1d5a542d7a919ddeccef1cf3c9607b2f"/><file name="Collection.php~" hash="701b62fdd06add657539e507a3212971"/></dir><file name="Videos.php" hash="4ac319ed11931591649f9ac4569d107b"/><file name="Videos.php~" hash="2d56dcba2e2548597e48bf1afbdb9a58"/></dir><file name="Videos.php" hash="d35074b3b0acd6426ec5df12cf63d077"/><file name="Videos.php~" hash="8bcb8be4da9a0a642722ac4a38ac6729"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VideosController.php" hash="7174a2ff3564f654110d94a16138bf5a"/><file name="VideosController.php~" hash="d5d5dff399e2a59559e8f635e58258a0"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="a00ffae61be96cd04e435c830cf3fd4d"/><file name="adminhtml.xml~" hash="3d6cc4da367e365a43f9ad9bd7884b79"/><file name="config.xml" hash="e9664be84d55b51586a24b65c7490cd0"/><file name="config.xml~" hash="31e04f56504768122775237092c66119"/><file name="system.xml" hash="b8f38b5efc46ec5a9e0ae6c7d02d6232"/><file name="system.xml~" hash="153a4c149fbb890c81ff6f2cabe9ff61"/></dir><dir name="sql"><dir name="productvideo_setup"><file name="mysql4-install-0.1.0.php" hash="4022ec194b52e4800bbe6061ecf8d61c"/><file name="mysql4-install-0.1.0.php~" hash="a0c584b076e48fa0d7f9ced873df3ae7"/></dir></dir></dir><dir name="Productlabels"><dir name="Block"><dir name="Adminhtml"><dir name="Css"><dir name="Edit"><file name="Form.php" hash="ed8c1915d2f972d5849631b069f26d2c"/><dir name="Tab"><file name="Css.php" hash="5896363400ff6896bfe85cf43c25a47c"/></dir><file name="Tabs.php" hash="7a72c8ab6b34bfb293038c1eb6b339b9"/></dir><file name="Edit.php" hash="7ef9fc050ffb651b5653b728bf6c0915"/></dir><dir name="Element"><file name="Fieldset.php" hash="dcaa6c730ef2e45189395ea2d529c7b8"/><file name="Fieldsetcss.php" hash="18ed9185d8f2cc4a25bfddd7f9fcb69b"/><file name="Form.php" hash="a4b21cb1f410d082dd34b0f7ba772f59"/><file name="Formcss.php" hash="c5774cd8a0175403ebd1154b1022ed53"/></dir><dir name="Productlabels"><dir name="Edit"><file name="Form.php" hash="fe73133f3bfe4017ed67ec0d99938152"/><dir name="Tab"><file name="Form.php" hash="c864703a4b3bb5b5b878e9793215df74"/></dir><file name="Tabs.php" hash="c6d8814b6f87b642baaab4f139d6b8f2"/></dir><file name="Edit.php" hash="2707424e17e7b90408dafa3a412db9c2"/><file name="Grid.php" hash="f3b71f4e4f921924f2d46904f8bd2ee4"/></dir><file name="Productlabels.php" hash="315baf396b30ad602cf3767d603b4f7e"/></dir><file name="Css.php" hash="07d4a0e8f0ea4c799fb946b900a45db3"/><file name="Productlabels.php" hash="36cab2e245b8d063705b3d5ef6a9ad3c"/></dir><dir name="Helper"><file name="Data.php" hash="a70dcac7899973067cee7151642364ae"/></dir><dir name="Model"><file name="Attribute.php" hash="48fac3d5a030d35167166823cb8cf725"/><dir name="Config"><file name="Listlabel.php" hash="26e4b02997f1533fc1017a1618032ea8"/></dir><file name="Css.php" hash="81098db1bbf248e1f09f0e44d3a3bad6"/><file name="Filter.php" hash="6a3bb1444b27ee658534b143a9e3c87f"/><dir name="Mysql4"><dir name="Attribute"><file name="Collection.php" hash="acfc8ec200a806a8a0c2f89c7fb5193b"/></dir><file name="Attribute.php" hash="72fe613a46c1d132b35e3468d58d3219"/><dir name="Css"><file name="Collection.php" hash="9638e030e64cb9ba369bb9812529b9f1"/></dir><file name="Css.php" hash="a25ff38ac6c201a6aa69055d2e1ab6be"/><dir name="Productlabels"><file name="Collection.php" hash="088e985434b0bb89fce61097cd05e32d"/></dir><file name="Productlabels.php" hash="6641c732e67ed167ae1e5a4cf609abdf"/><dir name="Type"><dir name="Int"><file name="Collection.php" hash="48704bf993039f9e3a8c2d471ddfa4d3"/></dir><file name="Int.php" hash="462c3c025c8597a64171cd0514c56795"/><dir name="Text"><file name="Collection.php" hash="6a041a2150543a33c766836a421e58b4"/></dir><file name="Text.php" hash="9ae20145e4ce51141cbf1d5f6d104f5f"/><dir name="Varchar"><file name="Collection.php" hash="4aade6c96b304c31b52c55225189c5bb"/></dir><file name="Varchar.php" hash="11fa5f50c8537ac5a22873887c8df71f"/></dir></dir><file name="Productlabels.php" hash="c96e916c3690553abcb480591b90c65b"/><file name="Productrule.php" hash="b7fda88790fa5c8d75a197798d49eaed"/><dir name="Rule"><file name="Combine.php" hash="f0405f5a64b4705136c5656496ff7b54"/><dir name="Condition"><file name="Product.php" hash="b36b021911e5f8c1ea3d181f57eb5c1b"/></dir></dir><file name="Rule.php" hash="3d8e84ab8330c7c500f87e5acbba6b06"/><file name="Status.php" hash="ba4d1887925d64b5f1e08d8a76ada20b"/><dir name="Type"><file name="Int.php" hash="eb66febc12123f89f3ba79471e643f5e"/><file name="Text.php" hash="439800248c540054e0b9569a9b6b091d"/><file name="Varchar.php" hash="b4bd9e725692dfad41ee8cdd5ec63072"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CssController.php" hash="76c9435113ac8b8c8c2095015c8121ca"/><file name="ProductlabelsController.php" hash="b5c6857152c6db604fac4875031a6636"/></dir><file name="IndexController.php" hash="d9329179b2df9ac7592b43859a95e303"/></dir><dir name="etc"><file name="config.xml" hash="f2096683d45027ea2b77af514520e718"/></dir><dir name="sql"><dir name="productlabels_setup"><file name="mysql4-install-0.1.0.php" hash="036e89fddcc47a057405b09078f716fe"/></dir></dir></dir><dir name="Requestproduct"><dir name="Block"><dir name="Adminhtml"><dir name="Requestnewproduct"><file name="Grid.php" hash="984afc40cdcc6e5de0111b2d979c49df"/></dir><file name="Requestnewproduct.php" hash="49d5319bc250e3a2fccabf64fafb6f2a"/></dir><file name="Requestnewproduct.php" hash="521a429ca3cb52355ad0cc3b3e54d563"/></dir><dir name="Helper"><file name="Data.php" hash="3b9e179e7208b94a24953047acd8dfeb"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Requestnewproduct"><file name="Collection.php" hash="214ee065627f865530848a104fbd7e42"/></dir><file name="Requestnewproduct.php" hash="c41aba6bc9960cca9d57bb0b79a9da99"/></dir><file name="Requestnewproduct.php" hash="3e8de61d3aa001b29d17e1eb98dbda45"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RequestnewproductController.php" hash="8d1b637b22946ad97241da64477dc22e"/></dir><file name="IndexController.php" hash="d10c2a99cca80d2e99fb4ca74e3c67f3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e574166dfed0b5ff3cba53d8b7fa7971"/><file name="config.xml" hash="a63b6aeeaf54b20a2248df4eb1d97f01"/></dir><dir name="sql"><dir name="niveus_requestproduct_setup"><file name="mysql4-install-1.0.0.php" hash="09bf04e865cc38bc18011401e96e877e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Niveus_ProductVideo.xml" hash="7d2fb29c666116bb33c0867e383e0788"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="niveusproductvideo.xml" hash="61f41423688de05affbfd3f0287d609d"/></dir><dir name="template"><dir name="niveusproductvideo"><dir name="tab"><file name="videos.phtml" hash="4374353dec1adea731a75181407b8490"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="niveusproductvideo.xml" hash="de98ce985d056729d5f0f86e57809f7f"/></dir><dir name="template"><dir name="niveusproductvideo"><file name="video.phtml" hash="d659f4a028076d328819319447fde673"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>