Orbitvu_Sun - Version 1.0.12

Version Notes

-Added thumbnail assign to the associated (child) products of configurable product
-Fixed many notices and warnings
-Increased connect timeout to sun server
-Fixed thumbnail deletion

Download this release

Release Info

Developer Développeurs EnvoiMoinsCher.com
Extension Orbitvu_Sun
Version 1.0.12
Comparing to
See all releases


Code changes from version 1.0.11 to 1.0.12

Files changed (56) hide show
  1. app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Grid.php +367 -367
  2. app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Gridrenderer.php +104 -104
  3. app/code/community/Orbitvu/Sun/Block/Adminhtml/Tabs.php +34 -34
  4. app/code/community/Orbitvu/Sun/Block/Adminhtml/Tabs/Tabid.php +23 -23
  5. app/code/community/Orbitvu/Sun/Block/Delay.php +54 -54
  6. app/code/community/Orbitvu/Sun/Block/Html5.php +50 -50
  7. app/code/community/Orbitvu/Sun/Block/KeyComment.php +19 -19
  8. app/code/community/Orbitvu/Sun/Block/Orbittour.php +52 -52
  9. app/code/community/Orbitvu/Sun/Block/Product/View/Media.php +12 -12
  10. app/code/community/Orbitvu/Sun/Block/Scroll.php +50 -50
  11. app/code/community/Orbitvu/Sun/Block/Syncsku.php +51 -51
  12. app/code/community/Orbitvu/Sun/Block/Teaser.php +54 -54
  13. app/code/community/Orbitvu/Sun/Helper/Data.php +3 -3
  14. app/code/community/Orbitvu/Sun/Model/Observer.php +249 -227
  15. app/code/community/Orbitvu/Sun/Model/Resource/Setup.php +13 -13
  16. app/code/community/Orbitvu/Sun/Model/Resource/Sun.php +13 -13
  17. app/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php +948 -940
  18. app/code/community/Orbitvu/Sun/controllers/OrbitvuConnect.php +1056 -1056
  19. app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseDriver.php +374 -372
  20. app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseInterface.php +2173 -2146
  21. app/code/community/Orbitvu/Sun/controllers/OrbitvuDebugger.php +41 -41
  22. app/code/community/Orbitvu/Sun/controllers/OrbitvuTests.php +126 -126
  23. app/code/community/Orbitvu/Sun/etc/adminhtml.xml +25 -25
  24. app/code/community/Orbitvu/Sun/etc/config.xml +101 -101
  25. app/code/community/Orbitvu/Sun/etc/system.xml +318 -318
  26. app/code/community/Orbitvu/Sun/etc/translations.xml +8 -8
  27. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.0.php +22 -22
  28. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.1.php +22 -22
  29. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.10.php +23 -23
  30. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.2.php +22 -22
  31. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.3.php +22 -22
  32. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.4.php +22 -22
  33. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.5.php +22 -22
  34. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.6.php +22 -22
  35. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.7.php +22 -22
  36. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.8.php +23 -23
  37. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.9.php +23 -23
  38. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.0-1.0.1.php +16 -16
  39. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.1-1.0.2.php +16 -16
  40. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.10-1.0.11.php +16 -16
  41. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.11-1.0.12.php +17 -0
  42. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.2-1.0.3.php +16 -16
  43. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.3-1.0.4.php +16 -16
  44. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.4-1.0.5.php +16 -16
  45. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.5-1.0.6.php +21 -21
  46. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.6-1.0.7.php +16 -16
  47. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.7-1.0.8.php +16 -16
  48. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.8-1.0.9.php +16 -16
  49. app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.9-1.0.10.php +16 -16
  50. app/design/adminhtml/default/default/template/sun/orbitvu.phtml +1497 -1469
  51. app/design/frontend/base/default/layout/sun.xml +16 -16
  52. app/design/frontend/base/default/template/orbitvu/product/view/media.phtml +1037 -1037
  53. app/etc/modules/Orbitvu_Sun.xml +16 -16
  54. app/locale/en_US/Orbitvu_Sun.csv +138 -138
  55. crossdomain.xml +3 -3
  56. package.xml +8 -5
app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Grid.php CHANGED
@@ -1,368 +1,368 @@
1
- <?php
2
-
3
- /**
4
- * @category Orbitvu
5
- * @package Orbitvu_Sun
6
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
7
- * @license http://www.orbitvu.com/plugins/license
8
- * @version 1.0.0
9
- */
10
- class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid {
11
-
12
- const XML_SEVERITY_ICONS_URL_PATH = 'system/adminnotification/severity_icons_url';
13
-
14
- /*
15
- * Get column "Orbitvu"
16
- * for products view
17
- */
18
- public function setCollection($collection) {
19
- //------------------------------------------------------------------------------------------------------------------
20
- //$store = $this->_getStore();
21
- //------------------------------------------------------------------------------------------------------------------
22
- /*if ($store->getId() && !isset($this->_joinAttributes['orbitvu_sun'])) {
23
- $collection->joinAttribute(
24
- 'orbitvu_sun', 'catalog_product/orbitvu_sun', 'entity_id', null, 'left', $store->getId()
25
- );
26
- }
27
- else {
28
- $collection->addAttributeToSelect('orbitvu_sun');
29
- }*/
30
- //------------------------------------------------------------------------------------------------------------------
31
- parent::setCollection($collection);
32
- //------------------------------------------------------------------------------------------------------------------
33
- }
34
-
35
- /*
36
- * Don't know why Magento links this notification icons to external resources
37
- * But OK...
38
- */
39
- public function getSeverityIconsUrl($icon_type = 'NOTICE') {
40
- //------------------------------------------------------------------------------------------------------------------
41
- $url = (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
42
- .sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(), 'SEVERITY_'.$icon_type);
43
- //------------------------------------------------------------------------------------------------------------------
44
- return $url;
45
- }
46
-
47
- /*
48
- * Render columns with our new one
49
- * Also, add buttons "Link all presentations" and "Configuration"
50
- */
51
- protected function _prepareColumns() {
52
- //------------------------------------------------------------------------------------------------------------------
53
- $store = $this->_getStore();
54
- $request = Mage::app()->getRequest();
55
- $cookies = Mage::getModel('core/cookie');
56
- //------------------------------------------------------------------------------------------------------------------
57
- $observer = Mage::getSingleton('sun/observer');
58
- $observer->ExtendOrbitvu();
59
-
60
- $orbitvu_connected = $observer->_Orbitvu->IsConnected();
61
- //------------------------------------------------------------------------------------------------------------------
62
- $o_configuration_url = explode('/system_config/', $this->getUrl('*/system_config/edit/section/orbitvu/'));
63
- $o_configuration_url = '*/system_config/'.$o_configuration_url[count($o_configuration_url)-1];
64
-
65
- $o_update_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/update'));
66
- $o_update_url = '*/catalog_product/'.$o_update_url[count($o_update_url)-1];
67
-
68
- $o_close_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/dismiss'));
69
- $o_close_url = '*/catalog_product/'.$o_close_url[count($o_close_url)-1];
70
-
71
- $o_close_welcome_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/dismiss_welcome'));
72
- $o_close_welcome_url = '*/catalog_product/'.$o_close_welcome_url[count($o_close_welcome_url)-1];
73
-
74
- $display_first_time = true;
75
- //------------------------------------------------------------------------------------------------------------------
76
-
77
- /*
78
- * Add column Orbitvu
79
- */
80
- //------------------------------------------------------------------------------------------------------------------
81
- $this->addColumnAfter('orbitvu_sun', array(
82
- 'header' => Mage::helper('catalog')->__('Orbitvu'),
83
- 'type' => 'text',
84
- 'width' => '100px',
85
- 'renderer' => 'Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Gridrenderer',
86
- 'index' => 'orbitvu_sun',
87
- ), 'sku'
88
- );
89
- //------------------------------------------------------------------------------------------------------------------
90
-
91
- /*
92
- * SUN actions
93
- */
94
- //------------------------------------------------------------------------------------------------------------------
95
- if (date('Y-m-d', strtotime($observer->_Orbitvu->GetConfiguration('last_refreshed'))) != date('Y-m-d')) {
96
- $observer->_Orbitvu->SynchronizePresentationsItems();
97
- }
98
- //------------------------------------------------------------------------------------------------------------------
99
- if ($request->getParam('sun') == 'update') {
100
- $observer->SynchronizeAllProducts();
101
- }
102
- //------------------------------------------------------------------------------------------------------------------
103
- else if ($request->getParam('sun') == 'register') {
104
- $email = strip_tags($_GET['orbitvu_register_email']);
105
-
106
- $response = $observer->_Orbitvu->CreateAccount($email);
107
-
108
- if ($response->status == 'BAD') {
109
- //------------------------------------------------------------------------------------------------------------------
110
- $buttons = '<a href="'.$this->getUrl('*/catalog_product/index/').'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('OK').'</a>';
111
- //------------------------------------------------------------------------------------------------------------------
112
- $orbitvu_popup = $this->genPopup(
113
- Mage::helper('catalog')->__('Error!'),
114
- Mage::helper('catalog')->__($response->error),
115
- $buttons,
116
- '*/catalog_product/index/',
117
- 'MAJOR'
118
- );
119
- //------------------------------------------------------------------------------------------------------------------
120
- $display_first_time = false;
121
- //------------------------------------------------------------------------------------------------------------------
122
- }
123
- else {
124
- //------------------------------------------------------------------------------------------------------------------
125
- $buttons = '<a href="'.$this->getUrl('*/catalog_product/index/').'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('OK').'</a>';
126
- //------------------------------------------------------------------------------------------------------------------
127
- $orbitvu_popup = $this->genPopup(
128
- Mage::helper('catalog')->__('Your account was created!'),
129
- Mage::helper('catalog')->__('Now you have your own account on Orbitvu SUN.<br />We sent your an email with details.').' <br /><strong>'.Mage::helper('catalog')->__('Your trial License Key was created and it\'s now in use.').'</strong>.',
130
- $buttons,
131
- '*/catalog_product/index/',
132
- 'NOTICE'
133
- );
134
- //------------------------------------------------------------------------------------------------------------------
135
- /*
136
- * <br />Your login details:').'<br />'.Mage::helper('catalog')->__('Login:').' <strong>'.$response->email.'</strong><br />'.Mage::helper('catalog')->__('Password: ').' <strong>'.$response->password.'</strong><br />'.Mage::helper('catalog')->__('License key:').'<br /><strong>'.$response->key.'</strong>
137
- *
138
- */
139
- $observer->_Orbitvu->SetConfiguration('first_time', 'false');
140
- $display_first_time = false;
141
- //------------------------------------------------------------------------------------------------------------------
142
- }
143
- }
144
- //------------------------------------------------------------------------------------------------------------------
145
-
146
- /*
147
- * Orbitvu Pop-up
148
- */
149
- //------------------------------------------------------------------------------------------------------------------
150
- // Disconnected error
151
- //------------------------------------------------------------------------------------------------------------------
152
- if (!$orbitvu_connected) {
153
- //------------------------------------------------------------------------------------------------------------------
154
- if ($request->getParam('sun') == 'dismiss' || $cookies->get('sun_cookie') == 'dismiss') {
155
- //------------------------------------------------------------------------------------------------------------------
156
- $cookies->set('sun_cookie', 'dismiss');
157
- //------------------------------------------------------------------------------------------------------------------
158
- }
159
- else {
160
- //------------------------------------------------------------------------------------------------------------------
161
- $buttons = '<a href="'.$this->getUrl($o_configuration_url).'">'.Mage::helper('catalog')->__('Update your key').'</a>
162
- <a href="mailto:dev@orbitvu.com" onclick="this.target=\'_blank\';">'.Mage::helper('catalog')->__('Contact Orbitvu').'</a>';
163
- //------------------------------------------------------------------------------------------------------------------
164
- $orbitvu_popup = $this->genPopup(
165
- Mage::helper('catalog')->__('License Key is not valid'),
166
- Mage::helper('catalog')->__('Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.'),
167
- $buttons,
168
- $o_close_url,
169
- 'MAJOR'
170
- );
171
- //------------------------------------------------------------------------------------------------------------------
172
- }
173
- //------------------------------------------------------------------------------------------------------------------
174
- }
175
- //------------------------------------------------------------------------------------------------------------------
176
- // First time
177
- //------------------------------------------------------------------------------------------------------------------
178
- if (($observer->_Orbitvu->GetConfiguration('first_time') == 'true' && $display_first_time) || ($request->getParam('sun') == 'show_welcome' && $display_first_time) || $request->getParam('sun') == 'dismiss_welcome') {
179
- //------------------------------------------------------------------------------------------------------------------
180
- if ($request->getParam('sun') == 'dismiss_welcome') {
181
- //------------------------------------------------------------------------------------------------------------------
182
- $cookies->set('sun_cookie', 'dismiss');
183
-
184
- $observer->_Orbitvu->SetConfiguration('first_time', 'false');
185
- $observer->_Orbitvu->SetDemoAccessToken();
186
-
187
- $orbitvu_popup = '';
188
- //------------------------------------------------------------------------------------------------------------------
189
- }
190
- else {
191
- //------------------------------------------------------------------------------------------------------------------
192
- $orbitvu_popup = $this->genPopup(
193
- Mage::helper('catalog')->__('Orbitvu Extension Wizard'),
194
- '<strong>'.Mage::helper('catalog')->__('You need a <a href="http://orbitvu.co" target="_blank">Orbitvu SUN</a> account and License Key to use the extension.').'</strong> '.Mage::helper('catalog')->__('Choose an option:'),
195
- '<a href="'.$this->getUrl($o_configuration_url).'">'.Mage::helper('catalog')->__('Enter License Key').'</a>',
196
- $o_close_welcome_url,
197
- 'NOTICE',
198
- '',
199
- '2'
200
- );
201
- //------------------------------------------------------------------------------------------------------------------
202
- }
203
- //------------------------------------------------------------------------------------------------------------------
204
- }
205
-
206
- /*
207
- * Render Orbitvu buttons actions
208
- * <a href="javascript:if (confirm(\''.Mage::helper('catalog')->__('Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name? This operation will only be applied to not yet linked products.').'\')) { window.location.href = \''.$o_update_url.'\'; }'">
209
- */
210
- //------------------------------------------------------------------------------------------------------------------
211
- $this->addRssList(
212
- '></a>',
213
- '<span style="display: inline-block; position: relative; width: 1px; height: 16px; background: white;"><span style="position: absolute; left: -20px; top: 0; width: 20px; background: white; height: 20px; cursor: default;" onclick="return false;"></span></span>'.
214
- (!$orbitvu_connected ? '<a href="#" style="cursor: default;">' :
215
-
216
- '<a href="javascript:if (confirm(\''.Mage::helper('catalog')->__('Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?').' '.Mage::helper('catalog')->__('This operation will only be applied to not yet linked products.').'\')) { window.location.href = \''.$this->getUrl($o_update_url).'\'; }">'
217
-
218
- ).
219
-
220
- '<button type="button" '.(!$orbitvu_connected ?
221
-
222
- ' disabled="disabled" onclick="return false;" style="opacity: 0.5;" class="scalable orbitvu-button disabled disable"'
223
-
224
- :
225
-
226
- ' class="scalable orbitvu-button"'
227
-
228
- ).' title="'.Mage::helper('catalog')->__('Link Orbitvu SUN presentations to all products matched with SKU or name.').' '.Mage::helper('catalog')->__('This operation will only be applied to not yet linked products.').'" id="button_orbitvu_update"><span><span style="float: left; width: 16px; height: 16px; margin: 0 4px 0 0 !important; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png) !important; background-repeat: no-repeat; background-position: 0 -108px !important;"></span>'.Mage::helper('catalog')->__('Link Orbitvu SUN presentations').'</span></button>'.(!$orbitvu_connected ? '<a href="#">' : '').'');
229
- //------------------------------------------------------------------------------------------------------------------
230
- $this->addRssList($o_configuration_url, '<button type="button" class="scalable orbitvu-button" title="'.Mage::helper('catalog')->__('Orbitvu Configuration').'" id="button_orbitvu_configuration"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Configuration').'<span></span></span></button><script>document.getElementById(\'button_orbitvu_configuration\').parentNode.className = \'\';document.getElementById(\'button_orbitvu_update\').parentNode.className = \'\';
231
- window.onbeforeunload = function() {
232
- document.getElementById(\'orbitvu_postloader\').style.display = \'block\';
233
- }
234
- </script></a>'.$orbitvu_popup.'<div id="orbitvu_postloader">
235
- <div id="orbitvu_postloader_bg"></div>
236
- <div id="orbitvu_postloader_fg"><img src="'.Mage::getBaseUrl('media').'orbitvu/loader.gif" style="margin-top: 150px;" alt="" /></div>
237
- </div><style type="text/css">
238
- #orbitvu_postloader { display: none; }
239
- #orbitvu_postloader_bg { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 999998; background: white; opacity: 0.8; }
240
- #orbitvu_postloader_fg { position: fixed; width: 100%; top: 0; left: 0; z-index: 999999; text-align: center; }
241
- .orbitvu-button { border-color: #1191A6; background: #8dd5e0; background: -moz-linear-gradient(top, #8dd5e0 0%, #009cb5 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8dd5e0), color-stop(45%,#009cb5)); background: -webkit-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -o-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -ms-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: linear-gradient(to bottom, #8dd5e0 0%,#009cb5 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#8dd5e0\', endColorstr=\'#009cb5\',GradientType=0 ); }
242
- .orbitvu-button:hover { background: #ddfaff; background: -moz-linear-gradient(top, #ddfaff 0%, #15adc6 59%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ddfaff), color-stop(59%,#15adc6)); background: -webkit-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: -o-linear-gradient(top, #ddfaff 0%,#15adc6 59%);background: -ms-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: linear-gradient(to bottom, #ddfaff 0%,#15adc6 59%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#ddfaff\', endColorstr=\'#15adc6\',GradientType=0 ); }
243
- </style><a href="#">');
244
- //------------------------------------------------------------------------------------------------------------------
245
- return parent::_prepareColumns();
246
- //------------------------------------------------------------------------------------------------------------------
247
- }
248
-
249
- /*
250
- * Generate popup to own usage
251
- * Based on Magento default notification popup template
252
- * (unfortunately can't be used without this)
253
- * Not proud of this part of file... but other solution will be waiste of time
254
- */
255
- public function genPopup($header, $message, $buttons, $close_url = '#', $level = 'NOTICE', $icon_text = '', $tpl = '1') {
256
-
257
- $out = '
258
- <script type="text/javascript">
259
- //<![CDATA[
260
- var messagePopupClosed = false;
261
- function openMessagePopup() {
262
- var height = $(\'html-body\').getHeight();
263
- $(\'message-popup-window-mask\').setStyle({\'height\':height+\'px\'});
264
- toggleSelectsUnderBlock($(\'message-popup-window-mask\'), false);
265
- Element.show(\'message-popup-window-mask\');
266
- $(\'message-popup-window\').addClassName(\'show\');
267
- }
268
-
269
- function closeMessagePopup() {
270
- toggleSelectsUnderBlock($(\'message-popup-window-mask\'), true);
271
- Element.hide(\'message-popup-window-mask\');
272
- $(\'message-popup-window\').removeClassName(\'show\');
273
- messagePopupClosed = true;
274
- }
275
-
276
- Event.observe(window, \'load\', openMessagePopup);
277
- Event.observe(window, \'keyup\', function(evt) {
278
- if(messagePopupClosed) return;
279
- var code;
280
- if (evt.keyCode) code = evt.keyCode;
281
- else if (evt.which) code = evt.which;
282
- if (code == Event.KEY_ESC) {
283
- closeMessagePopup();
284
- }
285
- });
286
- //]]>
287
- </script>
288
- <div id="message-popup-window-mask" style="display:none;"></div>';
289
-
290
- if ($tpl == '1') {
291
- $out .= '
292
- <div id="message-popup-window" class="message-popup">
293
- <div class="message-popup-head">
294
- <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();"><span>'.Mage::helper('catalog')->__('close').'</span></a>
295
- <h2>'.$header.'</h2>
296
- </div>
297
- <div class="message-popup-content">
298
- <div class="message">
299
- <span class="message-icon message-error" style="background-image:url('.$this->getSeverityIconsUrl($level).');">'.$icon_text.'</span>
300
- <p class="message-text">'.$message.'</p>
301
- </div>
302
- <p class="read-more">
303
- '.$buttons.'
304
- </p>
305
- </div>
306
- </div>
307
- ';
308
- }
309
- else {
310
-
311
- $out .= '
312
- <div id="message-popup-window" class="message-popup">
313
- <div class="message-popup-head">
314
- <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();"><span>'.Mage::helper('catalog')->__('close').'</span></a>
315
- <h2>'.$header.'</h2>
316
- </div>
317
- <div class="message-popup-content">
318
- <div class="message" id="orbitvu_options">
319
- <p class="message-text" style="float: none; width: auto; min-height: 1px;">'.$message.'</p>
320
- <div style="clear: both; overflow: hidden; zoom: 1.0;">
321
- <div style="padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
322
- <p class="read-more" style="margin: 0; text-align: left;">
323
- <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('Try extension with DEMO account').'</a>
324
- <br />
325
- '.Mage::helper('catalog')->__('You get access to predefined set of 360&deg; presentations.').'
326
- </p>
327
- </div>
328
- <div style="padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
329
- <p class="read-more" style="margin: 0; text-align: left;">
330
- <a href="#" onclick="document.getElementById(\'orbitvu_options\').style.display = \'none\'; document.getElementById(\'orbitvu_html_register\').style.display = \'block\';">'.Mage::helper('catalog')->__('Register Orbitvu SUN FREE trial account').'</a>
331
- <br />
332
- '.Mage::helper('catalog')->__('Create and customize your own presentations.').'
333
- </p>
334
- </div>
335
- <div style="margin: 0 0 10px 0; padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
336
- <p class="read-more" style="margin: 0; text-align: left;">
337
- <a href="'.$this->getUrl('*/system_config/edit/section/orbitvu/').'">'.Mage::helper('catalog')->__('Enter License Key').'</a>
338
- <br />
339
- '.Mage::helper('catalog')->__('Connect to your Orbitvu SUN account.').'
340
- </p>
341
- </div>
342
- </div>
343
- <a href="http://orbitvu.co" target="_blank"><img src="'.Mage::getBaseUrl('media').'orbitvu/logo.png" style="float: right;" alt="" /></a>
344
- </div>
345
-
346
- <div class="message" id="orbitvu_html_register" style="display: none;">
347
- <p class="message-text" style="float: none; width: auto; min-height: 1px;">'.
348
- Mage::helper('catalog')->__('Creating new account is free. Just enter your e-mail address.').'<br />'.Mage::helper('catalog')->__('We will send you the password and generate trial License Key automaticaly.').'</p>
349
- <form action="'.$this->getUrl('*/catalog_product/index/sun/register').'" method="get">
350
- <div class="message-text" style="min-height: 1px; padding: 10px 0 10px 0;">
351
- <input id="orbitvu_register_email" type="text" name="orbitvu_register_email" placeholder="'.Mage::helper('catalog')->__('Enter your e-mail...').'" value="'.Mage::getStoreConfig('trans_email/ident_general/email').'" />
352
- <button type="submit" class="scalable orbitvu-button">'.Mage::helper('catalog')->__('Register').'</button>
353
- <button type="button" onclick="document.getElementById(\'orbitvu_options\').style.display = \'block\'; document.getElementById(\'orbitvu_html_register\').style.display = \'none\';" class="scalable back">'.Mage::helper('catalog')->__('Cancel').'</button>
354
- </div>
355
- </form>
356
- </div>
357
- </div>
358
- </div>
359
- ';
360
- }
361
- //------------------------------------------------------------------------------------------------------------------
362
- return $out;
363
- //------------------------------------------------------------------------------------------------------------------
364
- }
365
-
366
- }
367
-
368
  ?>
1
+ <?php
2
+
3
+ /**
4
+ * @category Orbitvu
5
+ * @package Orbitvu_Sun
6
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
7
+ * @license http://www.orbitvu.com/plugins/license
8
+ * @version 1.0.0
9
+ */
10
+ class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid {
11
+
12
+ const XML_SEVERITY_ICONS_URL_PATH = 'system/adminnotification/severity_icons_url';
13
+
14
+ /*
15
+ * Get column "Orbitvu"
16
+ * for products view
17
+ */
18
+ public function setCollection($collection) {
19
+ //------------------------------------------------------------------------------------------------------------------
20
+ //$store = $this->_getStore();
21
+ //------------------------------------------------------------------------------------------------------------------
22
+ /*if ($store->getId() && !isset($this->_joinAttributes['orbitvu_sun'])) {
23
+ $collection->joinAttribute(
24
+ 'orbitvu_sun', 'catalog_product/orbitvu_sun', 'entity_id', null, 'left', $store->getId()
25
+ );
26
+ }
27
+ else {
28
+ $collection->addAttributeToSelect('orbitvu_sun');
29
+ }*/
30
+ //------------------------------------------------------------------------------------------------------------------
31
+ parent::setCollection($collection);
32
+ //------------------------------------------------------------------------------------------------------------------
33
+ }
34
+
35
+ /*
36
+ * Don't know why Magento links this notification icons to external resources
37
+ * But OK...
38
+ */
39
+ public function getSeverityIconsUrl($icon_type = 'NOTICE') {
40
+ //------------------------------------------------------------------------------------------------------------------
41
+ $url = (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
42
+ .sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(), 'SEVERITY_'.$icon_type);
43
+ //------------------------------------------------------------------------------------------------------------------
44
+ return $url;
45
+ }
46
+
47
+ /*
48
+ * Render columns with our new one
49
+ * Also, add buttons "Link all presentations" and "Configuration"
50
+ */
51
+ protected function _prepareColumns() {
52
+ //------------------------------------------------------------------------------------------------------------------
53
+ $store = $this->_getStore();
54
+ $request = Mage::app()->getRequest();
55
+ $cookies = Mage::getModel('core/cookie');
56
+ //------------------------------------------------------------------------------------------------------------------
57
+ $observer = Mage::getSingleton('sun/observer');
58
+ $observer->ExtendOrbitvu();
59
+
60
+ $orbitvu_connected = $observer->_Orbitvu->IsConnected();
61
+ //------------------------------------------------------------------------------------------------------------------
62
+ $o_configuration_url = explode('/system_config/', $this->getUrl('*/system_config/edit/section/orbitvu/'));
63
+ $o_configuration_url = '*/system_config/'.$o_configuration_url[count($o_configuration_url)-1];
64
+
65
+ $o_update_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/update'));
66
+ $o_update_url = '*/catalog_product/'.$o_update_url[count($o_update_url)-1];
67
+
68
+ $o_close_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/dismiss'));
69
+ $o_close_url = '*/catalog_product/'.$o_close_url[count($o_close_url)-1];
70
+
71
+ $o_close_welcome_url = explode('/catalog_product/', $this->getUrl('*/catalog_product/index/sun/dismiss_welcome'));
72
+ $o_close_welcome_url = '*/catalog_product/'.$o_close_welcome_url[count($o_close_welcome_url)-1];
73
+
74
+ $display_first_time = true;
75
+ //------------------------------------------------------------------------------------------------------------------
76
+
77
+ /*
78
+ * Add column Orbitvu
79
+ */
80
+ //------------------------------------------------------------------------------------------------------------------
81
+ $this->addColumnAfter('orbitvu_sun', array(
82
+ 'header' => Mage::helper('catalog')->__('Orbitvu'),
83
+ 'type' => 'text',
84
+ 'width' => '100px',
85
+ 'renderer' => 'Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Gridrenderer',
86
+ 'index' => 'orbitvu_sun',
87
+ ), 'sku'
88
+ );
89
+ //------------------------------------------------------------------------------------------------------------------
90
+
91
+ /*
92
+ * SUN actions
93
+ */
94
+ //------------------------------------------------------------------------------------------------------------------
95
+ if (date('Y-m-d', strtotime($observer->_Orbitvu->GetConfiguration('last_refreshed'))) != date('Y-m-d')) {
96
+ $observer->_Orbitvu->SynchronizePresentationsItems();
97
+ }
98
+ //------------------------------------------------------------------------------------------------------------------
99
+ if ($request->getParam('sun') == 'update') {
100
+ $observer->SynchronizeAllProducts();
101
+ }
102
+ //------------------------------------------------------------------------------------------------------------------
103
+ else if ($request->getParam('sun') == 'register') {
104
+ $email = strip_tags($_GET['orbitvu_register_email']);
105
+
106
+ $response = $observer->_Orbitvu->CreateAccount($email);
107
+
108
+ if ($response->status == 'BAD') {
109
+ //------------------------------------------------------------------------------------------------------------------
110
+ $buttons = '<a href="'.$this->getUrl('*/catalog_product/index/').'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('OK').'</a>';
111
+ //------------------------------------------------------------------------------------------------------------------
112
+ $orbitvu_popup = $this->genPopup(
113
+ Mage::helper('catalog')->__('Error!'),
114
+ Mage::helper('catalog')->__($response->error),
115
+ $buttons,
116
+ '*/catalog_product/index/',
117
+ 'MAJOR'
118
+ );
119
+ //------------------------------------------------------------------------------------------------------------------
120
+ $display_first_time = false;
121
+ //------------------------------------------------------------------------------------------------------------------
122
+ }
123
+ else {
124
+ //------------------------------------------------------------------------------------------------------------------
125
+ $buttons = '<a href="'.$this->getUrl('*/catalog_product/index/').'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('OK').'</a>';
126
+ //------------------------------------------------------------------------------------------------------------------
127
+ $orbitvu_popup = $this->genPopup(
128
+ Mage::helper('catalog')->__('Your account was created!'),
129
+ Mage::helper('catalog')->__('Now you have your own account on Orbitvu SUN.<br />We sent your an email with details.').' <br /><strong>'.Mage::helper('catalog')->__('Your trial License Key was created and it\'s now in use.').'</strong>.',
130
+ $buttons,
131
+ '*/catalog_product/index/',
132
+ 'NOTICE'
133
+ );
134
+ //------------------------------------------------------------------------------------------------------------------
135
+ /*
136
+ * <br />Your login details:').'<br />'.Mage::helper('catalog')->__('Login:').' <strong>'.$response->email.'</strong><br />'.Mage::helper('catalog')->__('Password: ').' <strong>'.$response->password.'</strong><br />'.Mage::helper('catalog')->__('License key:').'<br /><strong>'.$response->key.'</strong>
137
+ *
138
+ */
139
+ $observer->_Orbitvu->SetConfiguration('first_time', 'false');
140
+ $display_first_time = false;
141
+ //------------------------------------------------------------------------------------------------------------------
142
+ }
143
+ }
144
+ //------------------------------------------------------------------------------------------------------------------
145
+
146
+ /*
147
+ * Orbitvu Pop-up
148
+ */
149
+ //------------------------------------------------------------------------------------------------------------------
150
+ // Disconnected error
151
+ //------------------------------------------------------------------------------------------------------------------
152
+ if (!$orbitvu_connected) {
153
+ //------------------------------------------------------------------------------------------------------------------
154
+ if ($request->getParam('sun') == 'dismiss' || $cookies->get('sun_cookie') == 'dismiss') {
155
+ //------------------------------------------------------------------------------------------------------------------
156
+ $cookies->set('sun_cookie', 'dismiss');
157
+ //------------------------------------------------------------------------------------------------------------------
158
+ }
159
+ else {
160
+ //------------------------------------------------------------------------------------------------------------------
161
+ $buttons = '<a href="'.$this->getUrl($o_configuration_url).'">'.Mage::helper('catalog')->__('Update your key').'</a>
162
+ <a href="mailto:dev@orbitvu.com" onclick="this.target=\'_blank\';">'.Mage::helper('catalog')->__('Contact Orbitvu').'</a>';
163
+ //------------------------------------------------------------------------------------------------------------------
164
+ $orbitvu_popup = $this->genPopup(
165
+ Mage::helper('catalog')->__('License Key is not valid'),
166
+ Mage::helper('catalog')->__('Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.'),
167
+ $buttons,
168
+ $o_close_url,
169
+ 'MAJOR'
170
+ );
171
+ //------------------------------------------------------------------------------------------------------------------
172
+ }
173
+ //------------------------------------------------------------------------------------------------------------------
174
+ }
175
+ //------------------------------------------------------------------------------------------------------------------
176
+ // First time
177
+ //------------------------------------------------------------------------------------------------------------------
178
+ if (($observer->_Orbitvu->GetConfiguration('first_time') == 'true' && $display_first_time) || ($request->getParam('sun') == 'show_welcome' && $display_first_time) || $request->getParam('sun') == 'dismiss_welcome') {
179
+ //------------------------------------------------------------------------------------------------------------------
180
+ if ($request->getParam('sun') == 'dismiss_welcome') {
181
+ //------------------------------------------------------------------------------------------------------------------
182
+ $cookies->set('sun_cookie', 'dismiss');
183
+
184
+ $observer->_Orbitvu->SetConfiguration('first_time', 'false');
185
+ $observer->_Orbitvu->SetDemoAccessToken();
186
+
187
+ $orbitvu_popup = '';
188
+ //------------------------------------------------------------------------------------------------------------------
189
+ }
190
+ else {
191
+ //------------------------------------------------------------------------------------------------------------------
192
+ $orbitvu_popup = $this->genPopup(
193
+ Mage::helper('catalog')->__('Orbitvu Extension Wizard'),
194
+ '<strong>'.Mage::helper('catalog')->__('You need a <a href="http://orbitvu.co" target="_blank">Orbitvu SUN</a> account and License Key to use the extension.').'</strong> '.Mage::helper('catalog')->__('Choose an option:'),
195
+ '<a href="'.$this->getUrl($o_configuration_url).'">'.Mage::helper('catalog')->__('Enter License Key').'</a>',
196
+ $o_close_welcome_url,
197
+ 'NOTICE',
198
+ '',
199
+ '2'
200
+ );
201
+ //------------------------------------------------------------------------------------------------------------------
202
+ }
203
+ //------------------------------------------------------------------------------------------------------------------
204
+ }
205
+
206
+ /*
207
+ * Render Orbitvu buttons actions
208
+ * <a href="javascript:if (confirm(\''.Mage::helper('catalog')->__('Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name? This operation will only be applied to not yet linked products.').'\')) { window.location.href = \''.$o_update_url.'\'; }'">
209
+ */
210
+ //------------------------------------------------------------------------------------------------------------------
211
+ $this->addRssList(
212
+ '></a>',
213
+ '<span style="display: inline-block; position: relative; width: 1px; height: 16px; background: white;"><span style="position: absolute; left: -20px; top: 0; width: 20px; background: white; height: 20px; cursor: default;" onclick="return false;"></span></span>'.
214
+ (!$orbitvu_connected ? '<a href="#" style="cursor: default;">' :
215
+
216
+ '<a href="javascript:if (confirm(\''.Mage::helper('catalog')->__('Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?').' '.Mage::helper('catalog')->__('This operation will only be applied to not yet linked products.').'\')) { window.location.href = \''.$this->getUrl($o_update_url).'\'; }">'
217
+
218
+ ).
219
+
220
+ '<button type="button" '.(!$orbitvu_connected ?
221
+
222
+ ' disabled="disabled" onclick="return false;" style="opacity: 0.5;" class="scalable orbitvu-button disabled disable"'
223
+
224
+ :
225
+
226
+ ' class="scalable orbitvu-button"'
227
+
228
+ ).' title="'.Mage::helper('catalog')->__('Link Orbitvu SUN presentations to all products matched with SKU or name.').' '.Mage::helper('catalog')->__('This operation will only be applied to not yet linked products.').'" id="button_orbitvu_update"><span><span style="float: left; width: 16px; height: 16px; margin: 0 4px 0 0 !important; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png) !important; background-repeat: no-repeat; background-position: 0 -108px !important;"></span>'.Mage::helper('catalog')->__('Link Orbitvu SUN presentations').'</span></button>'.(!$orbitvu_connected ? '<a href="#">' : '').'');
229
+ //------------------------------------------------------------------------------------------------------------------
230
+ $this->addRssList($o_configuration_url, '<button type="button" class="scalable orbitvu-button" title="'.Mage::helper('catalog')->__('Orbitvu Configuration').'" id="button_orbitvu_configuration"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Configuration').'<span></span></span></button><script>document.getElementById(\'button_orbitvu_configuration\').parentNode.className = \'\';document.getElementById(\'button_orbitvu_update\').parentNode.className = \'\';
231
+ window.onbeforeunload = function() {
232
+ document.getElementById(\'orbitvu_postloader\').style.display = \'block\';
233
+ }
234
+ </script></a>'.(isset($orbitvu_popup) ? $orbitvu_popup : '').'<div id="orbitvu_postloader">
235
+ <div id="orbitvu_postloader_bg"></div>
236
+ <div id="orbitvu_postloader_fg"><img src="'.Mage::getBaseUrl('media').'orbitvu/loader.gif" style="margin-top: 150px;" alt="" /></div>
237
+ </div><style type="text/css">
238
+ #orbitvu_postloader { display: none; }
239
+ #orbitvu_postloader_bg { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 999998; background: white; opacity: 0.8; }
240
+ #orbitvu_postloader_fg { position: fixed; width: 100%; top: 0; left: 0; z-index: 999999; text-align: center; }
241
+ .orbitvu-button { border-color: #1191A6; background: #8dd5e0; background: -moz-linear-gradient(top, #8dd5e0 0%, #009cb5 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8dd5e0), color-stop(45%,#009cb5)); background: -webkit-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -o-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -ms-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: linear-gradient(to bottom, #8dd5e0 0%,#009cb5 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#8dd5e0\', endColorstr=\'#009cb5\',GradientType=0 ); }
242
+ .orbitvu-button:hover { background: #ddfaff; background: -moz-linear-gradient(top, #ddfaff 0%, #15adc6 59%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ddfaff), color-stop(59%,#15adc6)); background: -webkit-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: -o-linear-gradient(top, #ddfaff 0%,#15adc6 59%);background: -ms-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: linear-gradient(to bottom, #ddfaff 0%,#15adc6 59%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#ddfaff\', endColorstr=\'#15adc6\',GradientType=0 ); }
243
+ </style><a href="#">');
244
+ //------------------------------------------------------------------------------------------------------------------
245
+ return parent::_prepareColumns();
246
+ //------------------------------------------------------------------------------------------------------------------
247
+ }
248
+
249
+ /*
250
+ * Generate popup to own usage
251
+ * Based on Magento default notification popup template
252
+ * (unfortunately can't be used without this)
253
+ * Not proud of this part of file... but other solution will be waiste of time
254
+ */
255
+ public function genPopup($header, $message, $buttons, $close_url = '#', $level = 'NOTICE', $icon_text = '', $tpl = '1') {
256
+
257
+ $out = '
258
+ <script type="text/javascript">
259
+ //<![CDATA[
260
+ var messagePopupClosed = false;
261
+ function openMessagePopup() {
262
+ var height = $(\'html-body\').getHeight();
263
+ $(\'message-popup-window-mask\').setStyle({\'height\':height+\'px\'});
264
+ toggleSelectsUnderBlock($(\'message-popup-window-mask\'), false);
265
+ Element.show(\'message-popup-window-mask\');
266
+ $(\'message-popup-window\').addClassName(\'show\');
267
+ }
268
+
269
+ function closeMessagePopup() {
270
+ toggleSelectsUnderBlock($(\'message-popup-window-mask\'), true);
271
+ Element.hide(\'message-popup-window-mask\');
272
+ $(\'message-popup-window\').removeClassName(\'show\');
273
+ messagePopupClosed = true;
274
+ }
275
+
276
+ Event.observe(window, \'load\', openMessagePopup);
277
+ Event.observe(window, \'keyup\', function(evt) {
278
+ if(messagePopupClosed) return;
279
+ var code;
280
+ if (evt.keyCode) code = evt.keyCode;
281
+ else if (evt.which) code = evt.which;
282
+ if (code == Event.KEY_ESC) {
283
+ closeMessagePopup();
284
+ }
285
+ });
286
+ //]]>
287
+ </script>
288
+ <div id="message-popup-window-mask" style="display:none;"></div>';
289
+
290
+ if ($tpl == '1') {
291
+ $out .= '
292
+ <div id="message-popup-window" class="message-popup">
293
+ <div class="message-popup-head">
294
+ <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();"><span>'.Mage::helper('catalog')->__('close').'</span></a>
295
+ <h2>'.$header.'</h2>
296
+ </div>
297
+ <div class="message-popup-content">
298
+ <div class="message">
299
+ <span class="message-icon message-error" style="background-image:url('.$this->getSeverityIconsUrl($level).');">'.$icon_text.'</span>
300
+ <p class="message-text">'.$message.'</p>
301
+ </div>
302
+ <p class="read-more">
303
+ '.$buttons.'
304
+ </p>
305
+ </div>
306
+ </div>
307
+ ';
308
+ }
309
+ else {
310
+
311
+ $out .= '
312
+ <div id="message-popup-window" class="message-popup">
313
+ <div class="message-popup-head">
314
+ <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();"><span>'.Mage::helper('catalog')->__('close').'</span></a>
315
+ <h2>'.$header.'</h2>
316
+ </div>
317
+ <div class="message-popup-content">
318
+ <div class="message" id="orbitvu_options">
319
+ <p class="message-text" style="float: none; width: auto; min-height: 1px;">'.$message.'</p>
320
+ <div style="clear: both; overflow: hidden; zoom: 1.0;">
321
+ <div style="padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
322
+ <p class="read-more" style="margin: 0; text-align: left;">
323
+ <a href="'.$this->getUrl($close_url).'" onclick="closeMessagePopup();">'.Mage::helper('catalog')->__('Try extension with DEMO account').'</a>
324
+ <br />
325
+ '.Mage::helper('catalog')->__('You get access to predefined set of 360&deg; presentations.').'
326
+ </p>
327
+ </div>
328
+ <div style="padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
329
+ <p class="read-more" style="margin: 0; text-align: left;">
330
+ <a href="#" onclick="document.getElementById(\'orbitvu_options\').style.display = \'none\'; document.getElementById(\'orbitvu_html_register\').style.display = \'block\';">'.Mage::helper('catalog')->__('Register Orbitvu SUN FREE trial account').'</a>
331
+ <br />
332
+ '.Mage::helper('catalog')->__('Create and customize your own presentations.').'
333
+ </p>
334
+ </div>
335
+ <div style="margin: 0 0 10px 0; padding: 10px 0 10px 0; border-bottom: 1px dotted #f3bf8f;">
336
+ <p class="read-more" style="margin: 0; text-align: left;">
337
+ <a href="'.$this->getUrl('*/system_config/edit/section/orbitvu/').'">'.Mage::helper('catalog')->__('Enter License Key').'</a>
338
+ <br />
339
+ '.Mage::helper('catalog')->__('Connect to your Orbitvu SUN account.').'
340
+ </p>
341
+ </div>
342
+ </div>
343
+ <a href="http://orbitvu.co" target="_blank"><img src="'.Mage::getBaseUrl('media').'orbitvu/logo.png" style="float: right;" alt="" /></a>
344
+ </div>
345
+
346
+ <div class="message" id="orbitvu_html_register" style="display: none;">
347
+ <p class="message-text" style="float: none; width: auto; min-height: 1px;">'.
348
+ Mage::helper('catalog')->__('Creating new account is free. Just enter your e-mail address.').'<br />'.Mage::helper('catalog')->__('We will send you the password and generate trial License Key automaticaly.').'</p>
349
+ <form action="'.$this->getUrl('*/catalog_product/index/sun/register').'" method="get">
350
+ <div class="message-text" style="min-height: 1px; padding: 10px 0 10px 0;">
351
+ <input id="orbitvu_register_email" type="text" name="orbitvu_register_email" placeholder="'.Mage::helper('catalog')->__('Enter your e-mail...').'" value="'.Mage::getStoreConfig('trans_email/ident_general/email').'" />
352
+ <button type="submit" class="scalable orbitvu-button">'.Mage::helper('catalog')->__('Register').'</button>
353
+ <button type="button" onclick="document.getElementById(\'orbitvu_options\').style.display = \'block\'; document.getElementById(\'orbitvu_html_register\').style.display = \'none\';" class="scalable back">'.Mage::helper('catalog')->__('Cancel').'</button>
354
+ </div>
355
+ </form>
356
+ </div>
357
+ </div>
358
+ </div>
359
+ ';
360
+ }
361
+ //------------------------------------------------------------------------------------------------------------------
362
+ return $out;
363
+ //------------------------------------------------------------------------------------------------------------------
364
+ }
365
+
366
+ }
367
+
368
  ?>
app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Gridrenderer.php CHANGED
@@ -1,105 +1,105 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Gridrenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
11
-
12
- /*
13
- * Render cell value for column "Orbitvu"
14
- * No time and no need for external CSS etc.
15
- */
16
- public function render(Varien_Object $row) {
17
- //------------------------------------------------------------------------------------------------------------------
18
- $product_id = $row->getId();
19
- //------------------------------------------------------------------------------------------------------------------
20
- $request = Mage::app()->getRequest();
21
- $observer = Mage::getSingleton('sun/observer');
22
- $_Orbitvu = $observer->ExtendOrbitvu();
23
- //------------------------------------------------------------------------------------------------------------------
24
- $presentation = $_Orbitvu->GetProductPresentation($product_id);
25
- $types = $presentation['types'];
26
- //------------------------------------------------------------------------------------------------------------------
27
- $out = '<div style="width: 100px; min-height: 16px; text-align: center; clear: both; overflow: hidden; zoom: 1.0; position: relative;">';
28
- //------------------------------------------------------------------------------------------------------------------
29
- $dot = ' display; block; position: absolute; top: 0; left: 0; width: 16px; height: 17px; background-repeat: no-repeat; ';
30
- //------------------------------------------------------------------------------------------------------------------
31
- /*
32
- * Linked icon
33
- * Presentation thumbnail
34
- * Presentation types icon
35
- */
36
- if ($presentation['id'] > 0) {
37
- //------------------------------------------------------------------------------------------------------------------
38
- $thumbnail = $presentation['items'][0]['thumbnail'];
39
- foreach ($presentation['items'] as $item) {
40
- if ($item['status'] == 'active') {
41
- $thumbnail = $item['thumbnail'];
42
- break;
43
- }
44
- }
45
- //------------------------------------------------------------------------------------------------------------------
46
- $out .= '<div style="width: 100%; height: 100%; background: white; clear: both; overflow: hidden; zoom: 1.0; border-radius: 5px;"><span style="'.$dot.' background-position: 0 -108px; background-color: rgba(255, 255, 255, 0.5); border-bottom-right-radius: 5px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/blue.png);" title="'.$this->__('Linked').'"></span>
47
-
48
- <div style="clear: both; overflow: hidden; zoom: 1.0;"><img src="'.$thumbnail.'?max_width=100&max_height=50" style="max-width: 100px; border-radius: 5px; border: 2px solid white;" alt="" /></div>';
49
-
50
- $out .= '<div style="position: absolute; bottom: 0; right: 0;">';
51
- //------------------------------------------------------------------------------------------------------------------
52
- foreach ($types as $type) {
53
- //------------------------------------------------------------------------------------------------------------------
54
- switch ($type) {
55
- case '0':
56
- $text = $this->__('Orbittour');
57
- $bg = '0 -92px';
58
- break;
59
- case '1':
60
- $text = $this->__('360&deg;');
61
- $bg = '-80px -108px';
62
- break;
63
- default:
64
- $text = $this->__('2D');
65
- $bg = '-16px -92px';
66
- break;
67
- }
68
-
69
- $out .= '
70
- <span style="float: left; width: 16px; height: 16px; margin: 0 -2px -2px 4px; background-position: '.$bg.'; background-color: rgba(255, 255, 255, 0.5); background-image: url('.Mage::getBaseUrl('media').'orbitvu/blue.png); background-repeat: no-repeat; border-radius: 5px; border: 2px solid white;" class="orbitvu_tooltip" title="'.$text.'"></span>
71
- ';
72
- //------------------------------------------------------------------------------------------------------------------
73
- }
74
- //------------------------------------------------------------------------------------------------------------------
75
- $out .= '</div></div>';
76
- }
77
- else {
78
- //------------------------------------------------------------------------------------------------------------------
79
- /*
80
- * Unlinked icon
81
- */
82
- if ($_Orbitvu->IsProductUnlinked($product_id)) {
83
- //------------------------------------------------------------------------------------------------------------------
84
- $out .= '<span style="'.$dot.' background-position: -16px -108px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/black.png);" title="'.$this->__('Unlinked').'"></span>';
85
- //------------------------------------------------------------------------------------------------------------------
86
- }
87
- /*
88
- * Not linked icon
89
- */
90
- else {
91
- //------------------------------------------------------------------------------------------------------------------
92
- $out .= '<span style="'.$dot.' background-position: -16px -108px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/black.png);" title="'.$this->__('Not linked').'"></span>';
93
- //------------------------------------------------------------------------------------------------------------------
94
- }
95
- //------------------------------------------------------------------------------------------------------------------
96
- }
97
- //------------------------------------------------------------------------------------------------------------------
98
- $out .= '</div>';
99
-
100
- return $out;
101
- //------------------------------------------------------------------------------------------------------------------
102
- }
103
-
104
- }
105
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Gridrenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
11
+
12
+ /*
13
+ * Render cell value for column "Orbitvu"
14
+ * No time and no need for external CSS etc.
15
+ */
16
+ public function render(Varien_Object $row) {
17
+ //------------------------------------------------------------------------------------------------------------------
18
+ $product_id = $row->getId();
19
+ //------------------------------------------------------------------------------------------------------------------
20
+ $request = Mage::app()->getRequest();
21
+ $observer = Mage::getSingleton('sun/observer');
22
+ $_Orbitvu = $observer->ExtendOrbitvu();
23
+ //------------------------------------------------------------------------------------------------------------------
24
+ $presentation = $_Orbitvu->GetProductPresentation($product_id);
25
+ $types = $presentation['types'];
26
+ //------------------------------------------------------------------------------------------------------------------
27
+ $out = '<div style="width: 100px; min-height: 16px; text-align: center; clear: both; overflow: hidden; zoom: 1.0; position: relative;">';
28
+ //------------------------------------------------------------------------------------------------------------------
29
+ $dot = ' display; block; position: absolute; top: 0; left: 0; width: 16px; height: 17px; background-repeat: no-repeat; ';
30
+ //------------------------------------------------------------------------------------------------------------------
31
+ /*
32
+ * Linked icon
33
+ * Presentation thumbnail
34
+ * Presentation types icon
35
+ */
36
+ if ($presentation['id'] > 0) {
37
+ //------------------------------------------------------------------------------------------------------------------
38
+ $thumbnail = $presentation['items'][0]['thumbnail'];
39
+ foreach ($presentation['items'] as $item) {
40
+ if ($item['status'] == 'active') {
41
+ $thumbnail = $item['thumbnail'];
42
+ break;
43
+ }
44
+ }
45
+ //------------------------------------------------------------------------------------------------------------------
46
+ $out .= '<div style="width: 100%; height: 100%; background: white; clear: both; overflow: hidden; zoom: 1.0; border-radius: 5px;"><span style="'.$dot.' background-position: 0 -108px; background-color: rgba(255, 255, 255, 0.5); border-bottom-right-radius: 5px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/blue.png);" title="'.$this->__('Linked').'"></span>
47
+
48
+ <div style="clear: both; overflow: hidden; zoom: 1.0;"><img src="'.$thumbnail.'?max_width=100&max_height=50" style="max-width: 100px; border-radius: 5px; border: 2px solid white;" alt="" /></div>';
49
+
50
+ $out .= '<div style="position: absolute; bottom: 0; right: 0;">';
51
+ //------------------------------------------------------------------------------------------------------------------
52
+ foreach ($types as $type) {
53
+ //------------------------------------------------------------------------------------------------------------------
54
+ switch ($type) {
55
+ case '0':
56
+ $text = $this->__('Orbittour');
57
+ $bg = '0 -92px';
58
+ break;
59
+ case '1':
60
+ $text = $this->__('360&deg;');
61
+ $bg = '-80px -108px';
62
+ break;
63
+ default:
64
+ $text = $this->__('2D');
65
+ $bg = '-16px -92px';
66
+ break;
67
+ }
68
+
69
+ $out .= '
70
+ <span style="float: left; width: 16px; height: 16px; margin: 0 -2px -2px 4px; background-position: '.$bg.'; background-color: rgba(255, 255, 255, 0.5); background-image: url('.Mage::getBaseUrl('media').'orbitvu/blue.png); background-repeat: no-repeat; border-radius: 5px; border: 2px solid white;" class="orbitvu_tooltip" title="'.$text.'"></span>
71
+ ';
72
+ //------------------------------------------------------------------------------------------------------------------
73
+ }
74
+ //------------------------------------------------------------------------------------------------------------------
75
+ $out .= '</div></div>';
76
+ }
77
+ else {
78
+ //------------------------------------------------------------------------------------------------------------------
79
+ /*
80
+ * Unlinked icon
81
+ */
82
+ if ($_Orbitvu->IsProductUnlinked($product_id)) {
83
+ //------------------------------------------------------------------------------------------------------------------
84
+ $out .= '<span style="'.$dot.' background-position: -16px -108px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/black.png);" title="'.$this->__('Unlinked').'"></span>';
85
+ //------------------------------------------------------------------------------------------------------------------
86
+ }
87
+ /*
88
+ * Not linked icon
89
+ */
90
+ else {
91
+ //------------------------------------------------------------------------------------------------------------------
92
+ $out .= '<span style="'.$dot.' background-position: -16px -108px; background-image: url('.Mage::getBaseUrl('media').'orbitvu/black.png);" title="'.$this->__('Not linked').'"></span>';
93
+ //------------------------------------------------------------------------------------------------------------------
94
+ }
95
+ //------------------------------------------------------------------------------------------------------------------
96
+ }
97
+ //------------------------------------------------------------------------------------------------------------------
98
+ $out .= '</div>';
99
+
100
+ return $out;
101
+ //------------------------------------------------------------------------------------------------------------------
102
+ }
103
+
104
+ }
105
  ?>
app/code/community/Orbitvu/Sun/Block/Adminhtml/Tabs.php CHANGED
@@ -1,35 +1,35 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Adminhtml_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs {
11
-
12
- private $parent;
13
-
14
- /*
15
- * Add new custom tab "Orbitvu" to admin panel
16
- */
17
- protected function _prepareLayout() {
18
- //------------------------------------------------------------------------------------------------------------------
19
- $this->parent = parent::_prepareLayout();
20
-
21
- $request = Mage::app()->getRequest();
22
- $product_id = $request->getParam('id');
23
-
24
- if ($product_id > 0) {
25
- $this->addTab('tabid', array(
26
- 'label' => Mage::helper('catalog')->__('Orbitvu SUN'),
27
- 'content' => $this->getLayout()->createBlock('sun/adminhtml_tabs_tabid')->toHtml()
28
- ));
29
- }
30
- //------------------------------------------------------------------------------------------------------------------
31
- return $this->parent;
32
- //------------------------------------------------------------------------------------------------------------------
33
- }
34
- }
35
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Adminhtml_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs {
11
+
12
+ private $parent;
13
+
14
+ /*
15
+ * Add new custom tab "Orbitvu" to admin panel
16
+ */
17
+ protected function _prepareLayout() {
18
+ //------------------------------------------------------------------------------------------------------------------
19
+ $this->parent = parent::_prepareLayout();
20
+
21
+ $request = Mage::app()->getRequest();
22
+ $product_id = $request->getParam('id');
23
+
24
+ if ($product_id > 0) {
25
+ $this->addTab('tabid', array(
26
+ 'label' => Mage::helper('catalog')->__('Orbitvu SUN'),
27
+ 'content' => $this->getLayout()->createBlock('sun/adminhtml_tabs_tabid')->toHtml()
28
+ ));
29
+ }
30
+ //------------------------------------------------------------------------------------------------------------------
31
+ return $this->parent;
32
+ //------------------------------------------------------------------------------------------------------------------
33
+ }
34
+ }
35
  ?>
app/code/community/Orbitvu/Sun/Block/Adminhtml/Tabs/Tabid.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Adminhtml_Tabs_Tabid extends Mage_Adminhtml_Block_Widget {
11
-
12
- /*
13
- * Set template "orbitvu.phtml" right ahead!
14
- */
15
- public function __construct() {
16
- //------------------------------------------------------------------------------------------------------------------
17
- parent::__construct();
18
-
19
- $this->setTemplate('sun/orbitvu.phtml');
20
- //------------------------------------------------------------------------------------------------------------------
21
- }
22
- }
23
-
24
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Adminhtml_Tabs_Tabid extends Mage_Adminhtml_Block_Widget {
11
+
12
+ /*
13
+ * Set template "orbitvu.phtml" right ahead!
14
+ */
15
+ public function __construct() {
16
+ //------------------------------------------------------------------------------------------------------------------
17
+ parent::__construct();
18
+
19
+ $this->setTemplate('sun/orbitvu.phtml');
20
+ //------------------------------------------------------------------------------------------------------------------
21
+ }
22
+ }
23
+
24
  ?>
app/code/community/Orbitvu/Sun/Block/Delay.php CHANGED
@@ -1,55 +1,55 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Delay
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuDelayOptions() {
17
- return array(
18
- '0' => Mage::helper('adminhtml')->__('No delay'),
19
- '1' => Mage::helper('adminhtml')->__('0,1 second'),
20
- '2' => Mage::helper('adminhtml')->__('0,2 second'),
21
- '3' => Mage::helper('adminhtml')->__('0,3 second'),
22
- '4' => Mage::helper('adminhtml')->__('0,4 second'),
23
- '5' => Mage::helper('adminhtml')->__('half a second')
24
- );
25
- }
26
-
27
- /**
28
- * Options getter
29
- *
30
- * @return array
31
- */
32
- public function toOptionArray() {
33
- $array = $this->OrbitvuDelayOptions();
34
-
35
- $ret = array();
36
- foreach ($array as $key => $value) {
37
- $ret[] = array(
38
- 'value' => $key,
39
- 'label' => $value
40
- );
41
- }
42
-
43
- return $ret;
44
- }
45
-
46
- /**
47
- * Get options in "key-value" format
48
- *
49
- * @return array
50
- */
51
- public function toArray() {
52
- return $this->OrbitvuDelayOptions();
53
- }
54
- }
55
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Delay
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuDelayOptions() {
17
+ return array(
18
+ '0' => Mage::helper('adminhtml')->__('No delay'),
19
+ '1' => Mage::helper('adminhtml')->__('0,1 second'),
20
+ '2' => Mage::helper('adminhtml')->__('0,2 second'),
21
+ '3' => Mage::helper('adminhtml')->__('0,3 second'),
22
+ '4' => Mage::helper('adminhtml')->__('0,4 second'),
23
+ '5' => Mage::helper('adminhtml')->__('half a second')
24
+ );
25
+ }
26
+
27
+ /**
28
+ * Options getter
29
+ *
30
+ * @return array
31
+ */
32
+ public function toOptionArray() {
33
+ $array = $this->OrbitvuDelayOptions();
34
+
35
+ $ret = array();
36
+ foreach ($array as $key => $value) {
37
+ $ret[] = array(
38
+ 'value' => $key,
39
+ 'label' => $value
40
+ );
41
+ }
42
+
43
+ return $ret;
44
+ }
45
+
46
+ /**
47
+ * Get options in "key-value" format
48
+ *
49
+ * @return array
50
+ */
51
+ public function toArray() {
52
+ return $this->OrbitvuDelayOptions();
53
+ }
54
+ }
55
  ?>
app/code/community/Orbitvu/Sun/Block/Html5.php CHANGED
@@ -1,51 +1,51 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Html5
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuHtml5Options() {
17
- return array(
18
- 'yes' => Mage::helper('adminhtml')->__('Always use HTML5'),
19
- 'no' => Mage::helper('adminhtml')->__('Use Flash if available, otherwise use HTML5')
20
- );
21
- }
22
-
23
- /**
24
- * Options getter
25
- *
26
- * @return array
27
- */
28
- public function toOptionArray() {
29
- $array = $this->OrbitvuHtml5Options();
30
-
31
- $ret = array();
32
- foreach ($array as $key => $value) {
33
- $ret[] = array(
34
- 'value' => $key,
35
- 'label' => $value
36
- );
37
- }
38
-
39
- return $ret;
40
- }
41
-
42
- /**
43
- * Get options in "key-value" format
44
- *
45
- * @return array
46
- */
47
- public function toArray() {
48
- return $this->OrbitvuHtml5Options();
49
- }
50
- }
51
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Html5
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuHtml5Options() {
17
+ return array(
18
+ 'yes' => Mage::helper('adminhtml')->__('Always use HTML5'),
19
+ 'no' => Mage::helper('adminhtml')->__('Use Flash if available, otherwise use HTML5')
20
+ );
21
+ }
22
+
23
+ /**
24
+ * Options getter
25
+ *
26
+ * @return array
27
+ */
28
+ public function toOptionArray() {
29
+ $array = $this->OrbitvuHtml5Options();
30
+
31
+ $ret = array();
32
+ foreach ($array as $key => $value) {
33
+ $ret[] = array(
34
+ 'value' => $key,
35
+ 'label' => $value
36
+ );
37
+ }
38
+
39
+ return $ret;
40
+ }
41
+
42
+ /**
43
+ * Get options in "key-value" format
44
+ *
45
+ * @return array
46
+ */
47
+ public function toArray() {
48
+ return $this->OrbitvuHtml5Options();
49
+ }
50
+ }
51
  ?>
app/code/community/Orbitvu/Sun/Block/KeyComment.php CHANGED
@@ -1,20 +1,20 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_KeyComment
11
- {
12
- /**
13
- * Parsed comment text
14
- * @return type string
15
- */
16
- public function getCommentText() {
17
- return Mage::helper('catalog')->__('You need <a href="http://orbitvu.co" target="_blank">Orbitvu SUN</a> account and License Key to use Orbitvu extension.').'<br />'.'<a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'">'.Mage::helper('catalog')->__('Register').'</a> '.Mage::helper('catalog')->__('trial account or').' <a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'">'.Mage::helper('catalog')->__('use DEMO License Key').'</a>.';
18
- }
19
- }
20
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_KeyComment
11
+ {
12
+ /**
13
+ * Parsed comment text
14
+ * @return type string
15
+ */
16
+ public function getCommentText() {
17
+ return Mage::helper('catalog')->__('You need <a href="http://orbitvu.co" target="_blank">Orbitvu SUN</a> account and License Key to use Orbitvu extension.').'<br />'.'<a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'">'.Mage::helper('catalog')->__('Register').'</a> '.Mage::helper('catalog')->__('trial account or').' <a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'">'.Mage::helper('catalog')->__('use DEMO License Key').'</a>.';
18
+ }
19
+ }
20
  ?>
app/code/community/Orbitvu/Sun/Block/Orbittour.php CHANGED
@@ -1,53 +1,53 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Orbittour
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuOrbittourOptions() {
17
- return array(
18
- 'right_views' => Mage::helper('adminhtml')->__('Views to the right'),
19
- 'default' => Mage::helper('adminhtml')->__('Views at the bottom'),
20
- 'noviews' => Mage::helper('adminhtml')->__('No views'),
21
- 'sun' => Mage::helper('adminhtml')->__('Use Orbitvu SUN setting')
22
- );
23
- }
24
-
25
- /**
26
- * Options getter
27
- *
28
- * @return array
29
- */
30
- public function toOptionArray() {
31
- $array = $this->OrbitvuOrbittourOptions();
32
-
33
- $ret = array();
34
- foreach ($array as $key => $value) {
35
- $ret[] = array(
36
- 'value' => $key,
37
- 'label' => $value
38
- );
39
- }
40
-
41
- return $ret;
42
- }
43
-
44
- /**
45
- * Get options in "key-value" format
46
- *
47
- * @return array
48
- */
49
- public function toArray() {
50
- return $this->OrbitvuOrbittourOptions();
51
- }
52
- }
53
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Orbittour
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuOrbittourOptions() {
17
+ return array(
18
+ 'right_views' => Mage::helper('adminhtml')->__('Views to the right'),
19
+ 'default' => Mage::helper('adminhtml')->__('Views at the bottom'),
20
+ 'noviews' => Mage::helper('adminhtml')->__('No views'),
21
+ 'sun' => Mage::helper('adminhtml')->__('Use Orbitvu SUN setting')
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Options getter
27
+ *
28
+ * @return array
29
+ */
30
+ public function toOptionArray() {
31
+ $array = $this->OrbitvuOrbittourOptions();
32
+
33
+ $ret = array();
34
+ foreach ($array as $key => $value) {
35
+ $ret[] = array(
36
+ 'value' => $key,
37
+ 'label' => $value
38
+ );
39
+ }
40
+
41
+ return $ret;
42
+ }
43
+
44
+ /**
45
+ * Get options in "key-value" format
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray() {
50
+ return $this->OrbitvuOrbittourOptions();
51
+ }
52
+ }
53
  ?>
app/code/community/Orbitvu/Sun/Block/Product/View/Media.php CHANGED
@@ -1,13 +1,13 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media {
11
-
12
- }
13
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media {
11
+
12
+ }
13
  ?>
app/code/community/Orbitvu/Sun/Block/Scroll.php CHANGED
@@ -1,51 +1,51 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_SelfHosted
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Scroll
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuScrollOptions() {
17
- return array(
18
- 'yes' => Mage::helper('adminhtml')->__('Enable thumbnails scroll'),
19
- 'no' => Mage::helper('adminhtml')->__('Display thumbnails inline (without scroll)')
20
- );
21
- }
22
-
23
- /**
24
- * Options getter
25
- *
26
- * @return array
27
- */
28
- public function toOptionArray() {
29
- $array = $this->OrbitvuScrollOptions();
30
-
31
- $ret = array();
32
- foreach ($array as $key => $value) {
33
- $ret[] = array(
34
- 'value' => $key,
35
- 'label' => $value
36
- );
37
- }
38
-
39
- return $ret;
40
- }
41
-
42
- /**
43
- * Get options in "key-value" format
44
- *
45
- * @return array
46
- */
47
- public function toArray() {
48
- return $this->OrbitvuScrollOptions();
49
- }
50
- }
51
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_SelfHosted
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Scroll
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuScrollOptions() {
17
+ return array(
18
+ 'yes' => Mage::helper('adminhtml')->__('Enable thumbnails scroll'),
19
+ 'no' => Mage::helper('adminhtml')->__('Display thumbnails inline (without scroll)')
20
+ );
21
+ }
22
+
23
+ /**
24
+ * Options getter
25
+ *
26
+ * @return array
27
+ */
28
+ public function toOptionArray() {
29
+ $array = $this->OrbitvuScrollOptions();
30
+
31
+ $ret = array();
32
+ foreach ($array as $key => $value) {
33
+ $ret[] = array(
34
+ 'value' => $key,
35
+ 'label' => $value
36
+ );
37
+ }
38
+
39
+ return $ret;
40
+ }
41
+
42
+ /**
43
+ * Get options in "key-value" format
44
+ *
45
+ * @return array
46
+ */
47
+ public function toArray() {
48
+ return $this->OrbitvuScrollOptions();
49
+ }
50
+ }
51
  ?>
app/code/community/Orbitvu/Sun/Block/Syncsku.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Syncsku
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuSyncskuOptions() {
17
- return array(
18
- 'false' => Mage::helper('adminhtml')->__('Disable'),
19
- 'true_ifempty' => Mage::helper('adminhtml')->__('Enable, if remote SKU is empty'),
20
- 'true' => Mage::helper('adminhtml')->__('Enable')
21
- );
22
- }
23
-
24
- /**
25
- * Options getter
26
- *
27
- * @return array
28
- */
29
- public function toOptionArray() {
30
- $array = $this->OrbitvuSyncskuOptions();
31
-
32
- $ret = array();
33
- foreach ($array as $key => $value) {
34
- $ret[] = array(
35
- 'value' => $key,
36
- 'label' => $value
37
- );
38
- }
39
-
40
- return $ret;
41
- }
42
-
43
- /**
44
- * Get options in "key-value" format
45
- *
46
- * @return array
47
- */
48
- public function toArray() {
49
- return $this->OrbitvuSyncskuOptions();
50
- }
51
- }
52
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Syncsku
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuSyncskuOptions() {
17
+ return array(
18
+ 'false' => Mage::helper('adminhtml')->__('Disable'),
19
+ 'true_ifempty' => Mage::helper('adminhtml')->__('Enable, if remote SKU is empty'),
20
+ 'true' => Mage::helper('adminhtml')->__('Enable')
21
+ );
22
+ }
23
+
24
+ /**
25
+ * Options getter
26
+ *
27
+ * @return array
28
+ */
29
+ public function toOptionArray() {
30
+ $array = $this->OrbitvuSyncskuOptions();
31
+
32
+ $ret = array();
33
+ foreach ($array as $key => $value) {
34
+ $ret[] = array(
35
+ 'value' => $key,
36
+ 'label' => $value
37
+ );
38
+ }
39
+
40
+ return $ret;
41
+ }
42
+
43
+ /**
44
+ * Get options in "key-value" format
45
+ *
46
+ * @return array
47
+ */
48
+ public function toArray() {
49
+ return $this->OrbitvuSyncskuOptions();
50
+ }
51
+ }
52
  ?>
app/code/community/Orbitvu/Sun/Block/Teaser.php CHANGED
@@ -1,55 +1,55 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Block_Teaser
11
- {
12
-
13
- /*
14
- * Options list
15
- */
16
- public function OrbitvuTeaserOptions() {
17
- return array(
18
- 'autorotate' => Mage::helper('adminhtml')->__('Auto-rotation'),
19
- 'play' => Mage::helper('adminhtml')->__('Play button enables rotation'),
20
- 'static' => Mage::helper('adminhtml')->__('No teaser (static presentation)'),
21
- 'onerotation' => Mage::helper('adminhtml')->__('Quick single rotation (make sense only if 360 presentation is your first gallery item)'),
22
- 'onerotationslow' => Mage::helper('adminhtml')->__('Slow single rotation (make sense only if 360 presentation is your first gallery item)'),
23
- 'sun' => Mage::helper('adminhtml')->__('Use Orbitvu SUN setting')
24
- );
25
- }
26
-
27
- /**
28
- * Options getter
29
- *
30
- * @return array
31
- */
32
- public function toOptionArray() {
33
- $array = $this->OrbitvuTeaserOptions();
34
-
35
- $ret = array();
36
- foreach ($array as $key => $value) {
37
- $ret[] = array(
38
- 'value' => $key,
39
- 'label' => $value
40
- );
41
- }
42
-
43
- return $ret;
44
- }
45
-
46
- /**
47
- * Get options in "key-value" format
48
- *
49
- * @return array
50
- */
51
- public function toArray() {
52
- return $this->OrbitvuTeaserOptions();
53
- }
54
- }
55
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Block_Teaser
11
+ {
12
+
13
+ /*
14
+ * Options list
15
+ */
16
+ public function OrbitvuTeaserOptions() {
17
+ return array(
18
+ 'autorotate' => Mage::helper('adminhtml')->__('Auto-rotation'),
19
+ 'play' => Mage::helper('adminhtml')->__('Play button enables rotation'),
20
+ 'static' => Mage::helper('adminhtml')->__('No teaser (static presentation)'),
21
+ 'onerotation' => Mage::helper('adminhtml')->__('Quick single rotation (make sense only if 360 presentation is your first gallery item)'),
22
+ 'onerotationslow' => Mage::helper('adminhtml')->__('Slow single rotation (make sense only if 360 presentation is your first gallery item)'),
23
+ 'sun' => Mage::helper('adminhtml')->__('Use Orbitvu SUN setting')
24
+ );
25
+ }
26
+
27
+ /**
28
+ * Options getter
29
+ *
30
+ * @return array
31
+ */
32
+ public function toOptionArray() {
33
+ $array = $this->OrbitvuTeaserOptions();
34
+
35
+ $ret = array();
36
+ foreach ($array as $key => $value) {
37
+ $ret[] = array(
38
+ 'value' => $key,
39
+ 'label' => $value
40
+ );
41
+ }
42
+
43
+ return $ret;
44
+ }
45
+
46
+ /**
47
+ * Get options in "key-value" format
48
+ *
49
+ * @return array
50
+ */
51
+ public function toArray() {
52
+ return $this->OrbitvuTeaserOptions();
53
+ }
54
+ }
55
  ?>
app/code/community/Orbitvu/Sun/Helper/Data.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- class Orbitvu_Sun_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
  }
1
+ <?php
2
+ class Orbitvu_Sun_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
  }
app/code/community/Orbitvu/Sun/Model/Observer.php CHANGED
@@ -1,228 +1,250 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Model_Observer {
11
- // Mark as Singleton (for Magento)
12
- static protected $_singletonFlag = false;
13
-
14
- public $_Orbitvu;
15
- //-------------------------------------------------------------------------------------------------------
16
- public function ExtendOrbitvu($return = true) {
17
- $no = strpos(dirname((__FILE__)), "Orbitvu".DIRECTORY_SEPARATOR."Sun");
18
- $dir = substr(dirname(__FILE__), 0, $no ? $no : strlen(dirname(__FILE__)));
19
- $helpers = $dir.DIRECTORY_SEPARATOR."Orbitvu".DIRECTORY_SEPARATOR."Sun".DIRECTORY_SEPARATOR."controllers".DIRECTORY_SEPARATOR."OrbitvuAdmin.php";
20
- include_once($helpers);
21
-
22
- /*$helpers = __DIR__.'/../controllers/OrbitvuAdmin.php';
23
- include_once($helpers);*/
24
-
25
- $this->_Orbitvu = new OrbitvuAdmin(false);
26
-
27
- //-------------------------------------------------------------------------------------------------------
28
- if ($return) {
29
- return $this->_Orbitvu;
30
- }
31
- //-------------------------------------------------------------------------------------------------------
32
- }
33
- //-------------------------------------------------------------------------------------------------------
34
- /*
35
- * Synchronize one thumbnail
36
- */
37
- public function UpdateThumbnails($product_id) {
38
- //-------------------------------------------------------------------------------------------------------
39
- $this->ExtendOrbitvu();
40
- //-------------------------------------------------------------------------------------------------------
41
- $CurrentProduct = Mage::getModel('catalog/product')->load($product_id);
42
- $ProductHelper = Mage::helper('catalog/product');
43
- $medias = $CurrentProduct->getMediaGalleryImages();
44
- $orbithumbs = $this->_Orbitvu->GetProductThumbnails($product_id);
45
- //-------------------------------------------------------------------------------------------------------
46
- $o_thumbs_count = intval(count($orbithumbs)); // = 1 or 0
47
- $m_thumbs_count = intval(count($medias));
48
- $n = $m_thumbs_count - $o_thumbs_count;
49
- //-------------------------------------------------------------------------------------------------------
50
- if ($o_thumbs_count > 0) {
51
- $this->DeleteThumbnail($product_id, $orbithumbs[0]);
52
- $o_thumbs_count = 0;
53
- }
54
- //-------------------------------------------------------------------------------------------------------
55
- if ($m_thumbs_count > 1 && $o_thumbs_count == 0) {
56
- // magento own images - do nothing
57
- }
58
- else if ($o_thumbs_count == 0 && $m_thumbs_count == 0) {
59
- //-------------------------------------------------------------------------------------------------------
60
- try {
61
- $new_thumbnail = $this->AddThumbnail($product_id);
62
- if (!empty($new_thumbnail)) {
63
- $this->_Orbitvu->SetProductThumbnail($product_id, $new_thumbnail);
64
- }
65
- }
66
- catch (Exception $e) {}
67
- //-------------------------------------------------------------------------------------------------------
68
- }
69
- //-------------------------------------------------------------------------------------------------------
70
- return true;
71
- //-------------------------------------------------------------------------------------------------------
72
- }
73
- //-------------------------------------------------------------------------------------------------------
74
- /*
75
- * Add thumbnail
76
- */
77
- public function AddThumbnail($product_id) {
78
- //-------------------------------------------------------------------------------------------------------
79
- $presentation = $this->_Orbitvu->GetProductPresentation($product_id, true);
80
- //-------------------------------------------------------------------------------------------------------
81
- if (count($presentation['items']) <= 0) {
82
- return false;
83
- }
84
- //-------------------------------------------------------------------------------------------------------
85
- $file = 'http:'.$presentation['items'][0]['thumbnail'];
86
-
87
- if (stristr($file, '.png')) {
88
- $ext = 'png';
89
- }
90
- else {
91
- $ext = 'jpeg';
92
- }
93
- //-------------------------------------------------------------------------------------------------------
94
- $sun = file_get_contents($file);
95
- //-------------------------------------------------------------------------------------------------------
96
- $media_api = Mage::getModel('catalog/product_attribute_media_api');
97
- //-------------------------------------------------------------------------------------------------------
98
- $newImage = array(
99
- 'file' => array(
100
- 'name' => md5(date('H:i:s Y-m-d').'Orbitvu Thumbnail'.mt_rand(0, 999999)),
101
- 'content' => base64_encode($sun),
102
- 'mime' => 'image/'.$ext
103
- ),
104
- 'label' => 'Orbitvu Thumbnail',
105
- 'position' => 1,
106
- 'types' => array('thumbnail', 'small_image', 'image'),
107
- 'exclude' => 1
108
- );
109
- //-------------------------------------------------------------------------------------------------------
110
- return $media_api->create($product_id, $newImage);
111
- //-------------------------------------------------------------------------------------------------------
112
- }
113
- //-------------------------------------------------------------------------------------------------------
114
- /*
115
- * Delete thumbnail
116
- */
117
- public function DeleteThumbnail($product_id, $orbitvu_entry) {
118
- //-------------------------------------------------------------------------------------------------------
119
- $mediaApi = Mage::getModel('catalog/product_attribute_media_api');
120
- $items = $mediaApi->items($product_id);
121
- $this->_Orbitvu->DeleteProductThumbnail($product_id);
122
- //-------------------------------------------------------------------------------------------------------
123
- foreach ($items as $item) {
124
- if ($item['file'] == $orbitvu_entry['thumbnail']) {
125
- $mediaApi->remove($product_id, $item['file']);
126
- $fileName = Mage::getBaseDir('media').'/catalog/product'.$item['file'];
127
-
128
- if (file_exists($fileName)) {
129
- unlink($fileName);
130
- }
131
- }
132
- }
133
- //-------------------------------------------------------------------------------------------------------
134
- }
135
- //-------------------------------------------------------------------------------------------------------
136
- /*
137
- * Synchronize thumbs
138
- */
139
- public function SynchronizeAllThumbnails() {
140
- //-------------------------------------------------------------------------------------------------------
141
- $storeId = Mage::app()->getStore()->getId();
142
- $product = Mage::getModel('catalog/product');
143
- //-------------------------------------------------------------------------------------------------------
144
- $products = $product->getCollection()
145
- ->addAttributeToSelect(array(
146
- 'name',
147
- 'sku'
148
- ))
149
- ->addAttributeToFilter('status', '1');
150
- //-------------------------------------------------------------------------------------------------------
151
- $products_array = array();
152
- foreach ($products as $q) {
153
- $this->UpdateThumbnails($q->getId());
154
- }
155
- //-------------------------------------------------------------------------------------------------------
156
- }
157
- //-------------------------------------------------------------------------------------------------------
158
- /*
159
- * Make synchronization
160
- */
161
- public function SynchronizeAllProducts() {
162
- //-------------------------------------------------------------------------------------------------------
163
- $products = $this->_Orbitvu->SynchronizeAllProducts();
164
- foreach ($products as $product) {
165
- $this->UpdateThumbnails($product['product_id']);
166
- }
167
- //-------------------------------------------------------------------------------------------------------
168
- }
169
- //-------------------------------------------------------------------------------------------------------
170
- /*
171
- * Simple redirect
172
- */
173
- public function RedirectAlias($url) {
174
- //-------------------------------------------------------------------------------------------------------
175
- $srv = Mage::getUrl($url);
176
- return Mage::app()->getResponse()->setHeader('Location', $srv)->sendHeaders();
177
- //-------------------------------------------------------------------------------------------------------
178
- }
179
- //-------------------------------------------------------------------------------------------------------
180
- /*
181
- * Own templates
182
- */
183
- public function UseTemplate($ar, $template) {
184
- //-------------------------------------------------------------------------------------------------------
185
- return $this->_Orbitvu->UseTemplate($ar, $template);
186
- //-------------------------------------------------------------------------------------------------------
187
- }
188
- //-------------------------------------------------------------------------------------------------------
189
- /*
190
- * Save product
191
- */
192
- public function saveProductTabData(Varien_Event_Observer $observer) {
193
- //-------------------------------------------------------------------------------------------------------
194
- if (!self::$_singletonFlag) {
195
- self::$_singletonFlag = true;
196
-
197
- //-------------------------------------------------------------------------------------------------------
198
- $this->ExtendOrbitvu();
199
- //-------------------------------------------------------------------------------------------------------
200
-
201
- /*
202
- * Update Orbitvu thumbnails
203
- */
204
- //-------------------------------------------------------------------------------------------------------
205
- if (Mage::app()->getRequest()->getParam('sun') != 'update') {
206
- if (is_object(Mage::registry('product'))) {
207
- $product_id = Mage::registry('product')->getId();
208
- $this->UpdateThumbnails($product_id);
209
- }
210
- }
211
- //-------------------------------------------------------------------------------------------------------
212
-
213
- /*
214
- * Force SUN synchro
215
- */
216
- //-------------------------------------------------------------------------------------------------------
217
- if (Mage::app()->getRequest()->getPost('synchronize_sun') == 'true') {
218
- //-------------------------------------------------------------------------------------------------------
219
- $this->SynchronizeAllProducts();
220
- //-------------------------------------------------------------------------------------------------------
221
- }
222
- //-------------------------------------------------------------------------------------------------------
223
- }
224
- //-------------------------------------------------------------------------------------------------------
225
- }
226
- }
227
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Model_Observer {
11
+ // Mark as Singleton (for Magento)
12
+ static protected $_singletonFlag = false;
13
+
14
+ public $_Orbitvu;
15
+ //-------------------------------------------------------------------------------------------------------
16
+ public function ExtendOrbitvu($return = true) {
17
+ $no = strpos(dirname((__FILE__)), "Orbitvu".DIRECTORY_SEPARATOR."Sun");
18
+ $dir = substr(dirname(__FILE__), 0, $no ? $no : strlen(dirname(__FILE__)));
19
+ $helpers = $dir.DIRECTORY_SEPARATOR."Orbitvu".DIRECTORY_SEPARATOR."Sun".DIRECTORY_SEPARATOR."controllers".DIRECTORY_SEPARATOR."OrbitvuAdmin.php";
20
+ include_once($helpers);
21
+
22
+ /*$helpers = __DIR__.'/../controllers/OrbitvuAdmin.php';
23
+ include_once($helpers);*/
24
+
25
+ $this->_Orbitvu = new OrbitvuAdmin(false);
26
+
27
+ //-------------------------------------------------------------------------------------------------------
28
+ if ($return) {
29
+ return $this->_Orbitvu;
30
+ }
31
+ //-------------------------------------------------------------------------------------------------------
32
+ }
33
+ //-------------------------------------------------------------------------------------------------------
34
+ /*
35
+ * Synchronize one thumbnail
36
+ */
37
+ public function UpdateThumbnails($product_id) {
38
+ //-------------------------------------------------------------------------------------------------------
39
+ $this->ExtendOrbitvu();
40
+ //-------------------------------------------------------------------------------------------------------
41
+ $CurrentProduct = Mage::getModel('catalog/product')->load($product_id);
42
+ $ProductHelper = Mage::helper('catalog/product');
43
+ $medias = $CurrentProduct->getMediaGallery();
44
+ $orbithumbs = $this->_Orbitvu->GetProductThumbnails($product_id);
45
+ //-------------------------------------------------------------------------------------------------------
46
+ $o_thumbs_count = intval(count($orbithumbs)); // = 1 or 0
47
+ $m_thumbs_count = intval(count($medias['images']));
48
+ $n = $m_thumbs_count - $o_thumbs_count;
49
+ //-------------------------------------------------------------------------------------------------------
50
+ /*if ($o_thumbs_count > 0) {
51
+ $this->DeleteThumbnail($product_id, $orbithumbs[0]);
52
+ $o_thumbs_count = 0;
53
+ }*/
54
+ //-------------------------------------------------------------------------------------------------------
55
+ if ($m_thumbs_count > 1 && $o_thumbs_count == 0) {
56
+ // magento own images - do nothing
57
+ }
58
+ else if ($o_thumbs_count == 0 && $m_thumbs_count == 0) {
59
+ //-------------------------------------------------------------------------------------------------------
60
+ try {
61
+ $new_thumbnail = $this->AddThumbnail($product_id);
62
+ if (!empty($new_thumbnail)) {
63
+ $this->_Orbitvu->SetProductThumbnail($product_id, $new_thumbnail);
64
+ }
65
+ }
66
+ catch (Exception $e) {}
67
+ //-------------------------------------------------------------------------------------------------------
68
+ }
69
+ //-------------------------------------------------------------------------------------------------------
70
+ return true;
71
+ //-------------------------------------------------------------------------------------------------------
72
+ }
73
+ //-------------------------------------------------------------------------------------------------------
74
+ /*
75
+ * Add thumbnail
76
+ */
77
+ public function AddThumbnail($product_id, $configurable_id = false) {
78
+ //-------------------------------------------------------------------------------------------------------
79
+ $presentation = $this->_Orbitvu->GetProductPresentation($configurable_id ? $configurable_id : $product_id, true);
80
+ //-------------------------------------------------------------------------------------------------------
81
+ if (count($presentation['items']) <= 0) {
82
+ return false;
83
+ }
84
+ //-------------------------------------------------------------------------------------------------------
85
+ $file = 'http:'.$presentation['items'][0]['thumbnail'];
86
+
87
+ if (stristr($file, '.png')) {
88
+ $ext = 'png';
89
+ }
90
+ else {
91
+ $ext = 'jpeg';
92
+ }
93
+ //-------------------------------------------------------------------------------------------------------
94
+ $sun = file_get_contents($file);
95
+ //-------------------------------------------------------------------------------------------------------
96
+ $media_api = Mage::getModel('catalog/product_attribute_media_api');
97
+ $pmodel = Mage::getModel('catalog/product');
98
+ $_product = $pmodel->load($product_id);
99
+ //-------------------------------------------------------------------------------------------------------
100
+ $newImage = array(
101
+ 'file' => array(
102
+ 'name' => md5(date('H:i:s Y-m-d').'Orbitvu Thumbnail'.mt_rand(0, 999999)),
103
+ 'content' => base64_encode($sun),
104
+ 'mime' => 'image/'.$ext
105
+ ),
106
+ 'label' => $_product->getName(),
107
+ 'position' => 1,
108
+ 'types' => array('thumbnail', 'small_image', 'image'),
109
+ 'exclude' => 1
110
+ );
111
+ //-------------------------------------------------------------------------------------------------------
112
+ return $media_api->create($product_id, $newImage);
113
+ //-------------------------------------------------------------------------------------------------------
114
+ }
115
+ //-------------------------------------------------------------------------------------------------------
116
+ /*
117
+ * Delete thumbnail
118
+ */
119
+ public function DeleteThumbnail($product_id, $orbitvu_entry) {
120
+ //-------------------------------------------------------------------------------------------------------
121
+ $mediaApi = Mage::getModel('catalog/product_attribute_media_api');
122
+ $items = $mediaApi->items($product_id);
123
+ $this->_Orbitvu->DeleteProductThumbnail($product_id);
124
+ //-------------------------------------------------------------------------------------------------------
125
+ foreach ($items as $item) {
126
+ if ($item['file'] == $orbitvu_entry['thumbnail']) {
127
+ $mediaApi->remove($product_id, $item['file']);
128
+ $fileName = Mage::getBaseDir('media').'/catalog/product'.$item['file'];
129
+
130
+ if (file_exists($fileName)) {
131
+ unlink($fileName);
132
+ }
133
+ }
134
+ }
135
+ //-------------------------------------------------------------------------------------------------------
136
+ }
137
+ //-------------------------------------------------------------------------------------------------------
138
+ /*
139
+ * Synchronize thumbs
140
+ */
141
+ public function SynchronizeAllThumbnails() {
142
+ //-------------------------------------------------------------------------------------------------------
143
+ $storeId = Mage::app()->getStore()->getId();
144
+ $product = Mage::getModel('catalog/product');
145
+ //-------------------------------------------------------------------------------------------------------
146
+ $products = $product->getCollection()
147
+ ->addAttributeToSelect(array(
148
+ 'name',
149
+ 'sku'
150
+ ))
151
+ ->addAttributeToFilter('status', '1');
152
+ //-------------------------------------------------------------------------------------------------------
153
+ $products_array = array();
154
+ foreach ($products as $q) {
155
+ $this->UpdateThumbnails($q->getId());
156
+ }
157
+ //-------------------------------------------------------------------------------------------------------
158
+ }
159
+ //-------------------------------------------------------------------------------------------------------
160
+ /*
161
+ * Make synchronization
162
+ */
163
+ public function SynchronizeAllProducts() {
164
+ //-------------------------------------------------------------------------------------------------------
165
+ $products = $this->_Orbitvu->SynchronizeAllProducts();
166
+ foreach ($products as $product) {
167
+ $this->UpdateThumbnails($product['product_id']);
168
+ }
169
+ //-------------------------------------------------------------------------------------------------------
170
+ }
171
+ //-------------------------------------------------------------------------------------------------------
172
+ /*
173
+ * Simple redirect
174
+ */
175
+ public function RedirectAlias($url) {
176
+ //-------------------------------------------------------------------------------------------------------
177
+ $srv = Mage::getUrl($url);
178
+ return Mage::app()->getResponse()->setHeader('Location', $srv)->sendHeaders();
179
+ //-------------------------------------------------------------------------------------------------------
180
+ }
181
+ //-------------------------------------------------------------------------------------------------------
182
+ /*
183
+ * Own templates
184
+ */
185
+ public function UseTemplate($ar, $template) {
186
+ //-------------------------------------------------------------------------------------------------------
187
+ return $this->_Orbitvu->UseTemplate($ar, $template);
188
+ //-------------------------------------------------------------------------------------------------------
189
+ }
190
+ //-------------------------------------------------------------------------------------------------------
191
+ /*
192
+ * Save product
193
+ */
194
+ public function saveProductTabData(Varien_Event_Observer $observer) {
195
+ //-------------------------------------------------------------------------------------------------------
196
+ if (!self::$_singletonFlag) {
197
+ self::$_singletonFlag = true;
198
+
199
+ //-------------------------------------------------------------------------------------------------------
200
+ $this->ExtendOrbitvu();
201
+ //-------------------------------------------------------------------------------------------------------
202
+
203
+ /*
204
+ * Update Orbitvu thumbnails
205
+ */
206
+ //-------------------------------------------------------------------------------------------------------
207
+ if (Mage::app()->getRequest()->getParam('sun') != 'update') {
208
+ if (is_object(Mage::registry('product'))) {
209
+ $product_id = Mage::registry('product')->getId();
210
+ $this->UpdateThumbnails($product_id);
211
+
212
+ /*
213
+ * (No) Assign images to associated products
214
+ */
215
+ if (Mage::registry('product')->isConfigurable()) {
216
+ $should_assign = (bool)Mage::app()->getRequest()->getParam('orbitvu_assign_configurable');
217
+ if ($should_assign) {
218
+ $associated = $this->_Orbitvu->GetAssociatedProducts(Mage::registry('product')->getId());
219
+ foreach($associated as $product) {
220
+ $pr = Mage::getModel('catalog/product')->load((int)$product['product_id']);
221
+ $pr->load('media_gallery');
222
+ $medias = $pr->getMediaGallery();
223
+ //-------------------------------------------------------------------------------------------------------
224
+ $m_thumbs_count = intval(count($medias['images']));
225
+ if ($m_thumbs_count <= 0) {
226
+ $this->AddThumbnail($product['product_id'], Mage::registry('product')->getId());
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }
233
+ //-------------------------------------------------------------------------------------------------------
234
+
235
+ /*
236
+ * Force SUN synchro
237
+ */
238
+ //-------------------------------------------------------------------------------------------------------
239
+ if (Mage::app()->getRequest()->getPost('synchronize_sun') == 'true') {
240
+ //-------------------------------------------------------------------------------------------------------
241
+ $this->SynchronizeAllProducts();
242
+ //-------------------------------------------------------------------------------------------------------
243
+ }
244
+ //-------------------------------------------------------------------------------------------------------
245
+ }
246
+ //-------------------------------------------------------------------------------------------------------
247
+ }
248
+ }
249
+
250
  ?>
app/code/community/Orbitvu/Sun/Model/Resource/Setup.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
11
-
12
- }
13
-
14
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
11
+
12
+ }
13
+
14
  ?>
app/code/community/Orbitvu/Sun/Model/Resource/Sun.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- class Orbitvu_Sun_Model_Sun extends Mage_Core_Model_Abstract {
11
-
12
- }
13
-
14
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ class Orbitvu_Sun_Model_Sun extends Mage_Core_Model_Abstract {
11
+
12
+ }
13
+
14
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php CHANGED
@@ -1,941 +1,949 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP Orbitvu eCommerce administration
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- */
6
-
7
- final class OrbitvuAdmin {
8
-
9
- /**
10
- * Database driver instance
11
- * @var instance
12
- */
13
- private $driver;
14
-
15
- /**
16
- * Is the extension connected?
17
- * @var bool
18
- */
19
- private $work = true;
20
-
21
- /**
22
- * Configuration vars and values
23
- * @var stdClass
24
- */
25
- public $Config;
26
-
27
- /**
28
- * SUN API connection instance
29
- * @var instance
30
- */
31
- public $Connect;
32
-
33
- /**
34
- * XML Handler
35
- * @var SimpleXMLElement
36
- */
37
- private $remote_xml;
38
-
39
- /**
40
- * Include all classes
41
- * @param boolean $debug Debug mode
42
- * @param boolean $test Unit tests mode
43
- * @param boolean $testinstance Unit tests instance.
44
- */
45
- public function __construct($debug = false, $test = false, $testinstance = false) {
46
- //-------------------------------------------------------------------------------------------------------
47
- require_once(__DIR__.'/OrbitvuDebugger.php');
48
- require_once(__DIR__.'/OrbitvuDatabaseInterface.php');
49
- require_once(__DIR__.'/OrbitvuConnect.php');
50
- //-------------------------------------------------------------------------------------------------------
51
- /*
52
- * Let's do the magic
53
- */
54
- //-------------------------------------------------------------------------------------------------------
55
- $this->driver = new OrbitvuDatabaseInterface('', $debug, $test, $testinstance);
56
- $this->Config = $this->driver->GetConfiguration();
57
- //-------------------------------------------------------------------------------------------------------
58
- $this->Connect = new Orbitvu($this->Config->access_token, $debug, $test, $testinstance);
59
- //-------------------------------------------------------------------------------------------------------
60
- $this->Connect->IntroduceYourself($this->driver->GetVersion());
61
- if (!$this->Connect->IsConnected()) {
62
- $this->work = false;
63
- }
64
- $this->Connect->ViewerPath = $this->Config->viewers_path;
65
- $this->Connect->DownloadPath = $this->Config->temp_path;
66
- $this->Connect->PresentationsPath = property_exists($this->Config, 'presentations_path') ? $this->Config->presentations_path : '';
67
- //-------------------------------------------------------------------------------------------------------
68
- $this->driver->SetSUNConnection($this->Connect);
69
- //-------------------------------------------------------------------------------------------------------
70
- }
71
-
72
- /**
73
- * Get presentations path
74
- * @return string
75
- */
76
- public function GetPresentationsPath() {
77
- //-------------------------------------------------------------------------------------------------------
78
- return $this->Connect->PresentationsPath;
79
- //-------------------------------------------------------------------------------------------------------
80
- }
81
-
82
- /**
83
- * Install presentation from file
84
- * @param string $file Presentation archive file (*.ovus, *.zip)
85
- * @param boolean $print_output Print console-like output messages
86
- * @return string
87
- */
88
- public function InstallPresentation($file, $print_output = true) {
89
- //-------------------------------------------------------------------------------------------------------
90
- return $this->Connect->InstallPresentation($file, $print_output);
91
- //-------------------------------------------------------------------------------------------------------
92
- }
93
-
94
- /**
95
- * Own simple, template parser.
96
- * Usign every store script template engine doesn't make practical sense.
97
- * Especially most of them doesn't have a template engine.
98
- * @param array $ar template array to replace in $template
99
- * @param string $template template
100
- * @return string
101
- */
102
- public function UseTemplate($ar, $template) {
103
- //-------------------------------------------------------------------------------------------------------
104
- $keys = array_map(function($str) {
105
- return '{'.$str.'}';
106
- }, array_keys($ar));
107
- //-------------------------------------------------------------------------------------------------------
108
- return str_replace($keys, array_values($ar), $template);
109
- //-------------------------------------------------------------------------------------------------------
110
- }
111
-
112
- /**
113
- * Register an account
114
- * @param string $email Email to register
115
- * @return stdClass
116
- */
117
- public function CreateAccount($email) {
118
- //-------------------------------------------------------------------------------------------------------
119
- try {
120
- //-------------------------------------------------------------------------------------------------------
121
- $account = $this->Connect->CreateAccount($email);
122
-
123
- $this->UpdateConfiguration('access_token', $account->key);
124
- //-------------------------------------------------------------------------------------------------------
125
- return $account;
126
- //-------------------------------------------------------------------------------------------------------
127
- }
128
- catch (Exception $e) {
129
- //-------------------------------------------------------------------------------------------------------
130
- $ret = new stdClass();
131
- $ret->error = $e->getMessage();
132
- $ret->status = 'BAD';
133
- //-------------------------------------------------------------------------------------------------------
134
- return $ret;
135
- //-------------------------------------------------------------------------------------------------------
136
- }
137
- //-------------------------------------------------------------------------------------------------------
138
- }
139
-
140
- /**
141
- * Renders XML content
142
- * @param SimpleXMLElement $xml
143
- */
144
- private function render_xml() {
145
- //----------------------------------------------------------------------
146
- header('Content-Type: text/xml; charset=utf-8');
147
- print $this->remote_xml->asXML();
148
- exit();
149
- //----------------------------------------------------------------------
150
- }
151
-
152
- /**
153
- * Authorization
154
- * @param $_POST['username'] @hidden
155
- * @param $_POST['password'] @hidden
156
- * @param object $ov_xml XML element
157
- * @return string
158
- */
159
- private function do_remote_authorize_action($ov_xml) {
160
- //----------------------------------------------------------------------
161
- if (count($_POST) > 0) {
162
- //-------------------------------------------------------------------------------------------------------
163
- if ($key = $this->Connect->LogInSun(filter_var($_POST['username']), filter_var($_POST['password']))) {
164
- if ($this->Connect->CheckAccessToken($key)) {
165
-
166
- /**
167
- * Generate token
168
- * Set cookie
169
- * Provide upload URL (expires)
170
- */
171
- //-------------------------------------------------------------------------------------------------------
172
- $token = md5(md5($_POST['username'].' '.$_POST['password'].' '.date('Y-m-d H:i:s').' '.mt_rand(1000, 10000)));
173
-
174
- session_start();
175
-
176
- $_SESSION['orbitvu_token'] = $token;
177
- setcookie('orbitvuid', $token, time()+3600*3);
178
- $upload_url = str_replace('&', '&amp;', $this->GetRemoteUploadUrl().'&ov_token='.$token);
179
- //-------------------------------------------------------------------------------------------------------
180
- $ov_xml->addChild('code', 0);
181
- $ov_xml->addChild('message', 'Authorization succeeded!');
182
- $ov_xml->addChild('data', $upload_url);
183
- //-------------------------------------------------------------------------------------------------------
184
- }
185
- else {
186
- //-------------------------------------------------------------------------------------------------------
187
- $ov_xml->addChild('code', 4);
188
- $ov_xml->addChild('message', 'Authorization failed. Permissions denied!');
189
- header('HTTP/1.0 401 Unauthorized');
190
- //-------------------------------------------------------------------------------------------------------
191
- }
192
- }
193
- else {
194
- //-------------------------------------------------------------------------------------------------------
195
- $ov_xml->addChild('code', 1);
196
- $ov_xml->addChild('message', 'Authorization failed. Wrong username/password!');
197
- header('HTTP/1.0 401 Unauthorized');
198
- //-------------------------------------------------------------------------------------------------------
199
- }
200
- }
201
- else {
202
- $ov_xml->addChild('code', 3);
203
- $ov_xml->addChild('message', 'Wrong HTTP method!');
204
- header('HTTP/1.0 501 Not implemented');
205
- }
206
-
207
- return $this->render_xml();
208
- //----------------------------------------------------------------------
209
- }
210
-
211
- /**
212
- * Upload
213
- * @param $_FILES['path'] @hidden
214
- * @param $_COOKIE['orbitvuid'] @hidden
215
- * @param $_SESSION['orbitvu_token'] @hidden
216
- * @param $_GET['ov_token'] @hidden
217
- * @param object $ov_xml XML handler
218
- * @return string
219
- */
220
- private function do_remote_upload_action($ov_xml) {
221
- //----------------------------------------------------------------------
222
- $no_errors = true;
223
-
224
- if (count($_POST) > 0 || count($_FILES) > 0) {
225
- if ($_SESSION['orbitvu_token'] != $_GET['ov_token']) {
226
- //-------------------------------------------------------------------------------------------------------
227
- $ov_xml->addChild('code', 2);
228
- $ov_xml->addChild('message', 'Authorization failed!');
229
- header('HTTP/1.0 401 Unauthorized');
230
- $no_errors = false;
231
- //-------------------------------------------------------------------------------------------------------
232
- }
233
- else if (!isset($_FILES['path']['tmp_name']) || (!stristr($_FILES['path']['name'], '.zip') && !stristr($_FILES['path']['name'], '.ovus'))) {
234
- //-------------------------------------------------------------------------------------------------------
235
- $ov_xml->addChild('code', 1);
236
- $ov_xml->addChild('message', 'Ovus file not provided or not valid!');
237
- header('HTTP/1.0 400 Bad request');
238
- $no_errors = false;
239
- //-------------------------------------------------------------------------------------------------------
240
- }
241
- else if (!$this->IsConnected()) {
242
- //-------------------------------------------------------------------------------------------------------
243
- $ov_xml->addChild('code', 6);
244
- $ov_xml->addChild('message', 'DEMO version - upload not permitted.');
245
- header('HTTP/1.0 401 Unauthorized');
246
- $no_errors = false;
247
- //-------------------------------------------------------------------------------------------------------
248
- }
249
- else {
250
- //----------------------------------------------------------------------
251
- $archive_name = $this->GetPresentationsPath().$_FILES['path']['name'];
252
- $file_contents = file_get_contents($file_contents);
253
-
254
- if (!empty($file_contents)) {
255
- //-------------------------------------------------------------------------------------------------------
256
- $ov_xml->addChild('code', 1);
257
- $ov_xml->addChild('message', 'Ovus file not valid!');
258
- header('HTTP/1.0 400 Bad request');
259
- $no_errors = false;
260
- //-------------------------------------------------------------------------------------------------------
261
- }
262
- else {
263
- try {
264
- if (copy($_FILES['path']['tmp_name'], $archive_name)) {
265
- //-------------------------------------------------------------------------------------------------------
266
- $this->InstallPresentation($archive_name, false);
267
- //-------------------------------------------------------------------------------------------------------
268
- $ov_xml->addChild('code', 0);
269
- $ov_xml->addChild('message', 'Upload succeed!');
270
- //-------------------------------------------------------------------------------------------------------
271
- setcookie('orbitvuid', '', time()-3600);
272
- unset($_SESSION['orbitvu_token']);
273
- $no_errors = false;
274
- //-------------------------------------------------------------------------------------------------------
275
- }
276
- else if ($_FILES['path']['error'] == '1') {
277
- //-------------------------------------------------------------------------------------------------------
278
- $ov_xml->addChild('code', 5);
279
- $ov_xml->addChild('message', 'No space available or file too big! Change `upload_max_filesize` value in your server php.ini file.');
280
- header('HTTP/1.0 400 Bad request');
281
- $no_errors = false;
282
- //-------------------------------------------------------------------------------------------------------
283
- }
284
- else {
285
- //-------------------------------------------------------------------------------------------------------
286
- $ov_xml->addChild('code', 4);
287
- $ov_xml->addChild('message', 'Upload error! Error code: '.intval($_FILES['path']['error']));
288
- header('HTTP/1.0 400 Bad request');
289
- $no_errors = false;
290
- //-------------------------------------------------------------------------------------------------------
291
- }
292
- }
293
- catch (Exception $e) {
294
- //-------------------------------------------------------------------------------------------------------
295
- $ov_xml->addChild('code', 4);
296
- $ov_xml->addChild('message', $e->getMessage());
297
- header('HTTP/1.0 400 Bad request');
298
- $no_errors = false;
299
- //-------------------------------------------------------------------------------------------------------
300
- }
301
- }
302
- //----------------------------------------------------------------------
303
- }
304
- }
305
- else {
306
- //-------------------------------------------------------------------------------------------------------
307
- $ov_xml->addChild('code', 3);
308
- $ov_xml->addChild('message', 'Wrong HTTP method!');
309
- header('HTTP/1.0 501 Not implemented');
310
- $no_errors = false;
311
- //-------------------------------------------------------------------------------------------------------
312
- }
313
- //----------------------------------------------------------------------
314
- if ($no_errors) {
315
- //-------------------------------------------------------------------------------------------------------
316
- $ov_xml->addChild('code', 4);
317
- $ov_xml->addChild('message', 'Other no permissions related error!');
318
- header('HTTP/1.0 401 Unauthorized');
319
- //-------------------------------------------------------------------------------------------------------
320
- }
321
- //----------------------------------------------------------------------
322
- return $this->render_xml();
323
- //----------------------------------------------------------------------
324
- }
325
-
326
- /**
327
- * Abstract layer for all remote actions for ALL platforms
328
- * @param $_GET['ov_key']
329
- * @param $_GET['ov_action']
330
- * @return type
331
- */
332
- public function StartRemoteListener() {
333
- //-------------------------------------------------------------------------------------------------------
334
- $this->remote_xml = new SimpleXMLElement('<ovs_response/>');
335
- //$ovs_response = $this->remote_xml->addChild('ovs_response');
336
- //-------------------------------------------------------------------------------------------------------
337
-
338
- /**
339
- * Security first
340
- */
341
- //-------------------------------------------------------------------------------------------------------
342
- if (!$_GET['ov_key'] || $_GET['ov_key'] != $this->GetLocalSessionKey()) {
343
-
344
- $this->remote_xml->addChild('code', 4);
345
- //$ovs_response->addChild('code', 4);
346
- $this->remote_xml->addChild('message', 'Authorization URL is not complete, not valid or expired.');
347
- //$ovs_response->addChild('message', 'Authorization URL is not complete, not valid or expired.');
348
- header('HTTP/1.0 401 Unauthorized');
349
-
350
- return $this->render_xml();
351
- }
352
- //-------------------------------------------------------------------------------------------------------
353
-
354
- /**
355
- * Session OK?
356
- * All right...
357
- */
358
- //-------------------------------------------------------------------------------------------------------
359
- if ($_GET['ov_action'] == 'upload') {
360
- //return $this->do_remote_upload_action($ovs_response);
361
- return $this->do_remote_upload_action($this->remote_xml);
362
-
363
- }
364
-
365
- //return $this->do_remote_authorize_action($ovs_response);
366
- return $this->do_remote_authorize_action($this->remote_xml);
367
- //-------------------------------------------------------------------------------------------------------
368
- }
369
-
370
- /**
371
- * Resize Image. Process image and generate other size in $target_path
372
- * @param string $file Original image file
373
- * @param integer|null $width New image width (null = auto)
374
- * @param integer|null $height New image height (null = auto)
375
- * @param string $target_path Output images path (cached processed versions)
376
- * @param string $scale_type[=crop] Scaling type crop|stretch|auto
377
- * @return string Path to new file
378
- */
379
- public function ResizeImage($file, $width = null, $height = null, $target_path = null, $scale_type = 'auto', $background = 'white') {
380
- //-------------------------------------------------------------------------------------------------------
381
- /**
382
- * Original file directory parsing
383
- */
384
- //-------------------------------------------------------------------------------------------------------
385
- $file_name = explode('/', $file);
386
- $file_name = $file_name[count($file_name)-1];
387
-
388
- if ($target_path === null) {
389
- $target_path = str_replace($file_name, '', $file);
390
- }
391
-
392
- $fname = $target_path.str_ireplace(array('.jpg', '.png', '.gif', '.jpeg'), '', $file_name);
393
-
394
- //-------------------------------------------------------------------------------------------------------
395
-
396
- /**
397
- * New dimensions
398
- */
399
- //-------------------------------------------------------------------------------------------------------
400
- if ($width === null) {
401
- $width = '*';
402
- }
403
- if ($height === null) {
404
- $height = '*';
405
- }
406
- //-------------------------------------------------------------------------------------------------------
407
-
408
- /**
409
- * Get image details
410
- * Create new image with proper type
411
- */
412
- //-------------------------------------------------------------------------------------------------------
413
- list($w, $h, $type) = getimagesize($file);
414
-
415
- switch ($type){
416
- case IMAGETYPE_GIF:
417
- $src_im = imagecreatefromgif($file);
418
- break;
419
- case IMAGETYPE_PNG:
420
- $src_im = imagecreatefrompng($file);
421
- break;
422
- default:
423
- $src_im = imagecreatefromjpeg($file);
424
- break;
425
- }
426
-
427
- /**
428
- * Image dimensions
429
- */
430
- //-------------------------------------------------------------------------------------------------------
431
- $tw = $width;
432
- $th = $height;
433
- if ($tw == '*') {
434
- $tw = $th / $h * $w;
435
- }
436
- if ($th == '*') {
437
- $th = $tw / $w * $h;
438
- }
439
-
440
- /**
441
- * Check if file already exists.
442
- * If so, return file path
443
- */
444
- //-------------------------------------------------------------------------------------------------------
445
- $final_path = $fname.'_'.round($tw).'_'.round($th).'.jpg';
446
-
447
- if (file_exists($final_path)) {
448
- return $final_path;
449
- }
450
-
451
- /**
452
- * Image resizing
453
- */
454
- //-------------------------------------------------------------------------------------------------------
455
- $dst_im = imagecreatetruecolor($tw, $th);
456
-
457
- if ($background == 'white') {
458
- $background = 16777215;
459
- }
460
- else {
461
- $background = 0;
462
- }
463
- imagefill($dst_im, 0, 0, $background);
464
-
465
- switch ($scale_type) {
466
- case 'crop':
467
- $nw = ceil($w / $h > $tw / $th ? $th * ($w / $h) : $tw);
468
- $nh = ceil($w / $h > $tw / $th ? $th : $tw / ($w / $h));
469
- $temp_gdim = imagecreatetruecolor($nw, $nh);
470
- imagecopyresampled($temp_gdim, $src_im, 0, 0, 0, 0, $nw, $nh, $w, $h);
471
- imagecopy($dst_im, $temp_gdim, 0, 0, ($nw - $tw) / 2, ($nh - $th) / 2, $tw, $th);
472
- imagedestroy($temp_gdim);
473
- break;
474
- case 'stretch':
475
- imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $tw, $th, $w, $h);
476
- break;
477
- default:
478
- $nw = ceil($w > $tw || $h > $th ? ($th < $tw ? $th / ($h / $w) : $tw) : $w);
479
- $nh = ceil($w > $tw || $h > $th ? ($th > $tw ? $tw * ($h / $w) : $th) : $h);
480
- imagecopyresampled($dst_im, $src_im, ($tw - $nw) / 2, ($th - $nh) / 2, 0, 0, $nw, $nh, $w, $h);
481
- break;
482
- }
483
- //-------------------------------------------------------------------------------------------------------
484
-
485
- /**
486
- * Use imagejpeg as one format and better quality
487
- */
488
- //-------------------------------------------------------------------------------------------------------
489
- imagejpeg($dst_im, $final_path, 100);
490
- imagedestroy($dst_im);
491
-
492
- if (!file_exists($final_path)) {
493
- throw new Exception('Orbitvu: Image file cannot be saved. Make sure you have set write permissions to parent directory of file: '.$final_path.'');
494
- }
495
- //-------------------------------------------------------------------------------------------------------
496
- return $final_path;
497
- //-------------------------------------------------------------------------------------------------------
498
- }
499
-
500
- /**
501
- * Set extension access token to default
502
- * @return boolean
503
- */
504
- public function SetDemoAccessToken() {
505
- //-------------------------------------------------------------------------------------------------------
506
- return $this->UpdateConfiguration('access_token', $this->Connect->GetDemoAccessToken());
507
- //-------------------------------------------------------------------------------------------------------
508
- }
509
-
510
- /**
511
- * Get presentation items types
512
- * @return array
513
- */
514
- public function GetPresentationTypes($result) {
515
- //-------------------------------------------------------------------------------------------------------
516
- $types = array();
517
- //-------------------------------------------------------------------------------------------------------
518
- if ($result->has_orbittour == 1) {
519
- $types[] = '0';
520
- }
521
- //-------------------------------------------------------------------------------------------------------
522
- for ($k = 0, $m = count($result->presentationcontent_set); $k < $m; $k++) {
523
- $cur_type = $result->presentationcontent_set[$k]->type;
524
-
525
- if (!in_array($cur_type, $types)) {
526
- $types[] = $cur_type;
527
- }
528
- }
529
- //-------------------------------------------------------------------------------------------------------
530
- rsort($types);
531
- //-------------------------------------------------------------------------------------------------------
532
- return $types;
533
- //-------------------------------------------------------------------------------------------------------
534
- }
535
-
536
- /**
537
- * Get product presentation items
538
- * @return array
539
- */
540
- public function GetProductPresentationItems($orbitvu_id) {
541
- //-------------------------------------------------------------------------------------------------------
542
- return $this->driver->GetProductPresentationItems($orbitvu_id);
543
- //-------------------------------------------------------------------------------------------------------
544
- }
545
-
546
- /**
547
- * Synchronize one product presentation
548
- * @return array
549
- */
550
- public function SynchronizeProductPresentation($product_id, $presentation_id, $presentation_name) {
551
- //-------------------------------------------------------------------------------------------------------
552
- $this->SetProductPresentation($product_id, $presentation_id, $presentation_name);
553
- $p_items = $this->GetProductPresentationItems($presentation_id, $this->GetConfiguration('sync_order'));
554
- $this->SetProductPresentationItems($product_id, $presentation_id, $presentation_name, $p_items);
555
- //-------------------------------------------------------------------------------------------------------
556
- return true;
557
- //-------------------------------------------------------------------------------------------------------
558
- }
559
-
560
- /**
561
- * Set SUN presentation SKU
562
- * @param type $presentation_id Presentation ID from database
563
- * @param type $new_sku Presentation new SKU
564
- * @param type $current_sku Presentation current SKU to update
565
- * @param boolean $update Force SKU update
566
- * @return boolean
567
- */
568
- public function SetSunPresentationSku($presentation_id, $new_sku, $current_sku, $update = false) {
569
- //-------------------------------------------------------------------------------------------------------
570
- if (!$update && (($this->GetConfiguration('auto_sync_sku') == 'true_ifempty' && empty($current_sku)) || $this->GetConfiguration('auto_sync_sku') == 'true')) {
571
- $update = true;
572
- }
573
- //-------------------------------------------------------------------------------------------------------
574
- if ($update) {
575
- return $this->Connect->CallSUN('presentations/'.$presentation_id.'/sku', array('sku' => $new_sku), true, true);
576
- }
577
- //-------------------------------------------------------------------------------------------------------
578
- return false;
579
- //-------------------------------------------------------------------------------------------------------
580
- }
581
-
582
- /**
583
- * Are we connected to the Orbitvu SUN?
584
- * @return bool
585
- */
586
- public function IsConnected() {
587
- //-------------------------------------------------------------------------------------------------------
588
- return $this->work;
589
- //-------------------------------------------------------------------------------------------------------
590
- }
591
-
592
- /**
593
- * Check for available updates
594
- * @return stdClass|boolean
595
- */
596
- public function CheckForUpdates() {
597
- //-------------------------------------------------------------------------------------------------------
598
- return $this->Connect->CheckForUpdates();
599
- //-------------------------------------------------------------------------------------------------------
600
- }
601
-
602
- /**
603
- * License days counter
604
- * @return integer
605
- */
606
- public function GetSupportDays() {
607
- //-------------------------------------------------------------------------------------------------------
608
- return $this->Connect->GetSupportDays();
609
- //-------------------------------------------------------------------------------------------------------
610
- }
611
-
612
- /**
613
- * Check if license is demo
614
- * @return boolean
615
- */
616
- public function IsDemo() {
617
- //-------------------------------------------------------------------------------------------------------
618
- return $this->Connect->IsDemo();
619
- //-------------------------------------------------------------------------------------------------------
620
- }
621
-
622
- //-------------------------------------------------------------------------------------------------------
623
- //-------------------------------------------------------------------------------------------------------
624
- //-------------------------------------------------------------------------------------------------------
625
- // Forward queries to included driver
626
- //-------------------------------------------------------------------------------------------------------
627
- //-------------------------------------------------------------------------------------------------------
628
- //-------------------------------------------------------------------------------------------------------
629
-
630
- /**
631
- * Update both extension and store configuration
632
- * @param string $var Configuration var to update
633
- * @param string $value New value
634
- * @return boolean
635
- */
636
- public function UpdateConfiguration($var, $value) {
637
- //-------------------------------------------------------------------------------------------------------
638
- $this->driver->SetConfiguration($var, $value);
639
- $this->driver->SetConfigurationParent($var, $value);
640
- //-------------------------------------------------------------------------------------------------------
641
- }
642
-
643
- /**
644
- * Clear Cache
645
- * @return boolean
646
- */
647
- public function ClearCache() {
648
- //-------------------------------------------------------------------------------------------------------
649
- return $this->driver->SetConfiguration('last_flushed_cache', date('Y-m-d'));
650
- //-------------------------------------------------------------------------------------------------------
651
- }
652
-
653
- /**
654
- * Use UpdateConfiguration if you want to update store configuration too
655
- * @param string $var Local configuration var to update
656
- * @param string $value Local new value
657
- * @return boolean
658
- */
659
- public function SetConfiguration($var, $value) {
660
- //-------------------------------------------------------------------------------------------------------
661
- return $this->driver->SetConfiguration($var, $value);
662
- //-------------------------------------------------------------------------------------------------------
663
- }
664
-
665
- /**
666
- * Switch presentation item priority
667
- * @param integer $product_id Store product ID from database
668
- * @param integer $item_id Current item ID from database
669
- * @param integer $item_id2 Item will be putted in order after this item
670
- * @return boolean
671
- */
672
- public function SwitchPresentationItemPriority($product_id, $item_id, $item_id2) {
673
- //-------------------------------------------------------------------------------------------------------
674
- return $this->driver->SwitchPresentationItemPriority($product_id, $item_id, $item_id2);
675
- //-------------------------------------------------------------------------------------------------------
676
- }
677
-
678
- /**
679
- * Get product presentation data
680
- * Get product presentation items
681
- * @param integer $product_id Store product ID from database
682
- * @param boolean $visible_only Return only items marked as visible
683
- * @return array
684
- */
685
- public function GetProductPresentation($product_id, $visible_only = false) {
686
- //-------------------------------------------------------------------------------------------------------
687
- return $this->driver->GetProductPresentation($product_id, $visible_only);
688
- //-------------------------------------------------------------------------------------------------------
689
- }
690
-
691
- /**
692
- * Set new product presentation
693
- * @param type $product_id Store product ID from database
694
- * @param type $orbitvu_id Orbitvu SUN presentation ID
695
- * @param type $orbitvu_name Orbitvu SUN presentation name
696
- * @return boolean
697
- */
698
- public function SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name = '') {
699
- //-------------------------------------------------------------------------------------------------------
700
- return $this->driver->SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name);
701
- //-------------------------------------------------------------------------------------------------------
702
- }
703
-
704
- /**
705
- * Set product presentation items
706
- * @param type $product_id Store product ID from database
707
- * @param type $orbitvu_id Orbitvu SUN presentation ID
708
- * @param type $orbitvu_name Orbitvu SUN presentation name
709
- * @param type $presentation_items Orbitvu SUN presentation items
710
- * @return type
711
- */
712
- public function SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items) {
713
- //-------------------------------------------------------------------------------------------------------
714
- return $this->driver->SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items);
715
- //-------------------------------------------------------------------------------------------------------
716
- }
717
-
718
- /**
719
- * Synchronize presentations
720
- * @param array $products_array Products array
721
- * @return boolean
722
- */
723
- public function SynchronizePresentations($products_array) {
724
- //-------------------------------------------------------------------------------------------------------
725
- return $this->driver->SynchronizePresentations($products_array);
726
- //-------------------------------------------------------------------------------------------------------
727
- }
728
-
729
- /**
730
- * Refresh presentations items
731
- * Delete non-existing on SUN
732
- * Add new from SUN
733
- * @return boolean
734
- */
735
- public function SynchronizePresentationsItems() {
736
- //-------------------------------------------------------------------------------------------------------
737
- return $this->driver->SynchronizePresentationsItems();
738
- //-------------------------------------------------------------------------------------------------------
739
- }
740
-
741
- /**
742
- * Is presentation unlinked?
743
- * @param integer $product_id Store product ID from database
744
- * @param integer $orbitvu_id Orbitvu SUN presentation ID
745
- * @return boolean
746
- */
747
- public function IsPresentationUnlinked($product_id, $orbitvu_id) {
748
- //-------------------------------------------------------------------------------------------------------
749
- return $this->driver->IsPresentationUnlinked($product_id, $orbitvu_id);
750
- //-------------------------------------------------------------------------------------------------------
751
- }
752
-
753
- /**
754
- * Is the product unlinked?
755
- * @param integer $product_id Store product ID from database
756
- * @return boolean
757
- */
758
- public function IsProductUnlinked($product_id) {
759
- //-------------------------------------------------------------------------------------------------------
760
- return $this->driver->IsProductUnlinked($product_id);
761
- //-------------------------------------------------------------------------------------------------------
762
- }
763
-
764
- /**
765
- * Unlink (free) presentation from product
766
- * @param integer $product_id Store product ID from database
767
- * @return boolean
768
- */
769
- public function FreeProduct($product_id) {
770
- //-------------------------------------------------------------------------------------------------------
771
- return $this->driver->FreeProduct($product_id);
772
- //-------------------------------------------------------------------------------------------------------
773
- }
774
-
775
- /**
776
- * Get configuration value from var
777
- * @param string $var Var from configuration
778
- * @return string
779
- */
780
- public function GetConfiguration($var) {
781
- //-------------------------------------------------------------------------------------------------------
782
- return $this->Config->$var;
783
- //-------------------------------------------------------------------------------------------------------
784
- }
785
-
786
- /**
787
- * Update item priority
788
- * @param integer $item_id Store product item ID from database
789
- * @param integer $new_priority New priority (order) value
790
- * @return boolean
791
- */
792
- public function UpdatePresentationItemPriority($item_id, $new_priority) {
793
- //-------------------------------------------------------------------------------------------------------
794
- return $this->driver->UpdatePresentationItemPriority($item_id, $new_priority);
795
- //-------------------------------------------------------------------------------------------------------
796
- }
797
-
798
- /**
799
- * Delete presentation item
800
- * @param integer $item_id Store product item ID from database
801
- * @return boolean
802
- */
803
- public function DeletePresentationItem($item_id) {
804
- //-------------------------------------------------------------------------------------------------------
805
- return $this->driver->DeletePresentationItem($item_id);
806
- //-------------------------------------------------------------------------------------------------------
807
- }
808
-
809
- /**
810
- * Have the product a presentation exists?
811
- * @param integer $product_id Store product ID from database
812
- * @return boolean
813
- */
814
- public function ExistsProductPresentation($product_id) {
815
- //-------------------------------------------------------------------------------------------------------
816
- return $this->driver->ExistsProductPresentation($product_id);
817
- //-------------------------------------------------------------------------------------------------------
818
- }
819
-
820
- /**
821
- * Search the presentation with name and SKU
822
- * @param array $product Product array with name and SKU
823
- * @return array|boolean
824
- */
825
- public function MatchPresentation($product) {
826
- //-------------------------------------------------------------------------------------------------------
827
- return $this->driver->MatchPresentation($product);
828
- //-------------------------------------------------------------------------------------------------------
829
- }
830
-
831
- /**
832
- * Update item visibility status
833
- * @param integer $item_id Store product item ID from database
834
- * @param string $status New item visibility status [active / inactive]
835
- * @return boolean
836
- */
837
- public function UpdatePresentationItemStatus($item_id, $status = 'inactive') {
838
- //-------------------------------------------------------------------------------------------------------
839
- return $this->driver->UpdatePresentationItemStatus($item_id, $status);
840
- //-------------------------------------------------------------------------------------------------------
841
- }
842
-
843
- /**
844
- * @see OrbitvuDatabaseDriver.php\GetLocalSessionKey()
845
- * @return string
846
- */
847
- public function GetLocalSessionKey() {
848
- //-------------------------------------------------------------------------------------------------------
849
- return $this->driver->GetLocalSessionKey();
850
- //-------------------------------------------------------------------------------------------------------
851
- }
852
-
853
- /**
854
- * @see OrbitvuDatabaseDriver.php\GetRemoteAuthorizationUrl()
855
- * @return string
856
- */
857
- public function GetRemoteAuthorizationUrl() {
858
- //-------------------------------------------------------------------------------------------------------
859
- return $this->driver->GetRemoteAuthorizationUrl();
860
- //-------------------------------------------------------------------------------------------------------
861
- }
862
-
863
- /**
864
- * @see OrbitvuDatabaseDriver.php\GetRemoteUploadUrl()
865
- * @return string
866
- */
867
- public function GetRemoteUploadUrl() {
868
- //-------------------------------------------------------------------------------------------------------
869
- return $this->driver->GetRemoteUploadUrl();
870
- //-------------------------------------------------------------------------------------------------------
871
- }
872
-
873
- /**
874
- * Install database tables
875
- * @return boolean
876
- */
877
- public function Install() {
878
- //-------------------------------------------------------------------------------------------------------
879
- return $this->driver->Install();
880
- //-------------------------------------------------------------------------------------------------------
881
- }
882
-
883
- /**
884
- * Get presentations from Orbitvu SUN
885
- * @param array $params Params for Orbitvu SUN filtering
886
- * @return stdClass
887
- */
888
- public function GetPresentationsList($params = false) {
889
- //-------------------------------------------------------------------------------------------------------
890
- return $this->driver->GetPresentationsList($params);
891
- //-------------------------------------------------------------------------------------------------------
892
- }
893
-
894
- /**
895
- * Get our store thumbnails
896
- * @param integer $product_id Store product ID from database
897
- * @return array
898
- */
899
- public function GetProductThumbnails($product_id) {
900
- //-------------------------------------------------------------------------------------------------------
901
- return $this->driver->GetProductThumbnails($product_id);
902
- //-------------------------------------------------------------------------------------------------------
903
- }
904
-
905
- /**
906
- * Set store thumbnail
907
- * @param integer $product_id Store product ID from database
908
- * @param string $thumbnail Thumbnail path
909
- * @return array
910
- */
911
- public function SetProductThumbnail($product_id, $thumbnail) {
912
- //-------------------------------------------------------------------------------------------------------
913
- return $this->driver->SetProductThumbnail($product_id, $thumbnail);
914
- //-------------------------------------------------------------------------------------------------------
915
- }
916
-
917
- /**
918
- * Delete store thumbnail
919
- * @param integer $product_id Store product ID from database
920
- * @param string $thumbnail Thumbnail path
921
- * @return array
922
- */
923
- public function DeleteProductThumbnail($product_id, $thumbnail = '') {
924
- //-------------------------------------------------------------------------------------------------------
925
- return $this->driver->DeleteProductThumbnail($product_id, $thumbnail);
926
- //-------------------------------------------------------------------------------------------------------
927
- }
928
-
929
- /**
930
- * Synchronization
931
- * @return boolean
932
- */
933
- public function SynchronizeAllProducts() {
934
- //-------------------------------------------------------------------------------------------------------
935
- return $this->driver->SynchronizeAllProducts();
936
- //-------------------------------------------------------------------------------------------------------
937
- }
938
-
939
- }
940
-
 
 
 
 
 
 
 
 
941
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP Orbitvu eCommerce administration
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ */
6
+
7
+ final class OrbitvuAdmin {
8
+
9
+ /**
10
+ * Database driver instance
11
+ * @var instance
12
+ */
13
+ private $driver;
14
+
15
+ /**
16
+ * Is the extension connected?
17
+ * @var bool
18
+ */
19
+ private $work = true;
20
+
21
+ /**
22
+ * Configuration vars and values
23
+ * @var stdClass
24
+ */
25
+ public $Config;
26
+
27
+ /**
28
+ * SUN API connection instance
29
+ * @var instance
30
+ */
31
+ public $Connect;
32
+
33
+ /**
34
+ * XML Handler
35
+ * @var SimpleXMLElement
36
+ */
37
+ private $remote_xml;
38
+
39
+ /**
40
+ * Include all classes
41
+ * @param boolean $debug Debug mode
42
+ * @param boolean $test Unit tests mode
43
+ * @param boolean $testinstance Unit tests instance.
44
+ */
45
+ public function __construct($debug = false, $test = false, $testinstance = false) {
46
+ //-------------------------------------------------------------------------------------------------------
47
+ require_once(__DIR__.'/OrbitvuDebugger.php');
48
+ require_once(__DIR__.'/OrbitvuDatabaseInterface.php');
49
+ require_once(__DIR__.'/OrbitvuConnect.php');
50
+ //-------------------------------------------------------------------------------------------------------
51
+ /*
52
+ * Let's do the magic
53
+ */
54
+ //-------------------------------------------------------------------------------------------------------
55
+ $this->driver = new OrbitvuDatabaseInterface('', $debug, $test, $testinstance);
56
+ $this->Config = $this->driver->GetConfiguration();
57
+ //-------------------------------------------------------------------------------------------------------
58
+ $this->Connect = new Orbitvu($this->Config->access_token, $debug, $test, $testinstance);
59
+ //-------------------------------------------------------------------------------------------------------
60
+ $this->Connect->IntroduceYourself($this->driver->GetVersion());
61
+ if (!$this->Connect->IsConnected()) {
62
+ $this->work = false;
63
+ }
64
+ $this->Connect->ViewerPath = $this->Config->viewers_path;
65
+ $this->Connect->DownloadPath = $this->Config->temp_path;
66
+ $this->Connect->PresentationsPath = property_exists($this->Config, 'presentations_path') ? $this->Config->presentations_path : '';
67
+ //-------------------------------------------------------------------------------------------------------
68
+ $this->driver->SetSUNConnection($this->Connect);
69
+ //-------------------------------------------------------------------------------------------------------
70
+ }
71
+
72
+ /**
73
+ * Get presentations path
74
+ * @return string
75
+ */
76
+ public function GetPresentationsPath() {
77
+ //-------------------------------------------------------------------------------------------------------
78
+ return $this->Connect->PresentationsPath;
79
+ //-------------------------------------------------------------------------------------------------------
80
+ }
81
+
82
+ /**
83
+ * Install presentation from file
84
+ * @param string $file Presentation archive file (*.ovus, *.zip)
85
+ * @param boolean $print_output Print console-like output messages
86
+ * @return string
87
+ */
88
+ public function InstallPresentation($file, $print_output = true) {
89
+ //-------------------------------------------------------------------------------------------------------
90
+ return $this->Connect->InstallPresentation($file, $print_output);
91
+ //-------------------------------------------------------------------------------------------------------
92
+ }
93
+
94
+ /**
95
+ * Own simple, template parser.
96
+ * Usign every store script template engine doesn't make practical sense.
97
+ * Especially most of them doesn't have a template engine.
98
+ * @param array $ar template array to replace in $template
99
+ * @param string $template template
100
+ * @return string
101
+ */
102
+ public function UseTemplate($ar, $template) {
103
+ //-------------------------------------------------------------------------------------------------------
104
+ $keys = array_map(function($str) {
105
+ return '{'.$str.'}';
106
+ }, array_keys($ar));
107
+ //-------------------------------------------------------------------------------------------------------
108
+ return str_replace($keys, array_values($ar), $template);
109
+ //-------------------------------------------------------------------------------------------------------
110
+ }
111
+
112
+ /**
113
+ * Register an account
114
+ * @param string $email Email to register
115
+ * @return stdClass
116
+ */
117
+ public function CreateAccount($email) {
118
+ //-------------------------------------------------------------------------------------------------------
119
+ try {
120
+ //-------------------------------------------------------------------------------------------------------
121
+ $account = $this->Connect->CreateAccount($email);
122
+
123
+ $this->UpdateConfiguration('access_token', $account->key);
124
+ //-------------------------------------------------------------------------------------------------------
125
+ return $account;
126
+ //-------------------------------------------------------------------------------------------------------
127
+ }
128
+ catch (Exception $e) {
129
+ //-------------------------------------------------------------------------------------------------------
130
+ $ret = new stdClass();
131
+ $ret->error = $e->getMessage();
132
+ $ret->status = 'BAD';
133
+ //-------------------------------------------------------------------------------------------------------
134
+ return $ret;
135
+ //-------------------------------------------------------------------------------------------------------
136
+ }
137
+ //-------------------------------------------------------------------------------------------------------
138
+ }
139
+
140
+ /**
141
+ * Renders XML content
142
+ * @param SimpleXMLElement $xml
143
+ */
144
+ private function render_xml() {
145
+ //----------------------------------------------------------------------
146
+ header('Content-Type: text/xml; charset=utf-8');
147
+ print $this->remote_xml->asXML();
148
+ exit();
149
+ //----------------------------------------------------------------------
150
+ }
151
+
152
+ /**
153
+ * Authorization
154
+ * @param $_POST['username'] @hidden
155
+ * @param $_POST['password'] @hidden
156
+ * @param object $ov_xml XML element
157
+ * @return string
158
+ */
159
+ private function do_remote_authorize_action($ov_xml) {
160
+ //----------------------------------------------------------------------
161
+ if (count($_POST) > 0) {
162
+ //-------------------------------------------------------------------------------------------------------
163
+ if ($key = $this->Connect->LogInSun(filter_var($_POST['username']), filter_var($_POST['password']))) {
164
+ if ($this->Connect->CheckAccessToken($key)) {
165
+
166
+ /**
167
+ * Generate token
168
+ * Set cookie
169
+ * Provide upload URL (expires)
170
+ */
171
+ //-------------------------------------------------------------------------------------------------------
172
+ $token = md5(md5($_POST['username'].' '.$_POST['password'].' '.date('Y-m-d H:i:s').' '.mt_rand(1000, 10000)));
173
+
174
+ session_start();
175
+
176
+ $_SESSION['orbitvu_token'] = $token;
177
+ setcookie('orbitvuid', $token, time()+3600*3);
178
+ $upload_url = str_replace('&', '&amp;', $this->GetRemoteUploadUrl().'&ov_token='.$token);
179
+ //-------------------------------------------------------------------------------------------------------
180
+ $ov_xml->addChild('code', 0);
181
+ $ov_xml->addChild('message', 'Authorization succeeded!');
182
+ $ov_xml->addChild('data', $upload_url);
183
+ //-------------------------------------------------------------------------------------------------------
184
+ }
185
+ else {
186
+ //-------------------------------------------------------------------------------------------------------
187
+ $ov_xml->addChild('code', 4);
188
+ $ov_xml->addChild('message', 'Authorization failed. Permissions denied!');
189
+ header('HTTP/1.0 401 Unauthorized');
190
+ //-------------------------------------------------------------------------------------------------------
191
+ }
192
+ }
193
+ else {
194
+ //-------------------------------------------------------------------------------------------------------
195
+ $ov_xml->addChild('code', 1);
196
+ $ov_xml->addChild('message', 'Authorization failed. Wrong username/password!');
197
+ header('HTTP/1.0 401 Unauthorized');
198
+ //-------------------------------------------------------------------------------------------------------
199
+ }
200
+ }
201
+ else {
202
+ $ov_xml->addChild('code', 3);
203
+ $ov_xml->addChild('message', 'Wrong HTTP method!');
204
+ header('HTTP/1.0 501 Not implemented');
205
+ }
206
+
207
+ return $this->render_xml();
208
+ //----------------------------------------------------------------------
209
+ }
210
+
211
+ /**
212
+ * Upload
213
+ * @param $_FILES['path'] @hidden
214
+ * @param $_COOKIE['orbitvuid'] @hidden
215
+ * @param $_SESSION['orbitvu_token'] @hidden
216
+ * @param $_GET['ov_token'] @hidden
217
+ * @param object $ov_xml XML handler
218
+ * @return string
219
+ */
220
+ private function do_remote_upload_action($ov_xml) {
221
+ //----------------------------------------------------------------------
222
+ $no_errors = true;
223
+
224
+ if (count($_POST) > 0 || count($_FILES) > 0) {
225
+ if ($_SESSION['orbitvu_token'] != $_GET['ov_token']) {
226
+ //-------------------------------------------------------------------------------------------------------
227
+ $ov_xml->addChild('code', 2);
228
+ $ov_xml->addChild('message', 'Authorization failed!');
229
+ header('HTTP/1.0 401 Unauthorized');
230
+ $no_errors = false;
231
+ //-------------------------------------------------------------------------------------------------------
232
+ }
233
+ else if (!isset($_FILES['path']['tmp_name']) || (!stristr($_FILES['path']['name'], '.zip') && !stristr($_FILES['path']['name'], '.ovus'))) {
234
+ //-------------------------------------------------------------------------------------------------------
235
+ $ov_xml->addChild('code', 1);
236
+ $ov_xml->addChild('message', 'Ovus file not provided or not valid!');
237
+ header('HTTP/1.0 400 Bad request');
238
+ $no_errors = false;
239
+ //-------------------------------------------------------------------------------------------------------
240
+ }
241
+ else if (!$this->IsConnected()) {
242
+ //-------------------------------------------------------------------------------------------------------
243
+ $ov_xml->addChild('code', 6);
244
+ $ov_xml->addChild('message', 'DEMO version - upload not permitted.');
245
+ header('HTTP/1.0 401 Unauthorized');
246
+ $no_errors = false;
247
+ //-------------------------------------------------------------------------------------------------------
248
+ }
249
+ else {
250
+ //----------------------------------------------------------------------
251
+ $archive_name = $this->GetPresentationsPath().$_FILES['path']['name'];
252
+ $file_contents = file_get_contents($file_contents);
253
+
254
+ if (!empty($file_contents)) {
255
+ //-------------------------------------------------------------------------------------------------------
256
+ $ov_xml->addChild('code', 1);
257
+ $ov_xml->addChild('message', 'Ovus file not valid!');
258
+ header('HTTP/1.0 400 Bad request');
259
+ $no_errors = false;
260
+ //-------------------------------------------------------------------------------------------------------
261
+ }
262
+ else {
263
+ try {
264
+ if (copy($_FILES['path']['tmp_name'], $archive_name)) {
265
+ //-------------------------------------------------------------------------------------------------------
266
+ $this->InstallPresentation($archive_name, false);
267
+ //-------------------------------------------------------------------------------------------------------
268
+ $ov_xml->addChild('code', 0);
269
+ $ov_xml->addChild('message', 'Upload succeed!');
270
+ //-------------------------------------------------------------------------------------------------------
271
+ setcookie('orbitvuid', '', time()-3600);
272
+ unset($_SESSION['orbitvu_token']);
273
+ $no_errors = false;
274
+ //-------------------------------------------------------------------------------------------------------
275
+ }
276
+ else if ($_FILES['path']['error'] == '1') {
277
+ //-------------------------------------------------------------------------------------------------------
278
+ $ov_xml->addChild('code', 5);
279
+ $ov_xml->addChild('message', 'No space available or file too big! Change `upload_max_filesize` value in your server php.ini file.');
280
+ header('HTTP/1.0 400 Bad request');
281
+ $no_errors = false;
282
+ //-------------------------------------------------------------------------------------------------------
283
+ }
284
+ else {
285
+ //-------------------------------------------------------------------------------------------------------
286
+ $ov_xml->addChild('code', 4);
287
+ $ov_xml->addChild('message', 'Upload error! Error code: '.intval($_FILES['path']['error']));
288
+ header('HTTP/1.0 400 Bad request');
289
+ $no_errors = false;
290
+ //-------------------------------------------------------------------------------------------------------
291
+ }
292
+ }
293
+ catch (Exception $e) {
294
+ //-------------------------------------------------------------------------------------------------------
295
+ $ov_xml->addChild('code', 4);
296
+ $ov_xml->addChild('message', $e->getMessage());
297
+ header('HTTP/1.0 400 Bad request');
298
+ $no_errors = false;
299
+ //-------------------------------------------------------------------------------------------------------
300
+ }
301
+ }
302
+ //----------------------------------------------------------------------
303
+ }
304
+ }
305
+ else {
306
+ //-------------------------------------------------------------------------------------------------------
307
+ $ov_xml->addChild('code', 3);
308
+ $ov_xml->addChild('message', 'Wrong HTTP method!');
309
+ header('HTTP/1.0 501 Not implemented');
310
+ $no_errors = false;
311
+ //-------------------------------------------------------------------------------------------------------
312
+ }
313
+ //----------------------------------------------------------------------
314
+ if ($no_errors) {
315
+ //-------------------------------------------------------------------------------------------------------
316
+ $ov_xml->addChild('code', 4);
317
+ $ov_xml->addChild('message', 'Other no permissions related error!');
318
+ header('HTTP/1.0 401 Unauthorized');
319
+ //-------------------------------------------------------------------------------------------------------
320
+ }
321
+ //----------------------------------------------------------------------
322
+ return $this->render_xml();
323
+ //----------------------------------------------------------------------
324
+ }
325
+
326
+ /**
327
+ * Abstract layer for all remote actions for ALL platforms
328
+ * @param $_GET['ov_key']
329
+ * @param $_GET['ov_action']
330
+ * @return type
331
+ */
332
+ public function StartRemoteListener() {
333
+ //-------------------------------------------------------------------------------------------------------
334
+ $this->remote_xml = new SimpleXMLElement('<ovs_response/>');
335
+ //$ovs_response = $this->remote_xml->addChild('ovs_response');
336
+ //-------------------------------------------------------------------------------------------------------
337
+
338
+ /**
339
+ * Security first
340
+ */
341
+ //-------------------------------------------------------------------------------------------------------
342
+ if (!$_GET['ov_key'] || $_GET['ov_key'] != $this->GetLocalSessionKey()) {
343
+
344
+ $this->remote_xml->addChild('code', 4);
345
+ //$ovs_response->addChild('code', 4);
346
+ $this->remote_xml->addChild('message', 'Authorization URL is not complete, not valid or expired.');
347
+ //$ovs_response->addChild('message', 'Authorization URL is not complete, not valid or expired.');
348
+ header('HTTP/1.0 401 Unauthorized');
349
+
350
+ return $this->render_xml();
351
+ }
352
+ //-------------------------------------------------------------------------------------------------------
353
+
354
+ /**
355
+ * Session OK?
356
+ * All right...
357
+ */
358
+ //-------------------------------------------------------------------------------------------------------
359
+ if ($_GET['ov_action'] == 'upload') {
360
+ //return $this->do_remote_upload_action($ovs_response);
361
+ return $this->do_remote_upload_action($this->remote_xml);
362
+
363
+ }
364
+
365
+ //return $this->do_remote_authorize_action($ovs_response);
366
+ return $this->do_remote_authorize_action($this->remote_xml);
367
+ //-------------------------------------------------------------------------------------------------------
368
+ }
369
+
370
+ /**
371
+ * Resize Image. Process image and generate other size in $target_path
372
+ * @param string $file Original image file
373
+ * @param integer|null $width New image width (null = auto)
374
+ * @param integer|null $height New image height (null = auto)
375
+ * @param string $target_path Output images path (cached processed versions)
376
+ * @param string $scale_type[=crop] Scaling type crop|stretch|auto
377
+ * @return string Path to new file
378
+ */
379
+ public function ResizeImage($file, $width = null, $height = null, $target_path = null, $scale_type = 'auto', $background = 'white') {
380
+ //-------------------------------------------------------------------------------------------------------
381
+ /**
382
+ * Original file directory parsing
383
+ */
384
+ //-------------------------------------------------------------------------------------------------------
385
+ $file_name = explode('/', $file);
386
+ $file_name = $file_name[count($file_name)-1];
387
+
388
+ if ($target_path === null) {
389
+ $target_path = str_replace($file_name, '', $file);
390
+ }
391
+
392
+ $fname = $target_path.str_ireplace(array('.jpg', '.png', '.gif', '.jpeg'), '', $file_name);
393
+
394
+ //-------------------------------------------------------------------------------------------------------
395
+
396
+ /**
397
+ * New dimensions
398
+ */
399
+ //-------------------------------------------------------------------------------------------------------
400
+ if ($width === null) {
401
+ $width = '*';
402
+ }
403
+ if ($height === null) {
404
+ $height = '*';
405
+ }
406
+ //-------------------------------------------------------------------------------------------------------
407
+
408
+ /**
409
+ * Get image details
410
+ * Create new image with proper type
411
+ */
412
+ //-------------------------------------------------------------------------------------------------------
413
+ list($w, $h, $type) = getimagesize($file);
414
+
415
+ switch ($type){
416
+ case IMAGETYPE_GIF:
417
+ $src_im = imagecreatefromgif($file);
418
+ break;
419
+ case IMAGETYPE_PNG:
420
+ $src_im = imagecreatefrompng($file);
421
+ break;
422
+ default:
423
+ $src_im = imagecreatefromjpeg($file);
424
+ break;
425
+ }
426
+
427
+ /**
428
+ * Image dimensions
429
+ */
430
+ //-------------------------------------------------------------------------------------------------------
431
+ $tw = $width;
432
+ $th = $height;
433
+ if ($tw == '*') {
434
+ $tw = $th / $h * $w;
435
+ }
436
+ if ($th == '*') {
437
+ $th = $tw / $w * $h;
438
+ }
439
+
440
+ /**
441
+ * Check if file already exists.
442
+ * If so, return file path
443
+ */
444
+ //-------------------------------------------------------------------------------------------------------
445
+ $final_path = $fname.'_'.round($tw).'_'.round($th).'.jpg';
446
+
447
+ if (file_exists($final_path)) {
448
+ return $final_path;
449
+ }
450
+
451
+ /**
452
+ * Image resizing
453
+ */
454
+ //-------------------------------------------------------------------------------------------------------
455
+ $dst_im = imagecreatetruecolor($tw, $th);
456
+
457
+ if ($background == 'white') {
458
+ $background = 16777215;
459
+ }
460
+ else {
461
+ $background = 0;
462
+ }
463
+ imagefill($dst_im, 0, 0, $background);
464
+
465
+ switch ($scale_type) {
466
+ case 'crop':
467
+ $nw = ceil($w / $h > $tw / $th ? $th * ($w / $h) : $tw);
468
+ $nh = ceil($w / $h > $tw / $th ? $th : $tw / ($w / $h));
469
+ $temp_gdim = imagecreatetruecolor($nw, $nh);
470
+ imagecopyresampled($temp_gdim, $src_im, 0, 0, 0, 0, $nw, $nh, $w, $h);
471
+ imagecopy($dst_im, $temp_gdim, 0, 0, ($nw - $tw) / 2, ($nh - $th) / 2, $tw, $th);
472
+ imagedestroy($temp_gdim);
473
+ break;
474
+ case 'stretch':
475
+ imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $tw, $th, $w, $h);
476
+ break;
477
+ default:
478
+ $nw = ceil($w > $tw || $h > $th ? ($th < $tw ? $th / ($h / $w) : $tw) : $w);
479
+ $nh = ceil($w > $tw || $h > $th ? ($th > $tw ? $tw * ($h / $w) : $th) : $h);
480
+ imagecopyresampled($dst_im, $src_im, ($tw - $nw) / 2, ($th - $nh) / 2, 0, 0, $nw, $nh, $w, $h);
481
+ break;
482
+ }
483
+ //-------------------------------------------------------------------------------------------------------
484
+
485
+ /**
486
+ * Use imagejpeg as one format and better quality
487
+ */
488
+ //-------------------------------------------------------------------------------------------------------
489
+ imagejpeg($dst_im, $final_path, 100);
490
+ imagedestroy($dst_im);
491
+
492
+ if (!file_exists($final_path)) {
493
+ throw new Exception('Orbitvu: Image file cannot be saved. Make sure you have set write permissions to parent directory of file: '.$final_path.'');
494
+ }
495
+ //-------------------------------------------------------------------------------------------------------
496
+ return $final_path;
497
+ //-------------------------------------------------------------------------------------------------------
498
+ }
499
+
500
+ /**
501
+ * Set extension access token to default
502
+ * @return boolean
503
+ */
504
+ public function SetDemoAccessToken() {
505
+ //-------------------------------------------------------------------------------------------------------
506
+ return $this->UpdateConfiguration('access_token', $this->Connect->GetDemoAccessToken());
507
+ //-------------------------------------------------------------------------------------------------------
508
+ }
509
+
510
+ /**
511
+ * Get presentation items types
512
+ * @return array
513
+ */
514
+ public function GetPresentationTypes($result) {
515
+ //-------------------------------------------------------------------------------------------------------
516
+ $types = array();
517
+ //-------------------------------------------------------------------------------------------------------
518
+ if ($result->has_orbittour == 1) {
519
+ $types[] = '0';
520
+ }
521
+ //-------------------------------------------------------------------------------------------------------
522
+ for ($k = 0, $m = count($result->presentationcontent_set); $k < $m; $k++) {
523
+ $cur_type = $result->presentationcontent_set[$k]->type;
524
+
525
+ if (!in_array($cur_type, $types)) {
526
+ $types[] = $cur_type;
527
+ }
528
+ }
529
+ //-------------------------------------------------------------------------------------------------------
530
+ rsort($types);
531
+ //-------------------------------------------------------------------------------------------------------
532
+ return $types;
533
+ //-------------------------------------------------------------------------------------------------------
534
+ }
535
+
536
+ /**
537
+ * Get product presentation items
538
+ * @return array
539
+ */
540
+ public function GetProductPresentationItems($orbitvu_id) {
541
+ //-------------------------------------------------------------------------------------------------------
542
+ return $this->driver->GetProductPresentationItems($orbitvu_id);
543
+ //-------------------------------------------------------------------------------------------------------
544
+ }
545
+
546
+ /**
547
+ * Synchronize one product presentation
548
+ * @return array
549
+ */
550
+ public function SynchronizeProductPresentation($product_id, $presentation_id, $presentation_name) {
551
+ //-------------------------------------------------------------------------------------------------------
552
+ $this->SetProductPresentation($product_id, $presentation_id, $presentation_name);
553
+ $p_items = $this->GetProductPresentationItems($presentation_id);
554
+ $this->SetProductPresentationItems($product_id, $presentation_id, $presentation_name, $p_items);
555
+ //-------------------------------------------------------------------------------------------------------
556
+ return true;
557
+ //-------------------------------------------------------------------------------------------------------
558
+ }
559
+
560
+ /**
561
+ * Set SUN presentation SKU
562
+ * @param type $presentation_id Presentation ID from database
563
+ * @param type $new_sku Presentation new SKU
564
+ * @param type $current_sku Presentation current SKU to update
565
+ * @param boolean $update Force SKU update
566
+ * @return boolean
567
+ */
568
+ public function SetSunPresentationSku($presentation_id, $new_sku, $current_sku, $update = false) {
569
+ //-------------------------------------------------------------------------------------------------------
570
+ if (!$update && (($this->GetConfiguration('auto_sync_sku') == 'true_ifempty' && empty($current_sku)) || $this->GetConfiguration('auto_sync_sku') == 'true')) {
571
+ $update = true;
572
+ }
573
+ //-------------------------------------------------------------------------------------------------------
574
+ if ($update) {
575
+ return $this->Connect->CallSUN('presentations/'.$presentation_id.'/sku', array('sku' => $new_sku), true, true);
576
+ }
577
+ //-------------------------------------------------------------------------------------------------------
578
+ return false;
579
+ //-------------------------------------------------------------------------------------------------------
580
+ }
581
+
582
+ /**
583
+ * Are we connected to the Orbitvu SUN?
584
+ * @return bool
585
+ */
586
+ public function IsConnected() {
587
+ //-------------------------------------------------------------------------------------------------------
588
+ return $this->work;
589
+ //-------------------------------------------------------------------------------------------------------
590
+ }
591
+
592
+ /**
593
+ * Check for available updates
594
+ * @return stdClass|boolean
595
+ */
596
+ public function CheckForUpdates() {
597
+ //-------------------------------------------------------------------------------------------------------
598
+ return $this->Connect->CheckForUpdates();
599
+ //-------------------------------------------------------------------------------------------------------
600
+ }
601
+
602
+ /**
603
+ * License days counter
604
+ * @return integer
605
+ */
606
+ public function GetSupportDays() {
607
+ //-------------------------------------------------------------------------------------------------------
608
+ return $this->Connect->GetSupportDays();
609
+ //-------------------------------------------------------------------------------------------------------
610
+ }
611
+
612
+ /**
613
+ * Check if license is demo
614
+ * @return boolean
615
+ */
616
+ public function IsDemo() {
617
+ //-------------------------------------------------------------------------------------------------------
618
+ return $this->Connect->IsDemo();
619
+ //-------------------------------------------------------------------------------------------------------
620
+ }
621
+
622
+ //-------------------------------------------------------------------------------------------------------
623
+ //-------------------------------------------------------------------------------------------------------
624
+ //-------------------------------------------------------------------------------------------------------
625
+ // Forward queries to included driver
626
+ //-------------------------------------------------------------------------------------------------------
627
+ //-------------------------------------------------------------------------------------------------------
628
+ //-------------------------------------------------------------------------------------------------------
629
+
630
+ /**
631
+ * Update both extension and store configuration
632
+ * @param string $var Configuration var to update
633
+ * @param string $value New value
634
+ * @return boolean
635
+ */
636
+ public function UpdateConfiguration($var, $value) {
637
+ //-------------------------------------------------------------------------------------------------------
638
+ $this->driver->SetConfiguration($var, $value);
639
+ $this->driver->SetConfigurationParent($var, $value);
640
+ //-------------------------------------------------------------------------------------------------------
641
+ }
642
+
643
+ /**
644
+ * Clear Cache
645
+ * @return boolean
646
+ */
647
+ public function ClearCache() {
648
+ //-------------------------------------------------------------------------------------------------------
649
+ return $this->driver->SetConfiguration('last_flushed_cache', date('Y-m-d'));
650
+ //-------------------------------------------------------------------------------------------------------
651
+ }
652
+
653
+ /**
654
+ * Use UpdateConfiguration if you want to update store configuration too
655
+ * @param string $var Local configuration var to update
656
+ * @param string $value Local new value
657
+ * @return boolean
658
+ */
659
+ public function SetConfiguration($var, $value) {
660
+ //-------------------------------------------------------------------------------------------------------
661
+ return $this->driver->SetConfiguration($var, $value);
662
+ //-------------------------------------------------------------------------------------------------------
663
+ }
664
+
665
+ /**
666
+ * Switch presentation item priority
667
+ * @param integer $product_id Store product ID from database
668
+ * @param integer $item_id Current item ID from database
669
+ * @param integer $item_id2 Item will be putted in order after this item
670
+ * @return boolean
671
+ */
672
+ public function SwitchPresentationItemPriority($product_id, $item_id, $item_id2) {
673
+ //-------------------------------------------------------------------------------------------------------
674
+ return $this->driver->SwitchPresentationItemPriority($product_id, $item_id, $item_id2);
675
+ //-------------------------------------------------------------------------------------------------------
676
+ }
677
+
678
+ /**
679
+ * Get product presentation data
680
+ * Get product presentation items
681
+ * @param integer $product_id Store product ID from database
682
+ * @param boolean $visible_only Return only items marked as visible
683
+ * @return array
684
+ */
685
+ public function GetProductPresentation($product_id, $visible_only = false) {
686
+ //-------------------------------------------------------------------------------------------------------
687
+ return $this->driver->GetProductPresentation($product_id, $visible_only);
688
+ //-------------------------------------------------------------------------------------------------------
689
+ }
690
+
691
+ /**
692
+ * Set new product presentation
693
+ * @param type $product_id Store product ID from database
694
+ * @param type $orbitvu_id Orbitvu SUN presentation ID
695
+ * @param type $orbitvu_name Orbitvu SUN presentation name
696
+ * @return boolean
697
+ */
698
+ public function SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name = '') {
699
+ //-------------------------------------------------------------------------------------------------------
700
+ return $this->driver->SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name);
701
+ //-------------------------------------------------------------------------------------------------------
702
+ }
703
+
704
+ /**
705
+ * Set product presentation items
706
+ * @param type $product_id Store product ID from database
707
+ * @param type $orbitvu_id Orbitvu SUN presentation ID
708
+ * @param type $orbitvu_name Orbitvu SUN presentation name
709
+ * @param type $presentation_items Orbitvu SUN presentation items
710
+ * @return type
711
+ */
712
+ public function SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items) {
713
+ //-------------------------------------------------------------------------------------------------------
714
+ return $this->driver->SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items);
715
+ //-------------------------------------------------------------------------------------------------------
716
+ }
717
+
718
+ /**
719
+ * Synchronize presentations
720
+ * @param array $products_array Products array
721
+ * @return boolean
722
+ */
723
+ public function SynchronizePresentations($products_array) {
724
+ //-------------------------------------------------------------------------------------------------------
725
+ return $this->driver->SynchronizePresentations($products_array);
726
+ //-------------------------------------------------------------------------------------------------------
727
+ }
728
+
729
+ /**
730
+ * Refresh presentations items
731
+ * Delete non-existing on SUN
732
+ * Add new from SUN
733
+ * @return boolean
734
+ */
735
+ public function SynchronizePresentationsItems() {
736
+ //-------------------------------------------------------------------------------------------------------
737
+ return $this->driver->SynchronizePresentationsItems();
738
+ //-------------------------------------------------------------------------------------------------------
739
+ }
740
+
741
+ /**
742
+ * Is presentation unlinked?
743
+ * @param integer $product_id Store product ID from database
744
+ * @param integer $orbitvu_id Orbitvu SUN presentation ID
745
+ * @return boolean
746
+ */
747
+ public function IsPresentationUnlinked($product_id, $orbitvu_id) {
748
+ //-------------------------------------------------------------------------------------------------------
749
+ return $this->driver->IsPresentationUnlinked($product_id, $orbitvu_id);
750
+ //-------------------------------------------------------------------------------------------------------
751
+ }
752
+
753
+ /**
754
+ * Is the product unlinked?
755
+ * @param integer $product_id Store product ID from database
756
+ * @return boolean
757
+ */
758
+ public function IsProductUnlinked($product_id) {
759
+ //-------------------------------------------------------------------------------------------------------
760
+ return $this->driver->IsProductUnlinked($product_id);
761
+ //-------------------------------------------------------------------------------------------------------
762
+ }
763
+
764
+ /**
765
+ * Unlink (free) presentation from product
766
+ * @param integer $product_id Store product ID from database
767
+ * @return boolean
768
+ */
769
+ public function FreeProduct($product_id) {
770
+ //-------------------------------------------------------------------------------------------------------
771
+ return $this->driver->FreeProduct($product_id);
772
+ //-------------------------------------------------------------------------------------------------------
773
+ }
774
+
775
+ /**
776
+ * Get configuration value from var
777
+ * @param string $var Var from configuration
778
+ * @return string
779
+ */
780
+ public function GetConfiguration($var) {
781
+ //-------------------------------------------------------------------------------------------------------
782
+ return $this->Config->$var;
783
+ //-------------------------------------------------------------------------------------------------------
784
+ }
785
+
786
+ /**
787
+ * Update item priority
788
+ * @param integer $item_id Store product item ID from database
789
+ * @param integer $new_priority New priority (order) value
790
+ * @return boolean
791
+ */
792
+ public function UpdatePresentationItemPriority($item_id, $new_priority) {
793
+ //-------------------------------------------------------------------------------------------------------
794
+ return $this->driver->UpdatePresentationItemPriority($item_id, $new_priority);
795
+ //-------------------------------------------------------------------------------------------------------
796
+ }
797
+
798
+ /**
799
+ * Delete presentation item
800
+ * @param integer $item_id Store product item ID from database
801
+ * @return boolean
802
+ */
803
+ public function DeletePresentationItem($item_id) {
804
+ //-------------------------------------------------------------------------------------------------------
805
+ return $this->driver->DeletePresentationItem($item_id);
806
+ //-------------------------------------------------------------------------------------------------------
807
+ }
808
+
809
+ /**
810
+ * Have the product a presentation exists?
811
+ * @param integer $product_id Store product ID from database
812
+ * @return boolean
813
+ */
814
+ public function ExistsProductPresentation($product_id) {
815
+ //-------------------------------------------------------------------------------------------------------
816
+ return $this->driver->ExistsProductPresentation($product_id);
817
+ //-------------------------------------------------------------------------------------------------------
818
+ }
819
+
820
+ /**
821
+ * Search the presentation with name and SKU
822
+ * @param array $product Product array with name and SKU
823
+ * @return array|boolean
824
+ */
825
+ public function MatchPresentation($product) {
826
+ //-------------------------------------------------------------------------------------------------------
827
+ return $this->driver->MatchPresentation($product);
828
+ //-------------------------------------------------------------------------------------------------------
829
+ }
830
+
831
+ /**
832
+ * Update item visibility status
833
+ * @param integer $item_id Store product item ID from database
834
+ * @param string $status New item visibility status [active / inactive]
835
+ * @return boolean
836
+ */
837
+ public function UpdatePresentationItemStatus($item_id, $status = 'inactive') {
838
+ //-------------------------------------------------------------------------------------------------------
839
+ return $this->driver->UpdatePresentationItemStatus($item_id, $status);
840
+ //-------------------------------------------------------------------------------------------------------
841
+ }
842
+
843
+ /**
844
+ * @see OrbitvuDatabaseDriver.php\GetLocalSessionKey()
845
+ * @return string
846
+ */
847
+ public function GetLocalSessionKey() {
848
+ //-------------------------------------------------------------------------------------------------------
849
+ return $this->driver->GetLocalSessionKey();
850
+ //-------------------------------------------------------------------------------------------------------
851
+ }
852
+
853
+ /**
854
+ * @see OrbitvuDatabaseDriver.php\GetRemoteAuthorizationUrl()
855
+ * @return string
856
+ */
857
+ public function GetRemoteAuthorizationUrl() {
858
+ //-------------------------------------------------------------------------------------------------------
859
+ return $this->driver->GetRemoteAuthorizationUrl();
860
+ //-------------------------------------------------------------------------------------------------------
861
+ }
862
+
863
+ /**
864
+ * @see OrbitvuDatabaseDriver.php\GetRemoteUploadUrl()
865
+ * @return string
866
+ */
867
+ public function GetRemoteUploadUrl() {
868
+ //-------------------------------------------------------------------------------------------------------
869
+ return $this->driver->GetRemoteUploadUrl();
870
+ //-------------------------------------------------------------------------------------------------------
871
+ }
872
+
873
+ /**
874
+ * Install database tables
875
+ * @return boolean
876
+ */
877
+ public function Install() {
878
+ //-------------------------------------------------------------------------------------------------------
879
+ return $this->driver->Install();
880
+ //-------------------------------------------------------------------------------------------------------
881
+ }
882
+
883
+ /**
884
+ * Get presentations from Orbitvu SUN
885
+ * @param array $params Params for Orbitvu SUN filtering
886
+ * @return stdClass
887
+ */
888
+ public function GetPresentationsList($params = false) {
889
+ //-------------------------------------------------------------------------------------------------------
890
+ return $this->driver->GetPresentationsList($params);
891
+ //-------------------------------------------------------------------------------------------------------
892
+ }
893
+
894
+ /**
895
+ * Get our store thumbnails
896
+ * @param integer $product_id Store product ID from database
897
+ * @return array
898
+ */
899
+ public function GetProductThumbnails($product_id) {
900
+ //-------------------------------------------------------------------------------------------------------
901
+ return $this->driver->GetProductThumbnails($product_id);
902
+ //-------------------------------------------------------------------------------------------------------
903
+ }
904
+
905
+ /**
906
+ * Set store thumbnail
907
+ * @param integer $product_id Store product ID from database
908
+ * @param string $thumbnail Thumbnail path
909
+ * @return array
910
+ */
911
+ public function SetProductThumbnail($product_id, $thumbnail) {
912
+ //-------------------------------------------------------------------------------------------------------
913
+ return $this->driver->SetProductThumbnail($product_id, $thumbnail);
914
+ //-------------------------------------------------------------------------------------------------------
915
+ }
916
+
917
+ /**
918
+ * Delete store thumbnail
919
+ * @param integer $product_id Store product ID from database
920
+ * @param string $thumbnail Thumbnail path
921
+ * @return array
922
+ */
923
+ public function DeleteProductThumbnail($product_id, $thumbnail = '') {
924
+ //-------------------------------------------------------------------------------------------------------
925
+ return $this->driver->DeleteProductThumbnail($product_id, $thumbnail);
926
+ //-------------------------------------------------------------------------------------------------------
927
+ }
928
+
929
+ /**
930
+ * Synchronization
931
+ * @return boolean
932
+ */
933
+ public function SynchronizeAllProducts() {
934
+ //-------------------------------------------------------------------------------------------------------
935
+ return $this->driver->SynchronizeAllProducts();
936
+ //-------------------------------------------------------------------------------------------------------
937
+ }
938
+
939
+ /**
940
+ * Get associated products of a given product *
941
+ * @param $product_id
942
+ * @return mixed
943
+ */
944
+ public function GetAssociatedProducts($product_id) {
945
+ return $this->driver->GetAssociatedProducts($product_id);
946
+ }
947
+ }
948
+
949
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuConnect.php CHANGED
@@ -1,1057 +1,1057 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP Orbitvu eCommerce SUN connector
4
- * @copyright Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- * @license Commercial
6
- */
7
-
8
- final class Orbitvu {
9
-
10
- /**
11
- * License Key
12
- * @var string
13
- */
14
- private $access_token;
15
-
16
- /**
17
- * Debug mode
18
- * @var boolean
19
- */
20
- private $debug = false;
21
-
22
- /**
23
- * Unit tests mode
24
- * @var boolean
25
- */
26
- private $test = false;
27
-
28
- /**
29
- * Test class instance
30
- * @var instance
31
- */
32
- private $testclass = false;
33
-
34
- /**
35
- * Curl version
36
- * @var string
37
- */
38
- private $curl_version;
39
-
40
- /**
41
- * New available version of plugin
42
- * @var string
43
- */
44
- private $plugin_available_version;
45
-
46
- /**
47
- * License end date
48
- * @var date Y-m-d
49
- */
50
- private $plugin_support;
51
-
52
- /**
53
- * Default DEMO access token
54
- * Available to change (if updated)
55
- * @var string
56
- */
57
- private $demo_access_token = '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29';
58
-
59
- /**
60
- * Local presentations count
61
- * @var integer
62
- */
63
- private $presentations_count = 0;
64
-
65
- /**
66
- * Viewers path
67
- * @fixme delete if not used
68
- * @var string
69
- */
70
- public $ViewerPath = 'viewers/src/';
71
-
72
- /**
73
- * Temporary path for uploads
74
- * @var string
75
- */
76
- public $DownloadPath = 'tmp/';
77
-
78
- /**
79
- * Temporary path for uploads
80
- * @var string
81
- */
82
- public $PresentationsPath = 'orbitvu_presentations/';
83
-
84
- /**
85
- * Let's do the magic
86
- * @param string $access_token License Key
87
- * @param boolean $debug Debug mode
88
- * @param boolean $test Unit tests mode
89
- * @param boolean $testinstance Unit tests instance.
90
- */
91
- public function __construct($access_token, $debug = false, $test = false, $testinstance = false) {
92
- //---------------------------------------------------------------------------------------------------
93
- $this->access_token = $access_token;
94
- $this->debug = $debug;
95
- $this->test = $test;
96
- //---------------------------------------------------------------------------------------------------
97
-
98
- /*
99
- * Test instance
100
- */
101
- //---------------------------------------------------------------------------------------------------
102
- if ($this->test) {
103
- $this->testclass = $testinstance;
104
-
105
- /*
106
- * Run test bot!
107
- */
108
- $this->run_tests();
109
- }
110
- //---------------------------------------------------------------------------------------------------
111
-
112
- //----------------------------------------------------------
113
- /**/ if ($this->debug || $this->test) {
114
- /**/ error_reporting(E_ALL & ~E_NOTICE);
115
- /**/ ini_set('display_errors', '1');
116
- /**/ }
117
- //----------------------------------------------------------
118
- }
119
-
120
- /**
121
- * Set the CURL version
122
- * @param string $v CURL version
123
- */
124
- public function IntroduceYourself($v) {
125
- //-------------------------------------------------------------------------------------------------------
126
- $this->curl_version = $v;
127
- //-------------------------------------------------------------------------------------------------------
128
- }
129
-
130
- /**
131
- * Get the demo access token
132
- * @return string
133
- */
134
- public function GetDemoAccessToken() {
135
- //-------------------------------------------------------------------------------------------------------
136
- return $this->demo_access_token;
137
- //-------------------------------------------------------------------------------------------------------
138
- }
139
-
140
- /**
141
- * Check if current license is demo
142
- * @return boolean
143
- */
144
- public function IsDemo() {
145
- //-------------------------------------------------------------------------------------------------------
146
- if ($this->access_token == $this->GetDemoAccessToken() && $this->IsConnected()) {
147
- //-------------------------------------------------------------------------------------------------------
148
- return true;
149
- //-------------------------------------------------------------------------------------------------------
150
- }
151
- //-------------------------------------------------------------------------------------------------------
152
- return false;
153
- //-------------------------------------------------------------------------------------------------------
154
- }
155
-
156
- /**
157
- * Want to change access_token for current session? No problem
158
- * @param string $access_token New access token
159
- */
160
- public function SetAccessToken($access_token) {
161
- //---------------------------------------------------------------------------------------------------
162
- $this->access_token = $access_token;
163
- //---------------------------------------------------------------------------------------------------
164
- }
165
-
166
- /**
167
- * Get current License Key
168
- * @return string
169
- */
170
- public function GetAccessToken() {
171
- //---------------------------------------------------------------------------------------------------
172
- return $this->access_token;
173
- //---------------------------------------------------------------------------------------------------
174
- }
175
-
176
- /**
177
- * Unit tests results
178
- * @return array
179
- */
180
- public function GetTestsResults() {
181
- //---------------------------------------------------------------------------------------------------
182
- return $this->testclass->GetResults();
183
- //---------------------------------------------------------------------------------------------------
184
- }
185
-
186
- /**
187
- * Orbitvu SUN API calling function
188
- * @param string $call API path to call
189
- * @param array|string $parameters Additional parameters to call
190
- * @param boolean $method_post Use POST method
191
- * @param boolean $get_headers Get HTTP headers
192
- * @param boolean $not_change Disable automatic call formatting
193
- * @param boolean $no_query_string Enable if sending sensitive data via POST
194
- * @return json|strong
195
- */
196
- public function CallAPI($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false, $no_query_string = false) {
197
- //---------------------------------------------------------------------------------------------------
198
- /*
199
- * Add URL parameters from array to URL
200
- */
201
- // presentation url auto status
202
- if (stristr($call, 'presentations') && !stristr($call, 'status=')) {
203
- if (!is_array($parameters)) {
204
- $parameters = array('status' => '1');
205
- }
206
- else if (!isset($parameters['status'])) {
207
- $parameters['status'] = '1';
208
- }
209
- }
210
-
211
- /*
212
- * POST
213
- */
214
- if ($method_post && !$not_change) {
215
- $parameters['_method'] = 'PATCH';
216
- }
217
-
218
- /*
219
- * Add URL parameters from array to URL
220
- */
221
- if (is_array($parameters)) {
222
- $parameters_array = $parameters;
223
- //---------------------------------------------------------------------------------------------------
224
- $keys = array_keys($parameters);
225
- $vals = array_values($parameters);
226
-
227
- $parameters = '';
228
- //---------------------------------------------------------------------------------------------------
229
- for ($i = 0, $n = count($keys); $i < $n; $i++) {
230
- if ($i == 0) $parameters .= '?';
231
- else $parameters .= '&';
232
-
233
- $parameters .= $keys[$i].'='.$vals[$i];
234
- }
235
- //---------------------------------------------------------------------------------------------------
236
- }
237
-
238
- //----------------------------------------------------------
239
- if ($this->test) {
240
- $this->testclass->AppendTest('api_call['.$call.']', array('type' => 'function_replace'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
241
- return $this->testclass->CallAPI($call, $parameters);
242
- }
243
- //----------------------------------------------------------
244
-
245
- /*
246
- * Make both ways calling option
247
- * but return json as possible
248
- */
249
- if (stristr($call, '//')) {
250
- $url = $this->clean_url($call);
251
- }
252
- else {
253
- $url = 'https://orbitvu.co/api/ecommerce/'.trim(str_replace(array('.html', '.json'), '', $call), '/').($method_post && !$not_change ? '' : '/').'.json';
254
- }
255
-
256
- /**
257
- * If query string is on, attach parameters to query also,
258
- * even if POST or PUT method
259
- */
260
- if (!$no_query_string) {
261
- $url .= $parameters;
262
- }
263
-
264
- /*
265
- * Set the access token
266
- */
267
- $header[] = "Authorization: Token ".$this->access_token;
268
- $header[] = "Accept-User-Agent: ".OrbitvuDatabaseDriver::DRIVER_VERSION;
269
- $header[] = "Accept-User-Agent-Version: ".$this->curl_version;
270
-
271
- //----------------------------------------------------------
272
- /**/ $this->return_debug(array(
273
- /**/ 'function' => __FUNCTION__,
274
- /**/ 'url' => $url,
275
- /**/ 'headers' => $header,
276
- /**/ 'parameters' => isset($parameters_array) ? $parameters_array : array(),
277
- /**/ 'post' => ($method_post ? 'true' : 'false')
278
- /**/ ));
279
- //----------------------------------------------------------
280
-
281
- /*
282
- * Call SUN with CURL
283
- * Method: GET
284
- * + headers
285
- */
286
- $c = curl_init();
287
- curl_setopt($c, CURLOPT_URL, $url);
288
- curl_setopt($c, CURLOPT_HTTPHEADER, $header);
289
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
290
- curl_setopt($c, CURLOPT_CONNECTTIMEOUT,2);
291
- curl_setopt($c, CURLOPT_TIMEOUT,5);
292
- curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
293
- if ($method_post) {
294
- curl_setopt($c, CURLOPT_POST, count($parameters_array));
295
- curl_setopt($c, CURLOPT_POSTFIELDS, $parameters_array);
296
- }
297
- if ($get_headers) {
298
- curl_setopt($c, CURLOPT_VERBOSE, 1);
299
- curl_setopt($c, CURLOPT_HEADER, 1);
300
- }
301
- $page = curl_exec($c);
302
-
303
-
304
- if ($get_headers) {
305
- //---------------------------------------------------------------------------------------------------
306
- $header_size = curl_getinfo($c, CURLINFO_HEADER_SIZE);
307
- $header = substr($page, 0, $header_size);
308
- $body = substr($page, $header_size);
309
- //---------------------------------------------------------------------------------------------------
310
- if (!stristr($header, '200 OK')) {
311
- $body = json_decode($body);
312
- $error = explode("\n", $header);
313
- $error = explode(' ', $error[0]);
314
- $error = $error[1];
315
- $body->error = $error;
316
- $body->header = $header;
317
- $body = json_encode($body);
318
- }
319
- //---------------------------------------------------------------------------------------------------
320
- $page = $body;
321
- //---------------------------------------------------------------------------------------------------
322
- }
323
-
324
- /*
325
- * Return SUN original response
326
- */
327
- //---------------------------------------------------------------------------------------------------
328
- curl_close($c);
329
-
330
- return $page;
331
- //---------------------------------------------------------------------------------------------------
332
- }
333
-
334
- /**
335
- * Orbitvu SUN API calling alias to CallAPI function.
336
- * Returns decoded json.
337
- * @param string $call API path to call
338
- * @param array|string $parameters Additional parameters to call
339
- * @param boolean $method_post Use POST method
340
- * @param boolean $get_headers Get HTTP headers
341
- * @param boolean $not_change Disable automatic call formatting
342
- * @param boolean $no_query_string Enable if sending sensitive data via POST
343
- * @return stdClass
344
- */
345
- public function CallSUN($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false, $no_query_string = false) {
346
- //---------------------------------------------------------------------------------------------------
347
- $page = json_decode($this->CallAPI($call, $parameters, $method_post, $get_headers, $not_change, $no_query_string));
348
-
349
- //----------------------------------------------------------
350
- /**/ $this->return_debug(array(
351
- /**/ 'function' => __FUNCTION__,
352
- /**/ 'response' => $page
353
- /**/ ));
354
- //----------------------------------------------------------
355
-
356
- //---------------------------------------------------------------------------------------------------
357
- return $page;
358
- //---------------------------------------------------------------------------------------------------
359
- }
360
-
361
- /**
362
- * Check if we are connected
363
- * Also, get updates info if available
364
- * @return boolean
365
- * @fixme new licenses with Maciej
366
- */
367
- public function IsConnected() {
368
- //---------------------------------------------------------------------------------------------------
369
- $get = $this->CallSUN('plugins/versions/latest', '', false, true);
370
- //-------------------------------------------------------------------------------------------------------
371
- $this->plugin_available_version = property_exists($get, 'version') ? $get->version : null;
372
- $this->plugin_support = property_exists($get, 'support') ? $get->support : null;
373
-
374
- if (property_exists($get, 'error') && $get->error) {
375
- return false;
376
- }
377
- //-------------------------------------------------------------------------------------------------------
378
- return true;
379
- //---------------------------------------------------------------------------------------------------
380
- }
381
-
382
- /**
383
- * Check for available updates
384
- * @return stdClass|boolean
385
- */
386
- public function CheckForUpdates() {
387
- //-------------------------------------------------------------------------------------------------------
388
- if ($this->curl_version != $this->plugin_available_version) {
389
- //-------------------------------------------------------------------------------------------------------
390
- $ret = new stdClass();
391
- $ret->version = $this->curl_version;
392
- $ret->new_version = $this->plugin_available_version;
393
- //-------------------------------------------------------------------------------------------------------
394
- return $ret;
395
- //-------------------------------------------------------------------------------------------------------
396
- }
397
- //-------------------------------------------------------------------------------------------------------
398
- return false;
399
- //-------------------------------------------------------------------------------------------------------
400
- }
401
-
402
- /**
403
- * License days counter
404
- * @return integer|string
405
- */
406
- public function GetSupportDays() {
407
- //-------------------------------------------------------------------------------------------------------
408
- if (!is_null($this->plugin_support)) {
409
- //-------------------------------------------------------------------------------------------------------
410
- $ret = new stdClass();
411
- $ret->days = $this->count_days($this->plugin_support, date('Y-m-d'));
412
- $ret->date = $this->plugin_support;
413
- //-------------------------------------------------------------------------------------------------------
414
- }
415
- //-------------------------------------------------------------------------------------------------------
416
- return 'n/a';
417
- //-------------------------------------------------------------------------------------------------------
418
- }
419
-
420
- /**
421
- * Register an account
422
- * @param string $email Email to register
423
- * @return stdClass
424
- */
425
- public function CreateAccount($email) {
426
- //---------------------------------------------------------------------------------------------------
427
- $reg_token = $this->CallSUN('regtoken', '', true, true, true);
428
- //---------------------------------------------------------------------------------------------------
429
- if (is_null($reg_token->token)) {
430
- //---------------------------------------------------------------------------------------------------
431
- throw new Exception('Orbitvu: cannot get a token');
432
- //---------------------------------------------------------------------------------------------------
433
- }
434
- //---------------------------------------------------------------------------------------------------
435
- $reg = $this->CallSUN('reguser', array(
436
- 'token' => $reg_token->token,
437
- 'email' => $email
438
- ), true, true, true);
439
- //---------------------------------------------------------------------------------------------------
440
- if ($reg->email[0]) {
441
- //---------------------------------------------------------------------------------------------------
442
- throw new Exception($reg->email[0]);
443
- //---------------------------------------------------------------------------------------------------
444
- }
445
- //---------------------------------------------------------------------------------------------------
446
- $reg->email = $email;
447
-
448
- //----------------------------------------------------------
449
- /**/ $this->return_debug(array(
450
- /**/ 'function' => __FUNCTION__,
451
- /**/ 'response' => $reg
452
- /**/ ));
453
- //----------------------------------------------------------
454
-
455
- //---------------------------------------------------------------------------------------------------
456
- return $reg;
457
- }
458
-
459
- /**
460
- * Gets a client License Key (Access Token) from Orbitvu SUN account after log in
461
- * @param type $user_name SUN user name
462
- * @param type $password SUN user password
463
- * @return boolean|string License Key or FALSE
464
- */
465
- public function LogInSun($user_name, $password) {
466
- //---------------------------------------------------------------------------------------------------
467
- $request = $this->CallSUN('get_api_key', array(
468
- 'username' => $user_name,
469
- 'password' => $password
470
- ), true, false, true, true);
471
-
472
- if (!is_null($request->key) && $request->key != '') {
473
- return $request->key;
474
- }
475
-
476
- return false;
477
- //---------------------------------------------------------------------------------------------------
478
- }
479
-
480
- /**
481
- * Checks if access token from SUN @see LogInSun
482
- * is the same as local access token
483
- * @param type $sun_access_token SUN access token
484
- * @return boolean
485
- */
486
- public function CheckAccessToken($sun_access_token) {
487
- //---------------------------------------------------------------------------------------------------
488
- if ($sun_access_token == $this->GetAccessToken() && $this->IsConnected()) {
489
- return true;
490
- }
491
-
492
- return false;
493
- //---------------------------------------------------------------------------------------------------
494
- }
495
-
496
- /*
497
- * Viewer downloader
498
- */
499
- public function DownloadViewer($viewer_url) {
500
-
501
- $viewer_url = str_ireplace('.html', '', $viewer_url);
502
-
503
- //----------------------------------------------------------
504
- if ($this->test) {
505
- $this->testclass->AppendTest('download_viewer_start['.$viewer_url.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
506
- }
507
- //----------------------------------------------------------
508
-
509
- //----------------------------------------------------------
510
- /**/ $this->return_debug(array(
511
- /**/ 'function' => __FUNCTION__,
512
- /**/ 'viewer_url' => $viewer_url
513
- /**/ ));
514
- //----------------------------------------------------------
515
-
516
- /*
517
- * Download the viewer
518
- */
519
- $file = $this->CallAPI($viewer_url);
520
-
521
- //----------------------------------------------------------
522
- /**/ $this->return_debug(array(
523
- /**/ 'function' => __FUNCTION__,
524
- /**/ 'file' => (strlen($file) > 100 ? '[ZIP_FILE]' : '')
525
- /**/ ));
526
- //----------------------------------------------------------
527
-
528
- /*
529
- * Try to put the content to the zip file
530
- */
531
- $temp_dir = __DIR__.'/'.$this->DownloadPath;
532
- $temp_file = __DIR__.'/'.$this->DownloadPath.'temp.zip';
533
-
534
- if (file_put_contents($temp_file, $file)) {
535
- /*
536
- * Check if upload was successfull
537
- */
538
- if (file_exists($temp_file)) {
539
- //----------------------------------------------------------
540
- if ($this->test) {
541
- $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
542
- }
543
- //----------------------------------------------------------
544
-
545
- /*
546
- * Return file path
547
- */
548
- return $temp_file;
549
- }
550
- else {
551
- //----------------------------------------------------------
552
- if ($this->test) {
553
- $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
554
- }
555
- //----------------------------------------------------------
556
-
557
- //---------------------------------------------------------------------------------------------------
558
- throw new Exception('Orbitvu: cannot download viewer file to '.$temp_dir);
559
- //---------------------------------------------------------------------------------------------------
560
- }
561
- }
562
- else {
563
- //----------------------------------------------------------
564
- if ($this->test) {
565
- $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
566
- }
567
- //----------------------------------------------------------
568
-
569
- //---------------------------------------------------------------------------------------------------
570
- throw new Exception('Orbitvu: cannot download viewer file. Set "write" permissions to '.$temp_dir);
571
- //---------------------------------------------------------------------------------------------------
572
- }
573
- }
574
-
575
- /**
576
- * Install presentation from file
577
- *
578
- * Check if file is .ovus (Orbitvu Sequence) or .zip package.
579
- * If so, unpack archive and refresh page
580
- *
581
- * Console like installator, needs to be working with any e-commerce platform/CMS),
582
- * that's why:
583
- * - I didn't used templates,
584
- * - I used exit() to stop rendering page by any platform we use,
585
- * - I used JavaScript redirect as this will be run in a browser, but one archive at the time
586
- * (a way to trick every server limits)
587
- *
588
- * @param string $file Presentation archive file (*.ovus, *.zip)
589
- * @param boolean $print_output Print console-like output messages
590
- * @return string
591
- */
592
- public function InstallPresentation($file, $print_output = true) {
593
-
594
- $dir_or_file = $file;
595
- $dir_name = explode('/', $dir_or_file);
596
- $dir_name = $dir_name[count($dir_name)-1];
597
-
598
- $is_sun = false;
599
- //-------------------------------------------------------------------------------------------------------
600
- if ($print_output) {
601
- echo '<div style="margin: 20px 10% 20px 10%; font: 14px Arial;"><strong>Orbitvu - Presentations Installer</strong><br />
602
- You will be redirected to your store automatically after installation.<br /><br /><pre style="font-size: 12px;">';
603
-
604
- echo '['.date('Y-m-d H:i:s').'] ';
605
- }
606
- //-------------------------------------------------------------------------------------------------------
607
-
608
- /**
609
- * Installing
610
- */
611
- //-------------------------------------------------------------------------------------------------------
612
- if (stristr($dir_name, '.ovus')) {
613
- $ext = '.ovus';
614
- }
615
- else {
616
- $ext = '.zip';
617
- }
618
- //-------------------------------------------------------------------------------------------------------
619
-
620
- if ($print_output) {
621
- echo 'Installing '.$ext.' presentation "'.$dir_name.'"...';
622
- }
623
-
624
- /**
625
- * Try to unpack the archive
626
- */
627
- try {
628
- $new_dir = $this->PresentationsPath.str_ireplace($ext, '', $dir_name);
629
-
630
- $this->Unzip($dir_or_file, $new_dir);
631
-
632
- /**
633
- * Is the archive from Orbitvu SUN?
634
- */
635
- if (file_exists($new_dir.'/orbitvu12')) {
636
- $is_sun = true;
637
-
638
- /**
639
- * Move presentations to parent folder
640
- */
641
- $tree = $this->GetDirectoryTree($new_dir);
642
- foreach ($tree as $current_inode) {
643
-
644
- /**
645
- * Make sure we didn't move the viewer from the package and any .html presentations
646
- * We will not use these
647
- */
648
- if (!stristr($current_inode, 'orbitvu12') && !stristr($current_inode, '.html')) {
649
-
650
- $current_name = explode('/', $current_inode);
651
- $current_name = $current_name[count($current_name)-1];
652
-
653
- rename($current_inode, $this->PresentationsPath.$current_name);
654
- }
655
- }
656
-
657
- /**
658
- * Delete unpacked folder
659
- */
660
- $this->rrmdir($new_dir);
661
- }
662
-
663
- if ($print_output) {
664
- echo ' OK<script type="text/javascript">window.location.reload();</script>'."\n";
665
- }
666
- else {
667
- return true;
668
- }
669
- }
670
- catch (Exception $e) {
671
- if ($print_output) {
672
- echo '<span style="color: red;font-weight: bold;"> FAILED</span><script type="text/javascript">alert(\'Installation failed!\');</script>'."\n";
673
- echo $e->getMessage();
674
- }
675
- else {
676
- return false;
677
- }
678
-
679
- }
680
-
681
- if ($print_output) {
682
- echo '</pre></div>';
683
-
684
- exit();
685
- }
686
-
687
- }
688
-
689
- /**
690
- * Install Viewer if $viewer_type is available
691
- * @param string $viewer_type Viewer type name
692
- * @return boolean
693
- * @throws Exception
694
- */
695
- public function InstallViewer($viewer_type = 'BASIC') {
696
-
697
- $viewers = $this->CallSun('viewers/licenses');
698
-
699
- foreach ($viewers as $viewer) {
700
-
701
- if ($viewer->type == $viewer_type) {
702
-
703
- /**
704
- * Temporary file name
705
- */
706
- $file_name = 'viewer.zip';
707
-
708
- /**
709
- * Download Viewer
710
- */
711
- $viewer = $this->CallAPI($this->clean_url($viewer->download), '', false, false, true);
712
-
713
- if (file_put_contents($this->ViewerPath.$file_name, $viewer)) {
714
-
715
- /**
716
- * Unzip the package
717
- */
718
-
719
- $this->Unzip($this->ViewerPath.$file_name, $this->ViewerPath);
720
-
721
- /**
722
- * Delete temporary file
723
- */
724
- unlink($this->ViewerPath.$file_name);
725
-
726
- return true;
727
- }
728
- else {
729
- throw new Exception('Orbitvu: cannot download Orbitvu Viewer. Set "write" permissions to directory '.$this->ViewerPath.'. If permissions are correct, contact Orbitvu dev@orbitvu.com, as it\'s can be Orbitvu Sun connection issue.');
730
- }
731
- }
732
- }
733
-
734
- }
735
-
736
- /*
737
- * Unzip
738
- * Require ZipArchive (PHP standard from 5.2.0)
739
- */
740
- public function Unzip($file, $path = null) {
741
-
742
- if ($path == null) {
743
- $path = $this->ViewerPath;
744
- }
745
-
746
- //----------------------------------------------------------
747
- if ($this->test) {
748
- $this->testclass->AppendTest('unzip['.$file.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
749
- }
750
- //----------------------------------------------------------
751
- /*
752
- * Check if user have ZipArchive class installed
753
- */
754
- if (!class_exists('ZipArchive')) {
755
- //----------------------------------------------------------
756
- if ($this->test) {
757
- $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
758
- }
759
- //----------------------------------------------------------
760
-
761
- //---------------------------------------------------------------------------------------------------
762
- throw new Exception('Orbitvu: PHP extension ZipArchive doesn\'t exist. Upgrade your PHP version to >= 5.2.0 or install ZipArchive: php.net/ZipArchive or unzip file manually');
763
- //---------------------------------------------------------------------------------------------------
764
- return false;
765
- }
766
-
767
- /*
768
- * Unpacking the archive
769
- */
770
- $zip = new ZipArchive();
771
- //---------------------------------------------------------------------------------------------------
772
- if ($res = $zip->open($file)) {
773
-
774
- if ($res === true) {
775
- //---------------------------------------------------------------------------------------------------
776
- /*
777
- * Extract
778
- */
779
- $zip->extractTo($path);
780
- $zip->close();
781
-
782
- /*
783
- * Delete the temp .zip file
784
- */
785
- unlink($file);
786
-
787
- if (file_exists($file)) {
788
- throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to dir '.$path.' and to the parent directory.');
789
- }
790
-
791
- //----------------------------------------------------------
792
- if ($this->test) {
793
- $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
794
- }
795
- //----------------------------------------------------------
796
-
797
- //---------------------------------------------------------------------------------------------------
798
- return true;
799
- //---------------------------------------------------------------------------------------------------
800
- }
801
- else {
802
- //----------------------------------------------------------
803
- if ($this->test) {
804
- $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
805
- }
806
- //----------------------------------------------------------
807
-
808
- //---------------------------------------------------------------------------------------------------
809
- throw new Exception('Orbitvu: cannot extract the file. Not valid file format or directory '.$path.' not found. Create this directory and set "write" permissions');
810
- //---------------------------------------------------------------------------------------------------
811
- }
812
- }
813
- else {
814
- //----------------------------------------------------------
815
- if ($this->test) {
816
- $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
817
- }
818
- //----------------------------------------------------------
819
-
820
- //---------------------------------------------------------------------------------------------------
821
- throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to '.$path);
822
- //---------------------------------------------------------------------------------------------------
823
- }
824
- }
825
-
826
- /**
827
- * Lists all directories
828
- * @param type $dir
829
- * @param type $no_basefiles
830
- * @return array
831
- */
832
- public static function GetDirectoryTree($dir, $no_basefiles = true, $per_page = 0, $page = 0) {
833
- //--------------------------------------------------------------------------------------------------------------------
834
- if ($page > 0) {
835
- $page--;
836
- }
837
- //-------------------------------------------------------------------------------------------------------
838
- $files = array();
839
-
840
- $i = 0;
841
- $j = 0;
842
- foreach (new DirectoryIterator($dir) as $current_file) {
843
- //-------------------------------------------------------------------------------------------------------
844
- if ($current_file->isDot() && $no_basefiles) {
845
- continue;
846
- }
847
- //-------------------------------------------------------------------------------------------------------
848
- if ($page > 0) {
849
- $j++;
850
-
851
- if ($j <= $per_page * $page) {
852
- $i = 0;
853
- }
854
- }
855
- //-------------------------------------------------------------------------------------------------------
856
- if ($i == $per_page && $per_page > 0) {
857
- break;
858
- }
859
- //-------------------------------------------------------------------------------------------------------
860
- if ($page == 0 || ($page > 0 && $j > $per_page * $page)) {
861
- $files[] = $current_file->getPathname();
862
- }
863
- //-------------------------------------------------------------------------------------------------------
864
- $i++;
865
- }
866
-
867
- return $files;
868
- //--------------------------------------------------------------------------------------------------------------------
869
- }
870
-
871
- /**
872
- * Counts presentations
873
- * @param string $dir
874
- * @return integer
875
- */
876
- public function GetPresentationsCount($dir) {
877
- //--------------------------------------------------------------------------------------------------------------------
878
- if ($this->presentations_count == 0) {
879
- $pres = self::GetDirectoryTree($dir);
880
-
881
- $this->presentations_count = count($pres);
882
- }
883
-
884
- return intval($this->presentations_count);
885
- //--------------------------------------------------------------------------------------------------------------------
886
- }
887
-
888
- /**
889
- * Converts XML content to multi-dimensional array
890
- * @param type $xml_content
891
- * @return array
892
- * @throws Exception
893
- */
894
- public static function XMLtoArray($xml_content) {
895
- //-------------------------------------------------------------------------------------------------------
896
- /*
897
- * Check if user have ZipArchive class installed
898
- */
899
- if (!class_exists('SimpleXMLElement')) {
900
- //---------------------------------------------------------------------------------------------------
901
- throw new Exception('Orbitvu: PHP extension SimpleXMLElement doesn\'t exist. Upgrade your PHP version to >= 5.0.1');
902
- //---------------------------------------------------------------------------------------------------
903
- }
904
-
905
- $xml = new SimpleXMLElement($xml_content);
906
-
907
- $xml_array = unserialize(serialize(json_decode(json_encode((array) $xml), 1)));
908
-
909
- return $xml_array;
910
- //-------------------------------------------------------------------------------------------------------
911
- }
912
-
913
- /**
914
- * Remove directory recursively
915
- * @param string $dirPath Directory to delete (could be non empty)
916
- */
917
- private function rrmdir($dirPath) {
918
- if (!is_dir($dirPath)) {
919
- throw new InvalidArgumentException($dirPath.' must be a directory');
920
- }
921
-
922
- if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
923
- $dirPath .= '/';
924
- }
925
-
926
- $files = glob($dirPath . '*', GLOB_MARK);
927
- foreach ($files as $file) {
928
- if (is_dir($file)) {
929
- $this->rrmdir($file);
930
- } else {
931
- unlink($file);
932
- }
933
- }
934
-
935
- rmdir($dirPath);
936
- }
937
-
938
- /**
939
- * Cleans API URL with http / https dependences
940
- * @param string $url Url to clean
941
- * @return string
942
- */
943
- private function clean_url($url) {
944
- //----------------------------------------------------------
945
- if ($this->test) {
946
- $this->testclass->AppendTest('clean_url['.$url.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
947
- }
948
- //---------------------------------------------------------------------------------------------------
949
- if (stristr($url, 'https://')) {
950
- return $url;
951
- }
952
- else if (stristr($url, 'http://')) {
953
- return str_ireplace('http://', 'https://', $url);
954
- }
955
- else if (stristr($url, '//') && stristr($url, '.')) {
956
- return str_ireplace('//', 'https://', $url);
957
- }
958
- //---------------------------------------------------------------------------------------------------
959
- return $url;
960
- //---------------------------------------------------------------------------------------------------
961
- }
962
-
963
- /**
964
- * Count days between two dates
965
- * @param date $date1 Date
966
- * @param date $date2 Date
967
- * @return integer
968
- */
969
- private function count_days($date1, $date2) {
970
- //-------------------------------------------------------------------------------------------------------
971
- $y1 = date('Y', strtotime($date1));
972
- $m1 = date('m', strtotime($date1));
973
- $d1 = date('d', strtotime($date1));
974
-
975
- $y2 = date('Y', strtotime($date2));
976
- $m2 = date('m', strtotime($date2));
977
- $d2 = date('d', strtotime($date2));
978
-
979
- $date1_set = mktime(0, 0, 0, $m1, $d1, $y1);
980
- $date2_set = mktime(0, 0, 0, $m2, $d2, $y2);
981
- //-------------------------------------------------------------------------------------------------------
982
- return (round(($date2_set - $date1_set) / (60 * 60 * 24)));
983
- //-------------------------------------------------------------------------------------------------------
984
- }
985
-
986
- /**
987
- * Run unit tests
988
- * @todo Add tests for new functions
989
- */
990
- private function run_tests() {
991
- //-----------------------------------------------------------------------------------------------------
992
- /*
993
- * Basic functions
994
- */
995
- //-----------------------------------------------------------------------------------------------------
996
- $tests_urls = array(
997
- 'http://orbitvu.com' => 'https://orbitvu.com',
998
- 'https://orbitvu.com' => 'https://orbitvu.com',
999
- '//orbitvu.com' => 'https://orbitvu.com',
1000
- 'orbitvu.com' => 'orbitvu.com',
1001
- 'orbitvu//com' => 'orbitvu//com'
1002
- );
1003
- $keys = array_keys($tests_urls);
1004
- $vals = array_values($tests_urls);
1005
- //-----------------------------------------------------------------------------------------------------
1006
- for ($i = 0, $n = count($tests_urls); $i < $n; $i++) {
1007
-
1008
- $clean = $this->clean_url($keys[$i]);
1009
-
1010
- $tst = array(
1011
- /**/ 'function' => 'clean_url('.$keys[$i].')',
1012
- /**/ 'given' => $clean,
1013
- /**/ 'expected' => $vals[$i]
1014
- );
1015
-
1016
- if ($clean == $vals[$i]) {
1017
- $result = 'ok';
1018
- }
1019
- else {
1020
- $result = 'fail';
1021
- }
1022
-
1023
- $this->testclass->UpdateTest('clean_url['.$keys[$i].']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
1024
- }
1025
-
1026
- //-----------------------------------------------------------------------------------------------------
1027
- /*
1028
- * Presentations display
1029
- */
1030
- //-----------------------------------------------------------------------------------------------------
1031
- $call = 'presentations';
1032
-
1033
- $response = $this->CallSUN($call);
1034
-
1035
- $status = 'ok';
1036
- $status = 'fail';
1037
- //---------------------------------------------------------------------------------------------------
1038
- $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
1039
- //---------------------------------------------------------------------------------------------------
1040
- }
1041
-
1042
- /**
1043
- * Debugger. Returns debug output if debug mode is enabled
1044
- * @param array $params
1045
- * @return string
1046
- */
1047
- private function return_debug($params) {
1048
- //---------------------------------------------------------------------------------------------------
1049
- if ($this->debug) {
1050
- return OrbitvuDebugger::Debug($params);
1051
- }
1052
- //---------------------------------------------------------------------------------------------------
1053
- }
1054
-
1055
- }
1056
-
1057
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP Orbitvu eCommerce SUN connector
4
+ * @copyright Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ * @license Commercial
6
+ */
7
+
8
+ final class Orbitvu {
9
+
10
+ /**
11
+ * License Key
12
+ * @var string
13
+ */
14
+ private $access_token;
15
+
16
+ /**
17
+ * Debug mode
18
+ * @var boolean
19
+ */
20
+ private $debug = false;
21
+
22
+ /**
23
+ * Unit tests mode
24
+ * @var boolean
25
+ */
26
+ private $test = false;
27
+
28
+ /**
29
+ * Test class instance
30
+ * @var instance
31
+ */
32
+ private $testclass = false;
33
+
34
+ /**
35
+ * Curl version
36
+ * @var string
37
+ */
38
+ private $curl_version;
39
+
40
+ /**
41
+ * New available version of plugin
42
+ * @var string
43
+ */
44
+ private $plugin_available_version;
45
+
46
+ /**
47
+ * License end date
48
+ * @var date Y-m-d
49
+ */
50
+ private $plugin_support;
51
+
52
+ /**
53
+ * Default DEMO access token
54
+ * Available to change (if updated)
55
+ * @var string
56
+ */
57
+ private $demo_access_token = '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29';
58
+
59
+ /**
60
+ * Local presentations count
61
+ * @var integer
62
+ */
63
+ private $presentations_count = 0;
64
+
65
+ /**
66
+ * Viewers path
67
+ * @fixme delete if not used
68
+ * @var string
69
+ */
70
+ public $ViewerPath = 'viewers/src/';
71
+
72
+ /**
73
+ * Temporary path for uploads
74
+ * @var string
75
+ */
76
+ public $DownloadPath = 'tmp/';
77
+
78
+ /**
79
+ * Temporary path for uploads
80
+ * @var string
81
+ */
82
+ public $PresentationsPath = 'orbitvu_presentations/';
83
+
84
+ /**
85
+ * Let's do the magic
86
+ * @param string $access_token License Key
87
+ * @param boolean $debug Debug mode
88
+ * @param boolean $test Unit tests mode
89
+ * @param boolean $testinstance Unit tests instance.
90
+ */
91
+ public function __construct($access_token, $debug = false, $test = false, $testinstance = false) {
92
+ //---------------------------------------------------------------------------------------------------
93
+ $this->access_token = $access_token;
94
+ $this->debug = $debug;
95
+ $this->test = $test;
96
+ //---------------------------------------------------------------------------------------------------
97
+
98
+ /*
99
+ * Test instance
100
+ */
101
+ //---------------------------------------------------------------------------------------------------
102
+ if ($this->test) {
103
+ $this->testclass = $testinstance;
104
+
105
+ /*
106
+ * Run test bot!
107
+ */
108
+ $this->run_tests();
109
+ }
110
+ //---------------------------------------------------------------------------------------------------
111
+
112
+ //----------------------------------------------------------
113
+ /**/ if ($this->debug || $this->test) {
114
+ /**/ error_reporting(E_ALL & ~E_NOTICE);
115
+ /**/ ini_set('display_errors', '1');
116
+ /**/ }
117
+ //----------------------------------------------------------
118
+ }
119
+
120
+ /**
121
+ * Set the CURL version
122
+ * @param string $v CURL version
123
+ */
124
+ public function IntroduceYourself($v) {
125
+ //-------------------------------------------------------------------------------------------------------
126
+ $this->curl_version = $v;
127
+ //-------------------------------------------------------------------------------------------------------
128
+ }
129
+
130
+ /**
131
+ * Get the demo access token
132
+ * @return string
133
+ */
134
+ public function GetDemoAccessToken() {
135
+ //-------------------------------------------------------------------------------------------------------
136
+ return $this->demo_access_token;
137
+ //-------------------------------------------------------------------------------------------------------
138
+ }
139
+
140
+ /**
141
+ * Check if current license is demo
142
+ * @return boolean
143
+ */
144
+ public function IsDemo() {
145
+ //-------------------------------------------------------------------------------------------------------
146
+ if ($this->access_token == $this->GetDemoAccessToken() && $this->IsConnected()) {
147
+ //-------------------------------------------------------------------------------------------------------
148
+ return true;
149
+ //-------------------------------------------------------------------------------------------------------
150
+ }
151
+ //-------------------------------------------------------------------------------------------------------
152
+ return false;
153
+ //-------------------------------------------------------------------------------------------------------
154
+ }
155
+
156
+ /**
157
+ * Want to change access_token for current session? No problem
158
+ * @param string $access_token New access token
159
+ */
160
+ public function SetAccessToken($access_token) {
161
+ //---------------------------------------------------------------------------------------------------
162
+ $this->access_token = $access_token;
163
+ //---------------------------------------------------------------------------------------------------
164
+ }
165
+
166
+ /**
167
+ * Get current License Key
168
+ * @return string
169
+ */
170
+ public function GetAccessToken() {
171
+ //---------------------------------------------------------------------------------------------------
172
+ return $this->access_token;
173
+ //---------------------------------------------------------------------------------------------------
174
+ }
175
+
176
+ /**
177
+ * Unit tests results
178
+ * @return array
179
+ */
180
+ public function GetTestsResults() {
181
+ //---------------------------------------------------------------------------------------------------
182
+ return $this->testclass->GetResults();
183
+ //---------------------------------------------------------------------------------------------------
184
+ }
185
+
186
+ /**
187
+ * Orbitvu SUN API calling function
188
+ * @param string $call API path to call
189
+ * @param array|string $parameters Additional parameters to call
190
+ * @param boolean $method_post Use POST method
191
+ * @param boolean $get_headers Get HTTP headers
192
+ * @param boolean $not_change Disable automatic call formatting
193
+ * @param boolean $no_query_string Enable if sending sensitive data via POST
194
+ * @return json|strong
195
+ */
196
+ public function CallAPI($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false, $no_query_string = false) {
197
+ //---------------------------------------------------------------------------------------------------
198
+ /*
199
+ * Add URL parameters from array to URL
200
+ */
201
+ // presentation url auto status
202
+ if (stristr($call, 'presentations') && !stristr($call, 'status=')) {
203
+ if (!is_array($parameters)) {
204
+ $parameters = array('status' => '1');
205
+ }
206
+ else if (!isset($parameters['status'])) {
207
+ $parameters['status'] = '1';
208
+ }
209
+ }
210
+
211
+ /*
212
+ * POST
213
+ */
214
+ if ($method_post && !$not_change) {
215
+ $parameters['_method'] = 'PATCH';
216
+ }
217
+
218
+ /*
219
+ * Add URL parameters from array to URL
220
+ */
221
+ if (is_array($parameters)) {
222
+ $parameters_array = $parameters;
223
+ //---------------------------------------------------------------------------------------------------
224
+ $keys = array_keys($parameters);
225
+ $vals = array_values($parameters);
226
+
227
+ $parameters = '';
228
+ //---------------------------------------------------------------------------------------------------
229
+ for ($i = 0, $n = count($keys); $i < $n; $i++) {
230
+ if ($i == 0) $parameters .= '?';
231
+ else $parameters .= '&';
232
+
233
+ $parameters .= $keys[$i].'='.$vals[$i];
234
+ }
235
+ //---------------------------------------------------------------------------------------------------
236
+ }
237
+
238
+ //----------------------------------------------------------
239
+ if ($this->test) {
240
+ $this->testclass->AppendTest('api_call['.$call.']', array('type' => 'function_replace'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
241
+ return $this->testclass->CallAPI($call, $parameters);
242
+ }
243
+ //----------------------------------------------------------
244
+
245
+ /*
246
+ * Make both ways calling option
247
+ * but return json as possible
248
+ */
249
+ if (stristr($call, '//')) {
250
+ $url = $this->clean_url($call);
251
+ }
252
+ else {
253
+ $url = 'https://orbitvu.co/api/ecommerce/'.trim(str_replace(array('.html', '.json'), '', $call), '/').($method_post && !$not_change ? '' : '/').'.json';
254
+ }
255
+
256
+ /**
257
+ * If query string is on, attach parameters to query also,
258
+ * even if POST or PUT method
259
+ */
260
+ if (!$no_query_string) {
261
+ $url .= $parameters;
262
+ }
263
+
264
+ /*
265
+ * Set the access token
266
+ */
267
+ $header[] = "Authorization: Token ".$this->access_token;
268
+ $header[] = "Accept-User-Agent: ".OrbitvuDatabaseDriver::DRIVER_VERSION;
269
+ $header[] = "Accept-User-Agent-Version: ".$this->curl_version;
270
+
271
+ //----------------------------------------------------------
272
+ /**/ $this->return_debug(array(
273
+ /**/ 'function' => __FUNCTION__,
274
+ /**/ 'url' => $url,
275
+ /**/ 'headers' => $header,
276
+ /**/ 'parameters' => isset($parameters_array) ? $parameters_array : array(),
277
+ /**/ 'post' => ($method_post ? 'true' : 'false')
278
+ /**/ ));
279
+ //----------------------------------------------------------
280
+
281
+ /*
282
+ * Call SUN with CURL
283
+ * Method: GET
284
+ * + headers
285
+ */
286
+ $c = curl_init();
287
+ curl_setopt($c, CURLOPT_URL, $url);
288
+ curl_setopt($c, CURLOPT_HTTPHEADER, $header);
289
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
290
+ curl_setopt($c, CURLOPT_CONNECTTIMEOUT,10);
291
+ curl_setopt($c, CURLOPT_TIMEOUT,20);
292
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
293
+ if ($method_post) {
294
+ curl_setopt($c, CURLOPT_POST, count($parameters_array));
295
+ curl_setopt($c, CURLOPT_POSTFIELDS, $parameters_array);
296
+ }
297
+ if ($get_headers) {
298
+ curl_setopt($c, CURLOPT_VERBOSE, 1);
299
+ curl_setopt($c, CURLOPT_HEADER, 1);
300
+ }
301
+ $page = curl_exec($c);
302
+
303
+
304
+ if ($get_headers) {
305
+ //---------------------------------------------------------------------------------------------------
306
+ $header_size = curl_getinfo($c, CURLINFO_HEADER_SIZE);
307
+ $header = substr($page, 0, $header_size);
308
+ $body = substr($page, $header_size);
309
+ //---------------------------------------------------------------------------------------------------
310
+ if (!stristr($header, '200 OK')) {
311
+ $body = json_decode($body);
312
+ $error = explode("\n", $header);
313
+ $error = explode(' ', $error[0]);
314
+ $error = $error[1];
315
+ $body->error = $error;
316
+ $body->header = $header;
317
+ $body = json_encode($body);
318
+ }
319
+ //---------------------------------------------------------------------------------------------------
320
+ $page = $body;
321
+ //---------------------------------------------------------------------------------------------------
322
+ }
323
+
324
+ /*
325
+ * Return SUN original response
326
+ */
327
+ //---------------------------------------------------------------------------------------------------
328
+ curl_close($c);
329
+
330
+ return $page;
331
+ //---------------------------------------------------------------------------------------------------
332
+ }
333
+
334
+ /**
335
+ * Orbitvu SUN API calling alias to CallAPI function.
336
+ * Returns decoded json.
337
+ * @param string $call API path to call
338
+ * @param array|string $parameters Additional parameters to call
339
+ * @param boolean $method_post Use POST method
340
+ * @param boolean $get_headers Get HTTP headers
341
+ * @param boolean $not_change Disable automatic call formatting
342
+ * @param boolean $no_query_string Enable if sending sensitive data via POST
343
+ * @return stdClass
344
+ */
345
+ public function CallSUN($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false, $no_query_string = false) {
346
+ //---------------------------------------------------------------------------------------------------
347
+ $page = json_decode($this->CallAPI($call, $parameters, $method_post, $get_headers, $not_change, $no_query_string));
348
+
349
+ //----------------------------------------------------------
350
+ /**/ $this->return_debug(array(
351
+ /**/ 'function' => __FUNCTION__,
352
+ /**/ 'response' => $page
353
+ /**/ ));
354
+ //----------------------------------------------------------
355
+
356
+ //---------------------------------------------------------------------------------------------------
357
+ return $page;
358
+ //---------------------------------------------------------------------------------------------------
359
+ }
360
+
361
+ /**
362
+ * Check if we are connected
363
+ * Also, get updates info if available
364
+ * @return boolean
365
+ * @fixme new licenses with Maciej
366
+ */
367
+ public function IsConnected() {
368
+ //---------------------------------------------------------------------------------------------------
369
+ $get = $this->CallSUN('plugins/versions/latest', '', false, true);
370
+ //-------------------------------------------------------------------------------------------------------
371
+ $this->plugin_available_version = property_exists($get, 'version') ? $get->version : null;
372
+ $this->plugin_support = property_exists($get, 'support') ? $get->support : null;
373
+
374
+ if (property_exists($get, 'error') && $get->error) {
375
+ return false;
376
+ }
377
+ //-------------------------------------------------------------------------------------------------------
378
+ return true;
379
+ //---------------------------------------------------------------------------------------------------
380
+ }
381
+
382
+ /**
383
+ * Check for available updates
384
+ * @return stdClass|boolean
385
+ */
386
+ public function CheckForUpdates() {
387
+ //-------------------------------------------------------------------------------------------------------
388
+ if ($this->curl_version != $this->plugin_available_version) {
389
+ //-------------------------------------------------------------------------------------------------------
390
+ $ret = new stdClass();
391
+ $ret->version = $this->curl_version;
392
+ $ret->new_version = $this->plugin_available_version;
393
+ //-------------------------------------------------------------------------------------------------------
394
+ return $ret;
395
+ //-------------------------------------------------------------------------------------------------------
396
+ }
397
+ //-------------------------------------------------------------------------------------------------------
398
+ return false;
399
+ //-------------------------------------------------------------------------------------------------------
400
+ }
401
+
402
+ /**
403
+ * License days counter
404
+ * @return integer|string
405
+ */
406
+ public function GetSupportDays() {
407
+ //-------------------------------------------------------------------------------------------------------
408
+ if (!is_null($this->plugin_support)) {
409
+ //-------------------------------------------------------------------------------------------------------
410
+ $ret = new stdClass();
411
+ $ret->days = $this->count_days($this->plugin_support, date('Y-m-d'));
412
+ $ret->date = $this->plugin_support;
413
+ //-------------------------------------------------------------------------------------------------------
414
+ }
415
+ //-------------------------------------------------------------------------------------------------------
416
+ return 'n/a';
417
+ //-------------------------------------------------------------------------------------------------------
418
+ }
419
+
420
+ /**
421
+ * Register an account
422
+ * @param string $email Email to register
423
+ * @return stdClass
424
+ */
425
+ public function CreateAccount($email) {
426
+ //---------------------------------------------------------------------------------------------------
427
+ $reg_token = $this->CallSUN('regtoken', '', true, true, true);
428
+ //---------------------------------------------------------------------------------------------------
429
+ if (is_null($reg_token->token)) {
430
+ //---------------------------------------------------------------------------------------------------
431
+ throw new Exception('Orbitvu: cannot get a token');
432
+ //---------------------------------------------------------------------------------------------------
433
+ }
434
+ //---------------------------------------------------------------------------------------------------
435
+ $reg = $this->CallSUN('reguser', array(
436
+ 'token' => $reg_token->token,
437
+ 'email' => $email
438
+ ), true, true, true);
439
+ //---------------------------------------------------------------------------------------------------
440
+ if ($reg->email[0]) {
441
+ //---------------------------------------------------------------------------------------------------
442
+ throw new Exception($reg->email[0]);
443
+ //---------------------------------------------------------------------------------------------------
444
+ }
445
+ //---------------------------------------------------------------------------------------------------
446
+ $reg->email = $email;
447
+
448
+ //----------------------------------------------------------
449
+ /**/ $this->return_debug(array(
450
+ /**/ 'function' => __FUNCTION__,
451
+ /**/ 'response' => $reg
452
+ /**/ ));
453
+ //----------------------------------------------------------
454
+
455
+ //---------------------------------------------------------------------------------------------------
456
+ return $reg;
457
+ }
458
+
459
+ /**
460
+ * Gets a client License Key (Access Token) from Orbitvu SUN account after log in
461
+ * @param type $user_name SUN user name
462
+ * @param type $password SUN user password
463
+ * @return boolean|string License Key or FALSE
464
+ */
465
+ public function LogInSun($user_name, $password) {
466
+ //---------------------------------------------------------------------------------------------------
467
+ $request = $this->CallSUN('get_api_key', array(
468
+ 'username' => $user_name,
469
+ 'password' => $password
470
+ ), true, false, true, true);
471
+
472
+ if (!is_null($request->key) && $request->key != '') {
473
+ return $request->key;
474
+ }
475
+
476
+ return false;
477
+ //---------------------------------------------------------------------------------------------------
478
+ }
479
+
480
+ /**
481
+ * Checks if access token from SUN @see LogInSun
482
+ * is the same as local access token
483
+ * @param type $sun_access_token SUN access token
484
+ * @return boolean
485
+ */
486
+ public function CheckAccessToken($sun_access_token) {
487
+ //---------------------------------------------------------------------------------------------------
488
+ if ($sun_access_token == $this->GetAccessToken() && $this->IsConnected()) {
489
+ return true;
490
+ }
491
+
492
+ return false;
493
+ //---------------------------------------------------------------------------------------------------
494
+ }
495
+
496
+ /*
497
+ * Viewer downloader
498
+ */
499
+ public function DownloadViewer($viewer_url) {
500
+
501
+ $viewer_url = str_ireplace('.html', '', $viewer_url);
502
+
503
+ //----------------------------------------------------------
504
+ if ($this->test) {
505
+ $this->testclass->AppendTest('download_viewer_start['.$viewer_url.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
506
+ }
507
+ //----------------------------------------------------------
508
+
509
+ //----------------------------------------------------------
510
+ /**/ $this->return_debug(array(
511
+ /**/ 'function' => __FUNCTION__,
512
+ /**/ 'viewer_url' => $viewer_url
513
+ /**/ ));
514
+ //----------------------------------------------------------
515
+
516
+ /*
517
+ * Download the viewer
518
+ */
519
+ $file = $this->CallAPI($viewer_url);
520
+
521
+ //----------------------------------------------------------
522
+ /**/ $this->return_debug(array(
523
+ /**/ 'function' => __FUNCTION__,
524
+ /**/ 'file' => (strlen($file) > 100 ? '[ZIP_FILE]' : '')
525
+ /**/ ));
526
+ //----------------------------------------------------------
527
+
528
+ /*
529
+ * Try to put the content to the zip file
530
+ */
531
+ $temp_dir = __DIR__.'/'.$this->DownloadPath;
532
+ $temp_file = __DIR__.'/'.$this->DownloadPath.'temp.zip';
533
+
534
+ if (file_put_contents($temp_file, $file)) {
535
+ /*
536
+ * Check if upload was successfull
537
+ */
538
+ if (file_exists($temp_file)) {
539
+ //----------------------------------------------------------
540
+ if ($this->test) {
541
+ $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
542
+ }
543
+ //----------------------------------------------------------
544
+
545
+ /*
546
+ * Return file path
547
+ */
548
+ return $temp_file;
549
+ }
550
+ else {
551
+ //----------------------------------------------------------
552
+ if ($this->test) {
553
+ $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
554
+ }
555
+ //----------------------------------------------------------
556
+
557
+ //---------------------------------------------------------------------------------------------------
558
+ throw new Exception('Orbitvu: cannot download viewer file to '.$temp_dir);
559
+ //---------------------------------------------------------------------------------------------------
560
+ }
561
+ }
562
+ else {
563
+ //----------------------------------------------------------
564
+ if ($this->test) {
565
+ $this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
566
+ }
567
+ //----------------------------------------------------------
568
+
569
+ //---------------------------------------------------------------------------------------------------
570
+ throw new Exception('Orbitvu: cannot download viewer file. Set "write" permissions to '.$temp_dir);
571
+ //---------------------------------------------------------------------------------------------------
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Install presentation from file
577
+ *
578
+ * Check if file is .ovus (Orbitvu Sequence) or .zip package.
579
+ * If so, unpack archive and refresh page
580
+ *
581
+ * Console like installator, needs to be working with any e-commerce platform/CMS),
582
+ * that's why:
583
+ * - I didn't used templates,
584
+ * - I used exit() to stop rendering page by any platform we use,
585
+ * - I used JavaScript redirect as this will be run in a browser, but one archive at the time
586
+ * (a way to trick every server limits)
587
+ *
588
+ * @param string $file Presentation archive file (*.ovus, *.zip)
589
+ * @param boolean $print_output Print console-like output messages
590
+ * @return string
591
+ */
592
+ public function InstallPresentation($file, $print_output = true) {
593
+
594
+ $dir_or_file = $file;
595
+ $dir_name = explode('/', $dir_or_file);
596
+ $dir_name = $dir_name[count($dir_name)-1];
597
+
598
+ $is_sun = false;
599
+ //-------------------------------------------------------------------------------------------------------
600
+ if ($print_output) {
601
+ echo '<div style="margin: 20px 10% 20px 10%; font: 14px Arial;"><strong>Orbitvu - Presentations Installer</strong><br />
602
+ You will be redirected to your store automatically after installation.<br /><br /><pre style="font-size: 12px;">';
603
+
604
+ echo '['.date('Y-m-d H:i:s').'] ';
605
+ }
606
+ //-------------------------------------------------------------------------------------------------------
607
+
608
+ /**
609
+ * Installing
610
+ */
611
+ //-------------------------------------------------------------------------------------------------------
612
+ if (stristr($dir_name, '.ovus')) {
613
+ $ext = '.ovus';
614
+ }
615
+ else {
616
+ $ext = '.zip';
617
+ }
618
+ //-------------------------------------------------------------------------------------------------------
619
+
620
+ if ($print_output) {
621
+ echo 'Installing '.$ext.' presentation "'.$dir_name.'"...';
622
+ }
623
+
624
+ /**
625
+ * Try to unpack the archive
626
+ */
627
+ try {
628
+ $new_dir = $this->PresentationsPath.str_ireplace($ext, '', $dir_name);
629
+
630
+ $this->Unzip($dir_or_file, $new_dir);
631
+
632
+ /**
633
+ * Is the archive from Orbitvu SUN?
634
+ */
635
+ if (file_exists($new_dir.'/orbitvu12')) {
636
+ $is_sun = true;
637
+
638
+ /**
639
+ * Move presentations to parent folder
640
+ */
641
+ $tree = $this->GetDirectoryTree($new_dir);
642
+ foreach ($tree as $current_inode) {
643
+
644
+ /**
645
+ * Make sure we didn't move the viewer from the package and any .html presentations
646
+ * We will not use these
647
+ */
648
+ if (!stristr($current_inode, 'orbitvu12') && !stristr($current_inode, '.html')) {
649
+
650
+ $current_name = explode('/', $current_inode);
651
+ $current_name = $current_name[count($current_name)-1];
652
+
653
+ rename($current_inode, $this->PresentationsPath.$current_name);
654
+ }
655
+ }
656
+
657
+ /**
658
+ * Delete unpacked folder
659
+ */
660
+ $this->rrmdir($new_dir);
661
+ }
662
+
663
+ if ($print_output) {
664
+ echo ' OK<script type="text/javascript">window.location.reload();</script>'."\n";
665
+ }
666
+ else {
667
+ return true;
668
+ }
669
+ }
670
+ catch (Exception $e) {
671
+ if ($print_output) {
672
+ echo '<span style="color: red;font-weight: bold;"> FAILED</span><script type="text/javascript">alert(\'Installation failed!\');</script>'."\n";
673
+ echo $e->getMessage();
674
+ }
675
+ else {
676
+ return false;
677
+ }
678
+
679
+ }
680
+
681
+ if ($print_output) {
682
+ echo '</pre></div>';
683
+
684
+ exit();
685
+ }
686
+
687
+ }
688
+
689
+ /**
690
+ * Install Viewer if $viewer_type is available
691
+ * @param string $viewer_type Viewer type name
692
+ * @return boolean
693
+ * @throws Exception
694
+ */
695
+ public function InstallViewer($viewer_type = 'BASIC') {
696
+
697
+ $viewers = $this->CallSun('viewers/licenses');
698
+
699
+ foreach ($viewers as $viewer) {
700
+
701
+ if ($viewer->type == $viewer_type) {
702
+
703
+ /**
704
+ * Temporary file name
705
+ */
706
+ $file_name = 'viewer.zip';
707
+
708
+ /**
709
+ * Download Viewer
710
+ */
711
+ $viewer = $this->CallAPI($this->clean_url($viewer->download), '', false, false, true);
712
+
713
+ if (file_put_contents($this->ViewerPath.$file_name, $viewer)) {
714
+
715
+ /**
716
+ * Unzip the package
717
+ */
718
+
719
+ $this->Unzip($this->ViewerPath.$file_name, $this->ViewerPath);
720
+
721
+ /**
722
+ * Delete temporary file
723
+ */
724
+ unlink($this->ViewerPath.$file_name);
725
+
726
+ return true;
727
+ }
728
+ else {
729
+ throw new Exception('Orbitvu: cannot download Orbitvu Viewer. Set "write" permissions to directory '.$this->ViewerPath.'. If permissions are correct, contact Orbitvu dev@orbitvu.com, as it\'s can be Orbitvu Sun connection issue.');
730
+ }
731
+ }
732
+ }
733
+
734
+ }
735
+
736
+ /*
737
+ * Unzip
738
+ * Require ZipArchive (PHP standard from 5.2.0)
739
+ */
740
+ public function Unzip($file, $path = null) {
741
+
742
+ if ($path == null) {
743
+ $path = $this->ViewerPath;
744
+ }
745
+
746
+ //----------------------------------------------------------
747
+ if ($this->test) {
748
+ $this->testclass->AppendTest('unzip['.$file.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
749
+ }
750
+ //----------------------------------------------------------
751
+ /*
752
+ * Check if user have ZipArchive class installed
753
+ */
754
+ if (!class_exists('ZipArchive')) {
755
+ //----------------------------------------------------------
756
+ if ($this->test) {
757
+ $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
758
+ }
759
+ //----------------------------------------------------------
760
+
761
+ //---------------------------------------------------------------------------------------------------
762
+ throw new Exception('Orbitvu: PHP extension ZipArchive doesn\'t exist. Upgrade your PHP version to >= 5.2.0 or install ZipArchive: php.net/ZipArchive or unzip file manually');
763
+ //---------------------------------------------------------------------------------------------------
764
+ return false;
765
+ }
766
+
767
+ /*
768
+ * Unpacking the archive
769
+ */
770
+ $zip = new ZipArchive();
771
+ //---------------------------------------------------------------------------------------------------
772
+ if ($res = $zip->open($file)) {
773
+
774
+ if ($res === true) {
775
+ //---------------------------------------------------------------------------------------------------
776
+ /*
777
+ * Extract
778
+ */
779
+ $zip->extractTo($path);
780
+ $zip->close();
781
+
782
+ /*
783
+ * Delete the temp .zip file
784
+ */
785
+ unlink($file);
786
+
787
+ if (file_exists($file)) {
788
+ throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to dir '.$path.' and to the parent directory.');
789
+ }
790
+
791
+ //----------------------------------------------------------
792
+ if ($this->test) {
793
+ $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
794
+ }
795
+ //----------------------------------------------------------
796
+
797
+ //---------------------------------------------------------------------------------------------------
798
+ return true;
799
+ //---------------------------------------------------------------------------------------------------
800
+ }
801
+ else {
802
+ //----------------------------------------------------------
803
+ if ($this->test) {
804
+ $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
805
+ }
806
+ //----------------------------------------------------------
807
+
808
+ //---------------------------------------------------------------------------------------------------
809
+ throw new Exception('Orbitvu: cannot extract the file. Not valid file format or directory '.$path.' not found. Create this directory and set "write" permissions');
810
+ //---------------------------------------------------------------------------------------------------
811
+ }
812
+ }
813
+ else {
814
+ //----------------------------------------------------------
815
+ if ($this->test) {
816
+ $this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
817
+ }
818
+ //----------------------------------------------------------
819
+
820
+ //---------------------------------------------------------------------------------------------------
821
+ throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to '.$path);
822
+ //---------------------------------------------------------------------------------------------------
823
+ }
824
+ }
825
+
826
+ /**
827
+ * Lists all directories
828
+ * @param type $dir
829
+ * @param type $no_basefiles
830
+ * @return array
831
+ */
832
+ public static function GetDirectoryTree($dir, $no_basefiles = true, $per_page = 0, $page = 0) {
833
+ //--------------------------------------------------------------------------------------------------------------------
834
+ if ($page > 0) {
835
+ $page--;
836
+ }
837
+ //-------------------------------------------------------------------------------------------------------
838
+ $files = array();
839
+
840
+ $i = 0;
841
+ $j = 0;
842
+ foreach (new DirectoryIterator($dir) as $current_file) {
843
+ //-------------------------------------------------------------------------------------------------------
844
+ if ($current_file->isDot() && $no_basefiles) {
845
+ continue;
846
+ }
847
+ //-------------------------------------------------------------------------------------------------------
848
+ if ($page > 0) {
849
+ $j++;
850
+
851
+ if ($j <= $per_page * $page) {
852
+ $i = 0;
853
+ }
854
+ }
855
+ //-------------------------------------------------------------------------------------------------------
856
+ if ($i == $per_page && $per_page > 0) {
857
+ break;
858
+ }
859
+ //-------------------------------------------------------------------------------------------------------
860
+ if ($page == 0 || ($page > 0 && $j > $per_page * $page)) {
861
+ $files[] = $current_file->getPathname();
862
+ }
863
+ //-------------------------------------------------------------------------------------------------------
864
+ $i++;
865
+ }
866
+
867
+ return $files;
868
+ //--------------------------------------------------------------------------------------------------------------------
869
+ }
870
+
871
+ /**
872
+ * Counts presentations
873
+ * @param string $dir
874
+ * @return integer
875
+ */
876
+ public function GetPresentationsCount($dir) {
877
+ //--------------------------------------------------------------------------------------------------------------------
878
+ if ($this->presentations_count == 0) {
879
+ $pres = self::GetDirectoryTree($dir);
880
+
881
+ $this->presentations_count = count($pres);
882
+ }
883
+
884
+ return intval($this->presentations_count);
885
+ //--------------------------------------------------------------------------------------------------------------------
886
+ }
887
+
888
+ /**
889
+ * Converts XML content to multi-dimensional array
890
+ * @param type $xml_content
891
+ * @return array
892
+ * @throws Exception
893
+ */
894
+ public static function XMLtoArray($xml_content) {
895
+ //-------------------------------------------------------------------------------------------------------
896
+ /*
897
+ * Check if user have ZipArchive class installed
898
+ */
899
+ if (!class_exists('SimpleXMLElement')) {
900
+ //---------------------------------------------------------------------------------------------------
901
+ throw new Exception('Orbitvu: PHP extension SimpleXMLElement doesn\'t exist. Upgrade your PHP version to >= 5.0.1');
902
+ //---------------------------------------------------------------------------------------------------
903
+ }
904
+
905
+ $xml = new SimpleXMLElement($xml_content);
906
+
907
+ $xml_array = unserialize(serialize(json_decode(json_encode((array) $xml), 1)));
908
+
909
+ return $xml_array;
910
+ //-------------------------------------------------------------------------------------------------------
911
+ }
912
+
913
+ /**
914
+ * Remove directory recursively
915
+ * @param string $dirPath Directory to delete (could be non empty)
916
+ */
917
+ private function rrmdir($dirPath) {
918
+ if (!is_dir($dirPath)) {
919
+ throw new InvalidArgumentException($dirPath.' must be a directory');
920
+ }
921
+
922
+ if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
923
+ $dirPath .= '/';
924
+ }
925
+
926
+ $files = glob($dirPath . '*', GLOB_MARK);
927
+ foreach ($files as $file) {
928
+ if (is_dir($file)) {
929
+ $this->rrmdir($file);
930
+ } else {
931
+ unlink($file);
932
+ }
933
+ }
934
+
935
+ rmdir($dirPath);
936
+ }
937
+
938
+ /**
939
+ * Cleans API URL with http / https dependences
940
+ * @param string $url Url to clean
941
+ * @return string
942
+ */
943
+ private function clean_url($url) {
944
+ //----------------------------------------------------------
945
+ if ($this->test) {
946
+ $this->testclass->AppendTest('clean_url['.$url.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
947
+ }
948
+ //---------------------------------------------------------------------------------------------------
949
+ if (stristr($url, 'https://')) {
950
+ return $url;
951
+ }
952
+ else if (stristr($url, 'http://')) {
953
+ return str_ireplace('http://', 'https://', $url);
954
+ }
955
+ else if (stristr($url, '//') && stristr($url, '.')) {
956
+ return str_ireplace('//', 'https://', $url);
957
+ }
958
+ //---------------------------------------------------------------------------------------------------
959
+ return $url;
960
+ //---------------------------------------------------------------------------------------------------
961
+ }
962
+
963
+ /**
964
+ * Count days between two dates
965
+ * @param date $date1 Date
966
+ * @param date $date2 Date
967
+ * @return integer
968
+ */
969
+ private function count_days($date1, $date2) {
970
+ //-------------------------------------------------------------------------------------------------------
971
+ $y1 = date('Y', strtotime($date1));
972
+ $m1 = date('m', strtotime($date1));
973
+ $d1 = date('d', strtotime($date1));
974
+
975
+ $y2 = date('Y', strtotime($date2));
976
+ $m2 = date('m', strtotime($date2));
977
+ $d2 = date('d', strtotime($date2));
978
+
979
+ $date1_set = mktime(0, 0, 0, $m1, $d1, $y1);
980
+ $date2_set = mktime(0, 0, 0, $m2, $d2, $y2);
981
+ //-------------------------------------------------------------------------------------------------------
982
+ return (round(($date2_set - $date1_set) / (60 * 60 * 24)));
983
+ //-------------------------------------------------------------------------------------------------------
984
+ }
985
+
986
+ /**
987
+ * Run unit tests
988
+ * @todo Add tests for new functions
989
+ */
990
+ private function run_tests() {
991
+ //-----------------------------------------------------------------------------------------------------
992
+ /*
993
+ * Basic functions
994
+ */
995
+ //-----------------------------------------------------------------------------------------------------
996
+ $tests_urls = array(
997
+ 'http://orbitvu.com' => 'https://orbitvu.com',
998
+ 'https://orbitvu.com' => 'https://orbitvu.com',
999
+ '//orbitvu.com' => 'https://orbitvu.com',
1000
+ 'orbitvu.com' => 'orbitvu.com',
1001
+ 'orbitvu//com' => 'orbitvu//com'
1002
+ );
1003
+ $keys = array_keys($tests_urls);
1004
+ $vals = array_values($tests_urls);
1005
+ //-----------------------------------------------------------------------------------------------------
1006
+ for ($i = 0, $n = count($tests_urls); $i < $n; $i++) {
1007
+
1008
+ $clean = $this->clean_url($keys[$i]);
1009
+
1010
+ $tst = array(
1011
+ /**/ 'function' => 'clean_url('.$keys[$i].')',
1012
+ /**/ 'given' => $clean,
1013
+ /**/ 'expected' => $vals[$i]
1014
+ );
1015
+
1016
+ if ($clean == $vals[$i]) {
1017
+ $result = 'ok';
1018
+ }
1019
+ else {
1020
+ $result = 'fail';
1021
+ }
1022
+
1023
+ $this->testclass->UpdateTest('clean_url['.$keys[$i].']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
1024
+ }
1025
+
1026
+ //-----------------------------------------------------------------------------------------------------
1027
+ /*
1028
+ * Presentations display
1029
+ */
1030
+ //-----------------------------------------------------------------------------------------------------
1031
+ $call = 'presentations';
1032
+
1033
+ $response = $this->CallSUN($call);
1034
+
1035
+ $status = 'ok';
1036
+ $status = 'fail';
1037
+ //---------------------------------------------------------------------------------------------------
1038
+ $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
1039
+ //---------------------------------------------------------------------------------------------------
1040
+ }
1041
+
1042
+ /**
1043
+ * Debugger. Returns debug output if debug mode is enabled
1044
+ * @param array $params
1045
+ * @return string
1046
+ */
1047
+ private function return_debug($params) {
1048
+ //---------------------------------------------------------------------------------------------------
1049
+ if ($this->debug) {
1050
+ return OrbitvuDebugger::Debug($params);
1051
+ }
1052
+ //---------------------------------------------------------------------------------------------------
1053
+ }
1054
+
1055
+ }
1056
+
1057
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseDriver.php CHANGED
@@ -1,373 +1,375 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @for: Magento
7
- *
8
- * This is the only class to modify for your store
9
- */
10
-
11
- class OrbitvuDatabaseDriver {
12
-
13
- /**
14
- * Database instance
15
- * @var instance
16
- */
17
- private $db_handle;
18
-
19
- /**
20
- * Database last insert ID
21
- * @var integer
22
- */
23
- private $db_last_id = 0;
24
-
25
- /**
26
- * Driver version (ID)
27
- */
28
- const DRIVER_VERSION = '1.0.1';
29
-
30
- /**
31
- * Connect to database
32
- */
33
- public function __construct() {
34
- //---------------------------------------------------------------------------------------------------
35
- $this->db_handle = Mage::getSingleton('core/resource')->getConnection('core_write');
36
- //---------------------------------------------------------------------------------------------------
37
- }
38
-
39
- /**
40
- * Get database prefix
41
- * @return string
42
- */
43
- public function GetPrefix() {
44
- //---------------------------------------------------------------------------------------------------
45
- return Mage::getConfig()->getTablePrefix(); // Store tables prefix
46
- //---------------------------------------------------------------------------------------------------
47
- }
48
-
49
- /**
50
- * Make a SQL query
51
- * @param string $db_query SQL query
52
- * @return boolean|Exception
53
- */
54
- public function Query($db_query) {
55
- //---------------------------------------------------------------------------------------------------
56
- return $this->db_handle->query($db_query); // Store query function
57
- //---------------------------------------------------------------------------------------------------
58
- }
59
-
60
- /**
61
- * Make a SQL query and return fetched items array
62
- * @param string $db_query SQL query
63
- * @return array|Exception
64
- */
65
- public function FetchAll($db_query) {
66
- //---------------------------------------------------------------------------------------------------
67
- return $this->db_handle->fetchAll($db_query); // Store query & fetch_array function + list results as array
68
- //---------------------------------------------------------------------------------------------------
69
- }
70
-
71
- /**
72
- * Escape SQL query string
73
- * @param string $query_string SQL query
74
- * @return type
75
- */
76
- public function Escape($query_string) {
77
- //---------------------------------------------------------------------------------------------------
78
- return mysql_escape_string(str_replace("'", "\'", $query_string));
79
- //---------------------------------------------------------------------------------------------------
80
- }
81
-
82
- /**
83
- * Return store last insert ID
84
- * @return integer
85
- */
86
- private function last_insert_id() {
87
- //---------------------------------------------------------------------------------------------------
88
- return $this->db_handle->lastInsertId(); // Store SQL last_insert_id
89
- //---------------------------------------------------------------------------------------------------
90
- }
91
-
92
- /**
93
- * SQL last insert ID
94
- * @return integer
95
- */
96
- public function GetLastInsertId() {
97
- //---------------------------------------------------------------------------------------------------
98
- $last_id = intval($this->last_insert_id()); // Store SQL last_insert_id
99
- //---------------------------------------------------------------------------------------------------
100
- if ($last_id > 0 && $last_id != $this->db_last_id) {
101
- $this->db_last_id = $last_id;
102
- }
103
- //---------------------------------------------------------------------------------------------------
104
- return $this->db_last_id;
105
- //---------------------------------------------------------------------------------------------------
106
- }
107
-
108
- /**
109
- * Get store configuration
110
- * @return array
111
- */
112
- public function GetConfiguration() {
113
- //---------------------------------------------------------------------------------------------------
114
- $config = array(
115
- 'access_token' => Mage::getStoreConfig('orbitvu/api/access_token'),
116
- 'auto_sync' => $this->make_boolean(Mage::getStoreConfig('orbitvu/synchro/auto_sync')),
117
- 'sync_2d' => $this->make_boolean(Mage::getStoreConfig('orbitvu/items/sync_2d')),
118
- 'sync_360' => $this->make_boolean(Mage::getStoreConfig('orbitvu/items/sync_360')),
119
- 'language' => $this->make_boolean(Mage::getStoreConfig('orbitvu/advanced/language')),
120
- 'auto_sync_sku' => Mage::getStoreConfig('orbitvu/synchro/auto_sync_sku'),
121
- 'width' => Mage::getStoreConfig('orbitvu/layout/width'),
122
- 'height' => Mage::getStoreConfig('orbitvu/layout/height'),
123
- 'border_color' => Mage::getStoreConfig('orbitvu/layout/border_color'),
124
- 'img_width' => Mage::getStoreConfig('orbitvu/layout/img_width'),
125
- 'img_height' => Mage::getStoreConfig('orbitvu/layout/img_height'),
126
- 'img_width_zoom' => Mage::getStoreConfig('orbitvu/layout/img_width_zoom'),
127
- 'img_height_zoom' => Mage::getStoreConfig('orbitvu/layout/img_height_zoom'),
128
- 'scroll' => Mage::getStoreConfig('orbitvu/layout/scroll'),
129
- 'img_width_tn' => Mage::getStoreConfig('orbitvu/layout/img_width_tn'),
130
- 'img_height_tn' => Mage::getStoreConfig('orbitvu/layout/img_height_tn'),
131
- 'img_tn_margin' => Mage::getStoreConfig('orbitvu/layout/img_tn_margin'),
132
- 'img_tn_padding' => Mage::getStoreConfig('orbitvu/layout/img_tn_padding'),
133
- 'button_width' => Mage::getStoreConfig('orbitvu/layout/button_width'),
134
- 'button_height' => Mage::getStoreConfig('orbitvu/layout/button_height'),
135
- 'button_opacity' => Mage::getStoreConfig('orbitvu/layout/button_opacity'),
136
- 'hover_mode' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/hover_mode')),
137
- 'hover_delay' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/hover_delay')),
138
- 'teaser' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/teaser')),
139
- 'html5' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/html5')),
140
- 'orbittour_thumbnails' => Mage::getStoreConfig('orbitvu/mode/orbittour_thumbnails')
141
- );
142
- //---------------------------------------------------------------------------------------------------
143
- return $config;
144
- //---------------------------------------------------------------------------------------------------
145
- }
146
-
147
- /**
148
- * Set store configuration.
149
- * Do not append local plugin configuration directly
150
- * @param string $var Var from configuration
151
- * @param string $value New vakue
152
- * @return boolean
153
- */
154
- public function SetConfiguration($var, $value) {
155
- //---------------------------------------------------------------------------------------------------
156
- $config = new Mage_Core_Model_Config();
157
- $config->saveConfig('orbitvu/api/'.$var, $value, 'default', 0);
158
- //---------------------------------------------------------------------------------------------------
159
- return true;
160
- //---------------------------------------------------------------------------------------------------
161
- }
162
-
163
- /**
164
- * Get store plugin version
165
- * @return string
166
- */
167
- public function GetVersion() {
168
- //---------------------------------------------------------------------------------------------------
169
- return (string) Mage::getConfig()->getNode()->modules->Orbitvu_Sun->version;
170
- //---------------------------------------------------------------------------------------------------
171
- }
172
-
173
- /**
174
- * Get all products with ORM and prepare to synchronize
175
- * @return array
176
- */
177
- public function SynchronizeAllProducts() {
178
- //-------------------------------------------------------------------------------------------------------
179
- $storeId = Mage::app()->getStore()->getId();
180
- $product = Mage::getModel('catalog/product');
181
- //-------------------------------------------------------------------------------------------------------
182
- $products = $product->getCollection()
183
- ->addAttributeToSelect(array(
184
- 'name',
185
- 'sku'
186
- ))
187
- ->addAttributeToFilter('status', '1');
188
- //-------------------------------------------------------------------------------------------------------
189
- $products_array = array();
190
- foreach ($products as $q) {
191
- $products_array[] = array(
192
- 'product_id' => $q->getId(),
193
- 'product_name' => $q->getName(),
194
- 'product_sku' => $q->getSku()
195
- );
196
- }
197
- //-------------------------------------------------------------------------------------------------------
198
- return $products_array;
199
- //-------------------------------------------------------------------------------------------------------
200
- }
201
-
202
- /**
203
- * Install database tables
204
- * @return boolean
205
- */
206
- public function Install() {
207
- //-------------------------------------------------------------------------------------------------------
208
- $prefix = $this->GetPrefix();
209
- //---------------------------------------------------------------------------------------------------
210
- $dump = "
211
-
212
- INSERT IGNORE INTO `".$prefix."core_config_data`
213
- (`scope`, `scope_id`, `path`, `value`)
214
- VALUES
215
- ('default', 0, 'orbitvu/api/access_token', '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29'),
216
- ('default', 0, 'orbitvu/mode/orbittour_thumbnails', 'right_views'),
217
- ('default', 0, 'orbitvu/mode/html5', 'yes'),
218
- ('default', 0, 'orbitvu/mode/hover_delay', '2'),
219
- ('default', 0, 'orbitvu/mode/teaser', 'autorotate'),
220
- ('default', 0, 'orbitvu/mode/hover_mode', '1'),
221
- ('default', 0, 'orbitvu/layout/button_opacity', '1'),
222
- ('default', 0, 'orbitvu/layout/button_height', '53px'),
223
- ('default', 0, 'orbitvu/layout/button_width', '30px'),
224
- ('default', 0, 'orbitvu/layout/scroll', 'yes'),
225
- ('default', 0, 'orbitvu/layout/img_tn_margin', '3px'),
226
- ('default', 0, 'orbitvu/layout/img_tn_padding', '2px'),
227
- ('default', 0, 'orbitvu/layout/img_height_tn', '50px'),
228
- ('default', 0, 'orbitvu/layout/img_width_tn', '75px'),
229
- ('default', 0, 'orbitvu/layout/img_height_zoom', '768px'),
230
- ('default', 0, 'orbitvu/layout/img_width_zoom', '1024px'),
231
- ('default', 0, 'orbitvu/layout/img_height', '300px'),
232
- ('default', 0, 'orbitvu/layout/img_width', '583px'),
233
- ('default', 0, 'orbitvu/layout/border_color', '#ccc'),
234
- ('default', 0, 'orbitvu/layout/height', '361px'),
235
- ('default', 0, 'orbitvu/layout/width', '100%'),
236
- ('default', 0, 'orbitvu/advanced/language', 'en'),
237
- ('default', 0, 'orbitvu/synchro/auto_sync_sku', 'false'),
238
- ('default', 0, 'orbitvu/items/sync_orbittour', '1'),
239
- ('default', 0, 'orbitvu/items/sync_360', '1'),
240
- ('default', 0, 'orbitvu/items/sync_2d', '1'),
241
- ('default', 0, 'orbitvu/synchro/sync_order', '0'),
242
- ('default', 0, 'orbitvu/synchro/auto_sync', '0');
243
-
244
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_configuration` (
245
- `id` int(3) NOT NULL auto_increment,
246
- `priority` int(2) NOT NULL,
247
- `var` varchar(20) NOT NULL,
248
- `value` text NOT NULL,
249
- `type` varchar(20) NOT NULL,
250
- `info` varchar(200) NOT NULL,
251
- PRIMARY KEY (`id`),
252
- UNIQUE KEY `var` (`var`)
253
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
254
-
255
- INSERT IGNORE INTO `".$prefix."orbitvu_configuration`
256
- (`var`, `value`, `type`, `info`)
257
- VALUES
258
- ('access_token', '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29', 'api', 'Your Orbitvu SUN Access Token'),
259
- ('viewers_path', 'viewers/src/', 'main', 'Your viewers upload folder (chmod 777)'),
260
- ('temp_path', 'tmp/', 'main', 'Your server''s temporary path (chmod 777)'),
261
- ('using_sun', 'true', 'main', 'Are you using Orbitvu SUN Cloud?'),
262
- ('last_updated', '2014-07-16 10:29:46', 'main', 'Last Orbitvu SUN Cloud synchronization date'),
263
- ('last_refreshed', '2014-07-16 10:29:46', 'main', 'Last Orbitvu SUN Cloud refresh date'),
264
- ('auto_sync', 'false', 'synchro', 'Synchronize presentations automatically?'),
265
- ('sync_2d', 'true', 'items', 'If 2D photos exists - synchronize them?'),
266
- ('sync_360', 'true', 'items', 'If 360 exists - synchronize it?'),
267
- ('sync_orbittour', 'true', 'items', 'If orbittour exists - synchronize it?'),
268
- ('auto_sync_sku', 'false', 'synchro', 'Automatically sync SKU'),
269
- ('hover_mode', 'true', 'mode', ''),
270
- ('width', '100%', 'layout', ''),
271
- ('height', '361px', 'layout', ''),
272
- ('border_color', '#ccc', 'layout', ''),
273
- ('img_width', '583px', 'layout', ''),
274
- ('img_height', '300px', 'layout', ''),
275
- ('img_width_zoom', '1024px', 'layout', ''),
276
- ('img_height_zoom', '768px', 'layout', ''),
277
- ('scroll', 'yes', 'layout', ''),
278
- ('img_width_tn', '75px', 'layout', ''),
279
- ('img_height_tn', '50px', 'layout', ''),
280
- ('img_tn_margin', '3px', 'layout', ''),
281
- ('img_tn_padding', '2px', 'layout', ''),
282
- ('button_width', '30px', 'layout', ''),
283
- ('button_height', '53px', 'layout', ''),
284
- ('button_opacity', '1', 'layout', ''),
285
- ('teaser', 'autorotate', 'mode', ''),
286
- ('hover_delay', '2', 'mode', ''),
287
- ('html5', 'yes', 'mode', ''),
288
- ('orbittour_thumbnails', 'right_views', 'mode', ''),
289
- ('first_time', 'true', 'main', '');
290
-
291
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_log` (
292
- `id` int(11) NOT NULL auto_increment,
293
- `_item_id` int(11) NOT NULL,
294
- `_item_table` enum('_presentations','_presentations_items','_viewers') NOT NULL,
295
- `action` enum('add','delete','info','skip','update') NOT NULL DEFAULT 'info',
296
- `comment` varchar(150) NOT NULL,
297
- `date` datetime NOT NULL,
298
- `ip` varchar(20) NOT NULL,
299
- PRIMARY KEY (`id`),
300
- KEY `_item_id` (`_item_id`)
301
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
302
-
303
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations` (
304
- `id` int(11) NOT NULL auto_increment,
305
- `product_id` int(11) NOT NULL,
306
- `orbitvu_id` int(11) NOT NULL,
307
- `name` varchar(150) NOT NULL,
308
- `config` text NOT NULL,
309
- `viewer` int(2) NOT NULL,
310
- `type` enum('sun','local') NOT NULL,
311
- PRIMARY KEY (`id`),
312
- UNIQUE KEY `product_id` (`product_id`),
313
- KEY `orbitvu_id` (`orbitvu_id`)
314
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
315
-
316
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations_history` (
317
- `id` int(11) NOT NULL auto_increment,
318
- `product_id` int(11) NOT NULL,
319
- `orbitvu_id` int(11) NOT NULL,
320
- `unlink_date` datetime NOT NULL,
321
- PRIMARY KEY (`id`),
322
- KEY `product_id` (`product_id`,`orbitvu_id`),
323
- KEY `orbitvu_id` (`orbitvu_id`)
324
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
325
-
326
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations_items` (
327
- `id` int(11) NOT NULL auto_increment,
328
- `_presentations_id` int(11) NOT NULL,
329
- `orbitvu_id` int(11) NOT NULL,
330
- `priority` int(3) NOT NULL,
331
- `name` varchar(150) NOT NULL,
332
- `type` tinyint(1) NOT NULL,
333
- `thumbnail` varchar(200) NOT NULL,
334
- `path` varchar(200) NOT NULL,
335
- `config` text NOT NULL,
336
- `status` enum('active','inactive') NOT NULL DEFAULT 'active',
337
- PRIMARY KEY (`id`),
338
- KEY `presentation_id` (`_presentations_id`,`orbitvu_id`)
339
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
340
-
341
- CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_thumbnails` (
342
- `product_id` int(11) NOT NULL,
343
- `thumbnail` varchar(200) NOT NULL,
344
- PRIMARY KEY (`product_id`)
345
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
346
- ";
347
-
348
- $dump = explode(';', $dump);
349
-
350
- foreach ($dump as $query) {
351
- try {
352
- $this->Query($query);
353
- }
354
- catch (Exception $e) {}
355
- }
356
- //---------------------------------------------------------------------------------------------------
357
- return true;
358
- //---------------------------------------------------------------------------------------------------
359
- }
360
-
361
- /**
362
- * Make boolean from integers
363
- * @param integer $value
364
- * @return boolean|string
365
- */
366
- private function make_boolean($value) {
367
- //---------------------------------------------------------------------------------------------------
368
- return str_replace(array('1', '0'), array('true', 'false'), $value);
369
- //---------------------------------------------------------------------------------------------------
370
- }
371
-
372
- }
 
 
373
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @for: Magento
7
+ *
8
+ * This is the only class to modify for your store
9
+ */
10
+
11
+ class OrbitvuDatabaseDriver {
12
+
13
+ /**
14
+ * Database instance
15
+ * @var instance
16
+ */
17
+ private $db_handle;
18
+
19
+ /**
20
+ * Database last insert ID
21
+ * @var integer
22
+ */
23
+ private $db_last_id = 0;
24
+
25
+ /**
26
+ * Driver version (ID)
27
+ */
28
+ const DRIVER_VERSION = '1.0.1';
29
+
30
+ /**
31
+ * Connect to database
32
+ */
33
+ public function __construct() {
34
+ //---------------------------------------------------------------------------------------------------
35
+ $this->db_handle = Mage::getSingleton('core/resource')->getConnection('core_write');
36
+ //---------------------------------------------------------------------------------------------------
37
+ }
38
+
39
+ /**
40
+ * Get database prefix
41
+ * @return string
42
+ */
43
+ public function GetPrefix() {
44
+ //---------------------------------------------------------------------------------------------------
45
+ return Mage::getConfig()->getTablePrefix(); // Store tables prefix
46
+ //---------------------------------------------------------------------------------------------------
47
+ }
48
+
49
+ /**
50
+ * Make a SQL query
51
+ * @param string $db_query SQL query
52
+ * @return boolean|Exception
53
+ */
54
+ public function Query($db_query) {
55
+ //---------------------------------------------------------------------------------------------------
56
+ return $this->db_handle->query($db_query); // Store query function
57
+ //---------------------------------------------------------------------------------------------------
58
+ }
59
+
60
+ /**
61
+ * Make a SQL query and return fetched items array
62
+ * @param string $db_query SQL query
63
+ * @return array|Exception
64
+ */
65
+ public function FetchAll($db_query) {
66
+ //---------------------------------------------------------------------------------------------------
67
+ return $this->db_handle->fetchAll($db_query); // Store query & fetch_array function + list results as array
68
+ //---------------------------------------------------------------------------------------------------
69
+ }
70
+
71
+ /**
72
+ * Escape SQL query string
73
+ * @param string $query_string SQL query
74
+ * @return type
75
+ */
76
+ public function Escape($query_string) {
77
+ //---------------------------------------------------------------------------------------------------
78
+ //return mysql_escape_string(str_replace("'", "\'", $query_string));
79
+ $query_string = Mage::getSingleton('core/resource')->getConnection('default_write')->quote(str_replace("'", "\'", $query_string));
80
+ $query_string = substr($query_string, 1, count($query_string) - 2);
81
+ return $query_string;
82
+ //---------------------------------------------------------------------------------------------------
83
+ }
84
+
85
+ /**
86
+ * Return store last insert ID
87
+ * @return integer
88
+ */
89
+ private function last_insert_id() {
90
+ //---------------------------------------------------------------------------------------------------
91
+ return $this->db_handle->lastInsertId(); // Store SQL last_insert_id
92
+ //---------------------------------------------------------------------------------------------------
93
+ }
94
+
95
+ /**
96
+ * SQL last insert ID
97
+ * @return integer
98
+ */
99
+ public function GetLastInsertId() {
100
+ //---------------------------------------------------------------------------------------------------
101
+ $last_id = intval($this->last_insert_id()); // Store SQL last_insert_id
102
+ //---------------------------------------------------------------------------------------------------
103
+ if ($last_id > 0 && $last_id != $this->db_last_id) {
104
+ $this->db_last_id = $last_id;
105
+ }
106
+ //---------------------------------------------------------------------------------------------------
107
+ return $this->db_last_id;
108
+ //---------------------------------------------------------------------------------------------------
109
+ }
110
+
111
+ /**
112
+ * Get store configuration
113
+ * @return array
114
+ */
115
+ public function GetConfiguration() {
116
+ //---------------------------------------------------------------------------------------------------
117
+ $config = array(
118
+ 'access_token' => Mage::getStoreConfig('orbitvu/api/access_token'),
119
+ 'auto_sync' => $this->make_boolean(Mage::getStoreConfig('orbitvu/synchro/auto_sync')),
120
+ 'sync_2d' => $this->make_boolean(Mage::getStoreConfig('orbitvu/items/sync_2d')),
121
+ 'sync_360' => $this->make_boolean(Mage::getStoreConfig('orbitvu/items/sync_360')),
122
+ 'language' => $this->make_boolean(Mage::getStoreConfig('orbitvu/advanced/language')),
123
+ 'auto_sync_sku' => Mage::getStoreConfig('orbitvu/synchro/auto_sync_sku'),
124
+ 'width' => Mage::getStoreConfig('orbitvu/layout/width'),
125
+ 'height' => Mage::getStoreConfig('orbitvu/layout/height'),
126
+ 'border_color' => Mage::getStoreConfig('orbitvu/layout/border_color'),
127
+ 'img_width' => Mage::getStoreConfig('orbitvu/layout/img_width'),
128
+ 'img_height' => Mage::getStoreConfig('orbitvu/layout/img_height'),
129
+ 'img_width_zoom' => Mage::getStoreConfig('orbitvu/layout/img_width_zoom'),
130
+ 'img_height_zoom' => Mage::getStoreConfig('orbitvu/layout/img_height_zoom'),
131
+ 'scroll' => Mage::getStoreConfig('orbitvu/layout/scroll'),
132
+ 'img_width_tn' => Mage::getStoreConfig('orbitvu/layout/img_width_tn'),
133
+ 'img_height_tn' => Mage::getStoreConfig('orbitvu/layout/img_height_tn'),
134
+ 'img_tn_margin' => Mage::getStoreConfig('orbitvu/layout/img_tn_margin'),
135
+ 'img_tn_padding' => Mage::getStoreConfig('orbitvu/layout/img_tn_padding'),
136
+ 'button_width' => Mage::getStoreConfig('orbitvu/layout/button_width'),
137
+ 'button_height' => Mage::getStoreConfig('orbitvu/layout/button_height'),
138
+ 'button_opacity' => Mage::getStoreConfig('orbitvu/layout/button_opacity'),
139
+ 'hover_mode' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/hover_mode')),
140
+ 'hover_delay' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/hover_delay')),
141
+ 'teaser' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/teaser')),
142
+ 'html5' => $this->make_boolean(Mage::getStoreConfig('orbitvu/mode/html5')),
143
+ 'orbittour_thumbnails' => Mage::getStoreConfig('orbitvu/mode/orbittour_thumbnails')
144
+ );
145
+ //---------------------------------------------------------------------------------------------------
146
+ return $config;
147
+ //---------------------------------------------------------------------------------------------------
148
+ }
149
+
150
+ /**
151
+ * Set store configuration.
152
+ * Do not append local plugin configuration directly
153
+ * @param string $var Var from configuration
154
+ * @param string $value New vakue
155
+ * @return boolean
156
+ */
157
+ public function SetConfiguration($var, $value) {
158
+ //---------------------------------------------------------------------------------------------------
159
+ $config = new Mage_Core_Model_Config();
160
+ $config->saveConfig('orbitvu/api/'.$var, $value, 'default', 0);
161
+ //---------------------------------------------------------------------------------------------------
162
+ return true;
163
+ //---------------------------------------------------------------------------------------------------
164
+ }
165
+
166
+ /**
167
+ * Get store plugin version
168
+ * @return string
169
+ */
170
+ public function GetVersion() {
171
+ //---------------------------------------------------------------------------------------------------
172
+ return (string) Mage::getConfig()->getNode()->modules->Orbitvu_Sun->version;
173
+ //---------------------------------------------------------------------------------------------------
174
+ }
175
+
176
+ /**
177
+ * Get all products with ORM and prepare to synchronize
178
+ * @return array
179
+ */
180
+ public function SynchronizeAllProducts() {
181
+ //-------------------------------------------------------------------------------------------------------
182
+ $storeId = Mage::app()->getStore()->getId();
183
+ $product = Mage::getModel('catalog/product');
184
+ //-------------------------------------------------------------------------------------------------------
185
+ $products = $product->getCollection()
186
+ ->addAttributeToSelect(array(
187
+ 'name',
188
+ 'sku'
189
+ ))
190
+ ->addAttributeToFilter('status', '1');
191
+ //-------------------------------------------------------------------------------------------------------
192
+ $products_array = array();
193
+ foreach ($products as $q) {
194
+ $products_array[] = array(
195
+ 'product_id' => $q->getId(),
196
+ 'product_name' => $q->getName(),
197
+ 'product_sku' => $q->getSku()
198
+ );
199
+ }
200
+ //-------------------------------------------------------------------------------------------------------
201
+ return $products_array;
202
+ //-------------------------------------------------------------------------------------------------------
203
+ }
204
+
205
+ /**
206
+ * Install database tables
207
+ * @return boolean
208
+ */
209
+ public function Install() {
210
+ //-------------------------------------------------------------------------------------------------------
211
+ $prefix = $this->GetPrefix();
212
+ //---------------------------------------------------------------------------------------------------
213
+ $dump = "
214
+
215
+ INSERT IGNORE INTO `".$prefix."core_config_data`
216
+ (`scope`, `scope_id`, `path`, `value`)
217
+ VALUES
218
+ ('default', 0, 'orbitvu/api/access_token', '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29'),
219
+ ('default', 0, 'orbitvu/mode/orbittour_thumbnails', 'right_views'),
220
+ ('default', 0, 'orbitvu/mode/html5', 'yes'),
221
+ ('default', 0, 'orbitvu/mode/hover_delay', '2'),
222
+ ('default', 0, 'orbitvu/mode/teaser', 'autorotate'),
223
+ ('default', 0, 'orbitvu/mode/hover_mode', '1'),
224
+ ('default', 0, 'orbitvu/layout/button_opacity', '1'),
225
+ ('default', 0, 'orbitvu/layout/button_height', '53px'),
226
+ ('default', 0, 'orbitvu/layout/button_width', '30px'),
227
+ ('default', 0, 'orbitvu/layout/scroll', 'yes'),
228
+ ('default', 0, 'orbitvu/layout/img_tn_margin', '3px'),
229
+ ('default', 0, 'orbitvu/layout/img_tn_padding', '2px'),
230
+ ('default', 0, 'orbitvu/layout/img_height_tn', '50px'),
231
+ ('default', 0, 'orbitvu/layout/img_width_tn', '75px'),
232
+ ('default', 0, 'orbitvu/layout/img_height_zoom', '768px'),
233
+ ('default', 0, 'orbitvu/layout/img_width_zoom', '1024px'),
234
+ ('default', 0, 'orbitvu/layout/img_height', '300px'),
235
+ ('default', 0, 'orbitvu/layout/img_width', '583px'),
236
+ ('default', 0, 'orbitvu/layout/border_color', '#ccc'),
237
+ ('default', 0, 'orbitvu/layout/height', '361px'),
238
+ ('default', 0, 'orbitvu/layout/width', '100%'),
239
+ ('default', 0, 'orbitvu/advanced/language', 'en'),
240
+ ('default', 0, 'orbitvu/synchro/auto_sync_sku', 'false'),
241
+ ('default', 0, 'orbitvu/items/sync_orbittour', '1'),
242
+ ('default', 0, 'orbitvu/items/sync_360', '1'),
243
+ ('default', 0, 'orbitvu/items/sync_2d', '1'),
244
+ ('default', 0, 'orbitvu/synchro/auto_sync', '0');
245
+
246
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_configuration` (
247
+ `id` int(3) NOT NULL auto_increment,
248
+ `priority` int(2) NOT NULL,
249
+ `var` varchar(20) NOT NULL,
250
+ `value` text NOT NULL,
251
+ `type` varchar(20) NOT NULL,
252
+ `info` varchar(200) NOT NULL,
253
+ PRIMARY KEY (`id`),
254
+ UNIQUE KEY `var` (`var`)
255
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
256
+
257
+ INSERT IGNORE INTO `".$prefix."orbitvu_configuration`
258
+ (`var`, `value`, `type`, `info`)
259
+ VALUES
260
+ ('access_token', '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29', 'api', 'Your Orbitvu SUN Access Token'),
261
+ ('viewers_path', 'viewers/src/', 'main', 'Your viewers upload folder (chmod 777)'),
262
+ ('temp_path', 'tmp/', 'main', 'Your server''s temporary path (chmod 777)'),
263
+ ('using_sun', 'true', 'main', 'Are you using Orbitvu SUN Cloud?'),
264
+ ('last_updated', '2014-07-16 10:29:46', 'main', 'Last Orbitvu SUN Cloud synchronization date'),
265
+ ('last_refreshed', '2014-07-16 10:29:46', 'main', 'Last Orbitvu SUN Cloud refresh date'),
266
+ ('auto_sync', 'false', 'synchro', 'Synchronize presentations automatically?'),
267
+ ('sync_2d', 'true', 'items', 'If 2D photos exists - synchronize them?'),
268
+ ('sync_360', 'true', 'items', 'If 360 exists - synchronize it?'),
269
+ ('sync_orbittour', 'true', 'items', 'If orbittour exists - synchronize it?'),
270
+ ('auto_sync_sku', 'false', 'synchro', 'Automatically sync SKU'),
271
+ ('hover_mode', 'true', 'mode', ''),
272
+ ('width', '100%', 'layout', ''),
273
+ ('height', '361px', 'layout', ''),
274
+ ('border_color', '#ccc', 'layout', ''),
275
+ ('img_width', '583px', 'layout', ''),
276
+ ('img_height', '300px', 'layout', ''),
277
+ ('img_width_zoom', '1024px', 'layout', ''),
278
+ ('img_height_zoom', '768px', 'layout', ''),
279
+ ('scroll', 'yes', 'layout', ''),
280
+ ('img_width_tn', '75px', 'layout', ''),
281
+ ('img_height_tn', '50px', 'layout', ''),
282
+ ('img_tn_margin', '3px', 'layout', ''),
283
+ ('img_tn_padding', '2px', 'layout', ''),
284
+ ('button_width', '30px', 'layout', ''),
285
+ ('button_height', '53px', 'layout', ''),
286
+ ('button_opacity', '1', 'layout', ''),
287
+ ('teaser', 'autorotate', 'mode', ''),
288
+ ('hover_delay', '2', 'mode', ''),
289
+ ('html5', 'yes', 'mode', ''),
290
+ ('orbittour_thumbnails', 'right_views', 'mode', ''),
291
+ ('first_time', 'true', 'main', '');
292
+
293
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_log` (
294
+ `id` int(11) NOT NULL auto_increment,
295
+ `_item_id` int(11) NOT NULL,
296
+ `_item_table` enum('_presentations','_presentations_items','_viewers') NOT NULL,
297
+ `action` enum('add','delete','info','skip','update') NOT NULL DEFAULT 'info',
298
+ `comment` varchar(150) NOT NULL,
299
+ `date` datetime NOT NULL,
300
+ `ip` varchar(20) NOT NULL,
301
+ PRIMARY KEY (`id`),
302
+ KEY `_item_id` (`_item_id`)
303
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
304
+
305
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations` (
306
+ `id` int(11) NOT NULL auto_increment,
307
+ `product_id` int(11) NOT NULL,
308
+ `orbitvu_id` int(11) NOT NULL,
309
+ `name` varchar(150) NOT NULL,
310
+ `config` text NOT NULL,
311
+ `viewer` int(2) NOT NULL,
312
+ `type` enum('sun','local') NOT NULL,
313
+ PRIMARY KEY (`id`),
314
+ UNIQUE KEY `product_id` (`product_id`),
315
+ KEY `orbitvu_id` (`orbitvu_id`)
316
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
317
+
318
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations_history` (
319
+ `id` int(11) NOT NULL auto_increment,
320
+ `product_id` int(11) NOT NULL,
321
+ `orbitvu_id` int(11) NOT NULL,
322
+ `unlink_date` datetime NOT NULL,
323
+ PRIMARY KEY (`id`),
324
+ KEY `product_id` (`product_id`,`orbitvu_id`),
325
+ KEY `orbitvu_id` (`orbitvu_id`)
326
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
327
+
328
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_presentations_items` (
329
+ `id` int(11) NOT NULL auto_increment,
330
+ `_presentations_id` int(11) NOT NULL,
331
+ `orbitvu_id` int(11) NOT NULL,
332
+ `priority` int(3) NOT NULL,
333
+ `name` varchar(150) NOT NULL,
334
+ `type` tinyint(1) NOT NULL,
335
+ `thumbnail` varchar(200) NOT NULL,
336
+ `path` varchar(200) NOT NULL,
337
+ `config` text NOT NULL,
338
+ `status` enum('active','inactive') NOT NULL DEFAULT 'active',
339
+ PRIMARY KEY (`id`),
340
+ KEY `presentation_id` (`_presentations_id`,`orbitvu_id`)
341
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
342
+
343
+ CREATE TABLE IF NOT EXISTS `".$prefix."orbitvu_products_thumbnails` (
344
+ `product_id` int(11) NOT NULL,
345
+ `thumbnail` varchar(200) NOT NULL,
346
+ PRIMARY KEY (`product_id`)
347
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
348
+ ";
349
+
350
+ $dump = explode(';', $dump);
351
+
352
+ foreach ($dump as $query) {
353
+ try {
354
+ $this->Query($query);
355
+ }
356
+ catch (Exception $e) {}
357
+ }
358
+ //---------------------------------------------------------------------------------------------------
359
+ return true;
360
+ //---------------------------------------------------------------------------------------------------
361
+ }
362
+
363
+ /**
364
+ * Make boolean from integers
365
+ * @param integer $value
366
+ * @return boolean|string
367
+ */
368
+ private function make_boolean($value) {
369
+ //---------------------------------------------------------------------------------------------------
370
+ return str_replace(array('1', '0'), array('true', 'false'), $value);
371
+ //---------------------------------------------------------------------------------------------------
372
+ }
373
+
374
+ }
375
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseInterface.php CHANGED
@@ -1,2147 +1,2174 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- */
6
-
7
- final class OrbitvuDatabaseInterface {
8
-
9
- /**
10
- * Database driver instance
11
- * @var instance
12
- */
13
- private $database;
14
-
15
- /**
16
- * Database tables prefix
17
- * @var string
18
- */
19
- private $db_prefix = '';
20
-
21
- /**
22
- * Orbitvu tables previx
23
- * @var string
24
- */
25
- private $db_orbitvu = 'orbitvu_';
26
-
27
- /**
28
- * Debug mode
29
- * @var boolean
30
- */
31
- private $debug = false;
32
-
33
- /**
34
- * Unit tests mode
35
- * @var boolean
36
- */
37
- private $test = false;
38
-
39
- /**
40
- * Test class instance
41
- * @var instance
42
- */
43
- private $testclass = false;
44
-
45
- /**
46
- * Configuration vars and values
47
- * @var stdClass|boolean
48
- */
49
- public $Config = false;
50
-
51
- /**
52
- * SUN API connection instance
53
- * @var instance
54
- */
55
- public $Connect;
56
-
57
- /**
58
- * Manage the database
59
- * @param string $prefix Database prefix
60
- * @param boolean $debug Debug mode
61
- * @param boolean $test Unit tests mode
62
- * @param boolean $testinstance Unit tests instance.
63
- */
64
- public function __construct($prefix = '', $debug = false, $test = false, $testinstance = false) {
65
- //-------------------------------------------------------------------------------------------------------
66
- require_once(__DIR__.'/OrbitvuDatabaseDriver.php');
67
- //-------------------------------------------------------------------------------------------------------
68
- $this->debug = $debug;
69
- $this->test = $test;
70
- //-------------------------------------------------------------------------------------------------------
71
- $this->database = new OrbitvuDatabaseDriver();
72
- //---------------------------------------------------------------------------------------------------
73
- if (!empty($prefix)) $this->db_prefix = $prefix;
74
- else $this->db_prefix = $this->database->GetPrefix();
75
-
76
- if ($this->is_sh()) {
77
- $this->db_orbitvu .= 'sh_';
78
- }
79
- //---------------------------------------------------------------------------------------------------
80
- $this->Config = $this->GetConfiguration();
81
- /*
82
- * Test instance
83
- */
84
- if ($this->test) {
85
- $this->testclass = $testinstance;
86
-
87
- /*
88
- * Run test bot!
89
- */
90
- $this->run_tests();
91
- }
92
- //-------------------------------------------------------------------------------------------------------
93
- }
94
-
95
- /**
96
- * Set Orbitvu SUN connection instance
97
- * @param instance $connect
98
- */
99
- public function SetSUNConnection($connect) {
100
- //----------------------------------------------------------
101
- $this->Connect = $connect;
102
- //----------------------------------------------------------
103
- }
104
-
105
- /**
106
- * Synchronize all products
107
- * @return boolean
108
- */
109
- public function SynchronizeAllProducts() {
110
- //----------------------------------------------------------
111
- return $this->SynchronizeAllPresentations($this->database->SynchronizeAllProducts());
112
- //----------------------------------------------------------
113
- }
114
-
115
- /**
116
- * @see OrbitvuDatabaseDriver.php\GetLocalSessionKey()
117
- * @return string
118
- */
119
- public function GetLocalSessionKey() {
120
- //----------------------------------------------------------
121
- return $this->database->GetLocalSessionKey();
122
- //----------------------------------------------------------
123
- }
124
-
125
- /**
126
- * @see OrbitvuDatabaseDriver.php\GetRemoteAuthorizationUrl()
127
- * @return string
128
- */
129
- public function GetRemoteAuthorizationUrl() {
130
- //----------------------------------------------------------
131
- return $this->database->GetRemoteAuthorizationUrl();
132
- //----------------------------------------------------------
133
- }
134
-
135
- /**
136
- * @see OrbitvuDatabaseDriver.php\GetRemoteUploadUrl()
137
- * @return string
138
- */
139
- public function GetRemoteUploadUrl() {
140
- //----------------------------------------------------------
141
- return $this->database->GetRemoteUploadUrl();
142
- //----------------------------------------------------------
143
- }
144
-
145
- /**
146
- * Get all configuration vars and values.
147
- * Update local values to store values
148
- * @return stdClass
149
- */
150
- public function GetConfiguration() {
151
- //----------------------------------------------------------
152
- if ($this->Config != false) return $this->Config;
153
- //----------------------------------------------------------
154
- if ($this->test) {
155
- $this->testclass->AppendTest('GetConfiguration', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
156
- }
157
- //----------------------------------------------------------
158
- $db_query = '
159
- SELECT *
160
- FROM `'.$this->db_prefix.$this->db_orbitvu.'configuration`
161
- ';
162
-
163
- //---------------------------------------------------------------------
164
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
165
- //---------------------------------------------------------------------
166
-
167
- try {
168
- $query = $this->database->FetchAll($db_query);
169
- }
170
- catch (Exception $e) {
171
- $this->Install();
172
-
173
- //----------------------------------------------------------
174
- /**/ $this->return_debug(array(
175
- /**/ 'function' => 'Install',
176
- /**/ 'response' => 'Database installed!'
177
- /**/ ));
178
- //----------------------------------------------------------
179
-
180
- $query = $this->database->FetchAll($db_query);
181
- }
182
-
183
- /*
184
- * Synchronize config with current store configuration
185
- */
186
- $store_config = $this->database->GetConfiguration();
187
-
188
- //-------------------------------------------------------------------------------------------------------
189
- $conf = new stdClass();
190
- $i = 0;
191
- foreach ($query as $q) {
192
- $conf->$q['var'] = $q['value'];
193
-
194
- if (isset($store_config[$q['var']]) && $store_config[$q['var']] != $conf->$q['var']) {
195
- $this->SetConfiguration($q['var'], $store_config[$q['var']]);
196
- $conf->$q['var'] = $store_config[$q['var']];
197
- }
198
- $i++;
199
- }
200
-
201
- //----------------------------------------------------------
202
- /**/ $this->return_debug(array(
203
- /**/ 'function' => __FUNCTION__,
204
- /**/ 'configuration' => $conf
205
- /**/ ));
206
- //----------------------------------------------------------
207
-
208
- //-------------------------------------------------------------------------------------------------------
209
- return $conf;
210
- //-------------------------------------------------------------------------------------------------------
211
- }
212
-
213
- /**
214
- * Set local configuration value
215
- * or add new var and value
216
- * @param string $var
217
- * @param string $value
218
- * @return boolean
219
- */
220
- public function SetConfiguration($var, $value) {
221
- //-------------------------------------------------------------------------------------------------------
222
- $db_query = '
223
- INSERT INTO
224
- `'.$this->db_prefix.$this->db_orbitvu.'configuration`
225
- (`var`, `value`, `type`)
226
-
227
- VALUES (
228
- \''.$var.'\',
229
- \''.$this->database->Escape($value).'\',
230
- \'main\'
231
- )
232
-
233
- ON DUPLICATE KEY
234
-
235
- UPDATE
236
- `value` = \''.($value).'\'
237
- ';
238
-
239
- //---------------------------------------------------------------------
240
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
241
- //---------------------------------------------------------------------
242
-
243
- $query = $this->database->Query($db_query);
244
-
245
- //-------------------------------------------------------------------------------------------------------
246
- $this->Log(0, '_configuration', 'update', $var.'='.$value, 'auto');
247
- //-------------------------------------------------------------------------------------------------------
248
- return true;
249
- //-------------------------------------------------------------------------------------------------------
250
- }
251
-
252
- /**
253
- * Set store configuration
254
- * @param string $var
255
- * @param string $value
256
- * @return boolean
257
- */
258
- public function SetConfigurationParent($var, $value) {
259
- //-------------------------------------------------------------------------------------------------------
260
- return $this->database->SetConfiguration($var, $value);
261
- //-------------------------------------------------------------------------------------------------------
262
- }
263
-
264
- /**
265
- * Unlink (free) presentation from product
266
- * @param integer $product_id Store product ID from database
267
- * @return boolean
268
- */
269
- public function FreeProduct($product_id) {
270
- //-------------------------------------------------------------------------------------------------------
271
- $db_query = '
272
- SELECT *
273
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
274
-
275
- WHERE
276
- `product_id` = '.intval($product_id).'
277
-
278
- LIMIT 1
279
- ';
280
-
281
- //---------------------------------------------------------------------
282
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
283
- //---------------------------------------------------------------------
284
-
285
- $query = $this->database->FetchAll($db_query);
286
- //-------------------------------------------------------------------------------------------------------
287
- $product = $query[0];
288
- //-------------------------------------------------------------------------------------------------------
289
-
290
- /*
291
- * Free items
292
- */
293
- //-------------------------------------------------------------------------------------------------------
294
- $db_query = '
295
- DELETE
296
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
297
-
298
- WHERE
299
- `_presentations_id` = '.intval($product['id']).'
300
- ';
301
-
302
- //---------------------------------------------------------------------
303
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
304
- //---------------------------------------------------------------------
305
-
306
- $query = $this->database->Query($db_query);
307
-
308
- /*
309
- * Add history
310
- */
311
- //-------------------------------------------------------------------------------------------------------
312
- $db_query = '
313
- INSERT INTO
314
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
315
- (`product_id`, `orbitvu_id`, `unlink_date`)
316
-
317
- VALUES (
318
- '.intval($product['product_id']).',
319
- '.intval($product['orbitvu_id']).',
320
- NOW()
321
- )
322
- ';
323
-
324
- //---------------------------------------------------------------------
325
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
326
- //---------------------------------------------------------------------
327
-
328
- $query = $this->database->Query($db_query);
329
-
330
- /*
331
- * Free product
332
- */
333
- //-------------------------------------------------------------------------------------------------------
334
- $db_query = '
335
- DELETE FROM
336
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
337
-
338
- WHERE
339
- `id` = '.intval($product['id']).'
340
-
341
- LIMIT 1
342
- ';
343
-
344
- //---------------------------------------------------------------------
345
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
346
- //---------------------------------------------------------------------
347
-
348
- $query = $this->database->Query($db_query);
349
-
350
- //-------------------------------------------------------------------------------------------------------
351
- $this->Log($product['id'], '_presentations', 'delete');
352
- //-------------------------------------------------------------------------------------------------------
353
- return true;
354
- //-------------------------------------------------------------------------------------------------------
355
- }
356
-
357
- /**
358
- * Get our store thumbnails
359
- * @param integer $product_id Store product ID from database
360
- * @return array
361
- */
362
- public function GetProductThumbnails($product_id) {
363
- //-------------------------------------------------------------------------------------------------------
364
- $db_query = '
365
- SELECT *
366
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
367
-
368
- WHERE
369
- `product_id` = '.intval($product_id).'
370
- ';
371
-
372
- //---------------------------------------------------------------------
373
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
374
- //---------------------------------------------------------------------
375
-
376
- $query = $this->database->FetchAll($db_query);
377
-
378
- //-------------------------------------------------------------------------------------------------------
379
- return $query;
380
- //-------------------------------------------------------------------------------------------------------
381
- }
382
-
383
- /**
384
- * Set store thumbnail
385
- * @param integer $product_id Store product ID from database
386
- * @param string $thumbnail Thumbnail path
387
- * @return array
388
- */
389
- public function SetProductThumbnail($product_id, $thumbnail) {
390
- //-------------------------------------------------------------------------------------------------------
391
- $db_query = '
392
- INSERT INTO
393
- `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
394
- (`product_id`, `thumbnail`)
395
-
396
- VALUES (
397
- '.intval($product_id).',
398
- \''.$thumbnail.'\'
399
- )
400
- ';
401
-
402
- //---------------------------------------------------------------------
403
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
404
- //---------------------------------------------------------------------
405
-
406
- try {
407
- $query = $this->database->Query($db_query);
408
- }
409
- catch(Exception $e) {}
410
-
411
- //-------------------------------------------------------------------------------------------------------
412
- return $query;
413
- //-------------------------------------------------------------------------------------------------------
414
- }
415
-
416
- /**
417
- * Delete store thumbnail
418
- * @param integer $product_id Store product ID from database
419
- * @param string $thumbnail Thumbnail path
420
- * @return array
421
- */
422
- public function DeleteProductThumbnail($product_id, $thumbnail = '') {
423
- //-------------------------------------------------------------------------------------------------------
424
- $db_query = '
425
- DELETE FROM
426
- `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
427
-
428
- WHERE
429
- `product_id` = '.intval($product_id).'
430
- '.(!empty($thumbnail) ? ' AND `thumbnail` = \''.$thumbnail.'\' ' : '').'
431
-
432
- LIMIT 1
433
- ';
434
-
435
- //---------------------------------------------------------------------
436
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
437
- //---------------------------------------------------------------------
438
-
439
- $query = $this->database->Query($db_query);
440
-
441
- //-------------------------------------------------------------------------------------------------------
442
- return $query;
443
- //-------------------------------------------------------------------------------------------------------
444
- }
445
-
446
- /**
447
- * Is the product unlinked?
448
- * @param integer $product_id Store product ID from database
449
- * @return boolean
450
- */
451
- public function IsProductUnlinked($product_id) {
452
- //-------------------------------------------------------------------------------------------------------
453
- $db_query = '
454
- SELECT *
455
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
456
-
457
- WHERE
458
- `product_id` = '.intval($product_id).'
459
-
460
- LIMIT 1
461
- ';
462
-
463
- //---------------------------------------------------------------------
464
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
465
- //---------------------------------------------------------------------
466
-
467
- $query = $this->database->FetchAll($db_query);
468
- $query = $query[0];
469
-
470
- //-------------------------------------------------------------------------------------------------------
471
- if ($query['orbitvu_id'] > 0) {
472
- return true;
473
- }
474
- else {
475
- return false;
476
- }
477
- //-------------------------------------------------------------------------------------------------------
478
- }
479
-
480
- /**
481
- * Is presentation unlinked?
482
- * @param integer $product_id Store product ID from database
483
- * @param integer $orbitvu_id Orbitvu SUN presentation ID
484
- * @return boolean
485
- */
486
- public function IsPresentationUnlinked($product_id, $orbitvu_id) {
487
- //-------------------------------------------------------------------------------------------------------
488
- $db_query = '
489
- SELECT *
490
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
491
-
492
- WHERE
493
- `product_id` = '.intval($product_id).' AND
494
- `orbitvu_id` = '.intval($orbitvu_id).'
495
-
496
- LIMIT 1
497
- ';
498
-
499
- //---------------------------------------------------------------------
500
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
501
- //---------------------------------------------------------------------
502
-
503
- $query = $this->database->FetchAll($db_query);
504
- $query = $query[0];
505
-
506
- //-------------------------------------------------------------------------------------------------------
507
- if ($query['orbitvu_id'] > 0) {
508
- return true;
509
- }
510
- else {
511
- return false;
512
- }
513
- //-------------------------------------------------------------------------------------------------------
514
- }
515
-
516
- /**
517
- * Product presentation exists?
518
- * @param integer $product_id Store product ID from database
519
- * @return boolean
520
- */
521
- public function ExistsProductPresentation($product_id) {
522
- //-------------------------------------------------------------------------------------------------------
523
- $db_query = '
524
- SELECT *
525
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
526
-
527
- WHERE
528
- `product_id` = '.intval($product_id).'
529
-
530
- LIMIT 1
531
- ';
532
-
533
- //---------------------------------------------------------------------
534
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
535
- //---------------------------------------------------------------------
536
-
537
- $query = $this->database->FetchAll($db_query);
538
- $query = $query[0];
539
- //-------------------------------------------------------------------------------------------------------
540
- if (isset($query['type'])) {
541
- return true;
542
- }
543
- //-------------------------------------------------------------------------------------------------------
544
- return false;
545
- //-------------------------------------------------------------------------------------------------------
546
- }
547
-
548
- /**
549
- * Get product presentation data
550
- * Get product presentation items
551
- * @param integer $product_id Store product ID from database
552
- * @param boolean $visible_only Return only items marked as visible
553
- * @return array
554
- */
555
- public function GetProductPresentation($product_id, $visible_only = false) {
556
- //-------------------------------------------------------------------------------------------------------
557
- $db_query = '
558
- SELECT *
559
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
560
-
561
- WHERE
562
- `product_id` = '.intval($product_id).'
563
-
564
- LIMIT 1
565
- ';
566
-
567
- //---------------------------------------------------------------------
568
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
569
- //---------------------------------------------------------------------
570
-
571
- $query = $this->database->FetchAll($db_query);
572
- $query = isset($query[0]) ? $query[0] : null;
573
- //-------------------------------------------------------------------------------------------------------
574
- $ret = array();
575
- //-------------------------------------------------------------------------------------------------------
576
- if (isset($query['type'])) {
577
- //-------------------------------------------------------------------------------------------------------
578
- $ret = $query;
579
-
580
- /**
581
- * SelfHosted data
582
- */
583
- if ($this->is_sh() && intval($ret['orbitvu_id']) > 0) {
584
- $db_query_sh = '
585
- SELECT *
586
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
587
-
588
- WHERE
589
- `id` = '.intval($ret['orbitvu_id']).'
590
-
591
- LIMIT 1
592
- ';
593
-
594
- //---------------------------------------------------------------------
595
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query_sh);
596
- //---------------------------------------------------------------------
597
-
598
- $qsh = $this->database->FetchAll($db_query_sh);
599
- $qsh = $qsh[0];
600
-
601
- $ret['dir'] = $qsh['dir'];
602
- $ret['presentation_name'] = $qsh['name'];
603
- $ret['content'] = json_decode($qsh['content']);
604
- }
605
-
606
- $ret['items'] = array();
607
-
608
- $ret['types'] = array();
609
-
610
- //-------------------------------------------------------------------------------------------------------
611
- $db_sub_query = '
612
- SELECT *
613
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
614
-
615
- WHERE
616
- `_presentations_id` = '.$ret['id'].'
617
- '.($visible_only ? ' AND `status` = \'active\' ' : '').'
618
-
619
- ORDER BY
620
- `priority` DESC
621
- ';
622
-
623
- //---------------------------------------------------------------------
624
- /**/ $this->return_sql_debug(__FUNCTION__, $db_sub_query);
625
- //---------------------------------------------------------------------
626
-
627
- $items = $this->database->FetchAll($db_sub_query);
628
- //-------------------------------------------------------------------------------------------------------
629
- foreach ($items as $qi) {
630
- $ret['items'][] = $qi;
631
-
632
- if (!in_array($qi['type'], $ret['types'])) {
633
- $ret['types'][] = $qi['type'];
634
- }
635
- }
636
- //rsort($ret['items']);
637
- rsort($ret['types']);
638
- //-------------------------------------------------------------------------------------------------------
639
- return $ret;
640
- //-------------------------------------------------------------------------------------------------------
641
- }
642
- //-------------------------------------------------------------------------------------------------------
643
- return false;
644
- //-------------------------------------------------------------------------------------------------------
645
- }
646
-
647
- /**
648
- * Set new product presentation
649
- * @param type $product_id Store product ID from database
650
- * @param type $orbitvu_id Orbitvu SUN presentation ID
651
- * @param type $orbitvu_name Orbitvu SUN presentation name
652
- * @return boolean
653
- */
654
- public function SetProductPresentation($product_id, $orbitvu_id, $presentation_name = '', $comment = 'manual') {
655
- //-------------------------------------------------------------------------------------------------------
656
- $db_query = '
657
- SELECT `id`
658
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
659
-
660
- WHERE
661
- `product_id` = '.intval($product_id).'
662
-
663
- LIMIT 1
664
- ';
665
-
666
- //---------------------------------------------------------------------
667
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
668
- //---------------------------------------------------------------------
669
-
670
- $check = $this->database->FetchAll($db_query);
671
- $check = $check[0];
672
- //-------------------------------------------------------------------------------------------------------
673
-
674
- $db_query = '
675
- INSERT INTO
676
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
677
- (`product_id`, `orbitvu_id`, `name`, `type`)
678
-
679
- VALUES (
680
- '.intval($product_id).',
681
- '.intval($orbitvu_id).',
682
- \''.$this->database->Escape($presentation_name).'\',
683
- \''.($this->is_sh() ? 'local' : 'sun').'\'
684
- )
685
-
686
- ON DUPLICATE KEY
687
-
688
- UPDATE
689
- `name` = \''.$this->database->Escape($presentation_name).'\',
690
- `type` = \''.($this->is_sh() ? 'local' : 'sun').'\'
691
- ';
692
-
693
- //---------------------------------------------------------------------
694
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
695
- //---------------------------------------------------------------------
696
-
697
- $query = $this->database->Query($db_query);
698
- //-------------------------------------------------------------------------------------------------------
699
- if (!isset($check['id'])) {
700
- //-------------------------------------------------------------------------------------------------------
701
- $this->Log($this->database->GetLastInsertId(), '_presentations', 'add', $comment);
702
- //-------------------------------------------------------------------------------------------------------
703
- return $this->database->GetLastInsertId();
704
- //-------------------------------------------------------------------------------------------------------
705
- }
706
- else {
707
- //-------------------------------------------------------------------------------------------------------
708
- $this->Log($check['id'], '_presentations', 'skip', $comment);
709
- //-------------------------------------------------------------------------------------------------------
710
- return $check['id'];
711
- //-------------------------------------------------------------------------------------------------------
712
- }
713
- }
714
-
715
- /**
716
- * Set product presentation items
717
- * @param type $product_id Store product ID from database
718
- * @param type $orbitvu_id Orbitvu SUN presentation ID
719
- * @param type $orbitvu_name Orbitvu SUN presentation name
720
- * @param type $presentation_items Orbitvu SUN presentation items
721
- * @return type
722
- */
723
- public function SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items, $comment = 'manual') {
724
- //-------------------------------------------------------------------------------------------------------
725
- /**
726
- * Updating presentation id
727
- */
728
- //-------------------------------------------------------------------------------------------------------
729
- $presentation_id = $this->SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name, 'auto');
730
- //-------------------------------------------------------------------------------------------------------
731
- /**
732
- * Inserting new items
733
- */
734
- $priority = 10;
735
- //-------------------------------------------------------------------------------------------------------
736
- for ($i = 0, $n = count($presentation_items); $i < $n; $i++) {
737
- //-------------------------------------------------------------------------------------------------------
738
- $item = $presentation_items[$i];
739
- //-------------------------------------------------------------------------------------------------------
740
- $db_query = '
741
- SELECT `id`
742
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
743
-
744
- WHERE
745
- `orbitvu_id` = \''.$this->database->Escape($item['orbitvu_id']).'\' AND
746
- `_presentations_id` = '.intval($presentation_id).'
747
-
748
- LIMIT 1
749
- ';
750
-
751
- //---------------------------------------------------------------------
752
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
753
- //---------------------------------------------------------------------
754
-
755
- $check = $this->database->FetchAll($db_query);
756
- $check = $check[0];
757
- //-------------------------------------------------------------------------------------------------------
758
- if (!isset($check['id'])) {
759
- //-------------------------------------------------------------------------------------------------------
760
- $priority += 10;
761
-
762
- $db_query = '
763
- INSERT INTO
764
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
765
- (`_presentations_id`, `orbitvu_id`, `priority`, `name`, `type`, `thumbnail`, `path`, `config`, `status`)
766
-
767
- VALUES (
768
- '.intval($presentation_id).',
769
- \''.$this->database->Escape($item['orbitvu_id']).'\',
770
- '.($priority).',
771
- \''.$this->database->Escape($item['name']).'\',
772
- '.intval($item['type']).',
773
- \''.($item['thumbnail']).'\',
774
- \''.($item['path']).'\',
775
- \''.$this->database->Escape($item['config']).'\',
776
- \''.($item['status']).'\'
777
- )
778
- ';
779
-
780
- //---------------------------------------------------------------------
781
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
782
- //---------------------------------------------------------------------
783
-
784
- $this->database->Query($db_query);
785
-
786
- //-------------------------------------------------------------------------------------------------------
787
- $this->Log($this->database->GetLastInsertId(), '_presentations_items', 'add', $comment);
788
- //-------------------------------------------------------------------------------------------------------
789
- }
790
- else {
791
- //-------------------------------------------------------------------------------------------------------
792
- $this->Log($check['id'], '_presentations_items', 'skip', 'auto');
793
- //-------------------------------------------------------------------------------------------------------
794
- }
795
- //-------------------------------------------------------------------------------------------------------
796
- }
797
- //-------------------------------------------------------------------------------------------------------
798
- return true;
799
- //-------------------------------------------------------------------------------------------------------
800
- }
801
-
802
- /**
803
- * Search the presentation with name and SKU
804
- * @param array $product Product array with name and SKU
805
- * @return array|boolean
806
- */
807
- public function MatchPresentation($product) {
808
- //-------------------------------------------------------------------------------------------------------
809
- $product_name = $product['product_name'];
810
- $product_sku = $product['product_sku'];
811
-
812
- //----------------------------------------------------------
813
- /**/ $this->return_debug(array(
814
- /**/ 'function' => __FUNCTION__,
815
- /**/ 'product_name' => $product_name,
816
- /**/ 'product_sku' => $product_sku,
817
- /**/ 'line' => __LINE__
818
- /**/ ));
819
- //----------------------------------------------------------
820
-
821
- //-------------------------------------------------------------------------------------------------------
822
- $count = 0;
823
- //-------------------------------------------------------------------------------------------------------
824
- if (!empty($product_sku)) {
825
- $presentations_choose = $this->GetPresentationsList(array(
826
- 'page_size' => 1,
827
- 'name' => $product_sku
828
- ));
829
-
830
- //----------------------------------------------------------
831
- /**/ $this->return_debug(array(
832
- /**/ 'function' => __FUNCTION__,
833
- /**/ 'line' => __LINE__,
834
- /**/ 'match_type' => 'name='.$product_sku,
835
- /**/ 'presentations' => $presentations_choose,
836
- /**/ ));
837
- //----------------------------------------------------------
838
-
839
- $count = $presentations_choose->count;
840
-
841
- if ($count == 0) {
842
- $presentations_choose = $this->GetPresentationsList(array(
843
- 'page_size' => 1,
844
- 'sku' => $product_sku
845
- ));
846
-
847
- //----------------------------------------------------------
848
- /**/ $this->return_debug(array(
849
- /**/ 'function' => __FUNCTION__,
850
- /**/ 'line' => __LINE__,
851
- /**/ 'match_type' => 'sku='.$product_sku,
852
- /**/ 'presentations' => $presentations_choose,
853
- /**/ ));
854
- //----------------------------------------------------------
855
-
856
- $count = $presentations_choose->count;
857
- }
858
- }
859
- //-------------------------------------------------------------------------------------------------------
860
- if (!empty($product_name) && $count == 0) {
861
- $presentations_choose = $this->GetPresentationsList(array(
862
- 'page_size' => 1,
863
- 'name' => $product_name
864
- ));
865
-
866
- //----------------------------------------------------------
867
- /**/ $this->return_debug(array(
868
- /**/ 'function' => __FUNCTION__,
869
- /**/ 'line' => __LINE__,
870
- /**/ 'match_type' => 'name='.$product_name,
871
- /**/ 'presentations' => $presentations_choose,
872
- /**/ ));
873
- //----------------------------------------------------------
874
-
875
- $count = $presentations_choose->count;
876
-
877
- if ($count == 0) {
878
- $presentations_choose = $this->GetPresentationsList(array(
879
- 'page_size' => 1,
880
- 'sku' => $product_name
881
- ));
882
-
883
- //----------------------------------------------------------
884
- /**/ $this->return_debug(array(
885
- /**/ 'function' => __FUNCTION__,
886
- /**/ 'line' => __LINE__,
887
- /**/ 'match_type' => 'sku='.$product_name,
888
- /**/ 'presentations' => $presentations_choose,
889
- /**/ ));
890
- //----------------------------------------------------------
891
-
892
- $count = $presentations_choose->count;
893
- }
894
- }
895
- //-------------------------------------------------------------------------------------------------------
896
- if ($count == 0) return false;
897
- else {
898
- return $presentations_choose;
899
- }
900
- //-------------------------------------------------------------------------------------------------------
901
- }
902
-
903
- public function SynchronizeAllPresentations($products_array) {
904
- $products = array();
905
- $presentations_list = $this->GetPresentationsList();
906
-
907
- for($i = 0; $i < count($products_array); $i++) {
908
- $current_product = $products_array[$i];
909
-
910
-
911
- //product has to posses name and id at least
912
- if (empty($current_product['product_id']) || empty($current_product['product_name'])) {
913
- //-------------------------------------------------------------------------------------------------------
914
- continue; //
915
- //-------------------------------------------------------------------------------------------------------
916
- }
917
-
918
-
919
- //check if product is already linked
920
- if ($try = $this->GetProductPresentation($current_product['product_id'])) {
921
- $comment = 'auto';
922
-
923
- $this->Log($current_product['product_id'], '_presentations', 'skip', $comment);
924
- //-------------------------------------------------------------------------------------------------------
925
- continue;
926
- //-------------------------------------------------------------------------------------------------------
927
- }
928
- $products[] = $current_product;
929
- }
930
-
931
-
932
- if ($presentations_list->count) {
933
- for($i = 0; $i < $presentations_list->count; $i++) {
934
-
935
- $current_presentation = $presentations_list->results[$i];
936
- for($j = 0; $j < count($products); $j++) {
937
-
938
- //ommit products which have been linked to current_presentation id
939
- //we dont set the ommit flag becasue product may match to presentation with other id
940
- if ($this->IsPresentationUnlinked($products[$j]['product_id'], $current_presentation->id)) {
941
- continue;
942
- }
943
-
944
- if (isset($products[$j]['ommit']) && $products[$j]['ommit'] = true) {
945
- continue;
946
- }
947
-
948
- $synch = false;
949
- if (isset($products[$j]['product_sku']) && $products[$j]['product_sku'] == $current_presentation->sku) {
950
- $products[$j]['ommit'] = true;
951
- $synch = true;
952
-
953
- } else if ($products[$j]['product_name'] && strcasecmp($products[$j]['product_name'], $current_presentation->name) == 0) {
954
- $products[$j]['ommit'] = true;
955
- $synch = true;
956
- }
957
-
958
- if ($synch) {
959
- $comment = ' auto - "'.$products[$j]['product_sku'].'"';
960
-
961
- $this->SetProductPresentation($products[$j]['product_id'], $current_presentation->id, $current_presentation->name, $comment);
962
-
963
- $p_items = array();
964
- //-------------------------------------------------------------------------------------------------------
965
- $sync_order = array(
966
- 'sync_2d' => true,
967
- 'sync_360' => true,
968
- 'sync_orbittour' => true
969
- );
970
- //-------------------------------------------------------------------------------------------------------
971
- foreach ($sync_order as $key => $value) {
972
- $sync_order[$key] = $this->Config->$key;
973
- }
974
-
975
- $results = $current_presentation;
976
- $uid = $results->uid;
977
- //-------------------------------------------------------------------------------------------------------
978
- /*
979
- * Get OrbitTour
980
- */
981
- //-------------------------------------------------------------------------------------------------------
982
- if ($results->has_orbittour == '1') {
983
- $p_items[] = array(
984
- 'orbitvu_id' => ($results->orbittour_set[0]->id),
985
- 'name' => 'OrbitTour',
986
- 'type' => 0,
987
- 'thumbnail' => $results->thumbnail_url,
988
- 'path' => $results->orbittour_set[0]->script_url,
989
- 'config' => json_encode(array('uid' => $uid)),
990
- 'status' => ($sync_order['sync_orbittour'] == 'true' ? 'active' : 'inactive')
991
- );
992
- }
993
- //-------------------------------------------------------------------------------------------------------
994
-
995
- /*
996
- * Get other items
997
- */
998
- //-------------------------------------------------------------------------------------------------------
999
- $results = $results->presentationcontent_set;
1000
- for ($k = 0, $n = count($results); $k < $n; $k++) {
1001
- $cur = $results[$k];
1002
- //-------------------------------------------------------------------------------------------------------
1003
- if (($sync_order['sync_360'] == 'true' && $cur->type == '1') || ($sync_order['sync_2d'] == 'true' && $cur->type == '3')) {
1004
- $status = 'active';
1005
- }
1006
- else {
1007
- $status = 'inactive';
1008
- }
1009
- //-------------------------------------------------------------------------------------------------------
1010
- $p_items[] = array(
1011
- 'orbitvu_id' => ($cur->id),
1012
- 'name' => $cur->name,
1013
- 'type' => $cur->type,
1014
- 'thumbnail' => $cur->thumbnail_url,
1015
- 'path' => (!empty($cur->script_url) ? $cur->script_url : $cur->view_url),
1016
- 'config' => json_encode(array('uid' => $uid)),
1017
- 'status' => $status
1018
- );
1019
- }
1020
-
1021
- if (count($p_items) >= 1) {
1022
- //-------------------------------------------------------------------------------------------------------
1023
- $this->SetProductPresentationItems($products[$j]['product_id'], $current_presentation->id, $current_presentation->name, $p_items, 'auto');
1024
- //-------------------------------------------------------------------------------------------------------
1025
- }
1026
-
1027
- }
1028
- }
1029
-
1030
- }
1031
- }
1032
-
1033
- //-------------------------------------------------------------------------------------------------------
1034
- $this->SetConfiguration('last_updated', date('Y-m-d H:i:s'));
1035
- //-------------------------------------------------------------------------------------------------------
1036
-
1037
- return $products_array;
1038
- //-------------------------------------------------------------------------------------------------------
1039
-
1040
- }
1041
-
1042
-
1043
- /**
1044
- * Synchronize presentations
1045
- * @param array $products_array Products array
1046
- * @return array
1047
- */
1048
- public function SynchronizePresentations($products_array) {
1049
- //-------------------------------------------------------------------------------------------------------
1050
- /**
1051
- * Match products with SUN
1052
- */
1053
- //-------------------------------------------------------------------------------------------------------
1054
- for ($i = 0, $n = count($products_array); $i < $n; $i++) {
1055
- //-------------------------------------------------------------------------------------------------------
1056
- $current = $products_array[$i];
1057
- //-------------------------------------------------------------------------------------------------------
1058
- if (empty($current['product_id']) || empty($current['product_name'])) {
1059
- //-------------------------------------------------------------------------------------------------------
1060
- throw new Exception('$product_id or $product_name not provided (both arguments are required).');
1061
- //-------------------------------------------------------------------------------------------------------
1062
- }
1063
- //-------------------------------------------------------------------------------------------------------
1064
- $comment = '';
1065
- //-------------------------------------------------------------------------------------------------------
1066
- /*
1067
- * Presentation exists?
1068
- */
1069
- if ($try = $this->GetProductPresentation($current['product_id'])) {
1070
- $comment = 'auto';
1071
-
1072
- $this->Log($current['product_id'], '_presentations', 'skip', $comment);
1073
- //-------------------------------------------------------------------------------------------------------
1074
- continue;
1075
- //-------------------------------------------------------------------------------------------------------
1076
- }
1077
- //-------------------------------------------------------------------------------------------------------
1078
- $product_search = array(
1079
- 'product_sku' => $current['product_sku'],
1080
- 'product_name' => $current['product_name']
1081
- );
1082
-
1083
- $response = $this->MatchPresentation($product_search);
1084
- $comment = ' auto - "'.$current['product_sku'].'"';
1085
- //-------------------------------------------------------------------------------------------------------
1086
- /*
1087
- * Found match? Update DB
1088
- */
1089
- //-------------------------------------------------------------------------------------------------------
1090
- if ($response->count > 0) {
1091
- //-------------------------------------------------------------------------------------------------------
1092
- $result = $response->results[0];
1093
- //-------------------------------------------------------------------------------------------------------
1094
- /*
1095
- * Update presentation if wasn't unlinked before
1096
- */
1097
- //-------------------------------------------------------------------------------------------------------
1098
- if (!$this->IsPresentationUnlinked($current['product_id'], $result->id)) {
1099
- //-------------------------------------------------------------------------------------------------------
1100
- $presentation_id = $this->SetProductPresentation($current['product_id'], $result->id, $result->name, $comment);
1101
- //-------------------------------------------------------------------------------------------------------
1102
- $p_items = $this->GetProductPresentationItems($response);
1103
-
1104
- //----------------------------------------------------------
1105
- /**/ $this->return_debug(array(
1106
- /**/ 'function' => __FUNCTION__,
1107
- /**/ 'items' => $p_items
1108
- /**/ ));
1109
- //----------------------------------------------------------
1110
-
1111
- //-------------------------------------------------------------------------------------------------------
1112
- /*
1113
- * Final items update
1114
- */
1115
- if (count($p_items) >= 1) {
1116
- //-------------------------------------------------------------------------------------------------------
1117
- $this->SetProductPresentationItems($current['product_id'], $result->id, $result->name, $p_items, 'auto');
1118
- //-------------------------------------------------------------------------------------------------------
1119
- }
1120
- //-------------------------------------------------------------------------------------------------------
1121
- }
1122
- //-------------------------------------------------------------------------------------------------------
1123
- }
1124
- }
1125
- //-------------------------------------------------------------------------------------------------------
1126
- $this->SetConfiguration('last_updated', date('Y-m-d H:i:s'));
1127
- //-------------------------------------------------------------------------------------------------------
1128
-
1129
- return $products_array;
1130
- //-------------------------------------------------------------------------------------------------------
1131
- }
1132
-
1133
- /**
1134
- * Refresh presentations items
1135
- * Delete non-existing on SUN
1136
- * Add new from SUN
1137
- * @return boolean
1138
- */
1139
- public function SynchronizePresentationsItems() {
1140
- //-------------------------------------------------------------------------------------------------------
1141
- $db_query = '
1142
- SELECT *
1143
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
1144
- ';
1145
-
1146
- //---------------------------------------------------------------------
1147
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1148
- //---------------------------------------------------------------------
1149
-
1150
- $query = $this->database->FetchAll($db_query);
1151
-
1152
- foreach ($query as $q) {
1153
- //-------------------------------------------------------------------------------------------------------
1154
- $items_sun = $this->GetProductPresentationItems($q['orbitvu_id']);
1155
-
1156
- $items_sun_ids = array();
1157
-
1158
- foreach ($items_sun as $item) {
1159
- $items_sun_ids[] = $item['orbitvu_id'];
1160
- }
1161
-
1162
- //-------------------------------------------------------------------------------------------------------
1163
- if (count($items_sun_ids) <= 0) {
1164
- continue; // nothing to update
1165
- }
1166
- //-------------------------------------------------------------------------------------------------------
1167
-
1168
- $db_query_items = '
1169
- SELECT *
1170
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1171
-
1172
- WHERE
1173
- `_presentations_id` = '.intval($q['id']).'
1174
- ';
1175
-
1176
- //---------------------------------------------------------------------
1177
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query_items);
1178
- //---------------------------------------------------------------------
1179
-
1180
- $items_current = $this->database->FetchAll($db_query_items);
1181
-
1182
- $items_current_ids = array();
1183
-
1184
- /**
1185
- * Deleting items not existing on SUN anymore
1186
- */
1187
- //-------------------------------------------------------------------------------------------------------
1188
- foreach ($items_current as $item) {
1189
- if (!in_array($item['orbitvu_id'], $items_sun_ids)) {
1190
- $this->DeletePresentationItem($item['id']);
1191
- }
1192
-
1193
- $items_current_ids[] = $item['orbitvu_id'];
1194
- }
1195
- //-------------------------------------------------------------------------------------------------------
1196
-
1197
- /**
1198
- * New items adding
1199
- */
1200
- //-------------------------------------------------------------------------------------------------------
1201
- foreach ($items_sun as $item) {
1202
- if (!in_array($item['orbitvu_id'], $items_current_ids)) {
1203
- $this->SetProductPresentationItems($q['product_id'], $q['orbitvu_id'], $q['name'], array($item));
1204
- }
1205
- }
1206
- //-------------------------------------------------------------------------------------------------------
1207
- }
1208
-
1209
- //-------------------------------------------------------------------------------------------------------
1210
- $this->SetConfiguration('last_refreshed', date('Y-m-d H:i:s'));
1211
- //-------------------------------------------------------------------------------------------------------
1212
-
1213
- return true;
1214
- //-------------------------------------------------------------------------------------------------------
1215
- }
1216
-
1217
- /**
1218
- * Is SH?
1219
- * @return boolean
1220
- */
1221
- private function is_sh() {
1222
- //-------------------------------------------------------------------------------------------------------
1223
- $v = OrbitvuDatabaseDriver::DRIVER_VERSION;
1224
- return $v{2} == '1';
1225
- //-------------------------------------------------------------------------------------------------------
1226
- }
1227
-
1228
- /**
1229
- * Get presentation data from XML file
1230
- * from self hosted presentation
1231
- * @param string $dir_or_file Directory or .ovus file path
1232
- * @return stdClass|boolean
1233
- */
1234
- public function GetHostedPresentationData($dir_or_file) {
1235
- //-------------------------------------------------------------------------------------------------------
1236
- /**
1237
- * Associations
1238
- */
1239
- $dir_name = explode('/', $dir_or_file);
1240
- $dir_name = $dir_name[count($dir_name)-1];
1241
- $relative_dir = $this->Config->presentations_path_relative.$dir_name;
1242
-
1243
- $cur = new stdClass();
1244
- $cur->config = new stdClass();
1245
-
1246
- /**
1247
- * Check if file is .ovus (Orbitvu Sequence) or .zip package.
1248
- * If so, unpack archive and refresh page
1249
- *
1250
- * Console like installator, needs to be working with any e-commerce platform/CMS),
1251
- * that's why:
1252
- * - I didn't used templates,
1253
- * - I used exit() to stop rendering page by any platform we use,
1254
- * - I used JavaScript redirect as this will be run in a browser, but one archive at the time
1255
- * (a way to trick every server limits)
1256
- */
1257
- if (stristr($dir_name, '.ovus') || stristr($dir_name, '.zip')) {
1258
- //-------------------------------------------------------------------------------------------------------
1259
- $this->Connect->InstallPresentation($dir_or_file);
1260
- //-------------------------------------------------------------------------------------------------------
1261
- //-------------------------------------------------------------------------------------------------------
1262
-
1263
-
1264
- // The old way
1265
- /**
1266
- * Not much data if is still a package
1267
- *
1268
-
1269
- $cur->is_ovus = true;
1270
- $cur->is_downloaded_from_sun = false;
1271
-
1272
- $res = array(
1273
- 'name' => str_ireplace('.ovus', '', $dir_name),
1274
- 'category_1' => '',
1275
- 'category_2' => '',
1276
- 'create_date' => null,
1277
- 'sku' => '',
1278
- 'presentation' => array(),
1279
- 'id' => $dir_name
1280
- );
1281
-
1282
- $dir_name = $res['name'];
1283
- /**/
1284
- //-------------------------------------------------------------------------------------------------------
1285
- }
1286
- else {
1287
- //-------------------------------------------------------------------------------------------------------
1288
-
1289
- /**
1290
- * Check if cached version exists
1291
- */
1292
- //-------------------------------------------------------------------------------------------------------
1293
- $db_query = '
1294
- SELECT *
1295
- FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
1296
-
1297
- WHERE
1298
- `dir` = \''.$this->database->Escape($dir_or_file).'\'
1299
-
1300
- LIMIT 1
1301
- ';
1302
-
1303
- //---------------------------------------------------------------------
1304
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1305
- //---------------------------------------------------------------------
1306
-
1307
- $query = $this->database->FetchAll($db_query);
1308
- $query = $query[0];
1309
-
1310
- //-------------------------------------------------------------------------------------------------------
1311
- /**/if (!empty($query['content']) && (strtotime($query['date']) == strtotime(date('Y-m-d')) || strtotime($query['date']) == strtotime(date('Y-m-d', strtotime('+1 days'))))) {
1312
- $content = json_decode($query['content']);
1313
- $content->id = $query['id'];
1314
-
1315
- return $content;
1316
- }
1317
- /**/
1318
- //-------------------------------------------------------------------------------------------------------
1319
-
1320
- $cur->is_ovus = false;
1321
- $cur->is_downloaded_from_sun = true;
1322
-
1323
- /**
1324
- * Check if package is Orbitvu presentation
1325
- */
1326
- //-------------------------------------------------------------------------------------------------------
1327
- if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
1328
- $dir_or_file .= '/'.$dir_name;
1329
- $cur->is_downloaded_from_sun = false;
1330
- }
1331
-
1332
- /**
1333
- * If is not a presentation
1334
- * @return false
1335
- */
1336
- //-------------------------------------------------------------------------------------------------------
1337
- if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
1338
- return false;
1339
- }
1340
-
1341
- /**
1342
- * Get XML files data
1343
- */
1344
- //-------------------------------------------------------------------------------------------------------
1345
- $files = array(
1346
- 'config' => file_get_contents($dir_or_file.'/config.xml'),
1347
- 'meta' => file_get_contents($dir_or_file.'/meta.xml'),
1348
- 'content' => file_get_contents($dir_or_file.'/content.xml')
1349
- );
1350
- //-------------------------------------------------------------------------------------------------------
1351
-
1352
- /**
1353
- * Parse XML files
1354
- * and get presentations data/details
1355
- */
1356
- //-------------------------------------------------------------------------------------------------------
1357
- $xml = new stdClass();
1358
-
1359
- $xml->config = $this->Connect->XMLtoArray($files['config']);
1360
- $xml->meta = $this->Connect->XMLtoArray($files['meta']);
1361
- $xml->content = $this->Connect->XMLtoArray($files['content']);
1362
-
1363
- if (file_exists($dir_or_file.'/content2.xml')) {
1364
- $files['content2'] = file_get_contents($dir_or_file.'/content2.xml');
1365
- $xml->content2 = $this->Connect->XMLtoArray($files['content2']);
1366
- }
1367
- //-------------------------------------------------------------------------------------------------------
1368
-
1369
- /**
1370
- * Data:
1371
- * config
1372
- */
1373
- //-------------------------------------------------------------------------------------------------------
1374
- $cur->config->xml_url = $xml->config['viewer-params']['xml_url'];
1375
- $cur->config->image_folder = $relative_dir.'/'.$xml->config['viewer-params']['image_folder'];
1376
- $cur->config->image_folder_full = $dir_or_file.'/'.$xml->config['viewer-params']['image_folder'];
1377
- $cur->config->image_folder_2d = $relative_dir.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
1378
- $cur->config->image_folder_2d_full = $dir_or_file.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
1379
- $cur->config->teaser = $xml->config['viewer-params']['teaser'];
1380
- $cur->config->auto_rotate = $xml->config['viewer-params']['auto_rotate'];
1381
- $cur->config->auto_rotate_dir = $xml->config['viewer-params']['auto_rotate_dir'];
1382
- $cur->config->rotate_dir = $xml->config['viewer-params']['rotate_dir'];
1383
-
1384
- /**
1385
- * Data:
1386
- * categories
1387
- */
1388
- //-------------------------------------------------------------------------------------------------------
1389
- $res = array(
1390
- 'category_1' => ($xml->meta['category_1_name'] != 'Category 1' ? $xml->meta['category_1_name'] : ''),
1391
- 'category_2' => ($xml->meta['category_2_name'] != 'Category 2' ? $xml->meta['category_2_name'] : ''),
1392
- 'sku' => $xml->meta['sku'],
1393
- 'create_date' => $xml->meta['creation-date'].' '.$xml->meta['creation-time'],
1394
- 'name' => (!empty($xml->content2['properties']['property'][0]) ? $xml->content2['properties']['property'][0] : $dir_name),
1395
- 'presentation' => array(),
1396
- 'id' => $dir_name
1397
- );
1398
-
1399
- /**
1400
- * 360* Presentation
1401
- */
1402
- $first_image = '';
1403
- //-------------------------------------------------------------------------------------------------------
1404
- if (isset($xml->content['img'][1])) {
1405
- $seq360 = new stdClass();
1406
- $img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_full);
1407
- sort($img_tree);
1408
- foreach ($img_tree as $search) {
1409
- if (stristr($search, 'a_0_0')) {
1410
- $first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $search);
1411
- }
1412
- }
1413
-
1414
- if (empty($first_image)) {
1415
- $first_image = $xml->content['img'][0]['@attributes']['name'].'.'.$xml->content['img'][0]['@attributes']['ext'];
1416
- }
1417
-
1418
- $seq360->id = md5($dir_name.'_'.str_replace($this->Config->presentations_path_relative, '', $first_image));
1419
- $seq360->name = '';
1420
- $seq360->type = 1;
1421
- $seq360->type_display = 'ORBITVU 360';
1422
- $seq360->thumbnail_url = $first_image;
1423
- $seq360->script_url = '';
1424
- $seq360->view_url = '';
1425
- $seq360->max_width = $xml->content['@attributes']['maxWidth'];
1426
- $seq360->max_height = $xml->content['@attributes']['maxHeight'];
1427
-
1428
- if (file_exists($dir_or_file.'/content2.xml')) {
1429
- $seq360->content2_xml = true;
1430
- }
1431
- else {
1432
- $seq360->content2_xml = false;
1433
- }
1434
-
1435
- $res['presentation'][] = $seq360;
1436
-
1437
- $first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $first_image);
1438
- }
1439
-
1440
- /**
1441
- * 2D Photos
1442
- */
1443
- //-------------------------------------------------------------------------------------------------------
1444
- $img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_2d_full);
1445
- $images = $xml->content2['images']['img'];
1446
-
1447
- $i = 0;
1448
- foreach ($img_tree as $image) {
1449
- $img = $images[$i];
1450
- $img = $img['@attributes'];
1451
- $image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $image);
1452
-
1453
- $current = new stdClass();
1454
-
1455
- $current->id = md5($dir_name.'_'.$img['name']);
1456
- $current->name = $img['name'];
1457
- $current->type = 3;
1458
- $current->type_display = 'image2d';
1459
- $current->thumbnail_url = $image;
1460
- $current->script_url = '';
1461
- $current->view_url = $image;
1462
- $current->max_width = $img['width'];
1463
- $current->max_height = $img['height'];
1464
- $current->content2_xml = '';
1465
-
1466
- $res['presentation'][] = $current;
1467
-
1468
- if ($i == 0) {
1469
- $first_image = $cur->config->image_folder_2d.$img['name'];
1470
- }
1471
-
1472
- $i++;
1473
- }
1474
-
1475
- $res['thumbnail_url'] = $first_image;
1476
-
1477
- //-------------------------------------------------------------------------------------------------------
1478
- }
1479
- //-------------------------------------------------------------------------------------------------------
1480
-
1481
- $cur->local_url = $dir_or_file;
1482
-
1483
- //$cur->id = $res['id'];
1484
- $cur->uid = '';
1485
-
1486
- $cur->name = $res['name'];
1487
- $cur->sku = $res['sku'];
1488
- $cur->category_1 = $res['category_1'];
1489
- $cur->category_2 = $res['category_2'];
1490
-
1491
- $cur->create_date = $res['create_date'];
1492
- $cur->has_orbittour = false;
1493
- $cur->presentation_size = 0;
1494
-
1495
- $cur->tags = array();
1496
- $cur->edit_url = '';
1497
- $cur->url = '';
1498
- $cur->thumbnail_url = $res['thumbnail_url'];
1499
- $cur->statistics_url = '';
1500
- $cur->orbittour_set = array();
1501
- $cur->page_size = 1;
1502
- $cur->presentationcontent_set = $res['presentation'];
1503
-
1504
- /**
1505
- * Add JSON data cache to database
1506
- * for presentations
1507
- */
1508
- //-------------------------------------------------------------------------------------------------------
1509
- if (!$cur->is_ovus) {
1510
- $db_query = '
1511
- INSERT INTO
1512
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
1513
- (`dir`, `name`, `date`, `content`)
1514
-
1515
- VALUES (
1516
- \''.$this->database->Escape($dir_or_file).'\',
1517
- \''.$this->database->Escape($dir_name).'\',
1518
- NOW(),
1519
- \''.$this->database->Escape(json_encode($cur)).'\'
1520
- )
1521
-
1522
- ON DUPLICATE KEY
1523
- UPDATE
1524
- `content` = \''.$this->database->Escape(json_encode($cur)).'\',
1525
- `date` = NOW()
1526
- ';
1527
-
1528
- //---------------------------------------------------------------------
1529
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1530
- //---------------------------------------------------------------------
1531
-
1532
- $query = $this->database->Query($db_query);
1533
- }
1534
- //-------------------------------------------------------------------------------------------------------
1535
-
1536
- return $cur;
1537
- //-------------------------------------------------------------------------------------------------------
1538
- }
1539
-
1540
- /**
1541
- * Get presentations from Orbitvu SUN
1542
- * @param array $params Params for Orbitvu SUN filtering
1543
- * @return stdClass
1544
- */
1545
- public function GetPresentationsList($params = false) {
1546
- //-------------------------------------------------------------------------------------------------------
1547
- if ($this->is_sh()) {
1548
- //-------------------------------------------------------------------------------------------------------
1549
- if ($this->Connect->IsConnected()) {
1550
- $results = $this->Connect->GetDirectoryTree($this->Config->presentations_path, true, (intval($params['page_size']) == 1 ? 0 : intval($params['page_size'])), intval($params['page']));
1551
- }
1552
- else {
1553
- /**
1554
- * @fixme
1555
- * Delete this after setting DEMO presentations
1556
- *
1557
- $results = array(
1558
- $this->Config->presentations_path.'/Untitled',
1559
- $this->Config->presentations_path.'/watch',
1560
- $this->Config->presentations_path.'/Testowa'
1561
- );
1562
- /**/
1563
- $results = base64decode('
1564
- V3lKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWVzUwYVhSc1pXUWlMQ0pjTDNaaGNsd3ZkM2QzWEM5a1pYWXViV0ZuWlc1MGJ5NXZjbUpwZEhaMUxtTnZiVnd2Y0hWaWJHbGpYMmgwYld4Y0wxOXZjbUpwZEhaMVgzQnlaWE5sYm5SaGRHbHZibk5jTDF3dmQyRjBZMmdpTENKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWR1Z6ZEc5M1lTSmQ=');
1565
- }
1566
-
1567
- //----------------------------------------------------------
1568
- /**/ $this->return_debug(array(
1569
- /**/ 'function' => __FUNCTION__,
1570
- /**/ 'line' => __LINE__,
1571
- /**/ 'type' => 'SelfHosted',
1572
- /**/ 'results' => $results,
1573
- /**/ 'params' => $params
1574
- /**/ ));
1575
- //----------------------------------------------------------
1576
-
1577
- $results_array = array();
1578
- foreach ($results as $dir) {
1579
-
1580
- /**
1581
- * Parse presentation data (local)
1582
- */
1583
- if ($cur = $this->GetHostedPresentationData($dir)) {
1584
-
1585
- $add_to_results = true;
1586
-
1587
- /**
1588
- * Check filters
1589
- */
1590
- if (is_array($params)) {
1591
- foreach ($params as $key => $val) {
1592
- if (in_array($key, array('id', 'name', 'sku'))) {
1593
-
1594
- $bool = $cur->$key != $val && (!empty($cur->$key) || $cur->$key !== null || $cur->$key !== 0);
1595
-
1596
- /**
1597
- if ($cur->name == 'watch') {
1598
- echo '<pre>';
1599
- echo '$cur-name = '.$cur->name."\n";
1600
- echo '$cur-sku = '.$cur->sku."\n";
1601
- echo '$key = '.$key."\n";
1602
- echo '$val = '.$val."\n";
1603
- echo '$cur->$key = '.$cur->$key."\n";
1604
- var_dump($cur->$key != $val);
1605
- var_dump(!empty($cur->$key));
1606
- var_dump($cur->$key !== null);
1607
- var_dump($cur->$key !== 0);
1608
- var_dump($bool);
1609
- echo '</pre>';
1610
- }
1611
-
1612
- //----------------------------------------------------------
1613
- /**/ $this->return_debug(array(
1614
- /**/ 'function' => __FUNCTION__,
1615
- /**/ 'line' => __LINE__,
1616
- /**/ 'type' => 'SelfHosted',
1617
- /**/ 'param' => $key.'='.$val,
1618
- /**/ 'result' => ($bool ? 'true' : 'false')
1619
- /**/ ));
1620
- //----------------------------------------------------------
1621
-
1622
- if ($bool) {
1623
- $add_to_results = false;
1624
- }
1625
- else {
1626
- $add_to_results = true;
1627
- break;
1628
- }
1629
- }
1630
- }
1631
- }
1632
-
1633
- /**
1634
- * Final array creating
1635
- */
1636
- if ($add_to_results) {
1637
- $results_array[] = $cur;
1638
- }
1639
- }
1640
-
1641
- }
1642
-
1643
- /*if (intval($params['page_size']) == 1) {
1644
- $results_array = array($results_array[0]);
1645
- }*/
1646
-
1647
- $response = array();
1648
- $response_results = new stdClass();
1649
-
1650
- /*
1651
- if (is_array($params)) {
1652
- $response_results->count = $this->Connect->GetPresentationsCount($this->Config->presentations_path);
1653
- }
1654
- else {
1655
- $response_results->count = count($results);
1656
- }*/
1657
- $response_results->count = count($results_array);
1658
-
1659
- $response_results->next = '';
1660
- $response_results->prev = '';
1661
-
1662
- if ($params['page_size'] > 0) {
1663
- $response_results->per_page = intval($params['page_size']);
1664
- }
1665
- $response_results->results = $results_array;
1666
-
1667
- //----------------------------------------------------------
1668
- /**/ $this->return_debug(array(
1669
- /**/ 'function' => __FUNCTION__,
1670
- /**/ 'line' => __LINE__,
1671
- /**/ 'type' => 'SelfHosted',
1672
- /**/ 'results' => $response_results,
1673
- /**/ ));
1674
- //----------------------------------------------------------
1675
-
1676
- return $response_results;
1677
- //-------------------------------------------------------------------------------------------------------
1678
- }
1679
- else {
1680
- //-------------------------------------------------------------------------------------------------------
1681
- if (is_array($params)) {
1682
- //-------------------------------------------------------------------------------------------------------
1683
- return $this->Connect->CallSUN('presentations', $params);
1684
- //-------------------------------------------------------------------------------------------------------
1685
- }
1686
- else {
1687
- //-------------------------------------------------------------------------------------------------------
1688
- $results = array();
1689
- $response_results = new stdClass();
1690
- $j = 0;
1691
- //-------------------------------------------------------------------------------------------------------
1692
- do {
1693
- //-------------------------------------------------------------------------------------------------------
1694
- if ($j == 0) {
1695
- $response = $this->Connect->CallSUN('presentations');
1696
- $response_results = $response;
1697
- }
1698
- else {
1699
- $response = $this->Connect->CallSUN($response->next);
1700
- }
1701
- //-------------------------------------------------------------------------------------------------------
1702
- for ($i = 0, $n = count($response->results); $i < $n; $i++) {
1703
- //-------------------------------------------------------------------------------------------------------
1704
- $results[] = $response->results[$i];
1705
- //-------------------------------------------------------------------------------------------------------
1706
- }
1707
- //-------------------------------------------------------------------------------------------------------
1708
- $j++;
1709
- }
1710
- //-------------------------------------------------------------------------------------------------------
1711
- while (!empty($response->next));
1712
- //-------------------------------------------------------------------------------------------------------
1713
- }
1714
- //-------------------------------------------------------------------------------------------------------
1715
- $response_results->count = count($results);
1716
- $response_results->next = '';
1717
- $response_results->prev = '';
1718
- $response_results->results = $results;
1719
- //-------------------------------------------------------------------------------------------------------
1720
- return $response_results;
1721
- //-------------------------------------------------------------------------------------------------------
1722
- }
1723
- }
1724
-
1725
- /**
1726
- * Get presentation items
1727
- * @param integer $orbitvu_id Orbitvu SUN presentation ID
1728
- * @return array
1729
- */
1730
- public function GetProductPresentationItems($orbitvu_id) {
1731
- //-------------------------------------------------------------------------------------------------------
1732
- if (is_array($orbitvu_id) || is_object($orbitvu_id)) {
1733
- $response = $orbitvu_id;
1734
- unset($orbitvu_id);
1735
- }
1736
- else {
1737
- $response = $this->GetPresentationsList(array('id' => $orbitvu_id));
1738
- }
1739
- //-------------------------------------------------------------------------------------------------------
1740
- $results = $response->results[0];
1741
- $uid = $results->uid;
1742
-
1743
- $p_items = array();
1744
- //-------------------------------------------------------------------------------------------------------
1745
- $sync_order = array(
1746
- 'sync_2d' => true,
1747
- 'sync_360' => true,
1748
- 'sync_orbittour' => true
1749
- );
1750
- //-------------------------------------------------------------------------------------------------------
1751
- foreach ($sync_order as $key => $value) {
1752
- $sync_order[$key] = $this->Config->$key;
1753
- }
1754
- //-------------------------------------------------------------------------------------------------------
1755
- /*
1756
- * Get OrbitTour
1757
- */
1758
- //-------------------------------------------------------------------------------------------------------
1759
- if ($results->has_orbittour == '1') {
1760
- $p_items[] = array(
1761
- 'orbitvu_id' => ($results->orbittour_set[0]->id),
1762
- 'name' => 'OrbitTour',
1763
- 'type' => 0,
1764
- 'thumbnail' => $results->thumbnail_url,
1765
- 'path' => $results->orbittour_set[0]->script_url,
1766
- 'config' => json_encode(array('uid' => $uid)),
1767
- 'status' => ($sync_order['sync_orbittour'] == 'true' ? 'active' : 'inactive')
1768
- );
1769
- }
1770
- //-------------------------------------------------------------------------------------------------------
1771
-
1772
- /*
1773
- * Get other items
1774
- */
1775
- //-------------------------------------------------------------------------------------------------------
1776
- $results = $results->presentationcontent_set;
1777
- for ($i = 0, $n = count($results); $i < $n; $i++) {
1778
- $cur = $results[$i];
1779
- //-------------------------------------------------------------------------------------------------------
1780
- if (($sync_order['sync_360'] == 'true' && $cur->type == '1') || ($sync_order['sync_2d'] == 'true' && $cur->type == '3')) {
1781
- $status = 'active';
1782
- }
1783
- else {
1784
- $status = 'inactive';
1785
- }
1786
- //-------------------------------------------------------------------------------------------------------
1787
- $p_items[] = array(
1788
- 'orbitvu_id' => ($cur->id),
1789
- 'name' => $cur->name,
1790
- 'type' => $cur->type,
1791
- 'thumbnail' => $cur->thumbnail_url,
1792
- 'path' => (!empty($cur->script_url) ? $cur->script_url : $cur->view_url),
1793
- 'config' => json_encode(array('uid' => $uid)),
1794
- 'status' => $status
1795
- );
1796
- }
1797
-
1798
- //-------------------------------------------------------------------------------------------------------
1799
- return $p_items;
1800
- //-------------------------------------------------------------------------------------------------------
1801
- }
1802
-
1803
- /**
1804
- * Switch presentation item priority
1805
- * @param integer $product_id Store product ID from database
1806
- * @param integer $item_id Current item ID from database
1807
- * @param integer $item_id2 Item will be putted in order after this item
1808
- * @return boolean
1809
- */
1810
- public function SwitchPresentationItemPriority($product_id, $item_id, $before_item_id) {
1811
- if ($item_id > 0 && $before_item_id > 0) {
1812
- //-------------------------------------------------------------------------------------------------------
1813
- $presentation = $this->GetProductPresentation($product_id);
1814
- $items = $presentation['items'];
1815
- //-------------------------------------------------------------------------------------------------------
1816
- $item_to_move = 0;
1817
- $before_item = 0;
1818
- //-------------------------------------------------------------------------------------------------------
1819
- $i = 0;
1820
- //-------------------------------------------------------------------------------------------------------
1821
- foreach ($items as $item) {
1822
- //-------------------------------------------------------------------------------------------------------
1823
- if ($item_id == $item['id']) {
1824
- $item_to_move = $i;
1825
- }
1826
- //-------------------------------------------------------------------------------------------------------
1827
- if ($before_item_id == $item['id']) {
1828
- $before_item = $i;
1829
- }
1830
- //-------------------------------------------------------------------------------------------------------
1831
- $i++;
1832
- }
1833
- //-------------------------------------------------------------------------------------------------------
1834
- $new_item = array($items[$item_to_move]);
1835
- unset($items[$item_to_move]);
1836
- array_splice($items, $before_item, 0, $new_item);
1837
-
1838
- $priority = count($items) * 10;
1839
- foreach ($items as $item) {
1840
- $this->UpdatePresentationItemPriority($item['id'], $priority);
1841
-
1842
- $priority -= 10;
1843
- }
1844
- //-------------------------------------------------------------------------------------------------------
1845
- return true;
1846
- //-------------------------------------------------------------------------------------------------------
1847
- }
1848
- //-------------------------------------------------------------------------------------------------------
1849
- return false;
1850
- //-------------------------------------------------------------------------------------------------------
1851
- }
1852
-
1853
- /**
1854
- * Update item priority
1855
- * @param integer $item_id Store product item ID from database
1856
- * @param integer $new_priority New priority (order) value
1857
- * @return boolean
1858
- */
1859
- public function UpdatePresentationItemPriority($item_id, $new_priority = 0) {
1860
- //-------------------------------------------------------------------------------------------------------
1861
- $db_query = '
1862
- UPDATE
1863
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1864
-
1865
- SET
1866
- `priority` = '.intval($new_priority).'
1867
-
1868
- WHERE
1869
- `id` = '.intval($item_id).'
1870
-
1871
- LIMIT 1
1872
- ';
1873
-
1874
- //---------------------------------------------------------------------
1875
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1876
- //---------------------------------------------------------------------
1877
-
1878
- //-------------------------------------------------------------------------------------------------------
1879
- if ($query = $this->database->Query($db_query)) {
1880
- //-------------------------------------------------------------------------------------------------------
1881
- $this->Log($item_id, '_presentations_items', 'update');
1882
- //-------------------------------------------------------------------------------------------------------
1883
- return true;
1884
- //-------------------------------------------------------------------------------------------------------
1885
- }
1886
- else {
1887
- //-------------------------------------------------------------------------------------------------------
1888
- return false;
1889
- //-------------------------------------------------------------------------------------------------------
1890
- }
1891
- //-------------------------------------------------------------------------------------------------------
1892
- }
1893
-
1894
- /**
1895
- * Update item visibility status
1896
- * @param integer $item_id Store product item ID from database
1897
- * @param string $status New item visibility status [active / inactive]
1898
- * @return boolean
1899
- */
1900
- public function UpdatePresentationItemStatus($item_id, $status = 'inactive') {
1901
- //-------------------------------------------------------------------------------------------------------
1902
- $db_query = '
1903
- UPDATE
1904
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1905
-
1906
- SET
1907
- `status` = \''.$status.'\'
1908
-
1909
- WHERE
1910
- `id` = '.intval($item_id).'
1911
-
1912
- LIMIT 1
1913
- ';
1914
-
1915
- //---------------------------------------------------------------------
1916
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1917
- //---------------------------------------------------------------------
1918
-
1919
- //-------------------------------------------------------------------------------------------------------
1920
- if ($query = $this->database->Query($db_query)) {
1921
- //-------------------------------------------------------------------------------------------------------
1922
- $this->Log($item_id, '_presentations_items', 'update');
1923
- //-------------------------------------------------------------------------------------------------------
1924
- return true;
1925
- //-------------------------------------------------------------------------------------------------------
1926
- }
1927
- else {
1928
- //-------------------------------------------------------------------------------------------------------
1929
- return false;
1930
- //-------------------------------------------------------------------------------------------------------
1931
- }
1932
- //-------------------------------------------------------------------------------------------------------
1933
- }
1934
-
1935
- /**
1936
- * Delete presentation item
1937
- * @param integer $item_id Store product item ID from database
1938
- * @return boolean
1939
- */
1940
- public function DeletePresentationItem($item_id) {
1941
- //-------------------------------------------------------------------------------------------------------
1942
- $db_query = '
1943
- DELETE FROM
1944
- `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1945
-
1946
- WHERE
1947
- `id` = '.intval($item_id).'
1948
-
1949
- LIMIT 1
1950
- ';
1951
-
1952
- //---------------------------------------------------------------------
1953
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1954
- //---------------------------------------------------------------------
1955
-
1956
- //-------------------------------------------------------------------------------------------------------
1957
- if ($query = $this->database->Query($db_query)) {
1958
- //-------------------------------------------------------------------------------------------------------
1959
- $this->Log($item_id, '_presentations_items', 'delete');
1960
- //-------------------------------------------------------------------------------------------------------
1961
- return true;
1962
- //-------------------------------------------------------------------------------------------------------
1963
- }
1964
- else {
1965
- //-------------------------------------------------------------------------------------------------------
1966
- return false;
1967
- //-------------------------------------------------------------------------------------------------------
1968
- }
1969
- //-------------------------------------------------------------------------------------------------------
1970
- }
1971
-
1972
- /**
1973
- * Get store plugin version
1974
- * @return string
1975
- */
1976
- public function GetVersion() {
1977
- //----------------------------------------------------------
1978
- return $this->database->GetVersion();
1979
- //----------------------------------------------------------
1980
- }
1981
-
1982
- /**
1983
- * Install database tables
1984
- * @return boolean
1985
- */
1986
- public function Install() {
1987
- //---------------------------------------------------------------------------------------------------
1988
- return $this->database->Install();
1989
- //---------------------------------------------------------------------------------------------------
1990
- }
1991
-
1992
- /**
1993
- * Save actions log
1994
- * @param integer $item_id Item ID
1995
- * @param integer $item_table Item table
1996
- * @param string $action Action to log [add/delete/info/skip/update]
1997
- * @param string $comment
1998
- * @return boolean
1999
- */
2000
- public function Log($item_id, $item_table = '_presentations', $action = 'info', $comment = 'manual') {
2001
- //-------------------------------------------------------------------------------------------------------
2002
-
2003
- $db_query = '
2004
- INSERT INTO
2005
- `'.$this->db_prefix.$this->db_orbitvu.'log`
2006
- (`_item_id`, `_item_table`, `action`, `comment`, `date`, `ip`)
2007
-
2008
- VALUES (
2009
- '.intval($item_id).',
2010
- \''.$item_table.'\',
2011
- \''.$action.'\',
2012
- \''.$this->database->Escape($comment).'\',
2013
- NOW(),
2014
- \''.$_SERVER['REMOTE_ADDR'].'\'
2015
- )
2016
- ';
2017
-
2018
- //---------------------------------------------------------------------
2019
- /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
2020
- //---------------------------------------------------------------------
2021
-
2022
- $query = $this->database->Query($db_query);
2023
- //-------------------------------------------------------------------------------------------------------
2024
- return true;
2025
- //-------------------------------------------------------------------------------------------------------
2026
- }
2027
-
2028
- /**
2029
- * Debugger
2030
- * @param array $params
2031
- * @return string
2032
- */
2033
- private function return_debug($params) {
2034
- //---------------------------------------------------------------------------------------------------
2035
- if ($this->debug) {
2036
- //---------------------------------------------------------------------------------------------------
2037
- return OrbitvuDebugger::Debug($params);
2038
- //---------------------------------------------------------------------------------------------------
2039
- }
2040
- //---------------------------------------------------------------------------------------------------
2041
- }
2042
-
2043
- /**
2044
- * SQL Debugger
2045
- * @param string $function
2046
- * @param string $db_query
2047
- * @return string
2048
- */
2049
- private function return_sql_debug($function, $db_query) {
2050
- //---------------------------------------------------------------------------------------------------
2051
- if ($this->debug) {
2052
- //---------------------------------------------------------------------------------------------------
2053
- return OrbitvuDebugger::DebugSQL($function, $db_query);
2054
- //---------------------------------------------------------------------------------------------------
2055
- }
2056
- //---------------------------------------------------------------------------------------------------
2057
- }
2058
-
2059
- /**
2060
- * Unit tests
2061
- */
2062
- private function run_tests() {
2063
- //-----------------------------------------------------------------------------------------------------
2064
- /*
2065
- * Basic functions
2066
- */
2067
- //-----------------------------------------------------------------------------------------------------
2068
- $tests_vars = array(
2069
- 'access_token',
2070
- 'viewers_path',
2071
- 'temp_path'
2072
- );
2073
-
2074
- $configuration = $this->GetConfiguration();
2075
- $tst = array();
2076
- //-----------------------------------------------------------------------------------------------------
2077
- for ($i = 0, $n = count($tests_vars); $i < $n; $i++) {
2078
-
2079
- $tst[] = array(
2080
- /**/ 'function' => 'GetConfiguration()',
2081
- /**/ 'given' => $configuration->$tests_vars[$i],
2082
- /**/ 'expected' => '->'.$tests_vars[$i]
2083
- );
2084
-
2085
- if (!empty($configuration->$tests_vars[$i])) {
2086
- $result = 'ok';
2087
- }
2088
- else {
2089
- $result = 'fail';
2090
- }
2091
-
2092
- }
2093
-
2094
- $this->testclass->UpdateTest('GetConfiguration', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2095
- $this->testclass->UpdateTest('GetConfiguration', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2096
- //-----------------------------------------------------------------------------------------------------
2097
- /*
2098
- * Paths writables
2099
- */
2100
- //-----------------------------------------------------------------------------------------------------
2101
- $this->testclass->AppendTest('is_writable(paths)', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
2102
-
2103
- $tests_vars = array(
2104
- 'viewers_path',
2105
- 'temp_path'
2106
- );
2107
-
2108
- $tst = array();
2109
- //-----------------------------------------------------------------------------------------------------
2110
- for ($i = 0, $n = count($tests_vars); $i < $n; $i++) {
2111
-
2112
- $bool = is_writable($configuration->$tests_vars[$i]);
2113
-
2114
- $tst[] = array(
2115
- /**/ 'function' => 'is_writable('.$configuration->$tests_vars[$i].')',
2116
- /**/ 'given' => ($bool ? 'true' : 'false'),
2117
- /**/ 'expected' => 'true'
2118
- );
2119
-
2120
- if ($bool) {
2121
- $result = 'ok';
2122
- }
2123
- else {
2124
- $result = 'fail';
2125
- }
2126
-
2127
- }
2128
- //-----------------------------------------------------------------------------------------------------
2129
- $this->testclass->UpdateTest('is_writable(paths)', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2130
- //-----------------------------------------------------------------------------------------------------
2131
- }
2132
-
2133
- }
2134
-
2135
- /**
2136
- * Decodes data encoded with MIME base64
2137
- * @param string $data The encoded data.
2138
- * @param bool $strict [optional]
2139
- * @return FALSE if input contains character from outside the base64 alphabet.
2140
- */
2141
- function base64decode($data, $strict = false) {
2142
- $data = json_decode(base64_decode(base64_decode($data)));
2143
-
2144
- return $data;
2145
- }
2146
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2147
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ */
6
+
7
+ final class OrbitvuDatabaseInterface {
8
+
9
+ /**
10
+ * Database driver instance
11
+ * @var instance
12
+ */
13
+ private $database;
14
+
15
+ /**
16
+ * Database tables prefix
17
+ * @var string
18
+ */
19
+ private $db_prefix = '';
20
+
21
+ /**
22
+ * Orbitvu tables previx
23
+ * @var string
24
+ */
25
+ private $db_orbitvu = 'orbitvu_';
26
+
27
+ /**
28
+ * Debug mode
29
+ * @var boolean
30
+ */
31
+ private $debug = false;
32
+
33
+ /**
34
+ * Unit tests mode
35
+ * @var boolean
36
+ */
37
+ private $test = false;
38
+
39
+ /**
40
+ * Test class instance
41
+ * @var instance
42
+ */
43
+ private $testclass = false;
44
+
45
+ /**
46
+ * Configuration vars and values
47
+ * @var stdClass|boolean
48
+ */
49
+ public $Config = false;
50
+
51
+ /**
52
+ * SUN API connection instance
53
+ * @var instance
54
+ */
55
+ public $Connect;
56
+
57
+ /**
58
+ * Manage the database
59
+ * @param string $prefix Database prefix
60
+ * @param boolean $debug Debug mode
61
+ * @param boolean $test Unit tests mode
62
+ * @param boolean $testinstance Unit tests instance.
63
+ */
64
+ public function __construct($prefix = '', $debug = false, $test = false, $testinstance = false) {
65
+ //-------------------------------------------------------------------------------------------------------
66
+ require_once(__DIR__.'/OrbitvuDatabaseDriver.php');
67
+ //-------------------------------------------------------------------------------------------------------
68
+ $this->debug = $debug;
69
+ $this->test = $test;
70
+ //-------------------------------------------------------------------------------------------------------
71
+ $this->database = new OrbitvuDatabaseDriver();
72
+ //---------------------------------------------------------------------------------------------------
73
+ if (!empty($prefix)) $this->db_prefix = $prefix;
74
+ else $this->db_prefix = $this->database->GetPrefix();
75
+
76
+ if ($this->is_sh()) {
77
+ $this->db_orbitvu .= 'sh_';
78
+ }
79
+ //---------------------------------------------------------------------------------------------------
80
+ $this->Config = $this->GetConfiguration();
81
+ /*
82
+ * Test instance
83
+ */
84
+ if ($this->test) {
85
+ $this->testclass = $testinstance;
86
+
87
+ /*
88
+ * Run test bot!
89
+ */
90
+ $this->run_tests();
91
+ }
92
+ //-------------------------------------------------------------------------------------------------------
93
+ }
94
+
95
+ /**
96
+ * Set Orbitvu SUN connection instance
97
+ * @param instance $connect
98
+ */
99
+ public function SetSUNConnection($connect) {
100
+ //----------------------------------------------------------
101
+ $this->Connect = $connect;
102
+ //----------------------------------------------------------
103
+ }
104
+
105
+ /**
106
+ * Synchronize all products
107
+ * @return boolean
108
+ */
109
+ public function SynchronizeAllProducts() {
110
+ //----------------------------------------------------------
111
+ return $this->SynchronizeAllPresentations($this->database->SynchronizeAllProducts());
112
+ //----------------------------------------------------------
113
+ }
114
+
115
+ /**
116
+ * @see OrbitvuDatabaseDriver.php\GetLocalSessionKey()
117
+ * @return string
118
+ */
119
+ public function GetLocalSessionKey() {
120
+ //----------------------------------------------------------
121
+ return $this->database->GetLocalSessionKey();
122
+ //----------------------------------------------------------
123
+ }
124
+
125
+ /**
126
+ * @see OrbitvuDatabaseDriver.php\GetRemoteAuthorizationUrl()
127
+ * @return string
128
+ */
129
+ public function GetRemoteAuthorizationUrl() {
130
+ //----------------------------------------------------------
131
+ return $this->database->GetRemoteAuthorizationUrl();
132
+ //----------------------------------------------------------
133
+ }
134
+
135
+ /**
136
+ * @see OrbitvuDatabaseDriver.php\GetRemoteUploadUrl()
137
+ * @return string
138
+ */
139
+ public function GetRemoteUploadUrl() {
140
+ //----------------------------------------------------------
141
+ return $this->database->GetRemoteUploadUrl();
142
+ //----------------------------------------------------------
143
+ }
144
+
145
+ /**
146
+ * Get all configuration vars and values.
147
+ * Update local values to store values
148
+ * @return stdClass
149
+ */
150
+ public function GetConfiguration() {
151
+ //----------------------------------------------------------
152
+ if ($this->Config != false) return $this->Config;
153
+ //----------------------------------------------------------
154
+ if ($this->test) {
155
+ $this->testclass->AppendTest('GetConfiguration', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
156
+ }
157
+ //----------------------------------------------------------
158
+ $db_query = '
159
+ SELECT *
160
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'configuration`
161
+ ';
162
+
163
+ //---------------------------------------------------------------------
164
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
165
+ //---------------------------------------------------------------------
166
+
167
+ try {
168
+ $query = $this->database->FetchAll($db_query);
169
+ }
170
+ catch (Exception $e) {
171
+ $this->Install();
172
+
173
+ //----------------------------------------------------------
174
+ /**/ $this->return_debug(array(
175
+ /**/ 'function' => 'Install',
176
+ /**/ 'response' => 'Database installed!'
177
+ /**/ ));
178
+ //----------------------------------------------------------
179
+
180
+ $query = $this->database->FetchAll($db_query);
181
+ }
182
+
183
+ /*
184
+ * Synchronize config with current store configuration
185
+ */
186
+ $store_config = $this->database->GetConfiguration();
187
+
188
+ //-------------------------------------------------------------------------------------------------------
189
+ $conf = new stdClass();
190
+ $i = 0;
191
+ foreach ($query as $q) {
192
+ $conf->$q['var'] = $q['value'];
193
+
194
+ if (isset($store_config[$q['var']]) && $store_config[$q['var']] != $conf->$q['var']) {
195
+ $this->SetConfiguration($q['var'], $store_config[$q['var']]);
196
+ $conf->$q['var'] = $store_config[$q['var']];
197
+ }
198
+ $i++;
199
+ }
200
+
201
+ //----------------------------------------------------------
202
+ /**/ $this->return_debug(array(
203
+ /**/ 'function' => __FUNCTION__,
204
+ /**/ 'configuration' => $conf
205
+ /**/ ));
206
+ //----------------------------------------------------------
207
+
208
+ //-------------------------------------------------------------------------------------------------------
209
+ return $conf;
210
+ //-------------------------------------------------------------------------------------------------------
211
+ }
212
+
213
+ /**
214
+ * Set local configuration value
215
+ * or add new var and value
216
+ * @param string $var
217
+ * @param string $value
218
+ * @return boolean
219
+ */
220
+ public function SetConfiguration($var, $value) {
221
+ //-------------------------------------------------------------------------------------------------------
222
+ $db_query = '
223
+ INSERT INTO
224
+ `'.$this->db_prefix.$this->db_orbitvu.'configuration`
225
+ (`var`, `value`, `type`)
226
+
227
+ VALUES (
228
+ \''.$var.'\',
229
+ \''.$this->database->Escape($value).'\',
230
+ \'main\'
231
+ )
232
+
233
+ ON DUPLICATE KEY
234
+
235
+ UPDATE
236
+ `value` = \''.($value).'\'
237
+ ';
238
+
239
+ //---------------------------------------------------------------------
240
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
241
+ //---------------------------------------------------------------------
242
+
243
+ $query = $this->database->Query($db_query);
244
+
245
+ //-------------------------------------------------------------------------------------------------------
246
+ $this->Log(0, '_configuration', 'update', $var.'='.$value, 'auto');
247
+ //-------------------------------------------------------------------------------------------------------
248
+ return true;
249
+ //-------------------------------------------------------------------------------------------------------
250
+ }
251
+
252
+ /**
253
+ * Set store configuration
254
+ * @param string $var
255
+ * @param string $value
256
+ * @return boolean
257
+ */
258
+ public function SetConfigurationParent($var, $value) {
259
+ //-------------------------------------------------------------------------------------------------------
260
+ return $this->database->SetConfiguration($var, $value);
261
+ //-------------------------------------------------------------------------------------------------------
262
+ }
263
+
264
+ /**
265
+ * Unlink (free) presentation from product
266
+ * @param integer $product_id Store product ID from database
267
+ * @return boolean
268
+ */
269
+ public function FreeProduct($product_id) {
270
+ //-------------------------------------------------------------------------------------------------------
271
+ $db_query = '
272
+ SELECT *
273
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
274
+
275
+ WHERE
276
+ `product_id` = '.intval($product_id).'
277
+
278
+ LIMIT 1
279
+ ';
280
+
281
+ //---------------------------------------------------------------------
282
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
283
+ //---------------------------------------------------------------------
284
+
285
+ $query = $this->database->FetchAll($db_query);
286
+ //-------------------------------------------------------------------------------------------------------
287
+ $product = $query[0];
288
+ //-------------------------------------------------------------------------------------------------------
289
+
290
+ /*
291
+ * Free items
292
+ */
293
+ //-------------------------------------------------------------------------------------------------------
294
+ $db_query = '
295
+ DELETE
296
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
297
+
298
+ WHERE
299
+ `_presentations_id` = '.intval($product['id']).'
300
+ ';
301
+
302
+ //---------------------------------------------------------------------
303
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
304
+ //---------------------------------------------------------------------
305
+
306
+ $query = $this->database->Query($db_query);
307
+
308
+ /*
309
+ * Add history
310
+ */
311
+ //-------------------------------------------------------------------------------------------------------
312
+ $db_query = '
313
+ INSERT INTO
314
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
315
+ (`product_id`, `orbitvu_id`, `unlink_date`)
316
+
317
+ VALUES (
318
+ '.intval($product['product_id']).',
319
+ '.intval($product['orbitvu_id']).',
320
+ NOW()
321
+ )
322
+ ';
323
+
324
+ //---------------------------------------------------------------------
325
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
326
+ //---------------------------------------------------------------------
327
+
328
+ $query = $this->database->Query($db_query);
329
+
330
+ /*
331
+ * Free product
332
+ */
333
+ //-------------------------------------------------------------------------------------------------------
334
+ $db_query = '
335
+ DELETE FROM
336
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
337
+
338
+ WHERE
339
+ `id` = '.intval($product['id']).'
340
+
341
+ LIMIT 1
342
+ ';
343
+
344
+ /*
345
+ * Free thumbnails
346
+ */
347
+ $this->DeleteProductThumbnail($product['product_id']);
348
+
349
+ //---------------------------------------------------------------------
350
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
351
+ //---------------------------------------------------------------------
352
+
353
+ $query = $this->database->Query($db_query);
354
+
355
+ //-------------------------------------------------------------------------------------------------------
356
+ $this->Log($product['id'], '_presentations', 'delete');
357
+ //-------------------------------------------------------------------------------------------------------
358
+ return true;
359
+ //-------------------------------------------------------------------------------------------------------
360
+ }
361
+
362
+ /**
363
+ * Get our store thumbnails
364
+ * @param integer $product_id Store product ID from database
365
+ * @return array
366
+ */
367
+ public function GetProductThumbnails($product_id) {
368
+ //-------------------------------------------------------------------------------------------------------
369
+ $db_query = '
370
+ SELECT *
371
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
372
+
373
+ WHERE
374
+ `product_id` = '.intval($product_id).'
375
+ ';
376
+
377
+ //---------------------------------------------------------------------
378
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
379
+ //---------------------------------------------------------------------
380
+
381
+ $query = $this->database->FetchAll($db_query);
382
+
383
+ //-------------------------------------------------------------------------------------------------------
384
+ return $query;
385
+ //-------------------------------------------------------------------------------------------------------
386
+ }
387
+
388
+ /**
389
+ * Set store thumbnail
390
+ * @param integer $product_id Store product ID from database
391
+ * @param string $thumbnail Thumbnail path
392
+ * @return array
393
+ */
394
+ public function SetProductThumbnail($product_id, $thumbnail) {
395
+ //-------------------------------------------------------------------------------------------------------
396
+ $db_query = '
397
+ INSERT INTO
398
+ `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
399
+ (`product_id`, `thumbnail`)
400
+
401
+ VALUES (
402
+ '.intval($product_id).',
403
+ \''.$thumbnail.'\'
404
+ )
405
+ ';
406
+
407
+ //---------------------------------------------------------------------
408
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
409
+ //---------------------------------------------------------------------
410
+
411
+ try {
412
+ $query = $this->database->Query($db_query);
413
+ }
414
+ catch(Exception $e) {}
415
+
416
+ //-------------------------------------------------------------------------------------------------------
417
+ return $query;
418
+ //-------------------------------------------------------------------------------------------------------
419
+ }
420
+
421
+ /**
422
+ * Delete store thumbnail
423
+ * @param integer $product_id Store product ID from database
424
+ * @param string $thumbnail Thumbnail path
425
+ * @return array
426
+ */
427
+ public function DeleteProductThumbnail($product_id, $thumbnail = '') {
428
+ //-------------------------------------------------------------------------------------------------------
429
+ $db_query = '
430
+ DELETE FROM
431
+ `'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
432
+
433
+ WHERE
434
+ `product_id` = '.intval($product_id).'
435
+ '.(!empty($thumbnail) ? ' AND `thumbnail` = \''.$thumbnail.'\' ' : '').'
436
+
437
+ LIMIT 1
438
+ ';
439
+
440
+ //---------------------------------------------------------------------
441
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
442
+ //---------------------------------------------------------------------
443
+
444
+ $query = $this->database->Query($db_query);
445
+
446
+ //-------------------------------------------------------------------------------------------------------
447
+ return $query;
448
+ //-------------------------------------------------------------------------------------------------------
449
+ }
450
+
451
+ /**
452
+ * Is the product unlinked?
453
+ * @param integer $product_id Store product ID from database
454
+ * @return boolean
455
+ */
456
+ public function IsProductUnlinked($product_id) {
457
+ //-------------------------------------------------------------------------------------------------------
458
+ $db_query = '
459
+ SELECT *
460
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
461
+
462
+ WHERE
463
+ `product_id` = '.intval($product_id).'
464
+
465
+ LIMIT 1
466
+ ';
467
+
468
+ //---------------------------------------------------------------------
469
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
470
+ //---------------------------------------------------------------------
471
+
472
+ $query = $this->database->FetchAll($db_query);
473
+ $query = isset($query[0]) ? $query[0] : null;
474
+
475
+ //-------------------------------------------------------------------------------------------------------
476
+ if (isset($query['orbitvu_id']) && $query['orbitvu_id'] > 0) {
477
+ return true;
478
+ }
479
+ else {
480
+ return false;
481
+ }
482
+ //-------------------------------------------------------------------------------------------------------
483
+ }
484
+
485
+ /**
486
+ * @param $product_id
487
+ * @return array|Exception
488
+ */
489
+ public function GetAssociatedProducts($product_id) {
490
+ //-------------------------------------------------------------------------------------------------------
491
+ $db_query = '
492
+ SELECT `product_id`
493
+ FROM `'.$this->db_prefix.'catalog_product_super_link`
494
+
495
+ WHERE
496
+ `parent_id` = '.intval($product_id).'
497
+
498
+ ';
499
+
500
+ $query = $this->database->FetchAll($db_query);
501
+
502
+ //-------------------------------------------------------------------------------------------------------
503
+ return $query;
504
+ //-------------------------------------------------------------------------------------------------------
505
+ }
506
+
507
+ /**
508
+ * Is presentation unlinked?
509
+ * @param integer $product_id Store product ID from database
510
+ * @param integer $orbitvu_id Orbitvu SUN presentation ID
511
+ * @return boolean
512
+ */
513
+ public function IsPresentationUnlinked($product_id, $orbitvu_id) {
514
+ //-------------------------------------------------------------------------------------------------------
515
+ $db_query = '
516
+ SELECT *
517
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_history`
518
+
519
+ WHERE
520
+ `product_id` = '.intval($product_id).' AND
521
+ `orbitvu_id` = '.intval($orbitvu_id).'
522
+
523
+ LIMIT 1
524
+ ';
525
+
526
+ //---------------------------------------------------------------------
527
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
528
+ //---------------------------------------------------------------------
529
+
530
+ $query = $this->database->FetchAll($db_query);
531
+ $query = isset($query[0]) ? $query[0] : null;
532
+
533
+ //-------------------------------------------------------------------------------------------------------
534
+ if (isset($query['orbitvu_id']) && $query['orbitvu_id'] > 0) {
535
+ return true;
536
+ }
537
+ else {
538
+ return false;
539
+ }
540
+ //-------------------------------------------------------------------------------------------------------
541
+ }
542
+
543
+ /**
544
+ * Product presentation exists?
545
+ * @param integer $product_id Store product ID from database
546
+ * @return boolean
547
+ */
548
+ public function ExistsProductPresentation($product_id) {
549
+ //-------------------------------------------------------------------------------------------------------
550
+ $db_query = '
551
+ SELECT *
552
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
553
+
554
+ WHERE
555
+ `product_id` = '.intval($product_id).'
556
+
557
+ LIMIT 1
558
+ ';
559
+
560
+ //---------------------------------------------------------------------
561
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
562
+ //---------------------------------------------------------------------
563
+
564
+ $query = $this->database->FetchAll($db_query);
565
+ $query = isset($query[0]) ? $query[0] : null;
566
+ //-------------------------------------------------------------------------------------------------------
567
+ if (isset($query['type'])) {
568
+ return true;
569
+ }
570
+ //-------------------------------------------------------------------------------------------------------
571
+ return false;
572
+ //-------------------------------------------------------------------------------------------------------
573
+ }
574
+
575
+ /**
576
+ * Get product presentation data
577
+ * Get product presentation items
578
+ * @param integer $product_id Store product ID from database
579
+ * @param boolean $visible_only Return only items marked as visible
580
+ * @return array
581
+ */
582
+ public function GetProductPresentation($product_id, $visible_only = false) {
583
+ //-------------------------------------------------------------------------------------------------------
584
+ $db_query = '
585
+ SELECT *
586
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
587
+
588
+ WHERE
589
+ `product_id` = '.intval($product_id).'
590
+
591
+ LIMIT 1
592
+ ';
593
+
594
+ //---------------------------------------------------------------------
595
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
596
+ //---------------------------------------------------------------------
597
+
598
+ $query = $this->database->FetchAll($db_query);
599
+ $query = isset($query[0]) ? $query[0] : null;
600
+ //-------------------------------------------------------------------------------------------------------
601
+ $ret = array();
602
+ //-------------------------------------------------------------------------------------------------------
603
+ if (isset($query['type'])) {
604
+ //-------------------------------------------------------------------------------------------------------
605
+ $ret = $query;
606
+
607
+ /**
608
+ * SelfHosted data
609
+ */
610
+ if ($this->is_sh() && intval($ret['orbitvu_id']) > 0) {
611
+ $db_query_sh = '
612
+ SELECT *
613
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
614
+
615
+ WHERE
616
+ `id` = '.intval($ret['orbitvu_id']).'
617
+
618
+ LIMIT 1
619
+ ';
620
+
621
+ //---------------------------------------------------------------------
622
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query_sh);
623
+ //---------------------------------------------------------------------
624
+
625
+ $qsh = $this->database->FetchAll($db_query_sh);
626
+ $qsh = $qsh[0];
627
+
628
+ $ret['dir'] = $qsh['dir'];
629
+ $ret['presentation_name'] = $qsh['name'];
630
+ $ret['content'] = json_decode($qsh['content']);
631
+ }
632
+
633
+ $ret['items'] = array();
634
+
635
+ $ret['types'] = array();
636
+
637
+ //-------------------------------------------------------------------------------------------------------
638
+ $db_sub_query = '
639
+ SELECT *
640
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
641
+
642
+ WHERE
643
+ `_presentations_id` = '.$ret['id'].'
644
+ '.($visible_only ? ' AND `status` = \'active\' ' : '').'
645
+
646
+ ORDER BY
647
+ `priority` DESC
648
+ ';
649
+
650
+ //---------------------------------------------------------------------
651
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_sub_query);
652
+ //---------------------------------------------------------------------
653
+
654
+ $items = $this->database->FetchAll($db_sub_query);
655
+ //-------------------------------------------------------------------------------------------------------
656
+ foreach ($items as $qi) {
657
+ $ret['items'][] = $qi;
658
+
659
+ if (!in_array($qi['type'], $ret['types'])) {
660
+ $ret['types'][] = $qi['type'];
661
+ }
662
+ }
663
+ //rsort($ret['items']);
664
+ rsort($ret['types']);
665
+ //-------------------------------------------------------------------------------------------------------
666
+ return $ret;
667
+ //-------------------------------------------------------------------------------------------------------
668
+ }
669
+ //-------------------------------------------------------------------------------------------------------
670
+ return false;
671
+ //-------------------------------------------------------------------------------------------------------
672
+ }
673
+
674
+ /**
675
+ * Set new product presentation
676
+ * @param type $product_id Store product ID from database
677
+ * @param type $orbitvu_id Orbitvu SUN presentation ID
678
+ * @param type $orbitvu_name Orbitvu SUN presentation name
679
+ * @return boolean
680
+ */
681
+ public function SetProductPresentation($product_id, $orbitvu_id, $presentation_name = '', $comment = 'manual') {
682
+ //-------------------------------------------------------------------------------------------------------
683
+ $db_query = '
684
+ SELECT `id`
685
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
686
+
687
+ WHERE
688
+ `product_id` = '.intval($product_id).'
689
+
690
+ LIMIT 1
691
+ ';
692
+
693
+ //---------------------------------------------------------------------
694
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
695
+ //---------------------------------------------------------------------
696
+
697
+ $check = $this->database->FetchAll($db_query);
698
+ $check = isset($check[0]) ? $check[0] : null;
699
+ //-------------------------------------------------------------------------------------------------------
700
+
701
+ $db_query = '
702
+ INSERT INTO
703
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
704
+ (`product_id`, `orbitvu_id`, `name`, `type`)
705
+
706
+ VALUES (
707
+ '.intval($product_id).',
708
+ '.intval($orbitvu_id).',
709
+ \''.$this->database->Escape($presentation_name).'\',
710
+ \''.($this->is_sh() ? 'local' : 'sun').'\'
711
+ )
712
+
713
+ ON DUPLICATE KEY
714
+
715
+ UPDATE
716
+ `name` = \''.$this->database->Escape($presentation_name).'\',
717
+ `type` = \''.($this->is_sh() ? 'local' : 'sun').'\'
718
+ ';
719
+
720
+ //---------------------------------------------------------------------
721
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
722
+ //---------------------------------------------------------------------
723
+
724
+ $query = $this->database->Query($db_query);
725
+ //-------------------------------------------------------------------------------------------------------
726
+ if (!isset($check['id'])) {
727
+ //-------------------------------------------------------------------------------------------------------
728
+ $this->Log($this->database->GetLastInsertId(), '_presentations', 'add', $comment);
729
+ //-------------------------------------------------------------------------------------------------------
730
+ return $this->database->GetLastInsertId();
731
+ //-------------------------------------------------------------------------------------------------------
732
+ }
733
+ else {
734
+ //-------------------------------------------------------------------------------------------------------
735
+ $this->Log($check['id'], '_presentations', 'skip', $comment);
736
+ //-------------------------------------------------------------------------------------------------------
737
+ return $check['id'];
738
+ //-------------------------------------------------------------------------------------------------------
739
+ }
740
+ }
741
+
742
+ /**
743
+ * Set product presentation items
744
+ * @param type $product_id Store product ID from database
745
+ * @param type $orbitvu_id Orbitvu SUN presentation ID
746
+ * @param type $orbitvu_name Orbitvu SUN presentation name
747
+ * @param type $presentation_items Orbitvu SUN presentation items
748
+ * @return type
749
+ */
750
+ public function SetProductPresentationItems($product_id, $orbitvu_id, $orbitvu_name, $presentation_items, $comment = 'manual') {
751
+ //-------------------------------------------------------------------------------------------------------
752
+ /**
753
+ * Updating presentation id
754
+ */
755
+ //-------------------------------------------------------------------------------------------------------
756
+ $presentation_id = $this->SetProductPresentation($product_id, $orbitvu_id, $orbitvu_name, 'auto');
757
+ //-------------------------------------------------------------------------------------------------------
758
+ /**
759
+ * Inserting new items
760
+ */
761
+ $priority = 10;
762
+ //-------------------------------------------------------------------------------------------------------
763
+ for ($i = 0, $n = count($presentation_items); $i < $n; $i++) {
764
+ //-------------------------------------------------------------------------------------------------------
765
+ $item = $presentation_items[$i];
766
+ //-------------------------------------------------------------------------------------------------------
767
+ $db_query = '
768
+ SELECT `id`
769
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
770
+
771
+ WHERE
772
+ `orbitvu_id` = \''.$this->database->Escape($item['orbitvu_id']).'\' AND
773
+ `_presentations_id` = '.intval($presentation_id).'
774
+
775
+ LIMIT 1
776
+ ';
777
+
778
+ //---------------------------------------------------------------------
779
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
780
+ //---------------------------------------------------------------------
781
+
782
+ $check = $this->database->FetchAll($db_query);
783
+ $check = isset($check[0]) ? $check[0] : null;
784
+ //-------------------------------------------------------------------------------------------------------
785
+ if (!isset($check['id'])) {
786
+ //-------------------------------------------------------------------------------------------------------
787
+ $priority += 10;
788
+
789
+ $db_query = '
790
+ INSERT INTO
791
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
792
+ (`_presentations_id`, `orbitvu_id`, `priority`, `name`, `type`, `thumbnail`, `path`, `config`, `status`)
793
+
794
+ VALUES (
795
+ '.intval($presentation_id).',
796
+ \''.$this->database->Escape($item['orbitvu_id']).'\',
797
+ '.($priority).',
798
+ \''.$this->database->Escape($item['name']).'\',
799
+ '.intval($item['type']).',
800
+ \''.($item['thumbnail']).'\',
801
+ \''.($item['path']).'\',
802
+ \''.$this->database->Escape($item['config']).'\',
803
+ \''.($item['status']).'\'
804
+ )
805
+ ';
806
+
807
+ //---------------------------------------------------------------------
808
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
809
+ //---------------------------------------------------------------------
810
+
811
+ $this->database->Query($db_query);
812
+
813
+ //-------------------------------------------------------------------------------------------------------
814
+ $this->Log($this->database->GetLastInsertId(), '_presentations_items', 'add', $comment);
815
+ //-------------------------------------------------------------------------------------------------------
816
+ }
817
+ else {
818
+ //-------------------------------------------------------------------------------------------------------
819
+ $this->Log($check['id'], '_presentations_items', 'skip', 'auto');
820
+ //-------------------------------------------------------------------------------------------------------
821
+ }
822
+ //-------------------------------------------------------------------------------------------------------
823
+ }
824
+ //-------------------------------------------------------------------------------------------------------
825
+ return true;
826
+ //-------------------------------------------------------------------------------------------------------
827
+ }
828
+
829
+ /**
830
+ * Search the presentation with name and SKU
831
+ * @param array $product Product array with name and SKU
832
+ * @return array|boolean
833
+ */
834
+ public function MatchPresentation($product) {
835
+ //-------------------------------------------------------------------------------------------------------
836
+ $product_name = $product['product_name'];
837
+ $product_sku = $product['product_sku'];
838
+
839
+ //----------------------------------------------------------
840
+ /**/ $this->return_debug(array(
841
+ /**/ 'function' => __FUNCTION__,
842
+ /**/ 'product_name' => $product_name,
843
+ /**/ 'product_sku' => $product_sku,
844
+ /**/ 'line' => __LINE__
845
+ /**/ ));
846
+ //----------------------------------------------------------
847
+
848
+ //-------------------------------------------------------------------------------------------------------
849
+ $count = 0;
850
+ //-------------------------------------------------------------------------------------------------------
851
+ if (!empty($product_sku)) {
852
+ $presentations_choose = $this->GetPresentationsList(array(
853
+ 'page_size' => 1,
854
+ 'name' => $product_sku
855
+ ));
856
+
857
+ //----------------------------------------------------------
858
+ /**/ $this->return_debug(array(
859
+ /**/ 'function' => __FUNCTION__,
860
+ /**/ 'line' => __LINE__,
861
+ /**/ 'match_type' => 'name='.$product_sku,
862
+ /**/ 'presentations' => $presentations_choose,
863
+ /**/ ));
864
+ //----------------------------------------------------------
865
+
866
+ $count = $presentations_choose->count;
867
+
868
+ if ($count == 0) {
869
+ $presentations_choose = $this->GetPresentationsList(array(
870
+ 'page_size' => 1,
871
+ 'sku' => $product_sku
872
+ ));
873
+
874
+ //----------------------------------------------------------
875
+ /**/ $this->return_debug(array(
876
+ /**/ 'function' => __FUNCTION__,
877
+ /**/ 'line' => __LINE__,
878
+ /**/ 'match_type' => 'sku='.$product_sku,
879
+ /**/ 'presentations' => $presentations_choose,
880
+ /**/ ));
881
+ //----------------------------------------------------------
882
+
883
+ $count = $presentations_choose->count;
884
+ }
885
+ }
886
+ //-------------------------------------------------------------------------------------------------------
887
+ if (!empty($product_name) && $count == 0) {
888
+ $presentations_choose = $this->GetPresentationsList(array(
889
+ 'page_size' => 1,
890
+ 'name' => $product_name
891
+ ));
892
+
893
+ //----------------------------------------------------------
894
+ /**/ $this->return_debug(array(
895
+ /**/ 'function' => __FUNCTION__,
896
+ /**/ 'line' => __LINE__,
897
+ /**/ 'match_type' => 'name='.$product_name,
898
+ /**/ 'presentations' => $presentations_choose,
899
+ /**/ ));
900
+ //----------------------------------------------------------
901
+
902
+ $count = $presentations_choose->count;
903
+
904
+ if ($count == 0) {
905
+ $presentations_choose = $this->GetPresentationsList(array(
906
+ 'page_size' => 1,
907
+ 'sku' => $product_name
908
+ ));
909
+
910
+ //----------------------------------------------------------
911
+ /**/ $this->return_debug(array(
912
+ /**/ 'function' => __FUNCTION__,
913
+ /**/ 'line' => __LINE__,
914
+ /**/ 'match_type' => 'sku='.$product_name,
915
+ /**/ 'presentations' => $presentations_choose,
916
+ /**/ ));
917
+ //----------------------------------------------------------
918
+
919
+ $count = $presentations_choose->count;
920
+ }
921
+ }
922
+ //-------------------------------------------------------------------------------------------------------
923
+ if ($count == 0) return false;
924
+ else {
925
+ return $presentations_choose;
926
+ }
927
+ //-------------------------------------------------------------------------------------------------------
928
+ }
929
+
930
+ public function SynchronizeAllPresentations($products_array) {
931
+ $products = array();
932
+ $presentations_list = $this->GetPresentationsList();
933
+
934
+ for($i = 0; $i < count($products_array); $i++) {
935
+ $current_product = $products_array[$i];
936
+
937
+
938
+ //product has to posses name and id at least
939
+ if (empty($current_product['product_id']) || empty($current_product['product_name'])) {
940
+ //-------------------------------------------------------------------------------------------------------
941
+ continue; //
942
+ //-------------------------------------------------------------------------------------------------------
943
+ }
944
+
945
+
946
+ //check if product is already linked
947
+ if ($try = $this->GetProductPresentation($current_product['product_id'])) {
948
+ $comment = 'auto';
949
+
950
+ $this->Log($current_product['product_id'], '_presentations', 'skip', $comment);
951
+ //-------------------------------------------------------------------------------------------------------
952
+ continue;
953
+ //-------------------------------------------------------------------------------------------------------
954
+ }
955
+ $products[] = $current_product;
956
+ }
957
+
958
+
959
+ if ($presentations_list->count) {
960
+ for($i = 0; $i < $presentations_list->count; $i++) {
961
+
962
+ $current_presentation = $presentations_list->results[$i];
963
+ for($j = 0; $j < count($products); $j++) {
964
+
965
+ //ommit products which have been linked to current_presentation id
966
+ //we dont set the ommit flag becasue product may match to presentation with other id
967
+ if ($this->IsPresentationUnlinked($products[$j]['product_id'], $current_presentation->id)) {
968
+ continue;
969
+ }
970
+
971
+ if (isset($products[$j]['ommit']) && $products[$j]['ommit'] = true) {
972
+ continue;
973
+ }
974
+
975
+ $synch = false;
976
+ if (isset($products[$j]['product_sku']) && $products[$j]['product_sku'] == $current_presentation->sku) {
977
+ $products[$j]['ommit'] = true;
978
+ $synch = true;
979
+
980
+ } else if ($products[$j]['product_name'] && strcasecmp($products[$j]['product_name'], $current_presentation->name) == 0) {
981
+ $products[$j]['ommit'] = true;
982
+ $synch = true;
983
+ }
984
+
985
+ if ($synch) {
986
+ $comment = ' auto - "'.$products[$j]['product_sku'].'"';
987
+
988
+ $this->SetProductPresentation($products[$j]['product_id'], $current_presentation->id, $current_presentation->name, $comment);
989
+
990
+ $p_items = array();
991
+ //-------------------------------------------------------------------------------------------------------
992
+ $sync_order = array(
993
+ 'sync_2d' => true,
994
+ 'sync_360' => true,
995
+ 'sync_orbittour' => true
996
+ );
997
+ //-------------------------------------------------------------------------------------------------------
998
+ foreach ($sync_order as $key => $value) {
999
+ $sync_order[$key] = $this->Config->$key;
1000
+ }
1001
+
1002
+ $results = $current_presentation;
1003
+ $uid = $results->uid;
1004
+ //-------------------------------------------------------------------------------------------------------
1005
+ /*
1006
+ * Get OrbitTour
1007
+ */
1008
+ //-------------------------------------------------------------------------------------------------------
1009
+ if ($results->has_orbittour == '1') {
1010
+ $p_items[] = array(
1011
+ 'orbitvu_id' => ($results->orbittour_set[0]->id),
1012
+ 'name' => 'OrbitTour',
1013
+ 'type' => 0,
1014
+ 'thumbnail' => $results->thumbnail_url,
1015
+ 'path' => $results->orbittour_set[0]->script_url,
1016
+ 'config' => json_encode(array('uid' => $uid)),
1017
+ 'status' => ($sync_order['sync_orbittour'] == 'true' ? 'active' : 'inactive')
1018
+ );
1019
+ }
1020
+ //-------------------------------------------------------------------------------------------------------
1021
+
1022
+ /*
1023
+ * Get other items
1024
+ */
1025
+ //-------------------------------------------------------------------------------------------------------
1026
+ $results = $results->presentationcontent_set;
1027
+ for ($k = 0, $n = count($results); $k < $n; $k++) {
1028
+ $cur = $results[$k];
1029
+ //-------------------------------------------------------------------------------------------------------
1030
+ if (($sync_order['sync_360'] == 'true' && $cur->type == '1') || ($sync_order['sync_2d'] == 'true' && $cur->type == '3')) {
1031
+ $status = 'active';
1032
+ }
1033
+ else {
1034
+ $status = 'inactive';
1035
+ }
1036
+ //-------------------------------------------------------------------------------------------------------
1037
+ $p_items[] = array(
1038
+ 'orbitvu_id' => ($cur->id),
1039
+ 'name' => $cur->name,
1040
+ 'type' => $cur->type,
1041
+ 'thumbnail' => $cur->thumbnail_url,
1042
+ 'path' => (!empty($cur->script_url) ? $cur->script_url : $cur->view_url),
1043
+ 'config' => json_encode(array('uid' => $uid)),
1044
+ 'status' => $status
1045
+ );
1046
+ }
1047
+
1048
+ if (count($p_items) >= 1) {
1049
+ //-------------------------------------------------------------------------------------------------------
1050
+ $this->SetProductPresentationItems($products[$j]['product_id'], $current_presentation->id, $current_presentation->name, $p_items, 'auto');
1051
+ //-------------------------------------------------------------------------------------------------------
1052
+ }
1053
+
1054
+ }
1055
+ }
1056
+
1057
+ }
1058
+ }
1059
+
1060
+ //-------------------------------------------------------------------------------------------------------
1061
+ $this->SetConfiguration('last_updated', date('Y-m-d H:i:s'));
1062
+ //-------------------------------------------------------------------------------------------------------
1063
+
1064
+ return $products;
1065
+ //-------------------------------------------------------------------------------------------------------
1066
+
1067
+ }
1068
+
1069
+
1070
+ /**
1071
+ * Synchronize presentations
1072
+ * @param array $products_array Products array
1073
+ * @return array
1074
+ */
1075
+ public function SynchronizePresentations($products_array) {
1076
+ //-------------------------------------------------------------------------------------------------------
1077
+ /**
1078
+ * Match products with SUN
1079
+ */
1080
+ //-------------------------------------------------------------------------------------------------------
1081
+ for ($i = 0, $n = count($products_array); $i < $n; $i++) {
1082
+ //-------------------------------------------------------------------------------------------------------
1083
+ $current = $products_array[$i];
1084
+ //-------------------------------------------------------------------------------------------------------
1085
+ if (empty($current['product_id']) || empty($current['product_name'])) {
1086
+ //-------------------------------------------------------------------------------------------------------
1087
+ throw new Exception('$product_id or $product_name not provided (both arguments are required).');
1088
+ //-------------------------------------------------------------------------------------------------------
1089
+ }
1090
+ //-------------------------------------------------------------------------------------------------------
1091
+ $comment = '';
1092
+ //-------------------------------------------------------------------------------------------------------
1093
+ /*
1094
+ * Presentation exists?
1095
+ */
1096
+ if ($try = $this->GetProductPresentation($current['product_id'])) {
1097
+ $comment = 'auto';
1098
+
1099
+ $this->Log($current['product_id'], '_presentations', 'skip', $comment);
1100
+ //-------------------------------------------------------------------------------------------------------
1101
+ continue;
1102
+ //-------------------------------------------------------------------------------------------------------
1103
+ }
1104
+ //-------------------------------------------------------------------------------------------------------
1105
+ $product_search = array(
1106
+ 'product_sku' => $current['product_sku'],
1107
+ 'product_name' => $current['product_name']
1108
+ );
1109
+
1110
+ $response = $this->MatchPresentation($product_search);
1111
+ $comment = ' auto - "'.$current['product_sku'].'"';
1112
+ //-------------------------------------------------------------------------------------------------------
1113
+ /*
1114
+ * Found match? Update DB
1115
+ */
1116
+ //-------------------------------------------------------------------------------------------------------
1117
+ if ($response->count > 0) {
1118
+ //-------------------------------------------------------------------------------------------------------
1119
+ $result = $response->results[0];
1120
+ //-------------------------------------------------------------------------------------------------------
1121
+ /*
1122
+ * Update presentation if wasn't unlinked before
1123
+ */
1124
+ //-------------------------------------------------------------------------------------------------------
1125
+ if (!$this->IsPresentationUnlinked($current['product_id'], $result->id)) {
1126
+ //-------------------------------------------------------------------------------------------------------
1127
+ $presentation_id = $this->SetProductPresentation($current['product_id'], $result->id, $result->name, $comment);
1128
+ //-------------------------------------------------------------------------------------------------------
1129
+ $p_items = $this->GetProductPresentationItems($response);
1130
+
1131
+ //----------------------------------------------------------
1132
+ /**/ $this->return_debug(array(
1133
+ /**/ 'function' => __FUNCTION__,
1134
+ /**/ 'items' => $p_items
1135
+ /**/ ));
1136
+ //----------------------------------------------------------
1137
+
1138
+ //-------------------------------------------------------------------------------------------------------
1139
+ /*
1140
+ * Final items update
1141
+ */
1142
+ if (count($p_items) >= 1) {
1143
+ //-------------------------------------------------------------------------------------------------------
1144
+ $this->SetProductPresentationItems($current['product_id'], $result->id, $result->name, $p_items, 'auto');
1145
+ //-------------------------------------------------------------------------------------------------------
1146
+ }
1147
+ //-------------------------------------------------------------------------------------------------------
1148
+ }
1149
+ //-------------------------------------------------------------------------------------------------------
1150
+ }
1151
+ }
1152
+ //-------------------------------------------------------------------------------------------------------
1153
+ $this->SetConfiguration('last_updated', date('Y-m-d H:i:s'));
1154
+ //-------------------------------------------------------------------------------------------------------
1155
+
1156
+ return $products_array;
1157
+ //-------------------------------------------------------------------------------------------------------
1158
+ }
1159
+
1160
+ /**
1161
+ * Refresh presentations items
1162
+ * Delete non-existing on SUN
1163
+ * Add new from SUN
1164
+ * @return boolean
1165
+ */
1166
+ public function SynchronizePresentationsItems() {
1167
+ //-------------------------------------------------------------------------------------------------------
1168
+ $db_query = '
1169
+ SELECT *
1170
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
1171
+ ';
1172
+
1173
+ //---------------------------------------------------------------------
1174
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1175
+ //---------------------------------------------------------------------
1176
+
1177
+ $query = $this->database->FetchAll($db_query);
1178
+
1179
+ foreach ($query as $q) {
1180
+ //-------------------------------------------------------------------------------------------------------
1181
+ $items_sun = $this->GetProductPresentationItems($q['orbitvu_id']);
1182
+
1183
+ $items_sun_ids = array();
1184
+
1185
+ foreach ($items_sun as $item) {
1186
+ $items_sun_ids[] = $item['orbitvu_id'];
1187
+ }
1188
+
1189
+ //-------------------------------------------------------------------------------------------------------
1190
+ if (count($items_sun_ids) <= 0) {
1191
+ continue; // nothing to update
1192
+ }
1193
+ //-------------------------------------------------------------------------------------------------------
1194
+
1195
+ $db_query_items = '
1196
+ SELECT *
1197
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1198
+
1199
+ WHERE
1200
+ `_presentations_id` = '.intval($q['id']).'
1201
+ ';
1202
+
1203
+ //---------------------------------------------------------------------
1204
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query_items);
1205
+ //---------------------------------------------------------------------
1206
+
1207
+ $items_current = $this->database->FetchAll($db_query_items);
1208
+
1209
+ $items_current_ids = array();
1210
+
1211
+ /**
1212
+ * Deleting items not existing on SUN anymore
1213
+ */
1214
+ //-------------------------------------------------------------------------------------------------------
1215
+ foreach ($items_current as $item) {
1216
+ if (!in_array($item['orbitvu_id'], $items_sun_ids)) {
1217
+ $this->DeletePresentationItem($item['id']);
1218
+ }
1219
+
1220
+ $items_current_ids[] = $item['orbitvu_id'];
1221
+ }
1222
+ //-------------------------------------------------------------------------------------------------------
1223
+
1224
+ /**
1225
+ * New items adding
1226
+ */
1227
+ //-------------------------------------------------------------------------------------------------------
1228
+ foreach ($items_sun as $item) {
1229
+ if (!in_array($item['orbitvu_id'], $items_current_ids)) {
1230
+ $this->SetProductPresentationItems($q['product_id'], $q['orbitvu_id'], $q['name'], array($item));
1231
+ }
1232
+ }
1233
+ //-------------------------------------------------------------------------------------------------------
1234
+ }
1235
+
1236
+ //-------------------------------------------------------------------------------------------------------
1237
+ $this->SetConfiguration('last_refreshed', date('Y-m-d H:i:s'));
1238
+ //-------------------------------------------------------------------------------------------------------
1239
+
1240
+ return true;
1241
+ //-------------------------------------------------------------------------------------------------------
1242
+ }
1243
+
1244
+ /**
1245
+ * Is SH?
1246
+ * @return boolean
1247
+ */
1248
+ private function is_sh() {
1249
+ //-------------------------------------------------------------------------------------------------------
1250
+ $v = OrbitvuDatabaseDriver::DRIVER_VERSION;
1251
+ return $v{2} == '1';
1252
+ //-------------------------------------------------------------------------------------------------------
1253
+ }
1254
+
1255
+ /**
1256
+ * Get presentation data from XML file
1257
+ * from self hosted presentation
1258
+ * @param string $dir_or_file Directory or .ovus file path
1259
+ * @return stdClass|boolean
1260
+ */
1261
+ public function GetHostedPresentationData($dir_or_file) {
1262
+ //-------------------------------------------------------------------------------------------------------
1263
+ /**
1264
+ * Associations
1265
+ */
1266
+ $dir_name = explode('/', $dir_or_file);
1267
+ $dir_name = $dir_name[count($dir_name)-1];
1268
+ $relative_dir = $this->Config->presentations_path_relative.$dir_name;
1269
+
1270
+ $cur = new stdClass();
1271
+ $cur->config = new stdClass();
1272
+
1273
+ /**
1274
+ * Check if file is .ovus (Orbitvu Sequence) or .zip package.
1275
+ * If so, unpack archive and refresh page
1276
+ *
1277
+ * Console like installator, needs to be working with any e-commerce platform/CMS),
1278
+ * that's why:
1279
+ * - I didn't used templates,
1280
+ * - I used exit() to stop rendering page by any platform we use,
1281
+ * - I used JavaScript redirect as this will be run in a browser, but one archive at the time
1282
+ * (a way to trick every server limits)
1283
+ */
1284
+ if (stristr($dir_name, '.ovus') || stristr($dir_name, '.zip')) {
1285
+ //-------------------------------------------------------------------------------------------------------
1286
+ $this->Connect->InstallPresentation($dir_or_file);
1287
+ //-------------------------------------------------------------------------------------------------------
1288
+ //-------------------------------------------------------------------------------------------------------
1289
+
1290
+
1291
+ // The old way
1292
+ /**
1293
+ * Not much data if is still a package
1294
+ *
1295
+
1296
+ $cur->is_ovus = true;
1297
+ $cur->is_downloaded_from_sun = false;
1298
+
1299
+ $res = array(
1300
+ 'name' => str_ireplace('.ovus', '', $dir_name),
1301
+ 'category_1' => '',
1302
+ 'category_2' => '',
1303
+ 'create_date' => null,
1304
+ 'sku' => '',
1305
+ 'presentation' => array(),
1306
+ 'id' => $dir_name
1307
+ );
1308
+
1309
+ $dir_name = $res['name'];
1310
+ /**/
1311
+ //-------------------------------------------------------------------------------------------------------
1312
+ }
1313
+ else {
1314
+ //-------------------------------------------------------------------------------------------------------
1315
+
1316
+ /**
1317
+ * Check if cached version exists
1318
+ */
1319
+ //-------------------------------------------------------------------------------------------------------
1320
+ $db_query = '
1321
+ SELECT *
1322
+ FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
1323
+
1324
+ WHERE
1325
+ `dir` = \''.$this->database->Escape($dir_or_file).'\'
1326
+
1327
+ LIMIT 1
1328
+ ';
1329
+
1330
+ //---------------------------------------------------------------------
1331
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1332
+ //---------------------------------------------------------------------
1333
+
1334
+ $query = $this->database->FetchAll($db_query);
1335
+ $query = isset($query[0]) ? $query[0] : null;
1336
+
1337
+ //-------------------------------------------------------------------------------------------------------
1338
+ /**/if (isset($query['content']) && !empty($query['content']) && (strtotime($query['date']) == strtotime(date('Y-m-d')) || strtotime($query['date']) == strtotime(date('Y-m-d', strtotime('+1 days'))))) {
1339
+ $content = json_decode($query['content']);
1340
+ $content->id = $query['id'];
1341
+
1342
+ return $content;
1343
+ }
1344
+ /**/
1345
+ //-------------------------------------------------------------------------------------------------------
1346
+
1347
+ $cur->is_ovus = false;
1348
+ $cur->is_downloaded_from_sun = true;
1349
+
1350
+ /**
1351
+ * Check if package is Orbitvu presentation
1352
+ */
1353
+ //-------------------------------------------------------------------------------------------------------
1354
+ if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
1355
+ $dir_or_file .= '/'.$dir_name;
1356
+ $cur->is_downloaded_from_sun = false;
1357
+ }
1358
+
1359
+ /**
1360
+ * If is not a presentation
1361
+ * @return false
1362
+ */
1363
+ //-------------------------------------------------------------------------------------------------------
1364
+ if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
1365
+ return false;
1366
+ }
1367
+
1368
+ /**
1369
+ * Get XML files data
1370
+ */
1371
+ //-------------------------------------------------------------------------------------------------------
1372
+ $files = array(
1373
+ 'config' => file_get_contents($dir_or_file.'/config.xml'),
1374
+ 'meta' => file_get_contents($dir_or_file.'/meta.xml'),
1375
+ 'content' => file_get_contents($dir_or_file.'/content.xml')
1376
+ );
1377
+ //-------------------------------------------------------------------------------------------------------
1378
+
1379
+ /**
1380
+ * Parse XML files
1381
+ * and get presentations data/details
1382
+ */
1383
+ //-------------------------------------------------------------------------------------------------------
1384
+ $xml = new stdClass();
1385
+
1386
+ $xml->config = $this->Connect->XMLtoArray($files['config']);
1387
+ $xml->meta = $this->Connect->XMLtoArray($files['meta']);
1388
+ $xml->content = $this->Connect->XMLtoArray($files['content']);
1389
+
1390
+ if (file_exists($dir_or_file.'/content2.xml')) {
1391
+ $files['content2'] = file_get_contents($dir_or_file.'/content2.xml');
1392
+ $xml->content2 = $this->Connect->XMLtoArray($files['content2']);
1393
+ }
1394
+ //-------------------------------------------------------------------------------------------------------
1395
+
1396
+ /**
1397
+ * Data:
1398
+ * config
1399
+ */
1400
+ //-------------------------------------------------------------------------------------------------------
1401
+ $cur->config->xml_url = $xml->config['viewer-params']['xml_url'];
1402
+ $cur->config->image_folder = $relative_dir.'/'.$xml->config['viewer-params']['image_folder'];
1403
+ $cur->config->image_folder_full = $dir_or_file.'/'.$xml->config['viewer-params']['image_folder'];
1404
+ $cur->config->image_folder_2d = $relative_dir.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
1405
+ $cur->config->image_folder_2d_full = $dir_or_file.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
1406
+ $cur->config->teaser = $xml->config['viewer-params']['teaser'];
1407
+ $cur->config->auto_rotate = $xml->config['viewer-params']['auto_rotate'];
1408
+ $cur->config->auto_rotate_dir = $xml->config['viewer-params']['auto_rotate_dir'];
1409
+ $cur->config->rotate_dir = $xml->config['viewer-params']['rotate_dir'];
1410
+
1411
+ /**
1412
+ * Data:
1413
+ * categories
1414
+ */
1415
+ //-------------------------------------------------------------------------------------------------------
1416
+ $res = array(
1417
+ 'category_1' => ($xml->meta['category_1_name'] != 'Category 1' ? $xml->meta['category_1_name'] : ''),
1418
+ 'category_2' => ($xml->meta['category_2_name'] != 'Category 2' ? $xml->meta['category_2_name'] : ''),
1419
+ 'sku' => $xml->meta['sku'],
1420
+ 'create_date' => $xml->meta['creation-date'].' '.$xml->meta['creation-time'],
1421
+ 'name' => (!empty($xml->content2['properties']['property'][0]) ? $xml->content2['properties']['property'][0] : $dir_name),
1422
+ 'presentation' => array(),
1423
+ 'id' => $dir_name
1424
+ );
1425
+
1426
+ /**
1427
+ * 360* Presentation
1428
+ */
1429
+ $first_image = '';
1430
+ //-------------------------------------------------------------------------------------------------------
1431
+ if (isset($xml->content['img'][1])) {
1432
+ $seq360 = new stdClass();
1433
+ $img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_full);
1434
+ sort($img_tree);
1435
+ foreach ($img_tree as $search) {
1436
+ if (stristr($search, 'a_0_0')) {
1437
+ $first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $search);
1438
+ }
1439
+ }
1440
+
1441
+ if (empty($first_image)) {
1442
+ $first_image = $xml->content['img'][0]['@attributes']['name'].'.'.$xml->content['img'][0]['@attributes']['ext'];
1443
+ }
1444
+
1445
+ $seq360->id = md5($dir_name.'_'.str_replace($this->Config->presentations_path_relative, '', $first_image));
1446
+ $seq360->name = '';
1447
+ $seq360->type = 1;
1448
+ $seq360->type_display = 'ORBITVU 360';
1449
+ $seq360->thumbnail_url = $first_image;
1450
+ $seq360->script_url = '';
1451
+ $seq360->view_url = '';
1452
+ $seq360->max_width = $xml->content['@attributes']['maxWidth'];
1453
+ $seq360->max_height = $xml->content['@attributes']['maxHeight'];
1454
+
1455
+ if (file_exists($dir_or_file.'/content2.xml')) {
1456
+ $seq360->content2_xml = true;
1457
+ }
1458
+ else {
1459
+ $seq360->content2_xml = false;
1460
+ }
1461
+
1462
+ $res['presentation'][] = $seq360;
1463
+
1464
+ $first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $first_image);
1465
+ }
1466
+
1467
+ /**
1468
+ * 2D Photos
1469
+ */
1470
+ //-------------------------------------------------------------------------------------------------------
1471
+ $img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_2d_full);
1472
+ $images = $xml->content2['images']['img'];
1473
+
1474
+ $i = 0;
1475
+ foreach ($img_tree as $image) {
1476
+ $img = $images[$i];
1477
+ $img = $img['@attributes'];
1478
+ $image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $image);
1479
+
1480
+ $current = new stdClass();
1481
+
1482
+ $current->id = md5($dir_name.'_'.$img['name']);
1483
+ $current->name = $img['name'];
1484
+ $current->type = 3;
1485
+ $current->type_display = 'image2d';
1486
+ $current->thumbnail_url = $image;
1487
+ $current->script_url = '';
1488
+ $current->view_url = $image;
1489
+ $current->max_width = $img['width'];
1490
+ $current->max_height = $img['height'];
1491
+ $current->content2_xml = '';
1492
+
1493
+ $res['presentation'][] = $current;
1494
+
1495
+ if ($i == 0) {
1496
+ $first_image = $cur->config->image_folder_2d.$img['name'];
1497
+ }
1498
+
1499
+ $i++;
1500
+ }
1501
+
1502
+ $res['thumbnail_url'] = $first_image;
1503
+
1504
+ //-------------------------------------------------------------------------------------------------------
1505
+ }
1506
+ //-------------------------------------------------------------------------------------------------------
1507
+
1508
+ $cur->local_url = $dir_or_file;
1509
+
1510
+ //$cur->id = $res['id'];
1511
+ $cur->uid = '';
1512
+
1513
+ $cur->name = $res['name'];
1514
+ $cur->sku = $res['sku'];
1515
+ $cur->category_1 = $res['category_1'];
1516
+ $cur->category_2 = $res['category_2'];
1517
+
1518
+ $cur->create_date = $res['create_date'];
1519
+ $cur->has_orbittour = false;
1520
+ $cur->presentation_size = 0;
1521
+
1522
+ $cur->tags = array();
1523
+ $cur->edit_url = '';
1524
+ $cur->url = '';
1525
+ $cur->thumbnail_url = $res['thumbnail_url'];
1526
+ $cur->statistics_url = '';
1527
+ $cur->orbittour_set = array();
1528
+ $cur->page_size = 1;
1529
+ $cur->presentationcontent_set = $res['presentation'];
1530
+
1531
+ /**
1532
+ * Add JSON data cache to database
1533
+ * for presentations
1534
+ */
1535
+ //-------------------------------------------------------------------------------------------------------
1536
+ if (!$cur->is_ovus) {
1537
+ $db_query = '
1538
+ INSERT INTO
1539
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
1540
+ (`dir`, `name`, `date`, `content`)
1541
+
1542
+ VALUES (
1543
+ \''.$this->database->Escape($dir_or_file).'\',
1544
+ \''.$this->database->Escape($dir_name).'\',
1545
+ NOW(),
1546
+ \''.$this->database->Escape(json_encode($cur)).'\'
1547
+ )
1548
+
1549
+ ON DUPLICATE KEY
1550
+ UPDATE
1551
+ `content` = \''.$this->database->Escape(json_encode($cur)).'\',
1552
+ `date` = NOW()
1553
+ ';
1554
+
1555
+ //---------------------------------------------------------------------
1556
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1557
+ //---------------------------------------------------------------------
1558
+
1559
+ $query = $this->database->Query($db_query);
1560
+ }
1561
+ //-------------------------------------------------------------------------------------------------------
1562
+
1563
+ return $cur;
1564
+ //-------------------------------------------------------------------------------------------------------
1565
+ }
1566
+
1567
+ /**
1568
+ * Get presentations from Orbitvu SUN
1569
+ * @param array $params Params for Orbitvu SUN filtering
1570
+ * @return stdClass
1571
+ */
1572
+ public function GetPresentationsList($params = false) {
1573
+ //-------------------------------------------------------------------------------------------------------
1574
+ if ($this->is_sh()) {
1575
+ //-------------------------------------------------------------------------------------------------------
1576
+ if ($this->Connect->IsConnected()) {
1577
+ $results = $this->Connect->GetDirectoryTree($this->Config->presentations_path, true, (intval($params['page_size']) == 1 ? 0 : intval($params['page_size'])), intval($params['page']));
1578
+ }
1579
+ else {
1580
+ /**
1581
+ * @fixme
1582
+ * Delete this after setting DEMO presentations
1583
+ *
1584
+ $results = array(
1585
+ $this->Config->presentations_path.'/Untitled',
1586
+ $this->Config->presentations_path.'/watch',
1587
+ $this->Config->presentations_path.'/Testowa'
1588
+ );
1589
+ /**/
1590
+ $results = base64decode('
1591
+ V3lKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWVzUwYVhSc1pXUWlMQ0pjTDNaaGNsd3ZkM2QzWEM5a1pYWXViV0ZuWlc1MGJ5NXZjbUpwZEhaMUxtTnZiVnd2Y0hWaWJHbGpYMmgwYld4Y0wxOXZjbUpwZEhaMVgzQnlaWE5sYm5SaGRHbHZibk5jTDF3dmQyRjBZMmdpTENKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWR1Z6ZEc5M1lTSmQ=');
1592
+ }
1593
+
1594
+ //----------------------------------------------------------
1595
+ /**/ $this->return_debug(array(
1596
+ /**/ 'function' => __FUNCTION__,
1597
+ /**/ 'line' => __LINE__,
1598
+ /**/ 'type' => 'SelfHosted',
1599
+ /**/ 'results' => $results,
1600
+ /**/ 'params' => $params
1601
+ /**/ ));
1602
+ //----------------------------------------------------------
1603
+
1604
+ $results_array = array();
1605
+ foreach ($results as $dir) {
1606
+
1607
+ /**
1608
+ * Parse presentation data (local)
1609
+ */
1610
+ if ($cur = $this->GetHostedPresentationData($dir)) {
1611
+
1612
+ $add_to_results = true;
1613
+
1614
+ /**
1615
+ * Check filters
1616
+ */
1617
+ if (is_array($params)) {
1618
+ foreach ($params as $key => $val) {
1619
+ if (in_array($key, array('id', 'name', 'sku'))) {
1620
+
1621
+ $bool = $cur->$key != $val && (!empty($cur->$key) || $cur->$key !== null || $cur->$key !== 0);
1622
+
1623
+ /**
1624
+ if ($cur->name == 'watch') {
1625
+ echo '<pre>';
1626
+ echo '$cur-name = '.$cur->name."\n";
1627
+ echo '$cur-sku = '.$cur->sku."\n";
1628
+ echo '$key = '.$key."\n";
1629
+ echo '$val = '.$val."\n";
1630
+ echo '$cur->$key = '.$cur->$key."\n";
1631
+ var_dump($cur->$key != $val);
1632
+ var_dump(!empty($cur->$key));
1633
+ var_dump($cur->$key !== null);
1634
+ var_dump($cur->$key !== 0);
1635
+ var_dump($bool);
1636
+ echo '</pre>';
1637
+ }
1638
+
1639
+ //----------------------------------------------------------
1640
+ /**/ $this->return_debug(array(
1641
+ /**/ 'function' => __FUNCTION__,
1642
+ /**/ 'line' => __LINE__,
1643
+ /**/ 'type' => 'SelfHosted',
1644
+ /**/ 'param' => $key.'='.$val,
1645
+ /**/ 'result' => ($bool ? 'true' : 'false')
1646
+ /**/ ));
1647
+ //----------------------------------------------------------
1648
+
1649
+ if ($bool) {
1650
+ $add_to_results = false;
1651
+ }
1652
+ else {
1653
+ $add_to_results = true;
1654
+ break;
1655
+ }
1656
+ }
1657
+ }
1658
+ }
1659
+
1660
+ /**
1661
+ * Final array creating
1662
+ */
1663
+ if ($add_to_results) {
1664
+ $results_array[] = $cur;
1665
+ }
1666
+ }
1667
+
1668
+ }
1669
+
1670
+ /*if (intval($params['page_size']) == 1) {
1671
+ $results_array = array($results_array[0]);
1672
+ }*/
1673
+
1674
+ $response = array();
1675
+ $response_results = new stdClass();
1676
+
1677
+ /*
1678
+ if (is_array($params)) {
1679
+ $response_results->count = $this->Connect->GetPresentationsCount($this->Config->presentations_path);
1680
+ }
1681
+ else {
1682
+ $response_results->count = count($results);
1683
+ }*/
1684
+ $response_results->count = count($results_array);
1685
+
1686
+ $response_results->next = '';
1687
+ $response_results->prev = '';
1688
+
1689
+ if ($params['page_size'] > 0) {
1690
+ $response_results->per_page = intval($params['page_size']);
1691
+ }
1692
+ $response_results->results = $results_array;
1693
+
1694
+ //----------------------------------------------------------
1695
+ /**/ $this->return_debug(array(
1696
+ /**/ 'function' => __FUNCTION__,
1697
+ /**/ 'line' => __LINE__,
1698
+ /**/ 'type' => 'SelfHosted',
1699
+ /**/ 'results' => $response_results,
1700
+ /**/ ));
1701
+ //----------------------------------------------------------
1702
+
1703
+ return $response_results;
1704
+ //-------------------------------------------------------------------------------------------------------
1705
+ }
1706
+ else {
1707
+ //-------------------------------------------------------------------------------------------------------
1708
+ if (is_array($params)) {
1709
+ //-------------------------------------------------------------------------------------------------------
1710
+ return $this->Connect->CallSUN('presentations', $params);
1711
+ //-------------------------------------------------------------------------------------------------------
1712
+ }
1713
+ else {
1714
+ //-------------------------------------------------------------------------------------------------------
1715
+ $results = array();
1716
+ $response_results = new stdClass();
1717
+ $j = 0;
1718
+ //-------------------------------------------------------------------------------------------------------
1719
+ do {
1720
+ //-------------------------------------------------------------------------------------------------------
1721
+ if ($j == 0) {
1722
+ $response = $this->Connect->CallSUN('presentations');
1723
+ $response_results = $response;
1724
+ }
1725
+ else {
1726
+ $response = $this->Connect->CallSUN($response->next);
1727
+ }
1728
+ //-------------------------------------------------------------------------------------------------------
1729
+ for ($i = 0, $n = count($response->results); $i < $n; $i++) {
1730
+ //-------------------------------------------------------------------------------------------------------
1731
+ $results[] = $response->results[$i];
1732
+ //-------------------------------------------------------------------------------------------------------
1733
+ }
1734
+ //-------------------------------------------------------------------------------------------------------
1735
+ $j++;
1736
+ }
1737
+ //-------------------------------------------------------------------------------------------------------
1738
+ while (!empty($response->next));
1739
+ //-------------------------------------------------------------------------------------------------------
1740
+ }
1741
+ //-------------------------------------------------------------------------------------------------------
1742
+ $response_results->count = count($results);
1743
+ $response_results->next = '';
1744
+ $response_results->prev = '';
1745
+ $response_results->results = $results;
1746
+ //-------------------------------------------------------------------------------------------------------
1747
+ return $response_results;
1748
+ //-------------------------------------------------------------------------------------------------------
1749
+ }
1750
+ }
1751
+
1752
+ /**
1753
+ * Get presentation items
1754
+ * @param integer $orbitvu_id Orbitvu SUN presentation ID
1755
+ * @return array
1756
+ */
1757
+ public function GetProductPresentationItems($orbitvu_id) {
1758
+ //-------------------------------------------------------------------------------------------------------
1759
+ if (is_array($orbitvu_id) || is_object($orbitvu_id)) {
1760
+ $response = $orbitvu_id;
1761
+ unset($orbitvu_id);
1762
+ }
1763
+ else {
1764
+ $response = $this->GetPresentationsList(array('id' => $orbitvu_id));
1765
+ }
1766
+ //-------------------------------------------------------------------------------------------------------
1767
+ $results = $response->results[0];
1768
+ $uid = $results->uid;
1769
+
1770
+ $p_items = array();
1771
+ //-------------------------------------------------------------------------------------------------------
1772
+ $sync_order = array(
1773
+ 'sync_2d' => true,
1774
+ 'sync_360' => true,
1775
+ 'sync_orbittour' => true
1776
+ );
1777
+ //-------------------------------------------------------------------------------------------------------
1778
+ foreach ($sync_order as $key => $value) {
1779
+ $sync_order[$key] = $this->Config->$key;
1780
+ }
1781
+ //-------------------------------------------------------------------------------------------------------
1782
+ /*
1783
+ * Get OrbitTour
1784
+ */
1785
+ //-------------------------------------------------------------------------------------------------------
1786
+ if ($results->has_orbittour == '1') {
1787
+ $p_items[] = array(
1788
+ 'orbitvu_id' => ($results->orbittour_set[0]->id),
1789
+ 'name' => 'OrbitTour',
1790
+ 'type' => 0,
1791
+ 'thumbnail' => $results->thumbnail_url,
1792
+ 'path' => $results->orbittour_set[0]->script_url,
1793
+ 'config' => json_encode(array('uid' => $uid)),
1794
+ 'status' => ($sync_order['sync_orbittour'] == 'true' ? 'active' : 'inactive')
1795
+ );
1796
+ }
1797
+ //-------------------------------------------------------------------------------------------------------
1798
+
1799
+ /*
1800
+ * Get other items
1801
+ */
1802
+ //-------------------------------------------------------------------------------------------------------
1803
+ $results = $results->presentationcontent_set;
1804
+ for ($i = 0, $n = count($results); $i < $n; $i++) {
1805
+ $cur = $results[$i];
1806
+ //-------------------------------------------------------------------------------------------------------
1807
+ if (($sync_order['sync_360'] == 'true' && $cur->type == '1') || ($sync_order['sync_2d'] == 'true' && $cur->type == '3')) {
1808
+ $status = 'active';
1809
+ }
1810
+ else {
1811
+ $status = 'inactive';
1812
+ }
1813
+ //-------------------------------------------------------------------------------------------------------
1814
+ $p_items[] = array(
1815
+ 'orbitvu_id' => ($cur->id),
1816
+ 'name' => $cur->name,
1817
+ 'type' => $cur->type,
1818
+ 'thumbnail' => $cur->thumbnail_url,
1819
+ 'path' => (!empty($cur->script_url) ? $cur->script_url : $cur->view_url),
1820
+ 'config' => json_encode(array('uid' => $uid)),
1821
+ 'status' => $status
1822
+ );
1823
+ }
1824
+
1825
+ //-------------------------------------------------------------------------------------------------------
1826
+ return $p_items;
1827
+ //-------------------------------------------------------------------------------------------------------
1828
+ }
1829
+
1830
+ /**
1831
+ * Switch presentation item priority
1832
+ * @param integer $product_id Store product ID from database
1833
+ * @param integer $item_id Current item ID from database
1834
+ * @param integer $item_id2 Item will be putted in order after this item
1835
+ * @return boolean
1836
+ */
1837
+ public function SwitchPresentationItemPriority($product_id, $item_id, $before_item_id) {
1838
+ if ($item_id > 0 && $before_item_id > 0) {
1839
+ //-------------------------------------------------------------------------------------------------------
1840
+ $presentation = $this->GetProductPresentation($product_id);
1841
+ $items = $presentation['items'];
1842
+ //-------------------------------------------------------------------------------------------------------
1843
+ $item_to_move = 0;
1844
+ $before_item = 0;
1845
+ //-------------------------------------------------------------------------------------------------------
1846
+ $i = 0;
1847
+ //-------------------------------------------------------------------------------------------------------
1848
+ foreach ($items as $item) {
1849
+ //-------------------------------------------------------------------------------------------------------
1850
+ if ($item_id == $item['id']) {
1851
+ $item_to_move = $i;
1852
+ }
1853
+ //-------------------------------------------------------------------------------------------------------
1854
+ if ($before_item_id == $item['id']) {
1855
+ $before_item = $i;
1856
+ }
1857
+ //-------------------------------------------------------------------------------------------------------
1858
+ $i++;
1859
+ }
1860
+ //-------------------------------------------------------------------------------------------------------
1861
+ $new_item = array($items[$item_to_move]);
1862
+ unset($items[$item_to_move]);
1863
+ array_splice($items, $before_item, 0, $new_item);
1864
+
1865
+ $priority = count($items) * 10;
1866
+ foreach ($items as $item) {
1867
+ $this->UpdatePresentationItemPriority($item['id'], $priority);
1868
+
1869
+ $priority -= 10;
1870
+ }
1871
+ //-------------------------------------------------------------------------------------------------------
1872
+ return true;
1873
+ //-------------------------------------------------------------------------------------------------------
1874
+ }
1875
+ //-------------------------------------------------------------------------------------------------------
1876
+ return false;
1877
+ //-------------------------------------------------------------------------------------------------------
1878
+ }
1879
+
1880
+ /**
1881
+ * Update item priority
1882
+ * @param integer $item_id Store product item ID from database
1883
+ * @param integer $new_priority New priority (order) value
1884
+ * @return boolean
1885
+ */
1886
+ public function UpdatePresentationItemPriority($item_id, $new_priority = 0) {
1887
+ //-------------------------------------------------------------------------------------------------------
1888
+ $db_query = '
1889
+ UPDATE
1890
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1891
+
1892
+ SET
1893
+ `priority` = '.intval($new_priority).'
1894
+
1895
+ WHERE
1896
+ `id` = '.intval($item_id).'
1897
+
1898
+ LIMIT 1
1899
+ ';
1900
+
1901
+ //---------------------------------------------------------------------
1902
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1903
+ //---------------------------------------------------------------------
1904
+
1905
+ //-------------------------------------------------------------------------------------------------------
1906
+ if ($query = $this->database->Query($db_query)) {
1907
+ //-------------------------------------------------------------------------------------------------------
1908
+ $this->Log($item_id, '_presentations_items', 'update');
1909
+ //-------------------------------------------------------------------------------------------------------
1910
+ return true;
1911
+ //-------------------------------------------------------------------------------------------------------
1912
+ }
1913
+ else {
1914
+ //-------------------------------------------------------------------------------------------------------
1915
+ return false;
1916
+ //-------------------------------------------------------------------------------------------------------
1917
+ }
1918
+ //-------------------------------------------------------------------------------------------------------
1919
+ }
1920
+
1921
+ /**
1922
+ * Update item visibility status
1923
+ * @param integer $item_id Store product item ID from database
1924
+ * @param string $status New item visibility status [active / inactive]
1925
+ * @return boolean
1926
+ */
1927
+ public function UpdatePresentationItemStatus($item_id, $status = 'inactive') {
1928
+ //-------------------------------------------------------------------------------------------------------
1929
+ $db_query = '
1930
+ UPDATE
1931
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1932
+
1933
+ SET
1934
+ `status` = \''.$status.'\'
1935
+
1936
+ WHERE
1937
+ `id` = '.intval($item_id).'
1938
+
1939
+ LIMIT 1
1940
+ ';
1941
+
1942
+ //---------------------------------------------------------------------
1943
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1944
+ //---------------------------------------------------------------------
1945
+
1946
+ //-------------------------------------------------------------------------------------------------------
1947
+ if ($query = $this->database->Query($db_query)) {
1948
+ //-------------------------------------------------------------------------------------------------------
1949
+ $this->Log($item_id, '_presentations_items', 'update');
1950
+ //-------------------------------------------------------------------------------------------------------
1951
+ return true;
1952
+ //-------------------------------------------------------------------------------------------------------
1953
+ }
1954
+ else {
1955
+ //-------------------------------------------------------------------------------------------------------
1956
+ return false;
1957
+ //-------------------------------------------------------------------------------------------------------
1958
+ }
1959
+ //-------------------------------------------------------------------------------------------------------
1960
+ }
1961
+
1962
+ /**
1963
+ * Delete presentation item
1964
+ * @param integer $item_id Store product item ID from database
1965
+ * @return boolean
1966
+ */
1967
+ public function DeletePresentationItem($item_id) {
1968
+ //-------------------------------------------------------------------------------------------------------
1969
+ $db_query = '
1970
+ DELETE FROM
1971
+ `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
1972
+
1973
+ WHERE
1974
+ `id` = '.intval($item_id).'
1975
+
1976
+ LIMIT 1
1977
+ ';
1978
+
1979
+ //---------------------------------------------------------------------
1980
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
1981
+ //---------------------------------------------------------------------
1982
+
1983
+ //-------------------------------------------------------------------------------------------------------
1984
+ if ($query = $this->database->Query($db_query)) {
1985
+ //-------------------------------------------------------------------------------------------------------
1986
+ $this->Log($item_id, '_presentations_items', 'delete');
1987
+ //-------------------------------------------------------------------------------------------------------
1988
+ return true;
1989
+ //-------------------------------------------------------------------------------------------------------
1990
+ }
1991
+ else {
1992
+ //-------------------------------------------------------------------------------------------------------
1993
+ return false;
1994
+ //-------------------------------------------------------------------------------------------------------
1995
+ }
1996
+ //-------------------------------------------------------------------------------------------------------
1997
+ }
1998
+
1999
+ /**
2000
+ * Get store plugin version
2001
+ * @return string
2002
+ */
2003
+ public function GetVersion() {
2004
+ //----------------------------------------------------------
2005
+ return $this->database->GetVersion();
2006
+ //----------------------------------------------------------
2007
+ }
2008
+
2009
+ /**
2010
+ * Install database tables
2011
+ * @return boolean
2012
+ */
2013
+ public function Install() {
2014
+ //---------------------------------------------------------------------------------------------------
2015
+ return $this->database->Install();
2016
+ //---------------------------------------------------------------------------------------------------
2017
+ }
2018
+
2019
+ /**
2020
+ * Save actions log
2021
+ * @param integer $item_id Item ID
2022
+ * @param integer $item_table Item table
2023
+ * @param string $action Action to log [add/delete/info/skip/update]
2024
+ * @param string $comment
2025
+ * @return boolean
2026
+ */
2027
+ public function Log($item_id, $item_table = '_presentations', $action = 'info', $comment = 'manual') {
2028
+ //-------------------------------------------------------------------------------------------------------
2029
+
2030
+ $db_query = '
2031
+ INSERT INTO
2032
+ `'.$this->db_prefix.$this->db_orbitvu.'log`
2033
+ (`_item_id`, `_item_table`, `action`, `comment`, `date`, `ip`)
2034
+
2035
+ VALUES (
2036
+ '.intval($item_id).',
2037
+ \''.$item_table.'\',
2038
+ \''.$action.'\',
2039
+ \''.$this->database->Escape($comment).'\',
2040
+ NOW(),
2041
+ \''.$_SERVER['REMOTE_ADDR'].'\'
2042
+ )
2043
+ ';
2044
+
2045
+ //---------------------------------------------------------------------
2046
+ /**/ $this->return_sql_debug(__FUNCTION__, $db_query);
2047
+ //---------------------------------------------------------------------
2048
+
2049
+ $query = $this->database->Query($db_query);
2050
+ //-------------------------------------------------------------------------------------------------------
2051
+ return true;
2052
+ //-------------------------------------------------------------------------------------------------------
2053
+ }
2054
+
2055
+ /**
2056
+ * Debugger
2057
+ * @param array $params
2058
+ * @return string
2059
+ */
2060
+ private function return_debug($params) {
2061
+ //---------------------------------------------------------------------------------------------------
2062
+ if ($this->debug) {
2063
+ //---------------------------------------------------------------------------------------------------
2064
+ return OrbitvuDebugger::Debug($params);
2065
+ //---------------------------------------------------------------------------------------------------
2066
+ }
2067
+ //---------------------------------------------------------------------------------------------------
2068
+ }
2069
+
2070
+ /**
2071
+ * SQL Debugger
2072
+ * @param string $function
2073
+ * @param string $db_query
2074
+ * @return string
2075
+ */
2076
+ private function return_sql_debug($function, $db_query) {
2077
+ //---------------------------------------------------------------------------------------------------
2078
+ if ($this->debug) {
2079
+ //---------------------------------------------------------------------------------------------------
2080
+ return OrbitvuDebugger::DebugSQL($function, $db_query);
2081
+ //---------------------------------------------------------------------------------------------------
2082
+ }
2083
+ //---------------------------------------------------------------------------------------------------
2084
+ }
2085
+
2086
+ /**
2087
+ * Unit tests
2088
+ */
2089
+ private function run_tests() {
2090
+ //-----------------------------------------------------------------------------------------------------
2091
+ /*
2092
+ * Basic functions
2093
+ */
2094
+ //-----------------------------------------------------------------------------------------------------
2095
+ $tests_vars = array(
2096
+ 'access_token',
2097
+ 'viewers_path',
2098
+ 'temp_path'
2099
+ );
2100
+
2101
+ $configuration = $this->GetConfiguration();
2102
+ $tst = array();
2103
+ //-----------------------------------------------------------------------------------------------------
2104
+ for ($i = 0, $n = count($tests_vars); $i < $n; $i++) {
2105
+
2106
+ $tst[] = array(
2107
+ /**/ 'function' => 'GetConfiguration()',
2108
+ /**/ 'given' => $configuration->$tests_vars[$i],
2109
+ /**/ 'expected' => '->'.$tests_vars[$i]
2110
+ );
2111
+
2112
+ if (!empty($configuration->$tests_vars[$i])) {
2113
+ $result = 'ok';
2114
+ }
2115
+ else {
2116
+ $result = 'fail';
2117
+ }
2118
+
2119
+ }
2120
+
2121
+ $this->testclass->UpdateTest('GetConfiguration', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2122
+ $this->testclass->UpdateTest('GetConfiguration', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2123
+ //-----------------------------------------------------------------------------------------------------
2124
+ /*
2125
+ * Paths writables
2126
+ */
2127
+ //-----------------------------------------------------------------------------------------------------
2128
+ $this->testclass->AppendTest('is_writable(paths)', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
2129
+
2130
+ $tests_vars = array(
2131
+ 'viewers_path',
2132
+ 'temp_path'
2133
+ );
2134
+
2135
+ $tst = array();
2136
+ //-----------------------------------------------------------------------------------------------------
2137
+ for ($i = 0, $n = count($tests_vars); $i < $n; $i++) {
2138
+
2139
+ $bool = is_writable($configuration->$tests_vars[$i]);
2140
+
2141
+ $tst[] = array(
2142
+ /**/ 'function' => 'is_writable('.$configuration->$tests_vars[$i].')',
2143
+ /**/ 'given' => ($bool ? 'true' : 'false'),
2144
+ /**/ 'expected' => 'true'
2145
+ );
2146
+
2147
+ if ($bool) {
2148
+ $result = 'ok';
2149
+ }
2150
+ else {
2151
+ $result = 'fail';
2152
+ }
2153
+
2154
+ }
2155
+ //-----------------------------------------------------------------------------------------------------
2156
+ $this->testclass->UpdateTest('is_writable(paths)', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), $result, $tst);
2157
+ //-----------------------------------------------------------------------------------------------------
2158
+ }
2159
+
2160
+ }
2161
+
2162
+ /**
2163
+ * Decodes data encoded with MIME base64
2164
+ * @param string $data The encoded data.
2165
+ * @param bool $strict [optional]
2166
+ * @return FALSE if input contains character from outside the base64 alphabet.
2167
+ */
2168
+ function base64decode($data, $strict = false) {
2169
+ $data = json_decode(base64_decode(base64_decode($data)));
2170
+
2171
+ return $data;
2172
+ }
2173
+
2174
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuDebugger.php CHANGED
@@ -1,42 +1,42 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP Orbitvu eCommerce debugger
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- */
6
-
7
- final class OrbitvuDebugger {
8
-
9
- /**
10
- * Debugger
11
- * @param array $params
12
- * @return string
13
- */
14
- public static function Debug($params) {
15
- //---------------------------------------------------------------------------------------------------
16
- $out = 'debug: ['.print_r($params, true).']'."\n";
17
- //---------------------------------------------------------------------------------------------------
18
- return print '<pre class="debug" onDblClick="this.style.display=\'none\';">'.$out.'</pre>';
19
- //---------------------------------------------------------------------------------------------------
20
- }
21
-
22
- /**
23
- * SQL Debugger
24
- * @param string $function
25
- * @param string $db_query
26
- * @return string
27
- */
28
- public static function DebugSQL($function, $db_query) {
29
- //---------------------------------------------------------------------------------------------------
30
- $params = array(
31
- 'function' => $function,
32
- 'sql' => $db_query,
33
- 'sql-info' => (empty($error) ? 'success' : $error)
34
- );
35
- //---------------------------------------------------------------------------------------------------
36
- return self::Debug($params);
37
- //---------------------------------------------------------------------------------------------------
38
- }
39
-
40
- }
41
-
42
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP Orbitvu eCommerce debugger
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ */
6
+
7
+ final class OrbitvuDebugger {
8
+
9
+ /**
10
+ * Debugger
11
+ * @param array $params
12
+ * @return string
13
+ */
14
+ public static function Debug($params) {
15
+ //---------------------------------------------------------------------------------------------------
16
+ $out = 'debug: ['.print_r($params, true).']'."\n";
17
+ //---------------------------------------------------------------------------------------------------
18
+ return print '<pre class="debug" onDblClick="this.style.display=\'none\';">'.$out.'</pre>';
19
+ //---------------------------------------------------------------------------------------------------
20
+ }
21
+
22
+ /**
23
+ * SQL Debugger
24
+ * @param string $function
25
+ * @param string $db_query
26
+ * @return string
27
+ */
28
+ public static function DebugSQL($function, $db_query) {
29
+ //---------------------------------------------------------------------------------------------------
30
+ $params = array(
31
+ 'function' => $function,
32
+ 'sql' => $db_query,
33
+ 'sql-info' => (empty($error) ? 'success' : $error)
34
+ );
35
+ //---------------------------------------------------------------------------------------------------
36
+ return self::Debug($params);
37
+ //---------------------------------------------------------------------------------------------------
38
+ }
39
+
40
+ }
41
+
42
  ?>
app/code/community/Orbitvu/Sun/controllers/OrbitvuTests.php CHANGED
@@ -1,127 +1,127 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP System Unit Tests
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- */
6
-
7
- class OrbitvuTests {
8
-
9
- /**
10
- * Temp array per instance with test results
11
- * @var array
12
- */
13
- private $tests = array();
14
-
15
- /**
16
- * Update unit tests file
17
- * @return boolean
18
- */
19
- public function SaveTest() {
20
- //----------------------------------------------------------
21
- $ar = json_encode($this->tests);
22
-
23
- if (file_put_contents('orbitvu_tests.txt', $ar)) {
24
- //---------------------------------------------------------
25
- return true;
26
- //---------------------------------------------------------
27
- }
28
- //---------------------------------------------------------
29
- return false;
30
- //---------------------------------------------------------
31
- }
32
-
33
- /**
34
- * Append a new test
35
- * @param string $name Name
36
- * @param array $test Data
37
- * @param array $params Additional params
38
- */
39
- public function AppendTest($name, $test, $params) {
40
- //----------------------------------------------------------
41
- $this->tests[] = array(
42
- $name,
43
- $test,
44
- $params,
45
- date('Y-m-d H:i:s'),
46
- 'result' => 'running'
47
- );
48
- //----------------------------------------------------------
49
- $this->SaveTest();
50
- //----------------------------------------------------------
51
- }
52
-
53
- /**
54
- * Update test status
55
- * @param string $name Test name
56
- * @param array $params Test params
57
- * @param string $result Test result [running/ok/failed]
58
- * @param string|null $debug
59
- */
60
- public function UpdateTest($name, $params, $result = 'ok', $debug = null) {
61
- //----------------------------------------------------------
62
- $this->tests[] = array(
63
- $name,
64
- $params,
65
- date('Y-m-d H:i:s'),
66
- 'result' => $result,
67
- $debug
68
- );
69
- //----------------------------------------------------------
70
- $this->SaveTest();
71
- //----------------------------------------------------------
72
- }
73
-
74
- /**
75
- * Orbitvu SUN API calling alias
76
- * @param string $call Orbitvu SUN API Call path
77
- * @param type $parameters Orbitvu SUN API Call parameters
78
- * @return string
79
- */
80
- public function CallAPI($call, $parameters) {
81
- //----------------------------------------------------------
82
- if ($call == 'viewers/licenses') {
83
- //----------------------------------------------------------
84
- $res = '[{"url": "https://orbitvu.co/api/viewers/licenses/362.json", "type": "STANDARD", "support": "2015-05-19", "domains": "", "licensed_for": "Orbitvu", "licensed_for_url": "http://orbitvu.com/", "available_version": "2.3.10", "latest_version": "2.3.10", "download": "https://orbitvu.co/api/viewers/licenses/362/download/.html"}, {"url": "https://orbitvu.co/api/viewers/licenses/365.json", "type": "ROYALTY FREE", "support": "2015-05-23", "domains": "", "licensed_for": "Orbitvu", "licensed_for_url": "http://orbitvu.com/", "available_version": "2.3.10", "latest_version": "2.3.10", "download": "https://orbitvu.co/api/viewers/licenses/365/download/.html"}]';
85
-
86
- //----------------------------------------------------------
87
- $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
88
- //----------------------------------------------------------
89
- return $res;
90
- //----------------------------------------------------------
91
- }
92
- else if (stristr($call, 'download/')) {
93
- //----------------------------------------------------------
94
- $res = file_get_contents('empty.zip');
95
-
96
- //----------------------------------------------------------
97
- $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
98
- //----------------------------------------------------------
99
- return $res;
100
- //----------------------------------------------------------
101
- }
102
- else if (stristr($call, 'presentations')) {
103
- //----------------------------------------------------------
104
- $res = '[
105
- {"count": 8, "next": null, "previous": null, "results": [{"id": 25180, "uid": "dw8tWSSPwV5GC4TXgaZmmG", "name": "Coffee machine", "category_1": "", "category_2": "", "create_date": "2014-05-26T11:15:04", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 221683161, "has_orbittour": true, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/img01.png", "orbittour_set": [{"id": 2699, "script_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/2/orbittour/2699/script", "view_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/2/orbittour/2699/view"}], "presentationcontent_set": [{"id": 178575, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/img01.png", "script_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/ov3601/3/script", "view_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178577, "name": "img_0001.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178577/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178577/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178578, "name": "img_0002.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178578/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178578/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178579, "name": "img_0003.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178579/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178579/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178580, "name": "img_0004.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178580/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178580/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178581, "name": "img_0005.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178581/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178581/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178582, "name": "img_0006.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178582/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178582/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178583, "name": "img_0007.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178583/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178583/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178584, "name": "img_0008.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178584/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178584/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178585, "name": "img_0009.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178585/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178585/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178586, "name": "img_0010.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178586/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178586/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178587, "name": "img_0011.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178587/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178587/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178588, "name": "img_0012.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178588/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178588/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178589, "name": "img_0013.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178589/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178589/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178590, "name": "img_0014.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178590/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178590/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178591, "name": "img_0015.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178591/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178591/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178592, "name": "img_0016.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178592/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178592/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178593, "name": "img_0017.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178593/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178593/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178594, "name": "img_0018.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178594/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178594/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178595, "name": "img_0019.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178595/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178595/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178596, "name": "img_0020.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178596/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178596/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178597, "name": "img_0021.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178597/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178597/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178598, "name": "img_0022.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178598/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178598/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178599, "name": "img_0023.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178599/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178599/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178600, "name": "img_0024.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178600/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178600/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178601, "name": "img_0025.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178601/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178601/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178602, "name": "img_0026.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178602/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178602/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178603, "name": "img_0027.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178603/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178603/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178604, "name": "img_0028.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178604/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178604/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178605, "name": "img_0029.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178605/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178605/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178606, "name": "img_0030.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178606/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178606/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178607, "name": "img_0031.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178607/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178607/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178608, "name": "img_0032.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178608/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178608/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178609, "name": "img_0033.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178609/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178609/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178610, "name": "img_0034.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178610/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178610/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178611, "name": "img_0035.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178611/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178611/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178612, "name": "img_0036.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178612/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178612/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25181, "uid": "LbAPq78zoBXaPQ68Q6ai4E", "name": "Gold earrings", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:08", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 606911, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/iproc/img01.png", "orbittour_set": [{"id": 2700, "script_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/2/orbittour/2700/script", "view_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/2/orbittour/2700/view"}], "presentationcontent_set": [{"id": 178613, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25181.json", "thumbnail_url": "//static.orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/iproc/img01.png", "script_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/ov3601/3/script", "view_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/ov3601/3/view", "max_width": 5021, "max_height": 3342, "content2_xml": true}]}, {"id": 25182, "uid": "pXBLcTYvn6ankyEC3b6iJX", "name": "watch", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:10", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 7611244, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178615, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/img01.png", "script_url": "//orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/ov3601/3/script", "view_url": "//orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178617, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178617/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178617/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178618, "name": "img_2D_0001_large.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178618/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178618/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178619, "name": "img_2D_0001_small.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178619/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178619/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25183, "uid": "kEe8tjEWkbMmrBsX8skyXD", "name": "Golden ring with diamond", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:13", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 511239, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178620, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25183.json", "thumbnail_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/2d/178620/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/2d/178620/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25184, "uid": "LANSnsaeKeUP9ua7ZDFFA3", "name": "BUTY_D_GOTOWE", "category_1": "Brak Wpisu", "category_2": "Brak Wpisu", "create_date": "2014-05-26T11:15:20", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 1234232, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178622, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25184.json", "thumbnail_url": "//static.orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/iproc/img01.png", "script_url": "//orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/ov3601/3/script", "view_url": "//orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25185, "uid": "WEWjYXumxfmufCuCynJ86g", "name": "YDP-142", "category_1": "", "category_2": "", "create_date": "2014-05-26T11:15:34", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 50316772, "has_orbittour": true, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/img01.png", "orbittour_set": [{"id": 2701, "script_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/2/orbittour/2701/script", "view_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/2/orbittour/2701/view"}], "presentationcontent_set": [{"id": 178624, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/img01.png", "script_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/ov3601/3/script", "view_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": false}, {"id": 178626, "name": "img75418.jpeg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178626/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178626/img01.png", "max_width": 0, "max_height": 0, "content2_xml": false}, {"id": 178627, "name": "img75419.jpeg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178627/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178627/img01.png", "max_width": 0, "max_height": 0, "content2_xml": false}]}, {"id": 25186, "uid": "DyKUxA29VPbCFiRiJrKb9N", "name": "Monitor z instrukcj\u0105 obs\u0142ugi", "category_1": "sprz\u0119t komputerowy", "category_2": "sprz\u0119t elektroniczny", "create_date": "2014-05-26T11:17:18", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 64320387, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178628, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25186.json", "thumbnail_url": "//static.orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/iproc/img01.png", "script_url": "//orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/ov3601/3/script", "view_url": "//orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25233, "uid": "BPo2ZYb2ShuVPjxppkn2mh", "name": "test3", "category_1": "Brak Wpisu", "category_2": "Brak Wpisu", "create_date": "2014-05-28T10:30:44", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 47027475, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/img01.png", "orbittour_set": [{"id": 2715, "script_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/2/orbittour/2715/script", "view_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/2/orbittour/2715/view"}], "presentationcontent_set": [{"id": 179181, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/img01.png", "script_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/ov3601/3/script", "view_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/ov3601/3/view", "max_width": 1500, "max_height": 1500, "content2_xml": true}, {"id": 179183, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179183/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179183/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179184, "name": "img_2D_0002.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179184/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179184/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179185, "name": "img_2D_0003.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179185/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179185/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179186, "name": "img_2D_0004.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179186/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179186/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179187, "name": "img_2D_0005.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179187/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179187/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179188, "name": "img_2D_0006.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179188/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179188/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179189, "name": "img_2D_0007.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179189/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179189/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179190, "name": "img_2D_0008.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179190/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179190/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179191, "name": "img_2D_0009.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179191/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179191/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179192, "name": "img_2D_0010.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179192/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179192/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179193, "name": "img_2D_0011.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179193/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179193/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179194, "name": "img_2D_0012.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179194/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179194/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179195, "name": "img_2D_0013.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179195/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179195/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179196, "name": "img_2D_0014.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179196/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179196/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179197, "name": "img_2D_0015.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179197/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179197/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179198, "name": "img_2D_0016.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179198/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179198/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179199, "name": "img_2D_0017.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179199/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179199/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}]}]}]';
106
-
107
- //----------------------------------------------------------
108
- $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
109
- //----------------------------------------------------------
110
- return $res;
111
- //----------------------------------------------------------
112
- }
113
- }
114
-
115
- /**
116
- * Get tests results
117
- * @return array
118
- */
119
- public function GetResults() {
120
- //----------------------------------------------------------
121
- return $this->tests;
122
- //----------------------------------------------------------
123
- }
124
-
125
- }
126
-
127
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP System Unit Tests
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ */
6
+
7
+ class OrbitvuTests {
8
+
9
+ /**
10
+ * Temp array per instance with test results
11
+ * @var array
12
+ */
13
+ private $tests = array();
14
+
15
+ /**
16
+ * Update unit tests file
17
+ * @return boolean
18
+ */
19
+ public function SaveTest() {
20
+ //----------------------------------------------------------
21
+ $ar = json_encode($this->tests);
22
+
23
+ if (file_put_contents('orbitvu_tests.txt', $ar)) {
24
+ //---------------------------------------------------------
25
+ return true;
26
+ //---------------------------------------------------------
27
+ }
28
+ //---------------------------------------------------------
29
+ return false;
30
+ //---------------------------------------------------------
31
+ }
32
+
33
+ /**
34
+ * Append a new test
35
+ * @param string $name Name
36
+ * @param array $test Data
37
+ * @param array $params Additional params
38
+ */
39
+ public function AppendTest($name, $test, $params) {
40
+ //----------------------------------------------------------
41
+ $this->tests[] = array(
42
+ $name,
43
+ $test,
44
+ $params,
45
+ date('Y-m-d H:i:s'),
46
+ 'result' => 'running'
47
+ );
48
+ //----------------------------------------------------------
49
+ $this->SaveTest();
50
+ //----------------------------------------------------------
51
+ }
52
+
53
+ /**
54
+ * Update test status
55
+ * @param string $name Test name
56
+ * @param array $params Test params
57
+ * @param string $result Test result [running/ok/failed]
58
+ * @param string|null $debug
59
+ */
60
+ public function UpdateTest($name, $params, $result = 'ok', $debug = null) {
61
+ //----------------------------------------------------------
62
+ $this->tests[] = array(
63
+ $name,
64
+ $params,
65
+ date('Y-m-d H:i:s'),
66
+ 'result' => $result,
67
+ $debug
68
+ );
69
+ //----------------------------------------------------------
70
+ $this->SaveTest();
71
+ //----------------------------------------------------------
72
+ }
73
+
74
+ /**
75
+ * Orbitvu SUN API calling alias
76
+ * @param string $call Orbitvu SUN API Call path
77
+ * @param type $parameters Orbitvu SUN API Call parameters
78
+ * @return string
79
+ */
80
+ public function CallAPI($call, $parameters) {
81
+ //----------------------------------------------------------
82
+ if ($call == 'viewers/licenses') {
83
+ //----------------------------------------------------------
84
+ $res = '[{"url": "https://orbitvu.co/api/viewers/licenses/362.json", "type": "STANDARD", "support": "2015-05-19", "domains": "", "licensed_for": "Orbitvu", "licensed_for_url": "http://orbitvu.com/", "available_version": "2.3.10", "latest_version": "2.3.10", "download": "https://orbitvu.co/api/viewers/licenses/362/download/.html"}, {"url": "https://orbitvu.co/api/viewers/licenses/365.json", "type": "ROYALTY FREE", "support": "2015-05-23", "domains": "", "licensed_for": "Orbitvu", "licensed_for_url": "http://orbitvu.com/", "available_version": "2.3.10", "latest_version": "2.3.10", "download": "https://orbitvu.co/api/viewers/licenses/365/download/.html"}]';
85
+
86
+ //----------------------------------------------------------
87
+ $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
88
+ //----------------------------------------------------------
89
+ return $res;
90
+ //----------------------------------------------------------
91
+ }
92
+ else if (stristr($call, 'download/')) {
93
+ //----------------------------------------------------------
94
+ $res = file_get_contents('empty.zip');
95
+
96
+ //----------------------------------------------------------
97
+ $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
98
+ //----------------------------------------------------------
99
+ return $res;
100
+ //----------------------------------------------------------
101
+ }
102
+ else if (stristr($call, 'presentations')) {
103
+ //----------------------------------------------------------
104
+ $res = '[
105
+ {"count": 8, "next": null, "previous": null, "results": [{"id": 25180, "uid": "dw8tWSSPwV5GC4TXgaZmmG", "name": "Coffee machine", "category_1": "", "category_2": "", "create_date": "2014-05-26T11:15:04", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 221683161, "has_orbittour": true, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/img01.png", "orbittour_set": [{"id": 2699, "script_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/2/orbittour/2699/script", "view_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/2/orbittour/2699/view"}], "presentationcontent_set": [{"id": 178575, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/img01.png", "script_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/ov3601/3/script", "view_url": "//orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178577, "name": "img_0001.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178577/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178577/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178578, "name": "img_0002.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178578/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178578/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178579, "name": "img_0003.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178579/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178579/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178580, "name": "img_0004.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178580/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178580/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178581, "name": "img_0005.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178581/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178581/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178582, "name": "img_0006.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178582/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178582/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178583, "name": "img_0007.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178583/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178583/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178584, "name": "img_0008.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178584/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178584/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178585, "name": "img_0009.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178585/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178585/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178586, "name": "img_0010.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178586/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178586/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178587, "name": "img_0011.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178587/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178587/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178588, "name": "img_0012.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178588/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178588/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178589, "name": "img_0013.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178589/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178589/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178590, "name": "img_0014.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178590/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178590/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178591, "name": "img_0015.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178591/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178591/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178592, "name": "img_0016.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178592/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178592/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178593, "name": "img_0017.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178593/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178593/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178594, "name": "img_0018.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178594/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178594/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178595, "name": "img_0019.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178595/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178595/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178596, "name": "img_0020.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178596/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178596/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178597, "name": "img_0021.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178597/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178597/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178598, "name": "img_0022.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178598/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178598/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178599, "name": "img_0023.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178599/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178599/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178600, "name": "img_0024.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178600/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178600/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178601, "name": "img_0025.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178601/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178601/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178602, "name": "img_0026.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178602/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178602/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178603, "name": "img_0027.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178603/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178603/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178604, "name": "img_0028.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178604/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178604/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178605, "name": "img_0029.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178605/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178605/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178606, "name": "img_0030.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178606/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178606/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178607, "name": "img_0031.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178607/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178607/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178608, "name": "img_0032.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178608/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178608/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178609, "name": "img_0033.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178609/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178609/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178610, "name": "img_0034.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178610/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178610/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178611, "name": "img_0035.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178611/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178611/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178612, "name": "img_0036.png", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25180.json", "thumbnail_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178612/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/dw8tWSSPwV5GC4TXgaZmmG/iproc/2d/178612/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25181, "uid": "LbAPq78zoBXaPQ68Q6ai4E", "name": "Gold earrings", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:08", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 606911, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/iproc/img01.png", "orbittour_set": [{"id": 2700, "script_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/2/orbittour/2700/script", "view_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/2/orbittour/2700/view"}], "presentationcontent_set": [{"id": 178613, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25181.json", "thumbnail_url": "//static.orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/iproc/img01.png", "script_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/ov3601/3/script", "view_url": "//orbitvu.co/001/LbAPq78zoBXaPQ68Q6ai4E/ov3601/3/view", "max_width": 5021, "max_height": 3342, "content2_xml": true}]}, {"id": 25182, "uid": "pXBLcTYvn6ankyEC3b6iJX", "name": "watch", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:10", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 7611244, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178615, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/img01.png", "script_url": "//orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/ov3601/3/script", "view_url": "//orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178617, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178617/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178617/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178618, "name": "img_2D_0001_large.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178618/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178618/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}, {"id": 178619, "name": "img_2D_0001_small.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25182.json", "thumbnail_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178619/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/pXBLcTYvn6ankyEC3b6iJX/iproc/2d/178619/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25183, "uid": "kEe8tjEWkbMmrBsX8skyXD", "name": "Golden ring with diamond", "category_1": "Not Specified", "category_2": "Not Specified", "create_date": "2014-05-26T11:15:13", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 511239, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178620, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25183.json", "thumbnail_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/2d/178620/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/kEe8tjEWkbMmrBsX8skyXD/iproc/2d/178620/img01.png", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25184, "uid": "LANSnsaeKeUP9ua7ZDFFA3", "name": "BUTY_D_GOTOWE", "category_1": "Brak Wpisu", "category_2": "Brak Wpisu", "create_date": "2014-05-26T11:15:20", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 1234232, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178622, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25184.json", "thumbnail_url": "//static.orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/iproc/img01.png", "script_url": "//orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/ov3601/3/script", "view_url": "//orbitvu.co/001/LANSnsaeKeUP9ua7ZDFFA3/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25185, "uid": "WEWjYXumxfmufCuCynJ86g", "name": "YDP-142", "category_1": "", "category_2": "", "create_date": "2014-05-26T11:15:34", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 50316772, "has_orbittour": true, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/img01.png", "orbittour_set": [{"id": 2701, "script_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/2/orbittour/2701/script", "view_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/2/orbittour/2701/view"}], "presentationcontent_set": [{"id": 178624, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/img01.png", "script_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/ov3601/3/script", "view_url": "//orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": false}, {"id": 178626, "name": "img75418.jpeg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178626/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178626/img01.png", "max_width": 0, "max_height": 0, "content2_xml": false}, {"id": 178627, "name": "img75419.jpeg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25185.json", "thumbnail_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178627/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/WEWjYXumxfmufCuCynJ86g/iproc/2d/178627/img01.png", "max_width": 0, "max_height": 0, "content2_xml": false}]}, {"id": 25186, "uid": "DyKUxA29VPbCFiRiJrKb9N", "name": "Monitor z instrukcj\u0105 obs\u0142ugi", "category_1": "sprz\u0119t komputerowy", "category_2": "sprz\u0119t elektroniczny", "create_date": "2014-05-26T11:17:18", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 64320387, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/iproc/img01.png", "orbittour_set": [], "presentationcontent_set": [{"id": 178628, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25186.json", "thumbnail_url": "//static.orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/iproc/img01.png", "script_url": "//orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/ov3601/3/script", "view_url": "//orbitvu.co/001/DyKUxA29VPbCFiRiJrKb9N/ov3601/3/view", "max_width": 0, "max_height": 0, "content2_xml": true}]}, {"id": 25233, "uid": "BPo2ZYb2ShuVPjxppkn2mh", "name": "test3", "category_1": "Brak Wpisu", "category_2": "Brak Wpisu", "create_date": "2014-05-28T10:30:44", "presentation_status_display": "Aktywny", "presentation_status": 1, "presentation_size": 47027475, "has_orbittour": false, "tags": [], "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/img01.png", "orbittour_set": [{"id": 2715, "script_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/2/orbittour/2715/script", "view_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/2/orbittour/2715/view"}], "presentationcontent_set": [{"id": 179181, "name": "ov3601", "type": 1, "type_display": "ORBITVU 360", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/img01.png", "script_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/ov3601/3/script", "view_url": "//orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/ov3601/3/view", "max_width": 1500, "max_height": 1500, "content2_xml": true}, {"id": 179183, "name": "img_2D_0001.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179183/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179183/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179184, "name": "img_2D_0002.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179184/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179184/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179185, "name": "img_2D_0003.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179185/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179185/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179186, "name": "img_2D_0004.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179186/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179186/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179187, "name": "img_2D_0005.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179187/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179187/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179188, "name": "img_2D_0006.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179188/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179188/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179189, "name": "img_2D_0007.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179189/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179189/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179190, "name": "img_2D_0008.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179190/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179190/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179191, "name": "img_2D_0009.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179191/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179191/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179192, "name": "img_2D_0010.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179192/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179192/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179193, "name": "img_2D_0011.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179193/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179193/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179194, "name": "img_2D_0012.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179194/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179194/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179195, "name": "img_2D_0013.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179195/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179195/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179196, "name": "img_2D_0014.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179196/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179196/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179197, "name": "img_2D_0015.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179197/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179197/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179198, "name": "img_2D_0016.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179198/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179198/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}, {"id": 179199, "name": "img_2D_0017.jpg", "type": 3, "type_display": "image2d", "presentation": "http://orbitvu.co/api/presentations/25233.json", "thumbnail_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179199/img01.png", "script_url": "", "view_url": "//static.orbitvu.co/001/BPo2ZYb2ShuVPjxppkn2mh/iproc/2d/179199/img01.png", "max_width": 2000, "max_height": 2000, "content2_xml": true}]}]}]';
106
+
107
+ //----------------------------------------------------------
108
+ $this->UpdateTest('api_call['.$call.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
109
+ //----------------------------------------------------------
110
+ return $res;
111
+ //----------------------------------------------------------
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Get tests results
117
+ * @return array
118
+ */
119
+ public function GetResults() {
120
+ //----------------------------------------------------------
121
+ return $this->tests;
122
+ //----------------------------------------------------------
123
+ }
124
+
125
+ }
126
+
127
  ?>
app/code/community/Orbitvu/Sun/etc/adminhtml.xml CHANGED
@@ -1,26 +1,26 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <acl>
4
- <resources>
5
- <all>
6
- <title>Allow Everything</title>
7
- </all>
8
- <admin>
9
- <children>
10
- <system>
11
- <children>
12
- <config>
13
- <children>
14
- <orbitvu translate="title" module="sun">
15
- <title>Orbitvu SUN Synchronization</title>
16
- <sort_order>100</sort_order>
17
- </orbitvu>
18
- </children>
19
- </config>
20
- </children>
21
- </system>
22
- </children>
23
- </admin>
24
- </resources>
25
- </acl>
26
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <orbitvu translate="title" module="sun">
15
+ <title>Orbitvu SUN Synchronization</title>
16
+ <sort_order>100</sort_order>
17
+ </orbitvu>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
  </config>
app/code/community/Orbitvu/Sun/etc/config.xml CHANGED
@@ -1,101 +1,101 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category Orbitvu
5
- * @package Orbitvu_Sun
6
- * @copyright Copyright (c) 2014 Orbitvu (http://www.orbitvu.com)
7
- */
8
- -->
9
- <config>
10
- <modules>
11
- <Orbitvu_Sun>
12
- <version>1.0.11</version>
13
- </Orbitvu_Sun>
14
- </modules>
15
- <global>
16
- <models>
17
- <sun>
18
- <class>Orbitvu_Sun_Model</class>
19
- <resourceModel>sun_resource</resourceModel>
20
- </sun>
21
- </models>
22
- <helpers>
23
- <sun>
24
- <class>Orbitvu_Sun_Helper</class>
25
- </sun>
26
- </helpers>
27
- <resources>
28
- <sun_setup>
29
- <setup>
30
- <module>Orbitvu_Sun</module>
31
- <class>Orbitvu_Sun_Model_Resource_Setup</class>
32
- </setup>
33
- </sun_setup>
34
- </resources>
35
- <blocks>
36
- <sun>
37
- <class>Orbitvu_Sun_Block</class>
38
- </sun>
39
- <adminhtml>
40
- <rewrite>
41
- <catalog_product_edit_tabs>Orbitvu_Sun_Block_Adminhtml_Tabs</catalog_product_edit_tabs>
42
- <catalog_product_grid>Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
43
- </rewrite>
44
- </adminhtml>
45
- <catalog>
46
- <rewrite>
47
- <product_view_media>Orbitvu_Sun_Block_Product_View_Media</product_view_media>
48
- </rewrite>
49
- </catalog>
50
- </blocks>
51
- <events>
52
- <catalog_product_save_after>
53
- <observers>
54
- <sun_save_product_data>
55
- <type>singleton</type>
56
- <class>sun/observer</class>
57
- <method>saveProductTabData</method>
58
- </sun_save_product_data>
59
- </observers>
60
- </catalog_product_save_after>
61
- </events>
62
- </global>
63
- <frontend>
64
- <routers>
65
- <sun>
66
- <use>standard</use>
67
- <args>
68
- <module>Orbitvu_Sun</module>
69
- <frontName>sun</frontName>
70
- </args>
71
- </sun>
72
- </routers>
73
- <layout>
74
- <updates>
75
- <sun>
76
- <file>sun.xml</file>
77
- </sun>
78
- </updates>
79
- </layout>
80
- <translate>
81
- <modules>
82
- <Orbitvu_Sun>
83
- <files>
84
- <default>Orbitvu_Sun.csv</default>
85
- </files>
86
- </Orbitvu_Sun>
87
- </modules>
88
- </translate>
89
- </frontend>
90
- <adminhtml>
91
- <translate>
92
- <modules>
93
- <Orbitvu_Sun>
94
- <files>
95
- <default>Orbitvu_Sun.csv</default>
96
- </files>
97
- </Orbitvu_Sun>
98
- </modules>
99
- </translate>
100
- </adminhtml>
101
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Orbitvu
5
+ * @package Orbitvu_Sun
6
+ * @copyright Copyright (c) 2014 Orbitvu (http://www.orbitvu.com)
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Orbitvu_Sun>
12
+ <version>1.0.12</version>
13
+ </Orbitvu_Sun>
14
+ </modules>
15
+ <global>
16
+ <models>
17
+ <sun>
18
+ <class>Orbitvu_Sun_Model</class>
19
+ <resourceModel>sun_resource</resourceModel>
20
+ </sun>
21
+ </models>
22
+ <helpers>
23
+ <sun>
24
+ <class>Orbitvu_Sun_Helper</class>
25
+ </sun>
26
+ </helpers>
27
+ <resources>
28
+ <sun_setup>
29
+ <setup>
30
+ <module>Orbitvu_Sun</module>
31
+ <class>Orbitvu_Sun_Model_Resource_Setup</class>
32
+ </setup>
33
+ </sun_setup>
34
+ </resources>
35
+ <blocks>
36
+ <sun>
37
+ <class>Orbitvu_Sun_Block</class>
38
+ </sun>
39
+ <adminhtml>
40
+ <rewrite>
41
+ <catalog_product_edit_tabs>Orbitvu_Sun_Block_Adminhtml_Tabs</catalog_product_edit_tabs>
42
+ <catalog_product_grid>Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
43
+ </rewrite>
44
+ </adminhtml>
45
+ <catalog>
46
+ <rewrite>
47
+ <product_view_media>Orbitvu_Sun_Block_Product_View_Media</product_view_media>
48
+ </rewrite>
49
+ </catalog>
50
+ </blocks>
51
+ <events>
52
+ <catalog_product_save_after>
53
+ <observers>
54
+ <sun_save_product_data>
55
+ <type>singleton</type>
56
+ <class>sun/observer</class>
57
+ <method>saveProductTabData</method>
58
+ </sun_save_product_data>
59
+ </observers>
60
+ </catalog_product_save_after>
61
+ </events>
62
+ </global>
63
+ <frontend>
64
+ <routers>
65
+ <sun>
66
+ <use>standard</use>
67
+ <args>
68
+ <module>Orbitvu_Sun</module>
69
+ <frontName>sun</frontName>
70
+ </args>
71
+ </sun>
72
+ </routers>
73
+ <layout>
74
+ <updates>
75
+ <sun>
76
+ <file>sun.xml</file>
77
+ </sun>
78
+ </updates>
79
+ </layout>
80
+ <translate>
81
+ <modules>
82
+ <Orbitvu_Sun>
83
+ <files>
84
+ <default>Orbitvu_Sun.csv</default>
85
+ </files>
86
+ </Orbitvu_Sun>
87
+ </modules>
88
+ </translate>
89
+ </frontend>
90
+ <adminhtml>
91
+ <translate>
92
+ <modules>
93
+ <Orbitvu_Sun>
94
+ <files>
95
+ <default>Orbitvu_Sun.csv</default>
96
+ </files>
97
+ </Orbitvu_Sun>
98
+ </modules>
99
+ </translate>
100
+ </adminhtml>
101
+ </config>
app/code/community/Orbitvu/Sun/etc/system.xml CHANGED
@@ -1,319 +1,319 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <sections>
4
- <orbitvu translate="label">
5
- <label>Orbitvu SUN</label>
6
- <tab>catalog</tab>
7
- <frontend_type>text</frontend_type>
8
- <sort_order>30</sort_order>
9
- <show_in_default>1</show_in_default>
10
- <show_in_website>1</show_in_website>
11
- <show_in_store>1</show_in_store>
12
- <groups>
13
- <api translate="label">
14
- <label>Orbitvu SUN connection settings</label>
15
- <frontend_type>text</frontend_type>
16
- <sort_order>100</sort_order>
17
- <show_in_default>1</show_in_default>
18
- <show_in_website>0</show_in_website>
19
- <show_in_store>0</show_in_store>
20
- <expanded>1</expanded>
21
- <fields>
22
- <access_token translate="label comment">
23
- <label>License Key</label>
24
- <comment>
25
- <model>Orbitvu_Sun_Block_KeyComment</model>
26
- </comment>
27
- <frontend_type>text</frontend_type>
28
- <sort_order>10</sort_order>
29
- <show_in_default>1</show_in_default>
30
- <show_in_website>0</show_in_website>
31
- <show_in_store>0</show_in_store>
32
- </access_token>
33
- </fields>
34
- </api>
35
- <synchro>
36
- <label>Orbitvu SUN integration</label>
37
- <frontend_type>text</frontend_type>
38
- <sort_order>200</sort_order>
39
- <show_in_default>1</show_in_default>
40
- <show_in_website>0</show_in_website>
41
- <show_in_store>0</show_in_store>
42
- <expanded>1</expanded>
43
- <fields>
44
-
45
- <auto_sync translate="label comment">
46
- <label>Link Orbitvu SUN presentations to products automatically</label>
47
- <comment><![CDATA[Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.]]></comment>
48
- <frontend_type>select</frontend_type>
49
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
50
- <sort_order>10</sort_order>
51
- <show_in_default>1</show_in_default>
52
- <show_in_website>0</show_in_website>
53
- <show_in_store>0</show_in_store>
54
- </auto_sync>
55
- <auto_sync_sku translate="label comment">
56
- <label>Update presentation SKU on Orbitvu SUN automatically</label>
57
- <comment><![CDATA[Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.]]></comment>
58
- <frontend_type>select</frontend_type>
59
- <source_model>Orbitvu_Sun_Block_Syncsku</source_model>
60
- <sort_order>20</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>0</show_in_website>
63
- <show_in_store>0</show_in_store>
64
- </auto_sync_sku>
65
-
66
- </fields>
67
- </synchro>
68
-
69
- <items>
70
- <label>Select what type of presentation content will be visible in store by default</label>
71
- <frontend_type>text</frontend_type>
72
- <sort_order>300</sort_order>
73
- <show_in_default>1</show_in_default>
74
- <show_in_website>0</show_in_website>
75
- <show_in_store>0</show_in_store>
76
- <expanded>1</expanded>
77
- <fields>
78
-
79
- <sync_orbittour translate="label comment">
80
- <label>Orbittour</label>
81
- <frontend_type>select</frontend_type>
82
- <source_model>adminhtml/system_config_source_yesno</source_model>
83
- <sort_order>10</sort_order>
84
- <show_in_default>1</show_in_default>
85
- <show_in_website>0</show_in_website>
86
- <show_in_store>0</show_in_store>
87
- </sync_orbittour>
88
- <sync_360 translate="label comment">
89
- <label>360°</label>
90
- <frontend_type>select</frontend_type>
91
- <source_model>adminhtml/system_config_source_yesno</source_model>
92
- <sort_order>20</sort_order>
93
- <show_in_default>1</show_in_default>
94
- <show_in_website>0</show_in_website>
95
- <show_in_store>0</show_in_store>
96
- </sync_360>
97
- <sync_2d translate="label comment">
98
- <label>2D</label>
99
- <frontend_type>select</frontend_type>
100
- <source_model>adminhtml/system_config_source_yesno</source_model>
101
- <sort_order>30</sort_order>
102
- <show_in_default>1</show_in_default>
103
- <show_in_website>0</show_in_website>
104
- <show_in_store>0</show_in_store>
105
- </sync_2d>
106
-
107
- </fields>
108
- </items>
109
-
110
- <mode>
111
- <label>Product view - gallery behavior</label>
112
- <frontend_type>text</frontend_type>
113
- <sort_order>400</sort_order>
114
- <show_in_default>1</show_in_default>
115
- <show_in_website>0</show_in_website>
116
- <show_in_store>0</show_in_store>
117
- <expanded>1</expanded>
118
- <fields>
119
-
120
- <hover_mode translate="label comment">
121
- <label>Mouse over mode</label>
122
- <comment><![CDATA[Change presentation items in gallery with just mouse over instead of click.]]></comment>
123
- <frontend_type>select</frontend_type>
124
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
125
- <sort_order>10</sort_order>
126
- <show_in_default>1</show_in_default>
127
- <show_in_website>0</show_in_website>
128
- <show_in_store>0</show_in_store>
129
- </hover_mode>
130
- <hover_delay translate="label comment">
131
- <label>Mouse over delay</label>
132
- <comment><![CDATA[Delay time before current photo will be changed.]]></comment>
133
- <frontend_type>select</frontend_type>
134
- <source_model>Orbitvu_Sun_Block_Delay</source_model>
135
- <sort_order>10</sort_order>
136
- <show_in_default>1</show_in_default>
137
- <show_in_website>0</show_in_website>
138
- <show_in_store>0</show_in_store>
139
- </hover_delay>
140
- <teaser translate="label comment">
141
- <label>360° Presentation teaser</label>
142
- <frontend_type>select</frontend_type>
143
- <source_model>Orbitvu_Sun_Block_Teaser</source_model>
144
- <sort_order>20</sort_order>
145
- <show_in_default>1</show_in_default>
146
- <show_in_website>0</show_in_website>
147
- <show_in_store>0</show_in_store>
148
- </teaser>
149
- <html5 translate="label comment">
150
- <label>HTML5 or Flash mode</label>
151
- <frontend_type>select</frontend_type>
152
- <source_model>Orbitvu_Sun_Block_Html5</source_model>
153
- <sort_order>30</sort_order>
154
- <show_in_default>1</show_in_default>
155
- <show_in_website>0</show_in_website>
156
- <show_in_store>0</show_in_store>
157
- </html5>
158
- <orbittour_thumbnails translate="label comment">
159
- <label>Orbittour views visibility</label>
160
- <frontend_type>select</frontend_type>
161
- <source_model>Orbitvu_Sun_Block_Orbittour</source_model>
162
- <sort_order>40</sort_order>
163
- <show_in_default>1</show_in_default>
164
- <show_in_website>0</show_in_website>
165
- <show_in_store>0</show_in_store>
166
- </orbittour_thumbnails>
167
-
168
- </fields>
169
- </mode>
170
-
171
- <layout>
172
- <label>Product view - gallery layout (edit only if you know what are you doing!)</label>
173
- <frontend_type>text</frontend_type>
174
- <sort_order>500</sort_order>
175
- <show_in_default>1</show_in_default>
176
- <show_in_website>0</show_in_website>
177
- <show_in_store>0</show_in_store>
178
- <expanded>0</expanded>
179
- <fields>
180
-
181
- <width translate="label comment">
182
- <label>Gallery width</label>
183
- <comment><![CDATA[Enter <strong>100%</strong> if you wan't to have responsive gallery layout (recommended)]]></comment>
184
- <frontend_type>text</frontend_type>
185
- <sort_order>10</sort_order>
186
- <show_in_default>1</show_in_default>
187
- <show_in_website>0</show_in_website>
188
- <show_in_store>0</show_in_store>
189
- </width>
190
- <img_width translate="label comment">
191
- <label>Gallery preview maximum width</label>
192
- <comment><![CDATA[Recommended: Your layout proportion to gallery preview maximum height eg. <strong>600px</strong>]]></comment>
193
- <frontend_type>text</frontend_type>
194
- <sort_order>20</sort_order>
195
- <show_in_default>1</show_in_default>
196
- <show_in_website>0</show_in_website>
197
- <show_in_store>0</show_in_store>
198
- </img_width>
199
- <img_height translate="label comment">
200
- <label>Gallery preview maximum height</label>
201
- <comment><![CDATA[Recommended: <strong>300px</strong>]]></comment>
202
- <frontend_type>text</frontend_type>
203
- <sort_order>25</sort_order>
204
- <show_in_default>1</show_in_default>
205
- <show_in_website>0</show_in_website>
206
- <show_in_store>0</show_in_store>
207
- </img_height>
208
- <border_color translate="label comment">
209
- <label>Gallery border color</label>
210
- <comment><![CDATA[Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders]]></comment>
211
- <frontend_type>text</frontend_type>
212
- <sort_order>30</sort_order>
213
- <show_in_default>1</show_in_default>
214
- <show_in_website>0</show_in_website>
215
- <show_in_store>0</show_in_store>
216
- </border_color>
217
-
218
- <img_width_zoom translate="label comment">
219
- <label>Internal zoom image width</label>
220
- <comment><![CDATA[Recommended: <strong>1024px</strong>]]></comment>
221
- <frontend_type>text</frontend_type>
222
- <sort_order>60</sort_order>
223
- <show_in_default>1</show_in_default>
224
- <show_in_website>0</show_in_website>
225
- <show_in_store>0</show_in_store>
226
- </img_width_zoom>
227
- <img_height_zoom translate="label comment">
228
- <label>Internal zoom image height</label>
229
- <comment><![CDATA[Recommended: <strong>768px</strong>]]></comment>
230
- <frontend_type>text</frontend_type>
231
- <sort_order>70</sort_order>
232
- <show_in_default>1</show_in_default>
233
- <show_in_website>0</show_in_website>
234
- <show_in_store>0</show_in_store>
235
- </img_height_zoom>
236
-
237
- <scroll translate="label comment">
238
- <label>Thumbnails scroll type</label>
239
- <comment><![CDATA[Enable or disable thumbnails scroll]]></comment>
240
- <frontend_type>select</frontend_type>
241
- <source_model>Orbitvu_Sun_Block_Scroll</source_model>
242
- <sort_order>78</sort_order>
243
- <show_in_default>1</show_in_default>
244
- <show_in_website>0</show_in_website>
245
- <show_in_store>0</show_in_store>
246
- </scroll>
247
-
248
- <img_width_tn translate="label comment">
249
- <label>Thumbnail width</label>
250
- <comment><![CDATA[Recommended: <strong>75px</strong>]]></comment>
251
- <frontend_type>text</frontend_type>
252
- <sort_order>80</sort_order>
253
- <show_in_default>1</show_in_default>
254
- <show_in_website>0</show_in_website>
255
- <show_in_store>0</show_in_store>
256
- </img_width_tn>
257
- <img_height_tn translate="label comment">
258
- <label>Thumbnail height</label>
259
- <comment><![CDATA[Recommended: <strong>50px</strong>]]></comment>
260
- <frontend_type>text</frontend_type>
261
- <sort_order>90</sort_order>
262
- <show_in_default>1</show_in_default>
263
- <show_in_website>0</show_in_website>
264
- <show_in_store>0</show_in_store>
265
- </img_height_tn>
266
- <img_tn_margin translate="label comment">
267
- <label>Thumbnail margin</label>
268
- <comment><![CDATA[Recommended: <strong>3px</strong>]]></comment>
269
- <frontend_type>text</frontend_type>
270
- <sort_order>100</sort_order>
271
- <show_in_default>1</show_in_default>
272
- <show_in_website>0</show_in_website>
273
- <show_in_store>0</show_in_store>
274
- </img_tn_margin>
275
-
276
- <img_tn_padding translate="label comment">
277
- <label>Thumbnail padding</label>
278
- <comment><![CDATA[Recommended: <strong>0px</strong>]]></comment>
279
- <frontend_type>text</frontend_type>
280
- <sort_order>100</sort_order>
281
- <show_in_default>1</show_in_default>
282
- <show_in_website>0</show_in_website>
283
- <show_in_store>0</show_in_store>
284
- </img_tn_padding>
285
-
286
- <button_width translate="label comment">
287
- <label>Button prev/next width</label>
288
- <comment><![CDATA[Recommended: <strong>30px</strong>]]></comment>
289
- <frontend_type>text</frontend_type>
290
- <sort_order>110</sort_order>
291
- <show_in_default>1</show_in_default>
292
- <show_in_website>0</show_in_website>
293
- <show_in_store>0</show_in_store>
294
- </button_width>
295
- <button_height translate="label comment">
296
- <label>Button prev/next height</label>
297
- <comment><![CDATA[Recommended: <strong>53px</strong>]]></comment>
298
- <frontend_type>text</frontend_type>
299
- <sort_order>120</sort_order>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>0</show_in_website>
302
- <show_in_store>0</show_in_store>
303
- </button_height>
304
- <button_opacity translate="label comment">
305
- <label>Button prev/next opacity</label>
306
- <comment><![CDATA[1 = 100% (recommended), 0.5 = 50%, 0 = 0%]]></comment>
307
- <frontend_type>text</frontend_type>
308
- <sort_order>130</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>0</show_in_website>
311
- <show_in_store>0</show_in_store>
312
- </button_opacity>
313
- </fields>
314
-
315
- </layout>
316
- </groups>
317
- </orbitvu>
318
- </sections>
319
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <orbitvu translate="label">
5
+ <label>Orbitvu SUN</label>
6
+ <tab>catalog</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>30</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <api translate="label">
14
+ <label>Orbitvu SUN connection settings</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>100</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>0</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <expanded>1</expanded>
21
+ <fields>
22
+ <access_token translate="label comment">
23
+ <label>License Key</label>
24
+ <comment>
25
+ <model>Orbitvu_Sun_Block_KeyComment</model>
26
+ </comment>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>10</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>0</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </access_token>
33
+ </fields>
34
+ </api>
35
+ <synchro>
36
+ <label>Orbitvu SUN integration</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>200</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>0</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ <expanded>1</expanded>
43
+ <fields>
44
+
45
+ <auto_sync translate="label comment">
46
+ <label>Link Orbitvu SUN presentations to products automatically</label>
47
+ <comment><![CDATA[Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.]]></comment>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
50
+ <sort_order>10</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ </auto_sync>
55
+ <auto_sync_sku translate="label comment">
56
+ <label>Update presentation SKU on Orbitvu SUN automatically</label>
57
+ <comment><![CDATA[Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.]]></comment>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>Orbitvu_Sun_Block_Syncsku</source_model>
60
+ <sort_order>20</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>0</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </auto_sync_sku>
65
+
66
+ </fields>
67
+ </synchro>
68
+
69
+ <items>
70
+ <label>Select what type of presentation content will be visible in store by default</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>300</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>0</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ <expanded>1</expanded>
77
+ <fields>
78
+
79
+ <sync_orbittour translate="label comment">
80
+ <label>Orbittour</label>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>adminhtml/system_config_source_yesno</source_model>
83
+ <sort_order>10</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>0</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ </sync_orbittour>
88
+ <sync_360 translate="label comment">
89
+ <label>360°</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <sort_order>20</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>0</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </sync_360>
97
+ <sync_2d translate="label comment">
98
+ <label>2D</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>adminhtml/system_config_source_yesno</source_model>
101
+ <sort_order>30</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>0</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ </sync_2d>
106
+
107
+ </fields>
108
+ </items>
109
+
110
+ <mode>
111
+ <label>Product view - gallery behavior</label>
112
+ <frontend_type>text</frontend_type>
113
+ <sort_order>400</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>0</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ <expanded>1</expanded>
118
+ <fields>
119
+
120
+ <hover_mode translate="label comment">
121
+ <label>Mouse over mode</label>
122
+ <comment><![CDATA[Change presentation items in gallery with just mouse over instead of click.]]></comment>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
125
+ <sort_order>10</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>0</show_in_website>
128
+ <show_in_store>0</show_in_store>
129
+ </hover_mode>
130
+ <hover_delay translate="label comment">
131
+ <label>Mouse over delay</label>
132
+ <comment><![CDATA[Delay time before current photo will be changed.]]></comment>
133
+ <frontend_type>select</frontend_type>
134
+ <source_model>Orbitvu_Sun_Block_Delay</source_model>
135
+ <sort_order>10</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>0</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </hover_delay>
140
+ <teaser translate="label comment">
141
+ <label>360° Presentation teaser</label>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>Orbitvu_Sun_Block_Teaser</source_model>
144
+ <sort_order>20</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>0</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ </teaser>
149
+ <html5 translate="label comment">
150
+ <label>HTML5 or Flash mode</label>
151
+ <frontend_type>select</frontend_type>
152
+ <source_model>Orbitvu_Sun_Block_Html5</source_model>
153
+ <sort_order>30</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>0</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ </html5>
158
+ <orbittour_thumbnails translate="label comment">
159
+ <label>Orbittour views visibility</label>
160
+ <frontend_type>select</frontend_type>
161
+ <source_model>Orbitvu_Sun_Block_Orbittour</source_model>
162
+ <sort_order>40</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>0</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </orbittour_thumbnails>
167
+
168
+ </fields>
169
+ </mode>
170
+
171
+ <layout>
172
+ <label>Product view - gallery layout (edit only if you know what are you doing!)</label>
173
+ <frontend_type>text</frontend_type>
174
+ <sort_order>500</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>0</show_in_website>
177
+ <show_in_store>0</show_in_store>
178
+ <expanded>0</expanded>
179
+ <fields>
180
+
181
+ <width translate="label comment">
182
+ <label>Gallery width</label>
183
+ <comment><![CDATA[Enter <strong>100%</strong> if you wan't to have responsive gallery layout (recommended)]]></comment>
184
+ <frontend_type>text</frontend_type>
185
+ <sort_order>10</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>0</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ </width>
190
+ <img_width translate="label comment">
191
+ <label>Gallery preview maximum width</label>
192
+ <comment><![CDATA[Recommended: Your layout proportion to gallery preview maximum height eg. <strong>600px</strong>]]></comment>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>20</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>0</show_in_website>
197
+ <show_in_store>0</show_in_store>
198
+ </img_width>
199
+ <img_height translate="label comment">
200
+ <label>Gallery preview maximum height</label>
201
+ <comment><![CDATA[Recommended: <strong>300px</strong>]]></comment>
202
+ <frontend_type>text</frontend_type>
203
+ <sort_order>25</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>0</show_in_website>
206
+ <show_in_store>0</show_in_store>
207
+ </img_height>
208
+ <border_color translate="label comment">
209
+ <label>Gallery border color</label>
210
+ <comment><![CDATA[Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders]]></comment>
211
+ <frontend_type>text</frontend_type>
212
+ <sort_order>30</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>0</show_in_website>
215
+ <show_in_store>0</show_in_store>
216
+ </border_color>
217
+
218
+ <img_width_zoom translate="label comment">
219
+ <label>Internal zoom image width</label>
220
+ <comment><![CDATA[Recommended: <strong>1024px</strong>]]></comment>
221
+ <frontend_type>text</frontend_type>
222
+ <sort_order>60</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>0</show_in_website>
225
+ <show_in_store>0</show_in_store>
226
+ </img_width_zoom>
227
+ <img_height_zoom translate="label comment">
228
+ <label>Internal zoom image height</label>
229
+ <comment><![CDATA[Recommended: <strong>768px</strong>]]></comment>
230
+ <frontend_type>text</frontend_type>
231
+ <sort_order>70</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>0</show_in_website>
234
+ <show_in_store>0</show_in_store>
235
+ </img_height_zoom>
236
+
237
+ <scroll translate="label comment">
238
+ <label>Thumbnails scroll type</label>
239
+ <comment><![CDATA[Enable or disable thumbnails scroll]]></comment>
240
+ <frontend_type>select</frontend_type>
241
+ <source_model>Orbitvu_Sun_Block_Scroll</source_model>
242
+ <sort_order>78</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>0</show_in_website>
245
+ <show_in_store>0</show_in_store>
246
+ </scroll>
247
+
248
+ <img_width_tn translate="label comment">
249
+ <label>Thumbnail width</label>
250
+ <comment><![CDATA[Recommended: <strong>75px</strong>]]></comment>
251
+ <frontend_type>text</frontend_type>
252
+ <sort_order>80</sort_order>
253
+ <show_in_default>1</show_in_default>
254
+ <show_in_website>0</show_in_website>
255
+ <show_in_store>0</show_in_store>
256
+ </img_width_tn>
257
+ <img_height_tn translate="label comment">
258
+ <label>Thumbnail height</label>
259
+ <comment><![CDATA[Recommended: <strong>50px</strong>]]></comment>
260
+ <frontend_type>text</frontend_type>
261
+ <sort_order>90</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>0</show_in_website>
264
+ <show_in_store>0</show_in_store>
265
+ </img_height_tn>
266
+ <img_tn_margin translate="label comment">
267
+ <label>Thumbnail margin</label>
268
+ <comment><![CDATA[Recommended: <strong>3px</strong>]]></comment>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>100</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>0</show_in_website>
273
+ <show_in_store>0</show_in_store>
274
+ </img_tn_margin>
275
+
276
+ <img_tn_padding translate="label comment">
277
+ <label>Thumbnail padding</label>
278
+ <comment><![CDATA[Recommended: <strong>0px</strong>]]></comment>
279
+ <frontend_type>text</frontend_type>
280
+ <sort_order>100</sort_order>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>0</show_in_website>
283
+ <show_in_store>0</show_in_store>
284
+ </img_tn_padding>
285
+
286
+ <button_width translate="label comment">
287
+ <label>Button prev/next width</label>
288
+ <comment><![CDATA[Recommended: <strong>30px</strong>]]></comment>
289
+ <frontend_type>text</frontend_type>
290
+ <sort_order>110</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>0</show_in_website>
293
+ <show_in_store>0</show_in_store>
294
+ </button_width>
295
+ <button_height translate="label comment">
296
+ <label>Button prev/next height</label>
297
+ <comment><![CDATA[Recommended: <strong>53px</strong>]]></comment>
298
+ <frontend_type>text</frontend_type>
299
+ <sort_order>120</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>0</show_in_website>
302
+ <show_in_store>0</show_in_store>
303
+ </button_height>
304
+ <button_opacity translate="label comment">
305
+ <label>Button prev/next opacity</label>
306
+ <comment><![CDATA[1 = 100% (recommended), 0.5 = 50%, 0 = 0%]]></comment>
307
+ <frontend_type>text</frontend_type>
308
+ <sort_order>130</sort_order>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>0</show_in_website>
311
+ <show_in_store>0</show_in_store>
312
+ </button_opacity>
313
+ </fields>
314
+
315
+ </layout>
316
+ </groups>
317
+ </orbitvu>
318
+ </sections>
319
  </config>
app/code/community/Orbitvu/Sun/etc/translations.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <translations>
5
- <active>true</active>
6
- <codepool>local</codepool>
7
- </translations>
8
- </modules>
9
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <translations>
5
+ <active>true</active>
6
+ <codepool>local</codepool>
7
+ </translations>
8
+ </modules>
9
  </config>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.0.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.1.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.10.php CHANGED
@@ -1,24 +1,24 @@
1
-
2
- <?php
3
- /**
4
- * Orbitvu PHP eCommerce Orbitvu DB drivers
5
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
- *
7
- * @For: Magento
8
- */
9
-
10
- /*
11
- * Start installation
12
- */
13
-
14
- $installer = $this;
15
- $installer->startSetup();
16
-
17
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
- include_once($inc);
19
-
20
- $_Orbitvu = new OrbitvuAdmin(false);
21
- $_Orbitvu->Install();
22
-
23
- $installer->endSetup();
24
  ?>
1
+
2
+ <?php
3
+ /**
4
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
5
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
+ *
7
+ * @For: Magento
8
+ */
9
+
10
+ /*
11
+ * Start installation
12
+ */
13
+
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
+ include_once($inc);
19
+
20
+ $_Orbitvu = new OrbitvuAdmin(false);
21
+ $_Orbitvu->Install();
22
+
23
+ $installer->endSetup();
24
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.2.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.3.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.4.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.5.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.6.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.7.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
- include_once($inc);
18
-
19
- $_Orbitvu = new OrbitvuAdmin(false);
20
- $_Orbitvu->Install();
21
-
22
- $installer->endSetup();
23
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
17
+ include_once($inc);
18
+
19
+ $_Orbitvu = new OrbitvuAdmin(false);
20
+ $_Orbitvu->Install();
21
+
22
+ $installer->endSetup();
23
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.8.php CHANGED
@@ -1,24 +1,24 @@
1
-
2
- <?php
3
- /**
4
- * Orbitvu PHP eCommerce Orbitvu DB drivers
5
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
- *
7
- * @For: Magento
8
- */
9
-
10
- /*
11
- * Start installation
12
- */
13
-
14
- $installer = $this;
15
- $installer->startSetup();
16
-
17
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
- include_once($inc);
19
-
20
- $_Orbitvu = new OrbitvuAdmin(false);
21
- $_Orbitvu->Install();
22
-
23
- $installer->endSetup();
24
  ?>
1
+
2
+ <?php
3
+ /**
4
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
5
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
+ *
7
+ * @For: Magento
8
+ */
9
+
10
+ /*
11
+ * Start installation
12
+ */
13
+
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
+ include_once($inc);
19
+
20
+ $_Orbitvu = new OrbitvuAdmin(false);
21
+ $_Orbitvu->Install();
22
+
23
+ $installer->endSetup();
24
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-install-1.0.9.php CHANGED
@@ -1,24 +1,24 @@
1
-
2
- <?php
3
- /**
4
- * Orbitvu PHP eCommerce Orbitvu DB drivers
5
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
- *
7
- * @For: Magento
8
- */
9
-
10
- /*
11
- * Start installation
12
- */
13
-
14
- $installer = $this;
15
- $installer->startSetup();
16
-
17
- $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
- include_once($inc);
19
-
20
- $_Orbitvu = new OrbitvuAdmin(false);
21
- $_Orbitvu->Install();
22
-
23
- $installer->endSetup();
24
  ?>
1
+
2
+ <?php
3
+ /**
4
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
5
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
6
+ *
7
+ * @For: Magento
8
+ */
9
+
10
+ /*
11
+ * Start installation
12
+ */
13
+
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ $inc = Mage::getBaseDir('app').'/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php';
18
+ include_once($inc);
19
+
20
+ $_Orbitvu = new OrbitvuAdmin(false);
21
+ $_Orbitvu->Install();
22
+
23
+ $installer->endSetup();
24
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.0-1.0.1.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.1-1.0.2.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.10-1.0.11.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.11-1.0.12.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
+ ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.2-1.0.3.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.3-1.0.4.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.4-1.0.5.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.5-1.0.6.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->run("INSERT IGNORE INTO {$this->getTable('core_config_data')} (`path`, `value`) VALUES ('orbitvu/layout/scroll', 'yes')");
17
- $installer->run("INSERT IGNORE INTO {$this->getTable('core_config_data')} (`path`, `value`) VALUES ('orbitvu/layout/img_tn_padding', '2px')");
18
- $installer->run("INSERT IGNORE INTO {$this->getTable('orbitvu_configuration')} (`var`, `value`, `type`, `info`) VALUES ('scroll', 'yes', 'layout', '')");
19
- $installer->run("INSERT IGNORE INTO {$this->getTable('orbitvu_configuration')} (`var`, `value`, `type`, `info`) VALUES ('img_tn_padding', '2px', 'layout', '')");
20
-
21
- $installer->endSetup();
22
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->run("INSERT IGNORE INTO {$this->getTable('core_config_data')} (`path`, `value`) VALUES ('orbitvu/layout/scroll', 'yes')");
17
+ $installer->run("INSERT IGNORE INTO {$this->getTable('core_config_data')} (`path`, `value`) VALUES ('orbitvu/layout/img_tn_padding', '2px')");
18
+ $installer->run("INSERT IGNORE INTO {$this->getTable('orbitvu_configuration')} (`var`, `value`, `type`, `info`) VALUES ('scroll', 'yes', 'layout', '')");
19
+ $installer->run("INSERT IGNORE INTO {$this->getTable('orbitvu_configuration')} (`var`, `value`, `type`, `info`) VALUES ('img_tn_padding', '2px', 'layout', '')");
20
+
21
+ $installer->endSetup();
22
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.6-1.0.7.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.7-1.0.8.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.8-1.0.9.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/code/community/Orbitvu/Sun/sql/sun_setup/mysql4-upgrade-1.0.9-1.0.10.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Orbitvu PHP eCommerce Orbitvu DB drivers
4
- * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
- *
6
- * @For: Magento
7
- */
8
-
9
- /*
10
- * Start installation
11
- */
12
-
13
- $installer = $this;
14
- $installer->startSetup();
15
-
16
- $installer->endSetup();
17
  ?>
1
+ <?php
2
+ /**
3
+ * Orbitvu PHP eCommerce Orbitvu DB drivers
4
+ * @Copyright: Orbitvu Sp. z o.o. is the owner of full rights to this code
5
+ *
6
+ * @For: Magento
7
+ */
8
+
9
+ /*
10
+ * Start installation
11
+ */
12
+
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $installer->endSetup();
17
  ?>
app/design/adminhtml/default/default/template/sun/orbitvu.phtml CHANGED
@@ -1,1470 +1,1498 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- *
9
- * From file author: I don't know is there any better way to create a layout.
10
- * Every Magento layout is mixed with PHP code, so I will do the same.
11
- */
12
-
13
- $__templates = array(
14
- //-------------------------------------------------------------------------------------------------------
15
- 'presentation_item' =>
16
- //-------------------------------------------------------------------------------------------------------
17
- '
18
- <div class="orbitvu_sun_presentation"{parameters}>
19
- <img src="{image_path}?width=100&amp;height=80&amp;action=crop" alt="">
20
- <div class="presentation_data">
21
- <strong>{name}</strong><br>
22
- '.$this->__('SKU').': <strong>{sku}</strong><br>
23
- <div class="presentation_types">
24
- <strong>{types}</strong>
25
- </div>
26
- </div>
27
- </div>
28
- ',
29
- //-------------------------------------------------------------------------------------------------------
30
- 'magento_section_start' =>
31
- //-------------------------------------------------------------------------------------------------------
32
- '
33
- <div class="entry-edit">
34
- <div class="entry-edit-head">
35
- <h4 class="icon-head head-edit-form fieldset-legend">{name}</h4>
36
- </div>
37
- <fieldset>
38
- <legend>{name}</legend>
39
- <div class="hor-scroll">
40
- ',
41
- //-------------------------------------------------------------------------------------------------------
42
- 'magento_section_end' =>
43
- //-------------------------------------------------------------------------------------------------------
44
- '
45
- </div>
46
- </fieldset>
47
- </div>
48
- '
49
-
50
- );
51
-
52
- /*
53
- * Get the SUN class
54
- */
55
- //-------------------------------------------------------------------------------------------------------
56
- $observer = Mage::getSingleton('sun/observer');
57
- $_Orbitvu = $observer->ExtendOrbitvu();
58
- $orbitvu_connected = $_Orbitvu->IsConnected();
59
- $orbitvu_demo = $_Orbitvu->IsDemo();
60
- //-------------------------------------------------------------------------------------------------------
61
-
62
- /*
63
- * Get Mage requests
64
- */
65
- //-------------------------------------------------------------------------------------------------------
66
- $request = Mage::app()->getRequest();
67
- $product_id = $request->getParam('id');
68
- //-------------------------------------------------------------------------------------------------------
69
-
70
- /*
71
- * Display nothing when product is not add yet
72
- */
73
- //-------------------------------------------------------------------------------------------------------
74
- if (empty($product_id)) {
75
- return '';
76
- }
77
- //-------------------------------------------------------------------------------------------------------
78
-
79
- /*
80
- * Declarations
81
- */
82
- //-------------------------------------------------------------------------------------------------------
83
- $_action = $request->getParam('sun');
84
- $_messages = array();
85
- $cookie = Mage::getSingleton('core/cookie');
86
- //-------------------------------------------------------------------------------------------------------
87
- $CurrentProduct = Mage::registry('current_product');
88
- $product_name = $CurrentProduct->getName();
89
- $product_sku = $CurrentProduct->getSku();
90
- //-------------------------------------------------------------------------------------------------------
91
-
92
- /*
93
- * Pagination
94
- */
95
- //-------------------------------------------------------------------------------------------------------
96
- $OrbitvuCurrentPage = intval($request->getParam('pager_start')) > 0 ? intval($request->getParam('pager_start')) : 0;
97
- //-------------------------------------------------------------------------------------------------------
98
- if ($request->getParam('page_size') > 0) {
99
- $cookie->set('page_size', $request->getParam('page_size'), time()+3600*24*7);
100
- $OrbitvuPagerPageSize = intval($request->getParam('page_size'));
101
- }
102
- else if ($cookie->get('page_size') > 0) {
103
- $OrbitvuPagerPageSize = intval($cookie->get('page_size'));
104
- }
105
- else {
106
- $OrbitvuPagerPageSize = 50;
107
- }
108
- //-------------------------------------------------------------------------------------------------------
109
- if ($request->getParam('sun_ordering') != '') {
110
- $cookie->set('sun_ordering', $request->getParam('sun_ordering'), time()+3600*24*7);
111
- $OrbitvuOrdering = $request->getParam('sun_ordering');
112
- }
113
- else if ($cookie->get('sun_ordering') > 0) {
114
- $OrbitvuOrdering = $cookie->get('sun_ordering');
115
- }
116
- else {
117
- $OrbitvuOrdering = '-create_date';
118
- }
119
- //-------------------------------------------------------------------------------------------------------
120
- if ($request->getParam('sun_keyword')) {
121
- $cookie->set('sun_keyword', $request->getParam('sun_keyword'), time()+3600);
122
- $OrbitvuKeyword = $request->getParam('sun_keyword');
123
- }
124
- else if ($cookie->get('sun_keyword') != '') {
125
- $OrbitvuKeyword = $cookie->get('sun_keyword');
126
- }
127
- else {
128
- $OrbitvuKeyword = '';
129
- }
130
- //-------------------------------------------------------------------------------------------------------
131
- if ($request->getParam('sun_keyword_reset')) {
132
- $cookie->delete('sun_keyword');
133
- $OrbitvuKeyword = '';
134
- }
135
- //-------------------------------------------------------------------------------------------------------
136
-
137
- /*
138
- * Actions switcher
139
- */
140
- //-------------------------------------------------------------------------------------------------------
141
- if ($_action == 'set_presentation' && $request->getParam('presentation_id') > 0) {
142
- $cur_pres = $_Orbitvu->GetPresentationsList(array('id' => intval($request->getParam('presentation_id'))));
143
- $_Orbitvu->SynchronizeProductPresentation($product_id, intval($request->getParam('presentation_id')), $cur_pres->results[0]->name);
144
- $_Orbitvu->SetSunPresentationSku(intval($request->getParam('presentation_id')), $product_sku, $cur_pres->results[0]->sku);
145
- //$observer->UpdateThumbnails($product_id);
146
-
147
- $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
148
- }
149
- else if ($_action == 'unlink') {
150
- $_Orbitvu->FreeProduct($product_id);
151
- $observer->UpdateThumbnails($product_id);
152
- $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/message/unlinked/');
153
- }
154
- else if ($_action == 'update_priority' && $request->getParam('sun_item_id') > 0 && $request->getParam('sun_priority')) {
155
- $_Orbitvu->UpdatePresentationItemPriority(
156
- intval($request->getParam('sun_item_id')),
157
- intval($request->getParam('sun_priority'))
158
- );
159
- //$observer->UpdateThumbnails($product_id);
160
- $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
161
- }
162
- else if ($_action == 'set_sku' && $request->getParam('presentation_id') > 0 && $request->getParam('sun_new_sku') != '') {
163
- $sun_response = $_Orbitvu->SetSunPresentationSku(intval($request->getParam('presentation_id')), $request->getParam('sun_new_sku'), '', true);
164
- if ($sun_response->error == '400') {
165
- $_messages[] = array('error', $this->__('One of your presentations already has this SKU assigned. SKU need to be unique. Modify SKU on your SUN Server and try again.'));
166
- }
167
- else {
168
- $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
169
- }
170
- }
171
- /*
172
- * Ajax actions
173
- */
174
- else if ($_action == 'update_status' && $request->getParam('sun_item_id') > 0) {
175
- if ($request->getParam('sun_status') == 'active') $sun_status = 'active';
176
- else $sun_status = 'inactive';
177
-
178
- $_Orbitvu->UpdatePresentationItemStatus(intval($request->getParam('sun_item_id')), $sun_status);
179
- //$observer->UpdateThumbnails($product_id);
180
- echo '200 OK';
181
- exit();
182
- //$observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
183
- }
184
- else if ($_action == 'update_order' && $request->getParam('sun_item_id') > 0 && $request->getParam('sun_before_item_id') > 0) {
185
- $_Orbitvu->SwitchPresentationItemPriority(
186
- $product_id,
187
- intval($request->getParam('sun_item_id')),
188
- intval($request->getParam('sun_before_item_id'))
189
- );
190
- //$observer->UpdateThumbnails($product_id);
191
- echo '200 OK';
192
- exit();
193
- //$observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
194
- } else if ($_action == 'update_statuses' && $request->getParam('sun_items_statuses')) {
195
- $ids = explode(",", $request->getParam('sun_items_statuses'));
196
- if ($request->getParam('sun_status') == 'active') {
197
- $sun_status = 'active';
198
- } else {
199
- $sun_status = 'inactive';
200
- }
201
-
202
- if ($ids) {
203
- foreach($ids as $id) {
204
- $_Orbitvu->UpdatePresentationItemStatus(intval($id), $sun_status);
205
- }
206
- }
207
- die(json_encode(array('status' => true, 'sun_status' => $sun_status)));
208
- }
209
- //-------------------------------------------------------------------------------------------------------
210
-
211
- /*
212
- * Scheduled actions
213
- */
214
- //-------------------------------------------------------------------------------------------------------
215
- if (date('Y-m-d', strtotime($_Orbitvu->GetConfiguration('last_refreshed'))) != date('Y-m-d') || $_action == 'synchronize_items') {
216
- $_Orbitvu->SynchronizePresentationsItems();
217
- }
218
- //-------------------------------------------------------------------------------------------------------
219
-
220
- /*
221
- * User is connected?
222
- */
223
- //-------------------------------------------------------------------------------------------------------
224
- if (!$orbitvu_connected) {
225
- $_messages[] = array('error', $this->__('Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.').' <button type="button" class="orbitvu-button scalable"><a href="'.$this->getUrl('*/system_config/edit/section/orbitvu/').'" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Update your key').'</span></span></span></a></button>');
226
- }
227
- //-------------------------------------------------------------------------------------------------------
228
-
229
- /*
230
- * User is demo?
231
- */
232
- //-------------------------------------------------------------------------------------------------------
233
- if ($orbitvu_demo) {
234
- $_messages[] = array('error', $this->__('Orbitvu extension is connected to DEMO account. Register Orbitvu SUN FREE trial account to create your own presentations.').' <button type="button" class="orbitvu-button scalable"><a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Get free trial').'</span></span></span></a></button>');
235
- }
236
- //-------------------------------------------------------------------------------------------------------
237
-
238
- /*
239
- * User is demo?
240
- */
241
- //-------------------------------------------------------------------------------------------------------
242
- if ($up = $_Orbitvu->CheckForUpdates()) {
243
- $_messages[] = array('notice', $this->__('Version').' '.$up->new_version.' '.$this->__('of Orbitvu extension is out!').' <button type="button" class="orbitvu-button scalable"><a href="http://www.magentocommerce.com/magento-connect/orbitvu-sun-product-teleporting-image-gallery.html" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Upgrade now from').' '.$up->version.' '.$this->__('to').' '.$up->new_version.'</span></span></span></a></button>');
244
- }
245
- //-------------------------------------------------
246
-
247
- /*
248
- * Check if product has a presentation set
249
- */
250
- //-------------------------------------------------------------------------------------------------------
251
- $presentations = $_Orbitvu->GetProductPresentation($product_id);
252
- //-------------------------------------------------------------------------------------------------------
253
- $items_count = count($presentations['items']);
254
- $found_match = false;
255
- //-------------------------------------------------------------------------------------------------------
256
-
257
- /*
258
- * No? Find one!
259
- */
260
- //-------------------------------------------------------------------------------------------------------
261
- if ($items_count == 0) {
262
- //-------------------------------------------------------------------------------------------------------
263
- $auto_sync = $_Orbitvu->GetConfiguration('auto_sync');
264
- $unlinked_before = false;
265
- //-------------------------------------------------------------------------------------------------------
266
-
267
- /*
268
- * Find match
269
- */
270
- //-------------------------------------------------------------------------------------------------------
271
- if ($_action != 'set_show_all') {
272
- $presentations_choose = $_Orbitvu->MatchPresentation(array(
273
- 'product_name' => $product_name,
274
- 'product_sku' => $product_sku
275
- ));
276
-
277
- /*
278
- * Do not link again, if auto_sync
279
- */
280
- //-------------------------------------------------------------------------------------------------------
281
- if ($presentations_choose->count > 0) {
282
- //-------------------------------------------------------------------------------------------------------
283
- $presentation_id = intval($presentations_choose->results[0]->id);
284
- //-------------------------------------------------------------------------------------------------------
285
- if ($_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
286
- $presentations_choose->count = 0;
287
- $auto_sync = 'false';
288
- $found_match = false;
289
- $unlinked_before = true;
290
- }
291
- }
292
- //-------------------------------------------------------------------------------------------------------
293
- }
294
- //-------------------------------------------------------------------------------------------------------
295
-
296
- /*
297
- * Not found? Show all
298
- */
299
- //-------------------------------------------------------------------------------------------------------
300
- if ($presentations_choose->count == 0 || $_action == 'set_show_all') {
301
- if ($_action != 'set_show_all') {
302
- if ($unlinked_before) {
303
- //$_messages[] = array('error', $this->__('We matched the presentation, but it was unlinked before and we don\'t link it automatically. You have to select a presentation on your own.'));
304
- }
305
- else {
306
- //$_messages[] = array('error', $this->__('We did not match this product to any of your Orbitvu SUN presentations. Make sure you have identical presentation name or SKU as your product or choose one of presentations displayed below.'));
307
- }
308
- }
309
- if ($request->getParam('message') == 'unlinked') {
310
- $_messages[] = array('success', $this->__('Your presentation has been unlinked. You can select a new one below.'));
311
- }
312
-
313
- $sun_params = array(
314
- 'page_size' => $OrbitvuPagerPageSize,
315
- 'page' => $OrbitvuCurrentPage + 1,
316
- 'ordering' => $OrbitvuOrdering
317
- );
318
-
319
- if (!empty($OrbitvuKeyword)) {
320
- $sun_params['search'] = $OrbitvuKeyword;
321
- $sun_params['page'] = 1;
322
- }
323
-
324
- $presentations_choose = $_Orbitvu->GetPresentationsList($sun_params);
325
- }
326
- //-------------------------------------------------------------------------------------------------------
327
- /*
328
- * Found match? Display info
329
- */
330
- //-------------------------------------------------------------------------------------------------------
331
- else {
332
- //-------------------------------------------------------------------------------------------------------
333
- $found_match = true;
334
- $presentation_unlinked = false;
335
- //-------------------------------------------------------------------------------------------------------
336
- $presentation_id = intval($presentations_choose->results[0]->id);
337
-
338
- /*if ($_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
339
- $_messages[] = array('error', $this->__('We matched the presentation, but it was unlinked before and we don\'t set it automatically. You have to select a presentation on your own.'));
340
- }*/
341
- //-------------------------------------------------------------------------------------------------------
342
-
343
- if ($auto_sync == 'true') {
344
- //-------------------------------------------------------------------------------------------------------
345
- if (!$_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
346
- $_Orbitvu->SynchronizeProductPresentation($product_id, $presentation_id, $presentations_choose->results[0]->name);
347
- $_Orbitvu->SetSunPresentationSku($presentation_id, $product_sku, $presentations_choose->results[0]->sku);
348
- //$observer->UpdateThumbnails($product_id);
349
-
350
- $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_group_tab/');
351
- }
352
- //-------------------------------------------------------------------------------------------------------
353
- }
354
- else {
355
- //-------------------------------------------------------------------------------------------------------
356
- $types = $_Orbitvu->GetPresentationTypes($presentations_choose->results[0]);
357
- $new_types = array();
358
- foreach ($types as $type) {
359
- switch ($type) {
360
- case '0':
361
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0" title="'.$this->__('Orbittour').'"></span>';
362
- break;
363
- case '1':
364
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1" title="'.$this->__('360&deg;').'"></span>';
365
- break;
366
- default:
367
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3" title="'.$this->__('2D').'"></span>';
368
- break;
369
- }
370
- }
371
- $types = $new_types;
372
- //-------------------------------------------------------------------------------------------------------
373
- $str = $presentations_choose->results[0]->name;
374
- if (strlen($str) > 15 ) $str = '<span title="'.Sstr.'">'.mb_substr($str, 0, 15, 'utf-8').'...</span>';
375
- //-------------------------------------------------------------------------------------------------------
376
- $sku = $presentations_choose->results[0]->sku;
377
- //-------------------------------------------------------------------------------------------------------
378
- if (!empty($sku)) {
379
- if (strlen($sku) > 10 ) {
380
- $sku = '<span title="'.$sku.'">'.mb_substr($sku, 0, 10, 'utf-8').'...</span>';
381
- }
382
- }
383
- else {
384
- $sku = '-';
385
- }
386
- //-------------------------------------------------------------------------------------------------------
387
- $_messages[] = array('success', '<div style="clear: both; overflow: hidden; zoom: 1.0;">
388
-
389
- '.$this->__('We used your product\'s SKU:').' "'.$product_sku.'" '.$this->__('and name:').' "'.$product_name.'" '.$this->__('to match one of your SUN presentations.').'
390
- </div>
391
- <div class="orbitvu_clearfix">
392
- '.$observer->UseTemplate(array(
393
- 'parameters' => 'onclick="OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$presentations_choose->results[0]->id.'/\');"',
394
- 'image_path' => $presentations_choose->results[0]->thumbnail_url,
395
- 'name' => $str,
396
- 'sku' => $sku,
397
- 'types' => implode('', $types)
398
-
399
- ), $__templates['presentation_item']).'
400
-
401
- <div style="float: left; margin: 35px 0 0 10px;">
402
- <button type="button" class="orbitvu-button orbitvu-button-link scalable" onclick="OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$presentations_choose->results[0]->id.'/\');" style=""><span><span></span>'.$this->__('Link this presentation').'</span></button>
403
- <div style="clear: both; overflow: hidden; zoom: 1.0; margin-top: 10px;">
404
- <button type="button" class="orbitvu-button-ok scalable back" onclick="OrbitvuSetAction(\'sun/set_show_all/\');" style=""><span style="background-image: none; padding: 0;"><span></span>'.$this->__('Select another one').'</span></button>
405
- </div>
406
- </div>
407
- </div>
408
- ');
409
- //-------------------------------------------------------------------------------------------------------
410
- }
411
- }
412
- //-------------------------------------------------------------------------------------------------------
413
- }
414
- //--------------------------------------------------------------------------------------------------------------------------------------
415
- ?>
416
- <style type="text/css">
417
- .orbitvu_sun_presentation, .orbitvu_sun_presentation_full { float: left; width: 250px; background: white; border: 1px solid #dedede; border-radius: 5px; margin: 10px 10px 0 0; padding: 10px; cursor: pointer; }
418
- .orbitvu_sun_presentation_full { float: none; width: 100%; clear: both; overflow: hidden; zoom: 1.0; cursor: default; box-sizing: border-box; }
419
- .orbitvu_sun_presentation { border: 2px solid #1CA0B3; }
420
-
421
- .orbitvu_sun_presentation_full table { width: 100%; margin: 0; padding: 0; border: 0; }
422
- .orbitvu_sun_presentation_full table td { padding: 0; vertical-align: top; border: 0; background: white; }
423
- .orbitvu_sun_presentation:hover { box-shadow: 0 0 15px black; }
424
- .orbitvu_sun_presentation.orbitvu_nohover, .orbitvu_nohover { margin: 0 0 20px 0; border-color: #dedede; box-shadow: none; cursor: default; }
425
- .orbitvu_sun_presentation img { float: left; width: 100px; height: 80px; margin: 0 10px 0 0; border-radius: 5px; }
426
- .orbitvu_sun_presentation .presentation_data { float: left; min-height: 80px; color: black; font-weight: normal; position: relative; }
427
- .orbitvu_clearfix { clear: both; overflow: hidden; zoom: 1.0; }
428
-
429
- .orbitvu-button, .orbitvu-button-disabled { border-color: #1191A6; background: #8dd5e0; background: -moz-linear-gradient(top, #8dd5e0 0%, #009cb5 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8dd5e0), color-stop(45%,#009cb5)); background: -webkit-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -o-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -ms-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: linear-gradient(to bottom, #8dd5e0 0%,#009cb5 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8dd5e0', endColorstr='#009cb5',GradientType=0 ); }
430
- .orbitvu-button:hover { background: #ddfaff; background: -moz-linear-gradient(top, #ddfaff 0%, #15adc6 59%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ddfaff), color-stop(59%,#15adc6)); background: -webkit-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: -o-linear-gradient(top, #ddfaff 0%,#15adc6 59%);background: -ms-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: linear-gradient(to bottom, #ddfaff 0%,#15adc6 59%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ddfaff', endColorstr='#15adc6',GradientType=0 ); }
431
- .orbitvu-icon { background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/blue.png); background-repeat: no-repeat; }
432
- .orbitvu-icon-visibility { background-position: 0 -54px; }
433
- .orbitvu-icon-visibility.disabled { background-position: -22px -54px; }
434
- .orbitvu-icon-type-0 { background-position: 0 -92px; }
435
- .orbitvu-icon-type-1 { background-position: -80px -108px; }
436
- .orbitvu-icon-type-3 { background-position: -16px -92px; }
437
- .orbitvu-drag-container { clear: both; overflow: hidden; zoom: 1.0; padding: 10px; }
438
- .orbitvu-drag-box { float: left; margin: 0 10px 10px 0; width: 100px; height: 100px; position: relative; border: 2px solid #1CA0B3; font-size: 10px; cursor: default; font-family: verdana, tahoma, arial; background-color: #eee; border-radius: 5px; }
439
- #orbitvu-drag-container .orbitvu-drag-box { cursor: pointer; }
440
- .orbitvu-drag-box.hidden { border-color: #F1D6DA; opacity: 0.7; }
441
- .orbitvu-drag-box.drag { opacity: 0.2; }
442
- #orbitvu-drag-container .orbitvu-drag-box:hover { border-style: dashed; }
443
- .orbitvu-drag-box span.orbitvu-text { padding: 2px 0 2px 0; position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; color: white; background: #1CA0B3; font-size: 10px; }
444
-
445
- .orbitvu-drag-box span.orbitvu-drag-text { display: none; }
446
- #orbitvu-drag-container .orbitvu-drag-box:hover span.orbitvu-drag-text { display: block; }
447
- .orbitvu-drag-box span.orbitvu-hide-text { display: none; }
448
- .orbitvu-drag-box span.orbitvu-hide-text.active { display: block; }
449
- .orbitvu-drag-box span.orbitvu-show-text { display: none; }
450
- .orbitvu-drag-box span.orbitvu-show-text.active { display: block; }
451
- .orbitvu-drag-box span.orbitvu-visibility { display: block; width: 22px; height: 22px; position: absolute; top: -7px; right: -7px; background-color: white; border-radius: 8px; cursor: pointer; }
452
- .orbitvu-drag-box span.orbitvu-visibility:hover { box-shadow: 0 0 5px black; }
453
-
454
- .orbitvu-drag-box span.orbitvu-type { display: block; width: 16px; height: 16px; position: absolute; bottom: 2px; right: 2px; }
455
-
456
- .orbitvu-button-sku { border-color: #CA6875; background: #e0b3b8; background: -moz-linear-gradient(top, #e0b3b8 0%, #ca4759 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e0b3b8), color-stop(45%,#ca4759)); background: -webkit-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: -o-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: -ms-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: linear-gradient(to bottom, #e0b3b8 0%,#ca4759 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0b3b8', endColorstr='#ca4759',GradientType=0 ); }
457
- .orbitvu-button-sku:hover { background: #ffced3;background: -moz-linear-gradient(top, #ffced3 0%, #e8475d 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffced3), color-stop(45%,#e8475d)); background: -webkit-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: -o-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: -ms-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: linear-gradient(to bottom, #ffced3 0%,#e8475d 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffced3', endColorstr='#e8475d',GradientType=0 ); }
458
- button.orbitvu-button-sku span span,
459
- button.orbitvu-button-edit span span,
460
- button.orbitvu-button-sync span span,
461
- button.orbitvu-button-unlink span span,
462
- button.orbitvu-button-link span span,
463
- button.orbitvu-button-ok span span,
464
- button.orbitvu-button-enable-items span span,
465
- button.orbitvu-button-disable-items span span,
466
- button.orbitvu-button-cancel span span { float: left; width: 16px; height: 16px; margin: 0 4px 0 0 !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/white.png) !important; background-repeat: no-repeat; }
467
-
468
- button.orbitvu-button-sku span span { background-position: -32px -108px !important; }
469
- button.orbitvu-button-edit span span { background-position: -48px -108px !important; }
470
- button.orbitvu-button-sync span span { background-position: -64px -108px !important; }
471
- button.orbitvu-button-unlink span span { background-position: -16px -108px !important; }
472
- button.orbitvu-button-enable-items span span { background-position: 0px -76px !important; }
473
- button.orbitvu-button-disable-items span span { background-position: -16px -76px !important; }
474
- button.orbitvu-button-link span span { background-position: 0 -108px !important; }
475
- button.orbitvu-button-ok span span { background-position: -32px -76px !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png) !important; }
476
- button.orbitvu-button-cancel span span { background-position: -48px -76px !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png) !important; }
477
- button.orbitvu-button-disabled { opacity: 0.5; cursor: default; }
478
- button.orbitvu-button-disabled:hover, button.orbitvu-button-disabled.active { background: url(<?=$this->getSkinUrl('images/btn_bg-disabled.gif')?>) 0px 0px repeat-x #919191 !important; opacity: 0.5 !important; }
479
- .dragstate span.orbitvu-visibility { display: none !important; }
480
-
481
- .presentation_types { width: 80px; position: absolute; bottom: 5px; left: 0; }
482
- .orbitvu-type { float: left; width: 16px; height: 16px; margin: 0 5px 0 0; }
483
-
484
- .orbitvu-icon-bg { background-color: white; border: 2px solid white; border-radius: 5px; }
485
- #orbitvu_postloader { display: none; }
486
- #orbitvu_postloader_bg { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 999998; background: white; opacity: 0.8; }
487
- #orbitvu_postloader_fg { position: fixed; width: 100%; top: 0; left: 0; z-index: 999999; text-align: center; }
488
- </style>
489
- <div id="orbitvu_postloader">
490
- <div id="orbitvu_postloader_bg"></div>
491
- <div id="orbitvu_postloader_fg"><img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" style="margin-top: 150px;" alt="" /></div>
492
- </div>
493
- <script>
494
- window.onbeforeunload = function() {
495
- document.getElementById('orbitvu_postloader').style.display = 'block';
496
- }
497
- </script>
498
- <div class="entry-edit orbitvu_clearfix">
499
-
500
- <?php if ($_action != 'set_show_all' && $found_match) {
501
- echo $observer->UseTemplate(array(
502
- 'name' => $this->__('Confirm linking matched presentation')
503
-
504
- ), $__templates['magento_section_start']);
505
-
506
- ?>
507
-
508
- <?php } ?>
509
- <input type="hidden" name="synchronize_sun" value="false" id="synchronize_sun" />
510
- <div id="orbitvu_sun_content">
511
- <ul class="messages">
512
- <?php for ($i = 0, $n = count($_messages); $i < $n; $i++) { ?>
513
- <li class="<?=$_messages[$i][0]?>-msg">
514
- <ul>
515
- <li>
516
- <?=$_messages[$i][1]?>
517
- </li>
518
- </ul>
519
- </li>
520
- <?php } ?>
521
- </ul>
522
- </div>
523
-
524
- </div>
525
- <?php
526
- //--------------------------------------------------------------------------------------------------------------------------------------
527
- /*
528
- * Show tabs if match not found
529
- */
530
- //-------------------------------------------------------------------------------------------------------------------------------------
531
- if (!$found_match) {
532
- ?>
533
- <div class="grid" id="local_magento">
534
- <?php
535
- }
536
- else {
537
- ?>
538
- <div style="display: none;">
539
- <?php
540
- }
541
- //--------------------------------------------------------------------------------------------------------------------------------------
542
- /*
543
- * First time presentation setting
544
- */
545
- //--------------------------------------------------------------------------------------------------------------------------------------
546
- if ($items_count == 0 && !$found_match) {
547
- //--------------------------------------------------------------------------------------------------------------------------------------
548
-
549
- if ($orbitvu_connected) {
550
- $results = $presentations_choose->results;
551
-
552
- $OrbitvuPager = array(
553
- 'start' => $OrbitvuCurrentPage,
554
- 'size' => $OrbitvuPagerPageSize,
555
- 'all' => intval(round($presentations_choose->count / $OrbitvuPagerPageSize))
556
- );
557
-
558
- $OrbitvuPager['url_next'] = $this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/pager_start/'.($OrbitvuPager['start'] + 1));
559
- $OrbitvuPager['url_prev'] = $this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/pager_start/'.($OrbitvuPager['start'] - 1));
560
-
561
- //--------------------------------------------------------------------------------------------------------------------------------------
562
- echo $observer->UseTemplate(array(
563
- 'name' => $this->__('Select presentation from your Orbitvu SUN account to link with product').' '.$product_name
564
- ), $__templates['magento_section_start']);
565
- //--------------------------------------------------------------------------------------------------------------------------------------
566
- ?>
567
- <table cellspacing="0" class="actions" style="width: 98%; margin: 0 0 0 10px;">
568
- <tbody>
569
- <tr>
570
- <td class="pager" style="width: 350px;">
571
- <?=$this->__('Page:')?>
572
-
573
- <?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']-1 >= 0) { ?>
574
- <a href="<?=$OrbitvuPager['url_prev']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_left.gif')?>" alt="" class="arrow"></a>
575
- <?php } else { ?>
576
- <img src="<?=$this->getSkinUrl('images/pager_arrow_left_off.gif')?>" alt="" class="arrow">
577
- <?php } ?>
578
-
579
- <strong><?=($OrbitvuPager['start']+1)?></strong>
580
-
581
- <?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']+1 < $OrbitvuPager['all']) { ?>
582
- <a href="<?=$OrbitvuPager['url_next']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_right.gif')?>" alt="" class="arrow"></a>
583
- <?php } else { ?>
584
- <img src="<?=$this->getSkinUrl('images/pager_arrow_right_off.gif')?>" alt="" class="arrow">
585
- <?php } ?>
586
-
587
- <?=$this->__('of')?> <?=$OrbitvuPager['all']?>
588
- <span class="separator">|</span>
589
- <?=$this->__('Per page:')?>
590
- <select name="pager_size" onchange="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>page_size/' + this.value + '/';">
591
- <option value="20"<?=($OrbitvuPager['size'] == '20' ? ' selected="selected"' : '')?>>20</option>
592
- <option value="30"<?=($OrbitvuPager['size'] == '30' ? ' selected="selected"' : '')?>>30</option>
593
- <option value="50"<?=($OrbitvuPager['size'] == '50' ? ' selected="selected"' : '')?>>50</option>
594
- <option value="100"<?=($OrbitvuPager['size'] == '100' ? ' selected="selected"' : '')?>>100</option>
595
- <option value="200"<?=($OrbitvuPager['size'] == '200' ? ' selected="selected"' : '')?>>200</option>
596
- </select>
597
- <span class="separator">|</span>
598
- <?=$this->__('Total:')?> <?=intval($presentations_choose->count)?>
599
- </td>
600
- <td class="filter-actions">
601
- <div class="orbitvu_filters">
602
- <select name="sun_ordering" style="width: 70px;" onchange="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_ordering/' + this.value + '/';">
603
- <option value="create_date"<?=($OrbitvuOrdering == 'create_date' ? ' selected="selected"' : '')?>><?=$this->__('Date')?> &uArr;</option>
604
- <option value="-create_date"<?=($OrbitvuOrdering == '-create_date' ? ' selected="selected"' : '')?>><?=$this->__('Date')?> &dArr;</option>
605
- <option value="sku"<?=($OrbitvuOrdering == 'sku' ? ' selected="selected"' : '')?>><?=$this->__('SKU')?> &uArr;</option>
606
- <option value="-sku"<?=($OrbitvuOrdering == '-sku' ? ' selected="selected"' : '')?>><?=$this->__('SKU')?> &dArr;</option>
607
- <option value="name"<?=($OrbitvuOrdering == 'name' ? ' selected="selected"' : '')?>><?=$this->__('Name')?> &uArr;</option>
608
- <option value="-name"<?=($OrbitvuOrdering == '-name' ? ' selected="selected"' : '')?>><?=$this->__('Name')?> &dArr;</option>
609
- </select>
610
- <input type="text" name="sun_search" id="orbitvu_sun_search" placeholder="<?=$this->__('Enter presentation name or SKU...')?>"<?php
611
- if (!empty($OrbitvuKeyword)) { echo ' value="'.$OrbitvuKeyword.'"'; }
612
- ?> size="30" />
613
- <button type="button" class="orbitvu-button scalable task" onclick="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_keyword/' + document.getElementById('orbitvu_sun_search').value + '/';"><span><span><span><?=$this->__('Search')?></span></span></span></button>
614
- <?php if (!empty($OrbitvuKeyword)) { ?>
615
- <button type="button" class="orbitvu-button scalable task" onclick="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_keyword_reset/true/';"><span><span><span><?=$this->__('Reset')?></span></span></span></button>
616
- <?php } ?>
617
- </div>
618
- </td>
619
- </tr>
620
- </tbody>
621
- </table>
622
-
623
-
624
- <div class="orbitvu_clearfix" style="padding: 10px;">
625
- <?php
626
- /*
627
- * Presentations final display
628
- */
629
- for ($i = 0, $n = count($results); $i < $n; $i++) {
630
- $cur = $results[$i];
631
-
632
- $types = $_Orbitvu->GetPresentationTypes($cur);
633
- $new_types = array();
634
- foreach ($types as $type) {
635
- switch ($type) {
636
- case '0':
637
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0" title="'.$this->__('Orbittour').'"></span>';
638
- break;
639
- case '1':
640
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1" title="'.$this->__('360&deg;').'"></span>';
641
- break;
642
- default:
643
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3" title="'.$this->__('2D').'"></span>';
644
- break;
645
- }
646
- }
647
- $types = $new_types;
648
-
649
- $sku = $cur->sku;
650
- //-------------------------------------------------------------------------------------------------------
651
- if (!empty($sku)) {
652
- if (strlen($sku) > 10) {
653
- $sku = '<span title="'.$sku.'">'.mb_substr($sku, 0, 10, 'utf-8').'...</span>';
654
- }
655
- }
656
- else {
657
- $sku = '-';
658
- }
659
- //-------------------------------------------------------------------------------------------------------
660
- $str = $cur->name;
661
- if (strlen($str) > 15 ) $str = mb_substr($str, 0, 15, 'utf-8').'...';
662
- //-------------------------------------------------------------------------------------------------------
663
- echo $observer->UseTemplate(array(
664
- 'parameters' => 'onclick="if (confirm(\''.$this->__('Do you really want to link this presentation with current product?').'\')) { OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$cur->id.'/\'); }"',
665
- 'image_path' => $cur->thumbnail_url,
666
- 'name' => $str,
667
- 'sku' => $sku,
668
- 'types' => implode('', $types)
669
- ), $__templates['presentation_item']);
670
- }
671
- ?>
672
- </div>
673
- <?php
674
- }
675
- else {
676
- //--------------------------------------------------------------------------------------------------------------------------------------
677
- echo $observer->UseTemplate(array(
678
- 'name' => $product_name
679
- ), $__templates['magento_section_start']);
680
- //--------------------------------------------------------------------------------------------------------------------------------------
681
- }
682
- }
683
- else {
684
- /*************************************************************************************************************************************************
685
- * Item edit
686
- ************************************************************************************************************************************************/
687
-
688
- $presentation_sun = $_Orbitvu->GetPresentationsList(array('id' => $presentations['orbitvu_id']));
689
- $presentation_sun = $presentation_sun->results[0];
690
-
691
- $sku = $presentation_sun->sku;
692
- //-------------------------------------------------------------------------------------------------------
693
- if (!empty($sku)) {
694
- $sku = '<span title="'.$sku.'">'.$sku.'</span>';
695
- }
696
- else {
697
- $sku = '-';
698
- }
699
- //--------------------------------------------------------------------------------------------------------------------------------------
700
- echo $observer->UseTemplate(array(
701
- 'name' => $this->__('Orbitvu SUN presentation linked to current product')
702
- ), $__templates['magento_section_start']);
703
- //--------------------------------------------------------------------------------------------------------------------------------------
704
- $add_buttons = '';
705
-
706
- $thumbnail = $presentations['items'][0]['thumbnail'];
707
- foreach ($presentations['items'] as $item) {
708
- if ($item['status'] == 'active') {
709
- $thumbnail = $item['thumbnail'];
710
- break;
711
- }
712
- }
713
- ?>
714
- <div class="orbitvu_sun_presentation_full">
715
- <table><td><td style="width: 1%;">
716
- <div style="position: relative;">
717
- <img src="<?=$thumbnail?>?height=200" style="margin: 0; padding: 0; border: 1px solid #dedede; border-radius: 5px;" alt="">
718
- <div style="position: absolute; bottom: 10px; right: 5px;">
719
- <?php
720
-
721
- $types = $presentations['types'];
722
- $new_types = array();
723
- foreach ($types as $type) {
724
- switch ($type) {
725
- case '0':
726
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0 orbitvu-icon-bg" title="'.$this->__('Orbittour').'"></span>';
727
- break;
728
- case '1':
729
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1 orbitvu-icon-bg" title="'.$this->__('360&deg;').'"></span>';
730
- break;
731
- default:
732
- $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3 orbitvu-icon-bg" title="'.$this->__('2D').'"></span>';
733
- break;
734
- }
735
- }
736
- $types = $new_types;
737
-
738
- print implode('', $types);
739
- ?>
740
- </div>
741
- </div>
742
- </td><td style="padding-left: 20px;">
743
-
744
- <div class="presentation_data">
745
- <strong style="font-size: 1.5em;"><?=$presentations['name']?></strong><br>
746
-
747
- <?php if ($presentation_sun->sku != $product_sku) {
748
- $update_sku = $_Orbitvu->SetSunPresentationSku($presentations['orbitvu_id'], $product_sku, $presentation_sun->sku);
749
-
750
- if (!$update_sku && $orbitvu_connected) {
751
-
752
- if (!$orbitvu_demo) {
753
- $add_buttons .= '<button type="button" class="orbitvu-button-sku scalable" onclick="if (confirm(\''.$this->__('Do you really want to update this presentation SKU on your Orbitvu SUN account?').'\')) { OrbitvuSetAction(\'sun/set_sku/presentation_id/'.$presentations['orbitvu_id'].'/sun_new_sku/'.$product_sku.'\'); }"><span><span></span>'.$this->__('Update SKU on SUN').'</span></button> ';
754
- }
755
- else {
756
- $add_buttons .= '<button type="button" class="orbitvu-button-sku scalable disabled orbitvu-button-disabled"><span><span></span>'.$this->__('Update SKU on SUN').'</span></button> ';
757
- }
758
- ?>
759
- <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
760
- <ul class="messages" style="float: left; max-width: 680px;">
761
- <li class="error-msg">
762
- <ul>
763
- <li>
764
-
765
- <?=$this->__('Product\'s SKU:')?> "<?=$product_sku?>" <?=$this->__('. Presentation\'s SKU from Orbitvu SUN:')?> <?=($sku == '-' ? '""' : '"'.$sku.'"')?>. <br /> <?=$this->__('Click "Update SKU on SUN" button below to update your presentation\'s SKU from Orbitvu SUN with:')?> "<?=$product_sku?>".
766
- </li>
767
- </ul>
768
- </li>
769
- </ul>
770
- <?php } else if ($update_sku->error == '400') {
771
- ?>
772
- <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
773
- <ul class="messages">
774
-
775
- <li class="error-msg">
776
- <ul>
777
- <li>
778
- <?=$this->__('We can\'t change your SUN Presentation SKU. One of your presentations already has this product SKU assigned. SKU need to be unique. Modify SKU on your SUN Server.')?>
779
- </li>
780
- </ul>
781
- </li>
782
-
783
- </ul>
784
-
785
-
786
- <?php
787
-
788
- }
789
-
790
- else { ?>
791
- <strong><?=$this->__('SKU')?>:</strong> <?=$product_sku?><br>
792
- <?php
793
- }
794
- }
795
- else { ?>
796
- <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
797
- <?php } ?>
798
- <div class="orbitvu_clearfix" style="padding-top: 10px;">
799
- <?=$add_buttons?>
800
- <button type="button" class="orbitvu-button orbitvu-button-unlink scalable" onclick="if (confirm('<?=$this->__('Do you really want to unlink this presentation?')?>')) { OrbitvuSetAction('sun/unlink/'); }"><span><span></span><?=$this->__('Unlink this presentation')?></span></button>
801
-
802
- <button type="button" class="orbitvu-button orbitvu-button-sync scalable" onclick="SynchronizeSunItems();"><span><span></span><?=$this->__('Synchronize with SUN')?></span></button>
803
-
804
- <?php
805
- $presentation_sun = $_Orbitvu->GetPresentationsList(array('id' => $presentations['orbitvu_id']));
806
- $presentation_sun = $presentation_sun->results[0];
807
- ?>
808
-
809
- <?php if ($orbitvu_connected && !$orbitvu_demo && isset($presentation_sun->edit_url)) { ?><button type="button" class="orbitvu-button orbitvu-button-edit scalable"><span><span></span><a href="<?=$presentation_sun->edit_url?>" target="_blank" style="color: white; text-decoration: none;"><?=$this->__('Edit on SUN')?></a></span></button> <?php } else { ?><button type="button" class="orbitvu-button-edit scalable disabled orbitvu-button-disabled" disabled="disabled"><span style="padding-left: 0; background: none;"><span></span><?=$this->__('Edit on SUN')?></span></button>
810
- <?php } ?> </div>
811
-
812
- <div class="orbitvu_clearfix" style="padding-top: 10px">
813
-
814
- <button type="button" id="orbitvu-button-enable-items" class="orbitvu-button orbitvu-button-enable-items scalable" onclick="enable_all_items();"><span><span></span><?=$this->__('Enable items')?></span></button>
815
- <img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" id="enable_all_items_loader" style="display: none" alt="" />
816
-
817
- <button type="button" id="orbitvu-button-disable-items" class="orbitvu-button orbitvu-button-disable-items scalable" onclick="disable_all_items();"><span><span></span><?=$this->__('Disable items')?></span></button>
818
- <img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" id="disable_all_items_loader" style="display: none" alt="" />
819
-
820
- </div>
821
- </div>
822
-
823
- </td></tr></table>
824
-
825
- <div id="<?=($items_count > 1 ? 'orbitvu-drag-container' : '')?>" class="orbitvu-drag-container" history="History1" style="border-top: 1px solid #dedede;">
826
- <?php
827
- for ($i = 0; $i < $items_count; $i++) {
828
- $items = $presentations['items'][$i];
829
-
830
- $display_id = $items['id'];
831
- ?>
832
- <div class="orbitvu-drag-box<?=($items['status'] == 'inactive' ? ' hidden' : '')?>" id="orbitvu-gallery-item-<?=$display_id?>" style="background: white url(<?=$items['thumbnail']?>?width=100) center center no-repeat;">
833
-
834
- <span class="orbitvu-icon orbitvu-type orbitvu-icon-type-<?=$items['type']?>" title="<?php
835
- switch ($items['type']) {
836
- case '0': echo $this->__('Orbittour'); break;
837
- case '1': echo $this->__('360&deg;'); break;
838
- default: echo $this->__('2D'); break;
839
- }
840
- ?>"></span>
841
-
842
- <span class="orbitvu-text orbitvu-drag-text">
843
- <?=$this->__('Drag &amp; move item')?>
844
- </span>
845
-
846
- <span class="orbitvu-text orbitvu-hide-text" id="orbitvu-text-hide-<?=$display_id?>">
847
- <?=$this->__('Hide item')?>
848
- </span>
849
-
850
- <span class="orbitvu-text orbitvu-show-text" id="orbitvu-text-show-<?=$display_id?>">
851
- <?=$this->__('Show item')?>
852
- </span>
853
-
854
-
855
-
856
- <span class="orbitvu-visibility orbitvu-icon orbitvu-icon-visibility<?=($items['status'] == 'inactive' ? ' disabled' : '')?>" id="orbitvu-visibility-trigger-<?=$display_id?>"></span>
857
- </div>
858
- <?php } ?>
859
- </div>
860
-
861
- </div>
862
- <script>
863
- function orbitvu_ajax(file, func) {
864
- var obj = null;
865
- if (window.XMLHttpRequest) obj = new XMLHttpRequest();
866
- else if (window.ActiveXObject) obj = new ActiveXObject('Microsoft.XMLHTTP');
867
- else return false;
868
-
869
- obj.onreadystatechange = function() {
870
- if (this.readyState == 4) func(this.responseText);
871
- };
872
- obj.open('GET', file, true);
873
- obj.send(null);
874
- }
875
-
876
- function orbitvu_drag_start() {
877
- if (document.getElementsByClassName('orbitvu-drag-box')) {
878
- var elems = document.getElementsByClassName('orbitvu-drag-box');
879
-
880
- for (var i = 0, n = elems.length; i < n; i++) {
881
- if (elems[i]) {
882
- elems[i].className += ' drag';
883
- }
884
- }
885
- }
886
- //orbitvu_log('Drag start!');
887
- }
888
-
889
- function orbitvu_drag_end() {
890
- if (document.getElementsByClassName('orbitvu-drag-box')) {
891
- var elems = document.getElementsByClassName('orbitvu-drag-box');
892
-
893
- //orbitvu_log('Drag end!');
894
-
895
- for (var i = 0, n = elems.length; i < n; i++) {
896
- if (elems[i]) {
897
- elems[i].className = elems[i].className.replace(' drag', '');
898
- }
899
- }
900
- }
901
- }
902
-
903
- function enable_all_items() {
904
- var elems = document.getElementsByClassName('orbitvu-visibility'),
905
- button = document.getElementById('orbitvu-button-enable-items'),
906
- img = document.getElementById('enable_all_items_loader'),
907
- ids = [],
908
- proper_elems = [];
909
-
910
- button.style.display = 'none';
911
- img.style.display = 'inline-block';
912
- for (var i = 0, n = elems.length; i < n; i++) {
913
- if (elems[i].className.replace(' disabled', '') !== elems[i].className) {
914
- ids.push(parseInt(elems[i].id.replace('orbitvu-visibility-trigger-', '')));
915
- proper_elems.push(elems[i]);
916
- }
917
- }
918
- if (ids.length) {
919
- orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_statuses/sun_items_statuses/' + ids.join(',') + '/sun_status/active', function(data){
920
- data = JSON.parse(data);
921
- if (data.status) {
922
- for (var i = 0, n = proper_elems.length; i < n; i++) {
923
- proper_elems[i].className = proper_elems[i].className.replace(' disabled', '');
924
- document.getElementById('orbitvu-gallery-item-' + ids[i]).className = document.getElementById('orbitvu-gallery-item-' + ids[i]).className.replace(' hidden', '');
925
- }
926
- button.style.display = 'inline-block';
927
- img.style.display = 'none';
928
- }
929
- });
930
- } else {
931
- button.style.display = 'inline-block';
932
- img.style.display = 'none';
933
- }
934
- }
935
-
936
- function disable_all_items() {
937
- var elems = document.getElementsByClassName('orbitvu-visibility'),
938
- button = document.getElementById('orbitvu-button-disable-items'),
939
- img = document.getElementById('disable_all_items_loader'),
940
- ids = [],
941
- proper_elems = [];
942
-
943
- button.style.display = 'none';
944
- img.style.display = 'inline-block';
945
- for (var i = 0, n = elems.length; i < n; i++) {
946
- if (elems[i].className.replace(' disabled', '') === elems[i].className) {
947
- ids.push(parseInt(elems[i].id.replace('orbitvu-visibility-trigger-', '')));
948
- proper_elems.push(elems[i]);
949
- }
950
- }
951
- if (ids.length) {
952
- orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_statuses/sun_items_statuses/' + ids.join(','), function(data){
953
- data = JSON.parse(data);
954
- if (data.status) {
955
- for (var i = 0, n = proper_elems.length; i < n; i++) {
956
- proper_elems[i].className += ' disabled';
957
- document.getElementById('orbitvu-gallery-item-' + ids[i]).className += ' hidden';
958
- }
959
- button.style.display = 'inline-block';
960
- img.style.display = 'none';
961
- }
962
- });
963
- } else {
964
- button.style.display = 'inline-block';
965
- img.style.display = 'none';
966
- }
967
- }
968
-
969
- var elems = document.getElementsByClassName('orbitvu-visibility');
970
-
971
- for (var i = 0, n = elems.length; i < n; i++) {
972
- elems[i].onmouseover = function() {
973
- var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
974
-
975
- if (this.className.replace(' disabled', '') != this.className) {
976
- document.getElementById('orbitvu-text-show-' + this_id).className += ' active';
977
- document.getElementById('orbitvu-text-hide-' + this_id).className = document.getElementById('orbitvu-text-hide-' + this_id).className.replace(' active', '');
978
- }
979
- else {
980
- document.getElementById('orbitvu-text-hide-' + this_id).className += ' active';
981
- document.getElementById('orbitvu-text-show-' + this_id).className = document.getElementById('orbitvu-text-show-' + this_id).className.replace(' active', '');
982
- }
983
- }
984
-
985
- elems[i].onmouseout = function() {
986
- var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
987
-
988
- document.getElementById('orbitvu-text-hide-' + this_id).className = document.getElementById('orbitvu-text-hide-' + this_id).className.replace(' active', '');
989
- document.getElementById('orbitvu-text-show-' + this_id).className = document.getElementById('orbitvu-text-show-' + this_id).className.replace(' active', '');
990
- }
991
-
992
- elems[i].onclick = function() {
993
- var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
994
-
995
- if (this.className.replace(' disabled', '') != this.className) {
996
- this.className = this.className.replace(' disabled', '');
997
- document.getElementById('orbitvu-gallery-item-' + this_id).className = document.getElementById('orbitvu-gallery-item-' + this_id).className.replace(' hidden', '');
998
-
999
- orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_status/sun_item_id/' + this_id + '/sun_status/active', function(odp){});
1000
- }
1001
- else {
1002
- this.className += ' disabled';
1003
- document.getElementById('orbitvu-gallery-item-' + this_id).className += ' hidden';
1004
-
1005
- orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_status/sun_item_id/' + this_id, function(odp){});
1006
- }
1007
- }
1008
- }
1009
- var orbitvu_mouse_offset = null;
1010
- var orbitvu_i_mouse_down = false;
1011
- var orbitvu_l_mouse_state = false;
1012
- var orbitvu_drag_object = null;
1013
- var orbitvu_drag_drops = [];
1014
- var OrbitvuCurrentTarget = null;
1015
- var OrbitvuLastTarget = null;
1016
- var OrbitvuDragTemp = null;
1017
- var OrbitvuTempDiv = null;
1018
- var OrbitvuRootParent = null;
1019
- var OrbitvuRootSibling = null;
1020
- var orbitvu_final_node, orbitvu_final_item_id;
1021
- var OrbitvuD1Target = null;
1022
-
1023
- Number.prototype.NaN0 = function() {
1024
- return isNaN(this) ? 0 : this;
1025
- }
1026
-
1027
- function orbitvu_create_drag_container() {
1028
-
1029
- var cDrag = orbitvu_drag_drops.length;
1030
- orbitvu_drag_drops[cDrag] = [];
1031
-
1032
-
1033
- for (var i = 0; i < arguments.length; i++) {
1034
- var cObj = arguments[i];
1035
- orbitvu_drag_drops[cDrag].push(cObj);
1036
- cObj.setAttribute('DropObj', cDrag);
1037
-
1038
-
1039
- for (var j = 0; j < cObj.childNodes.length; j++) {
1040
-
1041
-
1042
- if (cObj.childNodes[j].nodeName == '#text')
1043
- continue;
1044
-
1045
- cObj.childNodes[j].setAttribute('DragObj', cDrag);
1046
- }
1047
- }
1048
- }
1049
-
1050
- function orbitvu_get_position(e) {
1051
- var left = 0;
1052
- var top = 0;
1053
- while (e.offsetParent) {
1054
- left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
1055
- top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
1056
- e = e.offsetParent;
1057
- }
1058
-
1059
-
1060
- left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
1061
- top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
1062
-
1063
- return {x: left, y: top};
1064
-
1065
- }
1066
-
1067
- function orbitvu_mouse_coords(ev) {
1068
- if (ev.pageX || ev.pageY) {
1069
- return {x: ev.pageX, y: ev.pageY};
1070
- }
1071
- return {
1072
- x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
1073
- y: ev.clientY + document.body.scrollTop - document.body.clientTop
1074
- };
1075
- }
1076
-
1077
- function orbitvu_log(object, message) {
1078
- if (!object || !object.parentNode || !object.parentNode.getAttribute)
1079
- return;
1080
- //console.log(object.id + ': ' + message);
1081
- }
1082
-
1083
- function orbitvu_get_mouse_offset(target, ev) {
1084
- ev = ev || window.event;
1085
-
1086
- var docPos = orbitvu_get_position(target);
1087
- var mousePos = orbitvu_mouse_coords(ev);
1088
- return {x: mousePos.x - docPos.x, y: mousePos.y - docPos.y};
1089
- }
1090
-
1091
- function orbitvu_mouse_move(ev) {
1092
- ev = ev || window.event;
1093
-
1094
-
1095
- var target = ev.target || ev.srcElement;
1096
- var mousePos = orbitvu_mouse_coords(ev);
1097
-
1098
-
1099
-
1100
- if (OrbitvuLastTarget && (target !== OrbitvuLastTarget)) {
1101
- //orbitvu_log(OrbitvuLastTarget, 'Mouse Out Fired');
1102
-
1103
-
1104
- var origClass = OrbitvuLastTarget.getAttribute('origClass');
1105
- if (origClass)
1106
- OrbitvuLastTarget.className = origClass;
1107
- }
1108
-
1109
-
1110
- var dragObj = target.getAttribute('DragObj');
1111
-
1112
-
1113
- if (dragObj != null) {
1114
-
1115
-
1116
- if (target != OrbitvuLastTarget) {
1117
- //orbitvu_log(target, 'Mouse Over Fired');
1118
-
1119
- var oClass = target.getAttribute('overClass');
1120
- if (oClass) {
1121
- target.setAttribute('origClass', target.className);
1122
- target.className = oClass;
1123
- }
1124
- }
1125
-
1126
-
1127
- if (orbitvu_i_mouse_down && !orbitvu_l_mouse_state) {
1128
- orbitvu_log(target, 'Start Dragging');
1129
-
1130
-
1131
- OrbitvuCurrentTarget = target;
1132
-
1133
-
1134
- OrbitvuRootParent = OrbitvuCurrentTarget.parentNode;
1135
- OrbitvuRootSibling = OrbitvuCurrentTarget.nextSibling;
1136
-
1137
- orbitvu_mouse_offset = orbitvu_get_mouse_offset(target, ev);
1138
-
1139
-
1140
- for (var i = 0; i < OrbitvuDragTemp.childNodes.length; i++)
1141
- OrbitvuDragTemp.removeChild(OrbitvuDragTemp.childNodes[i]);
1142
-
1143
-
1144
- OrbitvuDragTemp.appendChild(OrbitvuCurrentTarget.cloneNode(true));
1145
- //OrbitvuDragTemp.style.display = 'block';
1146
-
1147
-
1148
- var dragClass = OrbitvuCurrentTarget.getAttribute('dragClass');
1149
- if (dragClass) {
1150
- OrbitvuDragTemp.firstChild.className = dragClass;
1151
- }
1152
-
1153
-
1154
- OrbitvuDragTemp.firstChild.removeAttribute('DragObj');
1155
-
1156
-
1157
- var dragConts = orbitvu_drag_drops[dragObj];
1158
-
1159
-
1160
- OrbitvuCurrentTarget.setAttribute('startWidth', parseInt(OrbitvuCurrentTarget.offsetWidth));
1161
- OrbitvuCurrentTarget.setAttribute('startHeight', parseInt(OrbitvuCurrentTarget.offsetHeight));
1162
- OrbitvuCurrentTarget.style.display = 'none';
1163
-
1164
- for (var i = 0; i < dragConts.length; i++) {
1165
- with (dragConts[i]) {
1166
- var pos = orbitvu_get_position(dragConts[i]);
1167
-
1168
-
1169
- setAttribute('startWidth', parseInt(offsetWidth));
1170
- setAttribute('startHeight', parseInt(offsetHeight));
1171
- setAttribute('startLeft', pos.x);
1172
- setAttribute('startTop', pos.y);
1173
- }
1174
-
1175
-
1176
- for (var j = 0; j < dragConts[i].childNodes.length; j++) {
1177
- with (dragConts[i].childNodes[j]) {
1178
- if ((nodeName == '#text') || (dragConts[i].childNodes[j] == OrbitvuCurrentTarget))
1179
- continue;
1180
-
1181
- var pos = orbitvu_get_position(dragConts[i].childNodes[j]);
1182
-
1183
-
1184
- setAttribute('startWidth', parseInt(offsetWidth));
1185
- setAttribute('startHeight', parseInt(offsetHeight));
1186
- setAttribute('startLeft', pos.x);
1187
- setAttribute('startTop', pos.y);
1188
- }
1189
- }
1190
- }
1191
- }
1192
- }
1193
-
1194
-
1195
- if (OrbitvuCurrentTarget) {
1196
-
1197
- OrbitvuDragTemp.style.top = mousePos.y - orbitvu_mouse_offset.y;
1198
- OrbitvuDragTemp.style.left = mousePos.x - orbitvu_mouse_offset.x;
1199
-
1200
- var dragConts = orbitvu_drag_drops[OrbitvuCurrentTarget.getAttribute('DragObj')];
1201
- var activeCont = null;
1202
-
1203
- var xPos = mousePos.x - orbitvu_mouse_offset.x + (parseInt(OrbitvuCurrentTarget.getAttribute('startWidth')) / 2);
1204
- var yPos = mousePos.y - orbitvu_mouse_offset.y + (parseInt(OrbitvuCurrentTarget.getAttribute('startHeight')) / 2);
1205
-
1206
-
1207
- for (var i = 0; i < dragConts.length; i++) {
1208
- with (dragConts[i]) {
1209
- if ((parseInt(getAttribute('startLeft')) < xPos) &&
1210
- (parseInt(getAttribute('startTop')) < yPos) &&
1211
- ((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
1212
- ((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {
1213
-
1214
-
1215
- activeCont = dragConts[i];
1216
-
1217
-
1218
- break;
1219
- }
1220
- }
1221
- }
1222
-
1223
-
1224
- if (activeCont) {
1225
- if (activeCont != OrbitvuCurrentTarget.parentNode) {
1226
- orbitvu_log(OrbitvuCurrentTarget, 'Moved into ' + activeCont.id);
1227
- }
1228
-
1229
-
1230
- var beforeNode = null;
1231
-
1232
-
1233
- for (var i = activeCont.childNodes.length - 1; i >= 0; i--) {
1234
- with (activeCont.childNodes[i]) {
1235
- if (nodeName == '#text')
1236
- continue;
1237
-
1238
-
1239
- if (OrbitvuCurrentTarget != activeCont.childNodes[i] &&
1240
- ((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
1241
- ((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {
1242
- beforeNode = activeCont.childNodes[i];
1243
- }
1244
- }
1245
- }
1246
-
1247
-
1248
- if (beforeNode) {
1249
- if (beforeNode != OrbitvuCurrentTarget.nextSibling) {
1250
- //`orbitvu_log(OrbitvuCurrentTarget, 'Ajax action -> Insert before ' + beforeNode.id);
1251
- orbitvu_final_item_id = OrbitvuCurrentTarget.id;
1252
- orbitvu_final_node = beforeNode.id;
1253
- activeCont.insertBefore(OrbitvuCurrentTarget, beforeNode);
1254
- }
1255
-
1256
-
1257
- } else {
1258
- if ((OrbitvuCurrentTarget.nextSibling) || (OrbitvuCurrentTarget.parentNode != activeCont)) {
1259
- orbitvu_log(OrbitvuCurrentTarget, 'Inserted at end of ' + activeCont.id);
1260
-
1261
- activeCont.appendChild(OrbitvuCurrentTarget);
1262
- }
1263
- }
1264
-
1265
-
1266
- setTimeout(function() {
1267
- var contPos = orbitvu_get_position(activeCont);
1268
- activeCont.setAttribute('startWidth', parseInt(activeCont.offsetWidth));
1269
- activeCont.setAttribute('startHeight', parseInt(activeCont.offsetHeight));
1270
- activeCont.setAttribute('startLeft', contPos.x);
1271
- activeCont.setAttribute('startTop', contPos.y);
1272
- }, 5);
1273
-
1274
-
1275
- if (OrbitvuCurrentTarget.style.display != '') {
1276
- orbitvu_log(OrbitvuCurrentTarget, 'Made Visible');
1277
- orbitvu_drag_start();
1278
- OrbitvuCurrentTarget.style.display = '';
1279
- OrbitvuCurrentTarget.className += ' dragstate';
1280
- OrbitvuCurrentTarget.style.opacity = '1';
1281
- OrbitvuCurrentTarget.style.cursor = 'move';
1282
- OrbitvuCurrentTarget.style.borderStyle = 'dashed';
1283
- OrbitvuCurrentTarget.style.boxShadow = '0 0 15px black';
1284
- }
1285
- } else {
1286
-
1287
-
1288
- if (OrbitvuCurrentTarget.style.display != 'none') {
1289
- orbitvu_log(OrbitvuCurrentTarget, 'Hidden');
1290
- OrbitvuCurrentTarget.style.display = 'none';
1291
- }
1292
- }
1293
- }
1294
-
1295
-
1296
- orbitvu_l_mouse_state = orbitvu_i_mouse_down;
1297
-
1298
-
1299
- OrbitvuLastTarget = target;
1300
-
1301
-
1302
- if (orbitvu_drag_object) {
1303
- orbitvu_drag_object.style.position = 'absolute';
1304
- orbitvu_drag_object.style.top = mousePos.y - orbitvu_mouse_offset.y;
1305
- orbitvu_drag_object.style.left = mousePos.x - orbitvu_mouse_offset.x;
1306
- }
1307
-
1308
-
1309
- orbitvu_l_mouse_state = orbitvu_i_mouse_down;
1310
-
1311
-
1312
- if (OrbitvuCurrentTarget || orbitvu_drag_object)
1313
- return false;
1314
- }
1315
-
1316
- function orbitvu_mouse_up(ev) {
1317
-
1318
-
1319
- if (OrbitvuCurrentTarget) {
1320
- orbitvu_log(OrbitvuCurrentTarget, 'Mouse Up Fired');
1321
- orbitvu_drag_end();
1322
- orbitvu_log(OrbitvuCurrentTarget, 'orbitvu_final_item_id: ' + orbitvu_final_item_id + ' / orbitvu_final_node: ' + orbitvu_final_node + ' / final_target: ' + OrbitvuLastTarget.id);
1323
-
1324
- orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_order/sun_item_id/' + parseInt(orbitvu_final_item_id.replace('orbitvu-gallery-item-', '')) + '/sun_before_item_id/' + parseInt(orbitvu_final_node.replace('orbitvu-gallery-item-', '')), function(odp){});
1325
-
1326
- if (document.getElementById('media_gallery_content_grid')) {
1327
- var torem = document.getElementById('media_gallery_content_grid');
1328
- torem.parentNode.removeChild(torem);
1329
- }
1330
-
1331
- if (document.getElementById('media_gallery_content_save')) {
1332
- var torem2 = document.getElementById('media_gallery_content_save');
1333
- torem2.parentNode.removeChild(torem2);
1334
- }
1335
-
1336
- if (document.getElementById('media_gallery_content_save_image')) {
1337
- var torem3 = document.getElementById('media_gallery_content_save_image');
1338
- torem3.parentNode.removeChild(torem3);
1339
- }
1340
-
1341
- OrbitvuDragTemp.style.display = 'none';
1342
- if (OrbitvuCurrentTarget.style.display == 'block') {
1343
- if (OrbitvuRootSibling) {
1344
- OrbitvuRootParent.insertBefore(OrbitvuCurrentTarget, OrbitvuRootSibling);
1345
- } else {
1346
- OrbitvuRootParent.appendChild(OrbitvuCurrentTarget);
1347
- }
1348
- }
1349
-
1350
- OrbitvuCurrentTarget.style.display = '';
1351
- OrbitvuCurrentTarget.style.opacity = '';
1352
- OrbitvuCurrentTarget.style.cursor = '';
1353
- OrbitvuCurrentTarget.style.borderStyle = '';
1354
- OrbitvuCurrentTarget.style.boxShadow = '';
1355
- OrbitvuCurrentTarget.className = OrbitvuCurrentTarget.className.replace(' dragstate','');
1356
- }
1357
-
1358
- orbitvu_drag_end();
1359
-
1360
- OrbitvuCurrentTarget = null;
1361
-
1362
-
1363
- orbitvu_drag_object = null;
1364
-
1365
- orbitvu_i_mouse_down = false;
1366
- }
1367
-
1368
- function orbitvu_mouse_down(ev) {
1369
- ev = ev || window.event;
1370
- var target = ev.target || ev.srcElement;
1371
-
1372
- orbitvu_i_mouse_down = true;
1373
-
1374
- if (OrbitvuLastTarget) {
1375
- orbitvu_log(OrbitvuLastTarget, 'Mouse Down Fired');
1376
- }
1377
-
1378
- if (target.onmousedown || target.getAttribute('DragObj')) {
1379
- return false;
1380
- }
1381
- }
1382
-
1383
- function orbitvu_make_draggable(item) {
1384
- if (!item)
1385
- return;
1386
- item.onmousedown = function(ev) {
1387
- orbitvu_drag_object = this;
1388
- orbitvu_mouse_offset = orbitvu_get_mouse_offset(this, ev);
1389
- return false;
1390
- }
1391
- }
1392
-
1393
- function orbitvu_make_clickable(item) {
1394
- if (!item)
1395
- return;
1396
- item.onmousedown = function(ev) {
1397
- document.getElementById('ClickImage').value = this.name;
1398
- }
1399
- }
1400
-
1401
- function orbitvu_add_drop_target(item, target) {
1402
- item.setAttribute('droptarget', target);
1403
- }
1404
-
1405
- if (document.getElementById('orbitvu-drag-container')) {
1406
- document.onmousemove = orbitvu_mouse_move;
1407
- document.onmousedown = orbitvu_mouse_down;
1408
- document.onmouseup = orbitvu_mouse_up;
1409
-
1410
- orbitvu_create_drag_container(document.getElementById('orbitvu-drag-container'));
1411
-
1412
- OrbitvuDragTemp = document.createElement('DIV');
1413
- OrbitvuDragTemp.style.cssText = 'position:absolute;display:none;';
1414
-
1415
- document.body.appendChild(OrbitvuDragTemp);
1416
- }
1417
- </script>
1418
-
1419
-
1420
-
1421
-
1422
- </div>
1423
-
1424
-
1425
- <?php } ?>
1426
-
1427
- <?php
1428
-
1429
- //--------------------------------------------------------------------------------------------------------------------------------------
1430
- echo $observer->UseTemplate(array(), $__templates['magento_section_end']);
1431
- //--------------------------------------------------------------------------------------------------------------------------------------
1432
-
1433
- ?>
1434
-
1435
- <div style="text-align: right;">
1436
- <button type="button" class="orbitvu-button scalable"><a href="<?=$this->getUrl('*/system_config/edit/section/orbitvu/')?>" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url(<?=Mage::getBaseUrl('media').'orbitvu/white.png'?>); background-repeat: no-repeat; background-position: -64px -108px;"></span><span><?=$this->__('Orbitvu Configuration')?></span></span></span></a></button>
1437
- </div>
1438
-
1439
- <script>
1440
- function SynchronizeSun() {
1441
- document.getElementById('synchronize_sun').value = 'true';
1442
- productForm.submit();
1443
- }
1444
- <?php
1445
- $ex = explode('index.php', $_SERVER['REQUEST_URI']);
1446
- $http_host = str_replace('//', '/', $ex[0]);
1447
- ?>
1448
- function RefreshSun() {
1449
- saveAndContinueEdit('<?=$this->getUrl('*/catalog_product/save/back/edit/')?>tab/{{tab_id}}/id/<?=$product_id?>/');
1450
- }
1451
-
1452
- function SynchronizeSunItems() {
1453
- saveAndContinueEdit('<?=$this->getUrl('*/catalog_product/save/back/edit/sun/synchronize_items/')?>tab/{{tab_id}}/id/<?=$product_id?>/');
1454
- }
1455
-
1456
- function OrbitvuSetAction(act) {
1457
- window.location.href = '<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/tab/' + product_info_tabsJsTabs.activeTab.id + '/' + act;
1458
- }
1459
- </script>
1460
- <?php
1461
- /*************************************************************************************************************************************************
1462
- * Scheduled actions
1463
- *************************************************************************************************************************************************/
1464
- if ($_Orbitvu->GetConfiguration('auto_sync') == 'true') {
1465
- if (date('Y-m-d', strtotime($_Orbitvu->GetConfiguration('last_updated'))) != date('Y-m-d')) {
1466
- $observer->SynchronizeAllProducts();
1467
- }
1468
- }
1469
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1470
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ *
9
+ * From file author: I don't know is there any better way to create a layout.
10
+ * Every Magento layout is mixed with PHP code, so I will do the same.
11
+ */
12
+
13
+ $__templates = array(
14
+ //-------------------------------------------------------------------------------------------------------
15
+ 'presentation_item' =>
16
+ //-------------------------------------------------------------------------------------------------------
17
+ '
18
+ <div class="orbitvu_sun_presentation"{parameters}>
19
+ <img src="{image_path}?width=100&amp;height=80&amp;action=crop" alt="">
20
+ <div class="presentation_data">
21
+ <strong>{name}</strong><br>
22
+ '.$this->__('SKU').': <strong>{sku}</strong><br>
23
+ <div class="presentation_types">
24
+ <strong>{types}</strong>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ ',
29
+ //-------------------------------------------------------------------------------------------------------
30
+ 'magento_section_start' =>
31
+ //-------------------------------------------------------------------------------------------------------
32
+ '
33
+ <div class="entry-edit">
34
+ <div class="entry-edit-head">
35
+ <h4 class="icon-head head-edit-form fieldset-legend">{name}</h4>
36
+ </div>
37
+ <fieldset>
38
+ <legend>{name}</legend>
39
+ <div class="hor-scroll">
40
+ ',
41
+ //-------------------------------------------------------------------------------------------------------
42
+ 'magento_section_end' =>
43
+ //-------------------------------------------------------------------------------------------------------
44
+ '
45
+ </div>
46
+ </fieldset>
47
+ </div>
48
+ '
49
+
50
+ );
51
+
52
+ /*
53
+ * Get the SUN class
54
+ */
55
+ //-------------------------------------------------------------------------------------------------------
56
+ $observer = Mage::getSingleton('sun/observer');
57
+ $_Orbitvu = $observer->ExtendOrbitvu();
58
+ $orbitvu_connected = $_Orbitvu->IsConnected();
59
+ $orbitvu_demo = $_Orbitvu->IsDemo();
60
+ //-------------------------------------------------------------------------------------------------------
61
+
62
+ /*
63
+ * Get Mage requests
64
+ */
65
+ //-------------------------------------------------------------------------------------------------------
66
+ $request = Mage::app()->getRequest();
67
+ $product_id = $request->getParam('id');
68
+ //-------------------------------------------------------------------------------------------------------
69
+
70
+ /*
71
+ * Display nothing when product is not add yet
72
+ */
73
+ //-------------------------------------------------------------------------------------------------------
74
+ if (empty($product_id)) {
75
+ return '';
76
+ }
77
+ //-------------------------------------------------------------------------------------------------------
78
+
79
+ /*
80
+ * Declarations
81
+ */
82
+ //-------------------------------------------------------------------------------------------------------
83
+ $_action = $request->getParam('sun');
84
+ $_messages = array();
85
+ $cookie = Mage::getSingleton('core/cookie');
86
+ //-------------------------------------------------------------------------------------------------------
87
+ $CurrentProduct = Mage::registry('current_product');
88
+ $product_name = $CurrentProduct->getName();
89
+ $product_sku = $CurrentProduct->getSku();
90
+ //-------------------------------------------------------------------------------------------------------
91
+
92
+ /*
93
+ * Pagination
94
+ */
95
+ //-------------------------------------------------------------------------------------------------------
96
+ $OrbitvuCurrentPage = intval($request->getParam('pager_start')) > 0 ? intval($request->getParam('pager_start')) : 0;
97
+ //-------------------------------------------------------------------------------------------------------
98
+ if ($request->getParam('page_size') > 0) {
99
+ $cookie->set('page_size', $request->getParam('page_size'), time()+3600*24*7);
100
+ $OrbitvuPagerPageSize = intval($request->getParam('page_size'));
101
+ }
102
+ else if ($cookie->get('page_size') > 0) {
103
+ $OrbitvuPagerPageSize = intval($cookie->get('page_size'));
104
+ }
105
+ else {
106
+ $OrbitvuPagerPageSize = 50;
107
+ }
108
+ //-------------------------------------------------------------------------------------------------------
109
+ if ($request->getParam('sun_ordering') != '') {
110
+ $cookie->set('sun_ordering', $request->getParam('sun_ordering'), time()+3600*24*7);
111
+ $OrbitvuOrdering = $request->getParam('sun_ordering');
112
+ }
113
+ else if ($cookie->get('sun_ordering') > 0) {
114
+ $OrbitvuOrdering = $cookie->get('sun_ordering');
115
+ }
116
+ else {
117
+ $OrbitvuOrdering = '-create_date';
118
+ }
119
+ //-------------------------------------------------------------------------------------------------------
120
+ if ($request->getParam('sun_keyword')) {
121
+ $cookie->set('sun_keyword', $request->getParam('sun_keyword'), time()+3600);
122
+ $OrbitvuKeyword = $request->getParam('sun_keyword');
123
+ }
124
+ else if ($cookie->get('sun_keyword') != '') {
125
+ $OrbitvuKeyword = $cookie->get('sun_keyword');
126
+ }
127
+ else {
128
+ $OrbitvuKeyword = '';
129
+ }
130
+ //-------------------------------------------------------------------------------------------------------
131
+ if ($request->getParam('sun_keyword_reset')) {
132
+ $cookie->delete('sun_keyword');
133
+ $OrbitvuKeyword = '';
134
+ }
135
+ //-------------------------------------------------------------------------------------------------------
136
+
137
+ /*
138
+ * Actions switcher
139
+ */
140
+ //-------------------------------------------------------------------------------------------------------
141
+ if ($_action == 'set_presentation' && $request->getParam('presentation_id') > 0) {
142
+ $cur_pres = $_Orbitvu->GetPresentationsList(array('id' => intval($request->getParam('presentation_id'))));
143
+ $_Orbitvu->SynchronizeProductPresentation($product_id, intval($request->getParam('presentation_id')), $cur_pres->results[0]->name);
144
+ $_Orbitvu->SetSunPresentationSku(intval($request->getParam('presentation_id')), $product_sku, $cur_pres->results[0]->sku);
145
+ //$observer->UpdateThumbnails($product_id);
146
+
147
+ $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
148
+ }
149
+ else if ($_action == 'unlink') {
150
+ $_Orbitvu->FreeProduct($product_id);
151
+ $observer->UpdateThumbnails($product_id);
152
+ $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/message/unlinked/');
153
+ }
154
+ else if ($_action == 'update_priority' && $request->getParam('sun_item_id') > 0 && $request->getParam('sun_priority')) {
155
+ $_Orbitvu->UpdatePresentationItemPriority(
156
+ intval($request->getParam('sun_item_id')),
157
+ intval($request->getParam('sun_priority'))
158
+ );
159
+ //$observer->UpdateThumbnails($product_id);
160
+ $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
161
+ }
162
+ else if ($_action == 'set_sku' && $request->getParam('presentation_id') > 0 && $request->getParam('sun_new_sku') != '') {
163
+ $sun_response = $_Orbitvu->SetSunPresentationSku(intval($request->getParam('presentation_id')), $request->getParam('sun_new_sku'), '', true);
164
+ if ($sun_response->error == '400') {
165
+ $_messages[] = array('error', $this->__('One of your presentations already has this SKU assigned. SKU need to be unique. Modify SKU on your SUN Server and try again.'));
166
+ }
167
+ else {
168
+ $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
169
+ }
170
+ }
171
+ /*
172
+ * Ajax actions
173
+ */
174
+ else if ($_action == 'update_status' && $request->getParam('sun_item_id') > 0) {
175
+ if ($request->getParam('sun_status') == 'active') $sun_status = 'active';
176
+ else $sun_status = 'inactive';
177
+
178
+ $_Orbitvu->UpdatePresentationItemStatus(intval($request->getParam('sun_item_id')), $sun_status);
179
+ //$observer->UpdateThumbnails($product_id);
180
+ echo '200 OK';
181
+ exit();
182
+ //$observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
183
+ }
184
+ else if ($_action == 'update_order' && $request->getParam('sun_item_id') > 0 && $request->getParam('sun_before_item_id') > 0) {
185
+ $_Orbitvu->SwitchPresentationItemPriority(
186
+ $product_id,
187
+ intval($request->getParam('sun_item_id')),
188
+ intval($request->getParam('sun_before_item_id'))
189
+ );
190
+ //$observer->UpdateThumbnails($product_id);
191
+ echo '200 OK';
192
+ exit();
193
+ //$observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/');
194
+ } else if ($_action == 'update_statuses' && $request->getParam('sun_items_statuses')) {
195
+ $ids = explode(",", $request->getParam('sun_items_statuses'));
196
+ if ($request->getParam('sun_status') == 'active') {
197
+ $sun_status = 'active';
198
+ } else {
199
+ $sun_status = 'inactive';
200
+ }
201
+
202
+ if ($ids) {
203
+ foreach($ids as $id) {
204
+ $_Orbitvu->UpdatePresentationItemStatus(intval($id), $sun_status);
205
+ }
206
+ }
207
+ die(json_encode(array('status' => true, 'sun_status' => $sun_status)));
208
+ }
209
+ //-------------------------------------------------------------------------------------------------------
210
+
211
+ /*
212
+ * Scheduled actions
213
+ */
214
+ //-------------------------------------------------------------------------------------------------------
215
+ if (date('Y-m-d', strtotime($_Orbitvu->GetConfiguration('last_refreshed'))) != date('Y-m-d') || $_action == 'synchronize_items') {
216
+ $_Orbitvu->SynchronizePresentationsItems();
217
+ }
218
+ //-------------------------------------------------------------------------------------------------------
219
+
220
+ /*
221
+ * User is connected?
222
+ */
223
+ //-------------------------------------------------------------------------------------------------------
224
+ if (!$orbitvu_connected) {
225
+ $_messages[] = array('error', $this->__('Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.').' <button type="button" class="orbitvu-button scalable"><a href="'.$this->getUrl('*/system_config/edit/section/orbitvu/').'" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Update your key').'</span></span></span></a></button>');
226
+ }
227
+ //-------------------------------------------------------------------------------------------------------
228
+
229
+ /*
230
+ * User is demo?
231
+ */
232
+ //-------------------------------------------------------------------------------------------------------
233
+ if ($orbitvu_demo) {
234
+ $_messages[] = array('error', $this->__('Orbitvu extension is connected to DEMO account. Register Orbitvu SUN FREE trial account to create your own presentations.').' <button type="button" class="orbitvu-button scalable"><a href="'.Mage::helper('adminhtml')->getUrl('*/catalog_product/index/sun/show_welcome').'" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Get free trial').'</span></span></span></a></button>');
235
+ }
236
+ //-------------------------------------------------------------------------------------------------------
237
+
238
+ /*
239
+ * User is demo?
240
+ */
241
+ //-------------------------------------------------------------------------------------------------------
242
+ if ($up = $_Orbitvu->CheckForUpdates()) {
243
+ $_messages[] = array('notice', $this->__('Version').' '.$up->new_version.' '.$this->__('of Orbitvu extension is out!').' <button type="button" class="orbitvu-button scalable"><a href="http://www.magentocommerce.com/magento-connect/orbitvu-sun-product-teleporting-image-gallery.html" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url('.Mage::getBaseUrl('media').'orbitvu/white.png'.'); background-repeat: no-repeat; background-position: -64px -108px;"></span><span>'.$this->__('Upgrade now from').' '.$up->version.' '.$this->__('to').' '.$up->new_version.'</span></span></span></a></button>');
244
+ }
245
+ //-------------------------------------------------
246
+
247
+ /*
248
+ * Check if product has a presentation set
249
+ */
250
+ //-------------------------------------------------------------------------------------------------------
251
+ $presentations = $_Orbitvu->GetProductPresentation($product_id);
252
+ //-------------------------------------------------------------------------------------------------------
253
+ $items_count = count($presentations['items']);
254
+ $found_match = false;
255
+ //-------------------------------------------------------------------------------------------------------
256
+
257
+ /*
258
+ * No? Find one!
259
+ */
260
+ //-------------------------------------------------------------------------------------------------------
261
+ if ($items_count == 0) {
262
+ //-------------------------------------------------------------------------------------------------------
263
+ $auto_sync = $_Orbitvu->GetConfiguration('auto_sync');
264
+ $unlinked_before = false;
265
+ //-------------------------------------------------------------------------------------------------------
266
+
267
+ /*
268
+ * Find match
269
+ */
270
+ //-------------------------------------------------------------------------------------------------------
271
+ if ($_action != 'set_show_all') {
272
+ $presentations_choose = $_Orbitvu->MatchPresentation(array(
273
+ 'product_name' => $product_name,
274
+ 'product_sku' => $product_sku
275
+ ));
276
+
277
+ /*
278
+ * Do not link again, if auto_sync
279
+ */
280
+ //-------------------------------------------------------------------------------------------------------
281
+ if ((!$presentations_choose || $presentations_choose->count == 0)) {
282
+ //-------------------------------------------------------------------------------------------------------
283
+ $presentation_id = is_object($presentations_choose) ? intval($presentations_choose->results[0]->id) : 0;
284
+ //-------------------------------------------------------------------------------------------------------
285
+ if ($presentation_id == 0 || $_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
286
+ if (is_object($presentations_choose)) {
287
+ $presentations_choose->count = 0;
288
+ } else {
289
+ $presentations_choose = new stdClass();
290
+ $presentations_choose->count = 0;
291
+ }
292
+ $auto_sync = 'false';
293
+ $found_match = false;
294
+ $unlinked_before = true;
295
+ }
296
+ }
297
+ //-------------------------------------------------------------------------------------------------------
298
+ }
299
+ //-------------------------------------------------------------------------------------------------------
300
+
301
+ /*
302
+ * Not found? Show all
303
+ */
304
+ //-------------------------------------------------------------------------------------------------------
305
+ if ((!isset($presentations_choose) || !$presentations_choose || $presentations_choose->count == 0) || $_action == 'set_show_all') {
306
+ if ($_action != 'set_show_all') {
307
+ if ($unlinked_before) {
308
+ //$_messages[] = array('error', $this->__('We matched the presentation, but it was unlinked before and we don\'t link it automatically. You have to select a presentation on your own.'));
309
+ }
310
+ else {
311
+ //$_messages[] = array('error', $this->__('We did not match this product to any of your Orbitvu SUN presentations. Make sure you have identical presentation name or SKU as your product or choose one of presentations displayed below.'));
312
+ }
313
+ }
314
+ if ($request->getParam('message') == 'unlinked') {
315
+ $_messages[] = array('success', $this->__('Your presentation has been unlinked. You can select a new one below.'));
316
+ }
317
+
318
+ $sun_params = array(
319
+ 'page_size' => $OrbitvuPagerPageSize,
320
+ 'page' => $OrbitvuCurrentPage + 1,
321
+ 'ordering' => $OrbitvuOrdering
322
+ );
323
+
324
+ if (!empty($OrbitvuKeyword)) {
325
+ $sun_params['search'] = $OrbitvuKeyword;
326
+ $sun_params['page'] = 1;
327
+ }
328
+
329
+ $presentations_choose = $_Orbitvu->GetPresentationsList($sun_params);
330
+ }
331
+ //-------------------------------------------------------------------------------------------------------
332
+ /*
333
+ * Found match? Display info
334
+ */
335
+ //-------------------------------------------------------------------------------------------------------
336
+ else {
337
+ //-------------------------------------------------------------------------------------------------------
338
+ $found_match = true;
339
+ $presentation_unlinked = false;
340
+ //-------------------------------------------------------------------------------------------------------
341
+ $presentation_id = intval($presentations_choose->results[0]->id);
342
+
343
+ /*if ($_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
344
+ $_messages[] = array('error', $this->__('We matched the presentation, but it was unlinked before and we don\'t set it automatically. You have to select a presentation on your own.'));
345
+ }*/
346
+ //-------------------------------------------------------------------------------------------------------
347
+
348
+ if ($auto_sync == 'true') {
349
+ //-------------------------------------------------------------------------------------------------------
350
+ if (!$_Orbitvu->IsPresentationUnlinked($product_id, $presentation_id)) {
351
+ $_Orbitvu->SynchronizeProductPresentation($product_id, $presentation_id, $presentations_choose->results[0]->name);
352
+ $_Orbitvu->SetSunPresentationSku($presentation_id, $product_sku, $presentations_choose->results[0]->sku);
353
+ //$observer->UpdateThumbnails($product_id);
354
+
355
+ $observer->RedirectAlias('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_group_tab/');
356
+ }
357
+ //-------------------------------------------------------------------------------------------------------
358
+ }
359
+ else {
360
+ //-------------------------------------------------------------------------------------------------------
361
+ $types = $_Orbitvu->GetPresentationTypes($presentations_choose->results[0]);
362
+ $new_types = array();
363
+ foreach ($types as $type) {
364
+ switch ($type) {
365
+ case '0':
366
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0" title="'.$this->__('Orbittour').'"></span>';
367
+ break;
368
+ case '1':
369
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1" title="'.$this->__('360&deg;').'"></span>';
370
+ break;
371
+ default:
372
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3" title="'.$this->__('2D').'"></span>';
373
+ break;
374
+ }
375
+ }
376
+ $types = $new_types;
377
+ //-------------------------------------------------------------------------------------------------------
378
+ $str = $presentations_choose->results[0]->name;
379
+ if (strlen($str) > 15 ) $str = '<span title="'.Sstr.'">'.mb_substr($str, 0, 15, 'utf-8').'...</span>';
380
+ //-------------------------------------------------------------------------------------------------------
381
+ $sku = $presentations_choose->results[0]->sku;
382
+ //-------------------------------------------------------------------------------------------------------
383
+ if (!empty($sku)) {
384
+ if (strlen($sku) > 10 ) {
385
+ $sku = '<span title="'.$sku.'">'.mb_substr($sku, 0, 10, 'utf-8').'...</span>';
386
+ }
387
+ }
388
+ else {
389
+ $sku = '-';
390
+ }
391
+ //-------------------------------------------------------------------------------------------------------
392
+ $_messages[] = array('success', '<div style="clear: both; overflow: hidden; zoom: 1.0;">
393
+
394
+ '.$this->__('We used your product\'s SKU:').' "'.$product_sku.'" '.$this->__('and name:').' "'.$product_name.'" '.$this->__('to match one of your SUN presentations.').'
395
+ </div>
396
+ <div class="orbitvu_clearfix">
397
+ '.$observer->UseTemplate(array(
398
+ 'parameters' => 'onclick="OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$presentations_choose->results[0]->id.'/\');"',
399
+ 'image_path' => $presentations_choose->results[0]->thumbnail_url,
400
+ 'name' => $str,
401
+ 'sku' => $sku,
402
+ 'types' => implode('', $types)
403
+
404
+ ), $__templates['presentation_item']).'
405
+
406
+ <div style="float: left; margin: 35px 0 0 10px;">
407
+ <button type="button" class="orbitvu-button orbitvu-button-link scalable" onclick="OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$presentations_choose->results[0]->id.'/\');" style=""><span><span></span>'.$this->__('Link this presentation').'</span></button>
408
+ <div style="clear: both; overflow: hidden; zoom: 1.0; margin-top: 10px;">
409
+ <button type="button" class="orbitvu-button-ok scalable back" onclick="OrbitvuSetAction(\'sun/set_show_all/\');" style=""><span style="background-image: none; padding: 0;"><span></span>'.$this->__('Select another one').'</span></button>
410
+ </div>
411
+ </div>
412
+ </div>
413
+ ');
414
+ //-------------------------------------------------------------------------------------------------------
415
+ }
416
+ }
417
+ //-------------------------------------------------------------------------------------------------------
418
+ }
419
+ //--------------------------------------------------------------------------------------------------------------------------------------
420
+ ?>
421
+ <style type="text/css">
422
+ .orbitvu_sun_presentation, .orbitvu_sun_presentation_full { float: left; width: 250px; background: white; border: 1px solid #dedede; border-radius: 5px; margin: 10px 10px 0 0; padding: 10px; cursor: pointer; }
423
+ .orbitvu_sun_presentation_full { float: none; width: 100%; clear: both; overflow: hidden; zoom: 1.0; cursor: default; box-sizing: border-box; }
424
+ .orbitvu_sun_presentation { border: 2px solid #1CA0B3; }
425
+
426
+ .orbitvu_sun_presentation_full table { width: 100%; margin: 0; padding: 0; border: 0; }
427
+ .orbitvu_sun_presentation_full table td { padding: 0; vertical-align: top; border: 0; background: white; }
428
+ .orbitvu_sun_presentation:hover { box-shadow: 0 0 15px black; }
429
+ .orbitvu_sun_presentation.orbitvu_nohover, .orbitvu_nohover { margin: 0 0 20px 0; border-color: #dedede; box-shadow: none; cursor: default; }
430
+ .orbitvu_sun_presentation img { float: left; width: 100px; height: 80px; margin: 0 10px 0 0; border-radius: 5px; }
431
+ .orbitvu_sun_presentation .presentation_data { float: left; min-height: 80px; color: black; font-weight: normal; position: relative; }
432
+ .orbitvu_clearfix { clear: both; overflow: hidden; zoom: 1.0; }
433
+
434
+ .orbitvu-button, .orbitvu-button-disabled { border-color: #1191A6; background: #8dd5e0; background: -moz-linear-gradient(top, #8dd5e0 0%, #009cb5 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8dd5e0), color-stop(45%,#009cb5)); background: -webkit-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -o-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: -ms-linear-gradient(top, #8dd5e0 0%,#009cb5 45%); background: linear-gradient(to bottom, #8dd5e0 0%,#009cb5 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8dd5e0', endColorstr='#009cb5',GradientType=0 ); }
435
+ .orbitvu-button:hover { background: #ddfaff; background: -moz-linear-gradient(top, #ddfaff 0%, #15adc6 59%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ddfaff), color-stop(59%,#15adc6)); background: -webkit-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: -o-linear-gradient(top, #ddfaff 0%,#15adc6 59%);background: -ms-linear-gradient(top, #ddfaff 0%,#15adc6 59%); background: linear-gradient(to bottom, #ddfaff 0%,#15adc6 59%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ddfaff', endColorstr='#15adc6',GradientType=0 ); }
436
+ .orbitvu-icon { background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/blue.png); background-repeat: no-repeat; }
437
+ .orbitvu-icon-visibility { background-position: 0 -54px; }
438
+ .orbitvu-icon-visibility.disabled { background-position: -22px -54px; }
439
+ .orbitvu-icon-type-0 { background-position: 0 -92px; }
440
+ .orbitvu-icon-type-1 { background-position: -80px -108px; }
441
+ .orbitvu-icon-type-3 { background-position: -16px -92px; }
442
+ .orbitvu-drag-container { clear: both; overflow: hidden; zoom: 1.0; padding: 10px; }
443
+ .orbitvu-drag-box { float: left; margin: 0 10px 10px 0; width: 100px; height: 100px; position: relative; border: 2px solid #1CA0B3; font-size: 10px; cursor: default; font-family: verdana, tahoma, arial; background-color: #eee; border-radius: 5px; }
444
+ #orbitvu-drag-container .orbitvu-drag-box { cursor: pointer; }
445
+ .orbitvu-drag-box.hidden { border-color: #F1D6DA; opacity: 0.7; }
446
+ .orbitvu-drag-box.drag { opacity: 0.2; }
447
+ #orbitvu-drag-container .orbitvu-drag-box:hover { border-style: dashed; }
448
+ .orbitvu-drag-box span.orbitvu-text { padding: 2px 0 2px 0; position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; color: white; background: #1CA0B3; font-size: 10px; }
449
+
450
+ .orbitvu-drag-box span.orbitvu-drag-text { display: none; }
451
+ #orbitvu-drag-container .orbitvu-drag-box:hover span.orbitvu-drag-text { display: block; }
452
+ .orbitvu-drag-box span.orbitvu-hide-text { display: none; }
453
+ .orbitvu-drag-box span.orbitvu-hide-text.active { display: block; }
454
+ .orbitvu-drag-box span.orbitvu-show-text { display: none; }
455
+ .orbitvu-drag-box span.orbitvu-show-text.active { display: block; }
456
+ .orbitvu-drag-box span.orbitvu-visibility { display: block; width: 22px; height: 22px; position: absolute; top: -7px; right: -7px; background-color: white; border-radius: 8px; cursor: pointer; }
457
+ .orbitvu-drag-box span.orbitvu-visibility:hover { box-shadow: 0 0 5px black; }
458
+
459
+ .orbitvu-drag-box span.orbitvu-type { display: block; width: 16px; height: 16px; position: absolute; bottom: 2px; right: 2px; }
460
+
461
+ .orbitvu-button-sku { border-color: #CA6875; background: #e0b3b8; background: -moz-linear-gradient(top, #e0b3b8 0%, #ca4759 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e0b3b8), color-stop(45%,#ca4759)); background: -webkit-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: -o-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: -ms-linear-gradient(top, #e0b3b8 0%,#ca4759 45%); background: linear-gradient(to bottom, #e0b3b8 0%,#ca4759 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0b3b8', endColorstr='#ca4759',GradientType=0 ); }
462
+ .orbitvu-button-sku:hover { background: #ffced3;background: -moz-linear-gradient(top, #ffced3 0%, #e8475d 45%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffced3), color-stop(45%,#e8475d)); background: -webkit-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: -o-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: -ms-linear-gradient(top, #ffced3 0%,#e8475d 45%); background: linear-gradient(to bottom, #ffced3 0%,#e8475d 45%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffced3', endColorstr='#e8475d',GradientType=0 ); }
463
+ button.orbitvu-button-sku span span,
464
+ button.orbitvu-button-edit span span,
465
+ button.orbitvu-button-sync span span,
466
+ button.orbitvu-button-unlink span span,
467
+ button.orbitvu-button-link span span,
468
+ button.orbitvu-button-ok span span,
469
+ button.orbitvu-button-enable-items span span,
470
+ button.orbitvu-button-disable-items span span,
471
+ button.orbitvu-button-cancel span span { float: left; width: 16px; height: 16px; margin: 0 4px 0 0 !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/white.png) !important; background-repeat: no-repeat; }
472
+
473
+ button.orbitvu-button-sku span span { background-position: -32px -108px !important; }
474
+ button.orbitvu-button-edit span span { background-position: -48px -108px !important; }
475
+ button.orbitvu-button-sync span span { background-position: -64px -108px !important; }
476
+ button.orbitvu-button-unlink span span { background-position: -16px -108px !important; }
477
+ button.orbitvu-button-enable-items span span { background-position: 0px -76px !important; }
478
+ button.orbitvu-button-disable-items span span { background-position: -16px -76px !important; }
479
+ button.orbitvu-button-link span span { background-position: 0 -108px !important; }
480
+ button.orbitvu-button-ok span span { background-position: -32px -76px !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png) !important; }
481
+ button.orbitvu-button-cancel span span { background-position: -48px -76px !important; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png) !important; }
482
+ button.orbitvu-button-disabled { opacity: 0.5; cursor: default; }
483
+ button.orbitvu-button-disabled:hover, button.orbitvu-button-disabled.active { background: url(<?=$this->getSkinUrl('images/btn_bg-disabled.gif')?>) 0px 0px repeat-x #919191 !important; opacity: 0.5 !important; }
484
+ .dragstate span.orbitvu-visibility { display: none !important; }
485
+
486
+ .presentation_types { width: 80px; position: absolute; bottom: 5px; left: 0; }
487
+ .orbitvu-type { float: left; width: 16px; height: 16px; margin: 0 5px 0 0; }
488
+
489
+ .orbitvu-icon-bg { background-color: white; border: 2px solid white; border-radius: 5px; }
490
+ #orbitvu_postloader { display: none; }
491
+ #orbitvu_postloader_bg { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 999998; background: white; opacity: 0.8; }
492
+ #orbitvu_postloader_fg { position: fixed; width: 100%; top: 0; left: 0; z-index: 999999; text-align: center; }
493
+ </style>
494
+ <div id="orbitvu_postloader">
495
+ <div id="orbitvu_postloader_bg"></div>
496
+ <div id="orbitvu_postloader_fg"><img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" style="margin-top: 150px;" alt="" /></div>
497
+ </div>
498
+ <script>
499
+ window.onbeforeunload = function() {
500
+ document.getElementById('orbitvu_postloader').style.display = 'block';
501
+ }
502
+ </script>
503
+ <div class="entry-edit orbitvu_clearfix">
504
+
505
+ <?php if ($_action != 'set_show_all' && $found_match) {
506
+ echo $observer->UseTemplate(array(
507
+ 'name' => $this->__('Confirm linking matched presentation')
508
+
509
+ ), $__templates['magento_section_start']);
510
+
511
+ ?>
512
+
513
+ <?php } ?>
514
+ <input type="hidden" name="synchronize_sun" value="false" id="synchronize_sun" />
515
+ <div id="orbitvu_sun_content">
516
+ <ul class="messages">
517
+ <?php for ($i = 0, $n = count($_messages); $i < $n; $i++) { ?>
518
+ <li class="<?=$_messages[$i][0]?>-msg">
519
+ <ul>
520
+ <li>
521
+ <?=$_messages[$i][1]?>
522
+ </li>
523
+ </ul>
524
+ </li>
525
+ <?php } ?>
526
+ </ul>
527
+ </div>
528
+
529
+ </div>
530
+ <?php
531
+ //--------------------------------------------------------------------------------------------------------------------------------------
532
+ /*
533
+ * Show tabs if match not found
534
+ */
535
+ //-------------------------------------------------------------------------------------------------------------------------------------
536
+ if (!$found_match) {
537
+ ?>
538
+ <div class="grid" id="local_magento">
539
+ <?php
540
+ }
541
+ else {
542
+ ?>
543
+ <div style="display: none;">
544
+ <?php
545
+ }
546
+ //--------------------------------------------------------------------------------------------------------------------------------------
547
+ /*
548
+ * First time presentation setting
549
+ */
550
+ //--------------------------------------------------------------------------------------------------------------------------------------
551
+ if ($items_count == 0 && !$found_match) {
552
+ //--------------------------------------------------------------------------------------------------------------------------------------
553
+
554
+ if ($orbitvu_connected) {
555
+ $results = $presentations_choose->results;
556
+
557
+ $OrbitvuPager = array(
558
+ 'start' => $OrbitvuCurrentPage,
559
+ 'size' => $OrbitvuPagerPageSize,
560
+ 'all' => intval(round($presentations_choose->count / $OrbitvuPagerPageSize))
561
+ );
562
+
563
+ $OrbitvuPager['url_next'] = $this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/pager_start/'.($OrbitvuPager['start'] + 1));
564
+ $OrbitvuPager['url_prev'] = $this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/pager_start/'.($OrbitvuPager['start'] - 1));
565
+
566
+ //--------------------------------------------------------------------------------------------------------------------------------------
567
+ echo $observer->UseTemplate(array(
568
+ 'name' => $this->__('Select presentation from your Orbitvu SUN account to link with product').' '.$product_name
569
+ ), $__templates['magento_section_start']);
570
+ //--------------------------------------------------------------------------------------------------------------------------------------
571
+ ?>
572
+ <table cellspacing="0" class="actions" style="width: 98%; margin: 0 0 0 10px;">
573
+ <tbody>
574
+ <tr>
575
+ <td class="pager" style="width: 350px;">
576
+ <?=$this->__('Page:')?>
577
+
578
+ <?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']-1 >= 0) { ?>
579
+ <a href="<?=$OrbitvuPager['url_prev']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_left.gif')?>" alt="" class="arrow"></a>
580
+ <?php } else { ?>
581
+ <img src="<?=$this->getSkinUrl('images/pager_arrow_left_off.gif')?>" alt="" class="arrow">
582
+ <?php } ?>
583
+
584
+ <strong><?=($OrbitvuPager['start']+1)?></strong>
585
+
586
+ <?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']+1 < $OrbitvuPager['all']) { ?>
587
+ <a href="<?=$OrbitvuPager['url_next']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_right.gif')?>" alt="" class="arrow"></a>
588
+ <?php } else { ?>
589
+ <img src="<?=$this->getSkinUrl('images/pager_arrow_right_off.gif')?>" alt="" class="arrow">
590
+ <?php } ?>
591
+
592
+ <?=$this->__('of')?> <?=$OrbitvuPager['all']?>
593
+ <span class="separator">|</span>
594
+ <?=$this->__('Per page:')?>
595
+ <select name="pager_size" onchange="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>page_size/' + this.value + '/';">
596
+ <option value="20"<?=($OrbitvuPager['size'] == '20' ? ' selected="selected"' : '')?>>20</option>
597
+ <option value="30"<?=($OrbitvuPager['size'] == '30' ? ' selected="selected"' : '')?>>30</option>
598
+ <option value="50"<?=($OrbitvuPager['size'] == '50' ? ' selected="selected"' : '')?>>50</option>
599
+ <option value="100"<?=($OrbitvuPager['size'] == '100' ? ' selected="selected"' : '')?>>100</option>
600
+ <option value="200"<?=($OrbitvuPager['size'] == '200' ? ' selected="selected"' : '')?>>200</option>
601
+ </select>
602
+ <span class="separator">|</span>
603
+ <?=$this->__('Total:')?> <?=intval($presentations_choose->count)?>
604
+ </td>
605
+ <td class="filter-actions">
606
+ <div class="orbitvu_filters">
607
+ <select name="sun_ordering" style="width: 70px;" onchange="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_ordering/' + this.value + '/';">
608
+ <option value="create_date"<?=($OrbitvuOrdering == 'create_date' ? ' selected="selected"' : '')?>><?=$this->__('Date')?> &uArr;</option>
609
+ <option value="-create_date"<?=($OrbitvuOrdering == '-create_date' ? ' selected="selected"' : '')?>><?=$this->__('Date')?> &dArr;</option>
610
+ <option value="sku"<?=($OrbitvuOrdering == 'sku' ? ' selected="selected"' : '')?>><?=$this->__('SKU')?> &uArr;</option>
611
+ <option value="-sku"<?=($OrbitvuOrdering == '-sku' ? ' selected="selected"' : '')?>><?=$this->__('SKU')?> &dArr;</option>
612
+ <option value="name"<?=($OrbitvuOrdering == 'name' ? ' selected="selected"' : '')?>><?=$this->__('Name')?> &uArr;</option>
613
+ <option value="-name"<?=($OrbitvuOrdering == '-name' ? ' selected="selected"' : '')?>><?=$this->__('Name')?> &dArr;</option>
614
+ </select>
615
+ <input type="text" name="sun_search" id="orbitvu_sun_search" placeholder="<?=$this->__('Enter presentation name or SKU...')?>"<?php
616
+ if (!empty($OrbitvuKeyword)) { echo ' value="'.$OrbitvuKeyword.'"'; }
617
+ ?> size="30" />
618
+ <button type="button" class="orbitvu-button scalable task" onclick="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_keyword/' + document.getElementById('orbitvu_sun_search').value + '/';"><span><span><span><?=$this->__('Search')?></span></span></span></button>
619
+ <?php if (!empty($OrbitvuKeyword)) { ?>
620
+ <button type="button" class="orbitvu-button scalable task" onclick="window.location.href = '<?=$this->getUrl('*/catalog_product/edit/id/'.$product_id.'/back/edit/tab/product_info_tabs_tabid/sun/set_show_all/')?>sun_keyword_reset/true/';"><span><span><span><?=$this->__('Reset')?></span></span></span></button>
621
+ <?php } ?>
622
+ </div>
623
+ </td>
624
+ </tr>
625
+ </tbody>
626
+ </table>
627
+
628
+
629
+ <div class="orbitvu_clearfix" style="padding: 10px;">
630
+ <?php
631
+ /*
632
+ * Presentations final display
633
+ */
634
+ for ($i = 0, $n = count($results); $i < $n; $i++) {
635
+ $cur = $results[$i];
636
+
637
+ $types = $_Orbitvu->GetPresentationTypes($cur);
638
+ $new_types = array();
639
+ foreach ($types as $type) {
640
+ switch ($type) {
641
+ case '0':
642
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0" title="'.$this->__('Orbittour').'"></span>';
643
+ break;
644
+ case '1':
645
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1" title="'.$this->__('360&deg;').'"></span>';
646
+ break;
647
+ default:
648
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3" title="'.$this->__('2D').'"></span>';
649
+ break;
650
+ }
651
+ }
652
+ $types = $new_types;
653
+
654
+ $sku = $cur->sku;
655
+ //-------------------------------------------------------------------------------------------------------
656
+ if (!empty($sku)) {
657
+ if (strlen($sku) > 10) {
658
+ $sku = '<span title="'.$sku.'">'.mb_substr($sku, 0, 10, 'utf-8').'...</span>';
659
+ }
660
+ }
661
+ else {
662
+ $sku = '-';
663
+ }
664
+ //-------------------------------------------------------------------------------------------------------
665
+ $str = $cur->name;
666
+ if (strlen($str) > 15 ) $str = mb_substr($str, 0, 15, 'utf-8').'...';
667
+ //-------------------------------------------------------------------------------------------------------
668
+ echo $observer->UseTemplate(array(
669
+ 'parameters' => 'onclick="if (confirm(\''.$this->__('Do you really want to link this presentation with current product?').'\')) { OrbitvuSetAction(\'sun/set_presentation/presentation_id/'.$cur->id.'/\'); }"',
670
+ 'image_path' => $cur->thumbnail_url,
671
+ 'name' => $str,
672
+ 'sku' => $sku,
673
+ 'types' => implode('', $types)
674
+ ), $__templates['presentation_item']);
675
+ }
676
+ ?>
677
+ </div>
678
+ <?php
679
+ }
680
+ else {
681
+ //--------------------------------------------------------------------------------------------------------------------------------------
682
+ echo $observer->UseTemplate(array(
683
+ 'name' => $product_name
684
+ ), $__templates['magento_section_start']);
685
+ //--------------------------------------------------------------------------------------------------------------------------------------
686
+ }
687
+ }
688
+ else {
689
+ /*************************************************************************************************************************************************
690
+ * Item edit
691
+ ************************************************************************************************************************************************/
692
+
693
+ $presentation_sun = $_Orbitvu->GetPresentationsList(array('id' => $presentations['orbitvu_id']));
694
+ $presentation_sun = $presentation_sun->results[0];
695
+
696
+ $sku = $presentation_sun->sku;
697
+ //-------------------------------------------------------------------------------------------------------
698
+ if (!empty($sku)) {
699
+ $sku = '<span title="'.$sku.'">'.$sku.'</span>';
700
+ }
701
+ else {
702
+ $sku = '-';
703
+ }
704
+ //--------------------------------------------------------------------------------------------------------------------------------------
705
+ echo $observer->UseTemplate(array(
706
+ 'name' => $this->__('Orbitvu SUN presentation linked to current product')
707
+ ), $__templates['magento_section_start']);
708
+ //--------------------------------------------------------------------------------------------------------------------------------------
709
+ $add_buttons = '';
710
+
711
+ $thumbnail = $presentations['items'][0]['thumbnail'];
712
+ if ($presentations) {
713
+ foreach ($presentations['items'] as $item) {
714
+ if ($item['status'] == 'active') {
715
+ $thumbnail = $item['thumbnail'];
716
+ break;
717
+ }
718
+ }
719
+ }
720
+ ?>
721
+ <div class="orbitvu_sun_presentation_full">
722
+ <table><td><td style="width: 1%;">
723
+ <div style="position: relative;">
724
+ <img src="<?=$thumbnail?>?height=200" style="margin: 0; padding: 0; border: 1px solid #dedede; border-radius: 5px;" alt="">
725
+ <div style="position: absolute; bottom: 10px; right: 5px;">
726
+ <?php
727
+
728
+ $types = $presentations['types'];
729
+ $new_types = array();
730
+ if ($types) {
731
+ foreach ($types as $type) {
732
+ switch ($type) {
733
+ case '0':
734
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-0 orbitvu-icon-bg" title="'.$this->__('Orbittour').'"></span>';
735
+ break;
736
+ case '1':
737
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-1 orbitvu-icon-bg" title="'.$this->__('360&deg;').'"></span>';
738
+ break;
739
+ default:
740
+ $new_types[] = '<span class="orbitvu-type orbitvu-icon orbitvu-icon-type-3 orbitvu-icon-bg" title="'.$this->__('2D').'"></span>';
741
+ break;
742
+ }
743
+ }
744
+ $types = $new_types;
745
+
746
+ print implode('', $types);
747
+ }
748
+ ?>
749
+ </div>
750
+ </div>
751
+ </td><td style="padding-left: 20px;">
752
+
753
+ <div class="presentation_data">
754
+ <strong style="font-size: 1.5em;"><?=$presentations['name']?></strong><br>
755
+
756
+ <?php if ($presentation_sun->sku != $product_sku) {
757
+ $update_sku = $_Orbitvu->SetSunPresentationSku($presentations['orbitvu_id'], $product_sku, $presentation_sun->sku);
758
+
759
+ if (!$update_sku && $orbitvu_connected) {
760
+
761
+ if (!$orbitvu_demo) {
762
+ $add_buttons .= '<button type="button" class="orbitvu-button-sku scalable" onclick="if (confirm(\''.$this->__('Do you really want to update this presentation SKU on your Orbitvu SUN account?').'\')) { OrbitvuSetAction(\'sun/set_sku/presentation_id/'.$presentations['orbitvu_id'].'/sun_new_sku/'.$product_sku.'\'); }"><span><span></span>'.$this->__('Update SKU on SUN').'</span></button> ';
763
+ }
764
+ else {
765
+ $add_buttons .= '<button type="button" class="orbitvu-button-sku scalable disabled orbitvu-button-disabled"><span><span></span>'.$this->__('Update SKU on SUN').'</span></button> ';
766
+ }
767
+ ?>
768
+ <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
769
+ <ul class="messages" style="float: left; max-width: 680px;">
770
+ <li class="error-msg">
771
+ <ul>
772
+ <li>
773
+
774
+ <?=$this->__('Product\'s SKU:')?> "<?=$product_sku?>" <?=$this->__('. Presentation\'s SKU from Orbitvu SUN:')?> <?=($sku == '-' ? '""' : '"'.$sku.'"')?>. <br /> <?=$this->__('Click "Update SKU on SUN" button below to update your presentation\'s SKU from Orbitvu SUN with:')?> "<?=$product_sku?>".
775
+ </li>
776
+ </ul>
777
+ </li>
778
+ </ul>
779
+ <?php } else if ($update_sku->error == '400') {
780
+ ?>
781
+ <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
782
+ <ul class="messages">
783
+
784
+ <li class="error-msg">
785
+ <ul>
786
+ <li>
787
+ <?=$this->__('We can\'t change your SUN Presentation SKU. One of your presentations already has this product SKU assigned. SKU need to be unique. Modify SKU on your SUN Server.')?>
788
+ </li>
789
+ </ul>
790
+ </li>
791
+
792
+ </ul>
793
+
794
+
795
+ <?php
796
+
797
+ }
798
+
799
+ else { ?>
800
+ <strong><?=$this->__('SKU')?>:</strong> <?=$product_sku?><br>
801
+ <?php
802
+ }
803
+ }
804
+ else { ?>
805
+ <strong><?=$this->__('SKU')?>:</strong> <?=$sku?><br>
806
+ <?php } ?>
807
+ <div class="orbitvu_clearfix" style="padding-top: 10px;">
808
+ <?=$add_buttons?>
809
+ <button type="button" class="orbitvu-button orbitvu-button-unlink scalable" onclick="if (confirm('<?=$this->__('Do you really want to unlink this presentation?')?>')) { OrbitvuSetAction('sun/unlink/'); }"><span><span></span><?=$this->__('Unlink this presentation')?></span></button>
810
+
811
+ <button type="button" class="orbitvu-button orbitvu-button-sync scalable" onclick="SynchronizeSunItems();"><span><span></span><?=$this->__('Synchronize with SUN')?></span></button>
812
+
813
+ <?php
814
+ $presentation_sun = $_Orbitvu->GetPresentationsList(array('id' => $presentations['orbitvu_id']));
815
+ $presentation_sun = $presentation_sun->results[0];
816
+ ?>
817
+
818
+ <?php if ($orbitvu_connected && !$orbitvu_demo && isset($presentation_sun->edit_url)) { ?><button type="button" class="orbitvu-button orbitvu-button-edit scalable"><span><span></span><a href="<?=$presentation_sun->edit_url?>" target="_blank" style="color: white; text-decoration: none;"><?=$this->__('Edit on SUN')?></a></span></button> <?php } else { ?><button type="button" class="orbitvu-button-edit scalable disabled orbitvu-button-disabled" disabled="disabled"><span style="padding-left: 0; background: none;"><span></span><?=$this->__('Edit on SUN')?></span></button>
819
+ <?php } ?> </div>
820
+
821
+ <div class="orbitvu_clearfix" style="padding-top: 10px">
822
+
823
+ <button type="button" id="orbitvu-button-enable-items" class="orbitvu-button orbitvu-button-enable-items scalable" onclick="enable_all_items();"><span><span></span><?=$this->__('Enable items')?></span></button>
824
+ <img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" id="enable_all_items_loader" style="display: none" alt="" />
825
+
826
+ <button type="button" id="orbitvu-button-disable-items" class="orbitvu-button orbitvu-button-disable-items scalable" onclick="disable_all_items();"><span><span></span><?=$this->__('Disable items')?></span></button>
827
+ <img src="<?=Mage::getBaseUrl('media')?>orbitvu/loader.gif" id="disable_all_items_loader" style="display: none" alt="" />
828
+
829
+ </div>
830
+
831
+ <?php if ($CurrentProduct->isConfigurable()): ?>
832
+ <div class="orbitvu_clearfix" style="padding-top: 10px">
833
+ <ul class="messages">
834
+ <li class="notice-msg">
835
+ <ul>
836
+ <li>
837
+ <?=$this->__('This option affect only associated products which don\'t have any images.')?>
838
+ <div style="padding-top: 10px;">
839
+ <input id="orbitvu-no-assign-configurable" name="orbitvu_assign_configurable" value="0" type="radio" checked="checked"><label for="orbitvu-no-assign-configurable"> <?=$this->__('Don\'t assign Orbitvu thumbnail to associated products'); ?></label><br />
840
+ <input id="orbitvu-assign-configurable" name="orbitvu_assign_configurable" value="1" type="radio"><label for="orbitvu-assign-configurable"> <?=$this->__('Assign Orbitvu thumbnail to associated products'); ?></label>
841
+ </div>
842
+ </li>
843
+ </ul>
844
+ </li>
845
+ </ul>
846
+ </div>
847
+ <?php endif; ?>
848
+
849
+ </div>
850
+
851
+ </td></tr></table>
852
+
853
+ <div id="<?=($items_count > 1 ? 'orbitvu-drag-container' : '')?>" class="orbitvu-drag-container" history="History1" style="border-top: 1px solid #dedede;">
854
+ <?php
855
+ for ($i = 0; $i < $items_count; $i++) {
856
+ $items = $presentations['items'][$i];
857
+
858
+ $display_id = $items['id'];
859
+ ?>
860
+ <div class="orbitvu-drag-box<?=($items['status'] == 'inactive' ? ' hidden' : '')?>" id="orbitvu-gallery-item-<?=$display_id?>" style="background: white url(<?=$items['thumbnail']?>?width=100) center center no-repeat;">
861
+
862
+ <span class="orbitvu-icon orbitvu-type orbitvu-icon-type-<?=$items['type']?>" title="<?php
863
+ switch ($items['type']) {
864
+ case '0': echo $this->__('Orbittour'); break;
865
+ case '1': echo $this->__('360&deg;'); break;
866
+ default: echo $this->__('2D'); break;
867
+ }
868
+ ?>"></span>
869
+
870
+ <span class="orbitvu-text orbitvu-drag-text">
871
+ <?=$this->__('Drag &amp; move item')?>
872
+ </span>
873
+
874
+ <span class="orbitvu-text orbitvu-hide-text" id="orbitvu-text-hide-<?=$display_id?>">
875
+ <?=$this->__('Hide item')?>
876
+ </span>
877
+
878
+ <span class="orbitvu-text orbitvu-show-text" id="orbitvu-text-show-<?=$display_id?>">
879
+ <?=$this->__('Show item')?>
880
+ </span>
881
+
882
+
883
+
884
+ <span class="orbitvu-visibility orbitvu-icon orbitvu-icon-visibility<?=($items['status'] == 'inactive' ? ' disabled' : '')?>" id="orbitvu-visibility-trigger-<?=$display_id?>"></span>
885
+ </div>
886
+ <?php } ?>
887
+ </div>
888
+
889
+ </div>
890
+ <script>
891
+ function orbitvu_ajax(file, func) {
892
+ var obj = null;
893
+ if (window.XMLHttpRequest) obj = new XMLHttpRequest();
894
+ else if (window.ActiveXObject) obj = new ActiveXObject('Microsoft.XMLHTTP');
895
+ else return false;
896
+
897
+ obj.onreadystatechange = function() {
898
+ if (this.readyState == 4) func(this.responseText);
899
+ };
900
+ obj.open('GET', file, true);
901
+ obj.send(null);
902
+ }
903
+
904
+ function orbitvu_drag_start() {
905
+ if (document.getElementsByClassName('orbitvu-drag-box')) {
906
+ var elems = document.getElementsByClassName('orbitvu-drag-box');
907
+
908
+ for (var i = 0, n = elems.length; i < n; i++) {
909
+ if (elems[i]) {
910
+ elems[i].className += ' drag';
911
+ }
912
+ }
913
+ }
914
+ //orbitvu_log('Drag start!');
915
+ }
916
+
917
+ function orbitvu_drag_end() {
918
+ if (document.getElementsByClassName('orbitvu-drag-box')) {
919
+ var elems = document.getElementsByClassName('orbitvu-drag-box');
920
+
921
+ //orbitvu_log('Drag end!');
922
+
923
+ for (var i = 0, n = elems.length; i < n; i++) {
924
+ if (elems[i]) {
925
+ elems[i].className = elems[i].className.replace(' drag', '');
926
+ }
927
+ }
928
+ }
929
+ }
930
+
931
+ function enable_all_items() {
932
+ var elems = document.getElementsByClassName('orbitvu-visibility'),
933
+ button = document.getElementById('orbitvu-button-enable-items'),
934
+ img = document.getElementById('enable_all_items_loader'),
935
+ ids = [],
936
+ proper_elems = [];
937
+
938
+ button.style.display = 'none';
939
+ img.style.display = 'inline-block';
940
+ for (var i = 0, n = elems.length; i < n; i++) {
941
+ if (elems[i].className.replace(' disabled', '') !== elems[i].className) {
942
+ ids.push(parseInt(elems[i].id.replace('orbitvu-visibility-trigger-', '')));
943
+ proper_elems.push(elems[i]);
944
+ }
945
+ }
946
+ if (ids.length) {
947
+ orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_statuses/sun_items_statuses/' + ids.join(',') + '/sun_status/active', function(data){
948
+ data = JSON.parse(data);
949
+ if (data.status) {
950
+ for (var i = 0, n = proper_elems.length; i < n; i++) {
951
+ proper_elems[i].className = proper_elems[i].className.replace(' disabled', '');
952
+ document.getElementById('orbitvu-gallery-item-' + ids[i]).className = document.getElementById('orbitvu-gallery-item-' + ids[i]).className.replace(' hidden', '');
953
+ }
954
+ button.style.display = 'inline-block';
955
+ img.style.display = 'none';
956
+ }
957
+ });
958
+ } else {
959
+ button.style.display = 'inline-block';
960
+ img.style.display = 'none';
961
+ }
962
+ }
963
+
964
+ function disable_all_items() {
965
+ var elems = document.getElementsByClassName('orbitvu-visibility'),
966
+ button = document.getElementById('orbitvu-button-disable-items'),
967
+ img = document.getElementById('disable_all_items_loader'),
968
+ ids = [],
969
+ proper_elems = [];
970
+
971
+ button.style.display = 'none';
972
+ img.style.display = 'inline-block';
973
+ for (var i = 0, n = elems.length; i < n; i++) {
974
+ if (elems[i].className.replace(' disabled', '') === elems[i].className) {
975
+ ids.push(parseInt(elems[i].id.replace('orbitvu-visibility-trigger-', '')));
976
+ proper_elems.push(elems[i]);
977
+ }
978
+ }
979
+ if (ids.length) {
980
+ orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_statuses/sun_items_statuses/' + ids.join(','), function(data){
981
+ data = JSON.parse(data);
982
+ if (data.status) {
983
+ for (var i = 0, n = proper_elems.length; i < n; i++) {
984
+ proper_elems[i].className += ' disabled';
985
+ document.getElementById('orbitvu-gallery-item-' + ids[i]).className += ' hidden';
986
+ }
987
+ button.style.display = 'inline-block';
988
+ img.style.display = 'none';
989
+ }
990
+ });
991
+ } else {
992
+ button.style.display = 'inline-block';
993
+ img.style.display = 'none';
994
+ }
995
+ }
996
+
997
+ var elems = document.getElementsByClassName('orbitvu-visibility');
998
+
999
+ for (var i = 0, n = elems.length; i < n; i++) {
1000
+ elems[i].onmouseover = function() {
1001
+ var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
1002
+
1003
+ if (this.className.replace(' disabled', '') != this.className) {
1004
+ document.getElementById('orbitvu-text-show-' + this_id).className += ' active';
1005
+ document.getElementById('orbitvu-text-hide-' + this_id).className = document.getElementById('orbitvu-text-hide-' + this_id).className.replace(' active', '');
1006
+ }
1007
+ else {
1008
+ document.getElementById('orbitvu-text-hide-' + this_id).className += ' active';
1009
+ document.getElementById('orbitvu-text-show-' + this_id).className = document.getElementById('orbitvu-text-show-' + this_id).className.replace(' active', '');
1010
+ }
1011
+ }
1012
+
1013
+ elems[i].onmouseout = function() {
1014
+ var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
1015
+
1016
+ document.getElementById('orbitvu-text-hide-' + this_id).className = document.getElementById('orbitvu-text-hide-' + this_id).className.replace(' active', '');
1017
+ document.getElementById('orbitvu-text-show-' + this_id).className = document.getElementById('orbitvu-text-show-' + this_id).className.replace(' active', '');
1018
+ }
1019
+
1020
+ elems[i].onclick = function() {
1021
+ var this_id = parseInt(this.id.replace('orbitvu-visibility-trigger-', ''));
1022
+
1023
+ if (this.className.replace(' disabled', '') != this.className) {
1024
+ this.className = this.className.replace(' disabled', '');
1025
+ document.getElementById('orbitvu-gallery-item-' + this_id).className = document.getElementById('orbitvu-gallery-item-' + this_id).className.replace(' hidden', '');
1026
+
1027
+ orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_status/sun_item_id/' + this_id + '/sun_status/active', function(odp){});
1028
+ }
1029
+ else {
1030
+ this.className += ' disabled';
1031
+ document.getElementById('orbitvu-gallery-item-' + this_id).className += ' hidden';
1032
+
1033
+ orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_status/sun_item_id/' + this_id, function(odp){});
1034
+ }
1035
+ }
1036
+ }
1037
+ var orbitvu_mouse_offset = null;
1038
+ var orbitvu_i_mouse_down = false;
1039
+ var orbitvu_l_mouse_state = false;
1040
+ var orbitvu_drag_object = null;
1041
+ var orbitvu_drag_drops = [];
1042
+ var OrbitvuCurrentTarget = null;
1043
+ var OrbitvuLastTarget = null;
1044
+ var OrbitvuDragTemp = null;
1045
+ var OrbitvuTempDiv = null;
1046
+ var OrbitvuRootParent = null;
1047
+ var OrbitvuRootSibling = null;
1048
+ var orbitvu_final_node, orbitvu_final_item_id;
1049
+ var OrbitvuD1Target = null;
1050
+
1051
+ Number.prototype.NaN0 = function() {
1052
+ return isNaN(this) ? 0 : this;
1053
+ }
1054
+
1055
+ function orbitvu_create_drag_container() {
1056
+
1057
+ var cDrag = orbitvu_drag_drops.length;
1058
+ orbitvu_drag_drops[cDrag] = [];
1059
+
1060
+
1061
+ for (var i = 0; i < arguments.length; i++) {
1062
+ var cObj = arguments[i];
1063
+ orbitvu_drag_drops[cDrag].push(cObj);
1064
+ cObj.setAttribute('DropObj', cDrag);
1065
+
1066
+
1067
+ for (var j = 0; j < cObj.childNodes.length; j++) {
1068
+
1069
+
1070
+ if (cObj.childNodes[j].nodeName == '#text')
1071
+ continue;
1072
+
1073
+ cObj.childNodes[j].setAttribute('DragObj', cDrag);
1074
+ }
1075
+ }
1076
+ }
1077
+
1078
+ function orbitvu_get_position(e) {
1079
+ var left = 0;
1080
+ var top = 0;
1081
+ while (e.offsetParent) {
1082
+ left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
1083
+ top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
1084
+ e = e.offsetParent;
1085
+ }
1086
+
1087
+
1088
+ left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
1089
+ top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
1090
+
1091
+ return {x: left, y: top};
1092
+
1093
+ }
1094
+
1095
+ function orbitvu_mouse_coords(ev) {
1096
+ if (ev.pageX || ev.pageY) {
1097
+ return {x: ev.pageX, y: ev.pageY};
1098
+ }
1099
+ return {
1100
+ x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
1101
+ y: ev.clientY + document.body.scrollTop - document.body.clientTop
1102
+ };
1103
+ }
1104
+
1105
+ function orbitvu_log(object, message) {
1106
+ if (!object || !object.parentNode || !object.parentNode.getAttribute)
1107
+ return;
1108
+ //console.log(object.id + ': ' + message);
1109
+ }
1110
+
1111
+ function orbitvu_get_mouse_offset(target, ev) {
1112
+ ev = ev || window.event;
1113
+
1114
+ var docPos = orbitvu_get_position(target);
1115
+ var mousePos = orbitvu_mouse_coords(ev);
1116
+ return {x: mousePos.x - docPos.x, y: mousePos.y - docPos.y};
1117
+ }
1118
+
1119
+ function orbitvu_mouse_move(ev) {
1120
+ ev = ev || window.event;
1121
+
1122
+
1123
+ var target = ev.target || ev.srcElement;
1124
+ var mousePos = orbitvu_mouse_coords(ev);
1125
+
1126
+
1127
+
1128
+ if (OrbitvuLastTarget && (target !== OrbitvuLastTarget)) {
1129
+ //orbitvu_log(OrbitvuLastTarget, 'Mouse Out Fired');
1130
+
1131
+
1132
+ var origClass = OrbitvuLastTarget.getAttribute('origClass');
1133
+ if (origClass)
1134
+ OrbitvuLastTarget.className = origClass;
1135
+ }
1136
+
1137
+
1138
+ var dragObj = target.getAttribute('DragObj');
1139
+
1140
+
1141
+ if (dragObj != null) {
1142
+
1143
+
1144
+ if (target != OrbitvuLastTarget) {
1145
+ //orbitvu_log(target, 'Mouse Over Fired');
1146
+
1147
+ var oClass = target.getAttribute('overClass');
1148
+ if (oClass) {
1149
+ target.setAttribute('origClass', target.className);
1150
+ target.className = oClass;
1151
+ }
1152
+ }
1153
+
1154
+
1155
+ if (orbitvu_i_mouse_down && !orbitvu_l_mouse_state) {
1156
+ orbitvu_log(target, 'Start Dragging');
1157
+
1158
+
1159
+ OrbitvuCurrentTarget = target;
1160
+
1161
+
1162
+ OrbitvuRootParent = OrbitvuCurrentTarget.parentNode;
1163
+ OrbitvuRootSibling = OrbitvuCurrentTarget.nextSibling;
1164
+
1165
+ orbitvu_mouse_offset = orbitvu_get_mouse_offset(target, ev);
1166
+
1167
+
1168
+ for (var i = 0; i < OrbitvuDragTemp.childNodes.length; i++)
1169
+ OrbitvuDragTemp.removeChild(OrbitvuDragTemp.childNodes[i]);
1170
+
1171
+
1172
+ OrbitvuDragTemp.appendChild(OrbitvuCurrentTarget.cloneNode(true));
1173
+ //OrbitvuDragTemp.style.display = 'block';
1174
+
1175
+
1176
+ var dragClass = OrbitvuCurrentTarget.getAttribute('dragClass');
1177
+ if (dragClass) {
1178
+ OrbitvuDragTemp.firstChild.className = dragClass;
1179
+ }
1180
+
1181
+
1182
+ OrbitvuDragTemp.firstChild.removeAttribute('DragObj');
1183
+
1184
+
1185
+ var dragConts = orbitvu_drag_drops[dragObj];
1186
+
1187
+
1188
+ OrbitvuCurrentTarget.setAttribute('startWidth', parseInt(OrbitvuCurrentTarget.offsetWidth));
1189
+ OrbitvuCurrentTarget.setAttribute('startHeight', parseInt(OrbitvuCurrentTarget.offsetHeight));
1190
+ OrbitvuCurrentTarget.style.display = 'none';
1191
+
1192
+ for (var i = 0; i < dragConts.length; i++) {
1193
+ with (dragConts[i]) {
1194
+ var pos = orbitvu_get_position(dragConts[i]);
1195
+
1196
+
1197
+ setAttribute('startWidth', parseInt(offsetWidth));
1198
+ setAttribute('startHeight', parseInt(offsetHeight));
1199
+ setAttribute('startLeft', pos.x);
1200
+ setAttribute('startTop', pos.y);
1201
+ }
1202
+
1203
+
1204
+ for (var j = 0; j < dragConts[i].childNodes.length; j++) {
1205
+ with (dragConts[i].childNodes[j]) {
1206
+ if ((nodeName == '#text') || (dragConts[i].childNodes[j] == OrbitvuCurrentTarget))
1207
+ continue;
1208
+
1209
+ var pos = orbitvu_get_position(dragConts[i].childNodes[j]);
1210
+
1211
+
1212
+ setAttribute('startWidth', parseInt(offsetWidth));
1213
+ setAttribute('startHeight', parseInt(offsetHeight));
1214
+ setAttribute('startLeft', pos.x);
1215
+ setAttribute('startTop', pos.y);
1216
+ }
1217
+ }
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+
1223
+ if (OrbitvuCurrentTarget) {
1224
+
1225
+ OrbitvuDragTemp.style.top = mousePos.y - orbitvu_mouse_offset.y;
1226
+ OrbitvuDragTemp.style.left = mousePos.x - orbitvu_mouse_offset.x;
1227
+
1228
+ var dragConts = orbitvu_drag_drops[OrbitvuCurrentTarget.getAttribute('DragObj')];
1229
+ var activeCont = null;
1230
+
1231
+ var xPos = mousePos.x - orbitvu_mouse_offset.x + (parseInt(OrbitvuCurrentTarget.getAttribute('startWidth')) / 2);
1232
+ var yPos = mousePos.y - orbitvu_mouse_offset.y + (parseInt(OrbitvuCurrentTarget.getAttribute('startHeight')) / 2);
1233
+
1234
+
1235
+ for (var i = 0; i < dragConts.length; i++) {
1236
+ with (dragConts[i]) {
1237
+ if ((parseInt(getAttribute('startLeft')) < xPos) &&
1238
+ (parseInt(getAttribute('startTop')) < yPos) &&
1239
+ ((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
1240
+ ((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {
1241
+
1242
+
1243
+ activeCont = dragConts[i];
1244
+
1245
+
1246
+ break;
1247
+ }
1248
+ }
1249
+ }
1250
+
1251
+
1252
+ if (activeCont) {
1253
+ if (activeCont != OrbitvuCurrentTarget.parentNode) {
1254
+ orbitvu_log(OrbitvuCurrentTarget, 'Moved into ' + activeCont.id);
1255
+ }
1256
+
1257
+
1258
+ var beforeNode = null;
1259
+
1260
+
1261
+ for (var i = activeCont.childNodes.length - 1; i >= 0; i--) {
1262
+ with (activeCont.childNodes[i]) {
1263
+ if (nodeName == '#text')
1264
+ continue;
1265
+
1266
+
1267
+ if (OrbitvuCurrentTarget != activeCont.childNodes[i] &&
1268
+ ((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
1269
+ ((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {
1270
+ beforeNode = activeCont.childNodes[i];
1271
+ }
1272
+ }
1273
+ }
1274
+
1275
+
1276
+ if (beforeNode) {
1277
+ if (beforeNode != OrbitvuCurrentTarget.nextSibling) {
1278
+ //`orbitvu_log(OrbitvuCurrentTarget, 'Ajax action -> Insert before ' + beforeNode.id);
1279
+ orbitvu_final_item_id = OrbitvuCurrentTarget.id;
1280
+ orbitvu_final_node = beforeNode.id;
1281
+ activeCont.insertBefore(OrbitvuCurrentTarget, beforeNode);
1282
+ }
1283
+
1284
+
1285
+ } else {
1286
+ if ((OrbitvuCurrentTarget.nextSibling) || (OrbitvuCurrentTarget.parentNode != activeCont)) {
1287
+ orbitvu_log(OrbitvuCurrentTarget, 'Inserted at end of ' + activeCont.id);
1288
+
1289
+ activeCont.appendChild(OrbitvuCurrentTarget);
1290
+ }
1291
+ }
1292
+
1293
+
1294
+ setTimeout(function() {
1295
+ var contPos = orbitvu_get_position(activeCont);
1296
+ activeCont.setAttribute('startWidth', parseInt(activeCont.offsetWidth));
1297
+ activeCont.setAttribute('startHeight', parseInt(activeCont.offsetHeight));
1298
+ activeCont.setAttribute('startLeft', contPos.x);
1299
+ activeCont.setAttribute('startTop', contPos.y);
1300
+ }, 5);
1301
+
1302
+
1303
+ if (OrbitvuCurrentTarget.style.display != '') {
1304
+ orbitvu_log(OrbitvuCurrentTarget, 'Made Visible');
1305
+ orbitvu_drag_start();
1306
+ OrbitvuCurrentTarget.style.display = '';
1307
+ OrbitvuCurrentTarget.className += ' dragstate';
1308
+ OrbitvuCurrentTarget.style.opacity = '1';
1309
+ OrbitvuCurrentTarget.style.cursor = 'move';
1310
+ OrbitvuCurrentTarget.style.borderStyle = 'dashed';
1311
+ OrbitvuCurrentTarget.style.boxShadow = '0 0 15px black';
1312
+ }
1313
+ } else {
1314
+
1315
+
1316
+ if (OrbitvuCurrentTarget.style.display != 'none') {
1317
+ orbitvu_log(OrbitvuCurrentTarget, 'Hidden');
1318
+ OrbitvuCurrentTarget.style.display = 'none';
1319
+ }
1320
+ }
1321
+ }
1322
+
1323
+
1324
+ orbitvu_l_mouse_state = orbitvu_i_mouse_down;
1325
+
1326
+
1327
+ OrbitvuLastTarget = target;
1328
+
1329
+
1330
+ if (orbitvu_drag_object) {
1331
+ orbitvu_drag_object.style.position = 'absolute';
1332
+ orbitvu_drag_object.style.top = mousePos.y - orbitvu_mouse_offset.y;
1333
+ orbitvu_drag_object.style.left = mousePos.x - orbitvu_mouse_offset.x;
1334
+ }
1335
+
1336
+
1337
+ orbitvu_l_mouse_state = orbitvu_i_mouse_down;
1338
+
1339
+
1340
+ if (OrbitvuCurrentTarget || orbitvu_drag_object)
1341
+ return false;
1342
+ }
1343
+
1344
+ function orbitvu_mouse_up(ev) {
1345
+
1346
+
1347
+ if (OrbitvuCurrentTarget) {
1348
+ orbitvu_log(OrbitvuCurrentTarget, 'Mouse Up Fired');
1349
+ orbitvu_drag_end();
1350
+ orbitvu_log(OrbitvuCurrentTarget, 'orbitvu_final_item_id: ' + orbitvu_final_item_id + ' / orbitvu_final_node: ' + orbitvu_final_node + ' / final_target: ' + OrbitvuLastTarget.id);
1351
+
1352
+ orbitvu_ajax('<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/sun/update_order/sun_item_id/' + parseInt(orbitvu_final_item_id.replace('orbitvu-gallery-item-', '')) + '/sun_before_item_id/' + parseInt(orbitvu_final_node.replace('orbitvu-gallery-item-', '')), function(odp){});
1353
+
1354
+ if (document.getElementById('media_gallery_content_grid')) {
1355
+ var torem = document.getElementById('media_gallery_content_grid');
1356
+ torem.parentNode.removeChild(torem);
1357
+ }
1358
+
1359
+ if (document.getElementById('media_gallery_content_save')) {
1360
+ var torem2 = document.getElementById('media_gallery_content_save');
1361
+ torem2.parentNode.removeChild(torem2);
1362
+ }
1363
+
1364
+ if (document.getElementById('media_gallery_content_save_image')) {
1365
+ var torem3 = document.getElementById('media_gallery_content_save_image');
1366
+ torem3.parentNode.removeChild(torem3);
1367
+ }
1368
+
1369
+ OrbitvuDragTemp.style.display = 'none';
1370
+ if (OrbitvuCurrentTarget.style.display == 'block') {
1371
+ if (OrbitvuRootSibling) {
1372
+ OrbitvuRootParent.insertBefore(OrbitvuCurrentTarget, OrbitvuRootSibling);
1373
+ } else {
1374
+ OrbitvuRootParent.appendChild(OrbitvuCurrentTarget);
1375
+ }
1376
+ }
1377
+
1378
+ OrbitvuCurrentTarget.style.display = '';
1379
+ OrbitvuCurrentTarget.style.opacity = '';
1380
+ OrbitvuCurrentTarget.style.cursor = '';
1381
+ OrbitvuCurrentTarget.style.borderStyle = '';
1382
+ OrbitvuCurrentTarget.style.boxShadow = '';
1383
+ OrbitvuCurrentTarget.className = OrbitvuCurrentTarget.className.replace(' dragstate','');
1384
+ }
1385
+
1386
+ orbitvu_drag_end();
1387
+
1388
+ OrbitvuCurrentTarget = null;
1389
+
1390
+
1391
+ orbitvu_drag_object = null;
1392
+
1393
+ orbitvu_i_mouse_down = false;
1394
+ }
1395
+
1396
+ function orbitvu_mouse_down(ev) {
1397
+ ev = ev || window.event;
1398
+ var target = ev.target || ev.srcElement;
1399
+
1400
+ orbitvu_i_mouse_down = true;
1401
+
1402
+ if (OrbitvuLastTarget) {
1403
+ orbitvu_log(OrbitvuLastTarget, 'Mouse Down Fired');
1404
+ }
1405
+
1406
+ if (target.onmousedown || target.getAttribute('DragObj')) {
1407
+ return false;
1408
+ }
1409
+ }
1410
+
1411
+ function orbitvu_make_draggable(item) {
1412
+ if (!item)
1413
+ return;
1414
+ item.onmousedown = function(ev) {
1415
+ orbitvu_drag_object = this;
1416
+ orbitvu_mouse_offset = orbitvu_get_mouse_offset(this, ev);
1417
+ return false;
1418
+ }
1419
+ }
1420
+
1421
+ function orbitvu_make_clickable(item) {
1422
+ if (!item)
1423
+ return;
1424
+ item.onmousedown = function(ev) {
1425
+ document.getElementById('ClickImage').value = this.name;
1426
+ }
1427
+ }
1428
+
1429
+ function orbitvu_add_drop_target(item, target) {
1430
+ item.setAttribute('droptarget', target);
1431
+ }
1432
+
1433
+ if (document.getElementById('orbitvu-drag-container')) {
1434
+ document.onmousemove = orbitvu_mouse_move;
1435
+ document.onmousedown = orbitvu_mouse_down;
1436
+ document.onmouseup = orbitvu_mouse_up;
1437
+
1438
+ orbitvu_create_drag_container(document.getElementById('orbitvu-drag-container'));
1439
+
1440
+ OrbitvuDragTemp = document.createElement('DIV');
1441
+ OrbitvuDragTemp.style.cssText = 'position:absolute;display:none;';
1442
+
1443
+ document.body.appendChild(OrbitvuDragTemp);
1444
+ }
1445
+ </script>
1446
+
1447
+
1448
+
1449
+
1450
+ </div>
1451
+
1452
+
1453
+ <?php } ?>
1454
+
1455
+ <?php
1456
+
1457
+ //--------------------------------------------------------------------------------------------------------------------------------------
1458
+ echo $observer->UseTemplate(array(), $__templates['magento_section_end']);
1459
+ //--------------------------------------------------------------------------------------------------------------------------------------
1460
+
1461
+ ?>
1462
+
1463
+ <div style="text-align: right;">
1464
+ <button type="button" class="orbitvu-button scalable"><a href="<?=$this->getUrl('*/system_config/edit/section/orbitvu/')?>" target="_blank" style="color: white; text-decoration: none;"><span style="float: left; width: 16px !important; height: 16px !important; margin: 0 5px 0 0; padding: 0; background-image: url(<?=Mage::getBaseUrl('media').'orbitvu/white.png'?>); background-repeat: no-repeat; background-position: -64px -108px;"></span><span><?=$this->__('Orbitvu Configuration')?></span></span></span></a></button>
1465
+ </div>
1466
+
1467
+ <script>
1468
+ function SynchronizeSun() {
1469
+ document.getElementById('synchronize_sun').value = 'true';
1470
+ productForm.submit();
1471
+ }
1472
+ <?php
1473
+ $ex = explode('index.php', $_SERVER['REQUEST_URI']);
1474
+ $http_host = str_replace('//', '/', $ex[0]);
1475
+ ?>
1476
+ function RefreshSun() {
1477
+ saveAndContinueEdit('<?=$this->getUrl('*/catalog_product/save/back/edit/')?>tab/{{tab_id}}/id/<?=$product_id?>/');
1478
+ }
1479
+
1480
+ function SynchronizeSunItems() {
1481
+ saveAndContinueEdit('<?=$this->getUrl('*/catalog_product/save/back/edit/sun/synchronize_items/')?>tab/{{tab_id}}/id/<?=$product_id?>/');
1482
+ }
1483
+
1484
+ function OrbitvuSetAction(act) {
1485
+ window.location.href = '<?=$this->getUrl('*/catalog_product/edit/')?>id/<?=$product_id?>/back/edit/tab/' + product_info_tabsJsTabs.activeTab.id + '/' + act;
1486
+ }
1487
+ </script>
1488
+ <?php
1489
+ /*************************************************************************************************************************************************
1490
+ * Scheduled actions
1491
+ *************************************************************************************************************************************************/
1492
+ if ($_Orbitvu->GetConfiguration('auto_sync') == 'true') {
1493
+ if (date('Y-m-d', strtotime($_Orbitvu->GetConfiguration('last_updated'))) != date('Y-m-d')) {
1494
+ $observer->SynchronizeAllProducts();
1495
+ }
1496
+ }
1497
+
1498
  ?>
app/design/frontend/base/default/layout/sun.xml CHANGED
@@ -1,17 +1,17 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category Orbitvu
5
- * @package Orbitvu_Sun
6
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
7
- * @license http://www.orbitvu.com/plugins/license
8
- * @version 1.0.0
9
- */
10
- -->
11
- <layout version="1.0">
12
- <catalog_product_view>
13
- <reference name="product.info.media">
14
- <action method="setTemplate"><name>orbitvu/product/view/media.phtml</name></action>
15
- </reference>
16
- </catalog_product_view>
17
  </layout>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Orbitvu
5
+ * @package Orbitvu_Sun
6
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
7
+ * @license http://www.orbitvu.com/plugins/license
8
+ * @version 1.0.0
9
+ */
10
+ -->
11
+ <layout version="1.0">
12
+ <catalog_product_view>
13
+ <reference name="product.info.media">
14
+ <action method="setTemplate"><name>orbitvu/product/view/media.phtml</name></action>
15
+ </reference>
16
+ </catalog_product_view>
17
  </layout>
app/design/frontend/base/default/template/orbitvu/product/view/media.phtml CHANGED
@@ -1,1038 +1,1038 @@
1
- <?php
2
- /**
3
- * @category Orbitvu
4
- * @package Orbitvu_Sun
5
- * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
- * @license http://www.orbitvu.com/plugins/license
7
- * @version 1.0.0
8
- */
9
-
10
- //-------------------------------------------------------------------------------------------------------
11
- $_product = $this->getProduct();
12
- $_helper = $this->helper('catalog/output');
13
- //-------------------------------------------------------------------------------------------------------
14
- $jspreloader = array();
15
- $jspreloader_tn = array();
16
- $thumbs_list = array();
17
- $images_list = array();
18
- //-------------------------------------------------------------------------------------------------------
19
- $observer = Mage::getSingleton('sun/observer');
20
- $_Orbitvu = $observer->ExtendOrbitvu();
21
-
22
- if (isset($_GET['flush']) && $_GET['flush'] == 'true') {
23
- $observer->SynchronizeAllThumbnails();
24
- }
25
- //-------------------------------------------------------------------------------------------------------
26
- /*
27
- * Gallery theme
28
- */
29
- $_orbitvu_gallery = array(
30
- 'width' => $_Orbitvu->GetConfiguration('width'),
31
- 'img_height' => $_Orbitvu->GetConfiguration('img_height'),
32
- 'border_color' => $_Orbitvu->GetConfiguration('border_color'),
33
- 'img_width_zoom' => $_Orbitvu->GetConfiguration('img_width_zoom'),
34
- 'img_height_zoom' => $_Orbitvu->GetConfiguration('img_height_zoom'),
35
- 'img_width_tn' => $_Orbitvu->GetConfiguration('img_width_tn'),
36
- 'img_height_tn' => $_Orbitvu->GetConfiguration('img_height_tn'),
37
- 'img_tn_margin' => $_Orbitvu->GetConfiguration('img_tn_margin'),
38
- 'button_width' => $_Orbitvu->GetConfiguration('button_width'),
39
- 'button_height' => $_Orbitvu->GetConfiguration('button_height'),
40
- 'button_opacity' => $_Orbitvu->GetConfiguration('button_opacity'),
41
- 'img_width' => $_Orbitvu->GetConfiguration('img_width'),
42
- 'img_tn_padding' => $_Orbitvu->GetConfiguration('img_tn_padding'),
43
- 'scroll' => $_Orbitvu->GetConfiguration('scroll'),
44
- );
45
- $_orbitvu_gallery['height'] = (str_replace('px', '', $_orbitvu_gallery['img_height']) + str_replace('px', '', $_orbitvu_gallery['img_height_tn'] + 2) + (3 * str_replace('px', '', $_orbitvu_gallery['img_tn_margin']))).'px';
46
- $_orbitvu_gallery['img_width_tn_marg'] = (str_replace('px', '', $_orbitvu_gallery['img_width_tn']) + str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])).'px';
47
- $_orbitvu_gallery['img_height_tn_marg'] = (str_replace('px', '', $_orbitvu_gallery['img_height_tn']) + str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])).'px';
48
-
49
- if (!$_orbitvu_gallery['scroll']) {
50
- $_orbitvu_gallery['scroll'] = 'yes';
51
- }
52
-
53
- if (!$_orbitvu_gallery['img_tn_padding']) {
54
- $_orbitvu_gallery['img_tn_padding'] = '2px';
55
- }
56
-
57
- $ratio = '56.25%'; //16:9 default
58
- if ((strpos($_orbitvu_gallery['img_width'], 'px') !== false) && (strpos($_orbitvu_gallery['img_height'], 'px') !== false) && (strpos($_orbitvu_gallery['width'], '%') !== false)) {
59
- $r_width = str_replace('px', '', $_orbitvu_gallery['img_width']);
60
- $r_height = str_replace('px', '', $_orbitvu_gallery['img_height']); //-2 px because of border
61
-
62
- $ratio = ($r_height) * 100 / $r_width;
63
- $ratio = (string)$ratio.'%';
64
- }
65
-
66
- //-------------------------------------------------------------------------------------------------------
67
- /*
68
- * Get original product images
69
- */
70
- foreach ($this->getGalleryImages() as $_image) {
71
- $current_array = array();
72
- // original image
73
- //-------------------------------------------------------------------------------------------------------
74
- $this_url = $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile());
75
- $thumbs_list[] = (string)$this_url;
76
- $jspreloader[] = '\''.((string)$this_url).'\'';
77
- $current_array['path'] = (string)$this_url;
78
- //-------------------------------------------------------------------------------------------------------
79
- // thumbnail 538x300
80
- //-------------------------------------------------------------------------------------------------------
81
- $this_url_tn = $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(str_replace('px', '', $_orbitvu_gallery['img_width']), str_replace('px', '', $_orbitvu_gallery['img_height']));
82
- $jspreloader_tn[] = '\''.((string)$this_url_tn).'\'';
83
- $current_array['path_tn'] = (string)$this_url_tn;
84
- //-------------------------------------------------------------------------------------------------------
85
- // thumbnail 75x75
86
- //-------------------------------------------------------------------------------------------------------
87
- $this_url_tn2 = $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(str_replace('px', '', $_orbitvu_gallery['img_width_tn']), str_replace('px', '', $_orbitvu_gallery['img_height_tn']));
88
- $current_array['path_tn2'] = (string)$this_url_tn2;
89
- //-------------------------------------------------------------------------------------------------------
90
-
91
- //-------------------------------------------------------------------------------------------------------
92
- $images_list[] = $current_array;
93
- //-------------------------------------------------------------------------------------------------------
94
- }
95
- //-------------------------------------------------------------------------------------------------------
96
- /*
97
- * Item template
98
- */
99
- $_media_item_tpl = '
100
- <li class="orbitvu-gallery-item{class}">
101
- <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" href="{path}" target="_blank">
102
- <img src="{path_tn2}" alt="" />
103
- </a>
104
- </li>
105
- ';
106
-
107
- $_presentation_item_tpl = '
108
- <li class="orbitvu-gallery-item{class}">
109
- <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" rel="presentation-360" href="{path}" target="_blank">
110
- <img src="{path_tn2}" alt="" /><span class="orbitvu-gallery-item-desc"><span class="orbitvu-icon orbitvu-icon-type-1"></span></span>
111
- </a>
112
- </li>
113
- ';
114
-
115
- $_orbittour_item_tpl = '
116
- <li class="orbitvu-gallery-item{class}">
117
- <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" rel="presentation-tour" href="{path}" target="_blank">
118
- <img src="{path_tn2}" alt="" /><span class="orbitvu-gallery-item-desc"><span class="orbitvu-icon orbitvu-icon-type-0"></span></span>
119
- </a>
120
- </li>
121
- ';
122
- //-------------------------------------------------------------------------------------------------------
123
- $all_items = 0;
124
- $_out_items = '';
125
- $i = 0;
126
- $first_image = '';
127
- /*
128
- * Magento images
129
- */
130
- //-------------------------------------------------------------------------------------------------------
131
- foreach ($images_list as $item) {
132
- if ($i == 0) $item['class'] = ' orbitvu_active';
133
- else $item['class'] = '';
134
-
135
- $item['id'] = $all_items;
136
-
137
- $_out_items .= $observer->UseTemplate($item, $_media_item_tpl);
138
-
139
- $i++;
140
- $all_items++;
141
- }
142
- //-------------------------------------------------------------------------------------------------------
143
- if (isset($images_list[0]['path_tn'])) {
144
- $first_image = array(
145
- 'path_tn' => $images_list[0]['path_tn'],
146
- 'path' => $images_list[0]['path']
147
- );
148
- }
149
- //-------------------------------------------------------------------------------------------------------
150
- $presentation = $_Orbitvu->GetProductPresentation($_product->getId(), true);
151
-
152
- $view_360 = array();
153
- $orbittour = array();
154
- $i = 0;
155
- if (count($presentation['items']) > 0) {
156
- foreach ($presentation['items'] as $item) {
157
- /*
158
- * Orbitvu 2D Images
159
- */
160
- if ($item['type'] == '3') {
161
- //-------------------------------------------------------------------------------------------------------
162
- $current_path = 'http:'.$item['path'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
163
- $current_path_tn = 'http:'.$item['path'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
164
-
165
- $_out_items .= $observer->UseTemplate(array(
166
- 'path' => $current_path,
167
- 'path_tn' => $current_path_tn,
168
- 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
169
- 'class' => '',
170
- 'id' => $all_items
171
- ), $_media_item_tpl);
172
- //-------------------------------------------------------------------------------------------------------
173
- $jspreloader_tn[] = '\''.$current_path_tn.'\'';
174
- $jspreloader[] = '\''.$current_path.'\'';
175
-
176
- if ($i == 0 && empty($first_image)) {
177
- $first_image = array(
178
- 'path_tn' => $current_path_tn,
179
- 'path' => $current_path
180
- );
181
- }
182
-
183
- $all_items++;
184
- }
185
- /*
186
- * Orbitvu 360 Presentations
187
- */
188
- else if ($item['type'] == '1') {
189
- //-------------------------------------------------------------------------------------------------------
190
- $current_path = 'http:'.$item['thumbnail'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
191
- $current_path_tn = 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
192
-
193
- $_out_items .= $observer->UseTemplate(array(
194
- 'path' => $current_path,
195
- 'path_tn' => $current_path_tn,
196
- 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
197
- 'class' => '',
198
- 'id' => $all_items
199
- ), $_presentation_item_tpl);
200
-
201
- $item_config = json_decode($item['config']);
202
- $item_uid = $item_config->uid;
203
- $view_360 = array(
204
- 'path' => $item['path'],
205
- 'path_tn' => $current_path_tn,
206
- 'uid' => $item_uid,
207
- 'thumbnail' => $item['thumbnail']
208
- );
209
- //-------------------------------------------------------------------------------------------------------
210
- $jspreloader_tn[] = '\''.$current_path_tn.'\'';
211
- $jspreloader[] = '\''.$current_path.'\'';
212
-
213
- if ($i == 0 && empty($first_image)) {
214
- $first_image = array(
215
- 'path_tn' => $current_path_tn,
216
- 'path' => $current_path
217
- );
218
- }
219
-
220
- $all_items++;
221
- }
222
- /*
223
- * Orbittour presentation
224
- */
225
- else if ($item['type'] == '0') {
226
- //-------------------------------------------------------------------------------------------------------
227
- $current_path = 'http:'.$item['thumbnail'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
228
- $current_path_tn = 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
229
-
230
- $_out_items .= $observer->UseTemplate(array(
231
- 'path' => $current_path,
232
- 'path_tn' => $current_path_tn,
233
- 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
234
- 'class' => '',
235
- 'id' => $all_items
236
- ), $_orbittour_item_tpl);
237
-
238
- $item_config = json_decode($item['config']);
239
- $item_uid = $item_config->uid;
240
- $orbittour = array(
241
- 'path' => $item['path'],
242
- 'path_tn' => $current_path_tn,
243
- 'uid' => $item_uid
244
- );
245
- //-------------------------------------------------------------------------------------------------------
246
- $jspreloader_tn[] = '\''.$current_path_tn.'\'';
247
- $jspreloader[] = '\''.$current_path.'\'';
248
-
249
- if ($i == 0 && empty($first_image)) {
250
- $first_image = array(
251
- 'path_tn' => $current_path_tn,
252
- 'path' => $current_path
253
- );
254
- }
255
-
256
- $all_items++;
257
- }
258
- //-------------------------------------------------------------------------------------------------------
259
- $i++;
260
- }
261
- }
262
-
263
- //-------------------------------------------------------------------------------------------------------
264
- /*
265
- * Display output
266
- */
267
- ?>
268
- <style type="text/css">
269
-
270
- #orbitvu-gallery-wrapper {
271
- width: <?=$_orbitvu_gallery['width'];?>
272
- }
273
-
274
- #orbitvu-gallery-fix {
275
- border: 1px solid <?=$_orbitvu_gallery['border_color']?>;
276
- }
277
- .orbitvu-gallery {
278
- margin: 0;
279
- padding: 0;
280
- position: relative;
281
- padding-bottom: <?=$ratio; ?>; /* 16:9 - default */
282
- height: 0;
283
- z-index: 9;
284
- }
285
- </style>
286
-
287
- <?
288
- if ($all_items <= 0) {
289
- ?>
290
- <div id="orbitvu-gallery-wrapper">
291
- <div id="orbitvu-gallery-fix">
292
- <div class="orbitvu-gallery" id="orbitvu-gallery" style="width: <?=$_orbitvu_gallery['width']?>; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/placeholder.png); background-position: center; center; background-repeat: no-repeat;"></div>
293
- </div>
294
- </div>
295
-
296
- <!--<div class="orbitvu-gallery" id="orbitvu-gallery-placeholder" style="width: <?=$_orbitvu_gallery['width']?>; height: <?=$_orbitvu_gallery['height']?>; margin: 0; padding: 0; position: relative; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/placeholder.png); background-position: center; center; background-repeat: no-repeat;"></div>-->
297
- <script>
298
- window.onresize = function() {
299
- if (window.innerWidth < 770) document.getElementById('orbitvu-gallery').style.display = 'none';
300
- else document.getElementById('orbitvu-gallery').style.display = 'block';
301
- }
302
- window.onresize();
303
- </script>
304
- <?php
305
- }
306
- else if ($all_items > 0) {
307
- ?>
308
- <div id="orbitvu-gallery-wrapper">
309
- <div id="orbitvu-gallery-fix">
310
- <div class="orbitvu-gallery" id="orbitvu-gallery">
311
- <div id="orbitvu-gallery-product-image" class="orbitvu-gallery-product-image">
312
- <div id="orbitvu-gallery-view-image">
313
- <img id="orbitvu-gallery-main-image" style="display: inline;" alt="orbitvu-0" src="<?=$first_image['path_tn']?>" />
314
- </div>
315
- <div id="orbitvu-gallery-view-360" class="orbitvu-presentation"<?php if (!empty($view_360['path'])) {
316
- echo ' style="background-image: url('.$view_360['thumbnail'].'?max_height='.str_replace('px', '', $_orbitvu_gallery['img_height']).');"';
317
- }?>><?php
318
- if (!empty($view_360['path'])) {
319
- ?>
320
- <script type="text/javascript" src="<?=$view_360['path']?>?content2=yes&force_html5=<?=$_Orbitvu->GetConfiguration('html5')?><?php
321
- $orbitvu_teaser = $_Orbitvu->GetConfiguration('teaser');
322
- if ($orbitvu_teaser != 'sun') {
323
- print '&teaser='.$orbitvu_teaser;
324
- }
325
- ?>&width=auto&height=auto&viewer_delayed=yes" id="orbitvu-viewer-script"></script>
326
- <div id="ovContent-<?=$view_360['uid']?>" class="orbitvu-container" style="width: 100%; height: 100%; background-repeat: no-repeat; background-position: center center; background-size: contain; background-image: url(<?=$view_360['thumbnail']?>?max_height=<?=str_replace('px', '', $_orbitvu_gallery['img_height'])?>);"></div>
327
- <?php
328
- }
329
- ?></div>
330
- <div id="orbitvu-gallery-view-tour" class="orbitvu-presentation"><?php
331
- if (!empty($orbittour['path'])) {
332
- ?>
333
- <div id="orbittour-<?=$orbittour['uid']?>" class="orbittour-container"></div>
334
- <script type="text/javascript" src="<?=$orbittour['path']?>?orbittour_delayed=yes&onready=no&force_html5=<?=$_Orbitvu->GetConfiguration('html5')?><?php
335
- $otn = $_Orbitvu->GetConfiguration('orbittour_thumbnails');
336
-
337
- if ($otn != 'sun') {
338
- print '&style='.$otn;
339
- }
340
-
341
- ?>"></script>
342
- <?php } ?></div>
343
- </div>
344
- <div id="orbitvu-gallery-product-image-zoom" style="background-image: url(<?=$first_image['path']?>);"></div>
345
- <div id="orbitvu-gallery-preloader"></div>
346
- </div>
347
- </div>
348
- <div id="orbitvu-gallery-scroller">
349
- <div class="orbitvu-gallery-product-views" id="orbitvu-gallery-product-views">
350
- <ul class="orbitvu-image-thumbs" id="orbitvu-image-thumbs" style="margin-left: 0;">
351
- <?=$_out_items?>
352
- </ul>
353
- <em id="orbitvu_go_next" class="orbitvu-gallery-button"><span>&raquo;</span></em>
354
- <em id="orbitvu_go_back" class="orbitvu-gallery-button"><span>&laquo;</span></em>
355
- </div>
356
- </div>
357
- </div>
358
-
359
- <style type="text/css">
360
-
361
- .orbitvu-gallery-product-image { clear: both; overflow: hidden; zoom: 1.0; max-height: <?=$_orbitvu_gallery['img_height']?>; position: relative; text-align: center; }
362
- .orbitvu-gallery-product-image img#orbitvu-gallery-main-image { display: inline; margin: 0; padding: 0; border: 0; max-width: 100%; max-height: 100%; cursor: crosshair; }
363
- #orbitvu-gallery-product-image-zoom { display: none; height: auto; box-sizing: content-box; position: absolute; z-index: 2; top: -1px; bottom: -1px; right: -100%; width: 100%; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; background-color: white; background-repeat: no-repeat; cursor: crosshair; }
364
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs { margin: 0; padding: 0; <?= $_orbitvu_gallery['scroll'] == 'yes' ? 'width: 99999px;' : '' ?> }
365
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item { float: left; display: table-row; overflow: hidden; margin: <?=$_orbitvu_gallery['img_tn_margin']?>; position: relative; border: 1px solid transparent; }
366
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item:hover, .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item.orbitvu_active { border: 1px solid <?=$_orbitvu_gallery['border_color']?>; }
367
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item a.orbitvu-gallery-item-link { display: table-cell; vertical-align: middle; width: <?=$_orbitvu_gallery['img_width_tn_marg']?>; height: <?=$_orbitvu_gallery['img_height_tn_marg']?>; text-align: center; }
368
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item:first-child { margin-left: 0px; }
369
- .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item a.orbitvu-gallery-item-link img { display: block; margin: 0 auto; max-width: <?=$_orbitvu_gallery['img_width_tn']?>; max-height: <?=$_orbitvu_gallery['img_height_tn']?>; padding: <?=$_orbitvu_gallery['img_tn_padding']?>; box-sizing: content-box !important }
370
- .orbitvu-gallery-item-desc { display: block; padding: 2px; position: absolute; bottom: 0; left: 0; background: rgba(255, 255, 255, 0.5); color: black; font-weight: bold; font-size: 0.8em; }
371
- .orbitvu-gallery-button { display: table-row; position: absolute; bottom: <?=$_orbitvu_gallery['img_tn_margin']?>; width: <?=$_orbitvu_gallery['button_width']?>; height: <?=$_orbitvu_gallery['button_height']?>; background: white; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; font-weight: bold; text-align: center; opacity: <?=$_orbitvu_gallery['button_opacity']?>; color: black; font-size: 24px; text-decoration: none; font-style: normal; cursor: pointer; }
372
- .orbitvu-gallery-button:hover { background: black; color: white; text-decoration: none; border-color: black; }
373
- .orbitvu-gallery-button span { display: table-cell; vertical-align: middle; width: <?=$_orbitvu_gallery['button_width']?>; height: <?=$_orbitvu_gallery['button_height']?>; }
374
- #orbitvu_go_next { right: -1px; <?= $_orbitvu_gallery['scroll'] == 'no' ? 'display: none' : '' ?>}
375
- #orbitvu_go_back { display: none; left: -1px; }
376
- #orbitvu-gallery-preloader { position: absolute; top: -10000px; left: -10000px; }
377
- .orbitvu-presentation { display: block; width: 100%; height: 100%; top: -10000px; background-repeat: no-repeat; background-position: center center; background-size: contain; }
378
- .orbitvu-icon { display: block; width: 22px; height: 22px; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png); background-repeat: no-repeat; }
379
- .orbitvu-icon-type-3 { background-position: 0 -32px; }
380
- .orbitvu-icon-type-1 { background-position: -22px -32px; }
381
- .orbitvu-icon-type-0 { background-position: -44px -32px; }
382
-
383
- #orbitvu-gallery-scroller {
384
- position: relative;
385
- height: auto;
386
- overflow: hidden;
387
- }
388
-
389
- .orbitvu-gallery .orbitvu-gallery-product-image {
390
- position: absolute;
391
- top: 0;
392
- left: 0;
393
- width: 100%;
394
- height: 100%;
395
- }
396
- </style>
397
- <script>
398
- /*
399
- * Orbitvu Public Declarations
400
- */
401
- var orbitvu_timer, orbitvu_rectangle, orbitvu_current_image, orbitvu_init_interval, orbitvu_box_width, orbitvu_box_height, orbitvu_switch_timer;
402
- var orbitvu_image_thumbs = Orb$('orbitvu-image-thumbs');
403
- var orbitvu_speed = 24;
404
- var orbitvu_xAll = 0;
405
- var orbitvu_xAllReal = 0;
406
- var orbitvu_xMax = 0;
407
- var orbitvu_gallery_inner;
408
- var orbitvu_pos = 0;
409
- var orbitvu_dir = 1;
410
- var orbitvu_fps = 30;
411
- var orbitvu_interval = 1000 / orbitvu_fps;
412
- var orbitvu_lastV = 0;
413
- var orbitvu_img_preloader_tn = new Array(<?=implode(',', $jspreloader_tn)?>);
414
- var orbitvu_img_preloader = new Array(<?=implode(',', $jspreloader)?>);
415
- var orbitvu_buttons = false;
416
- var orbitvu_max_counter = 3;
417
- var orbitvu_ready = false;
418
- var orbitvu_window_before = window.innerWidth;
419
- var orbitvu_window_growing = false;
420
- var orbitvu_smallest_height = '<?=$_orbitvu_gallery['img_height']?>';
421
- var orbitvu_window_onresize_enabled = true;
422
- var orbitvu_zoom_responsive = false;
423
- var orbitvu_scroll = '<?=$_orbitvu_gallery['scroll']?>';
424
-
425
- /*
426
- * Orbitvu Objects
427
- */
428
- function OrbitvuOffsetRectangle(elem){
429
- var box = elem.getBoundingClientRect();
430
- var clientTop = document.documentElement.clientTop || document.body.clientTop||0;
431
- var clientLeft = document.documentElement.clientLeft || document.body.clientLeft||0;
432
- var top = box.top - clientTop;
433
- var left = box.left - clientLeft;
434
-
435
- return {
436
- top: Math.round(top),
437
- left: Math.round(left)
438
- };
439
- }
440
-
441
- function OrbitvuImage(id) {
442
- id = parseInt(String(id).replace('orbitvu-', ''));
443
-
444
- var temp = orbitvu_get_image_dimensions(Orb$('orbitvu-img-tn-' + id));
445
- var temp_zoom = orbitvu_get_image_dimensions(Orb$('orbitvu-img-' + id));
446
-
447
- return {
448
- orbitvu_id: 'orbitvu-' + id,
449
- path: orbitvu_img_preloader[id],
450
- path_tn: orbitvu_img_preloader_tn[id],
451
- width: temp.width,
452
- height: temp.height,
453
- width_zoom: temp_zoom.width,
454
- height_zoom: temp_zoom.height
455
- };
456
- }
457
-
458
- /*
459
- * Orbitvu Funtions Pure JS
460
- */
461
- function Orb$(el) {
462
- return document.getElementById(el);
463
- }
464
-
465
- function orbitvu_stristr(haystack, needle, bool) {
466
- var pos = 0;
467
-
468
- haystack += '';
469
- pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());
470
- if (pos == -1) {
471
- return false;
472
- }
473
- else {
474
- if (bool) {
475
- return haystack.substr(0, pos);
476
- }
477
- else {
478
- return haystack.slice(pos);
479
- }
480
- }
481
- }
482
-
483
- /*
484
- * Inject 360
485
- */
486
- function orbitvu_inject_tour_now() {
487
- inject_orbittour_<?= isset($orbittour['uid']) ? $orbittour['uid'] : '' ?>();
488
- }
489
-
490
- function orbitvu_inject_tour() {
491
- <?php
492
- if (!empty($orbittour['path'])) {
493
- ?>
494
- if (orbitvu_ready) {
495
- clearInterval(orbitvu_tour_interval);
496
- orbitvu_inject_tour_now();
497
- console.log('OrbitTour loaded.');
498
- }
499
- <?php
500
- }
501
- ?>
502
- }
503
-
504
- function orbitvu_remove_bg_360() {
505
- Orb$('orbitvu-gallery-view-360').style.backgroundImage = '';
506
- }
507
-
508
- function orbitvu_inject_360_now() {
509
- <?php
510
- if (!empty($view_360['path'])) {
511
- ?>
512
- inject_viewer_<?=$view_360['uid']?>();
513
- setTimeout('orbitvu_remove_bg_360()', 500);
514
- <?php
515
- }
516
- ?>
517
- }
518
-
519
- function orbitvu_inject_360() {
520
- <?php
521
- if (!empty($view_360['path'])) {
522
- ?>
523
- if (orbitvu_ready) {
524
- clearInterval(orbitvu_360_interval);
525
- orbitvu_inject_360_now();
526
- console.log('360 loaded.');
527
- }
528
- <?php
529
- }
530
- ?>
531
- }
532
-
533
- /*
534
- * Get real image dimensions from preloaded 1x1
535
- * @returns {integer width, integer height}
536
- */
537
- function orbitvu_get_image_dimensions(temp) {
538
- if ((typeof temp === "undefined") || (temp === null) || (typeof temp.style === "undefined") || (temp.style === null)) {
539
- return {};
540
- }
541
- temp.style.width = 'auto';
542
- temp.style.height = 'auto';
543
- var img_width = parseInt(temp.offsetWidth);
544
- var img_height = parseInt(temp.offsetHeight);
545
- temp.style.width = '1px';
546
- temp.style.height = '1px';
547
-
548
- return {
549
- width: img_width,
550
- height: img_height
551
- };
552
- }
553
-
554
- function orbitvu_get_maxHeight() {
555
- return parseInt(Orb$('orbitvu-gallery').offsetHeight - Orb$('orbitvu-gallery-product-views').offsetHeight) - 2;
556
- }
557
-
558
- function orbitvu_init_gallery() {
559
- orbitvu_gallery_inner = Orb$('orbitvu-gallery').clientWidth;
560
-
561
- orbitvu_xMax = 0;
562
- orbitvu_xAll = 0;
563
-
564
- var i = 0;
565
-
566
- for (n = orbitvu_image_thumbs.children.length, orbitvu_current = 0; i < n; i++) {
567
- //orbitvu_current = orbitvu_image_thumbs.children[i].clientWidth + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin']) * 2)?> + 2;
568
- orbitvu_current = <?=(str_replace('px', '', $_orbitvu_gallery['img_width_tn']))?> + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin']) * 2)?> + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_padding']) * 2)?> + 2; //+2 is a border transparent from css
569
- if (i == 0) orbitvu_xMax += orbitvu_current;
570
- orbitvu_xAll += orbitvu_current;
571
- }
572
-
573
- if (i == 1) {
574
- Orb$('orbitvu-gallery-product-views').style.height = '1px';
575
- }
576
-
577
- orbitvu_xAllReal = orbitvu_xAll;
578
- orbitvu_xAll -= orbitvu_gallery_inner;
579
- }
580
-
581
-
582
- function orbitvu_reset_classes() {
583
- for (var i = 0, n = Orb$('orbitvu-image-thumbs').children.length; i < n; i++) {
584
- Orb$('orbitvu-image-thumbs').children[i].className = Orb$('orbitvu-image-thumbs').children[i].className.replace('orbitvu_active', '');
585
- }
586
- }
587
-
588
- /*
589
- * To delete if not used
590
- * @returns {undefined} */
591
- function orbitvu_presentations_resize() {
592
- orbitvu_window_onresize_enabled = false;
593
- window.dispatchEvent(new Event('resize'));
594
- orbitvu_window_onresize_enabled = true;
595
- }
596
-
597
- function orbitvu_switch_now(el) {
598
- orbitvu_reset_classes();
599
- el.parentNode.className += ' orbitvu_active';
600
-
601
- orbitvu_current_image = OrbitvuImage(el.id);
602
-
603
- Orb$('orbitvu-gallery-main-image').src = orbitvu_current_image.path_tn;
604
- Orb$('orbitvu-gallery-main-image').alt = el.id;
605
-
606
- if (el.rel == 'presentation-360') {
607
- Orb$('orbitvu-gallery-view-image').style.display = 'none';
608
- Orb$('orbitvu-gallery-view-tour').style.position = 'absolute';
609
- Orb$('orbitvu-gallery-view-360').style.position = '';
610
- //orbitvu_presentations_resize();
611
- }
612
- else if (el.rel == 'presentation-tour') {
613
- Orb$('orbitvu-gallery-view-image').style.display = 'none';
614
- Orb$('orbitvu-gallery-view-tour').style.position = '';
615
- Orb$('orbitvu-gallery-view-360').style.position = 'absolute';
616
- //orbitvu_presentations_resize();
617
- }
618
- else {
619
- Orb$('orbitvu-gallery-view-image').style.display = 'block';
620
- Orb$('orbitvu-gallery-view-360').style.position = 'absolute'; // workaround display: block/none
621
- Orb$('orbitvu-gallery-view-tour').style.position = 'absolute'; // workaround display: block/none
622
- }
623
- }
624
-
625
- function orbitvu_switch(el, delay) {
626
- if (delay > 0) {
627
- clearTimeout(orbitvu_switch_timer);
628
-
629
- orbitvu_switch_timer = setTimeout(function () {
630
- orbitvu_switch_now(el);
631
- }, delay);
632
- }
633
- else {
634
- orbitvu_switch_now(el);
635
- }
636
- }
637
-
638
- function orbitvu_hide_zoom() {
639
- Orb$('orbitvu-gallery-product-image-zoom').style.display = 'none';
640
- }
641
-
642
- function orbitvu_show_zoom() {
643
- if (!orbitvu_ready) return false;
644
-
645
- Orb$('orbitvu-gallery-product-image-zoom').style.backgroundImage = 'url(' + orbitvu_current_image.path + ')';
646
- Orb$('orbitvu-gallery-product-image-zoom').style.display = 'block';
647
-
648
- if (((Orb$('orbitvu-gallery-product-image-zoom').offsetLeft + Orb$('orbitvu-gallery-product-image-zoom').offsetWidth) > document.body.offsetWidth) || window.innerWidth < 770 || document.body.offsetWidth < 770) {
649
- Orb$('orbitvu-gallery-product-image-zoom').style.right = '-1px';
650
- Orb$('orbitvu-gallery-product-image-zoom').style.left = '-1px';
651
- Orb$('orbitvu-gallery-product-image-zoom').style.height = parseInt(Orb$('orbitvu-gallery').offsetHeight - Orb$('orbitvu-gallery-product-views').offsetHeight - 2) + 'px';
652
- orbitvu_rectangle = OrbitvuOffsetRectangle(Orb$('orbitvu-gallery-product-image-zoom'));
653
- orbitvu_zoom_responsive = true;
654
- }
655
- else {
656
- Orb$('orbitvu-gallery-product-image-zoom').style.right = '-100%';
657
- Orb$('orbitvu-gallery-product-image-zoom').style.left = 'auto';
658
- Orb$('orbitvu-gallery-product-image-zoom').style.height = 'auto';
659
- orbitvu_zoom_responsive = false;
660
- orbitvu_rectangle = OrbitvuOffsetRectangle(Orb$('orbitvu-gallery-main-image'));
661
- }
662
- }
663
-
664
- function orbitvu_manage_zoom(obj, event) {
665
- if (!orbitvu_ready) return false;
666
- if (!orbitvu_rectangle) {
667
- orbitvu_rectangle = OrbitvuOffsetRectangle(obj);
668
- }
669
-
670
- var mx = event.clientX - orbitvu_rectangle.left;
671
- var my = event.clientY - orbitvu_rectangle.top;
672
-
673
- if (Orb$('orbitvu-gallery-product-image-zoom').style.display == 'none') orbitvu_show_zoom();
674
-
675
- if (orbitvu_current_image) {
676
- //console.log('w: ' + obj.offsetWidth + ', h: ' + obj.offsetHeight + ', nw: ' + orbitvu_current_image.width_zoom + ', nh: ' + orbitvu_current_image.height_zoom);
677
- var interpolate_x = Math.round(mx * (orbitvu_current_image.width_zoom / obj.offsetWidth));
678
- var interpolate_y = Math.round(my * (orbitvu_current_image.height_zoom / obj.offsetHeight));
679
-
680
- interpolate_x = interpolate_x - (orbitvu_box_width/2);
681
- interpolate_y = interpolate_y - (orbitvu_box_height/2);
682
-
683
- var orb_box_w = orbitvu_current_image.width_zoom - orbitvu_box_width;
684
- var orb_box_h = orbitvu_current_image.height_zoom - orbitvu_box_height;
685
-
686
- if (interpolate_x >= orb_box_w) interpolate_x = orb_box_w;
687
- if (interpolate_y >= orb_box_h) interpolate_y = orb_box_h;
688
-
689
- interpolate_x *= -1;
690
- interpolate_y *= -1;
691
-
692
- if (interpolate_x >= 0) interpolate_x = 0;
693
- if (interpolate_y >= 0) interpolate_y = 0;
694
-
695
- //console.log('x: ' + mx + ', y: ' + my + ', new_x: ' + interpolate_x + ', new_y: ' + interpolate_y + ', orbw: ' + orb_box_w + ', orbh: ' + orb_box_h);
696
- Orb$('orbitvu-gallery-product-image-zoom').style.backgroundPosition = Math.round(interpolate_x) + 'px ' + Math.round(interpolate_y) + 'px';
697
- }
698
- }
699
-
700
- function orbitvu_preload_images() {
701
-
702
- var i = 0;
703
-
704
- Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-tn-' + i + '" src="' + orbitvu_img_preloader_tn[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
705
- Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-' + i + '" src="' + orbitvu_img_preloader[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
706
-
707
- Orb$('orbitvu-img-0').onload = function() {
708
- orbitvu_current_image = OrbitvuImage('orbitvu-0');
709
- console.log('Image preloader continues...');
710
-
711
- for (var i = 1, n = orbitvu_img_preloader_tn.length; i < n; i++) {
712
- Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-tn-' + i + '" src="' + orbitvu_img_preloader_tn[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
713
- Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-' + i + '" src="' + orbitvu_img_preloader[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
714
- }
715
-
716
- console.log('Done.');
717
-
718
- }
719
-
720
- }
721
-
722
- (function() {
723
- var lastTime = 0;
724
- var vendors = ['ms', 'moz', 'webkit', 'o'];
725
- for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
726
- window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
727
- window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
728
- || window[vendors[x]+'CancelRequestAnimationFrame'];
729
- }
730
-
731
- if (!window.requestAnimationFrame)
732
- window.requestAnimationFrame = function(callback, element) {
733
- var currTime = new Date().getTime();
734
- var timeToCall = Math.max(0, 16 - (currTime - lastTime));
735
- var id = window.setTimeout(function() { callback(currTime + timeToCall); },
736
- timeToCall);
737
- lastTime = currTime + timeToCall;
738
- return id;
739
- };
740
-
741
- if (!window.cancelAnimationFrame)
742
- window.cancelAnimationFrame = function(id) {
743
- clearTimeout(id);
744
- };
745
- }());
746
-
747
- function orbitvu_get_pos() {
748
- return parseInt(orbitvu_image_thumbs.style.marginLeft.replace('px', ''));
749
- }
750
-
751
- function orbitvu_go() {
752
- /*
753
- * Do the math
754
- */
755
- current_val = (orbitvu_dir * orbitvu_speed);
756
- orbitvu_pos = orbitvu_get_pos();
757
-
758
- /*
759
- * Check if animation can rewind
760
- */
761
- if ((orbitvu_dir == -1 && (orbitvu_pos * -1) > orbitvu_xAll) || (orbitvu_dir == 1 && (orbitvu_pos * -1) <= 0)) return false;
762
-
763
- /*
764
- * Start animation
765
- */
766
- orbitvu_lastV += current_val;
767
- orbitvu_animation = window.requestAnimationFrame(orbitvu_go);
768
- orbitvu_image_thumbs.style.marginLeft = (current_val + orbitvu_pos) + 'px';
769
-
770
- if ((orbitvu_dir == 1 && orbitvu_lastV >= (orbitvu_xMax * orbitvu_max_counter)) || (orbitvu_dir == -1 && (-1 * orbitvu_lastV) >= (orbitvu_xMax * orbitvu_max_counter))) {
771
- window.cancelAnimationFrame(orbitvu_animation);
772
- orbitvu_lastV = 0;
773
- orbitvu_max_counter = 1;
774
- }
775
-
776
- /*
777
- * Hide or show buttons
778
- */
779
- if (orbitvu_buttons) {
780
- new_pos = orbitvu_get_pos();
781
- if ((orbitvu_dir == -1 && (new_pos * -1) > orbitvu_xAll)) {
782
- Orb$('orbitvu_go_next').style.display = 'none';
783
- }
784
- else {
785
- Orb$('orbitvu_go_next').style.display = 'block';
786
- }
787
- if ((orbitvu_dir == 1 && (new_pos * -1) <= 0)) {
788
- Orb$('orbitvu_go_back').style.display = 'none';
789
- }
790
- else {
791
- Orb$('orbitvu_go_back').style.display = 'block';
792
- }
793
- }
794
- }
795
-
796
- function orbitvu_goNext() {
797
- orbitvu_dir = -1;
798
- orbitvu_max_counter = 3;
799
- orbitvu_go();
800
- }
801
-
802
- function orbitvu_goBack() {
803
- orbitvu_dir = 1;
804
- orbitvu_max_counter = 3;
805
- orbitvu_go();
806
- }
807
-
808
- function orbitvu_rewind() {
809
- orbitvu_dir = 1;
810
- orbitvu_max_counter = 100;
811
- orbitvu_go();
812
- }
813
-
814
- function orbitvu_get_param(element) {
815
- var main_prev_visibility, main_prev_display, prev_visibility, prev_display;
816
- var main_cont = Orb$('orbitvu-gallery-view-image');
817
-
818
- if (element.style.visibility == '') prev_visibility = 'visible';
819
- else prev_visibility = element.style.visibility;
820
-
821
- if (element.style.display == '') prev_display = 'block';
822
- else prev_display = element.style.display;
823
-
824
- if (main_cont.style.visibility == '') main_prev_display = 'visible';
825
- else main_prev_display = main_cont.style.visibility;
826
- if (main_cont.style.display == '') main_prev_display = 'block';
827
- else main_prev_display = main_cont.style.display;
828
-
829
- main_cont.style.visibility = 'visible';
830
- main_cont.style.display = 'block';
831
- element.style.visibility = 'visible';
832
- element.style.display = 'block';
833
-
834
- my_height = parseInt(element.offsetHeight);
835
- my_width = parseInt(element.offsetWidth);
836
-
837
- element.style.visibility = prev_visibility;
838
- element.style.display = prev_display;
839
- main_cont.style.visibility = main_prev_visibility;
840
- main_cont.style.display = main_prev_display;
841
-
842
- return {
843
- width: my_width,
844
- height: my_height
845
- };
846
- }
847
-
848
- function orbitvu_maxHeight_fix() {
849
- Orb$('orbitvu-gallery-product-image').style.maxHeight = '<?=$_orbitvu_gallery['img_height']?>';
850
-
851
- var orbitvu_gallery_dim = orbitvu_get_param(Orb$('orbitvu-gallery'));
852
- var orbitvu_gallery_main_image_dim = orbitvu_get_param(Orb$('orbitvu-gallery-main-image'));
853
- var orbitvu_gallery_product_views_dim = { height: parseInt(Orb$('orbitvu-gallery-product-views').offsetHeight) };
854
- var new_height = orbitvu_gallery_dim.height - (orbitvu_gallery_dim.height - orbitvu_gallery_main_image_dim.height - orbitvu_gallery_product_views_dim.height);
855
-
856
- Orb$('orbitvu-gallery').style.height = parseInt(new_height + 2) + 'px';
857
-
858
- orbitvu_smallest_height = orbitvu_get_maxHeight();
859
- Orb$('orbitvu-gallery-product-image').style.maxHeight = orbitvu_smallest_height + 'px';
860
-
861
- if (orbitvu_img_preloader.length <= 1) {
862
- var new_sm_height = orbitvu_smallest_height + 2;
863
- }
864
- else {
865
- var new_sm_height = orbitvu_smallest_height - 2;
866
- }
867
-
868
- Orb$('orbitvu-gallery-view-360').style.height = new_sm_height + 'px';
869
- Orb$('orbitvu-gallery-view-tour').style.height = new_sm_height + 'px';
870
- }
871
-
872
- function orbitvu_refresh() {
873
- var current_id = 'orbitvu-0';
874
-
875
- if (typeof orbitvu_current_image != 'undefined') {
876
- if ('orbitvu_id' in orbitvu_current_image) {
877
- current_id = orbitvu_current_image.orbitvu_id;
878
- }
879
- }
880
- orbitvu_switch(Orb$(current_id));
881
-
882
- if (orbitvu_current_image.width_zoom > 0) {
883
-
884
- //orbitvu_maxHeight_fix();
885
-
886
- clearInterval(orbitvu_init_interval);
887
- console.log('Ready.');
888
- orbitvu_ready = true;
889
-
890
- orbitvu_calculate_zoom();
891
- }
892
-
893
- if (orbitvu_scroll == 'yes') {
894
- if ((orbitvu_xAllReal - (<?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])*2)?>)) < orbitvu_gallery_inner) {
895
- Orb$('orbitvu_go_back').style.display = 'none';
896
- Orb$('orbitvu_go_next').style.display = 'none';
897
- orbitvu_buttons = false;
898
- } else {
899
- orbitvu_buttons = true;
900
- }
901
-
902
- if (orbitvu_buttons) {
903
- new_pos = orbitvu_get_pos();
904
- if ((orbitvu_dir == -1 && (new_pos * -1) > orbitvu_xAll)) {
905
- Orb$('orbitvu_go_next').style.display = 'none';
906
- }
907
- else {
908
- Orb$('orbitvu_go_next').style.display = 'block';
909
- }
910
- if ((orbitvu_dir == 1 && (new_pos * -1) <= 0)) {
911
- Orb$('orbitvu_go_back').style.display = 'none';
912
- }
913
- else {
914
- Orb$('orbitvu_go_back').style.display = 'block';
915
- }
916
- }
917
- }
918
- }
919
-
920
- function orbitvu_calculate_zoom() {
921
- orbitvu_show_zoom();
922
- var image_zoom = orbitvu_get_param(Orb$('orbitvu-gallery-product-image-zoom'));
923
- orbitvu_hide_zoom();
924
- orbitvu_box_width = image_zoom.width;
925
- orbitvu_box_height = image_zoom.height;
926
- }
927
-
928
- function orbitvu_recalculate() {
929
- orbitvu_calculate_zoom();
930
- orbitvu_refresh();
931
- }
932
-
933
- /*
934
- * Starting function
935
- */
936
- function OrbitvuInit() {
937
- /*
938
- * Init gallery and images
939
- */
940
- orbitvu_init_gallery();
941
-
942
- console.log('Waiting for image preloader...');
943
- orbitvu_preload_images();
944
-
945
- /*
946
- * Buttons starting visibility
947
- */
948
- if (orbitvu_scroll == 'yes') {
949
- if ((orbitvu_xAllReal - (<?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])*2)?>)) < orbitvu_gallery_inner) Orb$('orbitvu_go_next').style.display = 'none';
950
- else orbitvu_buttons = true;
951
- }
952
-
953
- /*
954
- * Attach events to thumbnails
955
- */
956
- var thumbnails = document.getElementsByClassName('orbitvu-gallery-item-link');
957
-
958
- for (var i = 0, n = thumbnails.length; i < n; i++) {
959
- <?php if ($_Orbitvu->GetConfiguration('hover_mode') == 'true') { ?>
960
- thumbnails[i].onmouseover = function() { orbitvu_switch(this, <?=($_Orbitvu->GetConfiguration('hover_delay')*100)?>); }
961
- thumbnails[i].onmouseout = function() { clearTimeout(orbitvu_switch_timer); }
962
- <?php } ?>
963
- thumbnails[i].onclick = function() { orbitvu_switch(this); return false; }
964
- }
965
-
966
- /*
967
- * Attach Events
968
- */
969
- Orb$('orbitvu-gallery-main-image').onmousemove = function(event) { orbitvu_manage_zoom(this, event); }
970
- Orb$('orbitvu-gallery-main-image').onmouseover = function() { orbitvu_show_zoom(); }
971
- Orb$('orbitvu-gallery-main-image').onmouseout = function() { orbitvu_hide_zoom(); }
972
- Orb$('orbitvu-gallery-product-image-zoom').onmousemove = function(event) { if (orbitvu_zoom_responsive) { orbitvu_manage_zoom(this, event); } }
973
- Orb$('orbitvu-gallery-product-image-zoom').onmouseover = function() { if (orbitvu_zoom_responsive) { orbitvu_show_zoom(); } }
974
- Orb$('orbitvu-gallery-product-image-zoom').onmouseout = function() { orbitvu_hide_zoom(); }
975
- Orb$('orbitvu_go_next').onclick = function() { orbitvu_goNext(); }
976
- Orb$('orbitvu_go_back').onclick = function() { orbitvu_goBack(); }
977
-
978
- /*
979
- * Calculate gallery dimensions
980
- */
981
- orbitvu_init_interval = setInterval('orbitvu_refresh()', 500);
982
- orbitvu_recalculate();
983
-
984
- /*
985
- * Load 360 presentation and/or tour
986
- */
987
- <?php
988
- if (!empty($view_360['path'])) {
989
- ?>
990
- if (typeof(orbitvu_360_interval) == 'undefined') {
991
- orbitvu_360_interval = setInterval('orbitvu_inject_360()', 500);
992
- }
993
- else {
994
- orbitvu_inject_360();
995
- }
996
- <?php
997
- }
998
- ?>
999
-
1000
- <?php
1001
- if (!empty($orbittour['path'])) {
1002
- ?>
1003
- if (typeof(orbitvu_tour_interval) == 'undefined') {
1004
- orbitvu_tour_interval = setInterval('orbitvu_inject_tour()', 500);
1005
- } else {
1006
- orbitvu_inject_tour()
1007
- }
1008
- <?php
1009
- }
1010
- ?>
1011
- }
1012
-
1013
- /*
1014
- * Synchronized actions
1015
- */
1016
- OrbitvuInit();
1017
-
1018
- /*
1019
- * Window events
1020
- */
1021
- window.onresize = function() {
1022
- if (orbitvu_window_onresize_enabled) {
1023
- if (window.innerWidth > orbitvu_window_before) orbitvu_window_growing = true;
1024
- else orbitvu_window_growing = false;
1025
-
1026
- orbitvu_init_gallery();
1027
- orbitvu_recalculate();
1028
- orbitvu_rewind();
1029
- orbitvu_max_counter = 1;
1030
-
1031
- orbitvu_window_before = window.innerWidth;
1032
- }
1033
- }
1034
- window.onorientationchange = function() { window.onresize(); }
1035
- </script>
1036
- <?php
1037
- }
1038
  ?>
1
+ <?php
2
+ /**
3
+ * @category Orbitvu
4
+ * @package Orbitvu_Sun
5
+ * @copyright Copyright (C) 2014 Orbitvu (http://www.orbitvu.com)
6
+ * @license http://www.orbitvu.com/plugins/license
7
+ * @version 1.0.0
8
+ */
9
+
10
+ //-------------------------------------------------------------------------------------------------------
11
+ $_product = $this->getProduct();
12
+ $_helper = $this->helper('catalog/output');
13
+ //-------------------------------------------------------------------------------------------------------
14
+ $jspreloader = array();
15
+ $jspreloader_tn = array();
16
+ $thumbs_list = array();
17
+ $images_list = array();
18
+ //-------------------------------------------------------------------------------------------------------
19
+ $observer = Mage::getSingleton('sun/observer');
20
+ $_Orbitvu = $observer->ExtendOrbitvu();
21
+
22
+ if (isset($_GET['flush']) && $_GET['flush'] == 'true') {
23
+ $observer->SynchronizeAllThumbnails();
24
+ }
25
+ //-------------------------------------------------------------------------------------------------------
26
+ /*
27
+ * Gallery theme
28
+ */
29
+ $_orbitvu_gallery = array(
30
+ 'width' => $_Orbitvu->GetConfiguration('width'),
31
+ 'img_height' => $_Orbitvu->GetConfiguration('img_height'),
32
+ 'border_color' => $_Orbitvu->GetConfiguration('border_color'),
33
+ 'img_width_zoom' => $_Orbitvu->GetConfiguration('img_width_zoom'),
34
+ 'img_height_zoom' => $_Orbitvu->GetConfiguration('img_height_zoom'),
35
+ 'img_width_tn' => $_Orbitvu->GetConfiguration('img_width_tn'),
36
+ 'img_height_tn' => $_Orbitvu->GetConfiguration('img_height_tn'),
37
+ 'img_tn_margin' => $_Orbitvu->GetConfiguration('img_tn_margin'),
38
+ 'button_width' => $_Orbitvu->GetConfiguration('button_width'),
39
+ 'button_height' => $_Orbitvu->GetConfiguration('button_height'),
40
+ 'button_opacity' => $_Orbitvu->GetConfiguration('button_opacity'),
41
+ 'img_width' => $_Orbitvu->GetConfiguration('img_width'),
42
+ 'img_tn_padding' => $_Orbitvu->GetConfiguration('img_tn_padding'),
43
+ 'scroll' => $_Orbitvu->GetConfiguration('scroll'),
44
+ );
45
+ $_orbitvu_gallery['height'] = (str_replace('px', '', $_orbitvu_gallery['img_height']) + str_replace('px', '', $_orbitvu_gallery['img_height_tn'] + 2) + (3 * str_replace('px', '', $_orbitvu_gallery['img_tn_margin']))).'px';
46
+ $_orbitvu_gallery['img_width_tn_marg'] = (str_replace('px', '', $_orbitvu_gallery['img_width_tn']) + str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])).'px';
47
+ $_orbitvu_gallery['img_height_tn_marg'] = (str_replace('px', '', $_orbitvu_gallery['img_height_tn']) + str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])).'px';
48
+
49
+ if (!$_orbitvu_gallery['scroll']) {
50
+ $_orbitvu_gallery['scroll'] = 'yes';
51
+ }
52
+
53
+ if (!$_orbitvu_gallery['img_tn_padding']) {
54
+ $_orbitvu_gallery['img_tn_padding'] = '2px';
55
+ }
56
+
57
+ $ratio = '56.25%'; //16:9 default
58
+ if ((strpos($_orbitvu_gallery['img_width'], 'px') !== false) && (strpos($_orbitvu_gallery['img_height'], 'px') !== false) && (strpos($_orbitvu_gallery['width'], '%') !== false)) {
59
+ $r_width = str_replace('px', '', $_orbitvu_gallery['img_width']);
60
+ $r_height = str_replace('px', '', $_orbitvu_gallery['img_height']); //-2 px because of border
61
+
62
+ $ratio = ($r_height) * 100 / $r_width;
63
+ $ratio = (string)$ratio.'%';
64
+ }
65
+
66
+ //-------------------------------------------------------------------------------------------------------
67
+ /*
68
+ * Get original product images
69
+ */
70
+ foreach ($this->getGalleryImages() as $_image) {
71
+ $current_array = array();
72
+ // original image
73
+ //-------------------------------------------------------------------------------------------------------
74
+ $this_url = $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile());
75
+ $thumbs_list[] = (string)$this_url;
76
+ $jspreloader[] = '\''.((string)$this_url).'\'';
77
+ $current_array['path'] = (string)$this_url;
78
+ //-------------------------------------------------------------------------------------------------------
79
+ // thumbnail 538x300
80
+ //-------------------------------------------------------------------------------------------------------
81
+ $this_url_tn = $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(str_replace('px', '', $_orbitvu_gallery['img_width']), str_replace('px', '', $_orbitvu_gallery['img_height']));
82
+ $jspreloader_tn[] = '\''.((string)$this_url_tn).'\'';
83
+ $current_array['path_tn'] = (string)$this_url_tn;
84
+ //-------------------------------------------------------------------------------------------------------
85
+ // thumbnail 75x75
86
+ //-------------------------------------------------------------------------------------------------------
87
+ $this_url_tn2 = $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(str_replace('px', '', $_orbitvu_gallery['img_width_tn']), str_replace('px', '', $_orbitvu_gallery['img_height_tn']));
88
+ $current_array['path_tn2'] = (string)$this_url_tn2;
89
+ //-------------------------------------------------------------------------------------------------------
90
+
91
+ //-------------------------------------------------------------------------------------------------------
92
+ $images_list[] = $current_array;
93
+ //-------------------------------------------------------------------------------------------------------
94
+ }
95
+ //-------------------------------------------------------------------------------------------------------
96
+ /*
97
+ * Item template
98
+ */
99
+ $_media_item_tpl = '
100
+ <li class="orbitvu-gallery-item{class}">
101
+ <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" href="{path}" target="_blank">
102
+ <img src="{path_tn2}" alt="" />
103
+ </a>
104
+ </li>
105
+ ';
106
+
107
+ $_presentation_item_tpl = '
108
+ <li class="orbitvu-gallery-item{class}">
109
+ <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" rel="presentation-360" href="{path}" target="_blank">
110
+ <img src="{path_tn2}" alt="" /><span class="orbitvu-gallery-item-desc"><span class="orbitvu-icon orbitvu-icon-type-1"></span></span>
111
+ </a>
112
+ </li>
113
+ ';
114
+
115
+ $_orbittour_item_tpl = '
116
+ <li class="orbitvu-gallery-item{class}">
117
+ <a class="orbitvu-gallery-item-link" id="orbitvu-{id}" rel="presentation-tour" href="{path}" target="_blank">
118
+ <img src="{path_tn2}" alt="" /><span class="orbitvu-gallery-item-desc"><span class="orbitvu-icon orbitvu-icon-type-0"></span></span>
119
+ </a>
120
+ </li>
121
+ ';
122
+ //-------------------------------------------------------------------------------------------------------
123
+ $all_items = 0;
124
+ $_out_items = '';
125
+ $i = 0;
126
+ $first_image = '';
127
+ /*
128
+ * Magento images
129
+ */
130
+ //-------------------------------------------------------------------------------------------------------
131
+ foreach ($images_list as $item) {
132
+ if ($i == 0) $item['class'] = ' orbitvu_active';
133
+ else $item['class'] = '';
134
+
135
+ $item['id'] = $all_items;
136
+
137
+ $_out_items .= $observer->UseTemplate($item, $_media_item_tpl);
138
+
139
+ $i++;
140
+ $all_items++;
141
+ }
142
+ //-------------------------------------------------------------------------------------------------------
143
+ if (isset($images_list[0]['path_tn'])) {
144
+ $first_image = array(
145
+ 'path_tn' => $images_list[0]['path_tn'],
146
+ 'path' => $images_list[0]['path']
147
+ );
148
+ }
149
+ //-------------------------------------------------------------------------------------------------------
150
+ $presentation = $_Orbitvu->GetProductPresentation($_product->getId(), true);
151
+
152
+ $view_360 = array();
153
+ $orbittour = array();
154
+ $i = 0;
155
+ if (count($presentation['items']) > 0) {
156
+ foreach ($presentation['items'] as $item) {
157
+ /*
158
+ * Orbitvu 2D Images
159
+ */
160
+ if ($item['type'] == '3') {
161
+ //-------------------------------------------------------------------------------------------------------
162
+ $current_path = 'http:'.$item['path'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
163
+ $current_path_tn = 'http:'.$item['path'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
164
+
165
+ $_out_items .= $observer->UseTemplate(array(
166
+ 'path' => $current_path,
167
+ 'path_tn' => $current_path_tn,
168
+ 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
169
+ 'class' => '',
170
+ 'id' => $all_items
171
+ ), $_media_item_tpl);
172
+ //-------------------------------------------------------------------------------------------------------
173
+ $jspreloader_tn[] = '\''.$current_path_tn.'\'';
174
+ $jspreloader[] = '\''.$current_path.'\'';
175
+
176
+ if ($i == 0 && empty($first_image)) {
177
+ $first_image = array(
178
+ 'path_tn' => $current_path_tn,
179
+ 'path' => $current_path
180
+ );
181
+ }
182
+
183
+ $all_items++;
184
+ }
185
+ /*
186
+ * Orbitvu 360 Presentations
187
+ */
188
+ else if ($item['type'] == '1') {
189
+ //-------------------------------------------------------------------------------------------------------
190
+ $current_path = 'http:'.$item['thumbnail'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
191
+ $current_path_tn = 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
192
+
193
+ $_out_items .= $observer->UseTemplate(array(
194
+ 'path' => $current_path,
195
+ 'path_tn' => $current_path_tn,
196
+ 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
197
+ 'class' => '',
198
+ 'id' => $all_items
199
+ ), $_presentation_item_tpl);
200
+
201
+ $item_config = json_decode($item['config']);
202
+ $item_uid = $item_config->uid;
203
+ $view_360 = array(
204
+ 'path' => $item['path'],
205
+ 'path_tn' => $current_path_tn,
206
+ 'uid' => $item_uid,
207
+ 'thumbnail' => $item['thumbnail']
208
+ );
209
+ //-------------------------------------------------------------------------------------------------------
210
+ $jspreloader_tn[] = '\''.$current_path_tn.'\'';
211
+ $jspreloader[] = '\''.$current_path.'\'';
212
+
213
+ if ($i == 0 && empty($first_image)) {
214
+ $first_image = array(
215
+ 'path_tn' => $current_path_tn,
216
+ 'path' => $current_path
217
+ );
218
+ }
219
+
220
+ $all_items++;
221
+ }
222
+ /*
223
+ * Orbittour presentation
224
+ */
225
+ else if ($item['type'] == '0') {
226
+ //-------------------------------------------------------------------------------------------------------
227
+ $current_path = 'http:'.$item['thumbnail'].'?max_width='.str_replace('px', '', $_orbitvu_gallery['img_width_zoom']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_zoom']);
228
+ $current_path_tn = 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height']).'&action=supplement';
229
+
230
+ $_out_items .= $observer->UseTemplate(array(
231
+ 'path' => $current_path,
232
+ 'path_tn' => $current_path_tn,
233
+ 'path_tn2' => 'http:'.$item['thumbnail'].'?width='.str_replace('px', '', $_orbitvu_gallery['img_width_tn']).'&height='.str_replace('px', '', $_orbitvu_gallery['img_height_tn']).'&action=supplement',
234
+ 'class' => '',
235
+ 'id' => $all_items
236
+ ), $_orbittour_item_tpl);
237
+
238
+ $item_config = json_decode($item['config']);
239
+ $item_uid = $item_config->uid;
240
+ $orbittour = array(
241
+ 'path' => $item['path'],
242
+ 'path_tn' => $current_path_tn,
243
+ 'uid' => $item_uid
244
+ );
245
+ //-------------------------------------------------------------------------------------------------------
246
+ $jspreloader_tn[] = '\''.$current_path_tn.'\'';
247
+ $jspreloader[] = '\''.$current_path.'\'';
248
+
249
+ if ($i == 0 && empty($first_image)) {
250
+ $first_image = array(
251
+ 'path_tn' => $current_path_tn,
252
+ 'path' => $current_path
253
+ );
254
+ }
255
+
256
+ $all_items++;
257
+ }
258
+ //-------------------------------------------------------------------------------------------------------
259
+ $i++;
260
+ }
261
+ }
262
+
263
+ //-------------------------------------------------------------------------------------------------------
264
+ /*
265
+ * Display output
266
+ */
267
+ ?>
268
+ <style type="text/css">
269
+
270
+ #orbitvu-gallery-wrapper {
271
+ width: <?=$_orbitvu_gallery['width'];?>
272
+ }
273
+
274
+ #orbitvu-gallery-fix {
275
+ border: 1px solid <?=$_orbitvu_gallery['border_color']?>;
276
+ }
277
+ .orbitvu-gallery {
278
+ margin: 0;
279
+ padding: 0;
280
+ position: relative;
281
+ padding-bottom: <?=$ratio; ?>; /* 16:9 - default */
282
+ height: 0;
283
+ z-index: 9;
284
+ }
285
+ </style>
286
+
287
+ <?php
288
+ if ($all_items <= 0) {
289
+ ?>
290
+ <div id="orbitvu-gallery-wrapper">
291
+ <div id="orbitvu-gallery-fix">
292
+ <div class="orbitvu-gallery" id="orbitvu-gallery" style="width: <?=$_orbitvu_gallery['width']?>; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/placeholder.png); background-position: center; center; background-repeat: no-repeat;"></div>
293
+ </div>
294
+ </div>
295
+
296
+ <!--<div class="orbitvu-gallery" id="orbitvu-gallery-placeholder" style="width: <?=$_orbitvu_gallery['width']?>; height: <?=$_orbitvu_gallery['height']?>; margin: 0; padding: 0; position: relative; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/placeholder.png); background-position: center; center; background-repeat: no-repeat;"></div>-->
297
+ <script>
298
+ window.onresize = function() {
299
+ if (window.innerWidth < 770) document.getElementById('orbitvu-gallery').style.display = 'none';
300
+ else document.getElementById('orbitvu-gallery').style.display = 'block';
301
+ }
302
+ window.onresize();
303
+ </script>
304
+ <?php
305
+ }
306
+ else if ($all_items > 0) {
307
+ ?>
308
+ <div id="orbitvu-gallery-wrapper">
309
+ <div id="orbitvu-gallery-fix">
310
+ <div class="orbitvu-gallery" id="orbitvu-gallery">
311
+ <div id="orbitvu-gallery-product-image" class="orbitvu-gallery-product-image">
312
+ <div id="orbitvu-gallery-view-image">
313
+ <img id="orbitvu-gallery-main-image" style="display: inline;" alt="orbitvu-0" src="<?=$first_image['path_tn']?>" />
314
+ </div>
315
+ <div id="orbitvu-gallery-view-360" class="orbitvu-presentation"<?php if (!empty($view_360['path'])) {
316
+ echo ' style="background-image: url('.$view_360['thumbnail'].'?max_height='.str_replace('px', '', $_orbitvu_gallery['img_height']).');"';
317
+ }?>><?php
318
+ if (!empty($view_360['path'])) {
319
+ ?>
320
+ <script type="text/javascript" src="<?=$view_360['path']?>?content2=yes&force_html5=<?=$_Orbitvu->GetConfiguration('html5')?><?php
321
+ $orbitvu_teaser = $_Orbitvu->GetConfiguration('teaser');
322
+ if ($orbitvu_teaser != 'sun') {
323
+ print '&teaser='.$orbitvu_teaser;
324
+ }
325
+ ?>&width=auto&height=auto&viewer_delayed=yes" id="orbitvu-viewer-script"></script>
326
+ <div id="ovContent-<?=$view_360['uid']?>" class="orbitvu-container" style="width: 100%; height: 100%; background-repeat: no-repeat; background-position: center center; background-size: contain; background-image: url(<?=$view_360['thumbnail']?>?max_height=<?=str_replace('px', '', $_orbitvu_gallery['img_height'])?>);"></div>
327
+ <?php
328
+ }
329
+ ?></div>
330
+ <div id="orbitvu-gallery-view-tour" class="orbitvu-presentation"><?php
331
+ if (!empty($orbittour['path'])) {
332
+ ?>
333
+ <div id="orbittour-<?=$orbittour['uid']?>" class="orbittour-container"></div>
334
+ <script type="text/javascript" src="<?=$orbittour['path']?>?orbittour_delayed=yes&onready=no&force_html5=<?=$_Orbitvu->GetConfiguration('html5')?><?php
335
+ $otn = $_Orbitvu->GetConfiguration('orbittour_thumbnails');
336
+
337
+ if ($otn != 'sun') {
338
+ print '&style='.$otn;
339
+ }
340
+
341
+ ?>"></script>
342
+ <?php } ?></div>
343
+ </div>
344
+ <div id="orbitvu-gallery-product-image-zoom" style="background-image: url(<?=$first_image['path']?>);"></div>
345
+ <div id="orbitvu-gallery-preloader"></div>
346
+ </div>
347
+ </div>
348
+ <div id="orbitvu-gallery-scroller">
349
+ <div class="orbitvu-gallery-product-views" id="orbitvu-gallery-product-views">
350
+ <ul class="orbitvu-image-thumbs" id="orbitvu-image-thumbs" style="margin-left: 0;">
351
+ <?=$_out_items?>
352
+ </ul>
353
+ <em id="orbitvu_go_next" class="orbitvu-gallery-button"><span>&raquo;</span></em>
354
+ <em id="orbitvu_go_back" class="orbitvu-gallery-button"><span>&laquo;</span></em>
355
+ </div>
356
+ </div>
357
+ </div>
358
+
359
+ <style type="text/css">
360
+
361
+ .orbitvu-gallery-product-image { clear: both; overflow: hidden; zoom: 1.0; max-height: <?=$_orbitvu_gallery['img_height']?>; position: relative; text-align: center; }
362
+ .orbitvu-gallery-product-image img#orbitvu-gallery-main-image { display: inline; margin: 0; padding: 0; border: 0; max-width: 100%; max-height: 100%; cursor: crosshair; }
363
+ #orbitvu-gallery-product-image-zoom { display: none; height: auto; box-sizing: content-box; position: absolute; z-index: 2; top: -1px; bottom: -1px; right: -100%; width: 100%; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; background-color: white; background-repeat: no-repeat; cursor: crosshair; }
364
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs { margin: 0; padding: 0; <?= $_orbitvu_gallery['scroll'] == 'yes' ? 'width: 99999px;' : '' ?> }
365
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item { float: left; display: table-row; overflow: hidden; margin: <?=$_orbitvu_gallery['img_tn_margin']?>; position: relative; border: 1px solid transparent; }
366
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item:hover, .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item.orbitvu_active { border: 1px solid <?=$_orbitvu_gallery['border_color']?>; }
367
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item a.orbitvu-gallery-item-link { display: table-cell; vertical-align: middle; width: <?=$_orbitvu_gallery['img_width_tn_marg']?>; height: <?=$_orbitvu_gallery['img_height_tn_marg']?>; text-align: center; }
368
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item:first-child { margin-left: 0px; }
369
+ .orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item a.orbitvu-gallery-item-link img { display: block; margin: 0 auto; max-width: <?=$_orbitvu_gallery['img_width_tn']?>; max-height: <?=$_orbitvu_gallery['img_height_tn']?>; padding: <?=$_orbitvu_gallery['img_tn_padding']?>; box-sizing: content-box !important }
370
+ .orbitvu-gallery-item-desc { display: block; padding: 2px; position: absolute; bottom: 0; left: 0; background: rgba(255, 255, 255, 0.5); color: black; font-weight: bold; font-size: 0.8em; }
371
+ .orbitvu-gallery-button { display: table-row; position: absolute; bottom: <?=$_orbitvu_gallery['img_tn_margin']?>; width: <?=$_orbitvu_gallery['button_width']?>; height: <?=$_orbitvu_gallery['button_height']?>; background: white; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; font-weight: bold; text-align: center; opacity: <?=$_orbitvu_gallery['button_opacity']?>; color: black; font-size: 24px; text-decoration: none; font-style: normal; cursor: pointer; }
372
+ .orbitvu-gallery-button:hover { background: black; color: white; text-decoration: none; border-color: black; }
373
+ .orbitvu-gallery-button span { display: table-cell; vertical-align: middle; width: <?=$_orbitvu_gallery['button_width']?>; height: <?=$_orbitvu_gallery['button_height']?>; }
374
+ #orbitvu_go_next { right: -1px; <?= $_orbitvu_gallery['scroll'] == 'no' ? 'display: none' : '' ?>}
375
+ #orbitvu_go_back { display: none; left: -1px; }
376
+ #orbitvu-gallery-preloader { position: absolute; top: -10000px; left: -10000px; }
377
+ .orbitvu-presentation { display: block; width: 100%; height: 100%; top: -10000px; background-repeat: no-repeat; background-position: center center; background-size: contain; }
378
+ .orbitvu-icon { display: block; width: 22px; height: 22px; background-image: url(<?=Mage::getBaseUrl('media')?>orbitvu/black.png); background-repeat: no-repeat; }
379
+ .orbitvu-icon-type-3 { background-position: 0 -32px; }
380
+ .orbitvu-icon-type-1 { background-position: -22px -32px; }
381
+ .orbitvu-icon-type-0 { background-position: -44px -32px; }
382
+
383
+ #orbitvu-gallery-scroller {
384
+ position: relative;
385
+ height: auto;
386
+ overflow: hidden;
387
+ }
388
+
389
+ .orbitvu-gallery .orbitvu-gallery-product-image {
390
+ position: absolute;
391
+ top: 0;
392
+ left: 0;
393
+ width: 100%;
394
+ height: 100%;
395
+ }
396
+ </style>
397
+ <script>
398
+ /*
399
+ * Orbitvu Public Declarations
400
+ */
401
+ var orbitvu_timer, orbitvu_rectangle, orbitvu_current_image, orbitvu_init_interval, orbitvu_box_width, orbitvu_box_height, orbitvu_switch_timer;
402
+ var orbitvu_image_thumbs = Orb$('orbitvu-image-thumbs');
403
+ var orbitvu_speed = 24;
404
+ var orbitvu_xAll = 0;
405
+ var orbitvu_xAllReal = 0;
406
+ var orbitvu_xMax = 0;
407
+ var orbitvu_gallery_inner;
408
+ var orbitvu_pos = 0;
409
+ var orbitvu_dir = 1;
410
+ var orbitvu_fps = 30;
411
+ var orbitvu_interval = 1000 / orbitvu_fps;
412
+ var orbitvu_lastV = 0;
413
+ var orbitvu_img_preloader_tn = new Array(<?=implode(',', $jspreloader_tn)?>);
414
+ var orbitvu_img_preloader = new Array(<?=implode(',', $jspreloader)?>);
415
+ var orbitvu_buttons = false;
416
+ var orbitvu_max_counter = 3;
417
+ var orbitvu_ready = false;
418
+ var orbitvu_window_before = window.innerWidth;
419
+ var orbitvu_window_growing = false;
420
+ var orbitvu_smallest_height = '<?=$_orbitvu_gallery['img_height']?>';
421
+ var orbitvu_window_onresize_enabled = true;
422
+ var orbitvu_zoom_responsive = false;
423
+ var orbitvu_scroll = '<?=$_orbitvu_gallery['scroll']?>';
424
+
425
+ /*
426
+ * Orbitvu Objects
427
+ */
428
+ function OrbitvuOffsetRectangle(elem){
429
+ var box = elem.getBoundingClientRect();
430
+ var clientTop = document.documentElement.clientTop || document.body.clientTop||0;
431
+ var clientLeft = document.documentElement.clientLeft || document.body.clientLeft||0;
432
+ var top = box.top - clientTop;
433
+ var left = box.left - clientLeft;
434
+
435
+ return {
436
+ top: Math.round(top),
437
+ left: Math.round(left)
438
+ };
439
+ }
440
+
441
+ function OrbitvuImage(id) {
442
+ id = parseInt(String(id).replace('orbitvu-', ''));
443
+
444
+ var temp = orbitvu_get_image_dimensions(Orb$('orbitvu-img-tn-' + id));
445
+ var temp_zoom = orbitvu_get_image_dimensions(Orb$('orbitvu-img-' + id));
446
+
447
+ return {
448
+ orbitvu_id: 'orbitvu-' + id,
449
+ path: orbitvu_img_preloader[id],
450
+ path_tn: orbitvu_img_preloader_tn[id],
451
+ width: temp.width,
452
+ height: temp.height,
453
+ width_zoom: temp_zoom.width,
454
+ height_zoom: temp_zoom.height
455
+ };
456
+ }
457
+
458
+ /*
459
+ * Orbitvu Funtions Pure JS
460
+ */
461
+ function Orb$(el) {
462
+ return document.getElementById(el);
463
+ }
464
+
465
+ function orbitvu_stristr(haystack, needle, bool) {
466
+ var pos = 0;
467
+
468
+ haystack += '';
469
+ pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());
470
+ if (pos == -1) {
471
+ return false;
472
+ }
473
+ else {
474
+ if (bool) {
475
+ return haystack.substr(0, pos);
476
+ }
477
+ else {
478
+ return haystack.slice(pos);
479
+ }
480
+ }
481
+ }
482
+
483
+ /*
484
+ * Inject 360
485
+ */
486
+ function orbitvu_inject_tour_now() {
487
+ inject_orbittour_<?= isset($orbittour['uid']) ? $orbittour['uid'] : '' ?>();
488
+ }
489
+
490
+ function orbitvu_inject_tour() {
491
+ <?php
492
+ if (!empty($orbittour['path'])) {
493
+ ?>
494
+ if (orbitvu_ready) {
495
+ clearInterval(orbitvu_tour_interval);
496
+ orbitvu_inject_tour_now();
497
+ //console.log('OrbitTour loaded.');
498
+ }
499
+ <?php
500
+ }
501
+ ?>
502
+ }
503
+
504
+ function orbitvu_remove_bg_360() {
505
+ Orb$('orbitvu-gallery-view-360').style.backgroundImage = '';
506
+ }
507
+
508
+ function orbitvu_inject_360_now() {
509
+ <?php
510
+ if (!empty($view_360['path'])) {
511
+ ?>
512
+ inject_viewer_<?=$view_360['uid']?>();
513
+ setTimeout('orbitvu_remove_bg_360()', 500);
514
+ <?php
515
+ }
516
+ ?>
517
+ }
518
+
519
+ function orbitvu_inject_360() {
520
+ <?php
521
+ if (!empty($view_360['path'])) {
522
+ ?>
523
+ if (orbitvu_ready) {
524
+ clearInterval(orbitvu_360_interval);
525
+ orbitvu_inject_360_now();
526
+ //console.log('360 loaded.');
527
+ }
528
+ <?php
529
+ }
530
+ ?>
531
+ }
532
+
533
+ /*
534
+ * Get real image dimensions from preloaded 1x1
535
+ * @returns {integer width, integer height}
536
+ */
537
+ function orbitvu_get_image_dimensions(temp) {
538
+ if ((typeof temp === "undefined") || (temp === null) || (typeof temp.style === "undefined") || (temp.style === null)) {
539
+ return {};
540
+ }
541
+ temp.style.width = 'auto';
542
+ temp.style.height = 'auto';
543
+ var img_width = parseInt(temp.offsetWidth);
544
+ var img_height = parseInt(temp.offsetHeight);
545
+ temp.style.width = '1px';
546
+ temp.style.height = '1px';
547
+
548
+ return {
549
+ width: img_width,
550
+ height: img_height
551
+ };
552
+ }
553
+
554
+ function orbitvu_get_maxHeight() {
555
+ return parseInt(Orb$('orbitvu-gallery').offsetHeight - Orb$('orbitvu-gallery-product-views').offsetHeight) - 2;
556
+ }
557
+
558
+ function orbitvu_init_gallery() {
559
+ orbitvu_gallery_inner = Orb$('orbitvu-gallery').clientWidth;
560
+
561
+ orbitvu_xMax = 0;
562
+ orbitvu_xAll = 0;
563
+
564
+ var i = 0;
565
+
566
+ for (n = orbitvu_image_thumbs.children.length, orbitvu_current = 0; i < n; i++) {
567
+ //orbitvu_current = orbitvu_image_thumbs.children[i].clientWidth + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin']) * 2)?> + 2;
568
+ orbitvu_current = <?=(str_replace('px', '', $_orbitvu_gallery['img_width_tn']))?> + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin']) * 2)?> + <?=(str_replace('px', '', $_orbitvu_gallery['img_tn_padding']) * 2)?> + 2; //+2 is a border transparent from css
569
+ if (i == 0) orbitvu_xMax += orbitvu_current;
570
+ orbitvu_xAll += orbitvu_current;
571
+ }
572
+
573
+ if (i == 1) {
574
+ Orb$('orbitvu-gallery-product-views').style.height = '1px';
575
+ }
576
+
577
+ orbitvu_xAllReal = orbitvu_xAll;
578
+ orbitvu_xAll -= orbitvu_gallery_inner;
579
+ }
580
+
581
+
582
+ function orbitvu_reset_classes() {
583
+ for (var i = 0, n = Orb$('orbitvu-image-thumbs').children.length; i < n; i++) {
584
+ Orb$('orbitvu-image-thumbs').children[i].className = Orb$('orbitvu-image-thumbs').children[i].className.replace('orbitvu_active', '');
585
+ }
586
+ }
587
+
588
+ /*
589
+ * To delete if not used
590
+ * @returns {undefined} */
591
+ function orbitvu_presentations_resize() {
592
+ orbitvu_window_onresize_enabled = false;
593
+ window.dispatchEvent(new Event('resize'));
594
+ orbitvu_window_onresize_enabled = true;
595
+ }
596
+
597
+ function orbitvu_switch_now(el) {
598
+ orbitvu_reset_classes();
599
+ el.parentNode.className += ' orbitvu_active';
600
+
601
+ orbitvu_current_image = OrbitvuImage(el.id);
602
+
603
+ Orb$('orbitvu-gallery-main-image').src = orbitvu_current_image.path_tn;
604
+ Orb$('orbitvu-gallery-main-image').alt = el.id;
605
+
606
+ if (el.rel == 'presentation-360') {
607
+ Orb$('orbitvu-gallery-view-image').style.display = 'none';
608
+ Orb$('orbitvu-gallery-view-tour').style.position = 'absolute';
609
+ Orb$('orbitvu-gallery-view-360').style.position = '';
610
+ //orbitvu_presentations_resize();
611
+ }
612
+ else if (el.rel == 'presentation-tour') {
613
+ Orb$('orbitvu-gallery-view-image').style.display = 'none';
614
+ Orb$('orbitvu-gallery-view-tour').style.position = '';
615
+ Orb$('orbitvu-gallery-view-360').style.position = 'absolute';
616
+ //orbitvu_presentations_resize();
617
+ }
618
+ else {
619
+ Orb$('orbitvu-gallery-view-image').style.display = 'block';
620
+ Orb$('orbitvu-gallery-view-360').style.position = 'absolute'; // workaround display: block/none
621
+ Orb$('orbitvu-gallery-view-tour').style.position = 'absolute'; // workaround display: block/none
622
+ }
623
+ }
624
+
625
+ function orbitvu_switch(el, delay) {
626
+ if (delay > 0) {
627
+ clearTimeout(orbitvu_switch_timer);
628
+
629
+ orbitvu_switch_timer = setTimeout(function () {
630
+ orbitvu_switch_now(el);
631
+ }, delay);
632
+ }
633
+ else {
634
+ orbitvu_switch_now(el);
635
+ }
636
+ }
637
+
638
+ function orbitvu_hide_zoom() {
639
+ Orb$('orbitvu-gallery-product-image-zoom').style.display = 'none';
640
+ }
641
+
642
+ function orbitvu_show_zoom() {
643
+ if (!orbitvu_ready) return false;
644
+
645
+ Orb$('orbitvu-gallery-product-image-zoom').style.backgroundImage = 'url(' + orbitvu_current_image.path + ')';
646
+ Orb$('orbitvu-gallery-product-image-zoom').style.display = 'block';
647
+
648
+ if (((Orb$('orbitvu-gallery-product-image-zoom').offsetLeft + Orb$('orbitvu-gallery-product-image-zoom').offsetWidth) > document.body.offsetWidth) || window.innerWidth < 770 || document.body.offsetWidth < 770) {
649
+ Orb$('orbitvu-gallery-product-image-zoom').style.right = '-1px';
650
+ Orb$('orbitvu-gallery-product-image-zoom').style.left = '-1px';
651
+ Orb$('orbitvu-gallery-product-image-zoom').style.height = parseInt(Orb$('orbitvu-gallery').offsetHeight - Orb$('orbitvu-gallery-product-views').offsetHeight - 2) + 'px';
652
+ orbitvu_rectangle = OrbitvuOffsetRectangle(Orb$('orbitvu-gallery-product-image-zoom'));
653
+ orbitvu_zoom_responsive = true;
654
+ }
655
+ else {
656
+ Orb$('orbitvu-gallery-product-image-zoom').style.right = '-100%';
657
+ Orb$('orbitvu-gallery-product-image-zoom').style.left = 'auto';
658
+ Orb$('orbitvu-gallery-product-image-zoom').style.height = 'auto';
659
+ orbitvu_zoom_responsive = false;
660
+ orbitvu_rectangle = OrbitvuOffsetRectangle(Orb$('orbitvu-gallery-main-image'));
661
+ }
662
+ }
663
+
664
+ function orbitvu_manage_zoom(obj, event) {
665
+ if (!orbitvu_ready) return false;
666
+ if (!orbitvu_rectangle) {
667
+ orbitvu_rectangle = OrbitvuOffsetRectangle(obj);
668
+ }
669
+
670
+ var mx = event.clientX - orbitvu_rectangle.left;
671
+ var my = event.clientY - orbitvu_rectangle.top;
672
+
673
+ if (Orb$('orbitvu-gallery-product-image-zoom').style.display == 'none') orbitvu_show_zoom();
674
+
675
+ if (orbitvu_current_image) {
676
+ //console.log('w: ' + obj.offsetWidth + ', h: ' + obj.offsetHeight + ', nw: ' + orbitvu_current_image.width_zoom + ', nh: ' + orbitvu_current_image.height_zoom);
677
+ var interpolate_x = Math.round(mx * (orbitvu_current_image.width_zoom / obj.offsetWidth));
678
+ var interpolate_y = Math.round(my * (orbitvu_current_image.height_zoom / obj.offsetHeight));
679
+
680
+ interpolate_x = interpolate_x - (orbitvu_box_width/2);
681
+ interpolate_y = interpolate_y - (orbitvu_box_height/2);
682
+
683
+ var orb_box_w = orbitvu_current_image.width_zoom - orbitvu_box_width;
684
+ var orb_box_h = orbitvu_current_image.height_zoom - orbitvu_box_height;
685
+
686
+ if (interpolate_x >= orb_box_w) interpolate_x = orb_box_w;
687
+ if (interpolate_y >= orb_box_h) interpolate_y = orb_box_h;
688
+
689
+ interpolate_x *= -1;
690
+ interpolate_y *= -1;
691
+
692
+ if (interpolate_x >= 0) interpolate_x = 0;
693
+ if (interpolate_y >= 0) interpolate_y = 0;
694
+
695
+ //console.log('x: ' + mx + ', y: ' + my + ', new_x: ' + interpolate_x + ', new_y: ' + interpolate_y + ', orbw: ' + orb_box_w + ', orbh: ' + orb_box_h);
696
+ Orb$('orbitvu-gallery-product-image-zoom').style.backgroundPosition = Math.round(interpolate_x) + 'px ' + Math.round(interpolate_y) + 'px';
697
+ }
698
+ }
699
+
700
+ function orbitvu_preload_images() {
701
+
702
+ var i = 0;
703
+
704
+ Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-tn-' + i + '" src="' + orbitvu_img_preloader_tn[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
705
+ Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-' + i + '" src="' + orbitvu_img_preloader[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
706
+
707
+ Orb$('orbitvu-img-0').onload = function() {
708
+ orbitvu_current_image = OrbitvuImage('orbitvu-0');
709
+ //console.log('Image preloader continues...');
710
+
711
+ for (var i = 1, n = orbitvu_img_preloader_tn.length; i < n; i++) {
712
+ Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-tn-' + i + '" src="' + orbitvu_img_preloader_tn[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
713
+ Orb$('orbitvu-gallery-preloader').innerHTML += '<img id="orbitvu-img-' + i + '" src="' + orbitvu_img_preloader[i] + '" style="width: 1px; height: 1px;" alt="" /> ';
714
+ }
715
+
716
+ //console.log('Done.');
717
+
718
+ }
719
+
720
+ }
721
+
722
+ (function() {
723
+ var lastTime = 0;
724
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
725
+ for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
726
+ window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
727
+ window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
728
+ || window[vendors[x]+'CancelRequestAnimationFrame'];
729
+ }
730
+
731
+ if (!window.requestAnimationFrame)
732
+ window.requestAnimationFrame = function(callback, element) {
733
+ var currTime = new Date().getTime();
734
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
735
+ var id = window.setTimeout(function() { callback(currTime + timeToCall); },
736
+ timeToCall);
737
+ lastTime = currTime + timeToCall;
738
+ return id;
739
+ };
740
+
741
+ if (!window.cancelAnimationFrame)
742
+ window.cancelAnimationFrame = function(id) {
743
+ clearTimeout(id);
744
+ };
745
+ }());
746
+
747
+ function orbitvu_get_pos() {
748
+ return parseInt(orbitvu_image_thumbs.style.marginLeft.replace('px', ''));
749
+ }
750
+
751
+ function orbitvu_go() {
752
+ /*
753
+ * Do the math
754
+ */
755
+ current_val = (orbitvu_dir * orbitvu_speed);
756
+ orbitvu_pos = orbitvu_get_pos();
757
+
758
+ /*
759
+ * Check if animation can rewind
760
+ */
761
+ if ((orbitvu_dir == -1 && (orbitvu_pos * -1) > orbitvu_xAll) || (orbitvu_dir == 1 && (orbitvu_pos * -1) <= 0)) return false;
762
+
763
+ /*
764
+ * Start animation
765
+ */
766
+ orbitvu_lastV += current_val;
767
+ orbitvu_animation = window.requestAnimationFrame(orbitvu_go);
768
+ orbitvu_image_thumbs.style.marginLeft = (current_val + orbitvu_pos) + 'px';
769
+
770
+ if ((orbitvu_dir == 1 && orbitvu_lastV >= (orbitvu_xMax * orbitvu_max_counter)) || (orbitvu_dir == -1 && (-1 * orbitvu_lastV) >= (orbitvu_xMax * orbitvu_max_counter))) {
771
+ window.cancelAnimationFrame(orbitvu_animation);
772
+ orbitvu_lastV = 0;
773
+ orbitvu_max_counter = 1;
774
+ }
775
+
776
+ /*
777
+ * Hide or show buttons
778
+ */
779
+ if (orbitvu_buttons) {
780
+ new_pos = orbitvu_get_pos();
781
+ if ((orbitvu_dir == -1 && (new_pos * -1) > orbitvu_xAll)) {
782
+ Orb$('orbitvu_go_next').style.display = 'none';
783
+ }
784
+ else {
785
+ Orb$('orbitvu_go_next').style.display = 'block';
786
+ }
787
+ if ((orbitvu_dir == 1 && (new_pos * -1) <= 0)) {
788
+ Orb$('orbitvu_go_back').style.display = 'none';
789
+ }
790
+ else {
791
+ Orb$('orbitvu_go_back').style.display = 'block';
792
+ }
793
+ }
794
+ }
795
+
796
+ function orbitvu_goNext() {
797
+ orbitvu_dir = -1;
798
+ orbitvu_max_counter = 3;
799
+ orbitvu_go();
800
+ }
801
+
802
+ function orbitvu_goBack() {
803
+ orbitvu_dir = 1;
804
+ orbitvu_max_counter = 3;
805
+ orbitvu_go();
806
+ }
807
+
808
+ function orbitvu_rewind() {
809
+ orbitvu_dir = 1;
810
+ orbitvu_max_counter = 100;
811
+ orbitvu_go();
812
+ }
813
+
814
+ function orbitvu_get_param(element) {
815
+ var main_prev_visibility, main_prev_display, prev_visibility, prev_display;
816
+ var main_cont = Orb$('orbitvu-gallery-view-image');
817
+
818
+ if (element.style.visibility == '') prev_visibility = 'visible';
819
+ else prev_visibility = element.style.visibility;
820
+
821
+ if (element.style.display == '') prev_display = 'block';
822
+ else prev_display = element.style.display;
823
+
824
+ if (main_cont.style.visibility == '') main_prev_display = 'visible';
825
+ else main_prev_display = main_cont.style.visibility;
826
+ if (main_cont.style.display == '') main_prev_display = 'block';
827
+ else main_prev_display = main_cont.style.display;
828
+
829
+ main_cont.style.visibility = 'visible';
830
+ main_cont.style.display = 'block';
831
+ element.style.visibility = 'visible';
832
+ element.style.display = 'block';
833
+
834
+ my_height = parseInt(element.offsetHeight);
835
+ my_width = parseInt(element.offsetWidth);
836
+
837
+ element.style.visibility = prev_visibility;
838
+ element.style.display = prev_display;
839
+ main_cont.style.visibility = main_prev_visibility;
840
+ main_cont.style.display = main_prev_display;
841
+
842
+ return {
843
+ width: my_width,
844
+ height: my_height
845
+ };
846
+ }
847
+
848
+ function orbitvu_maxHeight_fix() {
849
+ Orb$('orbitvu-gallery-product-image').style.maxHeight = '<?=$_orbitvu_gallery['img_height']?>';
850
+
851
+ var orbitvu_gallery_dim = orbitvu_get_param(Orb$('orbitvu-gallery'));
852
+ var orbitvu_gallery_main_image_dim = orbitvu_get_param(Orb$('orbitvu-gallery-main-image'));
853
+ var orbitvu_gallery_product_views_dim = { height: parseInt(Orb$('orbitvu-gallery-product-views').offsetHeight) };
854
+ var new_height = orbitvu_gallery_dim.height - (orbitvu_gallery_dim.height - orbitvu_gallery_main_image_dim.height - orbitvu_gallery_product_views_dim.height);
855
+
856
+ Orb$('orbitvu-gallery').style.height = parseInt(new_height + 2) + 'px';
857
+
858
+ orbitvu_smallest_height = orbitvu_get_maxHeight();
859
+ Orb$('orbitvu-gallery-product-image').style.maxHeight = orbitvu_smallest_height + 'px';
860
+
861
+ if (orbitvu_img_preloader.length <= 1) {
862
+ var new_sm_height = orbitvu_smallest_height + 2;
863
+ }
864
+ else {
865
+ var new_sm_height = orbitvu_smallest_height - 2;
866
+ }
867
+
868
+ Orb$('orbitvu-gallery-view-360').style.height = new_sm_height + 'px';
869
+ Orb$('orbitvu-gallery-view-tour').style.height = new_sm_height + 'px';
870
+ }
871
+
872
+ function orbitvu_refresh() {
873
+ var current_id = 'orbitvu-0';
874
+
875
+ if (typeof orbitvu_current_image != 'undefined') {
876
+ if ('orbitvu_id' in orbitvu_current_image) {
877
+ current_id = orbitvu_current_image.orbitvu_id;
878
+ }
879
+ }
880
+ orbitvu_switch(Orb$(current_id));
881
+
882
+ if (orbitvu_current_image.width_zoom > 0) {
883
+
884
+ //orbitvu_maxHeight_fix();
885
+
886
+ clearInterval(orbitvu_init_interval);
887
+ //console.log('Ready.');
888
+ orbitvu_ready = true;
889
+
890
+ orbitvu_calculate_zoom();
891
+ }
892
+
893
+ if (orbitvu_scroll == 'yes') {
894
+ if ((orbitvu_xAllReal - (<?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])*2)?>)) < orbitvu_gallery_inner) {
895
+ Orb$('orbitvu_go_back').style.display = 'none';
896
+ Orb$('orbitvu_go_next').style.display = 'none';
897
+ orbitvu_buttons = false;
898
+ } else {
899
+ orbitvu_buttons = true;
900
+ }
901
+
902
+ if (orbitvu_buttons) {
903
+ new_pos = orbitvu_get_pos();
904
+ if ((orbitvu_dir == -1 && (new_pos * -1) > orbitvu_xAll)) {
905
+ Orb$('orbitvu_go_next').style.display = 'none';
906
+ }
907
+ else {
908
+ Orb$('orbitvu_go_next').style.display = 'block';
909
+ }
910
+ if ((orbitvu_dir == 1 && (new_pos * -1) <= 0)) {
911
+ Orb$('orbitvu_go_back').style.display = 'none';
912
+ }
913
+ else {
914
+ Orb$('orbitvu_go_back').style.display = 'block';
915
+ }
916
+ }
917
+ }
918
+ }
919
+
920
+ function orbitvu_calculate_zoom() {
921
+ orbitvu_show_zoom();
922
+ var image_zoom = orbitvu_get_param(Orb$('orbitvu-gallery-product-image-zoom'));
923
+ orbitvu_hide_zoom();
924
+ orbitvu_box_width = image_zoom.width;
925
+ orbitvu_box_height = image_zoom.height;
926
+ }
927
+
928
+ function orbitvu_recalculate() {
929
+ orbitvu_calculate_zoom();
930
+ orbitvu_refresh();
931
+ }
932
+
933
+ /*
934
+ * Starting function
935
+ */
936
+ function OrbitvuInit() {
937
+ /*
938
+ * Init gallery and images
939
+ */
940
+ orbitvu_init_gallery();
941
+
942
+ //console.log('Waiting for image preloader...');
943
+ orbitvu_preload_images();
944
+
945
+ /*
946
+ * Buttons starting visibility
947
+ */
948
+ if (orbitvu_scroll == 'yes') {
949
+ if ((orbitvu_xAllReal - (<?=(str_replace('px', '', $_orbitvu_gallery['img_tn_margin'])*2)?>)) < orbitvu_gallery_inner) Orb$('orbitvu_go_next').style.display = 'none';
950
+ else orbitvu_buttons = true;
951
+ }
952
+
953
+ /*
954
+ * Attach events to thumbnails
955
+ */
956
+ var thumbnails = document.getElementsByClassName('orbitvu-gallery-item-link');
957
+
958
+ for (var i = 0, n = thumbnails.length; i < n; i++) {
959
+ <?php if ($_Orbitvu->GetConfiguration('hover_mode') == 'true') { ?>
960
+ thumbnails[i].onmouseover = function() { orbitvu_switch(this, <?=($_Orbitvu->GetConfiguration('hover_delay')*100)?>); }
961
+ thumbnails[i].onmouseout = function() { clearTimeout(orbitvu_switch_timer); }
962
+ <?php } ?>
963
+ thumbnails[i].onclick = function() { orbitvu_switch(this); return false; }
964
+ }
965
+
966
+ /*
967
+ * Attach Events
968
+ */
969
+ Orb$('orbitvu-gallery-main-image').onmousemove = function(event) { orbitvu_manage_zoom(this, event); }
970
+ Orb$('orbitvu-gallery-main-image').onmouseover = function() { orbitvu_show_zoom(); }
971
+ Orb$('orbitvu-gallery-main-image').onmouseout = function() { orbitvu_hide_zoom(); }
972
+ Orb$('orbitvu-gallery-product-image-zoom').onmousemove = function(event) { if (orbitvu_zoom_responsive) { orbitvu_manage_zoom(this, event); } }
973
+ Orb$('orbitvu-gallery-product-image-zoom').onmouseover = function() { if (orbitvu_zoom_responsive) { orbitvu_show_zoom(); } }
974
+ Orb$('orbitvu-gallery-product-image-zoom').onmouseout = function() { orbitvu_hide_zoom(); }
975
+ Orb$('orbitvu_go_next').onclick = function() { orbitvu_goNext(); }
976
+ Orb$('orbitvu_go_back').onclick = function() { orbitvu_goBack(); }
977
+
978
+ /*
979
+ * Calculate gallery dimensions
980
+ */
981
+ orbitvu_init_interval = setInterval('orbitvu_refresh()', 500);
982
+ orbitvu_recalculate();
983
+
984
+ /*
985
+ * Load 360 presentation and/or tour
986
+ */
987
+ <?php
988
+ if (!empty($view_360['path'])) {
989
+ ?>
990
+ if (typeof(orbitvu_360_interval) == 'undefined') {
991
+ orbitvu_360_interval = setInterval('orbitvu_inject_360()', 500);
992
+ }
993
+ else {
994
+ orbitvu_inject_360();
995
+ }
996
+ <?php
997
+ }
998
+ ?>
999
+
1000
+ <?php
1001
+ if (!empty($orbittour['path'])) {
1002
+ ?>
1003
+ if (typeof(orbitvu_tour_interval) == 'undefined') {
1004
+ orbitvu_tour_interval = setInterval('orbitvu_inject_tour()', 500);
1005
+ } else {
1006
+ orbitvu_inject_tour()
1007
+ }
1008
+ <?php
1009
+ }
1010
+ ?>
1011
+ }
1012
+
1013
+ /*
1014
+ * Synchronized actions
1015
+ */
1016
+ OrbitvuInit();
1017
+
1018
+ /*
1019
+ * Window events
1020
+ */
1021
+ window.onresize = function() {
1022
+ if (orbitvu_window_onresize_enabled) {
1023
+ if (window.innerWidth > orbitvu_window_before) orbitvu_window_growing = true;
1024
+ else orbitvu_window_growing = false;
1025
+
1026
+ orbitvu_init_gallery();
1027
+ orbitvu_recalculate();
1028
+ orbitvu_rewind();
1029
+ orbitvu_max_counter = 1;
1030
+
1031
+ orbitvu_window_before = window.innerWidth;
1032
+ }
1033
+ }
1034
+ window.onorientationchange = function() { window.onresize(); }
1035
+ </script>
1036
+ <?php
1037
+ }
1038
  ?>
app/etc/modules/Orbitvu_Sun.xml CHANGED
@@ -1,16 +1,16 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category Orbitvu
5
- * @package Orbitvu_Sun
6
- * @copyright Copyright (c) 2014 Orbitvu (http://www.orbitvu.com)
7
- */
8
- -->
9
- <config>
10
- <modules>
11
- <Orbitvu_Sun>
12
- <active>true</active>
13
- <codePool>community</codePool>
14
- </Orbitvu_Sun>
15
- </modules>
16
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Orbitvu
5
+ * @package Orbitvu_Sun
6
+ * @copyright Copyright (c) 2014 Orbitvu (http://www.orbitvu.com)
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Orbitvu_Sun>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ </Orbitvu_Sun>
15
+ </modules>
16
+ </config>
app/locale/en_US/Orbitvu_Sun.csv CHANGED
@@ -1,138 +1,138 @@
1
- Orbitvu,Orbitvu
2
- Error!,Error!
3
- OK,OK
4
- Your account was created!,Your account was created!
5
- Now you have your own account on Orbitvu SUN.<br />We sent your an email with details.,Orbitvu SUN account has been created for you.<br />Shortly you\'ll receive confirmation email.
6
- Your trial License Key was created and it\'s now in use.,Your trial License Key was created and it\'s now in use.
7
- Update your key,Update your key
8
- Contact Orbitvu,Contact Orbitvu
9
- License Key is not valid,License Key is not valid
10
- Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.,Your Orbitvu extension License Key is not valid. Please enter valid License Key. Orbitvu extension functionality is now limited.
11
- Orbitvu Extension Wizard,Orbitvu SUN Product Teleporting Extension Wizard
12
- "You need a <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use the extension.","You need a <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use the extension."
13
- Choose an option:,Choose an option:
14
- Enter License Key,Enter License Key
15
- Link Orbitvu SUN presentations to all products matched with SKU or name.,Link Orbitvu SUN presentations to all products matched with SKU or name.
16
- Link Orbitvu SUN presentations,Link Orbitvu SUN presentations
17
- Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?,Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?
18
- This operation will only be applied to not yet linked products.,This operation will only be applied to not yet linked products.
19
- Orbitvu Configuration,Orbitvu Configuration
20
- close,close
21
- Try extension with DEMO account,Try extension with DEMO account
22
- You get access to predefined set of 360&deg; presentations.,You get access to predefined set of 360&deg; presentations.
23
- Register Orbitvu SUN FREE trial account,Register Orbitvu SUN FREE trial account
24
- Create and customize your own presentations.,Create and customize your own presentations.
25
- Enter License Key,Enter License Key
26
- Connect to your Orbitvu SUN account.,Connect to your Orbitvu SUN account.
27
- Creating new account is free. Just enter your e-mail address,Creating new account is free. Just enter your e-mail address
28
- We will send you the password and generate trial License Key automaticaly.,We will send you the password and generate trial License Key automaticaly.
29
- Linked,Linked
30
- Orbittour,Orbittour
31
- 360&deg;,360&deg;
32
- 360°,360°
33
- 2D,2D
34
- Unlinked,Unlinked
35
- Not linked,Not linked
36
- No delay,No delay
37
- "0,1 second","0,1 second"
38
- "0,2 second","0,2 second"
39
- "0,3 second","0,3 second"
40
- "0,4 second","0,4 second"
41
- half a second,half a second
42
- Always use HTML5,Always use HTML5
43
- "Use Flash if available, otherwise use HTML5","Use Flash if available, otherwise use HTML5"
44
- "You need <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use Orbitvu extension.","You need <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use Orbitvu extension."
45
- Register,Register
46
- trial account or,trial account or
47
- use DEMO License Key,use DEMO License Key
48
- Views to the right,Views to the right
49
- Views at the bottom,Views at the bottom
50
- No views,No views
51
- Use Orbitvu SUN setting,Use Orbitvu SUN setting
52
- "Enable, if remote SKU is empty","Enable, if remote SKU is empty"
53
- Auto-rotation,Auto-rotation
54
- Play button enables rotation,Play button enables rotation
55
- No teaser (static presentation),No teaser (static presentation)
56
- Quick single rotation (make sense only if 360 presentation is your first gallery item),Quick single rotation (makes sense only if 360 presentation is your first gallery item)
57
- Slow single rotation (make sense only if 360 presentation is your first gallery item),Slow single rotation (makes sense only if 360 presentation is your first gallery item)
58
- Use Orbitvu SUN setting,Use Orbitvu SUN setting
59
- Orbitvu SUN Synchronization,Orbitvu SUN Synchronization
60
- Orbitvu SUN connection settings,Orbitvu SUN connection settings
61
- License Key,License Key
62
- Orbitvu SUN integration,Orbitvu SUN integration
63
- Link Orbitvu SUN presentations to products automatically,Link Orbitvu SUN presentations to products automatically
64
- Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.,Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.
65
- Update presentation SKU on Orbitvu SUN automatically,Automatically update presentation SKU on Orbitvu SUN
66
- Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.,Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.
67
- Select what type of presentation content will be visible in store by default,Select what type of presentation content will be visible in store by default
68
- Product view - gallery behavior,Product view - gallery behavior
69
- Mouse over mode,Mouse over mode
70
- Change presentation items in gallery with just mouse over instead of click.,Change presentation items in gallery with just mouse over instead of click.
71
- 360° Presentation teaser,360° Presentation teaser
72
- HTML5 or Flash mode,HTML5 or Flash mode
73
- Orbittour views visibility,Orbittour views visibility
74
- Product view - gallery layout (edit only if you know what are you doing!),Product view - gallery layout (edit only if you know what you are doing!)
75
- Gallery width,Gallery width
76
- Enter <strong>100%</strong> if you wan't to have responsive gallery layout (recommended),Enter <strong>100%</strong> if you want to have responsive gallery layout (recommended)
77
- Gallery preview maximum width,Gallery maximum width
78
- Recommended: Your layout proportion to gallery preview maximum height eg. <strong>600px</strong>,Recommended: Your layout proportion to gallery maximum height eg. <strong>600px</strong>
79
- Gallery preview maximum height,Gallery maximum height
80
- Recommended: <strong>300px</strong>,Recommended: <strong>300px</strong>
81
- Gallery border color,Gallery border color
82
- Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders,Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders
83
- Internal zoom image width,Internal zoom image width
84
- Recommended: <strong>1024px</strong>,Recommended: <strong>1024px</strong>
85
- Internal zoom image height,Internal zoom image height
86
- Recommended: <strong>768px</strong>,Recommended: <strong>768px</strong>
87
- Thumbnail width,Thumbnail width
88
- Recommended: <strong>75px</strong>,Recommended: <strong>75px</strong>
89
- Thumbnail height,Thumbnail height
90
- Recommended: <strong>50px</strong>,Recommended: <strong>50px</strong>
91
- Thumbnail margin,Thumbnail margin
92
- Recommended: <strong>3px</strong>,Recommended: <strong>3px</strong>
93
- Button prev/next width,Button prev/next width
94
- Recommended: <strong>30px</strong>,Recommended: <strong>30px</strong>
95
- Button prev/next height,Button prev/next height
96
- Recommended: <strong>53px</strong>,Recommended: <strong>53px</strong>
97
- Button prev/next opacity,Button prev/next opacity
98
- "1 = 100% (recommended), 0.5 = 50%, 0 = 0%","1 = 100% (recommended), 0.5 = 50%, 0 = 0%"
99
- SKU,SKU
100
- One of your presentations already has this SKU assigned. SKU need to be unique. Modify SKU on your SUN Server and try again.,This SKU is already in use by one of Orbitvu SUN presentations. Modify SKU on Orbitvu SUN and try again.
101
- Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.,Your Orbitvu extension License Key is not valid. Please enter valid License Key. Orbitvu extension functionality is now limited.
102
- Update your key,Update your License Key
103
- Orbitvu extension is connected to DEMO account. Register Orbitvu SUN FREE trial account to create your own presentations.,Orbitvu extension uses DEMO account License Key. Register Orbitvu SUN FREE trial account to create your own presentations.
104
- Get free trial,Get free trial
105
- Version,Version
106
- of Orbitvu extension is out!,of Orbitvu extension is out!
107
- Upgrade now from,Upgrade now from
108
- to,to
109
- Your presentation has been unlinked. You can select a new one below.,Your presentation has been unlinked. You can select a new one below.
110
- We used your product\'s SKU:,We used your product\'s SKU:
111
- and name:,and name:
112
- to match one of your SUN presentations.,to match one of your Orbitvu SUN presentations.
113
- Link this presentation,Link this presentation
114
- Select another one,Select another one
115
- Confirm linking matched presentation,Confirm linking matched presentation
116
- Select presentation from your Orbitvu SUN account to link with product,Select presentation from your Orbitvu SUN account to link with product
117
- Page:,Page:
118
- of,of
119
- Per page:,Per page:
120
- Total:,Total:
121
- Date,Date
122
- Name,Name
123
- Enter presentation name or SKU...,Enter presentation name or SKU...
124
- Search,Search
125
- Reset,Reset
126
- Do you really want to link this presentation with current product?,Do you really want to link this presentation with current product?
127
- Orbitvu SUN presentation linked to current product,Orbitvu SUN presentation linked to current product
128
- o you really want to update this presentation SKU on your Orbitvu SUN account?,Do you really want to update this presentation SKU on Orbitvu SUN?
129
- Product\'s SKU:,Product\'s SKU:
130
- . Presentation\'s SKU from Orbitvu SUN:,. Presentation\'s SKU from Orbitvu SUN:
131
- "Click ""Update SKU on SUN"" button below to update your presentation\'s SKU on Orbitvu SUN with:","Click ""Update SKU on SUN"" button below to update your presentation\'s SKU on Orbitvu SUN with:"
132
- We can\'t change your SUN Presentation SKU. One of your presentations already has this product SKU assigned. SKU need to be unique. Modify SKU on your SUN Server.,We can\'t change your Orbitvu SUN Presentation SKU because it is already in use by another presentation. SKU needs to be unique. Modify Presentation SKU on Orbitvu SUN Server to resolve the problem.
133
- Do you really want to unlink this presentation?,Do you really want to unlink this presentation?
134
- Unlink this presentation,Unlink this presentation
135
- Edit on SUN,Edit on SUN
136
- Drag &amp; move item,Drag &amp; move item
137
- Hide item,Hide item
138
- Show item,Show item
1
+ Orbitvu,Orbitvu
2
+ Error!,Error!
3
+ OK,OK
4
+ Your account was created!,Your account was created!
5
+ Now you have your own account on Orbitvu SUN.<br />We sent your an email with details.,Orbitvu SUN account has been created for you.<br />Shortly you\'ll receive confirmation email.
6
+ Your trial License Key was created and it\'s now in use.,Your trial License Key was created and it\'s now in use.
7
+ Update your key,Update your key
8
+ Contact Orbitvu,Contact Orbitvu
9
+ License Key is not valid,License Key is not valid
10
+ Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.,Your Orbitvu extension License Key is not valid. Please enter valid License Key. Orbitvu extension functionality is now limited.
11
+ Orbitvu Extension Wizard,Orbitvu SUN Product Teleporting Extension Wizard
12
+ "You need a <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use the extension.","You need a <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use the extension."
13
+ Choose an option:,Choose an option:
14
+ Enter License Key,Enter License Key
15
+ Link Orbitvu SUN presentations to all products matched with SKU or name.,Link Orbitvu SUN presentations to all products matched with SKU or name.
16
+ Link Orbitvu SUN presentations,Link Orbitvu SUN presentations
17
+ Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?,Do you really want to link Orbitvu SUN presentations to all products matched with SKU or name?
18
+ This operation will only be applied to not yet linked products.,This operation will only be applied to not yet linked products.
19
+ Orbitvu Configuration,Orbitvu Configuration
20
+ close,close
21
+ Try extension with DEMO account,Try extension with DEMO account
22
+ You get access to predefined set of 360&deg; presentations.,You get access to predefined set of 360&deg; presentations.
23
+ Register Orbitvu SUN FREE trial account,Register Orbitvu SUN FREE trial account
24
+ Create and customize your own presentations.,Create and customize your own presentations.
25
+ Enter License Key,Enter License Key
26
+ Connect to your Orbitvu SUN account.,Connect to your Orbitvu SUN account.
27
+ Creating new account is free. Just enter your e-mail address,Creating new account is free. Just enter your e-mail address
28
+ We will send you the password and generate trial License Key automaticaly.,We will send you the password and generate trial License Key automaticaly.
29
+ Linked,Linked
30
+ Orbittour,Orbittour
31
+ 360&deg;,360&deg;
32
+ 360°,360°
33
+ 2D,2D
34
+ Unlinked,Unlinked
35
+ Not linked,Not linked
36
+ No delay,No delay
37
+ "0,1 second","0,1 second"
38
+ "0,2 second","0,2 second"
39
+ "0,3 second","0,3 second"
40
+ "0,4 second","0,4 second"
41
+ half a second,half a second
42
+ Always use HTML5,Always use HTML5
43
+ "Use Flash if available, otherwise use HTML5","Use Flash if available, otherwise use HTML5"
44
+ "You need <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use Orbitvu extension.","You need <a href=""http://orbitvu.co"" target=""_blank"">Orbitvu SUN</a> account and License Key to use Orbitvu extension."
45
+ Register,Register
46
+ trial account or,trial account or
47
+ use DEMO License Key,use DEMO License Key
48
+ Views to the right,Views to the right
49
+ Views at the bottom,Views at the bottom
50
+ No views,No views
51
+ Use Orbitvu SUN setting,Use Orbitvu SUN setting
52
+ "Enable, if remote SKU is empty","Enable, if remote SKU is empty"
53
+ Auto-rotation,Auto-rotation
54
+ Play button enables rotation,Play button enables rotation
55
+ No teaser (static presentation),No teaser (static presentation)
56
+ Quick single rotation (make sense only if 360 presentation is your first gallery item),Quick single rotation (makes sense only if 360 presentation is your first gallery item)
57
+ Slow single rotation (make sense only if 360 presentation is your first gallery item),Slow single rotation (makes sense only if 360 presentation is your first gallery item)
58
+ Use Orbitvu SUN setting,Use Orbitvu SUN setting
59
+ Orbitvu SUN Synchronization,Orbitvu SUN Synchronization
60
+ Orbitvu SUN connection settings,Orbitvu SUN connection settings
61
+ License Key,License Key
62
+ Orbitvu SUN integration,Orbitvu SUN integration
63
+ Link Orbitvu SUN presentations to products automatically,Link Orbitvu SUN presentations to products automatically
64
+ Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.,Matching (by SKU or name) Orbitvu SUN presentation will be linked to new products immediately. Once a day we will check for changes at Orbitvu SUN and link matching presentations to products.
65
+ Update presentation SKU on Orbitvu SUN automatically,Automatically update presentation SKU on Orbitvu SUN
66
+ Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.,Automatically update empty Presentation's SKU on Orbitvu SUN server when such Presentation is linked to Product.
67
+ Select what type of presentation content will be visible in store by default,Select what type of presentation content will be visible in store by default
68
+ Product view - gallery behavior,Product view - gallery behavior
69
+ Mouse over mode,Mouse over mode
70
+ Change presentation items in gallery with just mouse over instead of click.,Change presentation items in gallery with just mouse over instead of click.
71
+ 360° Presentation teaser,360° Presentation teaser
72
+ HTML5 or Flash mode,HTML5 or Flash mode
73
+ Orbittour views visibility,Orbittour views visibility
74
+ Product view - gallery layout (edit only if you know what are you doing!),Product view - gallery layout (edit only if you know what you are doing!)
75
+ Gallery width,Gallery width
76
+ Enter <strong>100%</strong> if you wan't to have responsive gallery layout (recommended),Enter <strong>100%</strong> if you want to have responsive gallery layout (recommended)
77
+ Gallery preview maximum width,Gallery maximum width
78
+ Recommended: Your layout proportion to gallery preview maximum height eg. <strong>600px</strong>,Recommended: Your layout proportion to gallery maximum height eg. <strong>600px</strong>
79
+ Gallery preview maximum height,Gallery maximum height
80
+ Recommended: <strong>300px</strong>,Recommended: <strong>300px</strong>
81
+ Gallery border color,Gallery border color
82
+ Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders,Recommended: <strong>#ccc</strong><br />Enter <strong>transparent</strong> if you don't want borders
83
+ Internal zoom image width,Internal zoom image width
84
+ Recommended: <strong>1024px</strong>,Recommended: <strong>1024px</strong>
85
+ Internal zoom image height,Internal zoom image height
86
+ Recommended: <strong>768px</strong>,Recommended: <strong>768px</strong>
87
+ Thumbnail width,Thumbnail width
88
+ Recommended: <strong>75px</strong>,Recommended: <strong>75px</strong>
89
+ Thumbnail height,Thumbnail height
90
+ Recommended: <strong>50px</strong>,Recommended: <strong>50px</strong>
91
+ Thumbnail margin,Thumbnail margin
92
+ Recommended: <strong>3px</strong>,Recommended: <strong>3px</strong>
93
+ Button prev/next width,Button prev/next width
94
+ Recommended: <strong>30px</strong>,Recommended: <strong>30px</strong>
95
+ Button prev/next height,Button prev/next height
96
+ Recommended: <strong>53px</strong>,Recommended: <strong>53px</strong>
97
+ Button prev/next opacity,Button prev/next opacity
98
+ "1 = 100% (recommended), 0.5 = 50%, 0 = 0%","1 = 100% (recommended), 0.5 = 50%, 0 = 0%"
99
+ SKU,SKU
100
+ One of your presentations already has this SKU assigned. SKU need to be unique. Modify SKU on your SUN Server and try again.,This SKU is already in use by one of Orbitvu SUN presentations. Modify SKU on Orbitvu SUN and try again.
101
+ Your Orbitvu extension License Key is not valid. Please update your Key. Orbitvu extension functionality is now limited.,Your Orbitvu extension License Key is not valid. Please enter valid License Key. Orbitvu extension functionality is now limited.
102
+ Update your key,Update your License Key
103
+ Orbitvu extension is connected to DEMO account. Register Orbitvu SUN FREE trial account to create your own presentations.,Orbitvu extension uses DEMO account License Key. Register Orbitvu SUN FREE trial account to create your own presentations.
104
+ Get free trial,Get free trial
105
+ Version,Version
106
+ of Orbitvu extension is out!,of Orbitvu extension is out!
107
+ Upgrade now from,Upgrade now from
108
+ to,to
109
+ Your presentation has been unlinked. You can select a new one below.,Your presentation has been unlinked. You can select a new one below.
110
+ We used your product\'s SKU:,We used your product\'s SKU:
111
+ and name:,and name:
112
+ to match one of your SUN presentations.,to match one of your Orbitvu SUN presentations.
113
+ Link this presentation,Link this presentation
114
+ Select another one,Select another one
115
+ Confirm linking matched presentation,Confirm linking matched presentation
116
+ Select presentation from your Orbitvu SUN account to link with product,Select presentation from your Orbitvu SUN account to link with product
117
+ Page:,Page:
118
+ of,of
119
+ Per page:,Per page:
120
+ Total:,Total:
121
+ Date,Date
122
+ Name,Name
123
+ Enter presentation name or SKU...,Enter presentation name or SKU...
124
+ Search,Search
125
+ Reset,Reset
126
+ Do you really want to link this presentation with current product?,Do you really want to link this presentation with current product?
127
+ Orbitvu SUN presentation linked to current product,Orbitvu SUN presentation linked to current product
128
+ o you really want to update this presentation SKU on your Orbitvu SUN account?,Do you really want to update this presentation SKU on Orbitvu SUN?
129
+ Product\'s SKU:,Product\'s SKU:
130
+ . Presentation\'s SKU from Orbitvu SUN:,. Presentation\'s SKU from Orbitvu SUN:
131
+ "Click ""Update SKU on SUN"" button below to update your presentation\'s SKU on Orbitvu SUN with:","Click ""Update SKU on SUN"" button below to update your presentation\'s SKU on Orbitvu SUN with:"
132
+ We can\'t change your SUN Presentation SKU. One of your presentations already has this product SKU assigned. SKU need to be unique. Modify SKU on your SUN Server.,We can\'t change your Orbitvu SUN Presentation SKU because it is already in use by another presentation. SKU needs to be unique. Modify Presentation SKU on Orbitvu SUN Server to resolve the problem.
133
+ Do you really want to unlink this presentation?,Do you really want to unlink this presentation?
134
+ Unlink this presentation,Unlink this presentation
135
+ Edit on SUN,Edit on SUN
136
+ Drag &amp; move item,Drag &amp; move item
137
+ Hide item,Hide item
138
+ Show item,Show item
crossdomain.xml CHANGED
@@ -1,4 +1,4 @@
1
- <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
2
- <cross-domain-policy>
3
- <allow-access-from domain="*" secure="false"/>
4
  </cross-domain-policy>
1
+ <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
2
+ <cross-domain-policy>
3
+ <allow-access-from domain="*" secure="false"/>
4
  </cross-domain-policy>
package.xml CHANGED
@@ -1,18 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Orbitvu_Sun</name>
4
- <version>1.0.11</version>
5
  <stability>stable</stability>
6
  <license>Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automate and improve your customer's expierience with dynamic zoom, 360&#xB0;/3D spins, product tours using ORBITVU imaging solution.</summary>
10
  <description>Orbitvu SUN Product Teleporting extension will improve your store product experience with interactive product tours, 360&#xB0;/3D image spins and dynamic zoom on desktop and mobile. It will automate and facilitate your imaging workflow as never before. This extension is provided by ORBITVU &#x2013; the global leader for automated imaging solutions.</description>
11
- <notes>-fixed gallery thumbnails scroll when orientation screen changed</notes>
 
 
 
12
  <authors><author><name>Orbitvu</name><user>dev</user><email>dev@orbitvu.com</email></author></authors>
13
- <date>2015-09-30</date>
14
- <time>11:46:21</time>
15
- <contents><target name="magecommunity"><dir name="Orbitvu"><dir name="Sun"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Grid.php" hash="7400726bd8c37d56465cf19557c44b60"/><file name="Gridrenderer.php" hash="5faf1727cec7245a8da6d60e5d7d8e0f"/></dir></dir><dir name="Tabs"><file name="Tabid.php" hash="fcbed1fa070be0ca4838eb52a16d07ca"/></dir><file name="Tabs.php" hash="71403fb00d7ac0b46ea7fdce66ad55af"/></dir><file name="Delay.php" hash="035d8fca636cce61d33f08200725a5f1"/><file name="Html5.php" hash="208cecc71503046beefa9c02579a8263"/><file name="KeyComment.php" hash="a55dd2bfd936cbf687ed62c9bb163a26"/><file name="Orbittour.php" hash="727eccc98132ca01bd6e83ea8c7b6588"/><dir name="Product"><dir name="View"><file name="Media.php" hash="5f5b110f4b5330e9fd3bd6723eb49d92"/></dir></dir><file name="Scroll.php" hash="6c1413ee3054f871fc5ea989361dad13"/><file name="Syncsku.php" hash="495ac1a5f3a3d8409b1a66f2ca62c40b"/><file name="Teaser.php" hash="8e4070b43b663badab737921742821d7"/></dir><dir name="Helper"><file name="Data.php" hash="2f37cfd7929d5c930af1a1023602bb0d"/></dir><dir name="Model"><file name="Observer.php" hash="1e2693537a0671f5ea9db833076e3742"/><dir name="Resource"><file name="Setup.php" hash="f34f2bf697d3b554f2f90453a9f9203c"/><file name="Sun.php" hash="9fdb47d4318346d2f506e246f37ed0cc"/></dir></dir><dir name="controllers"><file name="OrbitvuAdmin.php" hash="c5eb73bd5b5d01f1f0a477a119f9aa9c"/><file name="OrbitvuConnect.php" hash="2571b84f443fb7d4c3af36f13c5b1ce3"/><file name="OrbitvuDatabaseDriver.php" hash="407d3bdd621bc69b97cbc44f75331ca4"/><file name="OrbitvuDatabaseInterface.php" hash="50775a50ed68e0a266f1fc1e1f2202cc"/><file name="OrbitvuDebugger.php" hash="2a1dd59fa2512a1ce877c5b9b1f8819d"/><file name="OrbitvuTests.php" hash="cdeeeaba1fd5b70ecfaea03e8718cd66"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1e4bf9feb4a3fda1d037eac942357cfc"/><file name="config.xml" hash="b35ddd6f68ebbad6f6c899767d106f6e"/><file name="local.xml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="system.xml" hash="a1955dd0392f17ad7fc8f57f699e183d"/><file name="translations.xml" hash="f27262b561cacd1a2fb1a1e56e0e8946"/></dir><dir name="sql"><dir name="sun_setup"><file name="mysql4-install-1.0.0.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.1.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.10.php" hash="9373e4eeaedb93cdad12a07964d88200"/><file name="mysql4-install-1.0.2.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.3.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.4.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.5.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.6.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.7.php" hash="36faff7b2a28f322aee73d2180632fdd"/><file name="mysql4-install-1.0.8.php" hash="9373e4eeaedb93cdad12a07964d88200"/><file name="mysql4-install-1.0.9.php" hash="9373e4eeaedb93cdad12a07964d88200"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="c06d3cbe9dc35d61e7bc6fdd202c68e7"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="c06d3cbe9dc35d61e7bc6fdd202c68e7"/><file name="mysql4-upgrade-1.0.10-1.0.11.php" hash="8a1a419119da4fb35e18df5337de1c20"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="c06d3cbe9dc35d61e7bc6fdd202c68e7"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="c06d3cbe9dc35d61e7bc6fdd202c68e7"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="c06d3cbe9dc35d61e7bc6fdd202c68e7"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="a2204f7a4d7fcf05e309614d04318084"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="8a1a419119da4fb35e18df5337de1c20"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="8a1a419119da4fb35e18df5337de1c20"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="8a1a419119da4fb35e18df5337de1c20"/><file name="mysql4-upgrade-1.0.9-1.0.10.php" hash="8a1a419119da4fb35e18df5337de1c20"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sun"><file name="orbitvu.phtml" hash="5e8dc45a3a64c1b34c3769f9d6d28d4f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sun.xml" hash="ea7cdb4f7d88f32f1872c3f975be5345"/></dir><dir name="template"><dir name="orbitvu"><dir name="product"><dir name="view"><file name="media.phtml" hash="a96957419dd0fa55e0d365ca501cbc45"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="orbitvu"><file name="black.png" hash="64dcb45b20e5e2e0cc07c62a843f8f68"/><file name="blue.png" hash="fa8b00e52ec0bf7cb9937b1d5789740c"/><file name="loader.gif" hash="875eec6b429c57e0eff9ba7c182072cd"/><file name="logo.png" hash="622ada057aadbe23af717431e85ef94f"/><file name="orbit.png" hash="c390d8598792d9cc86b19e9afef0ea4a"/><file name="placeholder.png" hash="43b6e81dc733e7d8fb279e54b5f39b3f"/><dir><dir name="thumbnails"><file name="index" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="white.png" hash="ff7713f7b45a4b7a4b5d8304eb3c655c"/></dir></target><target name="mage"><dir name="."><file name="crossdomain.xml" hash="3d73360d10233f48441db7ed045c3952"/><file name="ORBITVU-SUN-PRODUCT-TELEPORTING-EN.pdf" hash="069f8c15618e9ffe28dfc1e1efb6adf8"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Orbitvu_Sun.csv" hash="a60459310ed2b1e93062eae927b71979"/></dir></target><target name="mageetc"><dir name="modules"><file name="Orbitvu_Sun.xml" hash="04b339680876cb29b6c59758cfed3b8a"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Orbitvu_Sun</name>
4
+ <version>1.0.12</version>
5
  <stability>stable</stability>
6
  <license>Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automate and improve your customer's expierience with dynamic zoom, 360&#xB0;/3D spins, product tours using ORBITVU imaging solution.</summary>
10
  <description>Orbitvu SUN Product Teleporting extension will improve your store product experience with interactive product tours, 360&#xB0;/3D image spins and dynamic zoom on desktop and mobile. It will automate and facilitate your imaging workflow as never before. This extension is provided by ORBITVU &#x2013; the global leader for automated imaging solutions.</description>
11
+ <notes>-Added thumbnail assign to the associated (child) products of configurable product&#xD;
12
+ -Fixed many notices and warnings&#xD;
13
+ -Increased connect timeout to sun server&#xD;
14
+ -Fixed thumbnail deletion</notes>
15
  <authors><author><name>Orbitvu</name><user>dev</user><email>dev@orbitvu.com</email></author></authors>
16
+ <date>2015-10-16</date>
17
+ <time>12:45:54</time>
18
+ <contents><target name="magecommunity"><dir name="Orbitvu"><dir name="Sun"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Grid.php" hash="c12a6f672ceb379b9633a328e4fe499c"/><file name="Gridrenderer.php" hash="b86affaf935201508bb02e4b8975c988"/></dir></dir><dir name="Tabs"><file name="Tabid.php" hash="b90c1cac87797ebf579b7ebe694e53d3"/></dir><file name="Tabs.php" hash="cfa2df401d503f300f615d979f8eeab5"/></dir><file name="Delay.php" hash="570f327292c20cfc3e2ec5faf0687116"/><file name="Html5.php" hash="b7a6020751d85af690eed068a0f5eaf8"/><file name="KeyComment.php" hash="3a832bb181f1e709d5cf4bba4f55338f"/><file name="Orbittour.php" hash="f9d6c22b7c37b58771119dc2af3f0b00"/><dir name="Product"><dir name="View"><file name="Media.php" hash="d6c5268510a19afcd3ef273634913373"/></dir></dir><file name="Scroll.php" hash="f54d18dfb2445ae147746071527e56e4"/><file name="Syncsku.php" hash="dd57437599190a466d9ccf3ec8d47890"/><file name="Teaser.php" hash="f67f531671bcad679b433d7635236a35"/></dir><dir name="Helper"><file name="Data.php" hash="24762472300a32b09082a45d15959fc1"/></dir><dir name="Model"><file name="Observer.php" hash="0a684163858a6f72a54b9d32b88bbed2"/><dir name="Resource"><file name="Setup.php" hash="2cfd8dccd322e056cb4816e697bd9efd"/><file name="Sun.php" hash="8322d1a43b6aee941dc297bf31253504"/></dir></dir><dir name="controllers"><file name="OrbitvuAdmin.php" hash="3665e28d7022a064913395ee118a6561"/><file name="OrbitvuConnect.php" hash="047a5525761549f88fbca093668124db"/><file name="OrbitvuDatabaseDriver.php" hash="fcc50fd3a15be373f275f9caee942246"/><file name="OrbitvuDatabaseInterface.php" hash="cae8470ed463903bb62389dc948f51c4"/><file name="OrbitvuDebugger.php" hash="b77202848b43fbc7861845f352ab3239"/><file name="OrbitvuTests.php" hash="dde56bcf50d16cf7613a4e3ae4093a30"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ff6ac1784a5e92f6937411bebdea2811"/><file name="config.xml" hash="0f9126854fab9798c120e03ca7d3d508"/><file name="local.xml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="system.xml" hash="033e55c2f9b1070461343de1b715ee96"/><file name="translations.xml" hash="47ff4445ef63971e669c5f34cd2376fb"/></dir><dir name="sql"><dir name="sun_setup"><file name="mysql4-install-1.0.0.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.1.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.10.php" hash="502629e7f477aae069d913afd1541325"/><file name="mysql4-install-1.0.2.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.3.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.4.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.5.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.6.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.7.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.8.php" hash="502629e7f477aae069d913afd1541325"/><file name="mysql4-install-1.0.9.php" hash="502629e7f477aae069d913afd1541325"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.10-1.0.11.php" hash="968a1b44e87d5e34a26a59b862e6baed"/><file name="mysql4-upgrade-1.0.11-1.0.12.php" hash="968a1b44e87d5e34a26a59b862e6baed"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="0707469d392c0552614b875e1a1cb13e"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="968a1b44e87d5e34a26a59b862e6baed"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="968a1b44e87d5e34a26a59b862e6baed"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="968a1b44e87d5e34a26a59b862e6baed"/><file name="mysql4-upgrade-1.0.9-1.0.10.php" hash="968a1b44e87d5e34a26a59b862e6baed"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sun"><file name="orbitvu.phtml" hash="9609c61706a40e1133b5707e6f4c8f2e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sun.xml" hash="08f04468f5e883345cad2e6f5f9c4666"/></dir><dir name="template"><dir name="orbitvu"><dir name="product"><dir name="view"><file name="media.phtml" hash="42849d3d6bc90abecab8296eac61cf6c"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="orbitvu"><file name="black.png" hash="64dcb45b20e5e2e0cc07c62a843f8f68"/><file name="blue.png" hash="fa8b00e52ec0bf7cb9937b1d5789740c"/><file name="loader.gif" hash="875eec6b429c57e0eff9ba7c182072cd"/><file name="logo.png" hash="622ada057aadbe23af717431e85ef94f"/><file name="orbit.png" hash="c390d8598792d9cc86b19e9afef0ea4a"/><file name="placeholder.png" hash="43b6e81dc733e7d8fb279e54b5f39b3f"/><dir><dir name="thumbnails"><file name="index" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="white.png" hash="ff7713f7b45a4b7a4b5d8304eb3c655c"/></dir></target><target name="mage"><dir name="."><file name="crossdomain.xml" hash="6960cde6dd98feb5406c6b185521b041"/><file name="ORBITVU-SUN-PRODUCT-TELEPORTING-EN.pdf" hash="069f8c15618e9ffe28dfc1e1efb6adf8"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Orbitvu_Sun.csv" hash="7c5ea48271819e56b9253d2660012728"/></dir></target><target name="mageetc"><dir name="modules"><file name="Orbitvu_Sun.xml" hash="76f32cd06e5fb1aa4eda72a34c010d99"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>