BxBaseStudioStore.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  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. defined('BX_DOL') or die('hack attempt');
  11. bx_import('BxDolStudioStore');
  12. bx_import('BxTemplStudioFunctions');
  13. class BxBaseStudioStore extends BxDolStudioStore {
  14. function BxBaseStudioStore($sPage = "") {
  15. parent::BxDolStudioStore($sPage);
  16. }
  17. function getPageCss() {
  18. return array_merge(parent::getPageCss(), array('store.css'));
  19. }
  20. function getPageJs() {
  21. return array_merge(parent::getPageJs(), array('store.js'));
  22. }
  23. function getPageJsObject() {
  24. return 'oBxDolStudioStore';
  25. }
  26. function getPageMenu() {
  27. $sJsObject = $this->getPageJsObject();
  28. $aMenu = array();
  29. $aMenuItems = array('goodies', 'featured', 'purchases', 'updates', 'checkout');
  30. foreach($aMenuItems as $sMenuItem)
  31. $aMenu[] = array(
  32. 'name' => $sMenuItem,
  33. 'icon' => 'mi-str-' . $sMenuItem . '.png',
  34. 'link' => BX_DOL_URL_STUDIO . 'store.php?page=' . $sMenuItem,
  35. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  36. 'selected' => $sMenuItem == $this->sPage
  37. );
  38. return parent::getPageMenu($aMenu);
  39. }
  40. function getPageCode() {
  41. $sMethod = 'get' . ucfirst($this->sPage);
  42. if(!method_exists($this, $sMethod))
  43. return '';
  44. return $this->$sMethod();
  45. }
  46. protected function getGoodies() {
  47. $sJsObject = $this->getPageJsObject();
  48. $oTemplate = BxDolStudioTemplate::getInstance();
  49. $aProducts = $this->loadGoodies();
  50. $TmplVars = array(
  51. 'js_object' => $sJsObject,
  52. 'bx_repeat:blocks' => array()
  53. );
  54. $sActions = "";
  55. foreach($aProducts as $aBlock) {
  56. $sItems = "";
  57. foreach($aBlock['items'] as $aProduct)
  58. $sItems .= $oTemplate->parseHtmlByName('product.html', array());
  59. $TmplVars['bx_repeat:blocks'][] = array(
  60. 'caption' => $this->getBlockCaption($aBlock),
  61. 'items' => $sItems
  62. );
  63. }
  64. return $oTemplate->parseHtmlByName('store.html', $TmplVars);
  65. }
  66. protected function getPurchases() {
  67. $sJsObject = $this->getPageJsObject();
  68. $oTemplate = BxDolStudioTemplate::getInstance();
  69. $aProducts = $this->loadPurchases();
  70. $sItems = "";
  71. foreach($aProducts as $aProduct) {
  72. $sIcon = $oTemplate->getIconUrl($aProduct['name'] . '@modules/' . $aProduct['dir'] . '|std-si.png');
  73. if(empty($sIcon))
  74. $sIcon = $oTemplate->getIconUrl('pi-str-dump.png');
  75. $sItems .= $oTemplate->parseHtmlByName('product.html', array(
  76. 'js_object' => $sJsObject,
  77. 'url' => $aProduct['link_market'],
  78. 'icon' => $sIcon,
  79. 'title' => $aProduct['title'],
  80. 'vendor' => $aProduct['vendor'],
  81. 'dir' => $aProduct['dir'],
  82. 'bx_if:hide_install' => array(
  83. 'condition' => $aProduct['installed'],
  84. 'content' => array()
  85. ),
  86. 'bx_if:hide_installed' => array(
  87. 'condition' => !$aProduct['installed'],
  88. 'content' => array()
  89. )
  90. ));
  91. }
  92. $TmplVars = array(
  93. 'js_object' => $sJsObject,
  94. 'bx_repeat:blocks' => array(
  95. array(
  96. 'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_purchases'), 'actions' => array())),
  97. 'items' => $sItems
  98. )
  99. )
  100. );
  101. return $oTemplate->parseHtmlByName('store.html', $TmplVars);
  102. }
  103. }
  104. /** @} */