コード例 #1
0
ファイル: filter_api.php プロジェクト: vipjaven/mantisbt
/**
 * Print sort fields
 * @return void
 */
function print_filter_show_sort()
{
    global $g_filter;
    # get all of the displayed fields for sort, then drop ones that
    #  are not appropriate and translate the rest
    $t_fields = helper_get_columns_to_view();
    $t_n_fields = count($t_fields);
    $t_shown_fields[''] = '';
    for ($i = 0; $i < $t_n_fields; $i++) {
        if (!in_array($t_fields[$i], array('selection', 'edit', 'bugnotes_count', 'attachment_count'))) {
            if (strpos($t_fields[$i], 'custom_') === 0) {
                $t_field_name = string_display(lang_get_defaulted(utf8_substr($t_fields[$i], utf8_strlen('custom_'))));
            } else {
                $t_field_name = string_get_field_name($t_fields[$i]);
            }
            $t_shown_fields[$t_fields[$i]] = $t_field_name;
        }
    }
    $t_shown_dirs[''] = '';
    $t_shown_dirs['ASC'] = lang_get('bugnote_order_asc');
    $t_shown_dirs['DESC'] = lang_get('bugnote_order_desc');
    # get default values from filter structure
    $t_sort_fields = explode(',', $g_filter[FILTER_PROPERTY_SORT_FIELD_NAME]);
    $t_dir_fields = explode(',', $g_filter[FILTER_PROPERTY_SORT_DIRECTION]);
    if (!isset($t_sort_fields[1])) {
        $t_sort_fields[1] = '';
        $t_dir_fields[1] = '';
    }
    # if there are fields to display, show the dropdowns
    if (count($t_fields) > 0) {
        # display a primary and secondary sort fields
        echo '<select name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_0">';
        foreach ($t_shown_fields as $t_key => $t_val) {
            echo '<option value="' . $t_key . '"';
            check_selected($t_key, $t_sort_fields[0]);
            echo '>' . $t_val . '</option>';
        }
        echo '</select>';
        echo '<select name="', FILTER_PROPERTY_SORT_DIRECTION, '_0">';
        foreach ($t_shown_dirs as $t_key => $t_val) {
            echo '<option value="' . $t_key . '"';
            check_selected($t_key, $t_dir_fields[0]);
            echo '>' . $t_val . '</option>';
        }
        echo '</select>';
        echo ', ';
        # for secondary sort
        echo '<select name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_1">';
        foreach ($t_shown_fields as $t_key => $t_val) {
            echo '<option value="' . $t_key . '"';
            check_selected($t_key, $t_sort_fields[1]);
            echo '>' . $t_val . '</option>';
        }
        echo '</select>';
        echo '<select name="', FILTER_PROPERTY_SORT_DIRECTION, '_1">';
        foreach ($t_shown_dirs as $t_key => $t_val) {
            echo '<option value="' . $t_key . '"';
            check_selected($t_key, $t_dir_fields[1]);
            echo '>' . $t_val . '</option>';
        }
        echo '</select>';
    } else {
        echo lang_get_defaulted('last_updated') . lang_get('bugnote_order_desc');
        echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_1" value="last_updated" />';
        echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_1" value="DESC" />';
    }
}
コード例 #2
0
ファイル: filter_api.php プロジェクト: amjadtbssm/website
function print_filter_show_sort()
{
    global $t_filter;
    # get all of the displayed fields for sort, then drop ones that
    #  are not appropriate and translate the rest
    $t_fields = helper_get_columns_to_view();
    $t_n_fields = count($t_fields);
    $t_shown_fields[""] = "";
    for ($i = 0; $i < $t_n_fields; $i++) {
        if (!in_array($t_fields[$i], array('selection', 'edit', 'bugnotes_count', 'attachment'))) {
            if (strpos($t_fields[$i], 'custom_') === 0) {
                $t_field_name = string_display(lang_get_defaulted(substr($t_fields[$i], strlen('custom_'))));
            } else {
                $t_field_name = string_get_field_name($t_fields[$i]);
            }
            $t_shown_fields[$t_fields[$i]] = $t_field_name;
        }
    }
    $t_shown_dirs[""] = "";
    $t_shown_dirs["ASC"] = lang_get('bugnote_order_asc');
    $t_shown_dirs["DESC"] = lang_get('bugnote_order_desc');
    # get default values from filter structure
    $t_sort_fields = split(',', $t_filter['sort']);
    $t_dir_fields = split(',', $t_filter['dir']);
    if (!isset($t_sort_fields[1])) {
        $t_sort_fields[1] = '';
        $t_dir_fields[1] = '';
    }
    # if there are fields to display, show the dropdowns
    if (count($t_fields) > 0) {
        # display a primary and secondary sort fields
        echo '<select name="sort_0">';
        foreach ($t_shown_fields as $key => $val) {
            echo "<option value=\"{$key}\"";
            check_selected($key, $t_sort_fields[0]);
            echo ">{$val}</option>";
        }
        echo '</select>';
        echo '<select name="dir_0">';
        foreach ($t_shown_dirs as $key => $val) {
            echo "<option value=\"{$key}\"";
            check_selected($key, $t_dir_fields[0]);
            echo ">{$val}</option>";
        }
        echo '</select>';
        echo ', ';
        # for secondary sort
        echo '<select name="sort_1">';
        foreach ($t_shown_fields as $key => $val) {
            echo "<option value=\"{$key}\"";
            check_selected($key, $t_sort_fields[1]);
            echo ">{$val}</option>";
        }
        echo '</select>';
        echo '<select name="dir_1">';
        foreach ($t_shown_dirs as $key => $val) {
            echo "<option value=\"{$key}\"";
            check_selected($key, $t_dir_fields[1]);
            echo ">{$val}</option>";
        }
        echo '</select>';
    } else {
        echo lang_get_defaulted('last_updated') . lang_get('bugnote_order_desc');
        echo "<input type=\"hidden\" name=\"sort_1\" value=\"last_updated\" />";
        echo "<input type=\"hidden\" name=\"dir_1\" value=\"DESC\" />";
    }
}