Version Notes
Fixed:
- Pop-up window (wizard),
- Skin paths.
Download this release
Release Info
| Developer | Développeurs EnvoiMoinsCher.com |
| Extension | Orbitvu_Sun |
| Version | 1.0.4 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.3 to 1.0.4
- app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Grid.php +7 -6
- app/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php +430 -1
- app/code/community/Orbitvu/Sun/controllers/OrbitvuConnect.php +620 -110
- app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseInterface.php +651 -65
- app/code/community/Orbitvu/Sun/etc/config.xml +1 -1
- app/design/adminhtml/default/default/template/sun/orbitvu.phtml +4 -4
- app/design/frontend/base/default/template/orbitvu/product/view/media.phtml +1 -1
- package.xml +6 -5
app/code/community/Orbitvu/Sun/Block/Adminhtml/Catalog/Product/Grid.php
CHANGED
|
@@ -61,15 +61,15 @@ class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Bl
|
|
| 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($
|
| 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($
|
| 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($
|
| 73 |
|
| 74 |
$display_first_time = true;
|
| 75 |
//------------------------------------------------------------------------------------------------------------------
|
|
@@ -253,6 +253,7 @@ class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Bl
|
|
| 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 |
$out = '
|
| 257 |
<script type="text/javascript">
|
| 258 |
//<![CDATA[
|
|
@@ -348,8 +349,8 @@ class Orbitvu_Sun_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Bl
|
|
| 348 |
<form action="'.$this->getUrl('*/catalog_product/index/sun/register').'" method="get">
|
| 349 |
<div class="message-text" style="min-height: 1px; padding: 10px 0 10px 0;">
|
| 350 |
<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').'" />
|
| 351 |
-
<button type="submit" class="scalable orbitvu-button">Register</button>
|
| 352 |
-
<button type="button" onclick="document.getElementById(\'orbitvu_options\').style.display = \'block\'; document.getElementById(\'orbitvu_html_register\').style.display = \'none\';" class="scalable back">Cancel</button>
|
| 353 |
</div>
|
| 354 |
</form>
|
| 355 |
</div>
|
| 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 |
//------------------------------------------------------------------------------------------------------------------
|
| 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[
|
| 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>
|
app/code/community/Orbitvu/Sun/controllers/OrbitvuAdmin.php
CHANGED
|
@@ -29,6 +29,12 @@ final class OrbitvuAdmin {
|
|
| 29 |
* @var instance
|
| 30 |
*/
|
| 31 |
public $Connect;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
/**
|
| 34 |
* Include all classes
|
|
@@ -57,11 +63,34 @@ final class OrbitvuAdmin {
|
|
| 57 |
}
|
| 58 |
$this->Connect->ViewerPath = $this->Config->viewers_path;
|
| 59 |
$this->Connect->DownloadPath = $this->Config->temp_path;
|
|
|
|
| 60 |
//-------------------------------------------------------------------------------------------------------
|
| 61 |
$this->driver->SetSUNConnection($this->Connect);
|
| 62 |
//-------------------------------------------------------------------------------------------------------
|
| 63 |
}
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
/**
|
| 66 |
* Own simple, template parser.
|
| 67 |
* Usign every store script template engine doesn't make practical sense.
|
|
@@ -91,7 +120,7 @@ final class OrbitvuAdmin {
|
|
| 91 |
//-------------------------------------------------------------------------------------------------------
|
| 92 |
$account = $this->Connect->CreateAccount($email);
|
| 93 |
|
| 94 |
-
$this->
|
| 95 |
//-------------------------------------------------------------------------------------------------------
|
| 96 |
return $account;
|
| 97 |
//-------------------------------------------------------------------------------------------------------
|
|
@@ -108,6 +137,366 @@ final class OrbitvuAdmin {
|
|
| 108 |
//-------------------------------------------------------------------------------------------------------
|
| 109 |
}
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
/**
|
| 112 |
* Set extension access token to default
|
| 113 |
* @return boolean
|
|
@@ -250,6 +639,16 @@ final class OrbitvuAdmin {
|
|
| 250 |
$this->driver->SetConfigurationParent($var, $value);
|
| 251 |
//-------------------------------------------------------------------------------------------------------
|
| 252 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
/**
|
| 255 |
* Use UpdateConfiguration if you want to update store configuration too
|
|
@@ -441,6 +840,36 @@ final class OrbitvuAdmin {
|
|
| 441 |
//-------------------------------------------------------------------------------------------------------
|
| 442 |
}
|
| 443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
/**
|
| 445 |
* Install database tables
|
| 446 |
* @return boolean
|
| 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
|
| 63 |
}
|
| 64 |
$this->Connect->ViewerPath = $this->Config->viewers_path;
|
| 65 |
$this->Connect->DownloadPath = $this->Config->temp_path;
|
| 66 |
+
$this->Connect->PresentationsPath = $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.
|
| 120 |
//-------------------------------------------------------------------------------------------------------
|
| 121 |
$account = $this->Connect->CreateAccount($email);
|
| 122 |
|
| 123 |
+
$this->UpdateConfiguration('access_token', $account->key);
|
| 124 |
//-------------------------------------------------------------------------------------------------------
|
| 125 |
return $account;
|
| 126 |
//-------------------------------------------------------------------------------------------------------
|
| 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('&', '&', $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
|
| 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
|
| 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
|
app/code/community/Orbitvu/Sun/controllers/OrbitvuConnect.php
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Orbitvu PHP Orbitvu eCommerce SUN
|
| 4 |
-
* @
|
|
|
|
| 5 |
*/
|
| 6 |
|
| 7 |
final class Orbitvu {
|
|
@@ -54,6 +55,12 @@ final class Orbitvu {
|
|
| 54 |
* @var string
|
| 55 |
*/
|
| 56 |
private $demo_access_token = '1567f2b4a02a8bfc5d8aacf0f44b16157e149d29';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Viewers path
|
|
@@ -67,10 +74,13 @@ final class Orbitvu {
|
|
| 67 |
* @var string
|
| 68 |
*/
|
| 69 |
public $DownloadPath = 'tmp/';
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
*
|
|
|
|
| 73 |
*/
|
|
|
|
|
|
|
| 74 |
/**
|
| 75 |
* Let's do the magic
|
| 76 |
* @param string $access_token License Key
|
|
@@ -116,26 +126,6 @@ final class Orbitvu {
|
|
| 116 |
$this->curl_version = $v;
|
| 117 |
//-------------------------------------------------------------------------------------------------------
|
| 118 |
}
|
| 119 |
-
|
| 120 |
-
/**
|
| 121 |
-
* Check if we are connected
|
| 122 |
-
* Also, get updates info if available
|
| 123 |
-
* @return boolean
|
| 124 |
-
*/
|
| 125 |
-
public function IsConnected() {
|
| 126 |
-
//---------------------------------------------------------------------------------------------------
|
| 127 |
-
$get = $this->CallSUN('plugins/versions/latest', '', false, true);
|
| 128 |
-
//-------------------------------------------------------------------------------------------------------
|
| 129 |
-
$this->plugin_available_version = $get->version;
|
| 130 |
-
$this->plugin_support = $get->support;
|
| 131 |
-
|
| 132 |
-
if ($get->error) {
|
| 133 |
-
return false;
|
| 134 |
-
}
|
| 135 |
-
//-------------------------------------------------------------------------------------------------------
|
| 136 |
-
return true;
|
| 137 |
-
//---------------------------------------------------------------------------------------------------
|
| 138 |
-
}
|
| 139 |
|
| 140 |
/**
|
| 141 |
* Get the demo access token
|
|
@@ -153,7 +143,7 @@ final class Orbitvu {
|
|
| 153 |
*/
|
| 154 |
public function IsDemo() {
|
| 155 |
//-------------------------------------------------------------------------------------------------------
|
| 156 |
-
if ($this->access_token == $this->GetDemoAccessToken()) {
|
| 157 |
//-------------------------------------------------------------------------------------------------------
|
| 158 |
return true;
|
| 159 |
//-------------------------------------------------------------------------------------------------------
|
|
@@ -162,83 +152,6 @@ final class Orbitvu {
|
|
| 162 |
return false;
|
| 163 |
//-------------------------------------------------------------------------------------------------------
|
| 164 |
}
|
| 165 |
-
|
| 166 |
-
/**
|
| 167 |
-
* Check for available updates
|
| 168 |
-
* @return stdClass|boolean
|
| 169 |
-
*/
|
| 170 |
-
public function CheckForUpdates() {
|
| 171 |
-
//-------------------------------------------------------------------------------------------------------
|
| 172 |
-
if ($this->curl_version != $this->plugin_available_version) {
|
| 173 |
-
//-------------------------------------------------------------------------------------------------------
|
| 174 |
-
$ret = new stdClass();
|
| 175 |
-
$ret->version = $this->curl_version;
|
| 176 |
-
$ret->new_version = $this->plugin_available_version;
|
| 177 |
-
//-------------------------------------------------------------------------------------------------------
|
| 178 |
-
return $ret;
|
| 179 |
-
//-------------------------------------------------------------------------------------------------------
|
| 180 |
-
}
|
| 181 |
-
//-------------------------------------------------------------------------------------------------------
|
| 182 |
-
return false;
|
| 183 |
-
//-------------------------------------------------------------------------------------------------------
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
/**
|
| 187 |
-
* License days counter
|
| 188 |
-
* @return integer|string
|
| 189 |
-
*/
|
| 190 |
-
public function GetSupportDays() {
|
| 191 |
-
//-------------------------------------------------------------------------------------------------------
|
| 192 |
-
if (!is_null($this->plugin_support)) {
|
| 193 |
-
//-------------------------------------------------------------------------------------------------------
|
| 194 |
-
$ret = new stdClass();
|
| 195 |
-
$ret->days = $this->count_days($this->plugin_support, date('Y-m-d'));
|
| 196 |
-
$ret->date = $this->plugin_support;
|
| 197 |
-
//-------------------------------------------------------------------------------------------------------
|
| 198 |
-
}
|
| 199 |
-
//-------------------------------------------------------------------------------------------------------
|
| 200 |
-
return 'n/a';
|
| 201 |
-
//-------------------------------------------------------------------------------------------------------
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
/**
|
| 205 |
-
* Register an account
|
| 206 |
-
* @param string $email Email to register
|
| 207 |
-
* @return stdClass
|
| 208 |
-
*/
|
| 209 |
-
public function CreateAccount($email) {
|
| 210 |
-
//---------------------------------------------------------------------------------------------------
|
| 211 |
-
$reg_token = $this->CallSUN('regtoken', '', true, true, true);
|
| 212 |
-
//---------------------------------------------------------------------------------------------------
|
| 213 |
-
if (is_null($reg_token->token)) {
|
| 214 |
-
//---------------------------------------------------------------------------------------------------
|
| 215 |
-
throw new Exception('Orbitvu: cannot get a token');
|
| 216 |
-
//---------------------------------------------------------------------------------------------------
|
| 217 |
-
}
|
| 218 |
-
//---------------------------------------------------------------------------------------------------
|
| 219 |
-
$reg = $this->CallSUN('reguser', array(
|
| 220 |
-
'token' => $reg_token->token,
|
| 221 |
-
'email' => $email
|
| 222 |
-
), true, true, true);
|
| 223 |
-
//---------------------------------------------------------------------------------------------------
|
| 224 |
-
if ($reg->email[0]) {
|
| 225 |
-
//---------------------------------------------------------------------------------------------------
|
| 226 |
-
throw new Exception($reg->email[0]);
|
| 227 |
-
//---------------------------------------------------------------------------------------------------
|
| 228 |
-
}
|
| 229 |
-
//---------------------------------------------------------------------------------------------------
|
| 230 |
-
$reg->email = $email;
|
| 231 |
-
|
| 232 |
-
//----------------------------------------------------------
|
| 233 |
-
/**/ $this->return_debug(array(
|
| 234 |
-
/**/ 'function' => __FUNCTION__,
|
| 235 |
-
/**/ 'response' => $reg
|
| 236 |
-
/**/ ));
|
| 237 |
-
//----------------------------------------------------------
|
| 238 |
-
|
| 239 |
-
//---------------------------------------------------------------------------------------------------
|
| 240 |
-
return $reg;
|
| 241 |
-
}
|
| 242 |
|
| 243 |
/**
|
| 244 |
* Want to change access_token for current session? No problem
|
|
@@ -249,6 +162,16 @@ final class Orbitvu {
|
|
| 249 |
$this->access_token = $access_token;
|
| 250 |
//---------------------------------------------------------------------------------------------------
|
| 251 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
/**
|
| 254 |
* Unit tests results
|
|
@@ -267,9 +190,10 @@ final class Orbitvu {
|
|
| 267 |
* @param boolean $method_post Use POST method
|
| 268 |
* @param boolean $get_headers Get HTTP headers
|
| 269 |
* @param boolean $not_change Disable automatic call formatting
|
|
|
|
| 270 |
* @return json|strong
|
| 271 |
*/
|
| 272 |
-
public function CallAPI($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false) {
|
| 273 |
//---------------------------------------------------------------------------------------------------
|
| 274 |
/*
|
| 275 |
* Add URL parameters from array to URL
|
|
@@ -329,7 +253,13 @@ final class Orbitvu {
|
|
| 329 |
$url = 'https://orbitvu.co/api/ecommerce/'.trim(str_replace(array('.html', '.json'), '', $call), '/').($method_post && !$not_change ? '' : '/').'.json';
|
| 330 |
}
|
| 331 |
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
/*
|
| 335 |
* Set the access token
|
|
@@ -406,11 +336,12 @@ final class Orbitvu {
|
|
| 406 |
* @param boolean $method_post Use POST method
|
| 407 |
* @param boolean $get_headers Get HTTP headers
|
| 408 |
* @param boolean $not_change Disable automatic call formatting
|
|
|
|
| 409 |
* @return stdClass
|
| 410 |
*/
|
| 411 |
-
public function CallSUN($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false) {
|
| 412 |
//---------------------------------------------------------------------------------------------------
|
| 413 |
-
$page = json_decode($this->CallAPI($call, $parameters, $method_post, $get_headers, $not_change));
|
| 414 |
|
| 415 |
//----------------------------------------------------------
|
| 416 |
/**/ $this->return_debug(array(
|
|
@@ -423,6 +354,583 @@ final class Orbitvu {
|
|
| 423 |
return $page;
|
| 424 |
//---------------------------------------------------------------------------------------------------
|
| 425 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
/**
|
| 428 |
* Cleans API URL with http / https dependences
|
|
@@ -474,6 +982,7 @@ final class Orbitvu {
|
|
| 474 |
|
| 475 |
/**
|
| 476 |
* Run unit tests
|
|
|
|
| 477 |
*/
|
| 478 |
private function run_tests() {
|
| 479 |
//-----------------------------------------------------------------------------------------------------
|
|
@@ -484,9 +993,9 @@ final class Orbitvu {
|
|
| 484 |
$tests_urls = array(
|
| 485 |
'http://orbitvu.com' => 'https://orbitvu.com',
|
| 486 |
'https://orbitvu.com' => 'https://orbitvu.com',
|
| 487 |
-
'//orbitvu.com'
|
| 488 |
-
'orbitvu.com'
|
| 489 |
-
'orbitvu//com'
|
| 490 |
);
|
| 491 |
$keys = array_keys($tests_urls);
|
| 492 |
$vals = array_values($tests_urls);
|
|
@@ -541,4 +1050,5 @@ final class Orbitvu {
|
|
| 541 |
}
|
| 542 |
|
| 543 |
}
|
|
|
|
| 544 |
?>
|
| 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 {
|
| 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
|
| 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
|
| 126 |
$this->curl_version = $v;
|
| 127 |
//-------------------------------------------------------------------------------------------------------
|
| 128 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
/**
|
| 131 |
* Get the demo access token
|
| 143 |
*/
|
| 144 |
public function IsDemo() {
|
| 145 |
//-------------------------------------------------------------------------------------------------------
|
| 146 |
+
if ($this->access_token == $this->GetDemoAccessToken() && $this->IsConnected()) {
|
| 147 |
//-------------------------------------------------------------------------------------------------------
|
| 148 |
return true;
|
| 149 |
//-------------------------------------------------------------------------------------------------------
|
| 152 |
return false;
|
| 153 |
//-------------------------------------------------------------------------------------------------------
|
| 154 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
/**
|
| 157 |
* Want to change access_token for current session? No problem
|
| 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
|
| 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
|
| 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
|
| 336 |
* @param boolean $method_post Use POST method
|
| 337 |
* @param boolean $get_headers Get HTTP headers
|
| 338 |
* @param boolean $not_change Disable automatic call formatting
|
| 339 |
+
* @param boolean $no_query_string Enable if sending sensitive data via POST
|
| 340 |
* @return stdClass
|
| 341 |
*/
|
| 342 |
+
public function CallSUN($call, $parameters = '', $method_post = false, $get_headers = false, $not_change = false, $no_query_string = false) {
|
| 343 |
//---------------------------------------------------------------------------------------------------
|
| 344 |
+
$page = json_decode($this->CallAPI($call, $parameters, $method_post, $get_headers, $not_change, $no_query_string));
|
| 345 |
|
| 346 |
//----------------------------------------------------------
|
| 347 |
/**/ $this->return_debug(array(
|
| 354 |
return $page;
|
| 355 |
//---------------------------------------------------------------------------------------------------
|
| 356 |
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Check if we are connected
|
| 360 |
+
* Also, get updates info if available
|
| 361 |
+
* @return boolean
|
| 362 |
+
* @fixme new licenses with Maciej
|
| 363 |
+
*/
|
| 364 |
+
public function IsConnected() {
|
| 365 |
+
//---------------------------------------------------------------------------------------------------
|
| 366 |
+
$get = $this->CallSUN('plugins/versions/latest', '', false, true);
|
| 367 |
+
//-------------------------------------------------------------------------------------------------------
|
| 368 |
+
$this->plugin_available_version = $get->version;
|
| 369 |
+
$this->plugin_support = $get->support;
|
| 370 |
+
|
| 371 |
+
if ($get->error) {
|
| 372 |
+
return false;
|
| 373 |
+
}
|
| 374 |
+
//-------------------------------------------------------------------------------------------------------
|
| 375 |
+
return true;
|
| 376 |
+
//---------------------------------------------------------------------------------------------------
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* Check for available updates
|
| 381 |
+
* @return stdClass|boolean
|
| 382 |
+
*/
|
| 383 |
+
public function CheckForUpdates() {
|
| 384 |
+
//-------------------------------------------------------------------------------------------------------
|
| 385 |
+
if ($this->curl_version != $this->plugin_available_version) {
|
| 386 |
+
//-------------------------------------------------------------------------------------------------------
|
| 387 |
+
$ret = new stdClass();
|
| 388 |
+
$ret->version = $this->curl_version;
|
| 389 |
+
$ret->new_version = $this->plugin_available_version;
|
| 390 |
+
//-------------------------------------------------------------------------------------------------------
|
| 391 |
+
return $ret;
|
| 392 |
+
//-------------------------------------------------------------------------------------------------------
|
| 393 |
+
}
|
| 394 |
+
//-------------------------------------------------------------------------------------------------------
|
| 395 |
+
return false;
|
| 396 |
+
//-------------------------------------------------------------------------------------------------------
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
* License days counter
|
| 401 |
+
* @return integer|string
|
| 402 |
+
*/
|
| 403 |
+
public function GetSupportDays() {
|
| 404 |
+
//-------------------------------------------------------------------------------------------------------
|
| 405 |
+
if (!is_null($this->plugin_support)) {
|
| 406 |
+
//-------------------------------------------------------------------------------------------------------
|
| 407 |
+
$ret = new stdClass();
|
| 408 |
+
$ret->days = $this->count_days($this->plugin_support, date('Y-m-d'));
|
| 409 |
+
$ret->date = $this->plugin_support;
|
| 410 |
+
//-------------------------------------------------------------------------------------------------------
|
| 411 |
+
}
|
| 412 |
+
//-------------------------------------------------------------------------------------------------------
|
| 413 |
+
return 'n/a';
|
| 414 |
+
//-------------------------------------------------------------------------------------------------------
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
/**
|
| 418 |
+
* Register an account
|
| 419 |
+
* @param string $email Email to register
|
| 420 |
+
* @return stdClass
|
| 421 |
+
*/
|
| 422 |
+
public function CreateAccount($email) {
|
| 423 |
+
//---------------------------------------------------------------------------------------------------
|
| 424 |
+
$reg_token = $this->CallSUN('regtoken', '', true, true, true);
|
| 425 |
+
//---------------------------------------------------------------------------------------------------
|
| 426 |
+
if (is_null($reg_token->token)) {
|
| 427 |
+
//---------------------------------------------------------------------------------------------------
|
| 428 |
+
throw new Exception('Orbitvu: cannot get a token');
|
| 429 |
+
//---------------------------------------------------------------------------------------------------
|
| 430 |
+
}
|
| 431 |
+
//---------------------------------------------------------------------------------------------------
|
| 432 |
+
$reg = $this->CallSUN('reguser', array(
|
| 433 |
+
'token' => $reg_token->token,
|
| 434 |
+
'email' => $email
|
| 435 |
+
), true, true, true);
|
| 436 |
+
//---------------------------------------------------------------------------------------------------
|
| 437 |
+
if ($reg->email[0]) {
|
| 438 |
+
//---------------------------------------------------------------------------------------------------
|
| 439 |
+
throw new Exception($reg->email[0]);
|
| 440 |
+
//---------------------------------------------------------------------------------------------------
|
| 441 |
+
}
|
| 442 |
+
//---------------------------------------------------------------------------------------------------
|
| 443 |
+
$reg->email = $email;
|
| 444 |
+
|
| 445 |
+
//----------------------------------------------------------
|
| 446 |
+
/**/ $this->return_debug(array(
|
| 447 |
+
/**/ 'function' => __FUNCTION__,
|
| 448 |
+
/**/ 'response' => $reg
|
| 449 |
+
/**/ ));
|
| 450 |
+
//----------------------------------------------------------
|
| 451 |
+
|
| 452 |
+
//---------------------------------------------------------------------------------------------------
|
| 453 |
+
return $reg;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
/**
|
| 457 |
+
* Gets a client License Key (Access Token) from Orbitvu SUN account after log in
|
| 458 |
+
* @param type $user_name SUN user name
|
| 459 |
+
* @param type $password SUN user password
|
| 460 |
+
* @return boolean|string License Key or FALSE
|
| 461 |
+
*/
|
| 462 |
+
public function LogInSun($user_name, $password) {
|
| 463 |
+
//---------------------------------------------------------------------------------------------------
|
| 464 |
+
$request = $this->CallSUN('get_api_key', array(
|
| 465 |
+
'username' => $user_name,
|
| 466 |
+
'password' => $password
|
| 467 |
+
), true, false, true, true);
|
| 468 |
+
|
| 469 |
+
if (!is_null($request->key) && $request->key != '') {
|
| 470 |
+
return $request->key;
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
return false;
|
| 474 |
+
//---------------------------------------------------------------------------------------------------
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* Checks if access token from SUN @see LogInSun
|
| 479 |
+
* is the same as local access token
|
| 480 |
+
* @param type $sun_access_token SUN access token
|
| 481 |
+
* @return boolean
|
| 482 |
+
*/
|
| 483 |
+
public function CheckAccessToken($sun_access_token) {
|
| 484 |
+
//---------------------------------------------------------------------------------------------------
|
| 485 |
+
if ($sun_access_token == $this->GetAccessToken() && $this->IsConnected()) {
|
| 486 |
+
return true;
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
return false;
|
| 490 |
+
//---------------------------------------------------------------------------------------------------
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
/*
|
| 494 |
+
* Viewer downloader
|
| 495 |
+
*/
|
| 496 |
+
public function DownloadViewer($viewer_url) {
|
| 497 |
+
|
| 498 |
+
$viewer_url = str_ireplace('.html', '', $viewer_url);
|
| 499 |
+
|
| 500 |
+
//----------------------------------------------------------
|
| 501 |
+
if ($this->test) {
|
| 502 |
+
$this->testclass->AppendTest('download_viewer_start['.$viewer_url.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
|
| 503 |
+
}
|
| 504 |
+
//----------------------------------------------------------
|
| 505 |
+
|
| 506 |
+
//----------------------------------------------------------
|
| 507 |
+
/**/ $this->return_debug(array(
|
| 508 |
+
/**/ 'function' => __FUNCTION__,
|
| 509 |
+
/**/ 'viewer_url' => $viewer_url
|
| 510 |
+
/**/ ));
|
| 511 |
+
//----------------------------------------------------------
|
| 512 |
+
|
| 513 |
+
/*
|
| 514 |
+
* Download the viewer
|
| 515 |
+
*/
|
| 516 |
+
$file = $this->CallAPI($viewer_url);
|
| 517 |
+
|
| 518 |
+
//----------------------------------------------------------
|
| 519 |
+
/**/ $this->return_debug(array(
|
| 520 |
+
/**/ 'function' => __FUNCTION__,
|
| 521 |
+
/**/ 'file' => (strlen($file) > 100 ? '[ZIP_FILE]' : '')
|
| 522 |
+
/**/ ));
|
| 523 |
+
//----------------------------------------------------------
|
| 524 |
+
|
| 525 |
+
/*
|
| 526 |
+
* Try to put the content to the zip file
|
| 527 |
+
*/
|
| 528 |
+
$temp_dir = __DIR__.'/'.$this->DownloadPath;
|
| 529 |
+
$temp_file = __DIR__.'/'.$this->DownloadPath.'temp.zip';
|
| 530 |
+
|
| 531 |
+
if (file_put_contents($temp_file, $file)) {
|
| 532 |
+
/*
|
| 533 |
+
* Check if upload was successfull
|
| 534 |
+
*/
|
| 535 |
+
if (file_exists($temp_file)) {
|
| 536 |
+
//----------------------------------------------------------
|
| 537 |
+
if ($this->test) {
|
| 538 |
+
$this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
|
| 539 |
+
}
|
| 540 |
+
//----------------------------------------------------------
|
| 541 |
+
|
| 542 |
+
/*
|
| 543 |
+
* Return file path
|
| 544 |
+
*/
|
| 545 |
+
return $temp_file;
|
| 546 |
+
}
|
| 547 |
+
else {
|
| 548 |
+
//----------------------------------------------------------
|
| 549 |
+
if ($this->test) {
|
| 550 |
+
$this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
|
| 551 |
+
}
|
| 552 |
+
//----------------------------------------------------------
|
| 553 |
+
|
| 554 |
+
//---------------------------------------------------------------------------------------------------
|
| 555 |
+
throw new Exception('Orbitvu: cannot download viewer file to '.$temp_dir);
|
| 556 |
+
//---------------------------------------------------------------------------------------------------
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
else {
|
| 560 |
+
//----------------------------------------------------------
|
| 561 |
+
if ($this->test) {
|
| 562 |
+
$this->testclass->UpdateTest('download_viewer_start['.$viewer_url.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
|
| 563 |
+
}
|
| 564 |
+
//----------------------------------------------------------
|
| 565 |
+
|
| 566 |
+
//---------------------------------------------------------------------------------------------------
|
| 567 |
+
throw new Exception('Orbitvu: cannot download viewer file. Set "write" permissions to '.$temp_dir);
|
| 568 |
+
//---------------------------------------------------------------------------------------------------
|
| 569 |
+
}
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
/**
|
| 573 |
+
* Install presentation from file
|
| 574 |
+
*
|
| 575 |
+
* Check if file is .ovus (Orbitvu Sequence) or .zip package.
|
| 576 |
+
* If so, unpack archive and refresh page
|
| 577 |
+
*
|
| 578 |
+
* Console like installator, needs to be working with any e-commerce platform/CMS),
|
| 579 |
+
* that's why:
|
| 580 |
+
* - I didn't used templates,
|
| 581 |
+
* - I used exit() to stop rendering page by any platform we use,
|
| 582 |
+
* - I used JavaScript redirect as this will be run in a browser, but one archive at the time
|
| 583 |
+
* (a way to trick every server limits)
|
| 584 |
+
*
|
| 585 |
+
* @param string $file Presentation archive file (*.ovus, *.zip)
|
| 586 |
+
* @param boolean $print_output Print console-like output messages
|
| 587 |
+
* @return string
|
| 588 |
+
*/
|
| 589 |
+
public function InstallPresentation($file, $print_output = true) {
|
| 590 |
+
|
| 591 |
+
$dir_or_file = $file;
|
| 592 |
+
$dir_name = explode('/', $dir_or_file);
|
| 593 |
+
$dir_name = $dir_name[count($dir_name)-1];
|
| 594 |
+
|
| 595 |
+
$is_sun = false;
|
| 596 |
+
//-------------------------------------------------------------------------------------------------------
|
| 597 |
+
if ($print_output) {
|
| 598 |
+
echo '<div style="margin: 20px 10% 20px 10%; font: 14px Arial;"><strong>Orbitvu - Presentations Installer</strong><br />
|
| 599 |
+
You will be redirected to your store automatically after installation.<br /><br /><pre style="font-size: 12px;">';
|
| 600 |
+
|
| 601 |
+
echo '['.date('Y-m-d H:i:s').'] ';
|
| 602 |
+
}
|
| 603 |
+
//-------------------------------------------------------------------------------------------------------
|
| 604 |
+
|
| 605 |
+
/**
|
| 606 |
+
* Installing
|
| 607 |
+
*/
|
| 608 |
+
//-------------------------------------------------------------------------------------------------------
|
| 609 |
+
if (stristr($dir_name, '.ovus')) {
|
| 610 |
+
$ext = '.ovus';
|
| 611 |
+
}
|
| 612 |
+
else {
|
| 613 |
+
$ext = '.zip';
|
| 614 |
+
}
|
| 615 |
+
//-------------------------------------------------------------------------------------------------------
|
| 616 |
+
|
| 617 |
+
if ($print_output) {
|
| 618 |
+
echo 'Installing '.$ext.' presentation "'.$dir_name.'"...';
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
/**
|
| 622 |
+
* Try to unpack the archive
|
| 623 |
+
*/
|
| 624 |
+
try {
|
| 625 |
+
$new_dir = $this->PresentationsPath.str_ireplace($ext, '', $dir_name);
|
| 626 |
+
|
| 627 |
+
$this->Unzip($dir_or_file, $new_dir);
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* Is the archive from Orbitvu SUN?
|
| 631 |
+
*/
|
| 632 |
+
if (file_exists($new_dir.'/orbitvu12')) {
|
| 633 |
+
$is_sun = true;
|
| 634 |
+
|
| 635 |
+
/**
|
| 636 |
+
* Move presentations to parent folder
|
| 637 |
+
*/
|
| 638 |
+
$tree = $this->GetDirectoryTree($new_dir);
|
| 639 |
+
foreach ($tree as $current_inode) {
|
| 640 |
+
|
| 641 |
+
/**
|
| 642 |
+
* Make sure we didn't move the viewer from the package and any .html presentations
|
| 643 |
+
* We will not use these
|
| 644 |
+
*/
|
| 645 |
+
if (!stristr($current_inode, 'orbitvu12') && !stristr($current_inode, '.html')) {
|
| 646 |
+
|
| 647 |
+
$current_name = explode('/', $current_inode);
|
| 648 |
+
$current_name = $current_name[count($current_name)-1];
|
| 649 |
+
|
| 650 |
+
rename($current_inode, $this->PresentationsPath.$current_name);
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
/**
|
| 655 |
+
* Delete unpacked folder
|
| 656 |
+
*/
|
| 657 |
+
$this->rrmdir($new_dir);
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
if ($print_output) {
|
| 661 |
+
echo ' OK<script type="text/javascript">window.location.reload();</script>'."\n";
|
| 662 |
+
}
|
| 663 |
+
else {
|
| 664 |
+
return true;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
catch (Exception $e) {
|
| 668 |
+
if ($print_output) {
|
| 669 |
+
echo '<span style="color: red;font-weight: bold;"> FAILED</span><script type="text/javascript">alert(\'Installation failed!\');</script>'."\n";
|
| 670 |
+
echo $e->getMessage();
|
| 671 |
+
}
|
| 672 |
+
else {
|
| 673 |
+
return false;
|
| 674 |
+
}
|
| 675 |
+
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
if ($print_output) {
|
| 679 |
+
echo '</pre></div>';
|
| 680 |
+
|
| 681 |
+
exit();
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
/**
|
| 687 |
+
* Install Viewer if $viewer_type is available
|
| 688 |
+
* @param string $viewer_type Viewer type name
|
| 689 |
+
* @return boolean
|
| 690 |
+
* @throws Exception
|
| 691 |
+
*/
|
| 692 |
+
public function InstallViewer($viewer_type = 'BASIC') {
|
| 693 |
+
|
| 694 |
+
$viewers = $this->CallSun('viewers/licenses');
|
| 695 |
+
|
| 696 |
+
foreach ($viewers as $viewer) {
|
| 697 |
+
|
| 698 |
+
if ($viewer->type == $viewer_type) {
|
| 699 |
+
|
| 700 |
+
/**
|
| 701 |
+
* Temporary file name
|
| 702 |
+
*/
|
| 703 |
+
$file_name = 'viewer.zip';
|
| 704 |
+
|
| 705 |
+
/**
|
| 706 |
+
* Download Viewer
|
| 707 |
+
*/
|
| 708 |
+
$viewer = $this->CallAPI($this->clean_url($viewer->download), '', false, false, true);
|
| 709 |
+
|
| 710 |
+
if (file_put_contents($this->ViewerPath.$file_name, $viewer)) {
|
| 711 |
+
|
| 712 |
+
/**
|
| 713 |
+
* Unzip the package
|
| 714 |
+
*/
|
| 715 |
+
|
| 716 |
+
$this->Unzip($this->ViewerPath.$file_name, $this->ViewerPath);
|
| 717 |
+
|
| 718 |
+
/**
|
| 719 |
+
* Delete temporary file
|
| 720 |
+
*/
|
| 721 |
+
unlink($this->ViewerPath.$file_name);
|
| 722 |
+
|
| 723 |
+
return true;
|
| 724 |
+
}
|
| 725 |
+
else {
|
| 726 |
+
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.');
|
| 727 |
+
}
|
| 728 |
+
}
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
/*
|
| 734 |
+
* Unzip
|
| 735 |
+
* Require ZipArchive (PHP standard from 5.2.0)
|
| 736 |
+
*/
|
| 737 |
+
public function Unzip($file, $path = null) {
|
| 738 |
+
|
| 739 |
+
if ($path == null) {
|
| 740 |
+
$path = $this->ViewerPath;
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
//----------------------------------------------------------
|
| 744 |
+
if ($this->test) {
|
| 745 |
+
$this->testclass->AppendTest('unzip['.$file.']', array('type' => 'function_check'), array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__));
|
| 746 |
+
}
|
| 747 |
+
//----------------------------------------------------------
|
| 748 |
+
/*
|
| 749 |
+
* Check if user have ZipArchive class installed
|
| 750 |
+
*/
|
| 751 |
+
if (!class_exists('ZipArchive')) {
|
| 752 |
+
//----------------------------------------------------------
|
| 753 |
+
if ($this->test) {
|
| 754 |
+
$this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
|
| 755 |
+
}
|
| 756 |
+
//----------------------------------------------------------
|
| 757 |
+
|
| 758 |
+
//---------------------------------------------------------------------------------------------------
|
| 759 |
+
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');
|
| 760 |
+
//---------------------------------------------------------------------------------------------------
|
| 761 |
+
return false;
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
/*
|
| 765 |
+
* Unpacking the archive
|
| 766 |
+
*/
|
| 767 |
+
$zip = new ZipArchive();
|
| 768 |
+
//---------------------------------------------------------------------------------------------------
|
| 769 |
+
if ($res = $zip->open($file)) {
|
| 770 |
+
|
| 771 |
+
if ($res === true) {
|
| 772 |
+
//---------------------------------------------------------------------------------------------------
|
| 773 |
+
/*
|
| 774 |
+
* Extract
|
| 775 |
+
*/
|
| 776 |
+
$zip->extractTo($path);
|
| 777 |
+
$zip->close();
|
| 778 |
+
|
| 779 |
+
/*
|
| 780 |
+
* Delete the temp .zip file
|
| 781 |
+
*/
|
| 782 |
+
unlink($file);
|
| 783 |
+
|
| 784 |
+
if (file_exists($file)) {
|
| 785 |
+
throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to dir '.$path.' and to the parent directory.');
|
| 786 |
+
}
|
| 787 |
+
|
| 788 |
+
//----------------------------------------------------------
|
| 789 |
+
if ($this->test) {
|
| 790 |
+
$this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'ok');
|
| 791 |
+
}
|
| 792 |
+
//----------------------------------------------------------
|
| 793 |
+
|
| 794 |
+
//---------------------------------------------------------------------------------------------------
|
| 795 |
+
return true;
|
| 796 |
+
//---------------------------------------------------------------------------------------------------
|
| 797 |
+
}
|
| 798 |
+
else {
|
| 799 |
+
//----------------------------------------------------------
|
| 800 |
+
if ($this->test) {
|
| 801 |
+
$this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
|
| 802 |
+
}
|
| 803 |
+
//----------------------------------------------------------
|
| 804 |
+
|
| 805 |
+
//---------------------------------------------------------------------------------------------------
|
| 806 |
+
throw new Exception('Orbitvu: cannot extract the file. Not valid file format or directory '.$path.' not found. Create this directory and set "write" permissions');
|
| 807 |
+
//---------------------------------------------------------------------------------------------------
|
| 808 |
+
}
|
| 809 |
+
}
|
| 810 |
+
else {
|
| 811 |
+
//----------------------------------------------------------
|
| 812 |
+
if ($this->test) {
|
| 813 |
+
$this->testclass->UpdateTest('unzip['.$file.']', array('file' => __FILE__, 'line' => __LINE__, 'function' => __FUNCTION__), 'failed');
|
| 814 |
+
}
|
| 815 |
+
//----------------------------------------------------------
|
| 816 |
+
|
| 817 |
+
//---------------------------------------------------------------------------------------------------
|
| 818 |
+
throw new Exception('Orbitvu: cannot extract the file. Set "write" permissions to '.$path);
|
| 819 |
+
//---------------------------------------------------------------------------------------------------
|
| 820 |
+
}
|
| 821 |
+
}
|
| 822 |
+
|
| 823 |
+
/**
|
| 824 |
+
* Lists all directories
|
| 825 |
+
* @param type $dir
|
| 826 |
+
* @param type $no_basefiles
|
| 827 |
+
* @return array
|
| 828 |
+
*/
|
| 829 |
+
public static function GetDirectoryTree($dir, $no_basefiles = true, $per_page = 0, $page = 0) {
|
| 830 |
+
//--------------------------------------------------------------------------------------------------------------------
|
| 831 |
+
if ($page > 0) {
|
| 832 |
+
$page--;
|
| 833 |
+
}
|
| 834 |
+
//-------------------------------------------------------------------------------------------------------
|
| 835 |
+
$files = array();
|
| 836 |
+
|
| 837 |
+
$i = 0;
|
| 838 |
+
$j = 0;
|
| 839 |
+
foreach (new DirectoryIterator($dir) as $current_file) {
|
| 840 |
+
//-------------------------------------------------------------------------------------------------------
|
| 841 |
+
if ($current_file->isDot() && $no_basefiles) {
|
| 842 |
+
continue;
|
| 843 |
+
}
|
| 844 |
+
//-------------------------------------------------------------------------------------------------------
|
| 845 |
+
if ($page > 0) {
|
| 846 |
+
$j++;
|
| 847 |
+
|
| 848 |
+
if ($j <= $per_page * $page) {
|
| 849 |
+
$i = 0;
|
| 850 |
+
}
|
| 851 |
+
}
|
| 852 |
+
//-------------------------------------------------------------------------------------------------------
|
| 853 |
+
if ($i == $per_page && $per_page > 0) {
|
| 854 |
+
break;
|
| 855 |
+
}
|
| 856 |
+
//-------------------------------------------------------------------------------------------------------
|
| 857 |
+
if ($page == 0 || ($page > 0 && $j > $per_page * $page)) {
|
| 858 |
+
$files[] = $current_file->getPathname();
|
| 859 |
+
}
|
| 860 |
+
//-------------------------------------------------------------------------------------------------------
|
| 861 |
+
$i++;
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
return $files;
|
| 865 |
+
//--------------------------------------------------------------------------------------------------------------------
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
/**
|
| 869 |
+
* Counts presentations
|
| 870 |
+
* @param string $dir
|
| 871 |
+
* @return integer
|
| 872 |
+
*/
|
| 873 |
+
public function GetPresentationsCount($dir) {
|
| 874 |
+
//--------------------------------------------------------------------------------------------------------------------
|
| 875 |
+
if ($this->presentations_count == 0) {
|
| 876 |
+
$pres = self::GetDirectoryTree($dir);
|
| 877 |
+
|
| 878 |
+
$this->presentations_count = count($pres);
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
return intval($this->presentations_count);
|
| 882 |
+
//--------------------------------------------------------------------------------------------------------------------
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
/**
|
| 886 |
+
* Converts XML content to multi-dimensional array
|
| 887 |
+
* @param type $xml_content
|
| 888 |
+
* @return array
|
| 889 |
+
* @throws Exception
|
| 890 |
+
*/
|
| 891 |
+
public static function XMLtoArray($xml_content) {
|
| 892 |
+
//-------------------------------------------------------------------------------------------------------
|
| 893 |
+
/*
|
| 894 |
+
* Check if user have ZipArchive class installed
|
| 895 |
+
*/
|
| 896 |
+
if (!class_exists('SimpleXMLElement')) {
|
| 897 |
+
//---------------------------------------------------------------------------------------------------
|
| 898 |
+
throw new Exception('Orbitvu: PHP extension SimpleXMLElement doesn\'t exist. Upgrade your PHP version to >= 5.0.1');
|
| 899 |
+
//---------------------------------------------------------------------------------------------------
|
| 900 |
+
}
|
| 901 |
+
|
| 902 |
+
$xml = new SimpleXMLElement($xml_content);
|
| 903 |
+
|
| 904 |
+
$xml_array = unserialize(serialize(json_decode(json_encode((array) $xml), 1)));
|
| 905 |
+
|
| 906 |
+
return $xml_array;
|
| 907 |
+
//-------------------------------------------------------------------------------------------------------
|
| 908 |
+
}
|
| 909 |
+
|
| 910 |
+
/**
|
| 911 |
+
* Remove directory recursively
|
| 912 |
+
* @param string $dirPath Directory to delete (could be non empty)
|
| 913 |
+
*/
|
| 914 |
+
private function rrmdir($dirPath) {
|
| 915 |
+
if (!is_dir($dirPath)) {
|
| 916 |
+
throw new InvalidArgumentException($dirPath.' must be a directory');
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
|
| 920 |
+
$dirPath .= '/';
|
| 921 |
+
}
|
| 922 |
+
|
| 923 |
+
$files = glob($dirPath . '*', GLOB_MARK);
|
| 924 |
+
foreach ($files as $file) {
|
| 925 |
+
if (is_dir($file)) {
|
| 926 |
+
$this->rrmdir($file);
|
| 927 |
+
} else {
|
| 928 |
+
unlink($file);
|
| 929 |
+
}
|
| 930 |
+
}
|
| 931 |
+
|
| 932 |
+
rmdir($dirPath);
|
| 933 |
+
}
|
| 934 |
|
| 935 |
/**
|
| 936 |
* Cleans API URL with http / https dependences
|
| 982 |
|
| 983 |
/**
|
| 984 |
* Run unit tests
|
| 985 |
+
* @todo Add tests for new functions
|
| 986 |
*/
|
| 987 |
private function run_tests() {
|
| 988 |
//-----------------------------------------------------------------------------------------------------
|
| 993 |
$tests_urls = array(
|
| 994 |
'http://orbitvu.com' => 'https://orbitvu.com',
|
| 995 |
'https://orbitvu.com' => 'https://orbitvu.com',
|
| 996 |
+
'//orbitvu.com' => 'https://orbitvu.com',
|
| 997 |
+
'orbitvu.com' => 'orbitvu.com',
|
| 998 |
+
'orbitvu//com' => 'orbitvu//com'
|
| 999 |
);
|
| 1000 |
$keys = array_keys($tests_urls);
|
| 1001 |
$vals = array_values($tests_urls);
|
| 1050 |
}
|
| 1051 |
|
| 1052 |
}
|
| 1053 |
+
|
| 1054 |
?>
|
app/code/community/Orbitvu/Sun/controllers/OrbitvuDatabaseInterface.php
CHANGED
|
@@ -18,6 +18,12 @@ final class OrbitvuDatabaseInterface {
|
|
| 18 |
*/
|
| 19 |
private $db_prefix = '';
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
/**
|
| 22 |
* Debug mode
|
| 23 |
* @var boolean
|
|
@@ -66,6 +72,10 @@ final class OrbitvuDatabaseInterface {
|
|
| 66 |
//---------------------------------------------------------------------------------------------------
|
| 67 |
if (!empty($prefix)) $this->db_prefix = $prefix;
|
| 68 |
else $this->db_prefix = $this->database->GetPrefix();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
//---------------------------------------------------------------------------------------------------
|
| 70 |
$this->Config = $this->GetConfiguration();
|
| 71 |
/*
|
|
@@ -98,10 +108,40 @@ final class OrbitvuDatabaseInterface {
|
|
| 98 |
*/
|
| 99 |
public function SynchronizeAllProducts() {
|
| 100 |
//----------------------------------------------------------
|
| 101 |
-
return $this->SynchronizePresentations($this->database->SynchronizeAllProducts()
|
| 102 |
//----------------------------------------------------------
|
| 103 |
}
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
/**
|
| 106 |
* Get all configuration vars and values.
|
| 107 |
* Update local values to store values
|
|
@@ -117,7 +157,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 117 |
//----------------------------------------------------------
|
| 118 |
$db_query = '
|
| 119 |
SELECT *
|
| 120 |
-
FROM `'.$this->db_prefix.'
|
| 121 |
';
|
| 122 |
|
| 123 |
//---------------------------------------------------------------------
|
|
@@ -181,7 +221,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 181 |
//-------------------------------------------------------------------------------------------------------
|
| 182 |
$db_query = '
|
| 183 |
INSERT INTO
|
| 184 |
-
`'.$this->db_prefix.'
|
| 185 |
(`var`, `value`, `type`)
|
| 186 |
|
| 187 |
VALUES (
|
|
@@ -230,7 +270,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 230 |
//-------------------------------------------------------------------------------------------------------
|
| 231 |
$db_query = '
|
| 232 |
SELECT *
|
| 233 |
-
FROM `'.$this->db_prefix.'
|
| 234 |
|
| 235 |
WHERE
|
| 236 |
`product_id` = '.intval($product_id).'
|
|
@@ -253,7 +293,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 253 |
//-------------------------------------------------------------------------------------------------------
|
| 254 |
$db_query = '
|
| 255 |
DELETE
|
| 256 |
-
FROM `'.$this->db_prefix.'
|
| 257 |
|
| 258 |
WHERE
|
| 259 |
`_presentations_id` = '.intval($product['id']).'
|
|
@@ -271,7 +311,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 271 |
//-------------------------------------------------------------------------------------------------------
|
| 272 |
$db_query = '
|
| 273 |
INSERT INTO
|
| 274 |
-
`'.$this->db_prefix.'
|
| 275 |
(`product_id`, `orbitvu_id`, `unlink_date`)
|
| 276 |
|
| 277 |
VALUES (
|
|
@@ -293,7 +333,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 293 |
//-------------------------------------------------------------------------------------------------------
|
| 294 |
$db_query = '
|
| 295 |
DELETE FROM
|
| 296 |
-
`'.$this->db_prefix.'
|
| 297 |
|
| 298 |
WHERE
|
| 299 |
`id` = '.intval($product['id']).'
|
|
@@ -323,7 +363,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 323 |
//-------------------------------------------------------------------------------------------------------
|
| 324 |
$db_query = '
|
| 325 |
SELECT *
|
| 326 |
-
FROM `'.$this->db_prefix.'
|
| 327 |
|
| 328 |
WHERE
|
| 329 |
`product_id` = '.intval($product_id).'
|
|
@@ -350,7 +390,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 350 |
//-------------------------------------------------------------------------------------------------------
|
| 351 |
$db_query = '
|
| 352 |
INSERT INTO
|
| 353 |
-
`'.$this->db_prefix.'
|
| 354 |
(`product_id`, `thumbnail`)
|
| 355 |
|
| 356 |
VALUES (
|
|
@@ -383,7 +423,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 383 |
//-------------------------------------------------------------------------------------------------------
|
| 384 |
$db_query = '
|
| 385 |
DELETE FROM
|
| 386 |
-
`'.$this->db_prefix.'
|
| 387 |
|
| 388 |
WHERE
|
| 389 |
`product_id` = '.intval($product_id).'
|
|
@@ -412,7 +452,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 412 |
//-------------------------------------------------------------------------------------------------------
|
| 413 |
$db_query = '
|
| 414 |
SELECT *
|
| 415 |
-
FROM `'.$this->db_prefix.'
|
| 416 |
|
| 417 |
WHERE
|
| 418 |
`product_id` = '.intval($product_id).'
|
|
@@ -447,7 +487,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 447 |
//-------------------------------------------------------------------------------------------------------
|
| 448 |
$db_query = '
|
| 449 |
SELECT *
|
| 450 |
-
FROM `'.$this->db_prefix.'
|
| 451 |
|
| 452 |
WHERE
|
| 453 |
`product_id` = '.intval($product_id).' AND
|
|
@@ -482,7 +522,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 482 |
//-------------------------------------------------------------------------------------------------------
|
| 483 |
$db_query = '
|
| 484 |
SELECT *
|
| 485 |
-
FROM `'.$this->db_prefix.'
|
| 486 |
|
| 487 |
WHERE
|
| 488 |
`product_id` = '.intval($product_id).'
|
|
@@ -516,7 +556,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 516 |
//-------------------------------------------------------------------------------------------------------
|
| 517 |
$db_query = '
|
| 518 |
SELECT *
|
| 519 |
-
FROM `'.$this->db_prefix.'
|
| 520 |
|
| 521 |
WHERE
|
| 522 |
`product_id` = '.intval($product_id).'
|
|
@@ -536,6 +576,33 @@ final class OrbitvuDatabaseInterface {
|
|
| 536 |
if (isset($query['type'])) {
|
| 537 |
//-------------------------------------------------------------------------------------------------------
|
| 538 |
$ret = $query;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 539 |
$ret['items'] = array();
|
| 540 |
|
| 541 |
$ret['types'] = array();
|
|
@@ -543,7 +610,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 543 |
//-------------------------------------------------------------------------------------------------------
|
| 544 |
$db_sub_query = '
|
| 545 |
SELECT *
|
| 546 |
-
FROM `'.$this->db_prefix.'
|
| 547 |
|
| 548 |
WHERE
|
| 549 |
`_presentations_id` = '.$ret['id'].'
|
|
@@ -588,7 +655,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 588 |
//-------------------------------------------------------------------------------------------------------
|
| 589 |
$db_query = '
|
| 590 |
SELECT `id`
|
| 591 |
-
FROM `'.$this->db_prefix.'
|
| 592 |
|
| 593 |
WHERE
|
| 594 |
`product_id` = '.intval($product_id).'
|
|
@@ -606,21 +673,21 @@ final class OrbitvuDatabaseInterface {
|
|
| 606 |
|
| 607 |
$db_query = '
|
| 608 |
INSERT INTO
|
| 609 |
-
`'.$this->db_prefix.'
|
| 610 |
(`product_id`, `orbitvu_id`, `name`, `type`)
|
| 611 |
|
| 612 |
VALUES (
|
| 613 |
'.intval($product_id).',
|
| 614 |
'.intval($orbitvu_id).',
|
| 615 |
\''.$this->database->Escape($presentation_name).'\',
|
| 616 |
-
\'sun\'
|
| 617 |
)
|
| 618 |
|
| 619 |
ON DUPLICATE KEY
|
| 620 |
|
| 621 |
UPDATE
|
| 622 |
`name` = \''.$this->database->Escape($presentation_name).'\',
|
| 623 |
-
`type` = \'sun\'
|
| 624 |
';
|
| 625 |
|
| 626 |
//---------------------------------------------------------------------
|
|
@@ -672,10 +739,10 @@ final class OrbitvuDatabaseInterface {
|
|
| 672 |
//-------------------------------------------------------------------------------------------------------
|
| 673 |
$db_query = '
|
| 674 |
SELECT `id`
|
| 675 |
-
FROM `'.$this->db_prefix.'
|
| 676 |
|
| 677 |
WHERE
|
| 678 |
-
`orbitvu_id` = '
|
| 679 |
`_presentations_id` = '.intval($presentation_id).'
|
| 680 |
|
| 681 |
LIMIT 1
|
|
@@ -694,18 +761,19 @@ final class OrbitvuDatabaseInterface {
|
|
| 694 |
|
| 695 |
$db_query = '
|
| 696 |
INSERT INTO
|
| 697 |
-
`'.$this->db_prefix.'
|
| 698 |
-
(`_presentations_id`, `orbitvu_id`, `priority`, `name`, `type`, `thumbnail`, `path`, `config`)
|
| 699 |
|
| 700 |
VALUES (
|
| 701 |
'.intval($presentation_id).',
|
| 702 |
-
'
|
| 703 |
'.($priority).',
|
| 704 |
\''.$this->database->Escape($item['name']).'\',
|
| 705 |
'.intval($item['type']).',
|
| 706 |
\''.($item['thumbnail']).'\',
|
| 707 |
\''.($item['path']).'\',
|
| 708 |
-
\''.$this->database->Escape($item['config']).'\'
|
|
|
|
| 709 |
)
|
| 710 |
';
|
| 711 |
|
|
@@ -740,6 +808,16 @@ final class OrbitvuDatabaseInterface {
|
|
| 740 |
//-------------------------------------------------------------------------------------------------------
|
| 741 |
$product_name = $product['product_name'];
|
| 742 |
$product_sku = $product['product_sku'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 743 |
//-------------------------------------------------------------------------------------------------------
|
| 744 |
$count = 0;
|
| 745 |
//-------------------------------------------------------------------------------------------------------
|
|
@@ -749,6 +827,15 @@ final class OrbitvuDatabaseInterface {
|
|
| 749 |
'name' => $product_sku
|
| 750 |
));
|
| 751 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
$count = $presentations_choose->count;
|
| 753 |
|
| 754 |
if ($count == 0) {
|
|
@@ -757,6 +844,15 @@ final class OrbitvuDatabaseInterface {
|
|
| 757 |
'sku' => $product_sku
|
| 758 |
));
|
| 759 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 760 |
$count = $presentations_choose->count;
|
| 761 |
}
|
| 762 |
}
|
|
@@ -766,6 +862,15 @@ final class OrbitvuDatabaseInterface {
|
|
| 766 |
'page_size' => 1,
|
| 767 |
'name' => $product_name
|
| 768 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
|
| 770 |
$count = $presentations_choose->count;
|
| 771 |
|
|
@@ -774,6 +879,15 @@ final class OrbitvuDatabaseInterface {
|
|
| 774 |
'page_size' => 1,
|
| 775 |
'sku' => $product_name
|
| 776 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 777 |
|
| 778 |
$count = $presentations_choose->count;
|
| 779 |
}
|
|
@@ -886,7 +1000,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 886 |
//-------------------------------------------------------------------------------------------------------
|
| 887 |
$db_query = '
|
| 888 |
SELECT *
|
| 889 |
-
FROM `'.$this->db_prefix.'
|
| 890 |
';
|
| 891 |
|
| 892 |
//---------------------------------------------------------------------
|
|
@@ -913,14 +1027,14 @@ final class OrbitvuDatabaseInterface {
|
|
| 913 |
|
| 914 |
$db_query_items = '
|
| 915 |
SELECT *
|
| 916 |
-
FROM `'.$this->db_prefix.'
|
| 917 |
|
| 918 |
WHERE
|
| 919 |
`_presentations_id` = '.intval($q['id']).'
|
| 920 |
';
|
| 921 |
|
| 922 |
//---------------------------------------------------------------------
|
| 923 |
-
/**/ $this->return_sql_debug(__FUNCTION__, $
|
| 924 |
//---------------------------------------------------------------------
|
| 925 |
|
| 926 |
$items_current = $this->database->FetchAll($db_query_items);
|
|
@@ -959,6 +1073,329 @@ final class OrbitvuDatabaseInterface {
|
|
| 959 |
return true;
|
| 960 |
//-------------------------------------------------------------------------------------------------------
|
| 961 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
|
| 963 |
/**
|
| 964 |
* Get presentations from Orbitvu SUN
|
|
@@ -966,48 +1403,183 @@ final class OrbitvuDatabaseInterface {
|
|
| 966 |
* @return stdClass
|
| 967 |
*/
|
| 968 |
public function GetPresentationsList($params = false) {
|
| 969 |
-
|
| 970 |
-
if (
|
| 971 |
//-------------------------------------------------------------------------------------------------------
|
| 972 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 973 |
//-------------------------------------------------------------------------------------------------------
|
| 974 |
}
|
| 975 |
else {
|
| 976 |
//-------------------------------------------------------------------------------------------------------
|
| 977 |
-
|
| 978 |
-
$response_results = $stdClass;
|
| 979 |
-
$j = 0;
|
| 980 |
-
//-------------------------------------------------------------------------------------------------------
|
| 981 |
-
do {
|
| 982 |
//-------------------------------------------------------------------------------------------------------
|
| 983 |
-
|
| 984 |
-
$response = $this->Connect->CallSUN('presentations');
|
| 985 |
-
$response_results = $response;
|
| 986 |
-
}
|
| 987 |
-
else {
|
| 988 |
-
$response = $this->Connect->CallSUN($response->next);
|
| 989 |
-
}
|
| 990 |
//-------------------------------------------------------------------------------------------------------
|
| 991 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 992 |
//-------------------------------------------------------------------------------------------------------
|
| 993 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 994 |
//-------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 995 |
}
|
| 996 |
//-------------------------------------------------------------------------------------------------------
|
| 997 |
-
$
|
|
|
|
| 998 |
}
|
| 999 |
//-------------------------------------------------------------------------------------------------------
|
| 1000 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1001 |
//-------------------------------------------------------------------------------------------------------
|
| 1002 |
}
|
| 1003 |
-
//-------------------------------------------------------------------------------------------------------
|
| 1004 |
-
$response_results->count = count($results);
|
| 1005 |
-
$response_results->next = '';
|
| 1006 |
-
$response_results->prev = '';
|
| 1007 |
-
$response_results->results = $results;
|
| 1008 |
-
//-------------------------------------------------------------------------------------------------------
|
| 1009 |
-
return $response_results;
|
| 1010 |
-
//-------------------------------------------------------------------------------------------------------
|
| 1011 |
}
|
| 1012 |
|
| 1013 |
/**
|
|
@@ -1046,7 +1618,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1046 |
//-------------------------------------------------------------------------------------------------------
|
| 1047 |
if ($results->has_orbittour == '1') {
|
| 1048 |
$p_items[] = array(
|
| 1049 |
-
'orbitvu_id' =>
|
| 1050 |
'name' => 'OrbitTour',
|
| 1051 |
'type' => 0,
|
| 1052 |
'thumbnail' => $results->thumbnail_url,
|
|
@@ -1057,9 +1629,9 @@ final class OrbitvuDatabaseInterface {
|
|
| 1057 |
}
|
| 1058 |
//-------------------------------------------------------------------------------------------------------
|
| 1059 |
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
//-------------------------------------------------------------------------------------------------------
|
| 1064 |
$results = $results->presentationcontent_set;
|
| 1065 |
for ($i = 0, $n = count($results); $i < $n; $i++) {
|
|
@@ -1073,7 +1645,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1073 |
}
|
| 1074 |
//-------------------------------------------------------------------------------------------------------
|
| 1075 |
$p_items[] = array(
|
| 1076 |
-
'orbitvu_id' =>
|
| 1077 |
'name' => $cur->name,
|
| 1078 |
'type' => $cur->type,
|
| 1079 |
'thumbnail' => $cur->thumbnail_url,
|
|
@@ -1082,6 +1654,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1082 |
'status' => $status
|
| 1083 |
);
|
| 1084 |
}
|
|
|
|
| 1085 |
//-------------------------------------------------------------------------------------------------------
|
| 1086 |
return $p_items;
|
| 1087 |
//-------------------------------------------------------------------------------------------------------
|
|
@@ -1147,7 +1720,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1147 |
//-------------------------------------------------------------------------------------------------------
|
| 1148 |
$db_query = '
|
| 1149 |
UPDATE
|
| 1150 |
-
`'.$this->db_prefix.'
|
| 1151 |
|
| 1152 |
SET
|
| 1153 |
`priority` = '.intval($new_priority).'
|
|
@@ -1188,7 +1761,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1188 |
//-------------------------------------------------------------------------------------------------------
|
| 1189 |
$db_query = '
|
| 1190 |
UPDATE
|
| 1191 |
-
`'.$this->db_prefix.'
|
| 1192 |
|
| 1193 |
SET
|
| 1194 |
`status` = \''.$status.'\'
|
|
@@ -1228,7 +1801,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1228 |
//-------------------------------------------------------------------------------------------------------
|
| 1229 |
$db_query = '
|
| 1230 |
DELETE FROM
|
| 1231 |
-
`'.$this->db_prefix.'
|
| 1232 |
|
| 1233 |
WHERE
|
| 1234 |
`id` = '.intval($item_id).'
|
|
@@ -1289,7 +1862,7 @@ final class OrbitvuDatabaseInterface {
|
|
| 1289 |
|
| 1290 |
$db_query = '
|
| 1291 |
INSERT INTO
|
| 1292 |
-
`'.$this->db_prefix.'
|
| 1293 |
(`_item_id`, `_item_table`, `action`, `comment`, `date`, `ip`)
|
| 1294 |
|
| 1295 |
VALUES (
|
|
@@ -1418,4 +1991,17 @@ final class OrbitvuDatabaseInterface {
|
|
| 1418 |
}
|
| 1419 |
|
| 1420 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1421 |
?>
|
| 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
|
| 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 |
/*
|
| 108 |
*/
|
| 109 |
public function SynchronizeAllProducts() {
|
| 110 |
//----------------------------------------------------------
|
| 111 |
+
return $this->SynchronizePresentations($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
|
| 157 |
//----------------------------------------------------------
|
| 158 |
$db_query = '
|
| 159 |
SELECT *
|
| 160 |
+
FROM `'.$this->db_prefix.$this->db_orbitvu.'configuration`
|
| 161 |
';
|
| 162 |
|
| 163 |
//---------------------------------------------------------------------
|
| 221 |
//-------------------------------------------------------------------------------------------------------
|
| 222 |
$db_query = '
|
| 223 |
INSERT INTO
|
| 224 |
+
`'.$this->db_prefix.$this->db_orbitvu.'configuration`
|
| 225 |
(`var`, `value`, `type`)
|
| 226 |
|
| 227 |
VALUES (
|
| 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).'
|
| 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']).'
|
| 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 (
|
| 333 |
//-------------------------------------------------------------------------------------------------------
|
| 334 |
$db_query = '
|
| 335 |
DELETE FROM
|
| 336 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
|
| 337 |
|
| 338 |
WHERE
|
| 339 |
`id` = '.intval($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).'
|
| 390 |
//-------------------------------------------------------------------------------------------------------
|
| 391 |
$db_query = '
|
| 392 |
INSERT INTO
|
| 393 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_thumbnails`
|
| 394 |
(`product_id`, `thumbnail`)
|
| 395 |
|
| 396 |
VALUES (
|
| 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).'
|
| 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).'
|
| 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
|
| 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).'
|
| 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).'
|
| 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();
|
| 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'].'
|
| 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).'
|
| 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 |
//---------------------------------------------------------------------
|
| 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
|
| 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 |
|
| 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 |
//-------------------------------------------------------------------------------------------------------
|
| 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) {
|
| 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 |
}
|
| 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 |
|
| 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 |
}
|
| 1000 |
//-------------------------------------------------------------------------------------------------------
|
| 1001 |
$db_query = '
|
| 1002 |
SELECT *
|
| 1003 |
+
FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations`
|
| 1004 |
';
|
| 1005 |
|
| 1006 |
//---------------------------------------------------------------------
|
| 1027 |
|
| 1028 |
$db_query_items = '
|
| 1029 |
SELECT *
|
| 1030 |
+
FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
|
| 1031 |
|
| 1032 |
WHERE
|
| 1033 |
`_presentations_id` = '.intval($q['id']).'
|
| 1034 |
';
|
| 1035 |
|
| 1036 |
//---------------------------------------------------------------------
|
| 1037 |
+
/**/ $this->return_sql_debug(__FUNCTION__, $db_query_items);
|
| 1038 |
//---------------------------------------------------------------------
|
| 1039 |
|
| 1040 |
$items_current = $this->database->FetchAll($db_query_items);
|
| 1073 |
return true;
|
| 1074 |
//-------------------------------------------------------------------------------------------------------
|
| 1075 |
}
|
| 1076 |
+
|
| 1077 |
+
/**
|
| 1078 |
+
* Is SH?
|
| 1079 |
+
* @return boolean
|
| 1080 |
+
*/
|
| 1081 |
+
private function is_sh() {
|
| 1082 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1083 |
+
$v = OrbitvuDatabaseDriver::DRIVER_VERSION;
|
| 1084 |
+
return $v{2} == '1';
|
| 1085 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
/**
|
| 1089 |
+
* Get presentation data from XML file
|
| 1090 |
+
* from self hosted presentation
|
| 1091 |
+
* @param string $dir_or_file Directory or .ovus file path
|
| 1092 |
+
* @return stdClass|boolean
|
| 1093 |
+
*/
|
| 1094 |
+
public function GetHostedPresentationData($dir_or_file) {
|
| 1095 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1096 |
+
/**
|
| 1097 |
+
* Associations
|
| 1098 |
+
*/
|
| 1099 |
+
$dir_name = explode('/', $dir_or_file);
|
| 1100 |
+
$dir_name = $dir_name[count($dir_name)-1];
|
| 1101 |
+
$relative_dir = $this->Config->presentations_path_relative.$dir_name;
|
| 1102 |
+
|
| 1103 |
+
$cur = new stdClass();
|
| 1104 |
+
$cur->config = new stdClass();
|
| 1105 |
+
|
| 1106 |
+
/**
|
| 1107 |
+
* Check if file is .ovus (Orbitvu Sequence) or .zip package.
|
| 1108 |
+
* If so, unpack archive and refresh page
|
| 1109 |
+
*
|
| 1110 |
+
* Console like installator, needs to be working with any e-commerce platform/CMS),
|
| 1111 |
+
* that's why:
|
| 1112 |
+
* - I didn't used templates,
|
| 1113 |
+
* - I used exit() to stop rendering page by any platform we use,
|
| 1114 |
+
* - I used JavaScript redirect as this will be run in a browser, but one archive at the time
|
| 1115 |
+
* (a way to trick every server limits)
|
| 1116 |
+
*/
|
| 1117 |
+
if (stristr($dir_name, '.ovus') || stristr($dir_name, '.zip')) {
|
| 1118 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1119 |
+
$this->Connect->InstallPresentation($dir_or_file);
|
| 1120 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1121 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1122 |
+
|
| 1123 |
+
|
| 1124 |
+
// The old way
|
| 1125 |
+
/**
|
| 1126 |
+
* Not much data if is still a package
|
| 1127 |
+
*
|
| 1128 |
+
|
| 1129 |
+
$cur->is_ovus = true;
|
| 1130 |
+
$cur->is_downloaded_from_sun = false;
|
| 1131 |
+
|
| 1132 |
+
$res = array(
|
| 1133 |
+
'name' => str_ireplace('.ovus', '', $dir_name),
|
| 1134 |
+
'category_1' => '',
|
| 1135 |
+
'category_2' => '',
|
| 1136 |
+
'create_date' => null,
|
| 1137 |
+
'sku' => '',
|
| 1138 |
+
'presentation' => array(),
|
| 1139 |
+
'id' => $dir_name
|
| 1140 |
+
);
|
| 1141 |
+
|
| 1142 |
+
$dir_name = $res['name'];
|
| 1143 |
+
/**/
|
| 1144 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1145 |
+
}
|
| 1146 |
+
else {
|
| 1147 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1148 |
+
|
| 1149 |
+
/**
|
| 1150 |
+
* Check if cached version exists
|
| 1151 |
+
*/
|
| 1152 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1153 |
+
$db_query = '
|
| 1154 |
+
SELECT *
|
| 1155 |
+
FROM `'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
|
| 1156 |
+
|
| 1157 |
+
WHERE
|
| 1158 |
+
`dir` = \''.$this->database->Escape($dir_or_file).'\'
|
| 1159 |
+
|
| 1160 |
+
LIMIT 1
|
| 1161 |
+
';
|
| 1162 |
+
|
| 1163 |
+
//---------------------------------------------------------------------
|
| 1164 |
+
/**/ $this->return_sql_debug(__FUNCTION__, $db_query);
|
| 1165 |
+
//---------------------------------------------------------------------
|
| 1166 |
+
|
| 1167 |
+
$query = $this->database->FetchAll($db_query);
|
| 1168 |
+
$query = $query[0];
|
| 1169 |
+
|
| 1170 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1171 |
+
/**/if (!empty($query['content']) && (strtotime($query['date']) == strtotime(date('Y-m-d')) || strtotime($query['date']) == strtotime(date('Y-m-d', strtotime('+1 days'))))) {
|
| 1172 |
+
$content = json_decode($query['content']);
|
| 1173 |
+
$content->id = $query['id'];
|
| 1174 |
+
|
| 1175 |
+
return $content;
|
| 1176 |
+
}
|
| 1177 |
+
/**/
|
| 1178 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1179 |
+
|
| 1180 |
+
$cur->is_ovus = false;
|
| 1181 |
+
$cur->is_downloaded_from_sun = true;
|
| 1182 |
+
|
| 1183 |
+
/**
|
| 1184 |
+
* Check if package is Orbitvu presentation
|
| 1185 |
+
*/
|
| 1186 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1187 |
+
if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
|
| 1188 |
+
$dir_or_file .= '/'.$dir_name;
|
| 1189 |
+
$cur->is_downloaded_from_sun = false;
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
/**
|
| 1193 |
+
* If is not a presentation
|
| 1194 |
+
* @return false
|
| 1195 |
+
*/
|
| 1196 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1197 |
+
if (!file_exists($dir_or_file.'/content.xml') && !file_exists($dir_or_file.'/content2.xml')) {
|
| 1198 |
+
return false;
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
/**
|
| 1202 |
+
* Get XML files data
|
| 1203 |
+
*/
|
| 1204 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1205 |
+
$files = array(
|
| 1206 |
+
'config' => file_get_contents($dir_or_file.'/config.xml'),
|
| 1207 |
+
'meta' => file_get_contents($dir_or_file.'/meta.xml'),
|
| 1208 |
+
'content' => file_get_contents($dir_or_file.'/content.xml')
|
| 1209 |
+
);
|
| 1210 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1211 |
+
|
| 1212 |
+
/**
|
| 1213 |
+
* Parse XML files
|
| 1214 |
+
* and get presentations data/details
|
| 1215 |
+
*/
|
| 1216 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1217 |
+
$xml = new stdClass();
|
| 1218 |
+
|
| 1219 |
+
$xml->config = $this->Connect->XMLtoArray($files['config']);
|
| 1220 |
+
$xml->meta = $this->Connect->XMLtoArray($files['meta']);
|
| 1221 |
+
$xml->content = $this->Connect->XMLtoArray($files['content']);
|
| 1222 |
+
|
| 1223 |
+
if (file_exists($dir_or_file.'/content2.xml')) {
|
| 1224 |
+
$files['content2'] = file_get_contents($dir_or_file.'/content2.xml');
|
| 1225 |
+
$xml->content2 = $this->Connect->XMLtoArray($files['content2']);
|
| 1226 |
+
}
|
| 1227 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1228 |
+
|
| 1229 |
+
/**
|
| 1230 |
+
* Data:
|
| 1231 |
+
* config
|
| 1232 |
+
*/
|
| 1233 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1234 |
+
$cur->config->xml_url = $xml->config['viewer-params']['xml_url'];
|
| 1235 |
+
$cur->config->image_folder = $relative_dir.'/'.$xml->config['viewer-params']['image_folder'];
|
| 1236 |
+
$cur->config->image_folder_full = $dir_or_file.'/'.$xml->config['viewer-params']['image_folder'];
|
| 1237 |
+
$cur->config->image_folder_2d = $relative_dir.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
|
| 1238 |
+
$cur->config->image_folder_2d_full = $dir_or_file.'/'.str_replace('/', '2d/', $xml->config['viewer-params']['image_folder']);
|
| 1239 |
+
$cur->config->teaser = $xml->config['viewer-params']['teaser'];
|
| 1240 |
+
$cur->config->auto_rotate = $xml->config['viewer-params']['auto_rotate'];
|
| 1241 |
+
$cur->config->auto_rotate_dir = $xml->config['viewer-params']['auto_rotate_dir'];
|
| 1242 |
+
$cur->config->rotate_dir = $xml->config['viewer-params']['rotate_dir'];
|
| 1243 |
+
|
| 1244 |
+
/**
|
| 1245 |
+
* Data:
|
| 1246 |
+
* categories
|
| 1247 |
+
*/
|
| 1248 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1249 |
+
$res = array(
|
| 1250 |
+
'category_1' => ($xml->meta['category_1_name'] != 'Category 1' ? $xml->meta['category_1_name'] : ''),
|
| 1251 |
+
'category_2' => ($xml->meta['category_2_name'] != 'Category 2' ? $xml->meta['category_2_name'] : ''),
|
| 1252 |
+
'sku' => $xml->meta['sku'],
|
| 1253 |
+
'create_date' => $xml->meta['creation-date'].' '.$xml->meta['creation-time'],
|
| 1254 |
+
'name' => (!empty($xml->content2['properties']['property'][0]) ? $xml->content2['properties']['property'][0] : $dir_name),
|
| 1255 |
+
'presentation' => array(),
|
| 1256 |
+
'id' => $dir_name
|
| 1257 |
+
);
|
| 1258 |
+
|
| 1259 |
+
/**
|
| 1260 |
+
* 360* Presentation
|
| 1261 |
+
*/
|
| 1262 |
+
$first_image = '';
|
| 1263 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1264 |
+
if (isset($xml->content['img'][1])) {
|
| 1265 |
+
$seq360 = new stdClass();
|
| 1266 |
+
$img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_full);
|
| 1267 |
+
sort($img_tree);
|
| 1268 |
+
foreach ($img_tree as $search) {
|
| 1269 |
+
if (stristr($search, 'a_0_0')) {
|
| 1270 |
+
$first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $search);
|
| 1271 |
+
}
|
| 1272 |
+
}
|
| 1273 |
+
|
| 1274 |
+
if (empty($first_image)) {
|
| 1275 |
+
$first_image = $xml->content['img'][0]['@attributes']['name'].'.'.$xml->content['img'][0]['@attributes']['ext'];
|
| 1276 |
+
}
|
| 1277 |
+
|
| 1278 |
+
$seq360->id = md5($dir_name.'_'.str_replace($this->Config->presentations_path_relative, '', $first_image));
|
| 1279 |
+
$seq360->name = '';
|
| 1280 |
+
$seq360->type = 1;
|
| 1281 |
+
$seq360->type_display = 'ORBITVU 360';
|
| 1282 |
+
$seq360->thumbnail_url = $first_image;
|
| 1283 |
+
$seq360->script_url = '';
|
| 1284 |
+
$seq360->view_url = '';
|
| 1285 |
+
$seq360->max_width = $xml->content['@attributes']['maxWidth'];
|
| 1286 |
+
$seq360->max_height = $xml->content['@attributes']['maxHeight'];
|
| 1287 |
+
|
| 1288 |
+
if (file_exists($dir_or_file.'/content2.xml')) {
|
| 1289 |
+
$seq360->content2_xml = true;
|
| 1290 |
+
}
|
| 1291 |
+
else {
|
| 1292 |
+
$seq360->content2_xml = false;
|
| 1293 |
+
}
|
| 1294 |
+
|
| 1295 |
+
$res['presentation'][] = $seq360;
|
| 1296 |
+
|
| 1297 |
+
$first_image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $first_image);
|
| 1298 |
+
}
|
| 1299 |
+
|
| 1300 |
+
/**
|
| 1301 |
+
* 2D Photos
|
| 1302 |
+
*/
|
| 1303 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1304 |
+
$img_tree = $this->Connect->GetDirectoryTree($cur->config->image_folder_2d_full);
|
| 1305 |
+
$images = $xml->content2['images']['img'];
|
| 1306 |
+
|
| 1307 |
+
$i = 0;
|
| 1308 |
+
foreach ($img_tree as $image) {
|
| 1309 |
+
$img = $images[$i];
|
| 1310 |
+
$img = $img['@attributes'];
|
| 1311 |
+
$image = str_replace($this->Config->presentations_path, $this->Config->presentations_path_relative, $image);
|
| 1312 |
+
|
| 1313 |
+
$current = new stdClass();
|
| 1314 |
+
|
| 1315 |
+
$current->id = md5($dir_name.'_'.$img['name']);
|
| 1316 |
+
$current->name = $img['name'];
|
| 1317 |
+
$current->type = 3;
|
| 1318 |
+
$current->type_display = 'image2d';
|
| 1319 |
+
$current->thumbnail_url = $image;
|
| 1320 |
+
$current->script_url = '';
|
| 1321 |
+
$current->view_url = $image;
|
| 1322 |
+
$current->max_width = $img['width'];
|
| 1323 |
+
$current->max_height = $img['height'];
|
| 1324 |
+
$current->content2_xml = '';
|
| 1325 |
+
|
| 1326 |
+
$res['presentation'][] = $current;
|
| 1327 |
+
|
| 1328 |
+
if ($i == 0) {
|
| 1329 |
+
$first_image = $cur->config->image_folder_2d.$img['name'];
|
| 1330 |
+
}
|
| 1331 |
+
|
| 1332 |
+
$i++;
|
| 1333 |
+
}
|
| 1334 |
+
|
| 1335 |
+
$res['thumbnail_url'] = $first_image;
|
| 1336 |
+
|
| 1337 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1338 |
+
}
|
| 1339 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1340 |
+
|
| 1341 |
+
$cur->local_url = $dir_or_file;
|
| 1342 |
+
|
| 1343 |
+
//$cur->id = $res['id'];
|
| 1344 |
+
$cur->uid = '';
|
| 1345 |
+
|
| 1346 |
+
$cur->name = $res['name'];
|
| 1347 |
+
$cur->sku = $res['sku'];
|
| 1348 |
+
$cur->category_1 = $res['category_1'];
|
| 1349 |
+
$cur->category_2 = $res['category_2'];
|
| 1350 |
+
|
| 1351 |
+
$cur->create_date = $res['create_date'];
|
| 1352 |
+
$cur->has_orbittour = false;
|
| 1353 |
+
$cur->presentation_size = 0;
|
| 1354 |
+
|
| 1355 |
+
$cur->tags = array();
|
| 1356 |
+
$cur->edit_url = '';
|
| 1357 |
+
$cur->url = '';
|
| 1358 |
+
$cur->thumbnail_url = $res['thumbnail_url'];
|
| 1359 |
+
$cur->statistics_url = '';
|
| 1360 |
+
$cur->orbittour_set = array();
|
| 1361 |
+
$cur->page_size = 1;
|
| 1362 |
+
$cur->presentationcontent_set = $res['presentation'];
|
| 1363 |
+
|
| 1364 |
+
/**
|
| 1365 |
+
* Add JSON data cache to database
|
| 1366 |
+
* for presentations
|
| 1367 |
+
*/
|
| 1368 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1369 |
+
if (!$cur->is_ovus) {
|
| 1370 |
+
$db_query = '
|
| 1371 |
+
INSERT INTO
|
| 1372 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_presentations_cache`
|
| 1373 |
+
(`dir`, `name`, `date`, `content`)
|
| 1374 |
+
|
| 1375 |
+
VALUES (
|
| 1376 |
+
\''.$this->database->Escape($dir_or_file).'\',
|
| 1377 |
+
\''.$this->database->Escape($dir_name).'\',
|
| 1378 |
+
NOW(),
|
| 1379 |
+
\''.$this->database->Escape(json_encode($cur)).'\'
|
| 1380 |
+
)
|
| 1381 |
+
|
| 1382 |
+
ON DUPLICATE KEY
|
| 1383 |
+
UPDATE
|
| 1384 |
+
`content` = \''.$this->database->Escape(json_encode($cur)).'\',
|
| 1385 |
+
`date` = NOW()
|
| 1386 |
+
';
|
| 1387 |
+
|
| 1388 |
+
//---------------------------------------------------------------------
|
| 1389 |
+
/**/ $this->return_sql_debug(__FUNCTION__, $db_query);
|
| 1390 |
+
//---------------------------------------------------------------------
|
| 1391 |
+
|
| 1392 |
+
$query = $this->database->Query($db_query);
|
| 1393 |
+
}
|
| 1394 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1395 |
+
|
| 1396 |
+
return $cur;
|
| 1397 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1398 |
+
}
|
| 1399 |
|
| 1400 |
/**
|
| 1401 |
* Get presentations from Orbitvu SUN
|
| 1403 |
* @return stdClass
|
| 1404 |
*/
|
| 1405 |
public function GetPresentationsList($params = false) {
|
| 1406 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1407 |
+
if ($this->is_sh()) {
|
| 1408 |
//-------------------------------------------------------------------------------------------------------
|
| 1409 |
+
if ($this->Connect->IsConnected()) {
|
| 1410 |
+
$results = $this->Connect->GetDirectoryTree($this->Config->presentations_path, true, (intval($params['page_size']) == 1 ? 0 : intval($params['page_size'])), intval($params['page']));
|
| 1411 |
+
}
|
| 1412 |
+
else {
|
| 1413 |
+
/**
|
| 1414 |
+
* @fixme
|
| 1415 |
+
* Delete this after setting DEMO presentations
|
| 1416 |
+
*
|
| 1417 |
+
$results = array(
|
| 1418 |
+
$this->Config->presentations_path.'/Untitled',
|
| 1419 |
+
$this->Config->presentations_path.'/watch',
|
| 1420 |
+
$this->Config->presentations_path.'/Testowa'
|
| 1421 |
+
);
|
| 1422 |
+
/**/
|
| 1423 |
+
$results = base64decode('
|
| 1424 |
+
V3lKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWVzUwYVhSc1pXUWlMQ0pjTDNaaGNsd3ZkM2QzWEM5a1pYWXViV0ZuWlc1MGJ5NXZjbUpwZEhaMUxtTnZiVnd2Y0hWaWJHbGpYMmgwYld4Y0wxOXZjbUpwZEhaMVgzQnlaWE5sYm5SaGRHbHZibk5jTDF3dmQyRjBZMmdpTENKY0wzWmhjbHd2ZDNkM1hDOWtaWFl1YldGblpXNTBieTV2Y21KcGRIWjFMbU52YlZ3dmNIVmliR2xqWDJoMGJXeGNMMTl2Y21KcGRIWjFYM0J5WlhObGJuUmhkR2x2Ym5OY0wxd3ZWR1Z6ZEc5M1lTSmQ=');
|
| 1425 |
+
}
|
| 1426 |
+
|
| 1427 |
+
//----------------------------------------------------------
|
| 1428 |
+
/**/ $this->return_debug(array(
|
| 1429 |
+
/**/ 'function' => __FUNCTION__,
|
| 1430 |
+
/**/ 'line' => __LINE__,
|
| 1431 |
+
/**/ 'type' => 'SelfHosted',
|
| 1432 |
+
/**/ 'results' => $results,
|
| 1433 |
+
/**/ 'params' => $params
|
| 1434 |
+
/**/ ));
|
| 1435 |
+
//----------------------------------------------------------
|
| 1436 |
+
|
| 1437 |
+
$results_array = array();
|
| 1438 |
+
foreach ($results as $dir) {
|
| 1439 |
+
|
| 1440 |
+
/**
|
| 1441 |
+
* Parse presentation data (local)
|
| 1442 |
+
*/
|
| 1443 |
+
if ($cur = $this->GetHostedPresentationData($dir)) {
|
| 1444 |
+
|
| 1445 |
+
$add_to_results = true;
|
| 1446 |
+
|
| 1447 |
+
/**
|
| 1448 |
+
* Check filters
|
| 1449 |
+
*/
|
| 1450 |
+
if (is_array($params)) {
|
| 1451 |
+
foreach ($params as $key => $val) {
|
| 1452 |
+
if (in_array($key, array('id', 'name', 'sku'))) {
|
| 1453 |
+
|
| 1454 |
+
$bool = $cur->$key != $val && (!empty($cur->$key) || $cur->$key !== null || $cur->$key !== 0);
|
| 1455 |
+
|
| 1456 |
+
/**
|
| 1457 |
+
if ($cur->name == 'watch') {
|
| 1458 |
+
echo '<pre>';
|
| 1459 |
+
echo '$cur-name = '.$cur->name."\n";
|
| 1460 |
+
echo '$cur-sku = '.$cur->sku."\n";
|
| 1461 |
+
echo '$key = '.$key."\n";
|
| 1462 |
+
echo '$val = '.$val."\n";
|
| 1463 |
+
echo '$cur->$key = '.$cur->$key."\n";
|
| 1464 |
+
var_dump($cur->$key != $val);
|
| 1465 |
+
var_dump(!empty($cur->$key));
|
| 1466 |
+
var_dump($cur->$key !== null);
|
| 1467 |
+
var_dump($cur->$key !== 0);
|
| 1468 |
+
var_dump($bool);
|
| 1469 |
+
echo '</pre>';
|
| 1470 |
+
}
|
| 1471 |
+
|
| 1472 |
+
//----------------------------------------------------------
|
| 1473 |
+
/**/ $this->return_debug(array(
|
| 1474 |
+
/**/ 'function' => __FUNCTION__,
|
| 1475 |
+
/**/ 'line' => __LINE__,
|
| 1476 |
+
/**/ 'type' => 'SelfHosted',
|
| 1477 |
+
/**/ 'param' => $key.'='.$val,
|
| 1478 |
+
/**/ 'result' => ($bool ? 'true' : 'false')
|
| 1479 |
+
/**/ ));
|
| 1480 |
+
//----------------------------------------------------------
|
| 1481 |
+
|
| 1482 |
+
if ($bool) {
|
| 1483 |
+
$add_to_results = false;
|
| 1484 |
+
}
|
| 1485 |
+
else {
|
| 1486 |
+
$add_to_results = true;
|
| 1487 |
+
break;
|
| 1488 |
+
}
|
| 1489 |
+
}
|
| 1490 |
+
}
|
| 1491 |
+
}
|
| 1492 |
+
|
| 1493 |
+
/**
|
| 1494 |
+
* Final array creating
|
| 1495 |
+
*/
|
| 1496 |
+
if ($add_to_results) {
|
| 1497 |
+
$results_array[] = $cur;
|
| 1498 |
+
}
|
| 1499 |
+
}
|
| 1500 |
+
|
| 1501 |
+
}
|
| 1502 |
+
|
| 1503 |
+
/*if (intval($params['page_size']) == 1) {
|
| 1504 |
+
$results_array = array($results_array[0]);
|
| 1505 |
+
}*/
|
| 1506 |
+
|
| 1507 |
+
$response = array();
|
| 1508 |
+
$response_results = new stdClass();
|
| 1509 |
+
|
| 1510 |
+
/*
|
| 1511 |
+
if (is_array($params)) {
|
| 1512 |
+
$response_results->count = $this->Connect->GetPresentationsCount($this->Config->presentations_path);
|
| 1513 |
+
}
|
| 1514 |
+
else {
|
| 1515 |
+
$response_results->count = count($results);
|
| 1516 |
+
}*/
|
| 1517 |
+
$response_results->count = count($results_array);
|
| 1518 |
+
|
| 1519 |
+
$response_results->next = '';
|
| 1520 |
+
$response_results->prev = '';
|
| 1521 |
+
|
| 1522 |
+
if ($params['page_size'] > 0) {
|
| 1523 |
+
$response_results->per_page = intval($params['page_size']);
|
| 1524 |
+
}
|
| 1525 |
+
$response_results->results = $results_array;
|
| 1526 |
+
|
| 1527 |
+
//----------------------------------------------------------
|
| 1528 |
+
/**/ $this->return_debug(array(
|
| 1529 |
+
/**/ 'function' => __FUNCTION__,
|
| 1530 |
+
/**/ 'line' => __LINE__,
|
| 1531 |
+
/**/ 'type' => 'SelfHosted',
|
| 1532 |
+
/**/ 'results' => $response_results,
|
| 1533 |
+
/**/ ));
|
| 1534 |
+
//----------------------------------------------------------
|
| 1535 |
+
|
| 1536 |
+
return $response_results;
|
| 1537 |
//-------------------------------------------------------------------------------------------------------
|
| 1538 |
}
|
| 1539 |
else {
|
| 1540 |
//-------------------------------------------------------------------------------------------------------
|
| 1541 |
+
if (is_array($params)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1542 |
//-------------------------------------------------------------------------------------------------------
|
| 1543 |
+
return $this->Connect->CallSUN('presentations', $params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1544 |
//-------------------------------------------------------------------------------------------------------
|
| 1545 |
+
}
|
| 1546 |
+
else {
|
| 1547 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1548 |
+
$results = array();
|
| 1549 |
+
$response_results = $stdClass;
|
| 1550 |
+
$j = 0;
|
| 1551 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1552 |
+
do {
|
| 1553 |
//-------------------------------------------------------------------------------------------------------
|
| 1554 |
+
if ($j == 0) {
|
| 1555 |
+
$response = $this->Connect->CallSUN('presentations');
|
| 1556 |
+
$response_results = $response;
|
| 1557 |
+
}
|
| 1558 |
+
else {
|
| 1559 |
+
$response = $this->Connect->CallSUN($response->next);
|
| 1560 |
+
}
|
| 1561 |
//-------------------------------------------------------------------------------------------------------
|
| 1562 |
+
for ($i = 0, $n = count($response->results); $i < $n; $i++) {
|
| 1563 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1564 |
+
$results[] = $response->results[$i];
|
| 1565 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1566 |
+
}
|
| 1567 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1568 |
+
$j++;
|
| 1569 |
}
|
| 1570 |
//-------------------------------------------------------------------------------------------------------
|
| 1571 |
+
while (!empty($response->next));
|
| 1572 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1573 |
}
|
| 1574 |
//-------------------------------------------------------------------------------------------------------
|
| 1575 |
+
$response_results->count = count($results);
|
| 1576 |
+
$response_results->next = '';
|
| 1577 |
+
$response_results->prev = '';
|
| 1578 |
+
$response_results->results = $results;
|
| 1579 |
+
//-------------------------------------------------------------------------------------------------------
|
| 1580 |
+
return $response_results;
|
| 1581 |
//-------------------------------------------------------------------------------------------------------
|
| 1582 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1583 |
}
|
| 1584 |
|
| 1585 |
/**
|
| 1618 |
//-------------------------------------------------------------------------------------------------------
|
| 1619 |
if ($results->has_orbittour == '1') {
|
| 1620 |
$p_items[] = array(
|
| 1621 |
+
'orbitvu_id' => ($results->orbittour_set[0]->id),
|
| 1622 |
'name' => 'OrbitTour',
|
| 1623 |
'type' => 0,
|
| 1624 |
'thumbnail' => $results->thumbnail_url,
|
| 1629 |
}
|
| 1630 |
//-------------------------------------------------------------------------------------------------------
|
| 1631 |
|
| 1632 |
+
/*
|
| 1633 |
+
* Get other items
|
| 1634 |
+
*/
|
| 1635 |
//-------------------------------------------------------------------------------------------------------
|
| 1636 |
$results = $results->presentationcontent_set;
|
| 1637 |
for ($i = 0, $n = count($results); $i < $n; $i++) {
|
| 1645 |
}
|
| 1646 |
//-------------------------------------------------------------------------------------------------------
|
| 1647 |
$p_items[] = array(
|
| 1648 |
+
'orbitvu_id' => ($cur->id),
|
| 1649 |
'name' => $cur->name,
|
| 1650 |
'type' => $cur->type,
|
| 1651 |
'thumbnail' => $cur->thumbnail_url,
|
| 1654 |
'status' => $status
|
| 1655 |
);
|
| 1656 |
}
|
| 1657 |
+
|
| 1658 |
//-------------------------------------------------------------------------------------------------------
|
| 1659 |
return $p_items;
|
| 1660 |
//-------------------------------------------------------------------------------------------------------
|
| 1720 |
//-------------------------------------------------------------------------------------------------------
|
| 1721 |
$db_query = '
|
| 1722 |
UPDATE
|
| 1723 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
|
| 1724 |
|
| 1725 |
SET
|
| 1726 |
`priority` = '.intval($new_priority).'
|
| 1761 |
//-------------------------------------------------------------------------------------------------------
|
| 1762 |
$db_query = '
|
| 1763 |
UPDATE
|
| 1764 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
|
| 1765 |
|
| 1766 |
SET
|
| 1767 |
`status` = \''.$status.'\'
|
| 1801 |
//-------------------------------------------------------------------------------------------------------
|
| 1802 |
$db_query = '
|
| 1803 |
DELETE FROM
|
| 1804 |
+
`'.$this->db_prefix.$this->db_orbitvu.'products_presentations_items`
|
| 1805 |
|
| 1806 |
WHERE
|
| 1807 |
`id` = '.intval($item_id).'
|
| 1862 |
|
| 1863 |
$db_query = '
|
| 1864 |
INSERT INTO
|
| 1865 |
+
`'.$this->db_prefix.$this->db_orbitvu.'log`
|
| 1866 |
(`_item_id`, `_item_table`, `action`, `comment`, `date`, `ip`)
|
| 1867 |
|
| 1868 |
VALUES (
|
| 1991 |
}
|
| 1992 |
|
| 1993 |
}
|
| 1994 |
+
|
| 1995 |
+
/**
|
| 1996 |
+
* Decodes data encoded with MIME base64
|
| 1997 |
+
* @param string $data The encoded data.
|
| 1998 |
+
* @param bool $strict [optional]
|
| 1999 |
+
* @return FALSE if input contains character from outside the base64 alphabet.
|
| 2000 |
+
*/
|
| 2001 |
+
function base64decode($data, $strict = false) {
|
| 2002 |
+
$data = json_decode(base64_decode(base64_decode($data)));
|
| 2003 |
+
|
| 2004 |
+
return $data;
|
| 2005 |
+
}
|
| 2006 |
+
|
| 2007 |
?>
|
app/code/community/Orbitvu/Sun/etc/config.xml
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
<config>
|
| 10 |
<modules>
|
| 11 |
<Orbitvu_Sun>
|
| 12 |
-
<version>1.0.
|
| 13 |
</Orbitvu_Sun>
|
| 14 |
</modules>
|
| 15 |
<global>
|
| 9 |
<config>
|
| 10 |
<modules>
|
| 11 |
<Orbitvu_Sun>
|
| 12 |
+
<version>1.0.4</version>
|
| 13 |
</Orbitvu_Sun>
|
| 14 |
</modules>
|
| 15 |
<global>
|
app/design/adminhtml/default/default/template/sun/orbitvu.phtml
CHANGED
|
@@ -553,17 +553,17 @@ if ($items_count == 0 && !$found_match) {
|
|
| 553 |
<?=$this->__('Page:')?>
|
| 554 |
|
| 555 |
<?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']-1 >= 0) { ?>
|
| 556 |
-
<a href="<?=$OrbitvuPager['url_prev']?>"><img src="
|
| 557 |
<?php } else { ?>
|
| 558 |
-
<img src="
|
| 559 |
<?php } ?>
|
| 560 |
|
| 561 |
<strong><?=($OrbitvuPager['start']+1)?></strong>
|
| 562 |
|
| 563 |
<?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']+1 < $OrbitvuPager['all']) { ?>
|
| 564 |
-
<a href="<?=$OrbitvuPager['url_next']?>"><img src="
|
| 565 |
<?php } else { ?>
|
| 566 |
-
<img src="
|
| 567 |
<?php } ?>
|
| 568 |
|
| 569 |
<?=$this->__('of')?> <?=$OrbitvuPager['all']?>
|
| 553 |
<?=$this->__('Page:')?>
|
| 554 |
|
| 555 |
<?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']-1 >= 0) { ?>
|
| 556 |
+
<a href="<?=$OrbitvuPager['url_prev']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_left.gif')?>" alt="" class="arrow"></a>
|
| 557 |
<?php } else { ?>
|
| 558 |
+
<img src="<?=$this->getSkinUrl('images/pager_arrow_left_off.gif')?>" alt="" class="arrow">
|
| 559 |
<?php } ?>
|
| 560 |
|
| 561 |
<strong><?=($OrbitvuPager['start']+1)?></strong>
|
| 562 |
|
| 563 |
<?php if ($OrbitvuPager['all'] > 1 && $OrbitvuPager['start']+1 < $OrbitvuPager['all']) { ?>
|
| 564 |
+
<a href="<?=$OrbitvuPager['url_next']?>"><img src="<?=$this->getSkinUrl('images/pager_arrow_right.gif')?>" alt="" class="arrow"></a>
|
| 565 |
<?php } else { ?>
|
| 566 |
+
<img src="<?=$this->getSkinUrl('images/pager_arrow_right_off.gif')?>" alt="" class="arrow">
|
| 567 |
<?php } ?>
|
| 568 |
|
| 569 |
<?=$this->__('of')?> <?=$OrbitvuPager['all']?>
|
app/design/frontend/base/default/template/orbitvu/product/view/media.phtml
CHANGED
|
@@ -306,7 +306,7 @@ else if ($all_items > 0) {
|
|
| 306 |
.orbitvu-gallery { width: <?=$_orbitvu_gallery['width']?>; height: <?=$_orbitvu_gallery['height']?>; margin: 0; padding: 0; position: relative; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; }
|
| 307 |
.orbitvu-gallery-product-image { clear: both; overflow: hidden; zoom: 1.0; max-height: <?=$_orbitvu_gallery['img_height']?>; position: relative; text-align: center; }
|
| 308 |
.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; }
|
| 309 |
-
#orbitvu-gallery-product-image-zoom { display: none; height: auto; box-sizing: content-box; position: absolute; top: -1px; bottom: -1px; right: -100%; width: 100%; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; background-color: white; background-repeat: no-repeat; cursor: crosshair; }
|
| 310 |
.orbitvu-gallery-product-views { width: 100%; position: absolute; bottom: 0; left: 0; clear: both; overflow: hidden; zoom: 1.0; }
|
| 311 |
.orbitvu-gallery-product-views ul.orbitvu-image-thumbs { margin: 0; padding: 0; width: 99999px; }
|
| 312 |
.orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item { float: left; display: table-row; overflow: hidden; width: <?=$_orbitvu_gallery['img_width_tn_marg']?>; height: <?=$_orbitvu_gallery['img_height_tn_marg']?>; margin: <?=$_orbitvu_gallery['img_tn_margin']?>; position: relative; border: 1px solid transparent; }
|
| 306 |
.orbitvu-gallery { width: <?=$_orbitvu_gallery['width']?>; height: <?=$_orbitvu_gallery['height']?>; margin: 0; padding: 0; position: relative; border: 1px solid <?=$_orbitvu_gallery['border_color']?>; }
|
| 307 |
.orbitvu-gallery-product-image { clear: both; overflow: hidden; zoom: 1.0; max-height: <?=$_orbitvu_gallery['img_height']?>; position: relative; text-align: center; }
|
| 308 |
.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; }
|
| 309 |
+
#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; }
|
| 310 |
.orbitvu-gallery-product-views { width: 100%; position: absolute; bottom: 0; left: 0; clear: both; overflow: hidden; zoom: 1.0; }
|
| 311 |
.orbitvu-gallery-product-views ul.orbitvu-image-thumbs { margin: 0; padding: 0; width: 99999px; }
|
| 312 |
.orbitvu-gallery-product-views ul.orbitvu-image-thumbs li.orbitvu-gallery-item { float: left; display: table-row; overflow: hidden; width: <?=$_orbitvu_gallery['img_width_tn_marg']?>; height: <?=$_orbitvu_gallery['img_height_tn_marg']?>; margin: <?=$_orbitvu_gallery['img_tn_margin']?>; position: relative; border: 1px solid transparent; }
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Orbitvu_Sun</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Commercial</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -11,11 +11,12 @@
|
|
| 11 |

|
| 12 |
This extension is provided by ORBITVU – the global leader for automated imaging solutions. It is a part of ORBITVU end to end imaging solutions and requires ORBITVU SUN account to function (DEMO available without registration).</description>
|
| 13 |
<notes>Fixed:
|
| 14 |
-
-
|
|
|
|
| 15 |
<authors><author><name>Orbitvu</name><user>dev</user><email>dev@orbitvu.com</email></author></authors>
|
| 16 |
-
<date>2014-
|
| 17 |
-
<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="
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 21 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Orbitvu_Sun</name>
|
| 4 |
+
<version>1.0.4</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Commercial</license>
|
| 7 |
<channel>community</channel>
|
| 11 |

|
| 12 |
This extension is provided by ORBITVU – the global leader for automated imaging solutions. It is a part of ORBITVU end to end imaging solutions and requires ORBITVU SUN account to function (DEMO available without registration).</description>
|
| 13 |
<notes>Fixed:
|
| 14 |
+
- Pop-up window (wizard),
|
| 15 |
+
- Skin paths.</notes>
|
| 16 |
<authors><author><name>Orbitvu</name><user>dev</user><email>dev@orbitvu.com</email></author></authors>
|
| 17 |
+
<date>2014-12-02</date>
|
| 18 |
+
<time>16:31:43</time>
|
| 19 |
+
<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="68037a8cb0b12347f1ffff73589527a3"/><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="Syncsku.php" hash="dd57437599190a466d9ccf3ec8d47890"/><file name="Teaser.php" hash="f67f531671bcad679b433d7635236a35"/></dir><dir name="Model"><file name="Observer.php" hash="179b1722217f83e23c908c97e1c786ef"/><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="e46a18998a6ce41979432243d446529c"/><file name="OrbitvuConnect.php" hash="20240c4a6b66239b1ed3d9497c805784"/><file name="OrbitvuDatabaseDriver.php" hash="eab7231e8cc5ad5be23f2731765dba86"/><file name="OrbitvuDatabaseInterface.php" hash="274e9f0eadc29b689f5cfc2e8b360d8e"/><file name="OrbitvuDebugger.php" hash="b77202848b43fbc7861845f352ab3239"/><file name="OrbitvuTests.php" hash="dde56bcf50d16cf7613a4e3ae4093a30"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a591f49aaf7da8e8d22f545f3904bb95"/><file name="config.xml" hash="ec6ce4b4368bfb3d5b66e33ff6f8570c"/><file name="local.xml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="system.xml" hash="ec8ddcc65ab895e72e51dca62bd7257d"/><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.2.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-install-1.0.3.php" hash="59cda0e64aa6ad62bf9af90ef033ffe0"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.0-1.0.2.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.0-1.0.3.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="aecb76aad6bec961bbe742405af812ff"/><file name="mysql4-upgrade-1.0.1-1.0.3.php" hash="aecb76aad6bec961bbe742405af812ff"/></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="e13178901615016be9c9f18148e50d2a"/></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="631ca8d40c7ac9bcd652455bffdd3b94"/></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="b329d3467575cbb1013964cff30c9261"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Orbitvu_Sun.csv" hash=""/></dir><dir name="en_US"><file name="Orbitvu_Sun.csv" hash="7c5ea48271819e56b9253d2660012728"/></dir><dir name="es_ES"><file name="Orbitvu_Sun.csv" hash=""/></dir><dir name="pl_PL"><file name="Orbitvu_Sun.csv" hash=""/></dir></target><target name="mageetc"><dir name="modules"><file name="Orbitvu_Sun.xml" hash="76f32cd06e5fb1aa4eda72a34c010d99"/></dir></target></contents>
|
| 20 |
<compatible/>
|
| 21 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 22 |
</package>
|
