| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup TridentView Trident Studio Representation classes
- * @ingroup TridentStudio
- * @{
- */
- class BxBaseStudioStore extends BxDolStudioStore
- {
- protected $iPerPageDefault = 24;
- function __construct($sPage = "")
- {
- parent::__construct($sPage);
- }
- function getPageCss()
- {
- return array_merge(parent::getPageCss(), array('modules.css', 'store.css', 'store-media-tablet.css', 'store-media-desktop.css'));
- }
- function getPageJs()
- {
- BxDolStudioTemplate::getInstance()->addJsTranslation(array('_adm_btn_queued_submit'));
- return array_merge(parent::getPageJs(), array('fancybox/jquery.fancybox.pack.js', 'store.js'));
- }
- function getPageJsObject()
- {
- return 'oBxDolStudioStore';
- }
- function getPageMenu($aMenu = array(), $aMarkers = array())
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aMenu = array();
- $aMenuItems = array(
- 'goodies' => array('icon' => 'home'),
- 'featured' => array('icon' => 'thumbs-up'),
- 'purchases' => array('icon' => 'shopping-cart'),
- 'updates' => array('icon' => 'refresh'),
- 'checkout' => array('icon' => 'credit-card'),
- 'downloaded' => array('icon' => 'list')
- );
- foreach($aMenuItems as $sMenuItem => $aItem)
- $aMenu[] = array(
- 'name' => $sMenuItem,
- 'icon' => $aItem['icon'],
- 'link' => BX_DOL_URL_STUDIO . 'store.php?page=' . $sMenuItem,
- 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
- 'selected' => $sMenuItem == $this->sPage
- );
- $iCounter = BxDolStudioCart::getInstance()->getCount();
- $aMarkers = array(
- 'checkout_counter' => $oTemplate->parseHtmlByName('menu_side_counter.html', array(
- 'bx_if:hide_counter' => array(
- 'condition' => $iCounter <= 0,
- 'content' => array()
- ),
- 'counter' => $iCounter
- ))
- );
- return parent::getPageMenu($aMenu, $aMarkers);
- }
- function getPageCode($bHidden = false)
- {
- $sMethod = 'get' . ucfirst($this->sPage) . 'List';
- if(!method_exists($this, $sMethod))
- return '';
- return $this->$sMethod();
- }
- function getPageContent()
- {
- $sMethod = 'get' . ucfirst($this->sPage) . 'List';
- if(!method_exists($this, $sMethod))
- return '';
- return $this->$sMethod(false);
- }
- protected function getGoodiesList()
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
- if($mixedResult === true) {
- $aProducts = $this->loadGoodies();
- $sContent = "";
- foreach($aProducts as $aBlock) {
- $aBlock['items'] = $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayProducts($aBlock['items']),
- 'paginate' => ''
- ));
- $sContent .= $this->getBlockCode($aBlock);
- }
- }
- else
- $sContent = $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_goodies',
- 'items' => $mixedResult,
- ));
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $sJsObject,
- 'content' => $sContent
- ));
- }
- protected function getFeaturedList($bWrapInBlock = true)
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
- if($mixedResult === true) {
- $iStart = (int)bx_get('str_start');
- $iPerPage = (int)bx_get('str_per_page');
- if(empty($iPerPage))
- $iPerPage = $this->iPerPageDefault;
- $aProducts = $this->loadFeatured($iStart, $iPerPage + 1);
- $oPaginate = new BxTemplPaginate(array(
- 'start' => $iStart,
- 'per_page' => $iPerPage,
- 'on_change_page' => $sJsObject . ".changePagePaginate(this, 'featured', {start}, {per_page})"
- ));
- $oPaginate->setNumFromDataArray($aProducts);
- $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayProducts($aProducts),
- 'paginate' => $oPaginate->getSimplePaginate()
- ));
- }
- else
- $sContent = $mixedResult;
- if(!$bWrapInBlock)
- return $sContent;
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $sJsObject,
- 'content' => $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_featured',
- 'items' => $sContent
- ))
- ));
- }
- protected function getExtensionsList($bWrapInBlock = true)
- {
- return $this->getCategory('extensions', $bWrapInBlock);
- }
- protected function getTemplatesList($bWrapInBlock = true)
- {
- return $this->getCategory('templates', $bWrapInBlock);
- }
- protected function getTranslationsList($bWrapInBlock = true)
- {
- return $this->getCategory('translations', $bWrapInBlock);
- }
- protected function getTag($sLabel, $bWrapInBlock = true)
- {
- return $this->getLabel('tag', $sLabel, $bWrapInBlock);
- }
- protected function getCategory($sLabel, $bWrapInBlock = true)
- {
- return $this->getLabel('category', $sLabel, $bWrapInBlock);
- }
- protected function getLabel($sType, $sLabel, $bWrapInBlock = true)
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $iStart = (int)bx_get('str_start');
- $iPerPage = (int)bx_get('str_per_page');
- if(empty($iPerPage))
- $iPerPage = $this->iPerPageDefault;
- $sMethod = 'load' . bx_gen_method_name($sType);
- $aProducts = $this->$sMethod($sLabel, $iStart, $iPerPage + 1);
- $oPaginate = new BxTemplPaginate(array(
- 'start' => $iStart,
- 'per_page' => $iPerPage,
- 'on_change_page' => $sJsObject . ".changePagePaginate(this, '" . $sLabel . "', {start}, {per_page})"
- ));
- $oPaginate->setNumFromDataArray($aProducts);
- $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayProducts($aProducts),
- 'paginate' => $oPaginate->getSimplePaginate()
- ));
- if(!$bWrapInBlock)
- return $sContent;
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $sJsObject,
- 'content' => $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_' . $sLabel,
- 'items' => $sContent,
- ))
- ));
- }
- protected function getPurchasesList()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aProducts = $this->loadPurchases();
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $this->getPageJsObject(),
- 'content' => $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_purchases',
- 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayProducts($aProducts),
- 'paginate' => ''
- ))
- ))
- ));
- }
- protected function getUpdatesList()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aUpdates = $this->loadUpdates();
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $this->getPageJsObject(),
- 'content' => $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_updates',
- 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayUpdates($aUpdates),
- 'paginate' => ''
- ))
- ))
- ));
- }
- protected function getCheckoutList()
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- //--- Empty cart by vendor if the payment was accepted.
- $mixedVendor = bx_get('vendor');
- $mixedProducts = bx_get('products');
- if($mixedVendor !== false && $mixedProducts !== false) {
- $oCart = BxDolStudioCart::getInstance();
- $aProducts = explode(',', base64_decode($mixedProducts));
- foreach($aProducts as $iId)
- $oCart->delete($mixedVendor, $iId);
- return $this->getMessage('_adm_block_cpt_checkout', '_adm_msg_modules_success_checkouted');
- }
- $aVendors = $this->loadCheckout();
- if(empty($aVendors))
- return $this->getMessage('_adm_block_cpt_checkout', '_Empty');
- $sContent = '';
- foreach($aVendors as $iVendor => $aInfo) {
- $fTotal = 0;
- $sVendor = $sCurrency = '';
- foreach($aInfo['products'] as $aProduct) {
- $iCount = isset($aInfo['counts'][$aProduct['id']]) ? (int)$aInfo['counts'][$aProduct['id']] : 1;
- $fTotal += $iCount * $aProduct['price'];
- if($sVendor == '' && isset($aProduct['author_name']))
- $sVendor = $aProduct['author_name'];
- if($sCurrency == '' && isset($aProduct['currency_sign']))
- $sCurrency = $aProduct['currency_sign'];
- }
- $aMenu = array(
- 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),
- 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)
- );
- $oMenu = new BxTemplMenu(array('template' => 'menu_buttons_hor.html', 'menu_id'=> 'timeline-view-all', 'menu_items' => $aMenu));
- $sContent .= $this->getBlockCode(array(
- 'caption' => _t('_adm_block_cpt_checkout_by_vendor_csign', $sVendor, $sCurrency, $fTotal),
- 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $this->displayProducts($aInfo['products'], array('is_shopping_cart' => true, 'counts' => $aInfo['counts'])),
- 'paginate' => ''
- )),
- 'panel_bottom' => $oMenu->getCode()
- ));
- }
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $sJsObject,
- 'content' => $sContent
- ));
- }
- protected function getDownloadedList()
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sContent = $sModules = $sUpdates = "";
- $aProducts = $this->loadDownloaded();
- //--- Prepare modules.
- foreach($aProducts['modules'] as $aModule) {
- $sIcon = BxDolStudioUtils::getModuleIcon($aModule, 'store');
- $bIcon = strpos($sIcon, '.') === false;
- $bInstalled = $aModule['installed'];
- $bQueued = !$bInstalled && $this->oDb->isQueued('action', $aModule['dir']);
-
- $sModules .= $oTemplate->parseHtmlByName('str_product_v1.html', array(
- 'js_object' => $sJsObject,
- 'name' => $aModule['name'],
- 'bx_if:icon' => array (
- 'condition' => $bIcon,
- 'content' => array('icon' => $sIcon),
- ),
- 'bx_if:image' => array (
- 'condition' => !$bIcon,
- 'content' => array('icon_url' => $sIcon),
- ),
- 'title' => $aModule['title'],
- 'vendor' => $aModule['vendor'],
- 'version' => $aModule['version'],
- 'dir' => $aModule['dir'],
- 'bx_if:hide_install' => array(
- 'condition' => $bInstalled || $bQueued,
- 'content' => array()
- ),
- 'bx_if:hide_queued' => array(
- 'condition' => !$bQueued,
- 'content' => array()
- ),
- 'bx_if:hide_installed' => array(
- 'condition' => !$bInstalled || $bQueued,
- 'content' => array()
- )
- ));
- }
- //--- Prepare updates.
- foreach($aProducts['updates'] as $aUpdate) {
- $sIcon = BxDolStudioUtils::getModuleIcon(array('type' => $aUpdate['module_type'], 'name' => $aUpdate['module_name'], 'dir' => $aUpdate['module_dir']), 'store');
- $bIcon = strpos($sIcon, '.') === false;
- $sUpdates .= $oTemplate->parseHtmlByName('str_update_v1.html', array(
- 'js_object' => $sJsObject,
- 'name' => $aUpdate['module_name'],
- 'bx_if:icon' => array (
- 'condition' => $bIcon,
- 'content' => array('icon' => $sIcon),
- ),
- 'bx_if:image' => array (
- 'condition' => !$bIcon,
- 'content' => array('icon_url' => $sIcon),
- ),
- 'title' => $aUpdate['title'],
- 'vendor' => $aUpdate['vendor'],
- 'versions' => _t('_adm_str_txt_update_from_to', $aUpdate['version_from'], $aUpdate['version_to']),
- 'dir' => $aUpdate['dir']
- ));
- }
- if(!empty($sModules))
- $sContent .= $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_downloaded_modules',
- 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $sModules,
- 'paginate' => ''
- )),
- ));
- if(!empty($sUpdates))
- $sContent .= $this->getBlockCode(array(
- 'caption' => '_adm_block_cpt_downloaded_updates',
- 'items' => $oTemplate->parseHtmlByName('str_products.html', array(
- 'list' => $sUpdates,
- 'paginate' => ''
- )),
- ));
- return $oTemplate->parseHtmlByName('store.html', array(
- 'js_object' => $sJsObject,
- 'content' => $sContent
- ));
- }
- protected function getMessage($sCaption, $sContent, $aActions = array())
- {
- return BxDolStudioTemplate::getInstance()->parseHtmlByName('store.html', array(
- 'js_object' => $this->getPageJsObject(),
- 'content' => $this->getBlockCode(array(
- 'caption' => $sCaption,
- 'actions' => $aActions,
- 'items' => MsgBox(_t($sContent))
- ))
- ));
- }
- protected function getProduct($sModuleName)
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aProduct = $this->loadProduct($sModuleName);
- if(empty($aProduct) || !is_array($aProduct))
- return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($aProduct) ? $aProduct : _t('_adm_str_err_no_product_info')));
- $aDownloaded = $this->getDownloadedModules(false);
- $bFree = (int)$aProduct['is_free'] == 1;
- $bPurchased = (int)$aProduct['is_purchased'] == 1;
- $bPurchase = !$bFree && !$bPurchased;
- $bInCart = $bPurchase && BxDolStudioCart::getInstance()->exists($aProduct['author_id'], $aProduct['id']);
- $bDownloadable = (int)$aProduct['is_file'] == 1;
- $bDownloaded = array_key_exists($sModuleName, $aDownloaded);
- $bDownload = ($bFree || $bPurchased) && $bDownloadable;
- $bDiscount = !empty($aProduct['discount']);
- $sVersion = $bDownloaded && version_compare($aDownloaded[$sModuleName]['version'], $aProduct['version']) != 0 ? _t('_adm_str_txt_pv_version_mask', $aDownloaded[$sModuleName]['version'], $aProduct['version']) : $aProduct['version'];
- $iScreenshots = 0;
- $aScreenshots = array();
- $bScreenshots = is_array($aProduct['screenshots']) && !empty($aProduct['screenshots']);
- if($bScreenshots) {
- $iScreenshots = count($aProduct['screenshots']);
- foreach($aProduct['screenshots'] as $aScreenshot)
- $aScreenshots[] = array(
- 'view_url' => $aProduct['url'],
- 'image_url' => $aScreenshot['big']
- );
- }
- $sContent = $oTemplate->parseHtmlByname('str_product_view.html', array(
- 'id' => $aProduct['id'],
- 'title' => $aProduct['title'],
- 'url' => $aProduct['url'],
- 'author_name' => $aProduct['author_name'],
- 'author_url' => $aProduct['author_url'],
- 'version' => $sVersion,
- 'price' => !$bFree ? _t('_adm_str_txt_price_csign', $aProduct['author_currency_sign'], $aProduct['price']) : _t('_adm_str_txt_price_free'),
- 'bx_if:show_discount' => array(
- 'condition' => !$bFree && $bDiscount,
- 'content' => array(
- 'discount' => $bDiscount ? _t('_adm_str_txt_pv_discount_off_csign', $aProduct['discount']['percent'], $aProduct['author_currency_sign'], $aProduct['discount']['save']) : ''
- )
- ),
- 'category' => $aProduct['category'],
- 'category_url' => $aProduct['category_url'],
- 'tags' => implode(', ', explode(',', $aProduct['tags'])),
- 'reviews' => _t('_adm_str_txt_pv_stats_reviews', $aProduct['reviews_cnt']),
- 'reviews_url' => $aProduct['reviews_url'],
- 'likes' => _t('_adm_str_txt_pv_stats_likes', $aProduct['likes_cnt']),
- 'views' => _t('_adm_str_txt_pv_stats_views', $aProduct['views_cnt']),
- 'created' => bx_time_js($aProduct['created']),
- 'updated' => bx_time_js($aProduct['updated']),
- 'description' => $aProduct['description'],
- 'bx_if:show_screenshots' => array(
- 'condition' => $bScreenshots,
- 'content' => array(
- 'width' => 222 * $iScreenshots - 20,
- 'bx_repeat:screenshots' => $aScreenshots
- )
- ),
- 'bx_if:show_purchase' => array(
- 'condition' => $bPurchase && !$bInCart,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'id' => $aProduct['id'],
- 'vendor_id' => $aProduct['author_id'],
- )
- ),
- 'bx_if:show_checkout' => array(
- 'condition' => $bPurchase,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'id' => $aProduct['id'],
- 'vendor_id' => $aProduct['author_id'],
- 'bx_if:show_as_hidden' => array(
- 'condition' => !$bInCart,
- 'content' => array()
- )
- )
- ),
- 'bx_if:show_download' => array(
- 'condition' => $bDownload && !$bDownloaded,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'file_id' => $aProduct['file_id'],
- )
- ),
- 'bx_if:show_download_disabled' => array(
- 'condition' => $bDownload && $bDownloaded,
- 'content' => array()
- ),
- ));
- return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => '', 'popup' => PopupBox('bx-std-str-popup-product', $aProduct['title'], $sContent, true), 'screenshots' => $iScreenshots);
- }
- protected function getFile($iFileId)
- {
- $mixedResult = $this->loadFile($iFileId);
- if($mixedResult === true)
- return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download_successfully'));
- if(is_string($mixedResult))
- return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
- if(is_array($mixedResult))
- return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
- }
- protected function getUpdate($sModuleName, $bAutoUpdate = false)
- {
- $mixedResult = $this->loadUpdate($sModuleName, $bAutoUpdate);
- if($mixedResult === true)
- return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download' . ($bAutoUpdate ? '_and_install' : '') . '_successfully'));
- if(is_string($mixedResult))
- return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
- if(is_array($mixedResult))
- return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
- }
- protected function displayProducts($mixedItems, $aParams = array())
- {
- if(!is_array($mixedItems))
- return MsgBox($mixedItems);
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aDownloaded = $this->getDownloadedModules();
- $bShoppingCart = isset($aParams['is_shopping_cart']) && $aParams['is_shopping_cart'];
- $sResult = '';
- foreach($mixedItems as $aItem) {
- $bFree = (int)$aItem['is_free'] == 1;
- $bPurchased = (int)$aItem['is_purchased'] == 1;
- $bPurchase = !$bShoppingCart && !$bFree && !$bPurchased;
- $bInCart = $bPurchase && BxDolStudioCart::getInstance()->exists($aItem['author_id'], $aItem['id']);
- $bDownloadable = (int)$aItem['is_file'] == 1;
- $bDownloaded = in_array($aItem['name'], $aDownloaded);
- $bDownload = !$bShoppingCart && ($bFree || $bPurchased) && $bDownloadable;
- $bQueued = $this->oDb->isQueued('download', $aItem['name']);
- $sPrice = !$bFree ? _t('_adm_str_txt_price_csign', $aItem['currency_sign'], $aItem['price']) : _t('_adm_str_txt_price_free');
- $sDiscount = !$bFree && !empty($aItem['discount']) ? _t('_adm_str_txt_discount_csign', $aItem['currency_sign'], $aItem['discount']['price']) : '';
- $sIcon = !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : BxDolStudioUtils::getIconDefault(BX_DOL_MODULE_TYPE_MODULE);
- $bIcon = strpos($sIcon, '.') === false;
- $sResult .= $oTemplate->parseHtmlByName('str_product_v2.html', array(
- 'js_object' => $sJsObject,
- 'id' => $aItem['id'],
- 'name' => $aItem['name'],
- 'url' => $aItem['url'],
- 'bx_if:icon' => array (
- 'condition' => $bIcon,
- 'content' => array('icon' => $sIcon),
- ),
- 'bx_if:image' => array (
- 'condition' => !$bIcon,
- 'content' => array('icon_url' => $sIcon),
- ),
- 'title' => $aItem['title'],
- 'bx_if:show_vendor_price' => array(
- 'condition' => !$bShoppingCart,
- 'content' => array(
- 'vendor_name' => $aItem['author_name'],
- 'price' => $sPrice,
- 'discount' => $sDiscount,
- )
- ),
- 'bx_if:show_count_price' => array(
- 'condition' => $bShoppingCart,
- 'content' => array(
- 'count' => isset($aParams['counts'][$aItem['id']]) ? (int)$aParams['counts'][$aItem['id']] : 1,
- 'price' => $sPrice,
- 'discount' => $sDiscount,
- )
- ),
- 'bx_if:show_purchase' => array(
- 'condition' => $bPurchase && !$bInCart,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'id' => $aItem['id'],
- 'vendor_id' => $aItem['author_id']
- )
- ),
- 'bx_if:show_checkout' => array(
- 'condition' => $bPurchase,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'id' => $aItem['id'],
- 'vendor_id' => $aItem['author_id'],
- 'bx_if:show_as_hidden' => array(
- 'condition' => !$bInCart,
- 'content' => array()
- )
- )
- ),
- 'bx_if:show_download' => array(
- 'condition' => $bDownload && !$bQueued && !$bDownloaded,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'file_id' => $aItem['file_id']
- )
- ),
- 'bx_if:show_download_disabled' => array(
- 'condition' => $bDownload && !$bQueued && $bDownloaded,
- 'content' => array()
- ),
- 'bx_if:show_queued_disabled' => array(
- 'condition' => $bDownload && $bQueued && !$bDownloaded,
- 'content' => array()
- ),
- 'bx_if:show_delete' => array(
- 'condition' => $bShoppingCart,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'id' => $aItem['id'],
- 'vendor_id' => $aItem['author_id']
- )
- )
- ));
- }
- return $sResult;
- }
- protected function displayUpdates($mixedItems, $aParams = array())
- {
- if(!is_array($mixedItems))
- return MsgBox($mixedItems);
- if(empty($mixedItems))
- return MsgBox(_t('_Empty'));
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sResult = '';
- foreach($mixedItems as $aItem) {
- $bDownloadable = (int)$aItem['is_file'] == 1;
- $sIcon = !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : BxDolStudioUtils::getIconDefault(BX_DOL_MODULE_TYPE_MODULE);
- $bIcon = strpos($sIcon, '.') === false;
- $sResult .= $oTemplate->parseHtmlByName('str_update_v2.html', array(
- 'js_object' => $sJsObject,
- 'id' => $aItem['id'],
- 'name' => $aItem['name'],
- 'url' => $aItem['url'],
- 'bx_if:icon' => array (
- 'condition' => $bIcon,
- 'content' => array('icon' => $sIcon),
- ),
- 'bx_if:image' => array (
- 'condition' => !$bIcon,
- 'content' => array('icon_url' => $sIcon),
- ),
- 'title' => $aItem['title'],
- 'vendor' => $aItem['author_name'],
- 'versions' => _t('_adm_str_txt_update_from_to', $aItem['file_version'], $aItem['file_version_to']),
- 'bx_if:show_download' => array(
- 'condition' => $bDownloadable,
- 'content' => array(
- 'caption' => _t($this->bAuthAccessUpdates ? '_adm_btn_download_submit' : '_adm_btn_install_submit'),
- 'on_click' => $sJsObject . "." . ($this->bAuthAccessUpdates ? "getFile(" . $aItem['file_id'] . ", this)" : "getUpdateAndInstall('" . $aItem['name'] . "', this)")
- )
- )
- ));
- }
- return $sResult;
- }
- private function getDownloadedModules($bNamesOnly = true)
- {
- $aModules = BxDolStudioInstallerUtils::getInstance()->getModules(false);
- return $bNamesOnly ? array_keys($aModules) : $aModules;
- }
- }
- /** @} */
|