BxBaseStudioStore.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinView Dolphin Studio Representation classes
  7. * @ingroup DolphinStudio
  8. * @{
  9. */
  10. bx_import('BxDolStudioStore');
  11. bx_import('BxTemplStudioFunctions');
  12. class BxBaseStudioStore extends BxDolStudioStore {
  13. protected $iPerPageDefault = 24;
  14. function __construct($sPage = "") {
  15. parent::__construct($sPage);
  16. }
  17. function getPageCss() {
  18. return array_merge(parent::getPageCss(), array('store.css', 'store-media-tablet.css', 'store-media-desktop.css'));
  19. }
  20. function getPageJs() {
  21. return array_merge(parent::getPageJs(), array('jquery.migrate.js', 'jquery.fancybox.js', 'store.js'));
  22. }
  23. function getPageJsObject() {
  24. return 'oBxDolStudioStore';
  25. }
  26. function getPageMenu($aMenu = array(), $aMarkers = array()) {
  27. $sJsObject = $this->getPageJsObject();
  28. $oTemplate = BxDolStudioTemplate::getInstance();
  29. $aMenu = array();
  30. $aMenuItems = array('goodies', 'featured', 'purchases', 'updates', 'checkout', 'downloaded');
  31. foreach($aMenuItems as $sMenuItem)
  32. $aMenu[] = array(
  33. 'name' => $sMenuItem,
  34. 'icon' => 'mi-str-' . $sMenuItem . '.png',
  35. 'link' => BX_DOL_URL_STUDIO . 'store.php?page=' . $sMenuItem,
  36. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  37. 'selected' => $sMenuItem == $this->sPage
  38. );
  39. bx_import('BxDolStudioCart');
  40. $iCounter = BxDolStudioCart::getInstance()->getCount();
  41. $aMarkers = array(
  42. 'checkout_counter' => $oTemplate->parseHtmlByName('menu_side_counter.html', array(
  43. 'bx_if:hide_counter' => array(
  44. 'condition' => $iCounter <= 0,
  45. 'content' => array()
  46. ),
  47. 'counter' => $iCounter
  48. ))
  49. );
  50. return parent::getPageMenu($aMenu, $aMarkers);
  51. }
  52. function getPageCode($bHidden = false) {
  53. $sMethod = 'get' . ucfirst($this->sPage) . 'List';
  54. if(!method_exists($this, $sMethod))
  55. return '';
  56. return $this->$sMethod();
  57. }
  58. function getPageContent() {
  59. $sMethod = 'get' . ucfirst($this->sPage) . 'List';
  60. if(!method_exists($this, $sMethod))
  61. return '';
  62. return $this->$sMethod(false);
  63. }
  64. protected function getGoodiesList() {
  65. $sJsObject = $this->getPageJsObject();
  66. $oTemplate = BxDolStudioTemplate::getInstance();
  67. $aProducts = $this->loadGoodies();
  68. $aTmplVars = array(
  69. 'js_object' => $sJsObject,
  70. 'bx_repeat:blocks' => array()
  71. );
  72. $sActions = "";
  73. foreach($aProducts as $aBlock) {
  74. $sItems = $oTemplate->parseHtmlByName('str_products.html', array(
  75. 'list' => $this->displayProducts($aBlock['items']),
  76. 'paginate' => ''
  77. ));
  78. $aTmplVars['bx_repeat:blocks'][] = array(
  79. 'caption' => $this->getBlockCaption($aBlock),
  80. 'panel_top' => '',
  81. 'items' => $sItems,
  82. 'panel_bottom' => ''
  83. );
  84. }
  85. return $oTemplate->parseHtmlByName('store.html', $aTmplVars);
  86. }
  87. protected function getFeaturedList($bWrapInBlock = true) {
  88. $sJsObject = $this->getPageJsObject();
  89. $oTemplate = BxDolStudioTemplate::getInstance();
  90. $iStart = (int)bx_get('str_start');
  91. $iPerPage = (int)bx_get('str_per_page');
  92. if(empty($iPerPage))
  93. $iPerPage = $this->iPerPageDefault;
  94. $aProducts = $this->loadFeatured($iStart, $iPerPage + 1);
  95. bx_import('BxTemplPaginate');
  96. $oPaginate = new BxTemplPaginate(array(
  97. 'start' => $iStart,
  98. 'per_page' => $iPerPage,
  99. 'on_change_page' => $sJsObject . ".changePagePaginate(this, 'featured', {start}, {per_page})"
  100. ));
  101. $oPaginate->setNumFromDataArray($aProducts);
  102. $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
  103. 'list' => $this->displayProducts($aProducts),
  104. 'paginate' => $oPaginate->getSimplePaginate()
  105. ));
  106. if(!$bWrapInBlock)
  107. return $sContent;
  108. return $oTemplate->parseHtmlByName('store.html', array(
  109. 'js_object' => $sJsObject,
  110. 'bx_repeat:blocks' => array(
  111. array(
  112. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_featured'), 'actions' => array())),
  113. 'panel_top' => '',
  114. 'items' => $sContent,
  115. 'panel_bottom' => ''
  116. )
  117. )
  118. ));
  119. }
  120. protected function getModulesList($bWrapInBlock = true) {
  121. return $this->getTag('modules', $bWrapInBlock);
  122. }
  123. protected function getTemplatesList($bWrapInBlock = true) {
  124. return $this->getTag('templates', $bWrapInBlock);
  125. }
  126. protected function getLanguagesList($bWrapInBlock = true) {
  127. return $this->getTag('languages', $bWrapInBlock);
  128. }
  129. protected function getTag($sTag, $bWrapInBlock = true) {
  130. $sJsObject = $this->getPageJsObject();
  131. $oTemplate = BxDolStudioTemplate::getInstance();
  132. $iStart = (int)bx_get('str_start');
  133. $iPerPage = (int)bx_get('str_per_page');
  134. if(empty($iPerPage))
  135. $iPerPage = $this->iPerPageDefault;
  136. $aProducts = $this->loadTag($sTag, $iStart, $iPerPage + 1);
  137. bx_import('BxTemplPaginate');
  138. $oPaginate = new BxTemplPaginate(array(
  139. 'start' => $iStart,
  140. 'per_page' => $iPerPage,
  141. 'on_change_page' => $sJsObject . ".changePagePaginate(this, '" . $sTag . "', {start}, {per_page})"
  142. ));
  143. $oPaginate->setNumFromDataArray($aProducts);
  144. $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
  145. 'list' => $this->displayProducts($aProducts),
  146. 'paginate' => $oPaginate->getSimplePaginate()
  147. ));
  148. if(!$bWrapInBlock)
  149. return $sContent;
  150. return $oTemplate->parseHtmlByName('store.html', array(
  151. 'js_object' => $sJsObject,
  152. 'bx_repeat:blocks' => array(
  153. array(
  154. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_' . $sTag), 'actions' => array())),
  155. 'panel_top' => '',
  156. 'items' => $sContent,
  157. 'panel_bottom' => ''
  158. )
  159. )
  160. ));
  161. }
  162. protected function getPurchasesList() {
  163. $sJsObject = $this->getPageJsObject();
  164. $oTemplate = BxDolStudioTemplate::getInstance();
  165. $aProducts = $this->loadPurchases();
  166. $aTmplVars = array(
  167. 'js_object' => $sJsObject,
  168. 'bx_repeat:blocks' => array(
  169. array(
  170. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_purchases'), 'actions' => array())),
  171. 'panel_top' => '',
  172. 'items' => $this->displayProducts($aProducts),
  173. 'panel_bottom' => ''
  174. )
  175. )
  176. );
  177. return $oTemplate->parseHtmlByName('store.html', $aTmplVars);
  178. }
  179. protected function getUpdatesList() {
  180. $sJsObject = $this->getPageJsObject();
  181. $oTemplate = BxDolStudioTemplate::getInstance();
  182. $aUpdates = $this->loadUpdates();
  183. $aTmplVars = array(
  184. 'js_object' => $sJsObject,
  185. 'bx_repeat:blocks' => array(
  186. array(
  187. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_updates'), 'actions' => array())),
  188. 'panel_top' => '',
  189. 'items' => $this->displayUpdates($aUpdates),
  190. 'panel_bottom' => '',
  191. )
  192. )
  193. );
  194. return $oTemplate->parseHtmlByName('store.html', $aTmplVars);
  195. }
  196. protected function getCheckoutList() {
  197. $sJsObject = $this->getPageJsObject();
  198. $oTemplate = BxDolStudioTemplate::getInstance();
  199. //--- Empty cart by vendor if the payment was accepted.
  200. $mixedVendor = bx_get('vendor');
  201. $mixedProducts = bx_get('products');
  202. if($mixedVendor !== false && $mixedProducts !== false) {
  203. bx_import('BxDolStudioCart');
  204. $oCart = BxDolStudioCart::getInstance();
  205. $aProducts = explode(',', base64_decode($mixedProducts));
  206. foreach($aProducts as $iId)
  207. $oCart->delete($mixedVendor, $iId);
  208. return $this->getMessage('_adm_block_cpt_checkout', '_adm_msg_modules_success_checkouted');
  209. }
  210. $aVendors = $this->loadCheckout();
  211. $aTmplVarsBlocks = array();
  212. foreach($aVendors as $sName => $aInfo) {
  213. $fTotal = 0;
  214. $sCurrency = '';
  215. foreach($aInfo['products'] as $aProduct) {
  216. $iCount = isset($aInfo['counts'][$aProduct['id']]) ? (int)$aInfo['counts'][$aProduct['id']] : 1;
  217. $fTotal += $iCount * $aProduct['price'];
  218. if($sCurrency == '' && isset($aProduct['currency_sign']))
  219. $sCurrency = $aProduct['currency_sign'];
  220. }
  221. $aActions = array(
  222. array('name' => 'checkout-' . $sName, 'caption' => '_adm_action_cpt_checkout', 'url' => 'javascript:void(0)', 'onclick' => $sJsObject . ".checkoutCart('" . $sName . "', this);"),
  223. array('name' => 'delete-all-' . $sName, 'caption' => '_adm_action_cpt_delete_all', 'url' => 'javascript:void(0)', 'onclick' => $sJsObject . ".deleteAllFromCart('" . $sName . "', this)")
  224. );
  225. $aTmplVarsBlocks[] = array(
  226. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_checkout_by_vendor_csign', $sName, $sCurrency, $fTotal), 'actions' => $aActions)),
  227. 'panel_top' => '',
  228. 'items' => $this->displayProducts($aInfo['products'], array('is_shopping_cart' => true, 'counts' => $aInfo['counts'])),
  229. 'panel_bottom' => ''
  230. );
  231. }
  232. if(empty($aTmplVarsBlocks))
  233. return $this->getMessage('_adm_block_cpt_checkout', '_Empty');
  234. return $oTemplate->parseHtmlByName('store.html', array(
  235. 'js_object' => $sJsObject,
  236. 'bx_repeat:blocks' => $aTmplVarsBlocks
  237. ));
  238. }
  239. protected function getDownloadedList() {
  240. $sJsObject = $this->getPageJsObject();
  241. $oTemplate = BxDolStudioTemplate::getInstance();
  242. $sModules = $sUpdates = "";
  243. $aProducts = $this->loadDownloaded();
  244. //--- Prepare modules.
  245. foreach($aProducts['modules'] as $aModule) {
  246. $sIcon = $oTemplate->getIconUrl($aModule['name'] . '@modules/' . $aModule['dir'] . '|std-si.png');
  247. if(empty($sIcon))
  248. $sIcon = $oTemplate->getIconUrl('si-mod-empty.png');
  249. $sModules .= $oTemplate->parseHtmlByName('str_product_v1.html', array(
  250. 'js_object' => $sJsObject,
  251. 'url' => $aModule['link_market'],
  252. 'icon' => $sIcon,
  253. 'title' => $aModule['title'],
  254. 'vendor' => $aModule['vendor'],
  255. 'version' => $aModule['version'],
  256. 'dir' => $aModule['dir'],
  257. 'bx_if:hide_install' => array(
  258. 'condition' => $aModule['installed'],
  259. 'content' => array()
  260. ),
  261. 'bx_if:hide_installed' => array(
  262. 'condition' => !$aModule['installed'],
  263. 'content' => array()
  264. )
  265. ));
  266. }
  267. //--- Prepare updates.
  268. foreach($aProducts['updates'] as $aUpdate) {
  269. $sIcon = $oTemplate->getIconUrl($aUpdate['module_name'] . '@modules/' . $aUpdate['module_dir'] . '|std-si.png');
  270. if(empty($sIcon))
  271. $sIcon = $oTemplate->getIconUrl('si-mod-empty.png');
  272. $sUpdates .= $oTemplate->parseHtmlByName('str_update_v1.html', array(
  273. 'js_object' => $sJsObject,
  274. 'url' => $aUpdate['module_link_market'],
  275. 'icon' => $sIcon,
  276. 'title' => $aUpdate['title'],
  277. 'vendor' => $aUpdate['vendor'],
  278. 'versions' => _t('_adm_str_txt_update_from_to', $aUpdate['version_from'], $aUpdate['version_to']),
  279. 'dir' => $aUpdate['dir']
  280. ));
  281. }
  282. $aTmplVars = array(
  283. 'js_object' => $sJsObject,
  284. 'bx_repeat:blocks' => array(
  285. array(
  286. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_downloaded_modules'), 'actions' => array())),
  287. 'panel_top' => '',
  288. 'items' => $sModules,
  289. 'panel_bottom' => ''
  290. )
  291. )
  292. );
  293. if(!empty($sUpdates))
  294. $aTmplVars['bx_repeat:blocks'][] = array(
  295. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_downloaded_updates'), 'actions' => array())),
  296. 'panel_top' => '',
  297. 'items' => $sUpdates,
  298. 'panel_bottom' => ''
  299. );
  300. return $oTemplate->parseHtmlByName('store.html', $aTmplVars);
  301. }
  302. protected function getMessage($sCaption, $sContent, $aActions = array()) {
  303. $sJsObject = $this->getPageJsObject();
  304. $oTemplate = BxDolStudioTemplate::getInstance();
  305. return $oTemplate->parseHtmlByName('store.html', array(
  306. 'js_object' => $sJsObject,
  307. 'bx_repeat:blocks' => array(
  308. array(
  309. 'caption' => $this->getBlockCaption(array('caption' => _t($sCaption), 'actions' => $aActions)),
  310. 'items' => MsgBox(_t($sContent))
  311. )
  312. )
  313. ));
  314. }
  315. protected function getProduct($iId) {
  316. $sJsObject = $this->getPageJsObject();
  317. $oTemplate = BxDolStudioTemplate::getInstance();
  318. $aProduct = $this->loadProduct($iId);
  319. if(!is_array($aProduct))
  320. return array('code' => 1, 'message' => (!empty($aProduct) ? $aProduct : _t('_adm_str_err_no_product_info')));
  321. $bFree = (int)$aProduct['is_free'] == 1;
  322. $bPurchased = (int)$aProduct['is_purchased'] == 1;
  323. $bDownloadable = (int)$aProduct['is_file'] == 1;
  324. $bDiscount = !empty($aProduct['discount']);
  325. $bScreenshots = is_array($aProduct['screenshots']) && !empty($aProduct['screenshots']);
  326. $iScreenshots = 0;
  327. $aScreenshots = array();
  328. if($bScreenshots) {
  329. $iScreenshots = count($aProduct['screenshots']);
  330. foreach($aProduct['screenshots'] as $aScreenshot)
  331. $aScreenshots[] = array(
  332. 'view_url' => $aProduct['url'],
  333. 'image_url' => $aScreenshot['big']
  334. );
  335. }
  336. $sContent = $oTemplate->parseHtmlByname('str_product_view.html', array(
  337. 'id' => $aProduct['id'],
  338. 'title' => $aProduct['title'],
  339. 'url' => $aProduct['url'],
  340. 'author_name' => $aProduct['author_name'],
  341. 'author_url' => $aProduct['author_url'],
  342. 'version' => $aProduct['version'],
  343. 'price' => !$bFree ? _t('_adm_str_txt_price_csign', $aProduct['author_currency_sign'], $aProduct['price']) : _t('_adm_str_txt_price_free'),
  344. 'bx_if:show_discount' => array(
  345. 'condition' => !$bFree && $bDiscount,
  346. 'content' => array(
  347. 'discount' => $bDiscount ? _t('_adm_str_txt_pv_discount_off_csign', $aProduct['discount']['percent'], $aProduct['author_currency_sign'], $aProduct['discount']['save']) : ''
  348. )
  349. ),
  350. 'category' => $aProduct['category'],
  351. 'category_url' => $aProduct['category_url'],
  352. 'tags' => implode(', ', explode(',', $aProduct['tags'])),
  353. 'reviews' => _t('_adm_str_txt_pv_stats_reviews', $aProduct['reviews_cnt']),
  354. 'reviews_url' => $aProduct['reviews_url'],
  355. 'likes' => _t('_adm_str_txt_pv_stats_likes', $aProduct['likes_cnt']),
  356. 'views' => _t('_adm_str_txt_pv_stats_views', $aProduct['views_cnt']),
  357. 'created' => $aProduct['created'],
  358. 'updated' => $aProduct['updated'],
  359. 'description' => $aProduct['description'],
  360. 'bx_if:show_screenshots' => array(
  361. 'condition' => $bScreenshots,
  362. 'content' => array(
  363. 'width' => 222 * $iScreenshots - 20,
  364. 'bx_repeat:screenshots' => $aScreenshots
  365. )
  366. ),
  367. 'bx_if:show_purchase' => array(
  368. 'condition' => !$bFree && !$bPurchased,
  369. 'content' => array(
  370. 'js_object' => $sJsObject,
  371. 'id' => $aProduct['id'],
  372. 'vendor' => $aProduct['author_name'],
  373. )
  374. ),
  375. 'bx_if:show_download' => array(
  376. 'condition' => ($bFree || $bPurchased) && $bDownloadable,
  377. 'content' => array(
  378. 'js_object' => $sJsObject,
  379. 'id' => $aProduct['id'],
  380. 'file_id' => $aProduct['file_id'],
  381. )
  382. )
  383. ));
  384. return array('code' => 0, 'message' => '', 'popup' => PopupBox('bx-std-str-popup-product', $aProduct['title'], $sContent, true), 'screenshots' => $iScreenshots);
  385. }
  386. /*
  387. * NOTE. Is needed for download popup selector. Isn't used for now.
  388. */
  389. protected function getFiles($iId, $sType) {
  390. $sJsObject = $this->getPageJsObject();
  391. $oTemplate = BxDolStudioTemplate::getInstance();
  392. $aFiles = $this->loadFiles($iId, $sType);
  393. if(!is_array($aFiles))
  394. return array('code' => 1, 'message' => (!empty($aFiles) ? $aFiles : _t('_adm_str_err_no_files')));
  395. $aTmplVarsFiles = array();
  396. foreach($aFiles as $aFile)
  397. $aTmplVarsFiles[] = array(
  398. 'js_object' => $sJsObject,
  399. 'product_id' => $iId,
  400. 'id' => $aFile['id'],
  401. 'title' => $aFile['name'],
  402. 'version' => empty($aFile['version_to']) ? $aFile['version'] : _t('_adm_str_txt_update_from_to', $aFile['version'], $aFile['version_to']),
  403. );
  404. $sContent = $oTemplate->parseHtmlByName('str_files.html', array(
  405. 'bx_repeat:files' => $aTmplVarsFiles
  406. ));
  407. return array('code' => 0, 'message' => $sContent);
  408. }
  409. protected function getFile($iId) {
  410. $mixedResult = $this->loadFile($iId);
  411. if($mixedResult !== true)
  412. return array('code' => 1, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
  413. return array('code' => 0, 'message' => _t('_adm_str_msg_download_successfully'));
  414. }
  415. protected function displayProducts($aItems, $aParams = array()) {
  416. if(!is_array($aItems))
  417. return $aItems;
  418. $sJsObject = $this->getPageJsObject();
  419. $oTemplate = BxDolStudioTemplate::getInstance();
  420. $bShoppingCart = isset($aParams['is_shopping_cart']) && $aParams['is_shopping_cart'];
  421. $sResult = '';
  422. foreach($aItems as $aItem) {
  423. $bFree = (int)$aItem['is_free'] == 1;
  424. $bPurchased = (int)$aItem['is_purchased'] == 1;
  425. $bDownloadable = (int)$aItem['is_file'] == 1;
  426. $sPrice = !$bFree ? _t('_adm_str_txt_price_csign', $aItem['currency_sign'], $aItem['price']) : _t('_adm_str_txt_price_free');
  427. $sDiscount = !$bFree && !empty($aItem['discount']) ? _t('_adm_str_txt_discount_csign', $aItem['currency_sign'], $aItem['discount']['price']) : '';
  428. $sResult .= $oTemplate->parseHtmlByName('str_product_v2.html', array(
  429. 'js_object' => $sJsObject,
  430. 'id' => $aItem['id'],
  431. 'url' => $aItem['url'],
  432. 'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('si-mod-empty.png'),
  433. 'title' => $aItem['title'],
  434. 'bx_if:show_vendor_price' => array(
  435. 'condition' => !$bShoppingCart,
  436. 'content' => array(
  437. 'vendor' => $aItem['author'],
  438. 'price' => $sPrice,
  439. 'discount' => $sDiscount,
  440. )
  441. ),
  442. 'bx_if:show_count_price' => array(
  443. 'condition' => $bShoppingCart,
  444. 'content' => array(
  445. 'count' => isset($aParams['counts'][$aItem['id']]) ? (int)$aParams['counts'][$aItem['id']] : 1,
  446. 'price' => $sPrice,
  447. 'discount' => $sDiscount,
  448. )
  449. ),
  450. 'bx_if:show_purchase' => array(
  451. 'condition' => !$bShoppingCart && !$bFree && !$bPurchased,
  452. 'content' => array(
  453. 'js_object' => $sJsObject,
  454. 'id' => $aItem['id'],
  455. 'vendor' => $aItem['author']
  456. )
  457. ),
  458. 'bx_if:show_download' => array(
  459. 'condition' => !$bShoppingCart && ($bFree || $bPurchased) && $bDownloadable,
  460. 'content' => array(
  461. 'js_object' => $sJsObject,
  462. 'id' => $aItem['id'],
  463. 'file_id' => $aItem['file_id'],
  464. )
  465. ),
  466. 'bx_if:show_delete' => array(
  467. 'condition' => $bShoppingCart,
  468. 'content' => array(
  469. 'js_object' => $sJsObject,
  470. 'id' => $aItem['id'],
  471. 'vendor' => $aItem['author']
  472. )
  473. )
  474. ));
  475. }
  476. return $sResult;
  477. }
  478. protected function displayUpdates($aItems, $aParams = array()) {
  479. if(!is_array($aItems))
  480. return $aItems;
  481. $sJsObject = $this->getPageJsObject();
  482. $oTemplate = BxDolStudioTemplate::getInstance();
  483. $sResult = '';
  484. foreach($aItems as $aItem) {
  485. $bDownloadable = (int)$aItem['is_file'] == 1;
  486. $sResult .= $oTemplate->parseHtmlByName('str_update_v2.html', array(
  487. 'js_object' => $sJsObject,
  488. 'id' => $aItem['id'],
  489. 'url' => $aItem['url'],
  490. 'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('si-mod-empty.png'),
  491. 'title' => $aItem['title'],
  492. 'vendor' => $aItem['author'],
  493. 'versions' => _t('_adm_str_txt_update_from_to', $aItem['file_version'], $aItem['file_version_to']),
  494. 'bx_if:show_download' => array(
  495. 'condition' => $bDownloadable,
  496. 'content' => array(
  497. 'js_object' => $sJsObject,
  498. 'id' => $aItem['id'],
  499. 'file_id' => $aItem['file_id'],
  500. )
  501. )
  502. ));
  503. }
  504. return $sResult;
  505. }
  506. }
  507. /** @} */