Skip to content

Commit

Permalink
Use helper function to print button links
Browse files Browse the repository at this point in the history
  • Loading branch information
syncguru committed Jul 13, 2014
1 parent 4c5659b commit 5624902
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 92 deletions.
3 changes: 1 addition & 2 deletions account_delete.php
Expand Up @@ -103,8 +103,7 @@
<div class="space-10"></div>
<?php
echo lang_get( 'account_removed_msg' ) . '<br />';
print_link( config_get( 'logout_redirect_page' ), lang_get( 'proceed' ),
false, 'btn btn-primary btn-white btn-round');
print_button( config_get( 'logout_redirect_page' ), lang_get( 'proceed' ));
?>
</div>

Expand Down
4 changes: 2 additions & 2 deletions adm_config_report.php
Expand Up @@ -423,7 +423,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
if( config_can_delete( $v_config_id ) ) {
# Update button (will populate edit form at page bottom)
echo '<div class="pull-left">';
print_button(
print_form_button(
'#config_set_form',
lang_get( 'edit_link' ),
array(
Expand All @@ -439,7 +439,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {

# Delete button
echo '<div class="pull-left">';
print_button(
print_form_button(
'adm_config_delete.php',
lang_get( 'delete_link' ),
array(
Expand Down
3 changes: 1 addition & 2 deletions admin/move_attachments_page.php
Expand Up @@ -84,8 +84,7 @@
?>
<div>
<p>
<?php print_link( helper_mantis_url( 'admin/system_utils.php' ), 'Back to System Utilities',
false, 'btn btn-primary btn-white btn-round' ); ?>
<?php print_button( helper_mantis_url( 'admin/system_utils.php' ), 'Back to System Utilities' ); ?>
</p>
</div>

Expand Down
1 change: 1 addition & 0 deletions bug_file_upload_inc.php
Expand Up @@ -97,6 +97,7 @@
}
}
?>
<br/>
<input type="submit" class="btn btn-primary btn-sm btn-white btn-round"
value="<?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file_button' : 'upload_files_button' ) ?>"
/>
Expand Down
6 changes: 2 additions & 4 deletions bug_report.php
Expand Up @@ -305,10 +305,8 @@

<?php
echo '<p>' . lang_get( 'operation_successful' ) . '</p><br />';
print_link( string_get_bug_view_url( $t_bug_id ), sprintf( lang_get( 'view_submitted_bug_link' ), $t_bug_id ),
false, 'btn btn-sm btn-primary btn-white btn-round' );
print_link( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ),
false, 'btn btn-sm btn-primary btn-white btn-round' );
print_button( string_get_bug_view_url( $t_bug_id ), sprintf( lang_get( 'view_submitted_bug_link' ), $t_bug_id ) );
print_button( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ) );

if( $f_report_stay ) {
?>
Expand Down
5 changes: 2 additions & 3 deletions bug_update_page.php
Expand Up @@ -183,9 +183,8 @@
</h4>
<div class="widget-toolbar no-border">
<div class="widget-menu">
<?php print_link(
string_get_bug_view_url( $t_bug_id ), lang_get( 'back_to_bug_link' ),
false, 'btn btn-sm btn-primary btn-white btn-round' ); ?>
<?php print_small_button(
string_get_bug_view_url( $t_bug_id ), lang_get( 'back_to_bug_link' ) ); ?>
</div>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions bug_view_inc.php
Expand Up @@ -252,11 +252,11 @@
echo '<div class="btn-group pull-left">';

# Jump to Bugnotes
print_link( "#bugnotes", lang_get( 'jump_to_bugnotes' ), false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( "#bugnotes", lang_get( 'jump_to_bugnotes' ) );

# Send Bug Reminder
if( $t_show_reminder_link ) {
print_link( $t_bug_reminder_link, lang_get( 'bug_reminder' ), false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( $t_bug_reminder_link, lang_get( 'bug_reminder' ) );
}

if( !is_blank( $t_wiki_link ) ) {
Expand All @@ -270,7 +270,7 @@
if( is_numeric( $t_label ) ) {
print_bracket_link_prepared( $t_href );
} else {
print_link( $t_href, $t_label, false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( $t_href, $t_label );
}
}
} else {
Expand All @@ -282,11 +282,11 @@
# Links
if( !is_blank( $t_history_link ) ) {
# History
print_link( $t_history_link, lang_get( 'bug_history' ), false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( $t_history_link, lang_get( 'bug_history' ) );
}

# Print Bug
print_link( $t_print_link, lang_get( 'print' ), false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( $t_print_link, lang_get( 'print' ) );
echo '</div>';

# prev/next links
Expand All @@ -296,11 +296,11 @@
$t_index = array_search( $f_bug_id, $t_bugslist );
if( false !== $t_index ) {
if( isset( $t_bugslist[$t_index-1] ) ) {
print_link( 'view.php?id='.$t_bugslist[$t_index-1], '&lt;&lt;', false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( 'view.php?id='.$t_bugslist[$t_index-1], '&lt;&lt;' );
}

if( isset( $t_bugslist[$t_index+1] ) ) {
print_link( 'view.php?id='.$t_bugslist[$t_index+1], '&gt;&gt;', false, 'btn btn-primary btn-sm btn-white btn-round' );
print_small_button( 'view.php?id='.$t_bugslist[$t_index+1], '&gt;&gt;' );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bugnote_edit_page.php
Expand Up @@ -150,7 +150,7 @@
</div>
<div class="widget-toolbox padding-8 clearfix">
<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'update_information_button' ) ?>" />
<?php print_link( $t_redirect_url, lang_get( 'go_back' ), false, 'btn btn-sm btn-primary btn-white btn-round pull-right' ) ?>
<?php print_small_button( $t_redirect_url, lang_get( 'go_back' ) ) ?>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions bugnote_view_inc.php
Expand Up @@ -239,24 +239,24 @@
# show edit button if the user is allowed to edit this bugnote
if( $t_can_edit_bugnote ) {
echo '<div class="pull-left">';
print_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ) );
print_form_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ) );
echo '</div>';
}

# show delete button if the user is allowed to delete this bugnote
if( $t_can_delete_bugnote ) {
echo '<div class="pull-left">';
print_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ) );
print_form_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ) );
echo '</div>';
}

# show make public or make private button if the user is allowed to change the view state of this bugnote
if( $t_can_change_view_state ) {
echo '<div class="pull-left">';
if( VS_PRIVATE == $t_bugnote->view_state ) {
print_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ) );
print_form_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ) );
} else {
print_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ) );
print_form_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ) );
}
echo '</div>';
}
Expand Down
3 changes: 1 addition & 2 deletions core/access_api.php
Expand Up @@ -102,8 +102,7 @@ function access_denied() {
echo '<div class="alert alert-danger">';
echo '<div class="center bigger-130">' . error_string( ERROR_ACCESS_DENIED ) . '</p>';
echo '<p class="center">';
print_link( helper_mantis_url( 'main_page.php' ), lang_get( 'proceed' ), false,
'btn btn-primary btn-white btn-round');
print_button( helper_mantis_url( 'main_page.php' ), lang_get( 'proceed' ) );
echo '</p>';
echo '</div></div>';
layout_admin_page_end();
Expand Down
2 changes: 1 addition & 1 deletion core/html_api.php
Expand Up @@ -348,7 +348,7 @@ function html_operation_successful( $p_redirect_url, $p_message = '' ) {
}

echo '<p class="bold bigger-110">' . lang_get( 'operation_successful' ).'</p><br />';
print_link( $p_redirect_url, lang_get( 'proceed' ), false, 'btn btn-primary btn-white btn-round' );
print_button( $p_redirect_url, lang_get( 'proceed' ) );
echo '</div></div>';
}

