22 parent::__construct($oConfig,
$oDb);
25 function unit ($aData, $sTemplateName, &$oVotingView, $isShort =
false)
27 if (
null == $this->_oMain)
30 if (!$this->_oMain->isAllowedView ($aData)) {
31 $aVars = array (
'extra_css_class' =>
'ch_store_unit');
36 if ($aData[
'thumb']) {
37 $a = array (
'ID' => $aData[
'author_id'],
'Avatar' => $aData[
'thumb']);
39 $sImage = $aImage[
'no_image'] ?
'' : $aImage[
'file'];
44 'thumb_url' => $sImage ? $sImage : $this->
getImageUrl(
'no-image-thumb.png'),
45 'product_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aData[
'uri'],
46 'product_title' => $aData[
'title'],
47 'price_range' => $this->_oMain->_formatPriceRange($aData),
48 'snippet_text' => $this->_oMain->_formatSnippetText($aData, 500),
49 'ch_if:full' => array (
50 'condition' => !$isShort,
53 'author' => $aData[
'author_id'] ?
getNickName($aData[
'author_id']) :
_t(
'_ch_store_admin'),
54 'author_url' => $aData[
'author_id'] ?
getProfileLink($aData[
'author_id']) :
'javascript:void(0);',
55 'rate' => $oVotingView ? $oVotingView->getJustVotingElement(0, $aData[
'id'], $aData[
'rate']) :
' ',
68 'description' => $aDataEntry[
'desc'],
75 $iEntryId = $aData[
'id'];
76 $aReadyMedia = array ();
78 $aReadyMedia =
$GLOBALS[
'oChStoreModule']->_oDb->getFiles($iEntryId,
true);
84 'ch_repeat:files' => array (),
90 $sCurrencySign =
getParam(
'pmt_default_currency_sign');
91 foreach ($aReadyMedia
as $r) {
93 $iMediaId = $r[
'media_id'];
102 $aInputBtnDownload = array (
104 'name' =>
'ch_store_download',
105 'value' =>
_t (
'_ch_store_download'),
107 'onclick' =>
"window.open ('" . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
"download/{$r['id']}','_self');",
111 $aVars[
'ch_repeat:files'][] = array (
113 'title' => $a[
'title'],
114 'icon' => $a[
'file'],
115 'price' => $sCurrencySign .
' ' . $r[
'price'],
116 'for_group' => sprintf(
_t(
'_ch_store_for_group'),
$GLOBALS[
'oChStoreModule']->getGroupName($r[
'allow_purchase_to'])),
118 'ch_if:purchase' => array (
119 'condition' =>
$GLOBALS[
'oChStoreModule']->isAllowedPurchase($r),
121 'btn_purchase' => $oPayment->getAddToCartLink($r[
'author_id'], $this->_oConfig->getId(), $r[
'id'], 1),
124 'ch_if:download' => array (
125 'condition' =>
$GLOBALS[
'oChStoreModule']->isAllowedDownload($r),
127 'btn_download' =>
$oForm->genInputButton ($aInputBtnDownload),
133 if (!
$aVars[
'ch_repeat:files'])
141 $sRet =
'<table class="ch_store_fields">';
144 foreach (
$oForm->aInputs
as $k => $a) {
145 if (!isset($a[
'display']))
continue;
146 $sRet .=
'<tr><td class="ch_store_field_name ch-def-font-grayed ch-def-padding-sec-right" valign="top">' . $a[
'caption'] .
'</td><td class="ch_store_field_value">';
147 if (is_string($a[
'display']) && is_callable(array($this, $a[
'display'])))
148 $sRet .= call_user_func_array(array($this, $a[
'display']), array($aDataEntry[$k]));
150 $sRet .= $aDataEntry[$k];
151 $sRet .=
'</td></tr>';