AJAX_ZOOM - Version 1.0.0

Version Notes

Add zoom & pan functionality to your high resolution product images without flash.

Download this release

Release Info

Developer AJAX-ZOOM
Extension AJAX_ZOOM
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (50) hide show
  1. app/code/local/Ax/Zoom/Block/Adminhtml/System/Config/Fieldset/License.php +65 -0
  2. app/code/local/Ax/Zoom/Block/Adminhtml/Tabs.php +27 -0
  3. app/code/local/Ax/Zoom/Block/Adminhtml/Tabs/Tabid.php +35 -0
  4. app/code/local/Ax/Zoom/Helper/Data.php +4 -0
  5. app/code/local/Ax/Zoom/Helper/Head.php +34 -0
  6. app/code/local/Ax/Zoom/Model/Ax360.php +210 -0
  7. app/code/local/Ax/Zoom/Model/Ax360set.php +39 -0
  8. app/code/local/Ax/Zoom/Model/Axproducts.php +9 -0
  9. app/code/local/Ax/Zoom/Model/Observer.php +91 -0
  10. app/code/local/Ax/Zoom/Model/Position.php +14 -0
  11. app/code/local/Ax/Zoom/Model/Resource/Ax360.php +8 -0
  12. app/code/local/Ax/Zoom/Model/Resource/Ax360/Collection.php +9 -0
  13. app/code/local/Ax/Zoom/Model/Resource/Ax360set.php +8 -0
  14. app/code/local/Ax/Zoom/Model/Resource/Ax360set/Collection.php +9 -0
  15. app/code/local/Ax/Zoom/Model/Resource/Axproducts.php +8 -0
  16. app/code/local/Ax/Zoom/Model/Resource/Axproducts/Collection.php +9 -0
  17. app/code/local/Ax/Zoom/Model/Words.php +14 -0
  18. app/code/local/Ax/Zoom/Model/Yesno.php +12 -0
  19. app/code/local/Ax/Zoom/controllers/IndexController.php +387 -0
  20. app/code/local/Ax/Zoom/etc/config.xml +349 -0
  21. app/code/local/Ax/Zoom/etc/system.xml +1148 -0
  22. app/code/local/Ax/Zoom/sql/axzoom_setup/install-0.0.1.php +33 -0
  23. app/design/adminhtml/default/default/layout/axzoom.xml +25 -0
  24. app/design/adminhtml/default/default/template/axzoom/tab.phtml +38 -0
  25. app/design/adminhtml/default/default/template/axzoom/tab360-sets.phtml +323 -0
  26. app/design/adminhtml/default/default/template/axzoom/tab360-settings.phtml +280 -0
  27. app/design/adminhtml/default/default/template/axzoom/tab360.phtml +135 -0
  28. app/design/adminhtml/default/default/template/axzoom/uploader.phtml +179 -0
  29. app/design/frontend/default/default/layout/axzoom.xml +59 -0
  30. app/design/frontend/rwd/default/layout/axzoom.xml +65 -0
  31. app/design/frontend/rwd/default/template/ax_zoom/catalog/product/view/media.phtml +423 -0
  32. app/etc/modules/Ax_Zoom.xml +9 -0
  33. app/locale/ru_RU/Ax_Zoom.csv +150 -0
  34. js/axzoom/.htaccess +1 -0
  35. js/axzoom/check_jquery.js +4 -0
  36. js/axzoom/image_path.gif +0 -0
  37. js/axzoom/jquery-1.11.0.min.js +6 -0
  38. js/axzoom/jquery-migrate-1.2.1.min.js +2 -0
  39. js/axzoom/jquery.fileupload-process.js +164 -0
  40. js/axzoom/jquery.fileupload-validate.js +117 -0
  41. js/axzoom/jquery.fileupload.js +1368 -0
  42. js/axzoom/jquery.ui.widget.min.js +4 -0
  43. js/axzoom/lic.php +30 -0
  44. js/axzoom/no_image-100x100.jpg +0 -0
  45. js/axzoom/pic/readme.txt +1 -0
  46. js/axzoom/preview/index.php +11 -0
  47. js/axzoom/preview/preview.php +273 -0
  48. js/axzoom/tmp/readme.txt +1 -0
  49. js/axzoom/zip/readme.txt +1 -0
  50. package.xml +25 -0