Expand Down
37 changes: 35 additions & 2 deletions core/print_api.php
Expand Up @@ -1373,7 +1373,7 @@ function print_manage_project_sort_link( $p_page, $p_string, $p_field, $p_dir, $
* @see form_security_token()
* @return void
*/
function print_button( $p_action_page, $p_label, $p_args_to_post = null, $p_security_token = null, $p_class = '' ) {
function print_form_button( $p_action_page, $p_label, $p_args_to_post = null, $p_security_token = null, $p_class = '' ) {
$t_form_name = explode( '.php', $p_action_page, 2 );
# TODO: ensure all uses of print_button supply arguments via $p_args_to_post (POST)
# instead of via $p_action_page (GET). Then only add the CSRF form token if
Expand Down Expand Up @@ -1454,6 +1454,38 @@ function print_link( $p_link, $p_url_text, $p_new_window = false, $p_class = ''
}
}

/**
* print a HTML link with a button look
* @param string $p_link The page URL.
* @param string $p_url_text The displayed text for the link.
* @param boolean $p_new_window Whether to open in a new window.
* @param string $p_class The CSS class of the link.
* @return void
*/
function print_button( $p_link, $p_url_text, $p_class = '', $p_new_window = false ) {
if( is_blank( $p_link ) ) {
echo $p_url_text;
} else {
$t_link = htmlspecialchars( $p_link );
if( $p_new_window === true ) {
echo "<a class=\"btn btn-primary btn-white btn-round $p_class\" href=\"$t_link\" target=\"_blank\">$p_url_text</a>";
} else {
echo "<a class=\"btn btn-primary btn-white btn-round $p_class\" href=\"$t_link\">$p_url_text</a>";
}
}
}

/**
* shortcut for printing a HTML link with a small button look
* @param string $p_link The page URL.
* @param string $p_url_text The displayed text for the link.
* @param boolean $p_new_window Whether to open in a new window.
* @return void
*/
function print_small_button( $p_link, $p_url_text, $p_new_window = false ) {
print_button( $p_link, $p_url_text, 'btn-sm', $p_new_window );
}

/**
* print a HTML page link
* @param string $p_page_url The Page URL.
Expand Down Expand Up @@ -1879,7 +1911,8 @@ function print_bug_attachment_header( array $p_attachment ) {

if( $p_attachment['can_delete'] ) {
echo lang_get( 'word_separator' ) . '&#160;&#160;';
print_link( 'bug_file_delete.php?file_id=' . $p_attachment['id'] . form_security_param( 'bug_file_delete' ), lang_get( 'delete_link' ), false, 'btn btn-primary btn-xs btn-white btn-round' );
print_button( 'bug_file_delete.php?file_id=' . $p_attachment['id'] . form_security_param( 'bug_file_delete' ),
lang_get( 'delete_link' ), 'btn-xs' );
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/relationship_api.php
Expand Up @@ -848,8 +848,8 @@ function relationship_view_box( $p_bug_id ) {
if( ON == config_get( 'relationship_graph_enable' ) ) {
?>
<div class="btn-group pull-right">
<span class="small"><?php print_link( "bug_relationship_graph.php?bug_id=$p_bug_id&graph=relation", lang_get( 'relation_graph' ), false, 'btn btn-primary btn-sm btn-white btn-round' )?></span>
<span class="small"><?php print_link( "bug_relationship_graph.php?bug_id=$p_bug_id&graph=dependency", lang_get( 'dependency_graph' ), falase, 'btn btn-primary btn-sm btn-white btn-round' )?></span>
<span class="small"><?php print_small_button( "bug_relationship_graph.php?bug_id=$p_bug_id&graph=relation", lang_get( 'relation_graph' ) )?></span>
<span class="small"><?php print_small_button( "bug_relationship_graph.php?bug_id=$p_bug_id&graph=dependency", lang_get( 'dependency_graph' ) )?></span>
</div>
<?php
}
Expand Down
22 changes: 8 additions & 14 deletions main_page.php
Expand Up @@ -76,12 +76,12 @@
$t_hide_status = config_get( 'bug_resolved_status_threshold' );
echo '<span class="bigger-120">';
echo lang_get( 'open_and_assigned_to_me_label' ) . lang_get( 'word_separator' );
print_link( "view_all_set.php?type=1&handler_id=$t_current_user_id&hide_status=$t_hide_status", current_user_get_assigned_open_bug_count(), false, 'subtle' );
print_link( "view_all_set.php?type=1&handler_id=$t_current_user_id&hide_status=$t_hide_status", current_user_get_assigned_open_bug_count() );

echo '<br />';

echo lang_get( 'open_and_reported_to_me_label' ) . lang_get( 'word_separator' );
print_link( "view_all_set.php?type=1&reporter_id=$t_current_user_id&hide_status=$t_hide_status", current_user_get_reported_open_bug_count(), false, 'subtle' );
print_link( "view_all_set.php?type=1&reporter_id=$t_current_user_id&hide_status=$t_hide_status", current_user_get_reported_open_bug_count() );

echo '<br />';

Expand All @@ -97,11 +97,9 @@

# Admin can edit news for All Projects (site-wide)
if( ALL_PROJECTS != helper_get_current_project() || current_user_is_administrator() ) {
print_link( 'news_menu_page.php', lang_get( 'edit_news_link' ),
false, 'btn btn-primary btn-white btn-round pull-right');
print_button( 'news_menu_page.php', lang_get( 'edit_news_link' ), 'pull-right');
} else {
print_link( 'login_select_proj_page.php', lang_get( 'edit_news_link' ),
false, 'btn btn-primary btn-white btn-round pull-right');
print_button( 'login_select_proj_page.php', lang_get( 'edit_news_link' ), 'pull-right');
}
}
echo '</div>';
Expand Down Expand Up @@ -132,26 +130,22 @@
echo '<div class="space-10"></div>';
echo '<div class="btn-group">';

print_link( 'news_list_page.php', lang_get( 'archives' ),
false, 'btn btn-primary btn-white btn-round' );
print_button( 'news_list_page.php', lang_get( 'archives' ) );

$t_news_view_limit = config_get( 'news_view_limit' );
$f_offset_next = $f_offset + $t_news_view_limit;
$f_offset_prev = $f_offset - $t_news_view_limit;

if( $f_offset_prev >= 0 ) {
print_link( 'main_page.php?offset=' . $f_offset_prev, lang_get( 'newer_news_link' ),
false, 'btn btn-primary btn-white btn-round' );
print_button( 'main_page.php?offset=' . $f_offset_prev, lang_get( 'newer_news_link' ) );
}

if( $t_news_count == $t_news_view_limit ) {
print_link( 'main_page.php?offset=' . $f_offset_next, lang_get( 'older_news_link' ),
false, 'btn btn-primary btn-white btn-round' );
print_button( 'main_page.php?offset=' . $f_offset_next, lang_get( 'older_news_link' ) );
}

if( OFF != $t_rss_enabled ) {
print_link( $t_rss_link, lang_get( 'rss' ),
false, 'btn btn-primary btn-white btn-round' );
print_button( $t_rss_link, lang_get( 'rss' ) );
}
echo '</div>';
}
Expand Down
12 changes: 6 additions & 6 deletions manage_plugin_page.php
Expand Up @@ -195,15 +195,15 @@ function ( $p1, $p2 ) {
}
echo '<td class="center">';
if( $t_upgrade ) {
print_link(
print_button(
'manage_plugin_upgrade.php?name=' . $t_basename . form_security_param( 'manage_plugin_upgrade' ),
lang_get( 'plugin_upgrade' ), false, 'btn btn-xs btn-primary btn-white btn-round'
lang_get( 'plugin_upgrade' ), 'btn-xs'
);
}
if( !$t_protected ) {
print_link(
print_button(
'manage_plugin_uninstall.php?name=' . $t_basename . form_security_param( 'manage_plugin_uninstall' ),
lang_get( 'plugin_uninstall' ), false, 'btn btn-xs btn-primary btn-white btn-round'
lang_get( 'plugin_uninstall' ), 'btn-xs'
);
}
echo '</td></tr>';
Expand Down Expand Up @@ -307,9 +307,9 @@ function ( $p1, $p2 ) {
echo '<td class="center">',$t_depends,'</td>';
echo '<td class="center">';
if( $t_ready ) {
print_link(
print_small_button(
'manage_plugin_install.php?name=' . $t_basename . form_security_param( 'manage_plugin_install' ),
lang_get( 'plugin_install' ), false, 'btn btn-sm btn-primary btn-white btn-round'
lang_get( 'plugin_install' )
);
}
echo '</td></tr>';
Expand Down

0 comments on commit 5624902

Please sign in to comment.