1
0

BxBaseStudioStore.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioStore extends BxDolStudioStore
  11. {
  12. protected $iPerPageDefault = 24;
  13. function __construct($sPage = "")
  14. {
  15. parent::__construct($sPage);
  16. }
  17. function getPageCss()
  18. {
  19. return array_merge(parent::getPageCss(), array(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'fancybox/|jquery.fancybox.css', 'module.css', 'store.css'));
  20. }
  21. function getPageJs()
  22. {
  23. BxDolStudioTemplate::getInstance()->addJsTranslation(array('_adm_btn_queued_submit'));
  24. return array_merge(parent::getPageJs(), array('fancybox/jquery.fancybox.pack.js', 'store.js'));
  25. }
  26. function getPageJsObject()
  27. {
  28. return 'oBxDolStudioStore';
  29. }
  30. function getPageMenu($aMenu = array(), $aMarkers = array())
  31. {
  32. $sJsObject = $this->getPageJsObject();
  33. $oTemplate = BxDolStudioTemplate::getInstance();
  34. $aMenu = [];
  35. $aMenuItems = [
  36. 'goodies' => ['icon' => 'mi-str-home.svg'],
  37. 'latest' => ['icon' => 'mi-str-latest.svg'],
  38. 'featured' => ['icon' => 'mi-str-featured.svg'],
  39. 'popular' => ['icon' => 'mi-str-popular.svg'],
  40. 'categories' => ['icon' => 'mi-str-categories.svg'],
  41. 'search' => ['icon' => 'mi-str-search.svg'],
  42. 'purchases' => ['icon' => 'mi-str-purchases.svg'],
  43. 'updates' => ['icon' => 'mi-str-updates.svg'],
  44. 'checkout' => ['icon' => 'mi-str-checkout.svg', 'title' => '_adm_lmi_ttl_checkout'],
  45. 'downloaded' => ['icon' => 'mi-str-downloaded.svg']
  46. ];
  47. foreach($aMenuItems as $sMenuItem => $aItem)
  48. $aMenu[] = [
  49. 'name' => $sMenuItem,
  50. 'icon' => $aItem['icon'],
  51. 'icon_bg' => true,
  52. 'link' => $this->getBaseUrl($sMenuItem),
  53. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  54. 'title_attr' => !empty($aItem['title']) ? _t($aItem['title']) : '',
  55. 'selected' => $sMenuItem == $this->sPage
  56. ];
  57. $iCounter = BxDolStudioCart::getInstance()->getCount();
  58. $aMarkers = array(
  59. 'checkout_counter' => $oTemplate->parseHtmlByName('menu_side_counter.html', array(
  60. 'bx_if:hide_counter' => array(
  61. 'condition' => $iCounter <= 0,
  62. 'content' => array()
  63. ),
  64. 'counter' => $iCounter
  65. ))
  66. );
  67. return parent::getPageMenu($aMenu, $aMarkers);
  68. }
  69. function getPageCode($sPage = '', $bWrap = true)
  70. {
  71. $sResult = parent::getPageCode($sPage, $bWrap);
  72. if($sResult === false)
  73. return false;
  74. $sMethod = 'get' . ucfirst($this->sPage) . 'List';
  75. if(!method_exists($this, $sMethod))
  76. return '';
  77. return $this->$sMethod() . $sResult;
  78. }
  79. function getPageContent()
  80. {
  81. $sMethod = 'get' . ucfirst($this->sPage) . 'List';
  82. if(!method_exists($this, $sMethod))
  83. return '';
  84. return $this->$sMethod(false);
  85. }
  86. protected function getGoodiesList()
  87. {
  88. $sJsObject = $this->getPageJsObject();
  89. $oTemplate = BxDolStudioTemplate::getInstance();
  90. $mixedResult = $this->authorizeClient();
  91. if($mixedResult === true) {
  92. $aProducts = $this->loadGoodies();
  93. $sContent = "";
  94. $sContent .= $this->displayNonOwnerNotification();
  95. $sContent .= $this->getBlocksLine(array(
  96. array(
  97. 'caption' => '_adm_block_cpt_categories',
  98. 'actions' => array(),
  99. 'items' => $this->getCategoriesList(false)
  100. ),
  101. array(
  102. 'caption' => '_adm_block_cpt_tags',
  103. 'actions' => array(),
  104. 'items' => $this->getTagsList(false)
  105. )
  106. ));
  107. foreach($aProducts as $aBlock) {
  108. $aBlock['items'] = $oTemplate->parseHtmlByName('str_products.html', array(
  109. 'list' => $this->displayProducts($aBlock['items']),
  110. 'paginate' => ''
  111. ));
  112. $sContent .= $this->getBlockCode($aBlock);
  113. }
  114. }
  115. else
  116. $sContent = $this->getBlockCode(array(
  117. 'caption' => '_adm_block_cpt_goodies',
  118. 'items' => $mixedResult,
  119. ));
  120. return $oTemplate->parseHtmlByName('store.html', array(
  121. 'js_object' => $sJsObject,
  122. 'content' => $sContent
  123. ));
  124. }
  125. protected function getLatestList($bWrapInBlock = true)
  126. {
  127. return $this->getBrowsingList('latest', $bWrapInBlock);
  128. }
  129. protected function getFeaturedList($bWrapInBlock = true)
  130. {
  131. return $this->getBrowsingList('featured', $bWrapInBlock);
  132. }
  133. protected function getPopularList($bWrapInBlock = true)
  134. {
  135. return $this->getBrowsingList('popular', $bWrapInBlock);
  136. }
  137. protected function getBrowsingList($sType, $bWrapInBlock = true)
  138. {
  139. $sJsObject = $this->getPageJsObject();
  140. $oTemplate = BxDolStudioTemplate::getInstance();
  141. $mixedResult = $this->authorizeClient();
  142. if($mixedResult === true) {
  143. $iStart = (int)bx_get('str_start');
  144. $iPerPage = (int)bx_get('str_per_page');
  145. if(empty($iPerPage))
  146. $iPerPage = $this->iPerPageDefault;
  147. $aProducts = $this->{'load' . bx_gen_method_name($sType)}($iStart, $iPerPage + 1);
  148. $oPaginate = new BxTemplPaginate(array(
  149. 'start' => $iStart,
  150. 'per_page' => $iPerPage,
  151. 'on_change_page' => $sJsObject . ".changePagePaginate(this, '" . $sType . "', null, {start}, {per_page})"
  152. ));
  153. $oPaginate->setNumFromDataArray($aProducts);
  154. $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
  155. 'list' => $this->displayProducts($aProducts),
  156. 'paginate' => $oPaginate->getSimplePaginate()
  157. ));
  158. }
  159. else
  160. $sContent = $mixedResult;
  161. if(!$bWrapInBlock)
  162. return $sContent;
  163. return $oTemplate->parseHtmlByName('store.html', array(
  164. 'js_object' => $sJsObject,
  165. 'content' => $this->getBlockCode(array(
  166. 'caption' => '_adm_block_cpt_' . $sType,
  167. 'items' => $sContent
  168. ))
  169. ));
  170. }
  171. protected function getCategoriesList($bWrapInBlock = true)
  172. {
  173. return $this->getLabelsList('categories', $bWrapInBlock);
  174. }
  175. protected function getCategoryList($bWrapInBlock = true)
  176. {
  177. $sKey = 'value';
  178. if(bx_get($sKey) === false)
  179. $sKey = 'str_value';
  180. $aValue = array();
  181. $aValue['value'] = (int)bx_get($sKey);
  182. if(bx_get('title') !== false)
  183. $aValue['title'] = bx_process_input(urldecode(bx_get('title')));
  184. return $this->getLabelList('category', $aValue, $bWrapInBlock);
  185. }
  186. protected function getTagsList($bWrapInBlock = true)
  187. {
  188. return $this->getLabelsList('tags', $bWrapInBlock);
  189. }
  190. protected function getTagList($bWrapInBlock = true)
  191. {
  192. $sKey = 'value';
  193. if(bx_get($sKey) === false)
  194. $sKey = 'str_value';
  195. return $this->getLabelList('tag', bx_process_input(bx_get($sKey)), $bWrapInBlock);
  196. }
  197. protected function getLabelsList($sType, $bWrapInBlock = true)
  198. {
  199. $mixedResult = $this->authorizeClient();
  200. if($mixedResult === true) {
  201. $aLabels = $this->{'load' . bx_gen_method_name($sType)}();
  202. $sContent = $this->{'display' . bx_gen_method_name($sType)}($aLabels);
  203. }
  204. else
  205. $sContent = $mixedResult;
  206. if(!$bWrapInBlock)
  207. return $sContent;
  208. return BxDolStudioTemplate::getInstance()->parseHtmlByName('store.html', array(
  209. 'js_object' => $this->getPageJsObject(),
  210. 'content' => $this->getBlockCode(array(
  211. 'caption' => '_adm_block_cpt_' . $sType,
  212. 'items' => $sContent
  213. ))
  214. ));
  215. }
  216. protected function getLabelList($sType, $mixedValue, $bWrapInBlock = true)
  217. {
  218. $sJsObject = $this->getPageJsObject();
  219. $oTemplate = BxDolStudioTemplate::getInstance();
  220. $iStart = (int)bx_get('str_start');
  221. $iPerPage = (int)bx_get('str_per_page');
  222. if(empty($iPerPage))
  223. $iPerPage = $this->iPerPageDefault;
  224. $bArray = is_array($mixedValue);
  225. $sValue = $bArray ? $mixedValue['value'] : $mixedValue;
  226. $sTitle = $bArray && !empty($mixedValue['title']) ? $mixedValue['title'] : $sValue;
  227. $sMethod = 'load' . bx_gen_method_name($sType);
  228. $aProducts = $this->$sMethod($sValue, $iStart, $iPerPage + 1);
  229. $oPaginate = new BxTemplPaginate(array(
  230. 'start' => $iStart,
  231. 'per_page' => $iPerPage,
  232. 'on_change_page' => $sJsObject . ".changePagePaginate(this, '" . $sType . "', '" . $sValue . "', {start}, {per_page})"
  233. ));
  234. $oPaginate->setNumFromDataArray($aProducts);
  235. $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
  236. 'list' => $this->displayProducts($aProducts),
  237. 'paginate' => $oPaginate->getSimplePaginate()
  238. ));
  239. if(!$bWrapInBlock)
  240. return $sContent;
  241. return $oTemplate->parseHtmlByName('store.html', array(
  242. 'js_object' => $sJsObject,
  243. 'content' => $this->getBlockCode(array(
  244. 'caption' => array('_adm_block_cpt_' . $sType, $sTitle),
  245. 'items' => $sContent,
  246. ))
  247. ));
  248. }
  249. protected function getSearchList($bWrapInBlock = true)
  250. {
  251. $sJsObject = $this->getPageJsObject();
  252. $oTemplate = BxDolStudioTemplate::getInstance();
  253. $mixedResult = $this->authorizeClient();
  254. if($mixedResult === true) {
  255. //--- Search form
  256. $aForm = array(
  257. 'form_attrs' => array(
  258. 'id' => 'adm-str-search-form',
  259. 'name' => 'adm-str-search-form',
  260. 'action' => '',
  261. 'method' => 'post'
  262. ),
  263. 'params' => array(
  264. 'db' => array(
  265. 'table' => '',
  266. 'key' => '',
  267. 'uri' => '',
  268. 'uri_title' => '',
  269. 'submit_name' => 'search'
  270. ),
  271. ),
  272. 'inputs' => array(
  273. 'page' => array(
  274. 'type' => 'hidden',
  275. 'name' => 'page',
  276. 'value' => $this->sPage
  277. ),
  278. 'keyword' => array(
  279. 'type' => 'text',
  280. 'name' => 'keyword',
  281. 'caption' => '',
  282. 'value' => '',
  283. 'attrs' => array(
  284. 'placeholder' => bx_html_attribute(_t('_sys_search_placeholder'))
  285. ),
  286. 'db' => array (
  287. 'pass' => 'Xss',
  288. )
  289. ),
  290. 'search' => array(
  291. 'type' => 'submit',
  292. 'name' => 'search',
  293. 'value' => _t('_adm_btn_store_search'),
  294. )
  295. )
  296. );
  297. $oForm = new BxTemplStudioFormView($aForm);
  298. $oForm->initChecker();
  299. $sResults = '';
  300. if($oForm->isSubmittedAndValid()) {
  301. $sKeyword = $oForm->getCleanValue('keyword');
  302. $iStart = (int)bx_get('str_start');
  303. $iPerPage = (int)bx_get('str_per_page');
  304. if(empty($iPerPage))
  305. $iPerPage = 999;
  306. $aProducts = $this->loadSearch($sKeyword, $iStart, $iPerPage + 1);
  307. $sResults = empty($aProducts) || !is_array($aProducts) ? MsgBox(_t('_Empty')) : $oTemplate->parseHtmlByName('str_products.html', array(
  308. 'list' => $this->displayProducts($aProducts),
  309. 'paginate' => ''
  310. ));
  311. }
  312. $sContent = $oTemplate->parseHtmlByName('str_search.html', array(
  313. 'form' => $oForm->getCode(),
  314. 'bx_if:show_results' => array(
  315. 'condition' => !empty($sResults),
  316. 'content' => array(
  317. 'results' => $sResults
  318. )
  319. )
  320. ));
  321. }
  322. else
  323. $sContent = $mixedResult;
  324. if(!$bWrapInBlock)
  325. return $sContent;
  326. return $oTemplate->parseHtmlByName('store.html', array(
  327. 'js_object' => $sJsObject,
  328. 'content' => $this->getBlockCode(array(
  329. 'caption' => '_adm_block_cpt_search',
  330. 'items' => $sContent
  331. ))
  332. ));
  333. }
  334. protected function getPurchasesList()
  335. {
  336. $oTemplate = BxDolStudioTemplate::getInstance();
  337. $aProducts = $this->loadPurchases();
  338. return $oTemplate->parseHtmlByName('store.html', array(
  339. 'js_object' => $this->getPageJsObject(),
  340. 'content' => $this->getBlockCode(array(
  341. 'caption' => '_adm_block_cpt_purchases',
  342. 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
  343. 'list' => $this->displayProducts($aProducts),
  344. 'paginate' => ''
  345. ))
  346. ))
  347. ));
  348. }
  349. protected function getUpdatesList()
  350. {
  351. $oTemplate = BxDolStudioTemplate::getInstance();
  352. $aUpdates = $this->loadUpdates();
  353. return $oTemplate->parseHtmlByName('store.html', array(
  354. 'js_object' => $this->getPageJsObject(),
  355. 'content' => $this->getBlockCode(array(
  356. 'caption' => '_adm_block_cpt_updates',
  357. 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
  358. 'list' => $this->displayUpdates($aUpdates),
  359. 'paginate' => ''
  360. ))
  361. ))
  362. ));
  363. }
  364. protected function getCheckoutList()
  365. {
  366. $sJsObject = $this->getPageJsObject();
  367. $oTemplate = BxDolStudioTemplate::getInstance();
  368. //--- Empty cart by vendor if the payment was accepted.
  369. $mixedVendor = bx_get('vendor');
  370. $mixedProducts = bx_get('products');
  371. if($mixedVendor !== false && $mixedProducts !== false) {
  372. $oCart = BxDolStudioCart::getInstance();
  373. $aProducts = explode(',', base64_decode($mixedProducts));
  374. foreach($aProducts as $iId)
  375. $oCart->delete($mixedVendor, $iId);
  376. return $this->getMessage('_adm_block_cpt_checkout', '_adm_msg_modules_success_checkouted');
  377. }
  378. $aVendors = $this->loadCheckout();
  379. if(empty($aVendors))
  380. return $this->getMessage('_adm_block_cpt_checkout', '_Empty');
  381. $sContent = '';
  382. foreach($aVendors as $iVendor => $aInfo) {
  383. $fTotal = 0;
  384. $sVendor = $sCurrency = '';
  385. if(!empty($aInfo['products']) && is_array($aInfo['products']))
  386. foreach($aInfo['products'] as $aProduct) {
  387. $iCount = isset($aInfo['counts'][$aProduct['id']]) ? (int)$aInfo['counts'][$aProduct['id']] : 1;
  388. $fTotal += $iCount * $aProduct['price_single'];
  389. if($sVendor == '' && isset($aProduct['author_name']))
  390. $sVendor = $aProduct['author_name'];
  391. if($sCurrency == '' && isset($aProduct['author_currency_sign']))
  392. $sCurrency = $aProduct['author_currency_sign'];
  393. }
  394. $aMenu = array(
  395. array('id' => 'checkout-' . $iVendor, 'name' => 'checkout-' . $iVendor, 'link' => 'javascript:void(0)', 'onclick' => $sJsObject . ".checkoutCart(" . $iVendor . ", this);", 'target' => '_self', 'title' => '_adm_action_cpt_checkout', 'active' => 1),
  396. array('id' => 'delete-all-' . $iVendor, 'name' => 'delete-all-' . $iVendor, 'link' => 'javascript:void(0)', 'onclick' => $sJsObject . ".deleteAllFromCart(" . $iVendor . ", this)", 'target' => '_self', 'title' => '_adm_action_cpt_delete_all', 'active' => 1)
  397. );
  398. $oMenu = new BxTemplMenu(array('object'=> 'adm-std-checkout', 'template' => 'menu_buttons_hor.html', 'menu_items' => $aMenu));
  399. $sContent .= $this->getBlockCode(array(
  400. 'caption' => _t('_adm_block_cpt_checkout_by_vendor_csign', $sVendor, $sCurrency, $fTotal),
  401. 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
  402. 'list' => $this->displayProducts($aInfo['products'], array('is_shopping_cart' => true, 'counts' => $aInfo['counts'])),
  403. 'paginate' => ''
  404. )),
  405. 'panel_bottom' => $oMenu->getCode()
  406. ));
  407. }
  408. return $oTemplate->parseHtmlByName('store.html', array(
  409. 'js_object' => $sJsObject,
  410. 'content' => $sContent
  411. ));
  412. }
  413. protected function getDownloadedList()
  414. {
  415. $sJsObject = $this->getPageJsObject();
  416. $oTemplate = BxDolStudioTemplate::getInstance();
  417. $sContent = $sModules = $sUpdates = "";
  418. $aProducts = $this->loadDownloaded();
  419. //--- Prepare modules.
  420. $bCacheImage = getParam('sys_template_cache_image_enable') == 'on';
  421. foreach($aProducts['modules'] as $aModule) {
  422. $sIcon = BxDolStudioUtils::getModuleIcon($aModule, 'store');
  423. $bIcon = ($bCacheImage && substr($sIcon, 0, 10) == 'data:image') || strpos($sIcon, '.') !== false;
  424. $bInstalled = $aModule['installed'];
  425. $bQueued = !$bInstalled && $this->oDb->isQueued('action', $aModule['dir']);
  426. $sModules .= $oTemplate->parseHtmlByName('str_product_v1.html', array(
  427. 'js_object' => $sJsObject,
  428. 'name' => $aModule['name'],
  429. 'bx_if:no_icon' => array (
  430. 'condition' => !$bIcon,
  431. 'content' => array(
  432. 'icon' => $sIcon
  433. ),
  434. ),
  435. 'bx_if:icon' => array (
  436. 'condition' => $bIcon,
  437. 'content' => array(
  438. 'icon_url' => $sIcon,
  439. ),
  440. ),
  441. 'title' => $aModule['title'],
  442. 'vendor' => strtolower($aModule['vendor']) == 'boonex' ? 'UNA INC' : $aModule['vendor'],
  443. 'version' => $aModule['version'],
  444. 'dir' => $aModule['dir'],
  445. 'bx_if:hide_install' => array(
  446. 'condition' => $bInstalled || $bQueued,
  447. 'content' => array()
  448. ),
  449. 'bx_if:hide_queued' => array(
  450. 'condition' => !$bQueued,
  451. 'content' => array()
  452. ),
  453. 'bx_if:hide_installed' => array(
  454. 'condition' => !$bInstalled || $bQueued,
  455. 'content' => array()
  456. )
  457. ));
  458. }
  459. //--- Prepare updates.
  460. foreach($aProducts['updates'] as $aUpdate) {
  461. $sIcon = BxDolStudioUtils::getModuleIcon(array('type' => $aUpdate['module_type'], 'name' => $aUpdate['module_name'], 'dir' => $aUpdate['module_dir']), 'store');
  462. $bIcon = ($bCacheImage && substr($sIcon, 0, 10) == 'data:image') || strpos($sIcon, '.') !== false;
  463. $sUpdates .= $oTemplate->parseHtmlByName('str_update_v1.html', array(
  464. 'js_object' => $sJsObject,
  465. 'name' => $aUpdate['module_name'],
  466. 'bx_if:no_icon' => array (
  467. 'condition' => !$bIcon,
  468. 'content' => array(
  469. 'icon' => $sIcon
  470. ),
  471. ),
  472. 'bx_if:icon' => array (
  473. 'condition' => $bIcon,
  474. 'content' => array(
  475. 'icon_url' => $sIcon,
  476. ),
  477. ),
  478. 'title' => $aUpdate['title'],
  479. 'vendor' => strtolower($aUpdate['vendor']) == 'boonex' ? 'UNA INC' : $aUpdate['vendor'],
  480. 'versions' => _t('_adm_str_txt_update_from_to', $aUpdate['version_from'], $aUpdate['version_to']),
  481. 'dir' => $aUpdate['dir']
  482. ));
  483. }
  484. if(!empty($sModules))
  485. $sContent .= $this->getBlockCode(array(
  486. 'type' => BX_DB_DEF,
  487. 'caption' => '_adm_block_cpt_downloaded_modules',
  488. 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
  489. 'list' => $sModules,
  490. 'paginate' => ''
  491. )),
  492. ));
  493. if(!empty($sUpdates))
  494. $sContent .= $this->getBlockCode(array(
  495. 'type' => BX_DB_DEF,
  496. 'caption' => '_adm_block_cpt_downloaded_updates',
  497. 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
  498. 'list' => $sUpdates,
  499. 'paginate' => ''
  500. )),
  501. ));
  502. return $oTemplate->parseHtmlByName('store.html', array(
  503. 'js_object' => $sJsObject,
  504. 'content' => $sContent
  505. ));
  506. }
  507. protected function getMessage($sCaption, $sContent, $aActions = array())
  508. {
  509. return BxDolStudioTemplate::getInstance()->parseHtmlByName('store.html', array(
  510. 'js_object' => $this->getPageJsObject(),
  511. 'content' => $this->getBlockCode(array(
  512. 'caption' => $sCaption,
  513. 'actions' => $aActions,
  514. 'items' => MsgBox(_t($sContent))
  515. ))
  516. ));
  517. }
  518. protected function getProduct($sModuleName)
  519. {
  520. $bShowRating = true;
  521. $sJsObject = $this->getPageJsObject();
  522. $oTemplate = BxDolStudioTemplate::getInstance();
  523. $aProduct = $this->loadProduct($sModuleName);
  524. if(empty($aProduct) || !is_array($aProduct)) {
  525. $aLocalProduct = array();
  526. if(is_array($aProduct))
  527. $aLocalProduct = $this->loadLocalProduct($sModuleName);
  528. if(!empty($aLocalProduct) && is_array($aLocalProduct))
  529. return $this->getLocalProduct($aLocalProduct);
  530. return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($aProduct) ? $aProduct : _t('_adm_str_err_no_product_info')));
  531. }
  532. $aDownloaded = $this->getDownloadedModules(false);
  533. $bFree = (int)$aProduct['is_free'] == 1;
  534. $bPurchased = (int)$aProduct['is_purchased'] == 1;
  535. $bPurchaseSingle = !$bFree && !$bPurchased && (float)$aProduct['price_single'] != 0;
  536. $bInCart = $bPurchaseSingle && BxDolStudioCart::getInstance()->exists($aProduct['author_id'], $aProduct['id']);
  537. $bPurchaseRecurring = !$bFree && !$bPurchased && (float)$aProduct['price_recurring'] != 0;
  538. $bDownloadable = (int)$aProduct['is_file'] == 1;
  539. $bDownloaded = array_key_exists($sModuleName, $aDownloaded);
  540. $bDownload = ($bFree || $bPurchased) && $bDownloadable;
  541. $bDiscount = !empty($aProduct['discount_single']);
  542. $sVersion = $bDownloaded && version_compare(strtolower($aDownloaded[$sModuleName]['version']), strtolower($aProduct['version'])) != 0 ? _t('_adm_str_txt_pv_version_mask', $aDownloaded[$sModuleName]['version'], $aProduct['version']) : $aProduct['version'];
  543. $iScreenshots = 0;
  544. $aScreenshots = array();
  545. $bScreenshots = is_array($aProduct['screenshots']) && !empty($aProduct['screenshots']);
  546. if($bScreenshots) {
  547. $iScreenshots = count($aProduct['screenshots']);
  548. foreach($aProduct['screenshots'] as $aScreenshot)
  549. $aScreenshots[] = array(
  550. 'view_url' => $aProduct['url'],
  551. 'image_url' => $aScreenshot['big'],
  552. 'image_alt' => bx_html_attribute(_t('_adm_str_txt_pv_screenshot', $aProduct['title']))
  553. );
  554. }
  555. $bTmplVarsRate = $bShowRating;
  556. if($bTmplVarsRate)
  557. $aTmplVarsRate = array(
  558. 'rate' => $this->getVoteStars($aProduct)
  559. );
  560. $aTmplVarsVotes = array();
  561. $bTmplVarsVotes = $bShowRating && (int)$aProduct['votes_cnt'] > 0;
  562. if($bTmplVarsVotes)
  563. $aTmplVarsVotes = array(
  564. 'count' => (int)$aProduct['votes_cnt']
  565. );
  566. $sContent = $oTemplate->parseHtmlByname('str_product_view.html', array(
  567. 'id' => $aProduct['id'],
  568. 'title' => $aProduct['title'],
  569. 'url' => $aProduct['url'],
  570. 'author_name' => $aProduct['author_name'],
  571. 'author_url' => $aProduct['author_url'],
  572. 'version' => $sVersion,
  573. 'bx_if:show_price_single' => array(
  574. 'condition' => $bFree || (float)$aProduct['price_single'] != 0,
  575. 'content' => array(
  576. 'price_single' => !$bFree ? _t('_adm_str_txt_price_single', $aProduct['author_currency_sign'], $aProduct['price_single']) : _t('_adm_str_txt_price_free'),
  577. 'bx_if:show_discount' => array(
  578. 'condition' => !$bFree && $bDiscount,
  579. 'content' => array(
  580. 'discount_single' => $bDiscount ? _t('_adm_str_txt_pv_discount_off_csign', $aProduct['discount_single']['percent'], $aProduct['author_currency_sign'], $aProduct['discount_single']['save']) : ''
  581. )
  582. )
  583. )
  584. ),
  585. 'bx_if:show_price_recurring' => array(
  586. 'condition' => (float)$aProduct['price_recurring'] != 0,
  587. 'content' => array(
  588. 'price_recurring' => _t('_adm_str_txt_price_recurring', $aProduct['author_currency_sign'], $aProduct['price_recurring'], _t('_adm_str_txt_per_' . $aProduct['duration_recurring']))
  589. )
  590. ),
  591. 'bx_if:show_rate' => array(
  592. 'condition' => $bTmplVarsRate,
  593. 'content' => $aTmplVarsRate
  594. ),
  595. 'bx_if:show_votes' => array(
  596. 'condition' => $bTmplVarsVotes,
  597. 'content' => $aTmplVarsVotes
  598. ),
  599. 'category' => $aProduct['category'],
  600. 'category_url' => $aProduct['category_url'],
  601. 'tags' => implode(', ', explode(',', $aProduct['tags'])),
  602. 'reviews' => _t('_adm_str_txt_pv_stats_reviews', $aProduct['reviews_cnt']),
  603. 'reviews_url' => $aProduct['reviews_url'],
  604. 'votes' => _t('_adm_str_txt_pv_stats_votes', $aProduct['votes_cnt']),
  605. 'views' => _t('_adm_str_txt_pv_stats_views', $aProduct['views_cnt']),
  606. 'created' => bx_time_js($aProduct['created']),
  607. 'updated' => bx_time_js($aProduct['updated']),
  608. 'description' => $aProduct['description'],
  609. 'bx_if:show_screenshots' => array(
  610. 'condition' => $bScreenshots,
  611. 'content' => array(
  612. 'width' => 222 * $iScreenshots - 20,
  613. 'bx_repeat:screenshots' => $aScreenshots
  614. )
  615. ),
  616. 'bx_if:show_purchase' => array(
  617. 'condition' => $bPurchaseSingle || $bPurchaseRecurring,
  618. 'content' => array(
  619. 'bx_if:show_purchase_single' => array(
  620. 'condition' => $bPurchaseSingle && !$bInCart,
  621. 'content' => array(
  622. 'js_object' => $sJsObject,
  623. 'id' => $aProduct['id'],
  624. 'vendor_id' => $aProduct['author_id'],
  625. 'price_single' => _t('_adm_str_txt_price_single', $aProduct['author_currency_sign'], $aProduct['price_single'])
  626. )
  627. ),
  628. 'bx_if:show_checkout_single' => array(
  629. 'condition' => $bPurchaseSingle,
  630. 'content' => array(
  631. 'js_object' => $sJsObject,
  632. 'id' => $aProduct['id'],
  633. 'vendor_id' => $aProduct['author_id'],
  634. 'bx_if:show_as_hidden' => array(
  635. 'condition' => !$bInCart,
  636. 'content' => array()
  637. )
  638. )
  639. ),
  640. 'bx_if:show_purchase_recurring' => array(
  641. 'condition' => $bPurchaseRecurring,
  642. 'content' => array(
  643. 'js_object' => $sJsObject,
  644. 'id' => $aProduct['id'],
  645. 'vendor_id' => $aProduct['author_id'],
  646. 'price_recurring' => _t('_adm_str_txt_price_recurring', $aProduct['author_currency_sign'], $aProduct['price_recurring'], _t('_adm_str_txt_per_' . $aProduct['duration_recurring']))
  647. )
  648. )
  649. )
  650. ),
  651. 'bx_if:show_download' => array(
  652. 'condition' => $bDownload && !$bDownloaded,
  653. 'content' => array(
  654. 'js_object' => $sJsObject,
  655. 'file_id' => $aProduct['file_id'],
  656. )
  657. ),
  658. 'bx_if:show_download_disabled' => array(
  659. 'condition' => $bDownload && $bDownloaded,
  660. 'content' => array()
  661. ),
  662. ));
  663. return [
  664. 'code' => BX_DOL_STUDIO_IU_RC_SUCCESS,
  665. 'message' => '',
  666. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox('bx-std-str-popup-product', $aProduct['title'], $sContent, true),
  667. 'screenshots' => $iScreenshots
  668. ];
  669. }
  670. protected function getLocalProduct(array $aProduct)
  671. {
  672. $oTemplate = BxDolStudioTemplate::getInstance();
  673. $sContent = $oTemplate->parseHtmlByName('str_product_view_local.html', array(
  674. 'title' => $aProduct['title'],
  675. 'vendor' => bx_process_output($aProduct['vendor']),
  676. 'version' => bx_process_output($aProduct['version']),
  677. 'bx_if:show_note' => array(
  678. 'condition' => !empty($aProduct['note']),
  679. 'content' => array(
  680. 'note' => $aProduct['note'],
  681. ),
  682. ),
  683. ));
  684. return array(
  685. 'code' => BX_DOL_STUDIO_IU_RC_SUCCESS,
  686. 'message' => '',
  687. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox(
  688. 'bx-std-str-popup-product',
  689. $aProduct['title'],
  690. $sContent,
  691. true
  692. ),
  693. 'screenshots' => 0,
  694. );
  695. }
  696. protected function getFile($iFileId)
  697. {
  698. $mixedResult = $this->loadFile($iFileId);
  699. if($mixedResult === true)
  700. return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download_successfully'));
  701. if(is_string($mixedResult))
  702. return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
  703. if(is_array($mixedResult))
  704. return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
  705. }
  706. protected function getUpdate($sModuleName, $bApplyUpdate = false)
  707. {
  708. $aResult = array();
  709. $mixedResult = $this->loadUpdate($sModuleName, $bApplyUpdate);
  710. if($mixedResult === true)
  711. $aResult = array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download' . ($bApplyUpdate ? '_and_install' : '') . '_successfully'));
  712. else if(is_string($mixedResult))
  713. $aResult = array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
  714. else if(is_array($mixedResult))
  715. $aResult = array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
  716. $aResult['reload'] = 3000;
  717. return $aResult;
  718. }
  719. protected function displayProducts($mixedItems, $aParams = array())
  720. {
  721. $bShowRating = false;
  722. if(!is_array($mixedItems))
  723. return MsgBox($mixedItems);
  724. $sJsObject = $this->getPageJsObject();
  725. $oTemplate = BxDolStudioTemplate::getInstance();
  726. $aDownloaded = $this->getDownloadedModules();
  727. $bShoppingCart = isset($aParams['is_shopping_cart']) && $aParams['is_shopping_cart'];
  728. $sResult = '';
  729. foreach($mixedItems as $aItem) {
  730. $bFree = (int)$aItem['is_free'] == 1;
  731. $bPurchased = (int)$aItem['is_purchased'] == 1;
  732. $bPurchaseSingle = !$bShoppingCart && !$bFree && !$bPurchased && (float)$aItem['price_single'] != 0;
  733. $bInCart = $bPurchaseSingle && BxDolStudioCart::getInstance()->exists($aItem['author_id'], $aItem['id']);
  734. $bPurchaseRecurring = !$bShoppingCart && !$bFree && !$bPurchased && (float)$aItem['price_recurring'] != 0;
  735. $bDownloadable = (int)$aItem['is_file'] == 1;
  736. $bDownloaded = in_array($aItem['name'], $aDownloaded);
  737. $bDownload = !$bShoppingCart && ($bFree || $bPurchased) && $bDownloadable;
  738. $bQueued = $this->oDb->isQueued('download', $aItem['name']);
  739. $sPrice = !$bFree ? _t('_adm_str_txt_price_single', $aItem['author_currency_sign'], $aItem['price_single']) : _t('_adm_str_txt_price_free');
  740. $sDiscount = !$bFree && !empty($aItem['discount_single']) ? _t('_adm_str_txt_discount_csign', $aItem['author_currency_sign'], $aItem['discount_single']['price']) : '';
  741. $sIcon = !empty($aItem['thumbnail']['small']) ? $aItem['thumbnail']['small'] : BxDolStudioUtils::getIconDefault(BX_DOL_MODULE_TYPE_MODULE);
  742. $bIcon = strpos($sIcon, '.') !== false;
  743. $sImage = '';
  744. $bImage = $bImageRaw = false;
  745. if(empty($aItem['cover_raw'])) {
  746. if(!empty($aItem['cover']['medium']))
  747. $sImage = $aItem['cover']['medium'];
  748. else if(!empty($aItem['cover']['large']))
  749. $sImage = $aItem['cover']['large'];
  750. else if(!empty($aItem['cover']['big']))
  751. $sImage = $aItem['cover']['big'];
  752. $bImage = !empty($sImage) && strpos($sImage, '.') !== false;
  753. }
  754. else {
  755. $sImage = $aItem['cover_raw'];
  756. $bImageRaw = true;
  757. }
  758. $aTmplVarsRate = array();
  759. $bTmplVarsRate = $bShowRating && !$bShoppingCart;
  760. if($bTmplVarsRate)
  761. $aTmplVarsRate = array(
  762. 'rate' => $this->getVoteStars($aItem)
  763. );
  764. $aTmplVarsVotes = array();
  765. $bTmplVarsVotes = $bShowRating && !$bShoppingCart && (int)$aItem['votes_cnt'] > 0;
  766. if($bTmplVarsVotes)
  767. $aTmplVarsVotes = array(
  768. 'count' => (int)$aItem['votes_cnt']
  769. );
  770. $sResult .= $oTemplate->parseHtmlByName('str_product_v2.html', array(
  771. 'js_object' => $sJsObject,
  772. 'id' => $aItem['id'],
  773. 'name' => $aItem['name'],
  774. 'url' => $aItem['url'],
  775. 'description_plain_attr' => bx_html_attribute($aItem['description_plain']),
  776. 'bx_if:no_icon' => array (
  777. 'condition' => !$bIcon,
  778. 'content' => array(
  779. 'icon' => $sIcon
  780. ),
  781. ),
  782. 'bx_if:icon' => array (
  783. 'condition' => $bIcon,
  784. 'content' => array(
  785. 'icon_url' => $sIcon,
  786. ),
  787. ),
  788. 'bx_if:no_image' => array (
  789. 'condition' => !$bImage && !$bImageRaw,
  790. 'content' => array(
  791. 'description_plain' => $aItem['description_plain'],
  792. 'strecher' => mb_strlen($aItem['description_plain']) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($aItem['description_plain'])) / 6))
  793. ),
  794. ),
  795. 'bx_if:image' => array (
  796. 'condition' => $bImage,
  797. 'content' => array(
  798. 'image_url' => $sImage,
  799. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40)
  800. ),
  801. ),
  802. 'bx_if:image_raw' => array (
  803. 'condition' => $bImageRaw,
  804. 'content' => array(
  805. 'image_raw' => $sImage,
  806. ),
  807. ),
  808. 'title' => $aItem['title'],
  809. 'bx_if:show_vendor' => array(
  810. 'condition' => !$bShoppingCart,
  811. 'content' => array(
  812. 'vendor_name' => $aItem['author_name'],
  813. 'vendor_url' => $aItem['author_url'],
  814. 'bx_if:show_version' => array(
  815. 'condition' => !empty($aItem['file_version']),
  816. 'content' => array(
  817. 'version' => $aItem['file_version'],
  818. )
  819. ),
  820. )
  821. ),
  822. 'bx_if:show_count_price' => array(
  823. 'condition' => $bShoppingCart,
  824. 'content' => array(
  825. 'count' => isset($aParams['counts'][$aItem['id']]) ? (int)$aParams['counts'][$aItem['id']] : 1,
  826. 'price_single' => $sPrice,
  827. 'discount_single' => $sDiscount,
  828. )
  829. ),
  830. 'bx_if:show_rate' => array(
  831. 'condition' => $bTmplVarsRate,
  832. 'content' => $aTmplVarsRate
  833. ),
  834. 'bx_if:show_votes' => array(
  835. 'condition' => $bTmplVarsVotes,
  836. 'content' => $aTmplVarsVotes
  837. ),
  838. 'bx_if:show_purchase_single' => array(
  839. 'condition' => $bPurchaseSingle && !$bInCart,
  840. 'content' => array(
  841. 'js_object' => $sJsObject,
  842. 'id' => $aItem['id'],
  843. 'vendor_id' => $aItem['author_id'],
  844. 'price_single' => _t('_adm_str_txt_price_single', $aItem['author_currency_sign'], $aItem['price_single'])
  845. )
  846. ),
  847. 'bx_if:show_checkout_single' => array(
  848. 'condition' => $bPurchaseSingle,
  849. 'content' => array(
  850. 'js_object' => $sJsObject,
  851. 'id' => $aItem['id'],
  852. 'vendor_id' => $aItem['author_id'],
  853. 'bx_if:show_as_hidden' => array(
  854. 'condition' => !$bInCart,
  855. 'content' => array()
  856. )
  857. )
  858. ),
  859. 'bx_if:show_purchase_recurring' => array(
  860. 'condition' => $bPurchaseRecurring,
  861. 'content' => array(
  862. 'js_object' => $sJsObject,
  863. 'id' => $aItem['id'],
  864. 'vendor_id' => $aItem['author_id'],
  865. 'price_recurring' => _t('_adm_str_txt_price_recurring', $aItem['author_currency_sign'], $aItem['price_recurring'], _t('_adm_str_txt_per_' . $aItem['duration_recurring'] . '_short'))
  866. )
  867. ),
  868. 'bx_if:show_download' => array(
  869. 'condition' => $bDownload && !$bQueued && !$bDownloaded,
  870. 'content' => array(
  871. 'js_object' => $sJsObject,
  872. 'file_id' => $aItem['file_id']
  873. )
  874. ),
  875. 'bx_if:show_download_disabled' => array(
  876. 'condition' => $bDownload && !$bQueued && $bDownloaded,
  877. 'content' => array()
  878. ),
  879. 'bx_if:show_queued_disabled' => array(
  880. 'condition' => $bDownload && $bQueued && !$bDownloaded,
  881. 'content' => array()
  882. ),
  883. 'bx_if:show_delete' => array(
  884. 'condition' => $bShoppingCart,
  885. 'content' => array(
  886. 'js_object' => $sJsObject,
  887. 'id' => $aItem['id'],
  888. 'vendor_id' => $aItem['author_id']
  889. )
  890. )
  891. ));
  892. }
  893. return $sResult;
  894. }
  895. protected function displayUpdates($mixedItems, $aParams = array())
  896. {
  897. if(!is_array($mixedItems))
  898. return MsgBox($mixedItems);
  899. if(empty($mixedItems))
  900. return MsgBox(_t('_Empty'));
  901. $sJsObject = $this->getPageJsObject();
  902. $oTemplate = BxDolStudioTemplate::getInstance();
  903. $sResult = '';
  904. foreach($mixedItems as $aItem) {
  905. $bDownloadable = (int)$aItem['is_file'] == 1;
  906. $bQueued = $this->oDb->isQueued('download', $aItem['name']);
  907. $sIcon = !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : BxDolStudioUtils::getIconDefault(BX_DOL_MODULE_TYPE_MODULE);
  908. $bIcon = strpos($sIcon, '.') !== false;
  909. $sImage = !empty($aItem['cover']['big']) ? $aItem['cover']['big'] : '';
  910. $bImage = strpos($sImage, '.') !== false;
  911. $sResult .= $oTemplate->parseHtmlByName('str_update_v2.html', array(
  912. 'js_object' => $sJsObject,
  913. 'id' => $aItem['id'],
  914. 'name' => $aItem['name'],
  915. 'url' => $aItem['url'],
  916. 'bx_if:no_icon' => array (
  917. 'condition' => !$bIcon,
  918. 'content' => array(
  919. 'icon' => $sIcon
  920. ),
  921. ),
  922. 'bx_if:icon' => array (
  923. 'condition' => $bIcon,
  924. 'content' => array(
  925. 'icon_url' => $sIcon,
  926. ),
  927. ),
  928. 'bx_if:no_image' => array (
  929. 'condition' => !$bImage,
  930. 'content' => array(
  931. 'note' => $aItem['description_plain'],
  932. 'strecher' => mb_strlen($aItem['description_plain']) > 240 ? '' : str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', round((240 - mb_strlen($aItem['description_plain'])) / 6))
  933. ),
  934. ),
  935. 'bx_if:image' => array (
  936. 'condition' => $bImage,
  937. 'content' => array(
  938. 'image_url' => $sImage,
  939. 'strecher' => str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ', 40)
  940. ),
  941. ),
  942. 'title' => $aItem['title'],
  943. 'vendor' => $aItem['author_name'],
  944. 'versions' => _t('_adm_str_txt_update_from_to', $aItem['file_version'], $aItem['file_version_to']),
  945. 'bx_if:show_download' => array(
  946. 'condition' => $bDownloadable && !$bQueued,
  947. 'content' => array(
  948. 'caption' => _t('_adm_btn_install_submit'),
  949. 'on_click' => $sJsObject . ".getUpdateAndInstall('" . $aItem['name'] . "', this)"
  950. )
  951. ),
  952. 'bx_if:show_queued_disabled' => array(
  953. 'condition' => $bDownloadable && $bQueued,
  954. 'content' => array()
  955. )
  956. ));
  957. }
  958. return $sResult;
  959. }
  960. protected function displayCategories($aCategories)
  961. {
  962. foreach($aCategories['bx_repeat:cats'] as $iKey => $aItem)
  963. $aCategories['bx_repeat:cats'][$iKey]['url'] = $this->getBaseUrl(array('page' => 'category', 'value' => $aItem['value'], 'title' => urlencode($aItem['name'])));
  964. return BxDolStudioTemplate::getInstance()->parseHtmlByName('str_lbl_categories.html', $aCategories);
  965. }
  966. protected function displayTags($aTags)
  967. {
  968. foreach($aTags['bx_repeat:units'] as $iKey => $aItem)
  969. $aTags['bx_repeat:units'][$iKey]['href'] = $this->getBaseUrl(array('page' => 'tag', 'value' => $aItem['keyword']));
  970. return BxDolStudioTemplate::getInstance()->parseHtmlByName('str_lbl_tags.html', $aTags);
  971. }
  972. protected function displayNonOwnerNotification()
  973. {
  974. if(BxDolStudioOAuth::isAuthorizedOwner())
  975. return;
  976. $oSession = BxDolSession::getInstance();
  977. if($oSession->getValue($this->sSessionKeyNonOwnerNotified) === true)
  978. return;
  979. $oSession->setValue($this->sSessionKeyNonOwnerNotified, true);
  980. return $this->getJsResultBy(array(
  981. 'message' => '_adm_msg_oauth_non_owner_logged',
  982. 'translate' => array(BX_DOL_MARKET_URL_ROOT),
  983. 'on_page_load' => true
  984. ));
  985. }
  986. private function getDownloadedModules($bNamesOnly = true)
  987. {
  988. $aModules = BxDolStudioInstallerUtils::getInstance()->getModules(false);
  989. return $bNamesOnly ? array_keys($aModules) : $aModules;
  990. }
  991. private function getVoteStars($aItem)
  992. {
  993. $aTmplVarsStars = array();
  994. for($i = (int)$aItem['rate_min']; $i <= (int)$aItem['rate_max']; $i++)
  995. $aTmplVarsStars[] = array('value' => $i);
  996. return BxDolStudioTemplate::getInstance()->parseHtmlByName('str_vote_stars.html', array(
  997. 'id' => $aItem['id'],
  998. 'value' => (float)$aItem['rate'],
  999. 'bx_repeat:stars' => $aTmplVarsStars,
  1000. 'bx_repeat:slider' => $aTmplVarsStars,
  1001. ));
  1002. }
  1003. }
  1004. /** @} */