コード例 #1
0
ファイル: filter_api.php プロジェクト: vipjaven/mantisbt
/**
 * Print custom field date fields
 * @param integer $p_field_num Field number.
 * @param integer $p_field_id  Field identifier.
 * @return void
 */
function print_filter_custom_field_date($p_field_num, $p_field_id)
{
    global $g_filter, $t_accessible_custom_fields_values;
    # Resort the values so there ordered numerically, they are sorted as strings otherwise which
    # may be wrong for dates before early 2001.
    if (is_array($t_accessible_custom_fields_values[$p_field_num])) {
        array_multisort($t_accessible_custom_fields_values[$p_field_num], SORT_NUMERIC, SORT_ASC);
    }
    $t_sel_start_year = null;
    $t_sel_end_year = null;
    if (isset($t_accessible_custom_fields_values[$p_field_num][0])) {
        $t_sel_start_year = date('Y', $t_accessible_custom_fields_values[$p_field_num][0]);
    }
    $t_count = count($t_accessible_custom_fields_values[$p_field_num]);
    if (isset($t_accessible_custom_fields_values[$p_field_num][$t_count - 1])) {
        $t_sel_end_year = date('Y', $t_accessible_custom_fields_values[$p_field_num][$t_count - 1]);
    }
    $t_start = date('U');
    # Default to today in filters..
    $t_end = $t_start;
    if (isset($g_filter['custom_fields'][$p_field_id][1])) {
        $t_start_time = $g_filter['custom_fields'][$p_field_id][1];
    } else {
        $t_start_time = 0;
    }
    if (isset($g_filter['custom_fields'][$p_field_id][2])) {
        $t_end_time = $g_filter['custom_fields'][$p_field_id][2];
    } else {
        $t_end_time = 0;
    }
    $t_start_disable = true;
    $t_end_disable = true;
    # if $g_filter['custom_fields'][$p_field_id][0] is not set (ie no filter),
    # we will drop through the following switch and use the default values
    # above, so no need to check if stuff is set or not.
    switch ($g_filter['custom_fields'][$p_field_id][0]) {
        case CUSTOM_FIELD_DATE_ANY:
        case CUSTOM_FIELD_DATE_NONE:
            break;
        case CUSTOM_FIELD_DATE_BETWEEN:
            $t_start_disable = false;
            $t_end_disable = false;
            $t_start = $t_start_time;
            $t_end = $t_end_time;
            break;
        case CUSTOM_FIELD_DATE_ONORBEFORE:
        case CUSTOM_FIELD_DATE_BEFORE:
            $t_start_disable = false;
            $t_start = $t_end_time;
            break;
        case CUSTOM_FIELD_DATE_ON:
        case CUSTOM_FIELD_DATE_AFTER:
        case CUSTOM_FIELD_DATE_ONORAFTER:
            $t_start_disable = false;
            $t_start = $t_start_time;
            break;
    }
    echo '<table cellspacing="0" cellpadding="0"><tr><td>' . "\n";
    echo '<select size="1" name="custom_field_' . $p_field_id . '_control">' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_ANY . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ANY);
    echo '>' . lang_get('any') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_NONE . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_NONE);
    echo '>' . lang_get('none') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_BETWEEN . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_BETWEEN);
    echo '>' . lang_get('between_date') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_ONORBEFORE . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ONORBEFORE);
    echo '>' . lang_get('on_or_before_date') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_BEFORE . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_BEFORE);
    echo '>' . lang_get('before_date') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_ON . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ON);
    echo '>' . lang_get('on_date') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_AFTER . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_AFTER);
    echo '>' . lang_get('after_date') . '</option>' . "\n";
    echo '<option value="' . CUSTOM_FIELD_DATE_ONORAFTER . '"';
    check_selected((int) $g_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ONORAFTER);
    echo '>' . lang_get('on_or_after_date') . '</option>' . "\n";
    echo '</select>' . "\n";
    echo "</td></tr>\n<tr><td>";
    print_date_selection_set('custom_field_' . $p_field_id . '_start', config_get('short_date_format'), $t_start, $t_start_disable, false, $t_sel_start_year, $t_sel_end_year);
    print "</td></tr>\n<tr><td>";
    print_date_selection_set('custom_field_' . $p_field_id . '_end', config_get('short_date_format'), $t_end, $t_end_disable, false, $t_sel_start_year, $t_sel_end_year);
    print "</td></tr>\n</table>";
}
コード例 #2
0
ファイル: cfdef_standard.php プロジェクト: Kirill/mantisbt
/**
 * Prints the controls for the date selector.
 *
 * @param $p_field_def  The custom field definition.
 * @param $p_custom_field_value  The custom field value to print.
 */
