auguriaInteractiveImage - Version 0.0.1

Version Notes

First version of the extension. Free Auguria_Core extension required.

Download this release

Release Info

Developer Auguria
Extension auguriaInteractiveImage
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (33) hide show
  1. app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive.php +82 -0
  2. app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Panel/Area/Default.php +11 -0
  3. app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Panel/Areas.php +98 -0
  4. app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Popin.php +50 -0
  5. app/code/community/Auguria/InteractiveImage/Block/Catalog/Product/Image.php +186 -0
  6. app/code/community/Auguria/InteractiveImage/Helper/Config.php +24 -0
  7. app/code/community/Auguria/InteractiveImage/Helper/Data.php +33 -0
  8. app/code/community/Auguria/InteractiveImage/Model/Catalog/Product/Attribute/Backend/Image.php +94 -0
  9. app/code/community/Auguria/InteractiveImage/controllers/Adminhtml/Auguria/InteractiveImage/ImageController.php +111 -0
  10. app/code/community/Auguria/InteractiveImage/controllers/Checkout/Cart/AjaxController.php +164 -0
  11. app/code/community/Auguria/InteractiveImage/controllers/Checkout/CartController.php +164 -0
  12. app/code/community/Auguria/InteractiveImage/etc/adminhtml.xml +30 -0
  13. app/code/community/Auguria/InteractiveImage/etc/config.xml +111 -0
  14. app/code/community/Auguria/InteractiveImage/etc/jstranslator.xml +14 -0
  15. app/code/community/Auguria/InteractiveImage/etc/system.xml +45 -0
  16. app/code/community/Auguria/InteractiveImage/sql/auguria_interactiveimage_setup/install-0.0.1.php +37 -0
  17. app/design/adminhtml/default/default/layout/auguria/interactive_image.xml +35 -0
  18. app/design/adminhtml/default/default/template/auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/area/default.phtml +46 -0
  19. app/design/adminhtml/default/default/template/auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/areas.phtml +25 -0
  20. app/design/adminhtml/default/default/template/auguria/interactiveimage/catalog/product/helper/form/image/interactive/popin.phtml +35 -0
  21. app/design/frontend/base/default/layout/auguria/interactive_image.xml +26 -0
  22. app/design/frontend/base/default/template/auguria/interactiveimage/catalog/product/image.phtml +126 -0
  23. app/etc/modules/Auguria_InteractiveImage.xml +20 -0
  24. app/locale/en_US/Auguria_InteractiveImage.csv +0 -0
  25. app/locale/fr_FR/Auguria_InteractiveImage.csv +14 -0
  26. js/auguria/interactiveimage/cart.js +11 -0
  27. js/auguria/interactiveimage/image.js +357 -0
  28. js/auguria/interactiveimage/jquery-1.10.2.min.js +7 -0
  29. js/auguria/interactiveimage/jquery.maphilight.min.js +1 -0
  30. js/auguria/interactiveimage/kinetic-v4.5.4.min.js +4 -0
  31. package.xml +28 -0
  32. skin/adminhtml/default/default/auguria/interactiveimage/image.css +25 -0
  33. skin/frontend/base/default/css/auguria/interactiveimage/image.css +20 -0
