public static function getExtraDetailsByFieldType($field_type) { switch ($field_type) { case 'email': return SJB_EmailType::getFieldExtraDetails(); case 'list': return SJB_ListType::getFieldExtraDetails(); case 'multilist': return SJB_MultiListType::getFieldExtraDetails(); case 'string': return SJB_StringType::getFieldExtraDetails(); case 'text': return SJB_TextType::getFieldExtraDetails(); case 'integer': return SJB_IntegerType::getFieldExtraDetails(); case 'float': return SJB_FloatType::getFieldExtraDetails(); case 'file': return SJB_UploadFileType::getFieldExtraDetails(); case 'geo': return SJB_GeoType::getFieldExtraDetails(); case 'video': return SJB_UploadVideoFileType::getFieldExtraDetails(); case 'pictures': return SJB_PicturesType::getFieldExtraDetails(); case 'tree': return SJB_TreeType::getFieldExtraDetails(); case 'picture': return SJB_PictureType::getFieldExtraDetails(); case 'logo': return SJB_LogoType::getFieldExtraDetails(); case 'captcha': return SJB_CaptchaType::getFieldExtraDetails(); case 'youtube': return SJB_YouTubeType::getFieldExtraDetails(); case 'monetary': return SJB_MonetaryType::getFieldExtraDetails(); case 'location': return SJB_LocationType::getFieldExtraDetails(); break; default: return array(); } }
public function execute() { $listing_field_sid = SJB_Request::getVar('sid', null); $tp = SJB_System::getTemplateProcessor(); if (!is_null($listing_field_sid)) { $listing_field_info = SJB_ListingFieldManager::getFieldInfoBySID($listing_field_sid); $listing_field_info = array_merge($listing_field_info, $_REQUEST); $listing_field = new SJB_ListingField($listing_field_info); $listing_field->setSID($listing_field_sid); $form_submitted = SJB_Request::getVar('action', ''); if (!in_array($listing_field->field_type, array('video', 'picture', 'file', 'complex'))) { $profile_field = SJB_Request::getVar('profile_field', false); if ($form_submitted) { if ($profile_field) { $listing_field_info['default_value'] = ''; } else { $listing_field_info['profile_field_as_dv'] = ''; } } $default_value = array(); if ($listing_field->field_type != 'location') { $default_value = array('id' => 'default_value', 'sid' => isset($listing_field_info['sid']) ? $listing_field_info['sid'] : '', 'caption' => 'Default Value', 'value' => isset($listing_field_info['default_value']) ? $listing_field_info['default_value'] : '', 'type' => $listing_field->field_type, 'length' => '', 'is_required' => false, 'is_system' => true, 'add_parameter' => isset($listing_field_info['add_parameter']) ? $listing_field_info['add_parameter'] : ''); } switch ($listing_field->field_type) { case 'list': if (isset($listing_field_info['list_values'])) { $default_value['list_values'] = $listing_field_info['list_values']; } break; case 'multilist': if (isset($listing_field_info['list_values'])) { $default_value['list_values'] = $listing_field_info['list_values']; } if (!is_array($default_value['value'])) { if (strpos($default_value['value'], ',')) { $default_value['value'] = explode(',', $default_value['value']); } else { $default_value['value'] = array($default_value['value']); } } break; case 'tree': if (isset($listing_field_info['tree_values'])) { $default_value['tree_values'] = $listing_field_info['tree_values']; } if (isset($listing_field_info['display_as_select_boxes'])) { $default_value['display_as_select_boxes'] = $listing_field_info['display_as_select_boxes']; } unset($listing_field_info['choiceLimit']); break; case 'monetary': if (isset($listing_field_info['currency_values'])) { $default_value['currency_values'] = $listing_field_info['currency_values']; } break; } if ($listing_field->field_type != 'location') { $listing_field->addProperty($default_value); $profile_field_as_dv = array('id' => 'profile_field_as_dv', 'caption' => 'Default Value', 'value' => isset($listing_field_info['profile_field_as_dv']) ? $listing_field_info['profile_field_as_dv'] : '', 'type' => 'list', 'list_values' => SJB_UserProfileFieldManager::getAllFieldsInfo(), 'length' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($profile_field_as_dv); } if (in_array($listing_field->field_type, array('tree', 'multilist', 'list'))) { $sort_by_alphabet = array('id' => 'sort_by_alphabet', 'caption' => 'Sort Values By Alphabet', 'value' => isset($listing_field_info['sort_by_alphabet']) ? $listing_field_info['sort_by_alphabet'] : '', 'type' => 'boolean', 'lenght' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($sort_by_alphabet); } $tp->assign('profileFieldAsDV', !empty($listing_field_info['profile_field_as_dv'])); } if (in_array($listing_field->field_type, array('multilist', 'list'))) { $listing_field->addDisplayAsProperty($listing_field_info['display_as']); } // infil instructions should be the last element in form if (!in_array($listing_field->getFieldType(), array('complex', 'tree', 'location'))) { if ($form_submitted) { $listing_field->addInfillInstructions(SJB_Request::getVar('instructions')); } else { $listing_field->addInfillInstructions(isset($listing_field_info['instructions']) ? $listing_field_info['instructions'] : ''); } } if ('tree' == $listing_field->getFieldType()) { $listing_field->addProperty(SJB_TreeType::getDisplayAsDetail(isset($listing_field_info['display_as_select_boxes']) ? $listing_field_info['display_as_select_boxes'] : '')); $treeLevelsNumber = SJB_ListingFieldTreeManager::getTreeDepthBySID($listing_field_sid); $tp->assign('tree_levels_number', $treeLevelsNumber); // treee levels captions for ($i = 1; $i <= $treeLevelsNumber; $i++) { $levelID = 'level_' . $i; $listing_field->addProperty(array('id' => $levelID, 'caption' => $i . ' Level Name', 'value' => isset($listing_field_info[$levelID]) ? $listing_field_info[$levelID] : '', 'type' => 'string', 'length' => '250', 'is_required' => false, 'is_system' => true)); } } $edit_form = new SJB_Form($listing_field); $errors = array(); if ($form_submitted && $edit_form->isDataValid($errors)) { $old_listing_field_id = SJB_Request::getVar('old_listing_field_id', null); SJB_ListingFieldManager::saveListingField($listing_field); SJB_ListingFieldManager::changeListingPropertyIDs($listing_field_info['id'], $old_listing_field_id); if ($form_submitted == 'save_info') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/listing-fields/'); } } $edit_form->registerTags($tp); $edit_form->makeDisabled('type'); if ($listing_field_info['id'] == 'Location' && empty($errors['ID'])) { $edit_form->makeDisabled('id'); } $tp->assign('object_sid', $listing_field); $tp->assign('form_fields', $edit_form->getFormFieldsInfo()); $tp->assign('errors', $errors); $tp->assign('field_type', $listing_field->getFieldType()); $tp->assign('listing_field_info', $listing_field_info); $tp->assign('field_sid', $listing_field_sid); $tp->display('edit_listing_field.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listing_field_sid = SJB_Request::getVar('sid', null); if (!is_null($listing_field_sid)) { $listingFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($listing_field_sid); $old_listing_field_id = $listingFieldInfo['id']; $listingFieldInfo = array_merge($listingFieldInfo, $_REQUEST); $listing_field = new SJB_ListingField($listingFieldInfo, $listingFieldInfo['listing_type_sid']); $listing_field->setSID($listing_field_sid); $formSubmitted = SJB_Request::getVar('action', ''); if (!in_array($listing_field->field_type, array('video', 'picture', 'file', 'complex'))) { $profileField = SJB_Request::getVar('profile_field', false); if ($formSubmitted) { if ($profileField) { $listingFieldInfo['default_value'] = ''; } else { $listingFieldInfo['profile_field_as_dv'] = ''; } } $default_value = array('id' => 'default_value', 'sid' => isset($listingFieldInfo['sid']) ? $listingFieldInfo['sid'] : '', 'caption' => 'Default Value', 'value' => isset($listingFieldInfo['default_value']) ? $listingFieldInfo['default_value'] : '', 'type' => $listing_field->field_type, 'length' => '', 'is_required' => false, 'is_system' => true); $additionalParameters = array(); switch ($listing_field->field_type) { case 'list': if (isset($listingFieldInfo['list_values'])) { $additionalParameters = array('list_values' => $listingFieldInfo['list_values']); } break; case 'multilist': if (isset($listingFieldInfo['list_values'])) { $additionalParameters = array('list_values' => $listingFieldInfo['list_values']); } if (!is_array($default_value['value'])) { if (strpos($default_value['value'], ',')) { $default_value['value'] = explode(',', $default_value['value']); } else { $default_value['value'] = array($default_value['value']); } } break; case 'tree': if (isset($listingFieldInfo['tree_values'])) { $additionalParameters = array('tree_values' => $listingFieldInfo['tree_values']); } break; case 'monetary': if (isset($listingFieldInfo['currency_values'])) { $default_value['currency_values'] = $listingFieldInfo['currency_values']; } break; } $default_value = array_merge($default_value, $additionalParameters); $listing_field->addProperty($default_value); $user_groups = SJB_UserGroupManager::getAllUserGroupsInfo(); $list_values = array(); foreach ($user_groups as $user_group) { $list_values = array_merge($list_values, SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group['sid'])); } $profile_field_as_dv = array('id' => 'profile_field_as_dv', 'caption' => 'Default Value', 'value' => isset($listingFieldInfo['profile_field_as_dv']) ? $listingFieldInfo['profile_field_as_dv'] : '', 'type' => 'list', 'list_values' => $list_values, 'length' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($profile_field_as_dv); if (in_array($listing_field->field_type, array('tree', 'multilist', 'list'))) { $sort_by_alphabet = array('id' => 'sort_by_alphabet', 'caption' => 'Sort Values By Alphabet', 'value' => isset($listingFieldInfo['sort_by_alphabet']) ? $listingFieldInfo['sort_by_alphabet'] : '', 'type' => 'boolean', 'lenght' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($sort_by_alphabet); } $tp->assign('profileFieldAsDV', !empty($listingFieldInfo['profile_field_as_dv'])); } if (in_array($listing_field->field_type, array('multilist', 'list'))) { $listing_field->addDisplayAsProperty($listingFieldInfo['display_as']); } // infil instructions should be the last element in form if (!in_array($listing_field->getFieldType(), array('complex', 'tree', 'location')) && 'ApplicationSettings' != $listing_field->getPropertyValue('id')) { if ($formSubmitted) { $listing_field->addInfillInstructions(SJB_Request::getVar('instructions')); } else { $listing_field->addInfillInstructions(isset($listingFieldInfo['instructions']) ? $listingFieldInfo['instructions'] : ''); } } /** * "Display as" options for TREE TYPE */ if ('tree' == $listing_field->getFieldType()) { $listing_field->addProperty(SJB_TreeType::getDisplayAsDetail(isset($listingFieldInfo['display_as_select_boxes']) ? $listingFieldInfo['display_as_select_boxes'] : '')); $treeLevelsNumber = SJB_ListingFieldTreeManager::getTreeDepthBySID($listing_field_sid); $tp->assign('tree_levels_number', $treeLevelsNumber); // treee levels captions for ($i = 1; $i <= $treeLevelsNumber; $i++) { $levelID = 'level_' . $i; $listing_field->addProperty(array('id' => $levelID, 'caption' => $i . ' Level Name', 'value' => isset($listingFieldInfo[$levelID]) ? $listingFieldInfo[$levelID] : '', 'type' => 'string', 'length' => '250', 'is_required' => false, 'is_system' => true)); } } /* * end of ""Display as" options for TREE TYPE" */ $edit_form = new SJB_Form($listing_field); $edit_form->makeDisabled("type"); $errors = array(); if ($formSubmitted && $edit_form->isDataValid($errors)) { SJB_ListingFieldManager::saveListingField($listing_field); SJB_ListingFieldManager::changeListingPropertyIDs($listingFieldInfo['id'], $old_listing_field_id); if ($formSubmitted == 'save_info') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/edit-listing-type/?sid=" . $listing_field->getListingTypeSID()); } } $edit_form->registerTags($tp); $tp->assign("form_fields", $edit_form->getFormFieldsInfo()); $tp->assign("errors", $errors); $tp->assign("listing_type_sid", $listing_field->getListingTypeSID()); $tp->assign("field_type", $listing_field->getFieldType()); $tp->assign("field_sid", $listing_field->getSID()); $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_field->getListingTypeSID()); $tp->assign("listing_type_info", $listing_type_info); $tp->assign("listing_field_info", $listingFieldInfo); $tp->display("edit_listing_type_field.tpl"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $user_group_sid = SJB_Request::getVar('user_group_sid', null); $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $user_profile_field_sid = SJB_Request::getVar('sid', null); if (!is_null($user_profile_field_sid)) { $user_profile_field_info = SJB_UserProfileFieldManager::getFieldInfoBySID($user_profile_field_sid); $user_profile_field_old_id = $user_profile_field_info['id']; $user_profile_field_info = array_merge($user_profile_field_info, $_REQUEST); $user_profile_field = new SJB_UserProfileField($user_profile_field_info); $user_profile_field->setSID($user_profile_field_sid); $user_profile_field->setUserGroupSID($user_group_sid); if (!in_array($user_profile_field->field_type, array('video', 'picture', 'logo', 'file', 'location'))) { $default_value = array('id' => 'default_value', 'sid' => isset($user_profile_field_info['sid']) ? $user_profile_field_info['sid'] : '', 'caption' => 'Default Value', 'value' => isset($user_profile_field_info['default_value']) ? $user_profile_field_info['default_value'] : '', 'type' => $user_profile_field->field_type, 'length' => '', 'is_required' => false, 'is_system' => true); $additionalParameters = array(); switch ($user_profile_field->field_type) { case 'list': if (isset($user_profile_field_info['list_values'])) { $additionalParameters = array('list_values' => $user_profile_field_info['list_values']); } break; case 'multilist': if (isset($user_profile_field_info['list_values'])) { $additionalParameters = array('list_values' => $user_profile_field_info['list_values']); } if (!is_array($default_value['value'])) { if (strpos($default_value['value'], ',')) { $default_value['value'] = explode(',', $default_value['value']); } else { $default_value['value'] = array($default_value['value']); } } break; case 'tree': if (isset($user_profile_field_info['tree_values'])) { $additionalParameters = array('tree_values' => $user_profile_field_info['tree_values']); } if (isset($user_profile_field_info['display_as_select_boxes'])) { $additionalParameters['display_as_select_boxes'] = $user_profile_field_info['display_as_select_boxes']; } break; } $default_value = array_merge($default_value, $additionalParameters); $user_profile_field->addProperty($default_value); } if (in_array($user_profile_field->field_type, array('tree', 'multilist', 'list'))) { $sort_by_alphabet = array('id' => 'sort_by_alphabet', 'caption' => 'Sort Values By Alphabet', 'value' => isset($user_profile_field_info['sort_by_alphabet']) ? $user_profile_field_info['sort_by_alphabet'] : '', 'type' => 'boolean', 'lenght' => '', 'is_required' => false, 'is_system' => true); $user_profile_field->addProperty($sort_by_alphabet); } $edit_form = new SJB_Form($user_profile_field); $form_submitted = SJB_Request::getVar('action'); if (in_array($user_profile_field->field_type, array('multilist', 'list'))) { $user_profile_field->addDisplayAsProperty($user_profile_field_info['display_as']); } // infill instructions should be the last element in form // no instructions for tree field type if (!in_array($user_profile_field->getFieldType(), array('complex', 'tree', 'location'))) { if ($form_submitted) { $user_profile_field->addInfillInstructions(SJB_Request::getVar('instructions')); } else { $user_profile_field->addInfillInstructions(isset($user_profile_field_info['instructions']) ? $user_profile_field_info['instructions'] : ''); } } /** * "Display as" options for TREE TYPE */ if ('tree' == $user_profile_field->getFieldType()) { $user_profile_field->addProperty(SJB_TreeType::getDisplayAsDetail(isset($user_profile_field_info['display_as_select_boxes']) ? $user_profile_field_info['display_as_select_boxes'] : '')); $treeLevelsNumber = SJB_UserProfileFieldTreeManager::getTreeDepthBySID($user_profile_field_sid); $tp->assign('tree_levels_number', $treeLevelsNumber); // treee levels captions for ($i = 1; $i <= $treeLevelsNumber; $i++) { $levelID = 'level_' . $i; $user_profile_field->addProperty(array('id' => $levelID, 'caption' => $i . ' Level Name', 'value' => isset($user_profile_field_info[$levelID]) ? $user_profile_field_info[$levelID] : '', 'type' => 'string', 'length' => '250', 'is_required' => false, 'is_system' => true)); } } // end of ""Display as" options for TREE TYPE" $edit_form = new SJB_Form($user_profile_field); $errors = array(); if ($form_submitted && $edit_form->isDataValid($errors)) { SJB_UserProfileFieldManager::saveUserProfileField($user_profile_field); $user_profile_field_new_id = $user_profile_field_info['id']; if ($user_profile_field_old_id != $user_profile_field_new_id) { SJB_UserProfileFieldManager::changeUserPropertyIDs($user_group_sid, $user_profile_field_old_id, $user_profile_field_new_id); } if ($form_submitted == 'save_info') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-user-profile/?user_group_sid=' . $user_group_sid); } } if ($user_profile_field_info['id'] == 'Location' && empty($errors['ID'])) { $edit_form->makeDisabled('id'); } $edit_form->registerTags($tp); $edit_form->makeDisabled('type'); $tp->assign('user_group_sid', $user_group_sid); $tp->assign('form_fields', $edit_form->getFormFieldsInfo()); $tp->assign('errors', $errors); $tp->assign('field_type', $user_profile_field->getFieldType()); $tp->assign('userTree', true); $tp->assign('user_profile_field_info', $user_profile_field_info); $tp->assign('user_profile_field_sid', $user_profile_field_sid); $tp->assign('user_group_info', $user_group_info); $tp->display('edit_user_profile_field.tpl'); } }