function cfdef_input_date($p_field_def, $p_custom_field_value)
{
    print_date_selection_set('custom_field_' . $p_field_def['id'], config_get('short_date_format'), $p_custom_field_value, false, true);
}
コード例 #3
0
function print_custom_field_input($p_field_def, $p_bug_id = null)
{
    $t_id = $p_field_def['id'];
    if (null === $p_bug_id) {
        $t_custom_field_value = $p_field_def['default_value'];
    } else {
        $t_custom_field_value = custom_field_get_value($t_id, $p_bug_id);
    }
    $t_custom_field_value = string_attribute($t_custom_field_value);
    switch ($p_field_def['type']) {
        case CUSTOM_FIELD_TYPE_ENUM:
        case CUSTOM_FIELD_TYPE_LIST:
        case CUSTOM_FIELD_TYPE_MULTILIST:
            $t_values = explode('|', custom_field_prepare_possible_values($p_field_def['possible_values']));
            $t_list_size = $t_possible_values_count = count($t_values);
            if ($t_possible_values_count > 5) {
                $t_list_size = 5;
            }
            if ($p_field_def['type'] == CUSTOM_FIELD_TYPE_ENUM) {
                $t_list_size = 0;
                # for enums the size is 0
            }
            if ($p_field_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST) {
                echo '<select ', helper_get_tab_index(), ' name="custom_field_' . $t_id . '[]" size="' . $t_list_size . '" multiple="multiple">';
            } else {
                echo '<select ', helper_get_tab_index(), ' name="custom_field_' . $t_id . '" size="' . $t_list_size . '">';
            }
            $t_selected_values = explode('|', $t_custom_field_value);
            foreach ($t_values as $t_option) {
                if (in_array($t_option, $t_selected_values, true)) {
                    echo '<option value="' . $t_option . '" selected="selected"> ' . $t_option . '</option>';
                } else {
                    echo '<option value="' . $t_option . '">' . $t_option . '</option>';
                }
            }
            echo '</select>';
            break;
        case CUSTOM_FIELD_TYPE_CHECKBOX:
            $t_values = explode('|', custom_field_prepare_possible_values($p_field_def['possible_values']));
            $t_checked_values = explode('|', $t_custom_field_value);
            foreach ($t_values as $t_option) {
                echo '<input ', helper_get_tab_index(), ' type="checkbox" name="custom_field_' . $t_id . '[]"';
                if (in_array($t_option, $t_checked_values, true)) {
                    echo ' value="' . $t_option . '" checked="checked">&nbsp;' . $t_option . '&nbsp;&nbsp;';
                } else {
                    echo ' value="' . $t_option . '">&nbsp;' . $t_option . '&nbsp;&nbsp;';
                }
            }
            break;
        case CUSTOM_FIELD_TYPE_NUMERIC:
        case CUSTOM_FIELD_TYPE_FLOAT:
        case CUSTOM_FIELD_TYPE_EMAIL:
        case CUSTOM_FIELD_TYPE_STRING:
            echo '<input ', helper_get_tab_index(), ' type="text" name="custom_field_' . $t_id . '" size="80"';
            if (0 < $p_field_def['length_max']) {
                echo ' maxlength="' . $p_field_def['length_max'] . '"';
            } else {
                echo ' maxlength="255"';
            }
            echo ' value="' . $t_custom_field_value . '"></input>';
            break;
        case CUSTOM_FIELD_TYPE_DATE:
            print_date_selection_set("custom_field_" . $t_id, config_get('short_date_format'), $t_custom_field_value, false, true);
            break;
    }
}