Skip to content

Commit

Permalink
move prepare_verison_String into version api
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Sep 29, 2013
1 parent 1d665f1 commit 8b4c789
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
23 changes: 0 additions & 23 deletions core/prepare_api.php
Expand Up @@ -80,27 +80,4 @@ function prepare_user_name( $p_user_id ) {
}
}

/**
* A function that prepares the version string for outputting to the user on view / print issue pages.
* This function would add the version date, if appropriate.
*
* @param integer $p_project_id The project id.
* @param integer $p_version_id The version id. If false then this method will return an empty string.
* @return string The formatted version string.
*/
function prepare_version_string( $p_project_id, $p_version_id ) {
if ( $p_version_id === false ) {
return '';
}

$t_version_text = version_full_name( $p_version_id, /* showProject */ null, $p_project_id );

if ( access_has_project_level( config_get( 'show_version_dates_threshold' ), $p_project_id ) ) {
$t_short_date_format = config_get( 'short_date_format' );

$t_version = version_get( $p_version_id );
$t_version_text .= ' (' . date( $t_short_date_format, $t_version->date_order ) . ')';
}

return $t_version_text;
}
2 changes: 1 addition & 1 deletion core/print_api.php
Expand Up @@ -764,7 +764,7 @@ function print_version_option_list( $p_version = '', $p_project_id = null, $p_re
echo '<option value="' . $t_version . '"';
check_selected( string_attribute( $p_version ), $t_version );

$t_version_string = string_attribute( prepare_version_string( $c_project_id, $version['id'] ) );
$t_version_string = string_attribute( version_prepare_string( $c_project_id, $version['id'] ) );

echo '>', string_shorten( $t_version_string , $t_max_length ), '</option>';
}
Expand Down
25 changes: 25 additions & 0 deletions core/version_api.php
Expand Up @@ -672,3 +672,28 @@ function version_get_project_where_clause( $p_project_id, $p_inherit ) {

return $t_project_where;
}

/**
* A function that prepares the version string for outputting to the user on view / print issue pages.
* This function would add the version date, if appropriate.
*
* @param integer $p_project_id The project id.
* @param integer $p_version_id The version id. If false then this method will return an empty string.
* @return string The formatted version string.
*/
function version_prepare_string( $p_project_id, $p_version_id ) {
if ( $p_version_id === false ) {
return '';
}

$t_version_text = version_full_name( $p_version_id, /* showProject */ null, $p_project_id );

if ( access_has_project_level( config_get( 'show_version_dates_threshold' ), $p_project_id ) ) {
$t_short_date_format = config_get( 'short_date_format' );

$t_version = version_get( $p_version_id );
$t_version_text .= ' (' . date( $t_short_date_format, $t_version->date_order ) . ')';
}

return $t_version_text;
}
6 changes: 3 additions & 3 deletions print_bug_page.php
Expand Up @@ -158,15 +158,15 @@

$t_product_version =
$t_show_product_version ?
string_display_line( prepare_version_string( $t_bug->project_id, version_get_id( $t_bug->version, $t_bug->project_id ) ) ) : '';
string_display_line( version_prepare_string( $t_bug->project_id, version_get_id( $t_bug->version, $t_bug->project_id ) ) ) : '';

$t_target_version =
$t_show_target_version ?
string_display_line( prepare_version_string( $t_bug->project_id, version_get_id( $t_bug->target_version, $t_bug->project_id ) ) ) : '';
string_display_line( version_prepare_string( $t_bug->project_id, version_get_id( $t_bug->target_version, $t_bug->project_id ) ) ) : '';

$t_fixed_in_version =
$t_show_fixed_in_version ?
string_display_line( prepare_version_string( $t_bug->project_id, version_get_id( $t_bug->fixed_in_version, $t_bug->project_id ) ) ) : '';
string_display_line( version_prepare_string( $t_bug->project_id, version_get_id( $t_bug->fixed_in_version, $t_bug->project_id ) ) ) : '';

html_page_top1( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
html_head_end();
Expand Down

0 comments on commit 8b4c789

Please sign in to comment.