/** * print custom fields * @param integer $p_field_id Custom field identifier. * @return void */ function print_filter_custom_field($p_field_id) { global $g_filter, $t_accessible_custom_fields_names, $t_accessible_custom_fields_types, $t_accessible_custom_fields_values, $t_accessible_custom_fields_ids, $g_select_modifier; $j = array_search($p_field_id, $t_accessible_custom_fields_ids); if ($j === null || $j === false) { ?> <span style="color:red;font-weight:bold;"> unknown custom filter (custom <?php echo $p_field_id; ?> ) </span> <?php } else { if (isset($t_accessible_custom_fields_names[$j])) { if ($t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_DATE) { print_filter_custom_field_date($j, $p_field_id); } else { if ($t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_TEXTAREA) { echo '<input type="text" name="custom_field_', $p_field_id, '" size="10" value="" />'; } else { echo '<select' . $g_select_modifier . ' name="custom_field_' . $p_field_id . '[]">'; echo '<option value="' . META_FILTER_ANY . '"'; check_selected($g_filter['custom_fields'][$p_field_id], (string) META_FILTER_ANY); echo '>[' . lang_get('any') . ']</option>'; # don't show META_FILTER_NONE for enumerated types as it's not possible for them to be blank if (!in_array($t_accessible_custom_fields_types[$j], array(CUSTOM_FIELD_TYPE_ENUM, CUSTOM_FIELD_TYPE_LIST, CUSTOM_FIELD_TYPE_MULTILIST))) { echo '<option value="' . META_FILTER_NONE . '"'; check_selected($g_filter['custom_fields'][$p_field_id], (string) META_FILTER_NONE); echo '>[' . lang_get('none') . ']</option>'; } if (is_array($t_accessible_custom_fields_values[$j])) { $t_max_length = config_get('max_dropdown_length'); foreach ($t_accessible_custom_fields_values[$j] as $t_item) { if (strtolower($t_item) !== META_FILTER_ANY && strtolower($t_item) !== META_FILTER_NONE) { echo '<option value="' . string_attribute($t_item) . '"'; if (isset($g_filter['custom_fields'][$p_field_id])) { check_selected($g_filter['custom_fields'][$p_field_id], $t_item); } echo '>' . string_attribute(string_shorten($t_item, $t_max_length)) . '</option>' . "\n"; } } } echo '</select>'; } } } } }
function print_filter_custom_field($p_field_id) { global $t_filter, $t_accessible_custom_fields_names, $t_accessible_custom_fields_types, $t_accessible_custom_fields_values, $t_accessible_custom_fields_ids, $t_select_modifier; $j = array_search($p_field_id, $t_accessible_custom_fields_ids); if ($j === null || $j === false) { # Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE. ?> <span style="color:red;weight:bold;"> unknown custom filter (custom <?php $p_field_id; ?> ) </span> <?php } elseif (isset($t_accessible_custom_fields_names[$j])) { if ($t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_DATE) { print_filter_custom_field_date($j, $p_field_id); } else { echo '<select ' . $t_select_modifier . ' name="custom_field_' . $p_field_id . '[]">'; echo '<option value="' . META_FILTER_ANY . '" '; check_selected($t_filter['custom_fields'][$p_field_id], META_FILTER_ANY); echo '>[' . lang_get('any') . ']</option>'; # don't show META_FILTER_NONE for enumerated types as it's not possible for them to be blank if (!in_array($t_accessible_custom_fields_types[$j], array(CUSTOM_FIELD_TYPE_ENUM, CUSTOM_FIELD_TYPE_LIST, CUSTOM_FIELD_TYPE_MULTILIST))) { echo '<option value="' . META_FILTER_NONE . '" '; check_selected($t_filter['custom_fields'][$p_field_id], META_FILTER_NONE); echo '>[' . lang_get('none') . ']</option>'; } foreach ($t_accessible_custom_fields_values[$j] as $t_item) { if (strtolower($t_item) !== META_FILTER_ANY && strtolower($t_item) !== META_FILTER_NONE) { echo '<option value="' . string_html_entities($t_item) . '" '; if (isset($t_filter['custom_fields'][$p_field_id])) { check_selected($t_filter['custom_fields'][$p_field_id], $t_item); } echo '>' . string_shorten($t_item) . '</option>' . "\n"; } } echo '</select>'; } } }