app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Image
10
+ {
11
+ /**
12
+ * Override getValue method
13
+ *
14
+ * @return string : path of the image
15
+ */
16
+ public function getValue()
17
+ {
18
+ $array = $this->getJsonValue();
19
+
20
+ return $array['image_path'];
21
+ }
22
+
23
+ /**
24
+ * Get json value
25
+ *
26
+ * @param bool $asArray
27
+ * @return mixed|array|string
28
+ */
29
+ public function getJsonValue($asArray = true)
30
+ {
31
+ $string = $this->getData('value');
32
+
33
+ if($asArray){
34
+ return Mage::helper('core')->jsonDecode($string);
35
+ }
36
+
37
+ return $string;
38
+ }
39
+
40
+ /**
41
+ * Get areas value
42
+ *
43
+ * @param bool $asArray
44
+ * @return mixed|array|string
45
+ */
46
+ public function getAreas($asArray = true)
47
+ {
48
+ $attributeValue = $this->getJsonValue();
49
+ $areas = is_array($attributeValue) && array_key_exists('areas', $attributeValue) ? $attributeValue['areas'] : array();
50
+
51
+ if($asArray){
52
+ return $areas;
53
+ }else{
54
+ return Mage::helper('core')->jsonEncode($areas);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Return element html code
60
+ *
61
+ * @return string
62
+ */
63
+ public function getElementHtml()
64
+ {
65
+ $html = parent::getElementHtml();
66
+
67
+ $areas = $this->getAreas(false); // json encoded
68
+ $imageUrl = $this->_getUrl();
69
+
70
+ $params = $this->getJsonValue(false); // json encoded
71
+ $parameters = $params ? $params : '\'\'';
72
+
73
+ $html .= '
74
+ <div class="clear"></div>
75
+ <input type="hidden" id="' . $this->getName() . '_areas" name="product['. $this->getName() . '][areas]" value="' . $areas . '"/>
76
+ <script type="text/javascript">var interactiveImage = new InteractiveImage(\'' . $imageUrl . '\', ' . $parameters . ');</script>
77
+ <button type="button" onclick="interactiveImage.display();return false;">' . Mage::helper('auguria_interactiveimage')->__('Define areas') . '</button>
78
+ ';
79
+
80
+ return $html;
81
+ }
82
+ }
app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Panel/Area/Default.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Panel_Area_Default extends Mage_Core_Block_Template
10
+ {
11
+ }
app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Panel/Areas.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Panel_Areas extends Mage_Core_Block_Template
10
+ {
11
+ protected $_areas;
12
+
13
+ protected $_areaRenders = array();
14
+
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->addAreaRenderer(
19
+ 'default',
20
+ 'auguria_interactiveimage/adminhtml_catalog_product_helper_form_image_interactive_panel_area_default',
21
+ 'auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/area/default.phtml'
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Retrieve area
27
+ *
28
+ * @return array
29
+ */
30
+ public function getAreas()
31
+ {
32
+ return $this->_areas;
33
+ }
34
+
35
+ /**
36
+ * Set area
37
+ *
38
+ * @param array $area
39
+ * @return Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Panel_Areas
40
+ */
41
+ public function setAreas(array $areas = null)
42
+ {
43
+ $this->_areas = $areas;
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Add area renderer to renderers array
49
+ *
50
+ * @param string $type
51
+ * @param string $block
52
+ * @param string $template
53
+ * @return Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Panel_Areas
54
+ */
55
+ public function addAreaRenderer($type, $block, $template)
56
+ {
57
+ $this->_areaRenders[$type] = array(
58
+ 'block' => $block,
59
+ 'template' => $template,
60
+ 'renderer' => null
61
+ );
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Get area render by given type
67
+ *
68
+ * @param string $type
69
+ * @return array
70
+ */
71
+ public function getAreaRender($type)
72
+ {
73
+ if (isset($this->_areaRenders[$type])) {
74
+ return $this->_areaRenders[$type];
75
+ }
76
+
77
+ return $this->_areaRenders['default'];
78
+ }
79
+
80
+ /**
81
+ * Get option html block
82
+ *
83
+ * @param array $area
84
+ */
85
+ public function getAreaHtml(array $area)
86
+ {
87
+ $renderer = $this->_areaRenders[$area['render']];
88
+
89
+ if (is_null($renderer['renderer'])) {
90
+ $renderer['renderer'] = $this->getLayout()->createBlock($renderer['block'])
91
+ ->setTemplate($renderer['template']);
92
+ }
93
+
94
+ return $renderer['renderer']
95
+ ->setInteractiveArea($area) // "area" reserved name
96
+ ->toHtml();
97
+ }
98
+ }
app/code/community/Auguria/InteractiveImage/Block/Adminhtml/Catalog/Product/Helper/Form/Image/Interactive/Popin.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Popin extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Get edition interface parameters
13
+ *
14
+ * @var null|array
15
+ */
16
+ protected $_params = null;
17
+
18
+ /**
19
+ * Initialise parameters
20
+ *
21
+ * @param array $params
22
+ * @return Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Popin
23
+ */
24
+ public function setParams(array $params)
25
+ {
26
+ $this->_params = $params;
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * Get parameters
32
+ *
33
+ * @return null|array
34
+ */
35
+ public function getParams()
36
+ {
37
+ return $this->_params;
38
+ }
39
+
40
+ /**
41
+ * Get image properties
42
+ *
43
+ * @return array
44
+ */
45
+ public function getImage()
46
+ {
47
+ return array('url' => $this->_params['image_url'], 'size' => getimagesize($this->_params['image_url']));
48
+ }
49
+
50
+ }
app/code/community/Auguria/InteractiveImage/Block/Catalog/Product/Image.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Block_Catalog_Product_Image extends Mage_Core_Block_Template
10
+ {
11
+ protected $_imageUrl;
12
+ protected $_imageSize;
13
+ protected $_areas;
14
+ protected $_products;
15
+ protected $_productsBySku;
16
+ protected $_positions;
17
+
18
+ /**
19
+ * Get image url
20
+ *
21
+ * @return string
22
+ */
23
+ public function getInteractiveImage()
24
+ {
25
+ if(!$this->_imageUrl){
26
+ $values = Mage::helper('core')->jsonDecode($this->getProduct()->getData('auguria_interactiveimage_image'));
27
+ // image
28
+ if(!empty($values['image_path'])){
29
+ $this->_imageUrl = Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrl() . '/' . $values['image_path'];
30
+
31
+ $sizes = getimagesize($this->_imageUrl);
32
+ $this->_imageSize = array('width' => $sizes[0], 'height' => $sizes[1]);
33
+ }
34
+
35
+ // areas
36
+ if(!empty($values['areas'])){
37
+ $this->_areas = Mage::helper('core')->jsonDecode($values['areas']);
38
+ }
39
+ }
40
+
41
+ return $this->_imageUrl;
42
+ }
43
+
44
+ /**
45
+ * Get image size
46
+ *
47
+ * @return null|array
48
+ */
49
+ public function getInteractiveImageSize()
50
+ {
51
+ return $this->_imageSize;
52
+ }
53
+
54
+ /**
55
+ * Get areas
56
+ *
57
+ * @return array
58
+ */
59
+ public function getAreas()
60
+ {
61
+ return $this->_areas;
62
+ }
63
+
64
+ /**
65
+ * Retrieve current product model
66
+ *
67
+ * @return Mage_Catalog_Model_Product
68
+ */
69
+ public function getProduct()
70
+ {
71
+ return Mage::registry('product');
72
+ }
73
+
74
+ /**
75
+ * Get area coords
76
+ *
77
+ * @param array $area
78
+ * @return array
79
+ */
80
+ public function getCoords($area)
81
+ {
82
+ $coords = array();
83
+
84
+ if($area['type'] == 'rect'){
85
+ $x2 = $area['size']['x'] + $area['size']['width'];
86
+ $y2 = $area['size']['y'] + $area['size']['height'];
87
+ $coords['area'] = $area['size']['x'] . ',' . $area['size']['y'] . ',' . $x2 . ',' . $y2;
88
+ $coords['tooltip'] = array('top' => -($this->_imageSize['height'] - $area['size']['y']), 'left' => $x2 + 10);
89
+ }
90
+
91
+ return $coords;
92
+ }
93
+
94
+ /**
95
+ * Get product associated with areas
96
+ *
97
+ * @return Mage_Catalog_Model_Resource_Product_Collection
98
+ */
99
+ public function getProducts()
100
+ {
101
+ if(!$this->_products){
102
+ $ids = array();
103
+
104
+ $product = Mage::getSingleton('catalog/product');
105
+ if($this->_areas){
106
+ foreach ($this->_areas as $_area){
107
+ $ids[] = $product->getIdBySku($_area['sku']);
108
+ $this->_positions[$_area['sku']] = $_area['position'];
109
+ }
110
+ }
111
+
112
+ $this->_products = Mage::getResourceModel('catalog/product_collection')
113
+ ->addAttributeToSelect(array('name', 'sku'))
114
+ ->addFieldToFilter('entity_id', array('in' => $ids))
115
+ ->addFinalPrice()
116
+ ->addStoreFilter(Mage::app()->getStore());
117
+
118
+ // get easily product by without reload them
119
+ foreach ($this->_products as $_product){
120
+ $this->_productsBySku[$_product->getSku()] = $_product;
121
+ }
122
+ }
123
+
124
+ return $this->_products;
125
+ }
126
+
127
+ /**
128
+ * Get product by sku
129
+ *
130
+ * @param string $sku
131
+ * @return Mage_Catalog_Model_Product
132
+ */
133
+ public function getProductBySku($sku)
134
+ {
135
+ return is_array($this->_productsBySku) && array_key_exists($sku, $this->_productsBySku) ? $this->_productsBySku[$sku] : null;
136
+ }
137
+
138
+ /**
139
+ * Get product position by sku
140
+ *
141
+ * @param string $sku
142
+ */
143
+ public function getPositionBySku($sku)
144
+ {
145
+ return $this->_positions[$sku];
146
+ }
147
+
148
+ /**
149
+ * Retrieve url for direct adding product to cart
150
+ *
151
+ * @param string $sku
152
+ * @param array $additional
153
+ * @return string
154
+ */
155
+ public function getAddToCartUrl($sku, $additional = array())
156
+ {
157
+ if ($this->getRequest()->getParam('wishlist_next')){
158
+ $additional['wishlist_next'] = 1;
159
+ }
160
+
161
+ $addUrlKey = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
162
+ $addUrlValue = Mage::getUrl('*/*/*', array('_use_rewrite' => true, '_current' => true));
163
+ $additional[$addUrlKey] = Mage::helper('core')->urlEncode($addUrlValue);
164
+
165
+ // no product load
166
+ $product = Mage::getModel('catalog/product');
167
+ $id = Mage::getModel('catalog/product')->getIdBySku($sku);
168
+ $product->setId($id);
169
+
170
+ return $this->helper('checkout/cart')->getAddUrl($product, $additional);
171
+ }
172
+
173
+ /**
174
+ * Retrieve url for direct adding product to cart
175
+ *
176
+ * @return string
177
+ */
178
+ public function getMassAddToCartUrl()
179
+ {
180
+ $addUrlKey = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
181
+ $addUrlValue = Mage::getUrl('*/*/*', array('_use_rewrite' => true, '_current' => true));
182
+ $additional[$addUrlKey] = Mage::helper('core')->urlEncode($addUrlValue);
183
+
184
+ return Mage::getUrl('image/checkout_cart/add', $additional);
185
+ }
186
+ }
app/code/community/Auguria/InteractiveImage/Helper/Config.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Helper_Config extends Mage_Core_Helper_Abstract {
10
+
11
+ /* PATH TO CONFIGURATION */
12
+ const XML_PATH_INTERACTIVE_IMAGE_USE_AJAX = 'auguria_interactiveimage/general/use_ajax';
13
+
14
+ /**
15
+ * Check if ajax must be used
16
+ *
17
+ * @return bool
18
+ */
19
+ public function useAjax()
20
+ {
21
+ return Mage::helper('core')->isModuleEnabled('Auguria_CartAjax') && Mage::getStoreConfigFlag(self::XML_PATH_INTERACTIVE_IMAGE_USE_AJAX);
22
+ }
23
+
24
+ }
app/code/community/Auguria/InteractiveImage/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Helper_Data extends Mage_Core_Helper_Abstract {
10
+
11
+ /**
12
+ * Get the full image path by attribute path saved
13
+ *
14
+ * @param string $attributeImagePath
15
+ * @return string
16
+ */
17
+ public function getFullImagePath($attributeImagePath)
18
+ {
19
+ return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS . $attributeImagePath;
20
+ }
21
+
22
+ /**
23
+ * Get the full image url by attribute path saved
24
+ *
25
+ * @param string $attributeImagePath
26
+ * @return string
27
+ */
28
+ public function getFullImageUrl($attributeImagePath)
29
+ {
30
+ return Mage::getBaseUrl('media') . 'catalog/product/' . $attributeImagePath;
31
+ }
32
+
33
+ }
app/code/community/Auguria/InteractiveImage/Model/Catalog/Product/Attribute/Backend/Image.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Model_Catalog_Product_Attribute_Backend_Image extends Auguria_Core_Model_Attribute_Backend_Image_Abstract
10
+ {
11
+ /**
12
+ * Default format/value for the attribute
13
+ *
14
+ * @var array
15
+ */
16
+ protected $_defaultValue = array('image_path' => '', 'areas' => array());
17
+
18
+ /**
19
+ * Save uploaded file
20
+ *
21
+ * @param Varien_Object $object
22
+ */
23
+ public function afterSave($object)
24
+ {
25
+ $value = $object->getData($this->getAttribute()->getName());
26
+
27
+ if (is_array($value)) {
28
+ if(!empty($value['delete'])){ // delete : save default value
29
+ $object->setData($this->getAttribute()->getName(), Mage::helper('core')->jsonEncode($this->_defaultValue));
30
+ $this->getAttribute()->getEntity()
31
+ ->saveAttribute($object, $this->getAttribute()->getName());
32
+ return;
33
+ }
34
+
35
+ try {
36
+ // upload image
37
+ if(!isset($value['value']) || !file_exists($this->_getPathWithoutPrefix() . $value['value'])){
38
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
39
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
40
+ $uploader->setAllowRenameFiles(true);
41
+ $result = $uploader->save($this->_getPath());
42
+
43
+ $value['image_path'] = $this->_getPrefix() . $result['file']; // update image path
44
+ }else{
45
+ $value['image_path'] = $value['value'];
46
+ }
47
+
48
+ $object->setData($this->getAttribute()->getName(), Mage::helper('core')->jsonEncode($value));
49
+ $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); // save attribute
50
+ } catch (Exception $e) {
51
+ if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
52
+ Mage::logException($e);
53
+ }
54
+
55
+ return;
56
+ }
57
+ }else{ // save default value
58
+ $object->setData($this->getAttribute()->getName(), Mage::helper('core')->jsonEncode($this->_defaultValue));
59
+ $this->getAttribute()->getEntity()
60
+ ->saveAttribute($object, $this->getAttribute()->getName());
61
+ return;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Get path to save file
67
+ *
68
+ * @return string
69
+ */
70
+ protected function _getPath()
71
+ {
72
+ return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS . 'auguria' . DS . 'interactiveimage' . DS;
73
+ }
74
+
75
+ /**
76
+ * Get prefix when save path file in attribute value
77
+ *
78
+ * @return string
79
+ */
80
+ protected function _getPrefix()
81
+ {
82
+ return 'auguria' . DS . 'interactiveimage' . DS;
83
+ }
84
+
85
+ /**
86
+ * Get path without prefix
87
+ *
88
+ * @return string
89
+ */
90
+ protected function _getPathWithoutPrefix()
91
+ {
92
+ return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS;
93
+ }
94
+ }
app/code/community/Auguria/InteractiveImage/controllers/Adminhtml/Auguria/InteractiveImage/ImageController.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ class Auguria_InteractiveImage_Adminhtml_Auguria_InteractiveImage_ImageController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ /**
11
+ * Additional initialization
12
+ *
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->setUsedModuleName('Auguria_InteractiveImage');
17
+ }
18
+
19
+ /**
20
+ * Display popin and canvas with image background and image dimensions
21
+ */
22
+ public function displayAction()
23
+ {
24
+ $response = array('error' => false, 'messages' => array(), 'content' => '');
25
+ $params = Mage::helper('core')->jsonDecode($this->getRequest()->getParam('interactive_image', ''));
26
+
27
+ $fullImagePath = Mage::helper('auguria_interactiveimage')->getFullImagePath($params['image_path']);
28
+ $fullImageUrl = Mage::helper('auguria_interactiveimage')->getFullImageUrl($params['image_path']);
29
+
30
+ try {
31
+ if(file_exists($fullImagePath)){
32
+ $this->loadLayout(); // init layout messages
33
+
34
+ if(!is_array($params['areas'])){
35
+ $params['areas'] = Mage::helper('core')->jsonDecode($params['areas']);
36
+ }
37
+
38
+ $params['image_url'] = $fullImageUrl; // add full image path to params
39
+ $response['content'] = $this->getLayout()->getBlock('interactive.image.popin')->setParams($params)->toHtml();
40
+ }else{
41
+ Mage::throwException($this->__('Image not found.'));
42
+ }
43
+ } catch (Exception $e) {
44
+ $response['error'] = true;
45
+ $this->_getSession()->addException($e, $this->__('Error while loading edition interface.'));
46
+ }
47
+
48
+ if($response['error']){
49
+ // if success messages called in template
50
+ $response['messages'][Mage_Core_Model_Message::ERROR] = $this->_getSession()->getMessages(true)->getItemsByType(Mage_Core_Model_Message::ERROR); // clear messages
51
+ }
52
+
53
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
54
+ }
55
+
56
+ /**
57
+ * Get Panel Tab html
58
+ */
59
+ public function createPanelTabAction()
60
+ {
61
+ $response = array('error' => false, 'messages' => array(), 'content' => '');
62
+ $area = Mage::helper('core')->jsonDecode($this->getRequest()->getParam('area', ''));
63
+
64
+ try {
65
+ if($area){
66
+ $this->loadLayout(); // init layout messages
67
+
68
+ $response['content'] = $this->getLayout()->getBlock('interactive.image.panel.areas')->getAreaHtml($area);
69
+ }else{
70
+ Mage::throwException($this->__('Area does not exixsts.'));
71
+ }
72
+ } catch (Exception $e) {
73
+ $response['error'] = true;
74
+ $this->_getSession()->addException($e, $this->__('Error while adding area.'));
75
+ }
76
+
77
+ if($response['error']){
78
+ // if success messages called in template
79
+ $response['messages'][Mage_Core_Model_Message::ERROR] = $this->_getSession()->getMessages(true)->getItemsByType(Mage_Core_Model_Message::ERROR); // clear messages
80
+ }
81
+
82
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
83
+ }
84
+
85
+ /**
86
+ * Save form values
87
+ */
88
+ public function saveAction()
89
+ {
90
+ $response = array('error' => false, 'messages' => array(), 'content' => '');
91
+ $areas = $this->getRequest()->getParam('areas', null);
92
+
93
+ try {
94
+ if($areas){
95
+ $response['content'] = Mage::helper('core')->jsonEncode($areas);
96
+ }else{
97
+ Mage::throwException($this->__('Areas does not exixsts.'));
98
+ }
99
+ } catch (Exception $e) {
100
+ $response['error'] = true;
101
+ $this->_getSession()->addException($e, $this->__('Error while saving areas.'));
102
+ }
103
+
104
+ if($response['error']){
105
+ // if success messages called in template
106
+ $response['messages'][Mage_Core_Model_Message::ERROR] = $this->_getSession()->getMessages(true)->getItemsByType(Mage_Core_Model_Message::ERROR); // clear messages
107
+ }
108
+
109
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
110
+ }
111
+ }
app/code/community/Auguria/InteractiveImage/controllers/Checkout/Cart/AjaxController.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Checkout_Cart_AjaxController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Retrieve shopping cart model object
13
+ *
14
+ * @return Mage_Checkout_Model_Cart
15
+ */
16
+ protected function _getCart()
17
+ {
18
+ return Mage::getSingleton('checkout/cart');
19
+ }
20
+
21
+ /**
22
+ * Get checkout session model instance
23
+ *
24
+ * @return Mage_Checkout_Model_Session
25
+ */
26
+ protected function _getSession()
27
+ {
28
+ return Mage::getSingleton('checkout/session');
29
+ }
30
+
31
+ /**
32
+ * Set back redirect url to response
33
+ *
34
+ * @return Mage_Checkout_CartController
35
+ */
36
+ protected function _goBack()
37
+ {
38
+ $returnUrl = $this->getRequest()->getParam('return_url');
39
+ if ($returnUrl) {
40
+
41
+ if (!$this->_isUrlInternal($returnUrl)) {
42
+ throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
43
+ }
44
+
45
+ $this->_getSession()->getMessages(true);
46
+ $this->getResponse()->setRedirect($returnUrl);
47
+ } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
48
+ && !$this->getRequest()->getParam('in_cart')
49
+ && $backUrl = $this->_getRefererUrl()
50
+ ) {
51
+ $this->getResponse()->setRedirect($backUrl);
52
+ } else {
53
+ if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
54
+ $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
55
+ }
56
+ $this->_redirect('checkout/cart');
57
+ }
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Initialize product instance from request data
63
+ *
64
+ * @param int $productId
65
+ * @return Mage_Catalog_Model_Product || false
66
+ */
67
+ protected function _initProduct($productId)
68
+ {
69
+ if ($productId) {
70
+ $product = Mage::getModel('catalog/product')
71
+ ->setStoreId(Mage::app()->getStore()->getId())
72
+ ->load($productId);
73
+ if ($product->getId()) {
74
+ return $product;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Add product to shopping cart action
82
+ */
83
+ public function addAction()
84
+ {
85
+ $cart = $this->_getCart();
86
+ $params = $this->getRequest()->getParams();
87
+
88
+ try {
89
+
90
+ foreach($params['products'] as $_child){
91
+
92
+ // get required params to add in cart
93
+ $_child['uenc'] = $params['uenc'];
94
+
95
+ if (isset($_child['qty'])) {
96
+ $filter = new Zend_Filter_LocalizedToNormalized(
97
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
98
+ );
99
+ $_child['qty'] = $filter->filter($_child['qty']);
100
+ }
101
+
102
+ if(!array_key_exists('qty', $_child) || $_child['qty'] == 0){
103
+ continue; // check qty
104
+ }
105
+
106
+ $product = $this->_initProduct($_child['product']);
107
+
108
+ /**
109
+ * Check product availability
110
+ */
111
+ if (!$product) {
112
+ $this->_goBack();
113
+ return;
114
+ }
115
+
116
+ $related = $this->getRequest()->getParam('related_product');
117
+
118
+ $cart->addProduct($product, $_child);
119
+ if (!empty($related)) {
120
+ $cart->addProductsByIds(explode(',', $related));
121
+ }
122
+ }
123
+
124
+ $cart->save();
125
+
126
+ $this->_getSession()->setCartWasUpdated(true);
127
+
128
+ /**
129
+ * @todo remove wishlist observer processAddToCart
130
+ */
131
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
132
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
133
+ );
134
+
135
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
136
+ if (!$cart->getQuote()->getHasError()){
137
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
138
+ $this->_getSession()->addSuccess($message);
139
+ }
140
+ $this->_goBack();
141
+ }
142
+ } catch (Mage_Core_Exception $e) {
143
+ if ($this->_getSession()->getUseNotice(true)) {
144
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
145
+ } else {
146
+ $messages = array_unique(explode("\n", $e->getMessage()));
147
+ foreach ($messages as $message) {
148
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
149
+ }
150
+ }
151
+
152
+ $url = $this->_getSession()->getRedirectUrl(true);
153
+ if ($url) {
154
+ $this->getResponse()->setRedirect($url);
155
+ } else {
156
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
157
+ }
158
+ } catch (Exception $e) {
159
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
160
+ Mage::logException($e);
161
+ $this->_goBack();
162
+ }
163
+ }
164
+ }
app/code/community/Auguria/InteractiveImage/controllers/Checkout/CartController.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_InteractiveImage_Checkout_CartController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Retrieve shopping cart model object
13
+ *
14
+ * @return Mage_Checkout_Model_Cart
15
+ */
16
+ protected function _getCart()
17
+ {
18
+ return Mage::getSingleton('checkout/cart');
19
+ }
20
+
21
+ /**
22
+ * Get checkout session model instance
23
+ *
24
+ * @return Mage_Checkout_Model_Session
25
+ */
26
+ protected function _getSession()
27
+ {
28
+ return Mage::getSingleton('checkout/session');
29
+ }
30
+
31
+ /**
32
+ * Set back redirect url to response
33
+ *
34
+ * @return Mage_Checkout_CartController
35
+ */
36
+ protected function _goBack()
37
+ {
38
+ $returnUrl = $this->getRequest()->getParam('return_url');
39
+ if ($returnUrl) {
40
+
41
+ if (!$this->_isUrlInternal($returnUrl)) {
42
+ throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
43
+ }
44
+
45
+ $this->_getSession()->getMessages(true);
46
+ $this->getResponse()->setRedirect($returnUrl);
47
+ } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
48
+ && !$this->getRequest()->getParam('in_cart')
49
+ && $backUrl = $this->_getRefererUrl()
50
+ ) {
51
+ $this->getResponse()->setRedirect($backUrl);
52
+ } else {
53
+ if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
54
+ $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
55
+ }
56
+ $this->_redirect('checkout/cart');
57
+ }
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Initialize product instance from request data
63
+ *
64
+ * @param int $productId
65
+ * @return Mage_Catalog_Model_Product || false
66
+ */
67
+ protected function _initProduct($productId)
68
+ {
69
+ if ($productId) {
70
+ $product = Mage::getModel('catalog/product')
71
+ ->setStoreId(Mage::app()->getStore()->getId())
72
+ ->load($productId);
73
+ if ($product->getId()) {
74
+ return $product;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Add product to shopping cart action
82
+ */
83
+ public function addAction()
84
+ {
85
+ $cart = $this->_getCart();
86
+ $params = $this->getRequest()->getParams();
87
+
88
+ try {
89
+
90
+ foreach($params['products'] as $_child){
91
+
92
+ // get required params to add in cart
93
+ $_child['uenc'] = $params['uenc'];
94
+
95
+ if (isset($_child['qty'])) {
96
+ $filter = new Zend_Filter_LocalizedToNormalized(
97
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
98
+ );
99
+ $_child['qty'] = $filter->filter($_child['qty']);
100
+ }
101
+
102
+ if(!array_key_exists('qty', $_child) || $_child['qty'] == 0){
103
+ continue; // check qty
104
+ }
105
+
106
+ $product = $this->_initProduct($_child['product']);
107
+
108
+ /**
109
+ * Check product availability
110
+ */
111
+ if (!$product) {
112
+ $this->_goBack();
113
+ return;
114
+ }
115
+
116
+ $related = $this->getRequest()->getParam('related_product');
117
+
118
+ $cart->addProduct($product, $_child);
119
+ if (!empty($related)) {
120
+ $cart->addProductsByIds(explode(',', $related));
121
+ }
122
+ }
123
+
124
+ $cart->save();
125
+
126
+ $this->_getSession()->setCartWasUpdated(true);
127
+
128
+ /**
129
+ * @todo remove wishlist observer processAddToCart
130
+ */
131
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
132
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
133
+ );
134
+
135
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
136
+ if (!$cart->getQuote()->getHasError()){
137
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
138
+ $this->_getSession()->addSuccess($message);
139
+ }
140
+ $this->_goBack();
141
+ }
142
+ } catch (Mage_Core_Exception $e) {
143
+ if ($this->_getSession()->getUseNotice(true)) {
144
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
145
+ } else {
146
+ $messages = array_unique(explode("\n", $e->getMessage()));
147
+ foreach ($messages as $message) {
148
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
149
+ }
150
+ }
151
+
152
+ $url = $this->_getSession()->getRedirectUrl(true);
153
+ if ($url) {
154
+ $this->getResponse()->setRedirect($url);
155
+ } else {
156
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
157
+ }
158
+ } catch (Exception $e) {
159
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
160
+ Mage::logException($e);
161
+ $this->_goBack();
162
+ }
163
+ }
164
+ }
app/code/community/Auguria/InteractiveImage/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_InteractiveImage
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <auguria_interactiveimage translate="title" module="auguria_interactiveimage">
20
+ <title>Auguria interactive image</title>
21
+ </auguria_interactiveimage>
22
+ </children>
23
+ </config>
24
+ </children>
25
+ </system>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/Auguria/InteractiveImage/etc/config.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_InteractiveImage
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+
12
+ <modules>
13
+ <Auguria_InteractiveImage>
14
+ <version>0.0.1</version>
15
+ </Auguria_InteractiveImage>
16
+ </modules>
17
+
18
+ <global>
19
+ <resources>
20
+ <auguria_interactiveimage_setup>
21
+ <setup>
22
+ <module>Auguria_InteractiveImage</module>
23
+ <class>Mage_Catalog_Model_Resource_Setup</class>
24
+ </setup>
25
+ </auguria_interactiveimage_setup>
26
+ </resources>
27
+ <blocks>
28
+ <auguria_interactiveimage>
29
+ <class>Auguria_InteractiveImage_Block</class>
30
+ </auguria_interactiveimage>
31
+ </blocks>
32
+ <helpers>
33
+ <auguria_interactiveimage>
34
+ <class>Auguria_InteractiveImage_Helper</class>
35
+ </auguria_interactiveimage>
36
+ </helpers>
37
+ <models>
38
+ <auguria_interactiveimage>
39
+ <class>Auguria_InteractiveImage_Model</class>
40
+ </auguria_interactiveimage>
41
+ </models>
42
+ </global>
43
+
44
+ <frontend>
45
+ <routers>
46
+ <auguria_interactiveimage>
47
+ <use>standard</use>
48
+ <args>
49
+ <module>Auguria_InteractiveImage</module>
50
+ <frontName>image</frontName>
51
+ </args>
52
+ </auguria_interactiveimage>
53
+ </routers>
54
+ <layout>
55
+ <updates>
56
+ <auguria_interactiveimage>
57
+ <file>auguria/interactive_image.xml</file>
58
+ </auguria_interactiveimage>
59
+ </updates>
60
+ </layout>
61
+ <translate>
62
+ <modules>
63
+ <Auguria_InteractiveImage>
64
+ <files>
65
+ <default>Auguria_InteractiveImage.csv</default>
66
+ </files>
67
+ </Auguria_InteractiveImage>
68
+ </modules>
69
+ </translate>
70
+ </frontend>
71
+
72
+ <admin>
73
+ <routers>
74
+ <adminhtml>
75
+ <args>
76
+ <modules>
77
+ <auguria_interactiveimage before="Mage_Adminhtml">Auguria_InteractiveImage_Adminhtml</auguria_interactiveimage>
78
+ </modules>
79
+ </args>
80
+ </adminhtml>
81
+ </routers>
82
+ </admin>
83
+
84
+ <adminhtml>
85
+ <layout>
86
+ <updates>
87
+ <auguria_interactiveimage>
88
+ <file>auguria/interactive_image.xml</file>
89
+ </auguria_interactiveimage>
90
+ </updates>
91
+ </layout>
92
+ <translate>
93
+ <modules>
94
+ <Auguria_InteractiveImage>
95
+ <files>
96
+ <default>Auguria_InteractiveImage.csv</default>
97
+ </files>
98
+ </Auguria_InteractiveImage>
99
+ </modules>
100
+ </translate>
101
+ </adminhtml>
102
+
103
+ <default>
104
+ <auguria_interactiveimage>
105
+ <general>
106
+ <use_ajax>0</use_ajax>
107
+ </general>
108
+ </auguria_interactiveimage>
109
+ </default>
110
+
111
+ </config>
app/code/community/Auguria/InteractiveImage/etc/jstranslator.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_InteractiveImage
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <jstranslator>
11
+ <alert-display-image-url-undefined translate="message" module="auguria_interactiveimage">
12
+ <message>Complete</message>
13
+ </alert-display-image-url-undefined>
14
+ </jstranslator>
app/code/community/Auguria/InteractiveImage/etc/system.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <auguria_interactiveimage translate="label" module="auguria_interactiveimage">
12
+ <label>Interactive image</label>
13
+ <tab>auguria</tab>
14
+ <header_css>auguria-header</header_css>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>300</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>General</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ <fields>
29
+ <use_ajax translate="label comment">
30
+ <label>Use ajax for adding product to cart</label>
31
+ <comment>Module Auguria_CartAjax must be enabled</comment>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ <if_module_enabled>Auguria_CartAjax</if_module_enabled>
39
+ </use_ajax>
40
+ </fields>
41
+ </general>
42
+ </groups>
43
+ </auguria_interactiveimage>
44
+ </sections>
45
+ </config>
app/code/community/Auguria/InteractiveImage/sql/auguria_interactiveimage_setup/install-0.0.1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Mage_Catalog_Model_Resource_Setup */
10
+
11
+ // Create new attribute group ( render attribute element correctly )
12
+ $entityTypeId = $this->getEntityTypeId('catalog_product');
13
+
14
+ // add group for each existing attribute set
15
+ $attributeSets = $this->_conn->fetchAll('select * from '.$this->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
16
+ foreach ($attributeSets as $attributeSet) {
17
+ $setId = $attributeSet['attribute_set_id'];
18
+ $this->addAttributeGroup($entityTypeId, $setId, 'Interactive image');
19
+ }
20
+
21
+ // auguria_matrix_active : define if the matrix can be displayed on the product view page
22
+ $this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'auguria_interactiveimage_image', array(
23
+ 'group' => 'Interactive image',
24
+ 'type' => 'text',
25
+ 'backend' => 'auguria_interactiveimage/catalog_product_attribute_backend_image',
26
+ 'frontend' => '',
27
+ 'label' => 'Interactive image',
28
+ 'input' => 'image',
29
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
30
+ 'visible' => true,
31
+ 'required' => false,
32
+ 'user_defined' => false,
33
+ 'default' => '',
34
+ 'input_renderer' => 'auguria_interactiveimage/adminhtml_catalog_product_helper_form_image_interactive',
35
+ 'visible_on_front' => false,
36
+ 'used_in_product_listing' => true
37
+ ));
app/design/adminhtml/default/default/layout/auguria/interactive_image.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_InteractiveImage
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+
11
+ <layout>
12
+
13
+ <adminhtml_catalog_product_edit>
14
+ <reference name="head">
15
+ <action method="addJs"><link>auguria/interactiveimage/kinetic-v4.5.4.min.js</link></action>
16
+ <action method="addJs"><link>auguria/interactiveimage/image.js</link></action>
17
+ <action method="addCss"><link>auguria/interactiveimage/image.css</link></action>
18
+ </reference>
19
+ </adminhtml_catalog_product_edit>
20
+
21
+ <adminhtml_auguria_interactiveimage_image_display>
22
+ <reference name="content">
23
+ <block type="auguria_interactiveimage/adminhtml_catalog_product_helper_form_image_interactive_popin" name="interactive.image.popin" template="auguria/interactiveimage/catalog/product/helper/form/image/interactive/popin.phtml">
24
+ <block type="auguria_interactiveimage/adminhtml_catalog_product_helper_form_image_interactive_panel_areas" name="interactive.image.panel.areas" template="auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/areas.phtml">
25
+ </block>
26
+ </block>
27
+ </reference>
28
+ </adminhtml_auguria_interactiveimage_image_display>
29
+
30
+ <adminhtml_auguria_interactiveimage_image_createpaneltab>
31
+ <block type="auguria_interactiveimage/adminhtml_catalog_product_helper_form_image_interactive_panel_areas" name="interactive.image.panel.areas" template="auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/areas.phtml">
32
+ </block>
33
+ </adminhtml_auguria_interactiveimage_image_createpaneltab>
34
+
35
+ </layout>
app/design/adminhtml/default/default/template/auguria/interactiveimage/catalog/product/helper/form/image/interactive/panel/area/default.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_InteractiveImage
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Auguria_InteractiveImage_Block_Adminhtml_Catalog_Product_Helper_Form_Image_Interactive_Panel_Area_Default */
10
+ ?>
11
+ <?php
12
+ $area = $this->getInteractiveArea();
13
+ ?>
14
+
15
+ <fieldset id="fieldset-<?php echo $area['id']?>" class="area">
16
+ <input type="hidden" name="areas[<?php echo $area['id']?>][id]" value="<?php echo $area['id']?>">
17
+ <input type="hidden" name="areas[<?php echo $area['id']?>][size][x]" value="<?php echo $area['size']['x']?>">
18
+ <input type="hidden" name="areas[<?php echo $area['id']?>][size][y]" value="<?php echo $area['size']['y']?>">
19
+ <input type="hidden" name="areas[<?php echo $area['id']?>][size][width]" value="<?php echo $area['size']['width']?>">
20
+ <input type="hidden" name="areas[<?php echo $area['id']?>][size][height]" value="<?php echo $area['size']['height']?>">
21
+ <input type="hidden" name="areas[<?php echo $area['id']?>][type]" value="<?php echo $area['type']?>">
22
+ <input type="hidden" name="areas[<?php echo $area['id']?>][color]" value="<?php echo $area['color']?>">
23
+ <input type="hidden" name="areas[<?php echo $area['id']?>][render]" value="<?php echo $area['render']?>">
24
+ <label>
25
+ <?php echo $this->__('Position')?>
26
+ <input type="text" name="areas[<?php echo $area['id']?>][position]" value="<?php echo isset($area['position']) ? $area['position'] : '' ?>">
27
+ </label>
28
+ <label>
29
+ <?php echo $this->__('Product Sku')?>
30
+ <input type="text" name="areas[<?php echo $area['id']?>][sku]" value="<?php echo isset($area['sku']) ? $area['sku'] : '' ?>">
31
+ </label>
32
+ <label>
33
+ <?php $value = isset($area['hilight_area']) ? $area['hilight_area'] : '0' ?>
34
+
35
+ <?php echo $this->__('Hilight area on frontend')?>
36
+ <select name="areas[<?php echo $area['id']?>][hilight_area]">
37
+ <option value="0" <?php echo $value == '0' ? 'selected="selected"' : ''?>><?php echo $this->__('No')?></option>
38
+ <option value="1" <?php echo $value == '1' ? 'selected="selected"' : ''?>><?php echo $this->__('Yes')?></option>
39
+ </select>
40
+ </label>
41
+
42