app/code/local/Ax/Zoom/Block/Adminhtml/System/Config/Fieldset/License.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Block_Adminhtml_System_Config_Fieldset_License extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
3
+ {
4
+ public function _prepareToRender()
5
+ {
6
+ $this->addColumn('domain', array(
7
+ 'label' => Mage::helper('axzoom')->__('Domain'),
8
+ 'style' => 'width:100px',
9
+ ));
10
+ $this->addColumn('type', array(
11
+ 'label' => Mage::helper('axzoom')->__('License Type'),
12
+ 'style' => 'width:100px',
13
+ 'renderer' => 'bla'
14
+ ));
15
+
16
+ $this->addColumn('license', array(
17
+ 'label' => Mage::helper('axzoom')->__('License Key'),
18
+ 'style' => 'width:100px',
19
+ ));
20
+
21
+ $this->addColumn('error200', array(
22
+ 'label' => Mage::helper('axzoom')->__('Error200'),
23
+ 'style' => 'width:100px',
24
+ ));
25
+
26
+ $this->addColumn('error300', array(
27
+ 'label' => Mage::helper('axzoom')->__('Error300'),
28
+ 'style' => 'width:100px',
29
+ ));
30
+
31
+ $this->_addAfter = false;
32
+ $this->_addButtonLabel = Mage::helper('axzoom')->__('Add');
33
+ }
34
+
35
+ protected function _renderCellTemplate($columnName)
36
+ {
37
+ if ($columnName == 'type') {
38
+ $el = $this->getElement();
39
+
40
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
41
+ $rendered = '<select id="licType" name="' . $inputName . '">';
42
+ $rendered .= '<option value="evaluation" #{option_extra_attr_evaluation}>evaluation</option>';
43
+ $rendered .= '<option value="developer" #{option_extra_attr_developer}>developer</option>';
44
+ $rendered .= '<option value="basic" #{option_extra_attr_basic}>basic</option>';
45
+ $rendered .= '<option value="standard" #{option_extra_attr_standard}>standard</option>';
46
+ $rendered .= '<option value="business" #{option_extra_attr_business}>business</option>';
47
+ $rendered .= '<option value="corporate" #{option_extra_attr_corporate}>corporate</option>';
48
+ $rendered .= '<option value="enterprise" #{option_extra_attr_enterprise}>enterprise</option>';
49
+ $rendered .= '<option value="unlimited" #{option_extra_attr_unlimited}>unlimited</option>';
50
+ $rendered .= '</select>';
51
+
52
+ return $rendered;
53
+ }
54
+ return parent::_renderCellTemplate($columnName);
55
+ }
56
+
57
+ protected function _prepareArrayRow(Varien_Object $row)
58
+ {
59
+ $row->setData(
60
+ 'option_extra_attr_' . $row->getData('type'),
61
+ 'selected="selected"'
62
+ );
63
+ }
64
+ }
65
+ ?>
app/code/local/Ax/Zoom/Block/Adminhtml/Tabs.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ax_Zoom_Block_Adminhtml_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
4
+ {
5
+ private $parent;
6
+
7
+ protected function _prepareLayout()
8
+ {
9
+
10
+ $productId = Mage::app()->getRequest()->getParam('id');
11
+
12
+ //get all existing tabs
13
+ $this->parent = parent::_prepareLayout();
14
+
15
+ if (!empty($productId)) {
16
+ //add new tab
17
+ $this->addTab(
18
+ 'tabid', array(
19
+ 'label' => Mage::helper('catalog')->__('AJAX ZOOM'),
20
+ 'content' => $this->getLayout()
21
+ ->createBlock('zoom/adminhtml_tabs_tabid')->toHtml(),
22
+ ));
23
+ }
24
+
25
+ return $this->parent;
26
+ }
27
+ }
app/code/local/Ax/Zoom/Block/Adminhtml/Tabs/Tabid.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ax_Zoom_Block_Adminhtml_Tabs_Tabid extends Mage_Adminhtml_Block_Widget
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $productId = Mage::app()->getRequest()->getParam('id');
10
+
11
+ if (!empty($productId)) {
12
+ $this->assign(array(
13
+ 'files' => $this->getArcList()
14
+ ));
15
+ $this->setTemplate('axzoom/tab.phtml');
16
+ }
17
+ }
18
+
19
+ public function getArcList() {
20
+
21
+ $baseDir = Mage::getBaseDir();
22
+ $files = array();
23
+
24
+ if ($handle = opendir($baseDir . '/js/axzoom/zip/')) {
25
+ while (false !== ($entry = readdir($handle))) {
26
+ if ($entry != '.' && $entry != '..' && strtolower(substr($entry, -3)) == 'zip') {
27
+ array_push($files, $entry);
28
+ }
29
+ }
30
+ closedir($handle);
31
+ }
32
+
33
+ return $files;
34
+ }
35
+ }
app/code/local/Ax/Zoom/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Ax/Zoom/Helper/Head.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Helper_Head extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getFancyboxCSS()
5
+ {
6
+ if (Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancyboxFullscreen' || Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancybox') {
7
+ return 'axzoom/axZm/plugins/demo/jquery.fancybox/jquery.fancybox-1.3.4.css';
8
+ }
9
+ }
10
+ public function getFancyboxJS()
11
+ {
12
+ if (Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancyboxFullscreen' || Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancybox') {
13
+ return 'axzoom/axZm/plugins/demo/jquery.fancybox/jquery.fancybox-1.3.4.pack.js';
14
+ }
15
+ }
16
+ public function getFancyboxJSAX()
17
+ {
18
+ if (Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancyboxFullscreen' || Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'fancybox') {
19
+ return 'axzoom/axZm/extensions/jquery.axZm.openAjaxZoomInFancyBox.js';
20
+ }
21
+ }
22
+ public function getColorboxCSS()
23
+ {
24
+ if (Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'colorbox') {
25
+ return 'axzoom/axZm/plugins/demo/colorbox/example2/colorbox.css';
26
+ }
27
+ }
28
+ public function getColorboxJS()
29
+ {
30
+ if (Mage::getStoreConfig('axzoom_options/main/ajaxZoomOpenMode') == 'colorbox') {
31
+ return 'axzoom/axZm/plugins/demo/colorbox/jquery.colorbox-min.js';
32
+ }
33
+ }
34
+ }
app/code/local/Ax/Zoom/Model/Ax360.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Ax360 extends Mage_Core_Model_Abstract
3
+ {
4
+ static $axZmH;
5
+ static $zoom;
6
+
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('axzoom/ax360');
11
+ }
12
+
13
+ public function getSetsGroups($productId)
14
+ {
15
+ $tblItems = Mage::getSingleton('core/resource')->getTableName('ajaxzoom360set');
16
+ $collection = Mage::getModel('axzoom/ax360')->getCollection();
17
+ $collection->getSelect()->join(array('i' => $tblItems),
18
+ 'main_table.id_360 = i.id_360',
19
+ array('qty' => 'COUNT(i.id_360)', 'id_360set' => 'id_360set'));
20
+
21
+ $collection->getSelect()->group('main_table.id_360');
22
+ return $collection->addFieldToFilter('id_product', $productId)->getData();
23
+ }
24
+
25
+ public function getSetsGroup($id360)
26
+ {
27
+ $tblItems = Mage::getSingleton('core/resource')->getTableName('ajaxzoom360set');
28
+ $collection = Mage::getModel('axzoom/ax360')->getCollection();
29
+ $collection->getSelect()->join(array('i' => $tblItems),
30
+ 'main_table.id_360 = i.id_360',
31
+ array('qty' => 'COUNT(i.id_360)', 'id_360set' => 'id_360set'));
32
+
33
+ $collection->getSelect()->group('main_table.id_360');
34
+ return $collection->addFieldToFilter('main_table.id_360', $id360)->getData();
35
+ }
36
+
37
+ public function images360Json($productId, $extraGroups = array())
38
+ {
39
+
40
+ $extraGroups = array_unique($extraGroups);
41
+
42
+ $json = '{';
43
+ $cnt = 1;
44
+
45
+ if (!is_array($productId)) {
46
+ $products = array($productId);
47
+ } else {
48
+ $products = $productId;
49
+ }
50
+
51
+ foreach ($products as $productId) {
52
+ $setsGroups = $this->getSetsGroups($productId);
53
+ foreach ($setsGroups as $group) {
54
+
55
+ if ($group['status'] == 0)
56
+ continue;
57
+
58
+ $settings = $this->prepareSettings($group['settings']);
59
+ if (!empty($settings)) $settings = ", $settings";
60
+
61
+ if ($group['qty'] > 0) {
62
+ if ($group['qty'] == 1) {
63
+ $json .= "'" . $group['id_360'] . "'" . ": {'path': '" . $this->rootFolder() . "js/axzoom/pic/360/" . $productId . "/" . $group['id_360'] . "/" . $group['id_360set'] . "'" . $settings . ", 'combinations': [" . $group['combinations'] . "]}";
64
+ } else {
65
+ $json .= "'" . $group['id_360'] . "'" . ": {'path': '" . $this->rootFolder() . "js/axzoom/pic/360/" . $productId . "/" . $group['id_360'] . "'" . $settings . ", 'combinations': [" . $group['combinations'] . "]}";
66
+ }
67
+ $cnt++;
68
+ if ($cnt != count($setsGroups)+1) $json .= ',';
69
+ }
70
+ }
71
+ }
72
+
73
+ $cnt = 1;
74
+ if ($extraGroups) foreach ($extraGroups as $id360) {
75
+
76
+ $setsGroup = $this->getSetsGroup($id360);
77
+ $group = $setsGroup[0];
78
+
79
+ if ($group['status'] == 0)
80
+ continue;
81
+
82
+ $settings = $this->prepareSettings($group['settings']);
83
+ if (!empty($settings)) $settings = ", $settings";
84
+
85
+ if ($group['qty'] > 0) {
86
+ if ($group['qty'] == 1) {
87
+ $json .= "'" . $group['id_360'] . "'" . ": {'path': '" . $this->rootFolder() . "js/axzoom/pic/360/" . $group['id_product'] . "/" . $group['id_360'] . "/" . $group['id_360set'] . "'" . $settings . ", 'combinations': [" . $group['combinations'] . "]}";
88
+ } else {
89
+ $json .= "'" . $group['id_360'] . "'" . ": {'path': '" . $this->rootFolder() . "js/axzoom/pic/360/" . $group['id_product'] . "/" . $group['id_360'] . "'" . $settings . ", 'combinations': [" . $group['combinations'] . "]}";
90
+ }
91
+ $cnt++;
92
+ if ($cnt != count($extraGroups)+1) $json .= ',';
93
+ }
94
+
95
+ }
96
+
97
+ $json .= '}';
98
+
99
+ return $json;
100
+ }
101
+
102
+ public function prepareSettings($str)
103
+ {
104
+ $res = array();
105
+ $settings = (array)Mage::helper('core')->jsonDecode($str);
106
+ foreach ($settings as $key => $value) {
107
+ if ($value == 'false' || $value == 'true' || $value == 'null' || is_numeric($value) || substr($value, 0, 1) == '{' || substr($value, 0, 1) == '[') {
108
+ $res[] = "'$key': $value";
109
+ } else {
110
+ $res[] = "'$key': '$value'";
111
+ }
112
+ }
113
+ return implode(', ', $res);
114
+ }
115
+
116
+ public function get360Images($productId, $id360set = '')
117
+ {
118
+ $files = array();
119
+ $id360 = Mage::getModel('axzoom/ax360set')->load($id360set)->getId_360();
120
+
121
+ $dir = Mage::getBaseDir() . '/js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set;
122
+ if (file_exists($dir) && $handle = opendir($dir)) {
123
+ while (false !== ($entry = readdir($handle))) {
124
+ if ($entry != "." && $entry != "..") {
125
+ $files[] = $entry;
126
+ }
127
+ }
128
+ closedir($handle);
129
+ }
130
+ sort($files);
131
+
132
+ $res = array();
133
+ foreach ($files as $entry) {
134
+ $tmp = explode('.', $entry);
135
+ $ext = end($tmp);
136
+ $name = preg_replace('|\.' . $ext . '$|', '', $entry);
137
+ $res[] = array(
138
+ 'thumb' => Mage::getBaseUrl('js') . 'axzoom/axZm/zoomLoad.php?azImg=' . $this->rootFolder() . 'js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set . '/' . $entry . '&width=100&height=100&qual=90',
139
+ 'filename' => $entry,
140
+ 'id' => $name,
141
+ 'ext' => $ext
142
+ );
143
+ }
144
+
145
+ return $res;
146
+ }
147
+
148
+ public function deleteImageAZcache($file)
149
+ {
150
+
151
+ // Include all classes
152
+ include_once (Mage::getBaseDir() . '/js/axzoom/axZm/zoomInc.inc.php');
153
+ //error_reporting(E_ALL);
154
+ if (!Ax_Zoom_Model_Ax360::$axZmH){
155
+ Ax_Zoom_Model_Ax360::$axZmH = $axZmH;
156
+ Ax_Zoom_Model_Ax360::$zoom = $zoom;
157
+ }
158
+
159
+ // What to delete
160
+ $arrDel = array('In' => true, 'Th' => true, 'tC' => true, 'mO' => true, 'Ti' => true);
161
+
162
+ // Remove all cache
163
+ Ax_Zoom_Model_Ax360::$axZmH->removeAxZm(Ax_Zoom_Model_Ax360::$zoom, $file, $arrDel, false);
164
+ }
165
+
166
+ public function rootFolder()
167
+ {
168
+ $p = parse_url(Mage::getBaseUrl());
169
+ return str_replace('index.php/', '', $p['path']);
170
+ }
171
+
172
+ public function isProductActive($productId)
173
+ {
174
+ return !Mage::getModel('axzoom/axproducts')->getCollection()->addFieldToFilter('id_product', $productId)->count();
175
+ }
176
+
177
+ public function getCSV($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
178
+ {
179
+ if (function_exists('str_getcsv')) {
180
+ return str_getcsv($input, $delimiter, $enclosure, $escape);
181
+ }
182
+ else {
183
+ $temp = fopen('php://memory', 'rw');
184
+ fwrite($temp, $input);
185
+ fseek($temp, 0);
186
+ $r = fgetcsv($temp, 0, $delimiter, $enclosure);
187
+ fclose($temp);
188
+ return $r;
189
+ }
190
+ }
191
+
192
+ public function isOnlyProductActive($productId)
193
+ {
194
+
195
+ $products = Mage::getStoreConfig('axzoom_options/products/displayOnlyForThisProductID');
196
+
197
+ if (empty($products)) {
198
+ return true;
199
+ }
200
+
201
+ $arr = $this->getCSV($products);
202
+ if (in_array($productId, $arr)) {
203
+ return true;
204
+ }
205
+ return false;
206
+ }
207
+ }
208
+
209
+ Ax_Zoom_Model_Ax360::$axZmH;
210
+ Ax_Zoom_Model_Ax360::$zoom;
app/code/local/Ax/Zoom/Model/Ax360set.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Ax360set extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('axzoom/ax360set');
8
+ }
9
+
10
+ public function getSets($productId)
11
+ {
12
+
13
+ $model = Mage::getModel('axzoom/ax360set');
14
+ $setsCollection = $model->getCollection();
15
+
16
+ $tbl_set_group = Mage::getSingleton('core/resource')->getTableName('ajaxzoom360');
17
+ $setsCollection->getSelect()->join(array('t2' => $tbl_set_group), 'main_table.id_360 = t2.id_360 AND t2.id_product = ' . $productId, array('t2.name', 't2.status'));
18
+ $sets = $setsCollection->getData();
19
+
20
+ $baseDir = Mage::getBaseDir();
21
+ $baseUrlJs = Mage::getBaseUrl('js');
22
+
23
+ foreach ($sets as &$set) {
24
+ if (file_exists($baseDir . '/js/axzoom/pic/360/' . $productId . '/' . $set['id_360'] . '/' . $set['id_360set'])) {
25
+ $set['path'] = $baseUrlJs . 'axzoom/axZm/zoomLoad.php?qq=1&azImg360=' . $this->rootFolder() . 'js/axzoom/pic/360/' . $productId . '/' . $set['id_360'] . '/' . $set['id_360set'] . '&width=100&height=100&thumbMode=contain';
26
+ } else {
27
+ $set['path'] = $baseUrlJs . 'axzoom/no_image-100x100.jpg';
28
+ }
29
+ }
30
+
31
+ return $sets;
32
+ }
33
+
34
+ public function rootFolder()
35
+ {
36
+ $p = parse_url(Mage::getBaseUrl());
37
+ return str_replace('index.php/', '', $p['path']);
38
+ }
39
+ }
app/code/local/Ax/Zoom/Model/Axproducts.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Axproducts extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('axzoom/axproducts');
8
+ }
9
+ }
app/code/local/Ax/Zoom/Model/Observer.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Observer {
3
+ public function coreBlockBefore($observer)
4
+ {
5
+
6
+ if ($observer->getBlock() instanceof Mage_Catalog_Block_Product_View_Media) {
7
+
8
+ // if AJAX ZOOM is enabled for exact product then replace the product/view/media block
9
+ $productId = Mage::app()->getRequest()->getParam('id');
10
+
11
+ $ax = Mage::getModel('axzoom/ax360');
12
+ $active = $ax->isProductActive($productId);
13
+
14
+ if($active && $ax->isOnlyProductActive($productId)) {
15
+ $observer->getBlock()->setTemplate('ax_zoom/catalog/product/view/media.phtml');
16
+ }
17
+ }
18
+ }
19
+
20
+
21
+ public function productBefore($observer)
22
+ {
23
+ }
24
+
25
+ public function productSaveBefore($observer)
26
+ {
27
+ }
28
+
29
+ public function productSaveAfter($observer)
30
+ {
31
+ }
32
+
33
+ public function deleteProduct($observer)
34
+ {
35
+ $product = $observer->getProduct();
36
+ $model = Mage::getModel('axzoom/ax360');
37
+ $sets = Mage::getModel('axzoom/ax360set')->getSets($product->entity_id);
38
+
39
+ // clear AZ cache
40
+ foreach ($sets as $set) {
41
+ $images = $model->get360Images($product->entity_id, $set['id_360set']);
42
+
43
+ foreach ($images as $image) {
44
+ $model->deleteImageAZcache($image['filename']);
45
+ }
46
+ }
47
+
48
+ if ($images = $product->getMediaGalleryImages()) foreach ($images as $image) {
49
+ $model->deleteImageAZcache(basename($image->getFile()));
50
+ }
51
+ }
52
+
53
+ public function save360($observer)
54
+ {
55
+ $productId = $observer->product->entity_id;
56
+ $postData = Mage::app()->getRequest()->getPost();
57
+
58
+ // remove images from Ax cache if image checked as remove
59
+ $images = Mage::helper('core')->jsonDecode($postData['product']['media_gallery']['images']);
60
+ foreach ($images as $image) {
61
+ if(isset($image['removed']) && $image['removed'] == 1) {
62
+ Mage::getModel('axzoom/ax360')->deleteImageAZcache(basename($image['file']));
63
+ }
64
+ }
65
+
66
+ // save status
67
+ if (isset($postData['az_active']) && $postData['az_active'] == 1) {
68
+ $this->activateAx($productId);
69
+ } else {
70
+ Mage::getModel('axzoom/axproducts')->setData(array('id_product' => $productId))->save();
71
+ }
72
+
73
+ // save settings
74
+ if(isset($postData['settings'])) foreach ($postData['settings'] as $id_360 => $string) {
75
+
76
+ Mage::getModel('axzoom/ax360')->load($id_360)->addData(array(
77
+ 'settings' => urldecode($string),
78
+ 'combinations' => urldecode($postData['comb'][$id_360])
79
+ ))->setId($id_360)->save();
80
+ }
81
+ }
82
+
83
+ public function activateAx($productId)
84
+ {
85
+ $res = Mage::getSingleton('core/resource');
86
+ $con = $res->getConnection('core_write');
87
+ $table = $res->getTableName('axzoom/table_axproducts');
88
+ $query = "DELETE FROM {$table} WHERE id_product = " . (int)$productId;
89
+ $con->query($query);
90
+ }
91
+ }
app/code/local/Ax/Zoom/Model/Position.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Position
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'inside', 'label'=>Mage::helper('axzoom')->__('inside')),
8
+ array('value'=>'top', 'label'=>Mage::helper('axzoom')->__('top')),
9
+ array('value'=>'right', 'label'=>Mage::helper('axzoom')->__('right')),
10
+ array('value'=>'bottom', 'label'=>Mage::helper('axzoom')->__('bottom')),
11
+ array('value'=>'left', 'label'=>Mage::helper('axzoom')->__('left'))
12
+ );
13
+ }
14
+ }
app/code/local/Ax/Zoom/Model/Resource/Ax360.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Ax360 extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('axzoom/table_ax360', 'id_360');
7
+ }
8
+ }
app/code/local/Ax/Zoom/Model/Resource/Ax360/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Ax360_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('axzoom/ax360');
8
+ }
9
+ }
app/code/local/Ax/Zoom/Model/Resource/Ax360set.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Ax360set extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('axzoom/table_ax360set', 'id_360set');
7
+ }
8
+ }
app/code/local/Ax/Zoom/Model/Resource/Ax360set/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Ax360set_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('axzoom/ax360set');
8
+ }
9
+ }
app/code/local/Ax/Zoom/Model/Resource/Axproducts.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Axproducts extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('axzoom/table_axproducts', null);
7
+ }
8
+ }
app/code/local/Ax/Zoom/Model/Resource/Axproducts/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Resource_Axproducts_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('axzoom/axproducts');
8
+ }
9
+ }
app/code/local/Ax/Zoom/Model/Words.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Words
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>1, 'label'=>Mage::helper('axzoom')->__('Hello')),
8
+ array('value'=>2, 'label'=>Mage::helper('axzoom')->__('Goodbye')),
9
+ array('value'=>3, 'label'=>Mage::helper('axzoom')->__('Yes')),
10
+ array('value'=>4, 'label'=>Mage::helper('axzoom')->__('No')),
11
+ );
12
+ }
13
+
14
+ }
app/code/local/Ax/Zoom/Model/Yesno.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_Model_Yesno
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>0, 'label'=>Mage::helper('axzoom')->__('No')),
8
+ array('value'=>1, 'label'=>Mage::helper('axzoom')->__('Yes'))
9
+ );
10
+ }
11
+
12
+ }
app/code/local/Ax/Zoom/controllers/IndexController.php ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ax_Zoom_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function AddProductImage360Action()
5
+ {
6
+
7
+ $productId = Mage::app()->getRequest()->getParam('id_product');
8
+ $id360set = $this->getRequest()->getPost('id_360set');
9
+ $id360 = Mage::getModel('axzoom/ax360set')->load($id360set)->getId_360();
10
+ $folder = $this->createProduct360Folder($productId, $id360set);
11
+
12
+ if (isset($_FILES['file360']['name'][0]) && $_FILES['file360']['name'][0] != '') {
13
+ try {
14
+ $fileName = $_FILES['file360']['name'][0];
15
+ $fileExt = strtolower(substr(strrchr($fileName, '.'), 1));
16
+ $fileNamewoe = $productId . '_' . $id360set . '_' . $this->imgNameFilter(rtrim($fileName, '.' . $fileExt));
17
+ $fileName = $fileNamewoe . '.' . $fileExt;
18
+
19
+ $uploader = new Varien_File_Uploader(array(
20
+ 'name' => $_FILES['file360']['name'][0],
21
+ 'type' => $_FILES['file360']['type'][0],
22
+ 'tmp_name' => $_FILES['file360']['tmp_name'][0],
23
+ 'error' => $_FILES['file360']['error'][0],
24
+ 'size' => $_FILES['file360']['size'][0]
25
+ ));
26
+ $uploader->setAllowedExtensions(array('png', 'jpg')); //allowed extensions
27
+ $uploader->setAllowRenameFiles(false);
28
+ $uploader->setFilesDispersion(false);
29
+
30
+ $uploader->save($folder, $fileName );
31
+ } catch (Exception $e) {
32
+ echo $e->getMessage();
33
+ exit;
34
+ }
35
+ }
36
+
37
+ die(Mage::helper('core')->jsonEncode(array(
38
+ 'file360' => array(array(
39
+ 'status' => 'ok',
40
+ 'name' => $fileName,
41
+ 'id' => $fileNamewoe,
42
+ 'id_product' => $productId,
43
+ 'id_360' => $id360,
44
+ 'id_360set' => $id360set,
45
+ 'path' => Mage::getBaseUrl('js') . 'axzoom/axZm/zoomLoad.php?qq=1&azImg=' . $this->rootFolder() . 'js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set . '/' . $fileName . '&width=100&height=100&qual=90'
46
+ )))));
47
+ exit;
48
+ }
49
+
50
+ public function DeleteProductImage360Action()
51
+ {
52
+ $get = Mage::app()->getRequest();
53
+ $imageId = $get->getParam('id_image');
54
+ $productId = $get->getParam('id_product');
55
+ $id360set = $get->getParam('id_360set');
56
+ $id360 = Mage::getModel('axzoom/ax360set')->load($id360set)->getId_360();
57
+ $tmp = explode('&', $get->getParam('ext'));
58
+ $ext = reset($tmp);
59
+ $filename = $imageId . '.' . $ext;
60
+
61
+ $dst = Mage::getBaseDir() . '/js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set . '/' . $filename;
62
+ unlink($dst);
63
+
64
+ Mage::getModel('axzoom/ax360')->deleteImageAZcache($filename);
65
+
66
+ die(Mage::helper('core')->jsonEncode(array(
67
+ 'status' => 'ok',
68
+ 'content' => (object)array('id' => $imageId),
69
+ 'confirmations' => array('The image was successfully deleted.')
70
+ )));
71
+ }
72
+
73
+ public function ClearAzImageCacheAction()
74
+ {
75
+ $filename = (int)(Mage::app()->getRequest()->getParam('deletedImgID')) . '.jpg';
76
+ Mage::getModel('axzoom/ax360')->deleteImageAZcache($filename);
77
+ die(Mage::helper('core')->jsonEncode(array(
78
+ 'status' => 'ok',
79
+ 'confirmations' => array('AJAX-ZOOM cache has been deleted for image with ID ' . (int)(Mage::app()->getRequest()->getParam('deletedImgID')))
80
+ )));
81
+ }
82
+
83
+ public function GetImagesAction()
84
+ {
85
+ $get = Mage::app()->getRequest();
86
+ $productId = $get->getParam('id_product');
87
+ $id360set = $get->getParam('id_360set');
88
+ $images = Mage::getModel('axzoom/ax360')->get360Images($productId, $id360set);
89
+
90
+ die(Mage::helper('core')->jsonEncode(array(
91
+ 'status' => 'ok',
92
+ 'id_product' => $productId,
93
+ 'id_360set' => $id360set,
94
+ 'images' => $images
95
+ )));
96
+ }
97
+
98
+ public function DeleteSetAction()
99
+ {
100
+ $get = Mage::app()->getRequest();
101
+ $productId = $get->getParam('id_product');
102
+ $id360set = $get->getParam('id_360set');
103
+ $id360 = Mage::getModel('axzoom/ax360set')->load($id360set)->getId_360();
104
+
105
+ // clear AZ cache
106
+ $images = Mage::getModel('axzoom/ax360')->get360Images($productId, $id360set);
107
+
108
+ foreach ($images as $image) {
109
+ Mage::getModel('axzoom/ax360')->deleteImageAZcache($image['filename']);
110
+ }
111
+
112
+ Mage::getModel('axzoom/ax360set')->setId($id360set)->delete();
113
+
114
+ if (!Mage::getModel('axzoom/ax360set')->getCollection()->addFieldToFilter('id_360', $id360)->getData()) {
115
+ Mage::getModel('axzoom/ax360')->setId($id360)->delete();
116
+ }
117
+
118
+ $path = Mage::getBaseDir() . '/js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set;
119
+ $this->deleteDirectory($path);
120
+
121
+ die(Mage::helper('core')->jsonEncode(array(
122
+ 'id_360set' => $id360set,
123
+ 'id_360' => $id360,
124
+ 'path' => $path,
125
+ 'removed' => (!Mage::getModel('axzoom/ax360')->load($id360)->getData() ? 1 : 0),
126
+ 'confirmations' => array('The 360 image set was successfully removed.')
127
+ )));
128
+ }
129
+
130
+ public function Set360StatusAction()
131
+ {
132
+ $get = Mage::app()->getRequest();
133
+ $productId = $get->getParam('id_product');
134
+ $id360 = $get->getParam('id_360');
135
+ $status = $get->getParam('status');
136
+
137
+ Mage::getModel('axzoom/ax360')->load($id360)->addData(array('status' => $status))->setId($id360)->save();
138
+
139
+ die(Mage::helper('core')->jsonEncode(array(
140
+ 'status' => 'ok',
141
+ 'confirmations' => array('The status has been updated.' . $status . '-' . $id360)
142
+ )));
143
+ }
144
+
145
+ public function AddSetAction()
146
+ {
147
+ $get = Mage::app()->getRequest();
148
+ $productId = $get->getParam('id_product');
149
+ $name = $get->getParam('name');
150
+ $existing = $get->getParam('existing');
151
+ $zip = $get->getParam('zip');
152
+ $arcfile = $get->getParam('arcfile');
153
+ $newId = '';
154
+ $newName = '';
155
+ $newSettings = '';
156
+ $status = ($zip == 'true' ? 1 : 0);
157
+
158
+ if (!empty($existing)) {
159
+ $id360 = $existing;
160
+ $name = Mage::getModel('axzoom/ax360')->load($id360)->getName();
161
+ } else {
162
+ $newSettings = $settings = '{"position":"first","spinReverse":"true","spinBounce":"false","spinDemoRounds":"3","spinDemoTime":"4500"}';
163
+ $data = array(
164
+ 'id_product' => $productId,
165
+ 'name' => $name,
166
+ 'settings' => $settings,
167
+ 'status' => $status
168
+ );
169
+ $id360 = $newId = Mage::getModel('axzoom/ax360')->setData($data)->save()->getId();
170
+ $newName = $name;
171
+ }
172
+
173
+ $id360set = Mage::getModel('axzoom/ax360set')->setData(array('id_360' => $id360, 'sort_order' => 0))->save()->getId();
174
+
175
+ $sets = array();
176
+
177
+ if ($zip == 'true') {
178
+ $sets = $this->addImagesArc($arcfile, $productId, $id360, $id360set);
179
+ }
180
+
181
+ die(Mage::helper('core')->jsonEncode(array(
182
+ 'status' => $status,
183
+ 'name' => $name,
184
+ 'path' => Mage::getBaseUrl('js') . 'axzoom/no_image-100x100.jpg',
185
+ 'sets' => $sets,
186
+ 'id_360' => $id360,
187
+ 'id_product' => $productId,
188
+ 'id_360set' => $id360set,
189
+ 'confirmations' => array('The image set was successfully added.'),
190
+ 'new_id' => $newId,
191
+ 'new_name' => $newName,
192
+ 'new_settings' => urlencode($newSettings)
193
+ )));
194
+ }
195
+
196
+
197
+ public function addImagesArc($arcfile, $productId, $id360, $id360set)
198
+ {
199
+ set_time_limit(0);
200
+
201
+ $baseDir = Mage::getBaseDir();
202
+ $baseUrlJs = Mage::getBaseUrl('js');
203
+
204
+ $path = $baseDir . '/js/axzoom/zip/' . $arcfile;
205
+ $dst = $this->extractArc($path);
206
+ $data = $this->getFolderData($dst);
207
+
208
+ $name = Mage::getModel('axzoom/ax360')->load($id360)->getName();
209
+
210
+ $sets = array(array(
211
+ 'name' => $name,
212
+ 'path' => $baseUrlJs . 'axzoom/axZm/zoomLoad.php?qq=1&azImg360=' . $this->rootFolder() . 'js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set . '&width=100&height=100&thumbMode=contain',
213
+ 'id_360set' => $id360set,
214
+ 'id_360' => $id360,
215
+ 'status' => '1'
216
+ ));
217
+
218
+ if (count($data['folders']) == 0) { // files (360)
219
+ $this->copyImages($productId, $id360, $id360set, $dst);
220
+ } elseif (count($data['folders']) == 1) { // 1 folder (360)
221
+ $this->copyImages($productId, $id360, $id360set, $dst . '/' . $data['folders'][0]);
222
+ } else { // 3d
223
+ $this->copyImages($productId, $id360, $id360set, $dst . '/' . $data['folders'][0]);
224
+ for ($i=1; $i < count($data['folders']); $i++) {
225
+ $id360set = Mage::getModel('axzoom/ax360set')->setData(array('id_360' => $id360, 'sort_order' => 0))->save()->getId();
226
+ $this->copyImages($productId, $id360, $id360set, $dst . '/' . $data['folders'][$i]);
227
+
228
+ $sets[] = array(
229
+ 'name' => $name,
230
+ 'path' => $baseUrlJs . 'axzoom/axZm/zoomLoad.php?qq=1&azImg360=' . $this->rootFolder() . 'js/axzoom/pic/360/' . $productId . '/' . $id360 . '/' . $id360set . '&width=100&height=100&thumbMode=contain',
231
+ 'id_360set' => $id360set
232
+ );
233
+ }
234
+ }
235
+
236
+ $this->deleteDirectory($dst);
237
+ return $sets;
238
+ }
239
+
240
+ public function extractArc($file)
241
+ {
242
+
243
+ $baseDir = Mage::getBaseDir();
244
+
245
+ $zip = new ZipArchive;
246
+ $res = $zip->open($file);
247
+ if ($res === TRUE) {
248
+ $folder = uniqid(getmypid());
249
+ $path = $baseDir . '/js/axzoom/tmp/' . $folder;
250
+ mkdir($path, 0777);
251
+ $zip->extractTo($path);
252
+ $zip->close();
253
+ return $path;
254
+ } else {
255
+ return false;
256
+ }
257
+ }
258
+
259
+ public function getFolderData($path)
260
+ {
261
+ $files = array();
262
+ $folders = array();
263
+ if ($handle = opendir($path)) {
264
+ while (false !== ($entry = readdir($handle))) {
265
+ if ($entry != '.' && $entry != '..') {
266
+ if (is_dir($path . '/' . $entry)) {
267
+ array_push($folders, $entry);
268
+ } else {
269
+ array_push($files, $entry);
270
+ }
271
+ }
272
+ }
273
+ closedir($handle);
274
+ }
275
+
276
+ sort($folders);
277
+ sort($files);
278
+
279
+ return array(
280
+ 'folders' => $folders,
281
+ 'files' => $files
282
+ );
283
+ }
284
+
285
+ public function copyImages($productId, $id360, $id360set, $path)
286
+ {
287
+ $files = $this->getFilesFromFolder($path);
288
+ $folder = $this->createProduct360Folder($productId, $id360set);
289
+
290
+ foreach ($files as $file)
291
+ {
292
+ $name = $productId . '_' . $id360set . '_' . $this->imgNameFilter($file);
293
+ $tmp = explode('.', $name);
294
+ $ext = end($tmp);
295
+ $dst = $folder . '/' . $name;
296
+ rename($path . '/' . $file, $dst);
297
+ }
298
+ }
299
+
300
+
301
+ public function getFilesFromFolder($path)
302
+ {
303
+ $files = array();
304
+ if ($handle = opendir($path)) {
305
+ while (false !== ($entry = readdir($handle))) {
306
+ if ($entry != '.' && $entry != '..') {
307
+ $files[] = $entry;
308
+ }
309
+ }
310
+ closedir($handle);
311
+ }
312
+
313
+ return $files;
314
+ }
315
+
316
+ public function createProduct360Folder($productId, $id360set)
317
+ {
318
+ $productId = (int)($productId);
319
+ $id360set = (int)($id360set);
320
+ $id360 = Mage::getModel('axzoom/ax360set')->load($id360set)->getId_360();
321
+
322
+ $imgPath = Mage::getBaseDir() . '/js/axzoom/pic/360/';
323
+ @chmod(rtrim($imgPath, '/'), 0777);
324
+
325
+ if (!file_exists($imgPath . '.htaccess')) {
326
+ file_put_contents($imgPath . '.htaccess', 'deny from all');
327
+ }
328
+
329
+ if (!file_exists($imgPath . $productId)) {
330
+ mkdir($imgPath . $productId, 0777);
331
+ }
332
+
333
+ if (!file_exists($imgPath . $productId . '/' . $id360)) {
334
+ mkdir($imgPath . $productId . '/' . $id360, 0777);
335
+ }
336
+
337
+ $folder = $imgPath . $productId . '/' . $id360 . '/' . $id360set;
338
+
339
+ if (!file_exists($folder)) {
340
+ mkdir($folder, 0777);
341
+ } else {
342
+ chmod($folder, 0777);
343
+ }
344
+
345
+ return $folder;
346
+ }
347
+
348
+ public function deleteDirectory($dirname, $delete_self = true)
349
+ {
350
+ $dirname = rtrim($dirname, '/') . '/';
351
+ if (file_exists($dirname))
352
+ if ($files = scandir($dirname))
353
+ {
354
+ foreach ($files as $file)
355
+ if ($file != '.' && $file != '..' && $file != '.svn')
356
+ {
357
+ if (is_dir($dirname.$file))
358
+ $this->deleteDirectory($dirname.$file, true);
359
+ elseif (file_exists($dirname.$file))
360
+ {
361
+ @chmod($dirname.$file, 0777); // NT ?
362
+ unlink($dirname.$file);
363
+ }
364
+ }
365
+ if ($delete_self && file_exists($dirname))
366
+ if (!rmdir($dirname))
367
+ {
368
+ @chmod($dirname, 0777); // NT ?
369
+ return false;
370
+ }
371
+ return true;
372
+ }
373
+ return false;
374
+ }
375
+
376
+ public function imgNameFilter($filename)
377
+ {
378
+ $filename = preg_replace('/[^A-Za-z0-9_\.-]/', '-', $filename);
379
+ return $filename;
380
+ }
381
+
382
+ public function rootFolder()
383
+ {
384
+ $p = parse_url(Mage::getBaseUrl());
385
+ return str_replace('index.php/', '', $p['path']);
386
+ }
387
+ }
app/code/local/Ax/Zoom/etc/config.xml ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <modules>
5
+ <Ax_Zoom>
6
+ <version>0.0.1</version>
7
+ </Ax_Zoom>
8
+ </modules>
9
+
10
+ <global>
11
+ <helpers>
12
+ <axzoom>
13
+ <class>Ax_Zoom_Helper</class>
14
+ </axzoom>
15
+ </helpers>
16
+ <models>
17
+ <axzoom>
18
+ <class>Ax_Zoom_Model</class>
19
+ <resourceModel>axzoom_resource</resourceModel>
20
+ </axzoom>
21
+ <axzoom_resource>
22
+ <class>Ax_Zoom_Model_Resource</class>
23
+ <entities>
24
+ <table_ax360set>
25
+ <table>ajaxzoom360set</table>
26
+ </table_ax360set>
27
+ <table_ax360>
28
+ <table>ajaxzoom360</table>
29
+ </table_ax360>
30
+ <table_axproducts>
31
+ <table>ajaxzoomproducts</table>
32
+ </table_axproducts>
33
+ </entities>
34
+ </axzoom_resource>
35
+ </models>
36
+ <blocks>
37
+ <zoom>
38
+ <class>Ax_Zoom_Block</class>
39
+ </zoom>
40
+ <adminhtml>
41
+ <rewrite>
42
+ <catalog_product_edit_tabs>Ax_Zoom_Block_Adminhtml_Tabs</catalog_product_edit_tabs>
43
+ </rewrite>
44
+ </adminhtml>
45
+ </blocks>
46
+ <resources>
47
+ <axzoom_setup>
48
+ <setup>
49
+ <module>Ax_Zoom</module>
50
+ </setup>
51
+ </axzoom_setup>
52
+ </resources>
53
+ </global>
54
+
55
+ <frontend>
56
+ <translate>
57
+ <modules>
58
+ <Ax_Zoom>
59
+ <files>
60
+ <default>Ax_Zoom.csv</default>
61
+ </files>
62
+ </Ax_Zoom>
63
+ </modules>
64
+ </translate>
65
+
66
+ <routers>
67
+ <axzoom>
68
+ <use>standard</use>
69
+ <args>
70
+ <module>Ax_Zoom</module>
71
+ <frontName>axzoom</frontName>
72
+ </args>
73
+ </axzoom>
74
+ </routers>
75
+
76
+ <layout>
77
+ <updates>
78
+ <ax_zoom>
79
+ <file>axzoom.xml</file>
80
+ </ax_zoom>
81
+ </updates>
82
+ </layout>
83
+
84
+ <events>
85
+ <catalog_controller_product_init>
86
+ <observers>
87
+ <ax_zoom_model_observer>
88
+ <type>singleton</type>
89
+ <class>Ax_Zoom_Model_Observer</class>
90
+ <method>productBefore</method>
91
+ </ax_zoom_model_observer>
92
+ </observers>
93
+ </catalog_controller_product_init>
94
+
95
+ <core_block_abstract_to_html_before>
96
+ <observers>
97
+ <ax_zoom_model_observer>
98
+ <type>singleton</type>
99
+ <class>Ax_Zoom_Model_Observer</class>
100
+ <method>coreBlockBefore</method>
101
+ </ax_zoom_model_observer>
102
+ </observers>
103
+ </core_block_abstract_to_html_before>
104
+ </events>
105
+ </frontend>
106
+
107
+
108
+ <adminhtml>
109
+ <translate>
110
+ <modules>
111
+ <Ax_Zoom>
112
+ <files>
113
+ <default>Ax_Zoom.csv</default>
114
+ </files>
115
+ </Ax_Zoom>
116
+ </modules>
117
+ </translate>
118
+
119
+ <layout>
120
+ <updates>
121
+ <ax_zoom>
122
+ <file>axzoom.xml</file>
123
+ </ax_zoom>
124
+ </updates>
125
+ </layout>
126
+
127
+ <events>
128
+ <catalog_product_prepare_save>
129
+ <observers>
130
+ <ax_zoom_model_observer>
131
+ <type>singleton</type>
132
+ <class>Ax_Zoom_Model_Observer</class>
133
+ <method>save360</method>
134
+ </ax_zoom_model_observer>
135
+ </observers>
136
+ </catalog_product_prepare_save>
137
+
138
+ <catalog_product_delete_before>
139
+ <observers>
140
+ <ax_zoom_model_observer>
141
+ <type>singleton</type>
142
+ <class>Ax_Zoom_Model_Observer</class>
143
+ <method>deleteProduct</method>
144
+ </ax_zoom_model_observer>
145
+ </observers>
146
+ </catalog_product_delete_before>
147
+
148
+ <catalog_product_save_before>
149
+ <observers>
150
+ <ax_zoom_model_observer>
151
+ <type>singleton</type>
152
+ <class>Ax_Zoom_Model_Observer</class>
153
+ <method>productSaveBefore</method>
154
+ </ax_zoom_model_observer>
155
+ </observers>
156
+ </catalog_product_save_before>
157
+
158
+ <catalog_product_save_after>
159
+ <observers>
160
+ <ax_zoom_model_observer>
161
+ <type>singleton</type>
162
+ <class>Ax_Zoom_Model_Observer</class>
163
+ <method>productSaveAfter</method>
164
+ </ax_zoom_model_observer>
165
+ </observers>
166
+ </catalog_product_save_after>
167
+
168
+ </events>
169
+
170
+ <acl>
171
+ <resources>
172
+ <admin>
173
+ <children>
174
+ <system>
175
+ <children>
176
+ <config>
177
+ <children>
178
+ <axzoom_options>
179
+ <title>AJAX ZOOM Settings</title>
180
+ </axzoom_options>
181
+ </children>
182
+ </config>
183
+ </children>
184
+ </system>
185
+ </children>
186
+ </admin>
187
+ </resources>
188
+ </acl>
189
+
190
+ </adminhtml>
191
+
192
+ <default>
193
+ <axzoom_options>
194
+ <main>
195
+ <divid>az_mouseOverZoomContainer</divid>
196
+ <galleryDivID>az_mouseOverZoomGallery</galleryDivID>
197
+ <hideGalleryOneImage>1</hideGalleryOneImage>
198
+ <disableAllMsg >0</disableAllMsg >
199
+ <galleryHover></galleryHover>
200
+ <galleryAxZmThumbSlider>1</galleryAxZmThumbSlider>
201
+ <galleryAxZmThumbSliderParam>
202
+ {
203
+ orientation: "horizontal",
204
+ scrollBy: 1,
205
+ btn: true,
206
+ btnClass: "axZmThumbSlider_button_new",
207
+ btnBwdStyle: {
208
+ marginLeft: 0,
209
+ marginRight: 0
210
+ },
211
+ btnFwdStyle: {
212
+ marginLeft: 0,
213
+ marginRight: 0
214
+ },
215
+ btnLeftText: null,
216
+ btnRightText: null,
217
+ btnHidden: true,
218
+ pressScrollSnap: true,
219
+ centerNoScroll: true,
220
+ wrapStyle: {
221
+ borderWidth: 0
222
+ },
223
+ thumbImgStyle: {
224
+ maxHeight: "58px",
225
+ maxWidth: "58px"
226
+ },
227
+ thumbLiStyle: {
228
+ width: 58,
229
+ height: 58,
230
+ lineHeight: "56px",
231
+ marginBottom: 2,
232
+ marginLeft: 3,
233
+ marginRight: 3,
234
+ borderRadius: 3
235
+ }
236
+ }
237
+ </galleryAxZmThumbSliderParam>
238
+ <thumbW>58</thumbW>
239
+ <thumbH>58</thumbH>
240
+ <thumbRetina>1</thumbRetina>
241
+ <firstImageToLoad>1</firstImageToLoad>
242
+ <images360firstToLoad>0</images360firstToLoad>
243
+ <images360Opt>["spinReverse", "spinReverseZ", "spinBounce", "spinDemoRounds", "spinDemoTime", "spinWhilePreload"]</images360Opt>
244
+ <images360Thumb>1</images360Thumb>
245
+ <images360Preview>1</images360Preview>
246
+ <images360PreviewResponsive>1</images360PreviewResponsive>
247
+ <images360examplePreview>mouseOverExtension360</images360examplePreview>
248
+ <zoomMsg360>Drag to spin 360°, scroll to zoom in and out</zoomMsg360>
249
+ <preloadMouseOverImages>0</preloadMouseOverImages>
250
+ <noImageAvailableClass>axZm_mouseOverNoImage</noImageAvailableClass>
251
+ <width>auto</width>
252
+ <height>auto</height>
253
+ <responsive>1</responsive>
254
+ <oneSrcImg>0</oneSrcImg>
255
+ <heightRatio>1.0</heightRatio>
256
+ <heightMaxWidthRatio>["960|0.8", "700|0.7"]</heightMaxWidthRatio>
257
+ <widthRatio>false</widthRatio>
258
+ <widthMaxHeightRatio>false</widthMaxHeightRatio>
259
+ <maxSizePrc>1.0</maxSizePrc>
260
+ <mouseOverZoomWidth>1200</mouseOverZoomWidth>
261
+ <mouseOverZoomHeight>1200</mouseOverZoomHeight>
262
+ <ajaxZoomOpenMode>fancyboxFullscreen</ajaxZoomOpenMode>
263
+ <fancyBoxParam>{}</fancyBoxParam>
264
+ <colorBoxParam>{}</colorBoxParam>
265
+ <example>mouseOverExtension</example>
266
+ <exampleFancyboxFullscreen>mouseOverExtension</exampleFancyboxFullscreen>
267
+ <exampleFancybox>modal</exampleFancybox>
268
+ <exampleColorbox>modal</exampleColorbox>
269
+ <disableScrollAnm>1</disableScrollAnm>
270
+ <fullScreenApi>0</fullScreenApi>
271
+ <axZmCallBacks>{}</axZmCallBacks>
272
+ <azOptions>{}</azOptions>
273
+ <azOptions360>{}</azOptions360>
274
+ <qualityThumb>100</qualityThumb>
275
+ <quality>90</quality>
276
+ <qualityZoom>80</qualityZoom>
277
+ <onLoad>null</onLoad>
278
+ <onImageChange>null</onImageChange>
279
+ <onMouseOver>null</onMouseOver>
280
+ <onMouseOut>null</onMouseOut>
281
+ <spinner>1</spinner>
282
+ <spinnerParam>{}</spinnerParam>
283
+ </main>
284
+ <pinterest>
285
+ <enabled>1</enabled>
286
+ <build>parsePinBtns</build>
287
+ <wrapClass>axZm_mouseOverPinterest</wrapClass>
288
+ <href>//en.pinterest.com/pin/create/button/</href>
289
+ <description>null</description>
290
+ <url>null</url>
291
+ <media>null</media>
292
+ <btnSrc>//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png</btnSrc>
293
+ <data>{}</data>
294
+ </pinterest>
295
+ <mouseOverZoomParam>
296
+ <position>right</position>
297
+ <posAutoInside>150</posAutoInside>
298
+ <posInsideArea>0.2</posInsideArea>
299
+ <autoFlip>120</autoFlip>
300
+ <biggestSpace>0</biggestSpace>
301
+ <zoomFullSpace>0</zoomFullSpace>
302
+ <zoomWidth>.product-shop|+2</zoomWidth>
303
+ <zoomHeight>.product-img-box</zoomHeight>
304
+ <autoMargin>15</autoMargin>
305
+ <adjustX>13</adjustX>
306
+ <adjustY>-1</adjustY>
307
+ <lensOpacity>0.30</lensOpacity>
308
+ <lensStyle>{}</lensStyle>
309
+ <lensClass>false</lensClass>
310
+ <zoomAreaBorderWidth>1</zoomAreaBorderWidth>
311
+ <galleryFade>300</galleryFade>
312
+ <shutterSpeed>150</shutterSpeed>
313
+ <showFade>300</showFade>
314
+ <hideFade>300</hideFade>
315
+ <flyOutSpeed>false</flyOutSpeed>
316
+ <flyOutTransition>linear</flyOutTransition>
317
+ <flyOutOpacity>0.6</flyOutOpacity>
318
+ <flyBackSpeed>false</flyBackSpeed>
319
+ <flyBackTransition>linear</flyBackTransition>
320
+ <flyBackOpacity>0.2</flyBackOpacity>
321
+ <autoScroll>0</autoScroll>
322
+ <smoothMove>6</smoothMove>
323
+ <tint>false</tint>
324
+ <tintOpacity>0.3</tintOpacity>
325
+ <tintFilter>false</tintFilter>
326
+ <tintLensBack>1</tintLensBack>
327
+ <showTitle>1</showTitle>
328
+ <titleOpacity>0.5</titleOpacity>
329
+ <titlePosition>top</titlePosition>
330
+ <cursorPositionX>0.5</cursorPositionX>
331
+ <cursorPositionY>0.55</cursorPositionY>
332
+ <touchClickAbort>500</touchClickAbort>
333
+ <loading>1</loading>
334
+ <loadingMessage>Loading...</loadingMessage>
335
+ <loadingWidth>90</loadingWidth>
336
+ <loadingHeight>20</loadingHeight>
337
+ <loadingOpacity>1.0</loadingOpacity>
338
+ <zoomHintEnable>1</zoomHintEnable>
339
+ <zoomHintText>Zoom</zoomHintText>
340
+ <zoomMsgHover>Roll over image to zoom in, click to view expanded</zoomMsgHover>
341
+ <zoomMsgClick>Click to open expanded view</zoomMsgClick>
342
+ </mouseOverZoomParam>
343
+ <products>
344
+ <displayOnlyForThisProductID></displayOnlyForThisProductID>
345
+ </products>
346
+ </axzoom_options>
347
+ </default>
348
+
349
+ </config>
app/code/local/Ax/Zoom/etc/system.xml ADDED
@@ -0,0 +1,1148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
</