18 $this->_aMedia = array ();
20 $this->_aMedia[
'images'] = array (
21 'post' =>
'ready_images',
22 'upload_func' =>
'uploadPhotos',
27 'title_upload_post' =>
'images_titles',
28 'title_upload' =>
_t(
'_ch_store_form_caption_file_title'),
29 'service_method' =>
'get_photo_array',
33 $this->_aMedia[
'videos'] = array (
34 'post' =>
'ready_videos',
35 'upload_func' =>
'uploadVideos',
40 'title_upload' =>
_t(
'_ch_store_form_caption_file_title'),
41 'service_method' =>
'get_video_array',
44 $this->_oMain = $oMain;
45 $this->_oDb = $oMain->_oDb;
49 $oCategories->getTagObjectConfig ();
58 $aFilesChoice = array ();
59 $sCurrencySign =
getParam(
'pmt_default_currency_sign');
60 foreach ($aFilesChoiceOrig
as $k => $r) {
61 if (!$r[
'checked'])
continue;
62 $a =
$GLOBALS[
'oChStoreModule']->_oDb->getFileInfo ($iEntryId, $r[
'id']);
63 $r[
'file_id'] = $a[
'id'];
64 $r[
'title'] .=
' - ' . $sCurrencySign .
' ' . $a[
'price'] .
' (' .
$GLOBALS[
'oChStoreModule']->getGroupName($a[
'allow_purchase_to']) .
')';
65 $r[
'visibility'] = $a[
'hidden'] ?
_t(
'_ch_store_product_file_hidden') :
_t(
'_ch_store_product_file_visible');
68 $aVarsFilesChoice = array(
69 'ch_store_base_url' => $this->_oMain->_oConfig->getBaseUri(),
70 'ch_if:empty' => array(
71 'condition' =>
empty($aFilesChoice),
74 'ch_repeat:files' => $aFilesChoice,
77 $aInputPrivacyPurchase =
$GLOBALS[
'oChStoreModule']->_oPrivacyProduct->getGroupChooser(
$iProfileId,
'store',
'purchase');
78 foreach ($aInputPrivacyPurchase[
'values']
as $k => $r) {
80 unset ($aInputPrivacyPurchase[
'values'][$k]);
85 require_once(CH_DIRECTORY_PATH_INC .
'membership_levels.inc.php');
90 $aMemberships = array(
'' =>
'----') + $aMemberships;
91 $aMembershipsValues = array ();
92 foreach ($aMemberships
as $k => $v)
93 $aMembershipsValues[] = array (
'key' => $k ?
'm' . $k : $k,
'value' => $v);
94 $aInputPrivacyPurchase[
'values'] = array_merge($aInputPrivacyPurchase[
'values'], $aMembershipsValues);
99 $sInputPrivacyPurchase = str_replace(
'name="allow_purchase_to"',
'name="allow_purchase_to[]"', $this->
genInputSelect($aInputPrivacyPurchase));
101 $aVarsFilesUpload = array (
103 'title' =>
'files_titles',
104 'file_upload_title' =>
_t(
'_ch_store_form_caption_file_title'),
105 'ch_if:price' => array (
106 'condition' =>
true,
'content' => array(
'price' =>
'files_prices',
'file_price_title' =>
_t(
'_ch_store_form_caption_file_price'))
108 'ch_if:privacy' => array (
109 'condition' =>
true,
'content' => array(
'select' => $sInputPrivacyPurchase,
'file_permission_title' =>
_t(
'_ch_store_form_caption_file_allow_purcase_to'))
115 $aInputPrivacyCustom = array ();
116 $aInputPrivacyCustom[] = array (
'key' =>
'',
'value' =>
'----');
117 $aInputPrivacyCustom[] = array (
'key' =>
'c',
'value' =>
_t(
'_ch_store_privacy_customers_only'));
119 $aInputPrivacyPostInForum =
$GLOBALS[
'oChStoreModule']->_oPrivacyProduct->getGroupChooser(
$iProfileId,
'store',
'post_in_forum');
120 $aInputPrivacyPostInForum[
'values'] = array_merge($aInputPrivacyPostInForum[
'values'], $aInputPrivacyCustom);
121 $aInputPrivacyPostInForum[
'db'] = array (
123 'params' => array(
'/^([0-9c]+)$/'),
126 $aInputPrivacyViewForum =
$GLOBALS[
'oChStoreModule']->_oPrivacyProduct->getGroupChooser(
$iProfileId,
'store',
'view_forum');
127 $aInputPrivacyViewForum[
'values'] = array_merge($aInputPrivacyViewForum[
'values'], $aInputPrivacyCustom);
128 $aInputPrivacyViewForum[
'db'] = $aInputPrivacyPostInForum[
'db'];
130 $aCustomForm = array(
132 'form_attrs' => array(
133 'name' =>
'form_store',
136 'enctype' =>
'multipart/form-data',
141 'table' =>
'ch_store_products',
144 'uri_title' =>
'title',
145 'submit_name' =>
'submit_form',
151 'header_info' => array(
152 'type' =>
'block_header',
153 'caption' =>
_t(
'_ch_store_form_header_info')
158 'caption' =>
_t(
'_ch_store_form_caption_title'),
162 'params' => array(3,100),
163 'error' =>
_t (
'_ch_store_form_err_title'),
170 'type' =>
'textarea',
172 'caption' =>
_t(
'_ch_store_form_caption_desc'),
177 'params' => array(20,64000),
178 'error' =>
_t (
'_ch_store_form_err_desc'),
187 'caption' =>
_t(
'_Tags'),
188 'info' =>
_t(
'_sys_tags_note'),
192 'error' =>
_t (
'_ch_store_form_err_tags'),
199 'categories' => $oCategories->getGroupChooser (
'ch_store', (
int)
$iProfileId,
true),
201 'header_images' => array(
202 'type' =>
'block_header',
203 'caption' =>
_t(
'_ch_store_form_header_images'),
204 'collapsable' =>
true,
205 'collapsed' =>
false,
209 'content' => $aCustomMediaTemplates[
'images'][
'thumb_choice'],
211 'caption' =>
_t(
'_ch_store_form_caption_thumb_choice'),
212 'info' =>
_t(
'_ch_store_form_info_thumb_choice'),
218 'images_choice' => array(
220 'content' => $aCustomMediaTemplates[
'images'][
'choice'],
221 'name' =>
'images_choice[]',
222 'caption' =>
_t(
'_ch_store_form_caption_images_choice'),
223 'info' =>
_t(
'_ch_store_form_info_images_choice'),
226 'images_upload' => array(
228 'content' => $aCustomMediaTemplates[
'images'][
'upload'],
229 'name' =>
'images_upload[]',
230 'caption' =>
_t(
'_ch_store_form_caption_images_upload'),
231 'info' =>
_t(
'_ch_store_form_info_images_upload'),
235 'header_videos' => array(
236 'type' =>
'block_header',
237 'caption' =>
_t(
'_ch_store_form_header_videos'),
238 'collapsable' =>
true,
239 'collapsed' =>
false,
241 'videos_choice' => array(
243 'content' => $aCustomMediaTemplates[
'videos'][
'choice'],
244 'name' =>
'videos_choice[]',
245 'caption' =>
_t(
'_ch_store_form_caption_videos_choice'),
246 'info' =>
_t(
'_ch_store_form_info_videos_choice'),
249 'videos_upload' => array(
251 'content' => $aCustomMediaTemplates[
'videos'][
'upload'],
252 'name' =>
'videos_upload[]',
253 'caption' =>
_t(
'_ch_store_form_caption_videos_upload'),
254 'info' =>
_t(
'_ch_store_form_info_videos_upload'),
258 'header_files' => array(
259 'type' =>
'block_header',
260 'caption' =>
_t(
'_ch_store_form_header_files'),
261 'collapsable' =>
true,
262 'collapsed' =>
false,
264 'files_choice' => array(
266 'content' => $aFilesChoice ?
$GLOBALS[
'oChStoreModule']->_oTemplate->parseHtmlByName(
'form_field_product_files_choice', $aVarsFilesChoice) :
'',
267 'name' =>
'files_choice[]',
268 'caption' =>
_t(
'_ch_store_form_caption_files_choice'),
269 'info' =>
_t(
'_ch_store_form_info_files_choice'),
272 'files_upload' => array(
274 'content' =>
$GLOBALS[
'oChStoreModule']->_oTemplate->parseHtmlByName(
'form_field_files_upload', $aVarsFilesUpload),
275 'name' =>
'files_upload[]',
276 'caption' =>
_t(
'_ch_store_form_caption_files_upload'),
277 'info' =>
_t(
'_ch_store_form_info_files_upload'),
281 'header_privacy' => array(
282 'type' =>
'block_header',
283 'caption' =>
_t(
'_ch_store_form_header_privacy'),
286 'allow_view_product_to' =>
$GLOBALS[
'oChStoreModule']->_oPrivacyProduct->getGroupChooser(
$iProfileId,
'store',
'view_product'),
288 'allow_post_in_forum_to' => $aInputPrivacyPostInForum,
290 'allow_view_forum_to' => $aInputPrivacyViewForum,
295 if (!$aCustomForm[
'inputs'][
'images_choice'][
'content']) {
296 unset ($aCustomForm[
'inputs'][
'thumb']);
297 unset ($aCustomForm[
'inputs'][
'images_choice']);
300 if (!$aCustomForm[
'inputs'][
'videos_choice'][
'content'])
301 unset ($aCustomForm[
'inputs'][
'videos_choice']);
304 unset ($aCustomForm[
'inputs'][
'files_choice']);
306 if (!isset($this->_aMedia[
'images'])) {
307 unset ($aCustomForm[
'inputs'][
'header_images']);
308 unset ($aCustomForm[
'inputs'][
'PrimPhoto']);
309 unset ($aCustomForm[
'inputs'][
'images_choice']);
310 unset ($aCustomForm[
'inputs'][
'images_upload']);
311 unset ($aCustomForm[
'inputs'][
'allow_upload_photos_to']);
314 if (!isset($this->_aMedia[
'videos'])) {
315 unset ($aCustomForm[
'inputs'][
'header_videos']);
316 unset ($aCustomForm[
'inputs'][
'videos_choice']);
317 unset ($aCustomForm[
'inputs'][
'videos_upload']);
318 unset ($aCustomForm[
'inputs'][
'allow_upload_videos_to']);
321 $aFormInputsSubmit = array (
324 'name' =>
'submit_form',
325 'value' =>
_t(
'_Submit'),
329 $aCustomForm[
'inputs'] = array_merge($aCustomForm[
'inputs'], $aFormInputsSubmit);
333 parent::__construct ($aCustomForm);
336 function uploadFiles ($sTag, $sCat,
$sName =
'files',
$sTitle =
'files_titles', $sTitleAlt =
'title', $sPrivacy =
'allow_purchase_to')
346 $aPrices = $_POST[
'files_prices'];
349 foreach ($_FILES[
$sName][
'tmp_name']
as $i => $sUploadedFile) {
351 'medTitle' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
352 'medDesc' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
354 'Categories' => array($sCat),
355 'Type' => $_FILES[
$sName][
'type'][$i],
359 if (move_uploaded_file($sUploadedFile, $sTmpFile)) {
360 $iRet =
ChWsbService::call(
'files',
'perform_file_upload', array($sTmpFile, $aFileInfo),
'Uploader');
363 if (preg_match(
'/([0-9]+[\.0-9]*)/', $aPrices[$i], $m))
366 $aRet[] = array (
'id' => $iRet,
'price' => $sPrice,
'privacy' => $aPrivacy[$i]);
377 $this->_oDb->insertMediaFiles ($iEntryId, $aMedia, $this->_oMain->_iProfileId);