/** * Get tempcode for adding/editing form. * * @param SHORT_TEXT The name of the custom profile field * @param LONG_TEXT The description of the field * @param LONG_TEXT The default value of the field * @param BINARY Whether the field is publicly viewable * @param BINARY Whether the field may be viewed by the owner * @param BINARY Whether the owner may set the value of the field * @param BINARY Whether the field is encrypted * @param ID_TEXT The type of the field * @set short_text long_text short_trans long_trans integer upload picture url list tick * @param BINARY Whether the field is required to be filled in * @param BINARY Whether the field is to be shown on the join form * @param BINARY Whether the field is shown in posts * @param BINARY Whether the field is shown in post previews * @param ?integer The order the field is given relative to the order of the other custom profile fields (NULL: last) * @param LONG_TEXT The usergroups that this field is confined to (comma-separated list). * @param BINARY Whether the field is locked * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($name = '', $description = '', $default = '', $public_view = 1, $owner_view = 1, $owner_set = 1, $encrypted = 0, $type = 'long_text', $required = 0, $show_on_join_form = 0, $show_in_posts = 0, $show_in_post_previews = 0, $order = NULL, $only_group = '', $locked = 0) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); require_code('encryption'); require_lang('fields'); if ($locked == 0) { $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true)); } else { $hidden->attach(form_input_hidden('name', $name)); } $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false)); $fields->attach(form_input_line(do_lang_tempcode('DEFAULT_VALUE'), do_lang_tempcode('DESCRIPTION_DEFAULT_VALUE_CPF'), 'default', $default, false, NULL, 10000)); $fields->attach(form_input_tick(do_lang_tempcode('OWNER_VIEW'), do_lang_tempcode('DESCRIPTION_OWNER_VIEW'), 'owner_view', $owner_view == 1)); $fields->attach(form_input_tick(do_lang_tempcode('OWNER_SET'), do_lang_tempcode('DESCRIPTION_OWNER_SET'), 'owner_set', $owner_set == 1)); $fields->attach(form_input_tick(do_lang_tempcode('PUBLIC_VIEW'), do_lang_tempcode('DESCRIPTION_PUBLIC_VIEW'), 'public_view', $public_view == 1)); if (is_encryption_enabled() && $name == '') { $fields->attach(form_input_tick(do_lang_tempcode('ENCRYPTED'), do_lang_tempcode('DESCRIPTION_ENCRYPTED'), 'encrypted', $encrypted == 1)); } require_code('fields'); $type_list = nice_get_field_type($type, $name != ''); $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_FIELD_TYPE'), 'type', $type_list)); $fields->attach(form_input_tick(do_lang_tempcode('REQUIRED'), do_lang_tempcode('DESCRIPTION_REQUIRED'), 'required', $required == 1)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_ON_JOIN_FORM'), do_lang_tempcode('DESCRIPTION_SHOW_ON_JOIN_FORM'), 'show_on_join_form', $show_on_join_form == 1)); $orderlist = new ocp_tempcode(); $num_cpfs = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'COUNT(*)'); if ($name == '') { $num_cpfs++; } $selected_one = false; for ($i = 0; $i < (is_null($order) ? $num_cpfs : max($num_cpfs, $order)); $i++) { $selected = $i === $order || $name == '' && $i == $num_cpfs - 1; if ($selected) { $selected_one = true; } $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1))); } if (!$selected_one) { $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1))); } $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('DESCRIPTION_FIELD_ORDER'), 'order', $orderlist)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POSTS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POSTS'), 'show_in_posts', $show_in_posts == 1)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POST_PREVIEWS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POST_PREVIEWS'), 'show_in_post_previews', $show_in_post_previews == 1)); $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_super_admin'), array('g_is_private_club' => 0)); if ($locked == 0) { $groups = new ocp_tempcode(); //$groups=form_input_list_entry('-1',false,do_lang_tempcode('_ALL')); foreach ($rows as $group) { if ($group['id'] != db_get_first_id()) { $groups->attach(form_input_list_entry(strval($group['id']), count(array_intersect(array($group['id']), explode(',', $only_group))) != 0, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_multi_list(do_lang_tempcode('GROUP'), do_lang_tempcode('DESCRIPTION_FIELD_ONLY_GROUP'), 'only_group', $groups)); } else { $hidden->attach(form_input_hidden('only_group', '')); } return array($fields, $hidden); }
/** * Get tempcode for a catalogue field adding/editing form (many of these are put together to add/edit a single catalogue!). * * @param boolean Whether this is the first field of the entry fields * @param integer The number of fields that will be on the screen * @param string The prefix the field input fields are given (e.g. new1_) * @param integer The order of the field relative to the other fields * @param SHORT_TEXT The name of the field * @param LONG_TEXT Description for the field * @param ID_TEXT The field type * @param BINARY Whether the field defines entry ordering * @param BINARY Whether the field is searchable * @param BINARY Whether the field is visible when an entry is viewed * @param SHORT_TEXT Default value for the field * @param BINARY Whether the field is required * @param BINARY Whether the field is to be shown in category views (not applicable for the list display type) * @param BINARY Whether the field is to be shown in search views (not applicable for the list display type) * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_field_fields($first_field, $num_fields_to_show, $prefix, $order, $name = '', $description = '', $type = 'short_text', $defines_order = 0, $visible = 1, $searchable = 1, $default = '', $required = 0, $put_in_category = 1, $put_in_search = 1) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_FIELD_NAME'), $prefix . 'name', $name, $name != '' || $first_field)); // If this is gonna be a new field that might not be filled in, don't make them fill it in $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_FIELD_DESCRIPTION'), $prefix . 'description', $description, false)); $fields->attach(form_input_line(do_lang_tempcode('DEFAULT_VALUE'), do_lang_tempcode('DESCRIPTION_FIELD_DEFAULT'), $prefix . 'default', $default, false, NULL, 10000)); require_code('fields'); require_lang('fields'); $type_list = nice_get_field_type($type, $name != ''); $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode($name == '' ? 'DESCRIPTION_FIELD_TYPE_FIRST_TIME' : 'DESCRIPTION_FIELD_TYPE'), $prefix . 'type', $type_list)); $order_list = new ocp_tempcode(); for ($i = 0; $i < $num_fields_to_show; $i++) { $order_list->attach(form_input_list_entry(strval($i), $i == $order, integer_format($i + 1) . ($i == 0 && substr(get_param('id', ''), 0, 1) != '_' ? do_lang('NEW_FIELD_TITLE') : ''))); } $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('DESCRIPTION_FIELD_ORDER_CLEVER'), $prefix . 'order', $order_list)); // Defines order? $radios = form_input_radio_entry($prefix . 'defines_order', '0', $defines_order == 0, do_lang_tempcode('NO')); $radios->attach(form_input_radio_entry($prefix . 'defines_order', '1', $defines_order == 1, do_lang_tempcode('ASCENDING'))); $radios->attach(form_input_radio_entry($prefix . 'defines_order', '2', $defines_order == 2, do_lang_tempcode('DESCENDING'))); $fields->attach(form_input_radio(do_lang_tempcode('DEFINES_ORDER'), do_lang_tempcode('DESCRIPTION_DEFINES_ORDER'), $prefix . 'defines_order', $radios)); if ($first_field) { $hidden->attach(form_input_hidden($prefix . 'visible', '1')); $hidden->attach(form_input_hidden($prefix . 'required', '1')); } else { $fields->attach(form_input_tick(do_lang_tempcode('VISIBLE'), do_lang_tempcode('DESCRIPTION_VISIBLE'), $prefix . 'visible', $visible == 1)); $fields->attach(form_input_tick(do_lang_tempcode('REQUIRED'), do_lang_tempcode('DESCRIPTION_REQUIRED'), $prefix . 'required', $required == 1)); } $fields->attach(form_input_tick(do_lang_tempcode('SEARCHABLE'), do_lang_tempcode('DESCRIPTION_SEARCHABLE'), $prefix . 'searchable', $searchable == 1)); $fields->attach(form_input_tick(do_lang_tempcode('PUT_IN_CATEGORY'), do_lang_tempcode('DESCRIPTION_PUT_IN_CATEGORY'), $prefix . 'put_in_category', $put_in_category == 1)); $fields->attach(form_input_tick(do_lang_tempcode('PUT_IN_SEARCH'), do_lang_tempcode('DESCRIPTION_PUT_IN_SEARCH'), $prefix . 'put_in_search', $put_in_search == 1)); return array($fields, $hidden); }