本文整理汇总了PHP中BxDolCategories::getGroupChooser方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolCategories::getGroupChooser方法的具体用法?PHP BxDolCategories::getGroupChooser怎么用?PHP BxDolCategories::getGroupChooser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolCategories
的用法示例。
在下文中一共展示了BxDolCategories::getGroupChooser方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEditForm
function getEditForm($aValues, $aAddFields = array())
{
$oCategories = new BxDolCategories();
if (isset($this->_aForm['inputs']['categories'])) {
//--- convert post form to edit one ---//
$this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true, $aValues['categories']);
}
if (!empty($aValues) && is_array($aValues)) {
foreach ($aValues as $sKey => $sValue) {
if (array_key_exists($sKey, $this->_aForm['inputs'])) {
if ($this->_aForm['inputs'][$sKey]['type'] == 'checkbox') {
$this->_aForm['inputs'][$sKey]['checked'] = (int) $sValue == 1 ? true : false;
} else {
if ($this->_aForm['inputs'][$sKey]['type'] == 'select_box' && $this->_aForm['inputs'][$sKey]['name'] == 'Categories') {
$aCategories = preg_split('/[' . $oCategories->sTagsDivider . ']/', $sValue, 0, PREG_SPLIT_NO_EMPTY);
$this->_aForm['inputs'][$sKey]['value'] = $aCategories;
} else {
$this->_aForm['inputs'][$sKey]['value'] = $sValue;
}
}
}
}
unset($this->_aForm['inputs']['author_id']);
$this->_aForm['inputs']['id'] = array('type' => 'hidden', 'name' => 'id', 'value' => $aValues['id'], 'db' => array('pass' => 'Int'));
$this->_aForm['inputs']['post']['value'] = _t("_td_edit");
}
$oForm = new BxTemplFormView($this->_aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$iDateNow = mktime();
$iDatePublish = $oForm->getCleanValue('when');
if ($iDatePublish > $iDateNow) {
$iStatus = BX_TD_STATUS_PENDING;
} else {
if ($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove()) {
$iStatus = BX_TD_STATUS_ACTIVE;
} else {
$iStatus = BX_TD_STATUS_INACTIVE;
}
}
$aDefFields = array('date' => $iDateNow, 'status' => $iStatus);
$oForm->update($aValues['id'], array_merge($aDefFields, $aAddFields));
//--- 'System' -> Edit for Alerts Engine ---//
bx_import('BxDolAlerts');
$oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'edit', $aValues['id'], $this->_iOwnerId);
$oAlert->alert();
//--- 'System' -> Edit for Alerts Engine ---//
//--- Reparse Global Tags ---//
$oTags = new BxDolTags();
$oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues['id']);
//--- Reparse Global Tags ---//
//--- Reparse Global Categories ---//
$oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues['id']);
//--- Reparse Global Categories ---//
header('Location: ' . $oForm->aFormAttrs['action']);
} else {
return $oForm->getCode();
}
}
示例2: BxGroupsFormAdd
function BxGroupsFormAdd($oMain, $iProfileId, $iEntryId = 0, $iThumb = 0)
{
$this->_oMain = $oMain;
$this->_oDb = $oMain->_oDb;
$this->_aMedia = array('images' => array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_GROUPS_PHOTOS_TAG, 'cat' => BX_GROUPS_PHOTOS_CAT, 'thumb' => 'thumb', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_photo_array'), 'videos' => array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_GROUPS_VIDEOS_TAG, 'cat' => BX_GROUPS_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload_post' => 'videos_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_video_array'), 'sounds' => array('post' => 'ready_sounds', 'upload_func' => 'uploadSounds', 'tag' => BX_GROUPS_SOUNDS_TAG, 'cat' => BX_GROUPS_SOUNDS_CAT, 'thumb' => false, 'module' => 'sounds', 'title_upload_post' => 'sounds_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_music_array'), 'files' => array('post' => 'ready_files', 'upload_func' => 'uploadFiles', 'tag' => BX_GROUPS_FILES_TAG, 'cat' => BX_GROUPS_FILES_CAT, 'thumb' => false, 'module' => 'files', 'title_upload_post' => 'files_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_file_array'));
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oProfileFields = new BxDolProfileFields(0);
$aCountries = $oProfileFields->convertValues4Input('#!Country');
asort($aCountries);
// generate templates for custom form's elements
$aCustomMediaTemplates = $this->generateCustomMediaTemplates($oMain->_iProfileId, $iEntryId, $iThumb);
// privacy
$aInputPrivacyCustom = array();
$aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
$aInputPrivacyCustom[] = array('key' => 'f', 'value' => _t('_bx_groups_privacy_fans_only'));
$aInputPrivacyCustomPass = array('pass' => 'Preg', 'params' => array('/^([0-9f]+)$/'));
$aInputPrivacyCustom2 = array(array('key' => 'f', 'value' => _t('_bx_groups_privacy_fans')), array('key' => 'a', 'value' => _t('_bx_groups_privacy_admins_only')));
$aInputPrivacyCustom2Pass = array('pass' => 'Preg', 'params' => array('/^([fa]+)$/'));
$aInputPrivacyViewFans = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_fans');
$aInputPrivacyViewFans['values'] = array_merge($aInputPrivacyViewFans['values'], $aInputPrivacyCustom);
$aInputPrivacyComment = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'comment');
$aInputPrivacyComment['values'] = array_merge($aInputPrivacyComment['values'], $aInputPrivacyCustom);
$aInputPrivacyComment['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyRate = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'rate');
$aInputPrivacyRate['values'] = array_merge($aInputPrivacyRate['values'], $aInputPrivacyCustom);
$aInputPrivacyRate['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyForum = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'post_in_forum');
$aInputPrivacyForum['values'] = array_merge($aInputPrivacyForum['values'], $aInputPrivacyCustom);
$aInputPrivacyForum['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyUploadPhotos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_photos');
$aInputPrivacyUploadPhotos['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadPhotos['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadVideos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_videos');
$aInputPrivacyUploadVideos['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadVideos['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadSounds = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_sounds');
$aInputPrivacyUploadSounds['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadSounds['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadFiles = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_files');
$aInputPrivacyUploadFiles['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadFiles['db'] = $aInputPrivacyCustom2Pass;
$aCustomForm = array('form_attrs' => array('name' => 'form_groups', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_groups_main', 'key' => 'id', 'uri' => 'uri', 'uri_title' => 'title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_info')), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t('_bx_groups_form_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_groups_form_err_title')), 'db' => array('pass' => 'Xss'), 'display' => true), 'desc' => array('type' => 'textarea', 'name' => 'desc', 'caption' => _t('_bx_groups_form_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_groups_form_err_desc')), 'db' => array('pass' => 'XssHtml')), 'country' => array('type' => 'select', 'name' => 'country', 'caption' => _t('_bx_groups_form_caption_country'), 'values' => $aCountries, 'required' => false, 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{2})/')), 'display' => true), 'city' => array('type' => 'text', 'name' => 'city', 'caption' => _t('_bx_groups_form_caption_city'), 'required' => false, 'db' => array('pass' => 'Xss'), 'display' => true), 'zip' => array('type' => 'text', 'name' => 'zip', 'caption' => _t('_bx_groups_form_caption_zip'), 'required' => false, 'db' => array('pass' => 'Xss'), 'display' => true), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_groups_form_err_tags')), 'db' => array('pass' => 'Tags')), 'categories' => $oCategories->getGroupChooser('bx_groups', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'thumb' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'thumb', 'caption' => _t('_bx_groups_form_caption_thumb_choice'), 'info' => _t('_bx_groups_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_groups_form_caption_images_choice'), 'info' => _t('_bx_groups_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_groups_form_caption_images_upload'), 'info' => _t('_bx_groups_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_groups_form_caption_videos_choice'), 'info' => _t('_bx_groups_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_groups_form_caption_videos_upload'), 'info' => _t('_bx_groups_form_info_videos_upload'), 'required' => false), 'header_sounds' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_sounds'), 'collapsable' => true, 'collapsed' => false), 'sounds_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['choice'], 'name' => 'sounds_choice[]', 'caption' => _t('_bx_groups_form_caption_sounds_choice'), 'info' => _t('_bx_groups_form_info_sounds_choice'), 'required' => false), 'sounds_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['upload'], 'name' => 'sounds_upload[]', 'caption' => _t('_bx_groups_form_caption_sounds_upload'), 'info' => _t('_bx_groups_form_info_sounds_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['choice'], 'name' => 'files_choice[]', 'caption' => _t('_bx_groups_form_caption_files_choice'), 'info' => _t('_bx_groups_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['upload'], 'name' => 'files_upload[]', 'caption' => _t('_bx_groups_form_caption_files_upload'), 'info' => _t('_bx_groups_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_privacy')), 'allow_view_group_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_group'), 'allow_view_fans_to' => $aInputPrivacyViewFans, 'allow_comment_to' => $aInputPrivacyComment, 'allow_rate_to' => $aInputPrivacyRate, 'allow_post_in_forum_to' => $aInputPrivacyForum, 'allow_join_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'join'), 'join_confirmation' => array('type' => 'select', 'name' => 'join_confirmation', 'caption' => _t('_bx_groups_form_caption_join_confirmation'), 'info' => _t('_bx_groups_form_info_join_confirmation'), 'values' => array(0 => _t('_bx_groups_form_join_confirmation_disabled'), 1 => _t('_bx_groups_form_join_confirmation_enabled')), 'checker' => array('func' => 'int', 'error' => _t('_bx_groups_form_err_join_confirmation')), 'db' => array('pass' => 'Int')), 'allow_upload_photos_to' => $aInputPrivacyUploadPhotos, 'allow_upload_videos_to' => $aInputPrivacyUploadVideos, 'allow_upload_sounds_to' => $aInputPrivacyUploadSounds, 'allow_upload_files_to' => $aInputPrivacyUploadFiles, 'Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => false)));
if (!$aCustomForm['inputs']['images_choice']['content']) {
unset($aCustomForm['inputs']['thumb']);
unset($aCustomForm['inputs']['images_choice']);
}
if (!$aCustomForm['inputs']['videos_choice']['content']) {
unset($aCustomForm['inputs']['videos_choice']);
}
if (!$aCustomForm['inputs']['sounds_choice']['content']) {
unset($aCustomForm['inputs']['sounds_choice']);
}
if (!$aCustomForm['inputs']['files_choice']['content']) {
unset($aCustomForm['inputs']['files_choice']);
}
$this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
parent::BxDolFormMedia($aCustomForm);
}
示例3: BxGroupsFormEdit
function BxGroupsFormEdit($oMain, $iProfileId, $iEntryId, &$aDataEntry)
{
parent::BxGroupsFormAdd($oMain, $iProfileId, $iEntryId, $aDataEntry['thumb']);
$aFormInputsId = array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iEntryId));
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$this->aInputs['categories'] = $oCategories->getGroupChooser('bx_groups', (int) $iProfileId, true, $aDataEntry['categories']);
$this->aInputs = array_merge($this->aInputs, $aFormInputsId);
}
示例4: BxEventsFormEdit
function BxEventsFormEdit($oMain, $iProfileId, $iEventId, &$aEvent)
{
parent::BxEventsFormAdd($oMain, $iProfileId, $iEventId, $aEvent['PrimPhoto']);
$aFormInputsId = array('ID' => array('type' => 'hidden', 'name' => 'ID', 'value' => $iEventId));
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$this->aInputs['Categories'] = $oCategories->getGroupChooser('bx_events', (int) $iProfileId, true, $aEvent['Categories']);
$this->aInputs = array_merge($this->aInputs, $aFormInputsId);
}
示例5: getFullForm
function getFullForm()
{
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aForm = array('form_attrs' => array('name' => 'form_site', 'action' => BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'browse/my/add', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_sites_main', 'key' => 'id', 'uri' => 'entryUri', 'uri_title' => 'title', 'submit_name' => 'submit_form')), 'inputs' => array('url' => array('type' => 'text', 'name' => 'url', 'value' => isset($this->_aParam['url']) ? $this->_aParam['url'] : '', 'caption' => _t('_bx_sites_form_url'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(1, 100), 'error' => _t('_bx_sites_form_field_err')), 'db' => array('pass' => 'Xss'), 'display' => true), 'title' => array('type' => 'text', 'name' => 'title', 'value' => isset($this->_aParam['title']) ? $this->_aParam['title'] : '', 'caption' => _t('_bx_sites_form_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(1, 100), 'error' => _t('_bx_sites_form_field_err')), 'db' => array('pass' => 'Xss'), 'display' => true), 'description' => array('type' => 'textarea', 'name' => 'description', 'value' => isset($this->_aParam['description']) ? $this->_aParam['description'] : '', 'caption' => _t('_bx_sites_form_description'), 'required' => true, 'html' => 1, 'checker' => array('func' => 'length', 'params' => array(1, 64000), 'error' => _t('_bx_sites_form_field_err')), 'db' => array('pass' => 'XssHtml')), 'thumbnail' => array('type' => 'custom', 'name' => 'thumbnail', 'content' => '', 'caption' => 'Thumbnail'), 'photo' => array('type' => 'file', 'name' => 'photo', 'caption' => _t('_bx_sites_form_photo')), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_sites_form_field_err')), 'db' => array('pass' => 'Tags'), 'info' => _t('_sys_tags_note')), 'categories' => $oCategories->getGroupChooser('bx_sites', (int) $this->_oModule->iOwnerId, true), 'allowView' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId, 'bx_sites', 'view', array(), _t('_bx_sites_caption_allow_view')), 'allowComments' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId, 'bx_sites', 'comments', array(), _t('_bx_sites_caption_allow_comments')), 'allowRate' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId, 'bx_sites', 'rate', array(), _t('_bx_sites_caption_allow_rate'))));
if (isset($this->_aParam['thumbnail']) && getParam('bx_sites_account_type') != 'No Automated Screenshots') {
$aForm['inputs']['thumbnail']['content'] = $this->_aParam['thumbnail'];
$aForm['inputs']['photo']['caption'] = _t('_bx_sites_form_other_thumbnail');
if (isset($this->_aParam['thumbnail_html'])) {
$aForm['inputs'] = array_merge($aForm['inputs'], array('thumbnail_html' => array('type' => 'hidden', 'name' => 'thumbnail_html', 'value' => $this->_aParam['thumbnail_html'])));
}
} else {
unset($aForm['inputs']['thumbnail']);
}
return $aForm;
}
示例6: array
function __construct($oModule, $aParam = array())
{
$this->_oModule = $oModule;
$this->_aParam = $aParam;
if (count($aParam) && isset($aParam['photo']) && $aParam['photo'] != 0) {
$aFile = BxDolService::call('photos', 'get_photo_array', array($aParam['photo'], 'browse'), 'Search');
if (!$aFile['no_image']) {
$aParam = array_merge($aParam, array('thumbnail' => $GLOBALS['oBxSitesModule']->_oTemplate->parseHtmlByName('thumb110.html', array('image' => $aFile['file'], 'spacer' => getTemplateIcon('spacer.gif')))));
}
}
$this->_aCustomForm = $this->getFullForm();
$this->_aCustomForm['form_attrs']['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'edit/' . $aParam['id'];
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$this->_aCustomForm['inputs']['categories'] = $oCategories->getGroupChooser('bx_sites', (int) $this->_oModule->iOwnerId, true, $this->_aParam['categories']);
$aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => false));
$this->_aCustomForm['inputs'] = array_merge($this->_aCustomForm['inputs'], $aFormInputsSubmit);
parent::__construct($this->_aCustomForm);
}
示例7: array
function _GenSendFileInfoForm($iFileID, $aDefaultValues = array(), $aPossibleImage = array(), $aPossibleDuration = array())
{
header("Content-type: text/html; charset=utf-8");
$this->addJsTranslation(array('_bx_' . $this->sUploadTypeLC . 's_val_title_err', '_bx_' . $this->sUploadTypeLC . 's_val_descr_err'));
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aFormCategories['categories'] = $oCategories->getGroupChooser('bx_' . $this->sUploadTypeLC . 's', $this->_iOwnerId, true);
$aFormCategories['categories']['required'] = false;
$sKey = 'album';
$aAlbums = array();
if ($this->_aExtras[$sKey] != '') {
$aAlbums[BX_DOL_UPLOADER_EP_PREFIX . $sKey] = array('type' => 'hidden', 'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey, 'value' => stripslashes($this->_aExtras[$sKey]));
} else {
$oAlbum = new BxDolAlbums('bx_' . $this->sUploadTypeLC . 's');
$aAlbumList = $oAlbum->getAlbumList(array('owner' => $this->_iOwnerId));
if (count($aAlbumList) > 0) {
foreach ($aAlbumList as $aValue) {
$aList[$aValue['ID']] = stripslashes($aValue['Caption']);
}
} else {
$sDefName = $oAlbum->getAlbumDefaultName();
$aList[$sDefName] = stripslashes($sDefName);
}
$aAlbums['album'] = array('type' => 'select_box', 'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey, 'caption' => _t('_sys_album'), 'values' => $aList);
}
$sCaptionVal = $this->sSendFileInfoFormCaption != '' ? $this->sSendFileInfoFormCaption : _t('_Info');
// processing of possible default values
$aInputValues = array('title', 'tags', 'description', 'type', $this->sUploadTypeLC);
foreach ($aInputValues as $sField) {
$sEmpty = $sField == 'type' ? 'upload' : '';
$sTemp = isset($aDefaultValues[$sField]) ? strip_tags($aDefaultValues[$sField]) : $sEmpty;
$aDefaultValues[$sField] = $sTemp;
}
$aForm = array('form_attrs' => array('id' => $this->sUploadTypeLC . '_file_info_form', 'method' => 'post', 'action' => $this->sWorkingFile, 'target' => 'upload_file_info_frame_' . $iFileID), 'inputs' => array('header2' => array('type' => 'block_header', 'caption' => $sCaptionVal, 'collapsable' => false), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t('_Title'), 'required' => true, 'value' => $aDefaultValues['title']), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'info' => _t('_Tags_desc'), 'value' => $aDefaultValues['tags']), 'description' => array('type' => 'textarea', 'name' => 'description', 'caption' => _t('_Description'), 'value' => $aDefaultValues['description']), 'media_id' => array('type' => 'hidden', 'name' => 'file_id', 'value' => $iFileID), 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => 'accept_file_info'), $this->sUploadTypeLC => array('type' => 'hidden', 'name' => $this->sUploadTypeLC, 'value' => $aDefaultValues[$this->sUploadTypeLC]), 'type' => array('type' => 'hidden', 'name' => 'type', 'value' => $aDefaultValues['type'])));
//--- Process Extras ---//
foreach ($this->_aExtras as $sKey => $mixedValue) {
$aForm['inputs'][BX_DOL_UPLOADER_EP_PREFIX . $sKey] = array('type' => 'hidden', 'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey, 'value' => $mixedValue);
}
// merging categories
$aForm['inputs'] = $this->getUploadFormArray($aForm['inputs'], array($aFormCategories, $aAlbums));
if (is_array($aPossibleImage) && count($aPossibleImage) > 0) {
$aForm['inputs'] = array_merge($aForm['inputs'], $aPossibleImage);
}
if (is_array($aPossibleDuration) && count($aPossibleDuration) > 0) {
$aForm['inputs'] = array_merge($aForm['inputs'], $aPossibleDuration);
}
$aForm['inputs'][] = array('type' => 'input_set', 'colspan' => true, 0 => array('type' => 'submit', 'name' => 'upload', 'value' => _t('_Submit'), 'colspan' => true, 'attrs' => array('onclick' => "return parent." . $this->_sJsPostObject . ".doValidateFileInfo(this, '" . $iFileID . "');")), 1 => array('type' => 'button', 'name' => 'delete', 'value' => _t('_bx_' . $this->sUploadTypeLC . 's_admin_delete'), 'colspan' => true, 'attrs' => array('onclick' => "return parent." . $this->_sJsPostObject . ".cancelSendFileInfo('" . $iFileID . "', '" . $this->sWorkingFile . "'); ")));
$oForm = new BxTemplFormView($aForm);
$sForm = $this->parseHtmlByName('uploader_regular_info.html', array('id' => $iFileID, 'form' => $oForm->getCode()));
$sForm = str_replace(array("'", "\r", "\n"), array("\\'"), $sForm);
return "<script src='" . BX_DOL_URL_ROOT . "inc/js/jquery.webForms.js' type='text/javascript' language='javascript'></script><script type='text/javascript'>parent." . $this->_sJsPostObject . ".genSendFileInfoForm('" . $iFileID . "', '" . $sForm . "'); parent." . $this->_sJsPostObject . "._loading(false);</script>";
}
示例8: array
function __construct($oMain, $iProfileId, $isRemovePhotoFieldAllowed = true, $iEntryId = 0, $iThumb = 0)
{
$this->_aMedia = array();
if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
$this->_aMedia['images'] = array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_STORE_PHOTOS_TAG, 'cat' => BX_STORE_PHOTOS_CAT, 'thumb' => 'thumb', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_store_form_caption_file_title'), 'service_method' => 'get_photo_array');
}
if (BxDolRequest::serviceExists('videos', 'perform_video_upload', 'Uploader')) {
$this->_aMedia['videos'] = array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_STORE_VIDEOS_TAG, 'cat' => BX_STORE_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload' => _t('_bx_store_form_caption_file_title'), 'service_method' => 'get_video_array');
}
$this->_oMain = $oMain;
$this->_oDb = $oMain->_oDb;
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
// generate templates for form custom elements
$aCustomMediaTemplates = $this->generateCustomMediaTemplates($iProfileId, $iEntryId, $iThumb);
// files
$aFilesChoiceOrig = $this->_getFilesInEntry('files', 'get_file_array', 'ready_files', 'files', (int) $iProfileId, $iEntryId);
$aFilesChoice = array();
$sCurrencySign = getParam('pmt_default_currency_sign');
foreach ($aFilesChoiceOrig as $k => $r) {
if (!$r['checked']) {
continue;
}
$a = $GLOBALS['oBxStoreModule']->_oDb->getFileInfo($iEntryId, $r['id']);
$r['file_id'] = $a['id'];
$r['title'] .= ' - ' . $sCurrencySign . ' ' . $a['price'] . ' (' . $GLOBALS['oBxStoreModule']->getGroupName($a['allow_purchase_to']) . ')';
$r['visibility'] = $a['hidden'] ? _t('_bx_store_product_file_hidden') : _t('_bx_store_product_file_visible');
$aFilesChoice[] = $r;
}
$aVarsFilesChoice = array('bx_store_base_url' => $this->_oMain->_oConfig->getBaseUri(), 'bx_if:empty' => array('condition' => empty($aFilesChoice), 'content' => array()), 'bx_repeat:files' => $aFilesChoice);
$aInputPrivacyPurchase = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'purchase');
foreach ($aInputPrivacyPurchase['values'] as $k => $r) {
if ($r['key'] == BX_DOL_PG_ALL) {
unset($aInputPrivacyPurchase['values'][$k]);
break;
}
}
require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
$aMemberships = getMemberships();
unset($aMemberships[MEMBERSHIP_ID_NON_MEMBER]);
// unset Non-member
unset($aMemberships[MEMBERSHIP_ID_STANDARD]);
// unset member
$aMemberships = array('' => '----') + $aMemberships;
$aMembershipsValues = array();
foreach ($aMemberships as $k => $v) {
$aMembershipsValues[] = array('key' => $k ? 'm' . $k : $k, 'value' => $v);
}
$aInputPrivacyPurchase['values'] = array_merge($aInputPrivacyPurchase['values'], $aMembershipsValues);
/*
if (empty($aInputPrivacyPurchase['value']) || !$aInputPrivacyPurchase['value'])
$aInputPrivacyPurchase['value'] = BX_DOL_PG_MEMBERS;
*/
$sInputPrivacyPurchase = str_replace('name="allow_purchase_to"', 'name="allow_purchase_to[]"', $this->genInputSelect($aInputPrivacyPurchase));
$aVarsFilesUpload = array('file' => 'files', 'title' => 'files_titles', 'file_upload_title' => _t('_bx_store_form_caption_file_title'), 'bx_if:price' => array('condition' => true, 'content' => array('price' => 'files_prices', 'file_price_title' => _t('_bx_store_form_caption_file_price'))), 'bx_if:privacy' => array('condition' => true, 'content' => array('select' => $sInputPrivacyPurchase, 'file_permission_title' => _t('_bx_store_form_caption_file_allow_purcase_to'))));
// privacy
$aInputPrivacyCustom = array();
$aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
$aInputPrivacyCustom[] = array('key' => 'c', 'value' => _t('_bx_store_privacy_customers_only'));
$aInputPrivacyPostInForum = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'post_in_forum');
$aInputPrivacyPostInForum['values'] = array_merge($aInputPrivacyPostInForum['values'], $aInputPrivacyCustom);
$aInputPrivacyPostInForum['db'] = array('pass' => 'Preg', 'params' => array('/^([0-9c]+)$/'));
$aInputPrivacyViewForum = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'view_forum');
$aInputPrivacyViewForum['values'] = array_merge($aInputPrivacyViewForum['values'], $aInputPrivacyCustom);
$aInputPrivacyViewForum['db'] = $aInputPrivacyPostInForum['db'];
$aCustomForm = array('form_attrs' => array('name' => 'form_store', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_store_products', 'key' => 'id', 'uri' => 'uri', 'uri_title' => 'title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_info')), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t('_bx_store_form_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_store_form_err_title')), 'db' => array('pass' => 'Xss')), 'desc' => array('type' => 'textarea', 'name' => 'desc', 'caption' => _t('_bx_store_form_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_store_form_err_desc')), 'db' => array('pass' => 'XssHtml')), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_store_form_err_tags')), 'db' => array('pass' => 'Tags')), 'categories' => $oCategories->getGroupChooser('bx_store', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'thumb' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'thumb', 'caption' => _t('_bx_store_form_caption_thumb_choice'), 'info' => _t('_bx_store_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_store_form_caption_images_choice'), 'info' => _t('_bx_store_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_store_form_caption_images_upload'), 'info' => _t('_bx_store_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_store_form_caption_videos_choice'), 'info' => _t('_bx_store_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_store_form_caption_videos_upload'), 'info' => _t('_bx_store_form_info_videos_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aFilesChoice ? $GLOBALS['oBxStoreModule']->_oTemplate->parseHtmlByName('form_field_product_files_choice', $aVarsFilesChoice) : '', 'name' => 'files_choice[]', 'caption' => _t('_bx_store_form_caption_files_choice'), 'info' => _t('_bx_store_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $GLOBALS['oBxStoreModule']->_oTemplate->parseHtmlByName('form_field_files_upload', $aVarsFilesUpload), 'name' => 'files_upload[]', 'caption' => _t('_bx_store_form_caption_files_upload'), 'info' => _t('_bx_store_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_privacy')), 'allow_view_product_to' => $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'view_product'), 'allow_post_in_forum_to' => $aInputPrivacyPostInForum, 'allow_view_forum_to' => $aInputPrivacyViewForum));
if (!$aCustomForm['inputs']['images_choice']['content']) {
unset($aCustomForm['inputs']['thumb']);
unset($aCustomForm['inputs']['images_choice']);
}
if (!$aCustomForm['inputs']['videos_choice']['content']) {
unset($aCustomForm['inputs']['videos_choice']);
}
if (!$aFilesChoice) {
unset($aCustomForm['inputs']['files_choice']);
}
if (!isset($this->_aMedia['images'])) {
unset($aCustomForm['inputs']['header_images']);
unset($aCustomForm['inputs']['PrimPhoto']);
unset($aCustomForm['inputs']['images_choice']);
unset($aCustomForm['inputs']['images_upload']);
unset($aCustomForm['inputs']['allow_upload_photos_to']);
}
if (!isset($this->_aMedia['videos'])) {
unset($aCustomForm['inputs']['header_videos']);
unset($aCustomForm['inputs']['videos_choice']);
unset($aCustomForm['inputs']['videos_upload']);
unset($aCustomForm['inputs']['allow_upload_videos_to']);
}
$aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit')));
$aCustomForm['inputs'] = array_merge($aCustomForm['inputs'], $aFormInputsSubmit);
$this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
parent::__construct($aCustomForm);
}
示例9: AddNewPostForm
/**
* Generate Form for NewPost/EditPost
*
* @param $iPostID - Post ID
* @return HTML presentation of data
*/
function AddNewPostForm($iPostID = 0, $bBox = true)
{
$this->CheckLogged();
if ($iPostID == 0) {
if (!$this->isAllowedPostAdd()) {
return $this->_oTemplate->displayAccessDenied();
}
} else {
$iOwnerID = (int) $this->_oDb->getPostOwnerByID($iPostID);
if (!$this->isAllowedPostEdit($iOwnerID)) {
return $this->_oTemplate->displayAccessDenied();
}
}
$sPostCaptionC = _t('_Title');
$sPostTextC = _t('_Text');
$sAssociatedImageC = _t('_associated_image');
$sAddBlogC = $iPostID ? _t('_Submit') : _t('_Add Post');
$sTagsC = _t('_Tags');
$sNewPostC = _t('_New Post');
$sEditPostC = _t('_bx_blog_Edit_post');
$sDelImgC = _t('_Delete image');
$sErrorC = _t('_Error Occured');
$sCaptionErrorC = _t('_bx_blog_Caption_error');
$sTextErrorC = _t('_bx_blog_Text_error');
$sTagsInfoC = _t('_sys_tags_note');
$sLink = $this->genBlogFormUrl();
$sAddingForm = '';
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'view', array(), _t('_bx_blog_privacy_view'));
$aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'rate', array(), _t('_bx_blog_privacy_rate'));
$aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'comment', array(), _t('_bx_blog_privacy_comment'));
$sAction = $iPostID == 0 ? 'new_post' : 'edit_post';
//adding form
$aForm = array('form_attrs' => array('name' => 'CreateBlogPostForm', 'action' => $sLink, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLPostsTable, 'key' => 'PostID', 'submit_name' => 'add_button')), 'inputs' => array('PostCaption' => array('type' => 'text', 'name' => 'PostCaption', 'caption' => $sPostCaptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => $sCaptionErrorC), 'db' => array('pass' => 'Xss')), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => $sTagsC, 'info' => $sTagsInfoC, 'required' => false, 'db' => array('pass' => 'Xss')), 'PostText' => array('type' => 'textarea', 'html' => 2, 'name' => 'PostText', 'caption' => $sPostTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 65535), 'error' => $sTextErrorC), 'db' => array('pass' => 'XssHtml')), 'Categories' => $oCategories->getGroupChooser('bx_blogs', $this->_iVisitorID, true), 'File' => array('type' => 'file', 'name' => 'BlogPic[]', 'caption' => $sAssociatedImageC), 'AssociatedImage' => array('type' => 'hidden'), 'allowView' => $aAllowView, 'allowRate' => $aAllowRate, 'allowComment' => $aAllowComment, 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sAddBlogC)));
if ($iPostID > 0) {
$aBlogPost = $this->_oDb->getJustPostInfo($iPostID);
$sPostCaption = $aBlogPost['PostCaption'];
$sPostText = $aBlogPost['PostText'];
$sPostTags = $aBlogPost['Tags'];
$sPostPicture = $aBlogPost['PostPhoto'];
if ($sPostPicture != '') {
$sBlogsImagesUrl = BX_BLOGS_IMAGES_URL;
$sPostPictureTag = <<<EOF
<div class="blog_edit_image" id="edit_post_image_{$iPostID}">
<img class="bx-def-shadow bx-def-round-corners bx-def-margin-sec-right" style="max-width:{$this->iThumbSize}px; max-height:{$this->iThumbSize}px;" src="{$sBlogsImagesUrl}big_{$sPostPicture}" />
<a href="{$sLink}?action=del_img&post_id={$iPostID}" onclick="BlogpostImageDelete('{$sLink}?action=del_img&post_id={$iPostID}&mode=ajax', 'edit_post_image_{$iPostID}');return false;" >{$sDelImgC}</a>
</div>
EOF;
$aForm['inputs']['AssociatedImage']['type'] = 'custom';
$aForm['inputs']['AssociatedImage']['content'] = $sPostPictureTag;
$aForm['inputs']['AssociatedImage']['caption'] = $sAssociatedImageC;
}
$aCategories = explode(';', $aBlogPost['Categories']);
$aForm['inputs']['PostCaption']['value'] = $sPostCaption;
$aForm['inputs']['PostText']['value'] = $sPostText;
$aForm['inputs']['Tags']['value'] = $sPostTags;
$aForm['inputs']['Categories']['value'] = $aCategories;
$aForm['inputs']['allowView']['value'] = $aBlogPost['allowView'];
$aForm['inputs']['allowRate']['value'] = $aBlogPost['allowRate'];
$aForm['inputs']['allowComment']['value'] = $aBlogPost['allowComment'];
$aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'EditPostID', 'value' => $iPostID);
if ($aBlogPost['PostPhoto'] != '' && file_exists(BX_BLOGS_IMAGES_PATH . 'small_' . $aBlogPost['PostPhoto'])) {
$GLOBALS['oTopMenu']->setCustomSubIconUrl(BX_BLOGS_IMAGES_URL . 'small_' . $aBlogPost['PostPhoto']);
} else {
$GLOBALS['oTopMenu']->setCustomSubIconUrl('book');
}
$GLOBALS['oTopMenu']->setCustomSubHeader($sPostCaption);
}
if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) {
$aForm['inputs']['allowView']['value'] = BX_DOL_PG_ALL;
}
if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) {
$aForm['inputs']['allowRate']['value'] = BX_DOL_PG_ALL;
}
if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
$aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL;
}
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$this->CheckLogged();
$iOwnID = $this->_iVisitorID;
$sCurTime = time();
$sPostUri = uriGenerate(bx_get('PostCaption'), $this->_oConfig->sSQLPostsTable, 'PostUri');
$sAutoApprovalVal = getParam('blogAutoApproval') == 'on' ? "approval" : "disapproval";
$aValsAdd = array('PostDate' => $sCurTime, 'PostStatus' => $sAutoApprovalVal);
if ($iPostID == 0) {
$aValsAdd['OwnerID'] = $iOwnID;
$aValsAdd['PostUri'] = $sPostUri;
}
$iBlogPostID = -1;
if ($iPostID > 0) {
unset($aValsAdd['PostDate']);
//.........这里部分代码省略.........
示例10: actionEdit
function actionEdit($iFileId)
{
$bAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? TRUE : FALSE;
$iFileId = (int) $iFileId > 0 ? (int) $iFileId : (int) bx_get('fileId');
if (!$iFileId || !$bAjax) {
return;
}
$aManageArray = array('medTitle', 'medTags', 'medDesc', 'medProfId', 'Categories', 'medUri');
$aInfo = $this->_oDb->getFileInfo(array('fileId' => $iFileId), false, $aManageArray);
$sLangPref = '_' . $this->_oConfig->getMainPrefix();
if (!$this->isAllowedEdit($aInfo)) {
$sCode = MsgBox(_t($sLangPref . '_access_denied')) . $sJsCode;
} else {
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aCategories = $oCategories->getGroupChooser($this->_oConfig->getMainPrefix(), $this->_iProfileId, true);
$aCategories['value'] = explode(CATEGORIES_DIVIDER, $aInfo['Categories']);
$sUrlPref = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
$aForm = array('form_attrs' => array('id' => $sLangPref . '_upload_form', 'method' => 'post', 'action' => $sUrlPref . 'edit/' . $iFileId, 'onsubmit' => "return bx_ajax_form_check(this)"), 'params' => array('db' => array('submit_name' => 'do_submit'), 'checker_helper' => 'BxSupportCheckerHelper'), 'inputs' => array('header' => array('type' => 'block_header', 'caption' => _t('_Info')), 'title' => array('type' => 'text', 'name' => 'medTitle', 'caption' => _t('_Title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_td_err_incorrect_length')), 'value' => $aInfo['medTitle']), 'tags' => array('type' => 'text', 'name' => 'medTags', 'caption' => _t('_Tags'), 'info' => _t('_Tags_desc'), 'value' => $aInfo['medTags']), 'description' => array('type' => 'textarea', 'name' => 'medDesc', 'caption' => _t('_Description'), 'value' => $aInfo['medDesc']), 'categories' => $aCategories, 'fileId' => array('type' => 'hidden', 'name' => 'fileId', 'value' => $iFileId), 'medProfId' => array('type' => 'hidden', 'name' => 'medProfId', 'value' => $this->_iProfileId), 'do_submit' => array('type' => 'hidden', 'name' => 'do_submit', 'value' => 1), 'submit' => array('type' => 'submit', 'name' => 'submit_press', 'value' => _t('_Submit'), 'colspan' => true)));
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker($aInfo);
if ($oForm->isSubmittedAndValid()) {
$aValues = array();
array_pop($aManageArray);
foreach ($aManageArray as $sKey) {
if ($sKey != 'Categories') {
$aValues[$sKey] = $_POST[$sKey];
} else {
$aValues[$sKey] = implode(CATEGORIES_DIVIDER, $_POST[$sKey]);
}
}
if ($this->_oDb->updateData($iFileId, $aValues)) {
$sType = $this->_oConfig->getMainPrefix();
bx_import('BxDolCategories');
$oTag = new BxDolTags();
$oTag->reparseObjTags($sType, $iFileId);
$oCateg = new BxDolCategories();
$oCateg->reparseObjTags($sType, $iFileId);
$sCode = $GLOBALS['oFunctions']->msgBox(_t($sLangPref . '_save_success'), 3, 'window.location="' . $sUrlPref . 'view/' . $aInfo['medUri'] . '";');
} else {
$sCode = $GLOBALS['oFunctions']->msgBox(_t('_sys_save_nothing'));
}
} else {
$sCode = $this->_oTemplate->parseHtmlByName('default_padding.html', array('content' => $oForm->getCode()));
$sCode = $this->_oTemplate->parseHtmlByName('popup.html', array('title' => $aInfo['medTitle'], 'content' => $sCode));
$sCode = $GLOBALS['oFunctions']->transBox($sCode, TRUE);
}
}
header('Content-type:text/html;charset=utf-8');
echo $sCode;
exit;
}
示例11: BxEventsFormAdd
function BxEventsFormAdd($oMain, $iProfileId, $iEntryId = 0, $iThumb = 0)
{
$this->_oMain = $oMain;
$this->_oDb = $oMain->_oDb;
$this->_aMedia = array('images' => array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_EVENTS_PHOTOS_TAG, 'cat' => BX_EVENTS_PHOTOS_CAT, 'thumb' => 'PrimPhoto', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_photo_array'), 'videos' => array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_EVENTS_VIDEOS_TAG, 'cat' => BX_EVENTS_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload_post' => 'videos_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_video_array'), 'sounds' => array('post' => 'ready_sounds', 'upload_func' => 'uploadSounds', 'tag' => BX_EVENTS_SOUNDS_TAG, 'cat' => BX_EVENTS_SOUNDS_CAT, 'thumb' => false, 'module' => 'sounds', 'title_upload_post' => 'sounds_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_music_array'), 'files' => array('post' => 'ready_files', 'upload_func' => 'uploadFiles', 'tag' => BX_EVENTS_FILES_TAG, 'cat' => BX_EVENTS_FILES_CAT, 'thumb' => false, 'module' => 'files', 'title_upload_post' => 'files_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_file_array'));
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$oProfileFields = new BxDolProfileFields(0);
$aCountries = $oProfileFields->convertValues4Input('#!Country');
asort($aCountries);
// generate templates for form custom elements
$aCustomMediaTemplates = $this->generateCustomMediaTemplates($this->_oMain->_iProfileId, $iEntryId, $iThumb);
// privacy
$aInputPrivacyCustom = array();
$aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
$aInputPrivacyCustom[] = array('key' => 'p', 'value' => _t('_bx_events_privacy_participants_only'));
$aInputPrivacyCustomPass = array('pass' => 'Preg', 'params' => array('/^([0-9p]+)$/'));
$aInputPrivacyCustom2 = array(array('key' => 'p', 'value' => _t('_bx_events_privacy_participants')), array('key' => 'a', 'value' => _t('_bx_events_privacy_admins_only')));
$aInputPrivacyCustom2Pass = array('pass' => 'Preg', 'params' => array('/^([pa]+)$/'));
$aInputPrivacyViewParticipants = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'view_participants');
$aInputPrivacyViewParticipants['values'] = array_merge($aInputPrivacyViewParticipants['values'], $aInputPrivacyCustom);
$aInputPrivacyComment = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'comment');
$aInputPrivacyComment['values'] = array_merge($aInputPrivacyComment['values'], $aInputPrivacyCustom);
$aInputPrivacyComment['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyRate = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'rate');
$aInputPrivacyRate['values'] = array_merge($aInputPrivacyRate['values'], $aInputPrivacyCustom);
$aInputPrivacyRate['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyForum = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'post_in_forum');
$aInputPrivacyForum['values'] = array_merge($aInputPrivacyForum['values'], $aInputPrivacyCustom);
$aInputPrivacyForum['db'] = $aInputPrivacyCustomPass;
$aInputPrivacyUploadPhotos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_photos');
$aInputPrivacyUploadPhotos['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadPhotos['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadVideos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_videos');
$aInputPrivacyUploadVideos['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadVideos['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadSounds = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_sounds');
$aInputPrivacyUploadSounds['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadSounds['db'] = $aInputPrivacyCustom2Pass;
$aInputPrivacyUploadFiles = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_files');
$aInputPrivacyUploadFiles['values'] = $aInputPrivacyCustom2;
$aInputPrivacyUploadFiles['db'] = $aInputPrivacyCustom2Pass;
$aCustomForm = array('form_attrs' => array('name' => 'form_events', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_events_main', 'key' => 'ID', 'uri' => 'EntryUri', 'uri_title' => 'Title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_info')), 'Title' => array('type' => 'text', 'name' => 'Title', 'caption' => _t('_bx_events_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_events_err_title')), 'db' => array('pass' => 'Xss'), 'display' => true), 'Description' => array('type' => 'textarea', 'name' => 'Description', 'caption' => _t('_bx_events_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_events_err_desc')), 'db' => array('pass' => 'XssHtml')), 'Country' => array('type' => 'select', 'name' => 'Country', 'caption' => _t('_bx_events_caption_country'), 'values' => $aCountries, 'required' => true, 'checker' => array('func' => 'preg', 'params' => array('/^[a-zA-Z]{2}$/'), 'error' => _t('_bx_events_err_country')), 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{2})/'))), 'City' => array('type' => 'text', 'name' => 'City', 'caption' => _t('_bx_events_caption_city'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 50), 'error' => _t('_bx_events_err_city')), 'db' => array('pass' => 'Xss')), 'Place' => array('type' => 'text', 'name' => 'Place', 'caption' => _t('_bx_events_caption_place'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_events_err_place')), 'db' => array('pass' => 'Xss'), 'display' => true), 'EventStart' => array('type' => 'datetime', 'name' => 'EventStart', 'caption' => _t('_bx_events_caption_event_start'), 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => _t('_bx_events_err_event_start')), 'db' => array('pass' => 'DateTime'), 'display' => 'filterDate'), 'EventEnd' => array('type' => 'datetime', 'name' => 'EventEnd', 'caption' => _t('_bx_events_caption_event_end'), 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => _t('_bx_events_err_event_end')), 'db' => array('pass' => 'DateTime'), 'display' => 'filterDate'), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_events_err_tags')), 'db' => array('pass' => 'Tags')), 'Categories' => $oCategories->getGroupChooser('bx_events', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'PrimPhoto' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'PrimPhoto', 'caption' => _t('_bx_events_form_caption_thumb_choice'), 'info' => _t('_bx_events_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_events_form_caption_images_choice'), 'info' => _t('_bx_events_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_events_form_caption_images_upload'), 'info' => _t('_bx_events_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_events_form_caption_videos_choice'), 'info' => _t('_bx_events_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_events_form_caption_videos_upload'), 'info' => _t('_bx_events_form_info_videos_upload'), 'required' => false), 'header_sounds' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_sounds'), 'collapsable' => true, 'collapsed' => false), 'sounds_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['choice'], 'name' => 'sounds_choice[]', 'caption' => _t('_bx_events_form_caption_sounds_choice'), 'info' => _t('_bx_events_form_info_sounds_choice'), 'required' => false), 'sounds_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['upload'], 'name' => 'sounds_upload[]', 'caption' => _t('_bx_events_form_caption_sounds_upload'), 'info' => _t('_bx_events_form_info_sounds_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['choice'], 'name' => 'files_choice[]', 'caption' => _t('_bx_events_form_caption_files_choice'), 'info' => _t('_bx_events_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['upload'], 'name' => 'files_upload[]', 'caption' => _t('_bx_events_form_caption_files_upload'), 'info' => _t('_bx_events_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_privacy')), 'allow_view_event_to' => $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'view_event'), 'allow_view_participants_to' => $aInputPrivacyViewParticipants, 'allow_comment_to' => $aInputPrivacyComment, 'allow_rate_to' => $aInputPrivacyRate, 'allow_post_in_forum_to' => $aInputPrivacyForum, 'allow_join_to' => $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'join'), 'JoinConfirmation' => array('type' => 'select', 'name' => 'JoinConfirmation', 'caption' => _t('_bx_events_form_caption_join_confirmation'), 'info' => _t('_bx_events_form_info_join_confirmation'), 'values' => array(0 => _t('_bx_events_form_join_confirmation_disabled'), 1 => _t('_bx_events_form_join_confirmation_enabled')), 'checker' => array('func' => 'int', 'error' => _t('_bx_events_form_err_join_confirmation')), 'db' => array('pass' => 'Int')), 'allow_upload_photos_to' => $aInputPrivacyUploadPhotos, 'allow_upload_videos_to' => $aInputPrivacyUploadVideos, 'allow_upload_sounds_to' => $aInputPrivacyUploadSounds, 'allow_upload_files_to' => $aInputPrivacyUploadFiles));
if (!$aCustomForm['inputs']['images_choice']['content']) {
unset($aCustomForm['inputs']['PrimPhoto']);
unset($aCustomForm['inputs']['images_choice']);
}
if (!$aCustomForm['inputs']['videos_choice']['content']) {
unset($aCustomForm['inputs']['videos_choice']);
}
if (!$aCustomForm['inputs']['sounds_choice']['content']) {
unset($aCustomForm['inputs']['sounds_choice']);
}
if (!$aCustomForm['inputs']['files_choice']['content']) {
unset($aCustomForm['inputs']['files_choice']);
}
$aFormInputsAdminPart = array();
if ($GLOBALS['oBxEventsModule']->isAdmin()) {
require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
$aMemberships = getMemberships();
unset($aMemberships[MEMBERSHIP_ID_NON_MEMBER]);
// unset Non-member
$aMemberships = array('' => _t('_bx_events_membership_filter_none')) + $aMemberships;
$aFormInputsAdminPart = array('EventMembershipFilter' => array('type' => 'select', 'name' => 'EventMembershipFilter', 'caption' => _t('_bx_events_caption_membership_filter'), 'info' => _t('_bx_events_info_membership_filter'), 'values' => $aMemberships, 'value' => '', 'checker' => array('func' => 'preg', 'params' => array('/^[0-9a-zA-Z]*$/'), 'error' => _t('_bx_events_err_membership_filter')), 'db' => array('pass' => 'Preg', 'params' => array('/([0-9a-zA-Z]*)/'))));
}
$aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => true));
$aCustomForm['inputs'] = array_merge($aCustomForm['inputs'], $aFormInputsAdminPart, $aFormInputsSubmit);
$this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
parent::BxDolFormMedia($aCustomForm);
}
示例12: actionEdit
function actionEdit($iFileId)
{
$iFileId = (int) $iFileId > 0 ? (int) $iFileId : (int) $_POST['fileId'];
if ($iFileId == 0) {
exit;
}
$this->aPageTmpl['name_index'] = 44;
$sJsCode = '<script language="javascript">window.setTimeout(function () { window.parent.opener.location = window.parent.opener.location; window.parent.close(); }, 3000); </script>';
$aManageArray = array('medTitle', 'medTags', 'medDesc', 'medProfId', 'Categories');
$aInfo = $this->_oDb->getFileInfo(array('fileId' => $iFileId), false, $aManageArray);
if (!$this->isAllowedEdit($aInfo)) {
$sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_access_denied')) . $sJsCode;
} else {
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aCategories = $oCategories->getGroupChooser($this->_oConfig->getMainPrefix(), $this->_iProfileId, true);
$aCategories['value'] = explode(CATEGORIES_DIVIDER, $aInfo['Categories']);
$aForm = array('form_attrs' => array('id' => $this->_oConfig->getMainPrefix() . '_upload_form', 'method' => 'post', 'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iFileId), 'params' => array('db' => array('submit_name' => 'submit'), 'checker_helper' => 'BxSupportCheckerHelper'), 'inputs' => array('header' => array('type' => 'block_header', 'caption' => _t('_Info')), 'title' => array('type' => 'text', 'name' => 'medTitle', 'caption' => _t('_Title'), 'required' => true, 'value' => $aInfo['medTitle'], 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_td_err_incorrect_length'))), 'tags' => array('type' => 'text', 'name' => 'medTags', 'caption' => _t('_Tags'), 'info' => _t('_Tags_desc'), 'value' => $aInfo['medTags']), 'description' => array('type' => 'textarea', 'name' => 'medDesc', 'caption' => _t('_Description'), 'required' => true, 'value' => $aInfo['medDesc'], 'checker' => array('func' => 'length', 'params' => array(3, 65536), 'error' => _t('_td_err_incorrect_length'))), 'categories' => $aCategories, 'fileId' => array('type' => 'hidden', 'name' => 'fileId', 'value' => $iFileId), 'medProfId' => array('type' => 'hidden', 'name' => 'medProfId', 'value' => $aInfo['medProfId']), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t('_Submit'), 'colspan' => true)));
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$aValues = array();
foreach ($aManageArray as $sKey) {
if ($sKey != 'Categories') {
$aValues[$sKey] = $_POST[$sKey];
} else {
$aValues[$sKey] = implode(CATEGORIES_DIVIDER, $_POST[$sKey]);
}
}
if ($this->_oDb->updateData($iFileId, $aValues)) {
$sType = $this->_oConfig->getMainPrefix();
bx_import('BxDolCategories');
$oTag = new BxDolTags();
$oTag->reparseObjTags($sType, $iFileId);
$oCateg = new BxDolCategories();
$oCateg->reparseObjTags($sType, $iFileId);
$sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_save_success')) . $sJsCode;
}
} else {
$sCode = $oForm->getCode();
$this->aPageTmpl['css_name'] = array('forms_adv.css', 'explanation.css');
}
}
$this->aPageTmpl['header'] = _t('_Edit');
$this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => $sCode));
}
示例13: array
function convertValues4Input($mValues, $sUseLKey = 'LKey', $sName = '', $aItem = array(), $sValue = '')
{
$aValues = array();
if (db_value("SHOW TABLES LIKE '{$mValues[0]}'") && $sName && $mValues[0] != 'ml_clonetwo_fields') {
switch ($mValues[0]) {
case 'sys_acl_levels':
require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
$aMemberships = getMemberships();
unset($aMemberships[MEMBERSHIP_ID_NON_MEMBER]);
$aValues = array('' => _t('_ml_clonetwo_membership_filter_none')) + $aMemberships;
$aAllValues['values'] = $aValues;
return $aAllValues;
break;
case 'sys_categories':
bx_import('BxDolCategories');
$oCategories = new BxDolCategories();
$aValues = $oCategories->getGroupChooser('ml_clonetwo', getLoggedId(), true, $sValue);
$aValues = $aValues['values'];
$aAllValues['values'] = $aValues;
return $aAllValues;
break;
case 'sys_privacy_actions':
$aInputPrivacyCustom = array();
$aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
$aInputPrivacyCustom[] = array('key' => 'f', 'value' => _t('_ml_clonetwo_privacy_fans_only'));
$sName = str_replace('allow_', '', $sName);
$sName = str_replace('_to', '', $sName);
$aPValues = $this->_oMain->_oPrivacy->getGroupChooser(getLoggedId(), $this->_aModule['uri'], $sName);
//print_r($aPValues['values']);
foreach ($aPValues['values'] as $sKey => $aPValue) {
$aValues[] = array('key' => $aPValue['key'], 'value' => $aPValue['value']);
}
if ($sName == 'upload_files' || $sName == 'upload_photos' || $sName == 'upload_videos' || $sName == 'upload_sounds') {
$aValues = array(array('key' => 'f', 'value' => _t('_ml_clonetwo_privacy_fans')), array('key' => 'a', 'value' => _t('_ml_clonetwo_privacy_admins_only')));
} else {
$aValues = array_merge($aValues, $aInputPrivacyCustom);
}
break;
default:
if ($aItem['IdField'] && $aItem['CaptionField']) {
if ($aItem['DepParentField'] && !$aItem['DepField']) {
$sValue = $sValue ? $sValue : $aItem['Default'];
if (!$sValue) {
$sValue = db_value("SELECT `Default` FROM `ml_clonetwo_fields` WHERE `Name` = '{$sName}' LIMIT 1");
}
if ($sValue) {
$iParentId = db_value("SELECT `{$aItem['DepParentField']}` FROM `{$mValues[0]}` WHERE `{$aItem['IdField']}` = '{$sValue}' LIMIT 1");
if ($iParentId) {
$sAddQuery = "WHERE `{$aItem['DepParentField']}` = '{$iParentId}'";
} else {
$sAddQuery = "WHERE `{$aItem['DepParentField']}` = '{$sValue}'";
}
}
$aAllValues['attrs'] = array('id' => "{$sName}");
} elseif ($aItem['DepParentField'] && $aItem['DepField']) {
$sAddQuery = "WHERE `{$aItem['DepParentField']}` = '0'";
}
$sQuery = db_res("SELECT `{$aItem['IdField']}` as `key`, `{$aItem['CaptionField']}` as `value` FROM `{$mValues[0]}` {$sAddQuery}");
while ($aRow = mysql_fetch_array($sQuery)) {
$aValues[$aRow['key']] = $aRow['value'];
}
if ($aItem['DepField']) {
$aDepData = db_arr("SELECT `IdField`, `CaptionField`, `DepParentField` FROM `ml_clonetwo_fields` WHERE `Name` = '{$aItem['DepField']}' LIMIT 1");
if (empty($aDepData)) {
return;
}
$sAjaxUrl = BX_DOL_URL_ROOT . "modules/modloaded/clonetwo/pages.php?ajax=1&key={$aDepData['IdField']}&value={$aDepData['CaptionField']}&table={$mValues[0]}&parent={$aDepData['DepParentField']}&filter=";
$aAllValues['attrs'] = array('onchange' => "getHtmlData('{$aItem['DepField']}','{$sAjaxUrl}'+this.value)");
}
$aAllValues['values'] = $aValues;
return $aAllValues;
}
}
} elseif (is_array($mValues)) {
foreach ($mValues as $sKey) {
$aValues[$sKey] = _t('_FieldValues_' . $sKey);
}
} elseif (is_string($mValues) and !empty($mValues) and substr($mValues, 0, 2) == $this->sLinkPref) {
$sKey = substr($mValues, 2);
if (isset($GLOBALS['aPreValues'][$sKey])) {
$aPValues = $GLOBALS['aPreValues'][$sKey];
foreach ($aPValues as $sKey => $aPValue) {
if (!isset($aPValue[$sUseLKey])) {
$sUseLKey = 'LKey';
}
$aValues[$sKey] = _t($aPValue[$sUseLKey]);
}
}
}
//echoDbg($aValues);
return $aValues;
}
示例14: getEditForm
/**
* Function will generate the edit poll's form ;
*
* @return : (text) - Html presentation data ;
*/
function getEditForm()
{
if ($this->aPollSettings['edit_poll_id']) {
$aPollInfo = $this->_oDb->getPollInfo($this->aPollSettings['edit_poll_id']);
$aPollInfo = array_shift($aPollInfo);
// check poll's permission;
if ($this->aPollSettings['admin_mode'] || $aPollInfo['id_profile'] == $this->aPollSettings['member_id']) {
$aLanguageKeys = array('question' => _t('_bx_poll_question'), 'answer' => _t('_bx_poll_answer'), 'save' => _t('_bx_poll_save'), 'close' => _t('_bx_poll_close'), 'active' => _t('_bx_poll_active'), 'approve' => _t('_bx_poll_approve'), 'tags' => _t('_bx_poll_tags'), 'tags_sep' => _t('_bx_poll_tags_separeted'), 'question_length_req' => _t('_bx_poll_question_length_required', $this->aPollSettings['question_min_length'], $this->aPollSettings['question_max_length']), 'answer_length_req' => _t('_bx_poll_answer_length_required', $this->aPollSettings['answer_min_length'], $this->aPollSettings['answer_max_length']));
// generate edit form;
$aForm = array('form_attrs' => array('action' => $this->sPathToModule . '&mode=' . $this->aPollSettings['mode'] . '&edit_poll_id=' . $this->aPollSettings['edit_poll_id'], 'method' => 'post', 'name' => 'poll_edit_form'), 'params' => array('checker_helper' => 'BxCheckerPoll', 'db' => array('submit_name' => 'do_submit')), 'inputs' => array('question' => array('type' => 'text', 'name' => 'question', 'caption' => $aLanguageKeys['question'], 'required' => true, 'value' => $aPollInfo['poll_question'], 'checker' => array('func' => 'length', 'params' => array($this->aPollSettings['question_min_length'], $this->aPollSettings['question_max_length']), 'error' => $aLanguageKeys['question_length_req']))));
// generate answers list ;
$aAnswers = explode(BX_POLL_ANS_DIVIDER, $aPollInfo['poll_answers']);
$iIndex = 0;
foreach ($aAnswers as $iKey => $sValue) {
if ($sValue) {
$iIndex++;
$aForm['inputs'][] = array('type' => 'text', 'name' => 'answers_' . $iIndex, 'caption' => $aLanguageKeys['answer'] . ' ' . $iIndex, 'required' => true, 'value' => $sValue, 'checker' => array('func' => 'length', 'params' => array($this->aPollSettings['answer_min_length'], $this->aPollSettings['answer_max_length']), 'error' => $aLanguageKeys['answer_length_req']));
}
}
// generate categories;
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aCurrentCategories = explode(CATEGORIES_DIVIDER, $aPollInfo['poll_categories']);
$aForm['inputs']['category'] = $oCategories->getGroupChooser('bx_poll', $this->aPollSettings['member_id'], true, $aPollInfo['poll_categories']);
$aForm['inputs']['category']['value'] = $aCurrentCategories;
// generate tags el;
$aForm['inputs'][] = array('type' => 'text', 'name' => 'tags', 'caption' => $aLanguageKeys['tags'], 'required' => false, 'info' => $aLanguageKeys['tags_sep'], 'value' => $aPollInfo['poll_tags']);
$aForm['inputs'] = array_merge($aForm['inputs'], array('allow_view_to' => $this->oPrivacy->getGroupChooser($this->aPollSettings['member_id'], $this->aModuleInfo['uri'], 'view', array(), _t('_bx_poll_allow_view')), 'allow_comments_to' => $this->oPrivacy->getGroupChooser($this->aPollSettings['member_id'], $this->aModuleInfo['uri'], 'comment', array(), _t('_bx_poll_allow_comment')), 'allow_vote_to' => $this->oPrivacy->getGroupChooser($this->aPollSettings['member_id'], $this->aModuleInfo['uri'], 'vote', array(), _t('_bx_poll_allow_vote'))));
// add status checkbox;
$aForm['inputs'][] = array('type' => 'checkbox', 'name' => 'active', 'caption' => $aLanguageKeys['active'], 'attrs' => array('checked' => $aPollInfo['poll_status'] ? 'checked' : null));
// add approve checkbox;
if (isAdmin()) {
$aForm['inputs'][] = array('type' => 'checkbox', 'name' => 'approve', 'caption' => $aLanguageKeys['approve'], 'attrs' => array('checked' => $aPollInfo['poll_approval'] ? 'checked' : null));
}
// add submit button;
$aForm['inputs'][] = array('type' => 'submit', 'name' => 'do_submit', 'value' => $aLanguageKeys['save']);
$aForm['inputs']['allow_view_to']['value'] = (string) $aPollInfo['allow_view_to'];
$aForm['inputs']['allow_comments_to']['value'] = (string) $aPollInfo['allow_comment_to'];
$aForm['inputs']['allow_vote_to']['value'] = (string) $aPollInfo['allow_vote_to'];
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker();
// create new poll
if ($oForm->isSubmittedAndValid()) {
$this->proccesData();
$sOutputCode = MsgBox(_t('_bx_poll_was_edited'));
} else {
$sOutputCode = $oForm->getCode();
}
}
}
return $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sOutputCode));
}