Skip to content
Permalink
Browse files

Generalize usage of timeline_inc.php

Generalize timeline_inc.php so it can be used within other pages than
my_view page.
  • Loading branch information...
cproensa authored and vboctor committed Mar 25, 2017
1 parent dbe7be7 commit e2d1de8a9f2fc5a7190efa252b2aa6df7e5c6310
Showing with 38 additions and 8 deletions.
  1. +31 −7 core/timeline_inc.php
  2. +7 −1 my_view_page.php
@@ -19,17 +19,38 @@
define( 'MAX_EVENTS', 50 );
# Variables that are defined in parent script:
#
# $g_timeline_filter Filter array to be used to get timeline event
# If undefined, it's initialized as null.
# $g_timeline_user User id to limit timeline scope.
# If undefined, it's initialized as null.
#
if( !isset( $g_timeline_filter ) ) {
$g_timeline_filter = null;
}
if( !isset( $g_timeline_user ) ) {
$g_timeline_user = null;
}
$f_days = gpc_get_int( 'days', 0 );
$f_all = gpc_get_int( 'all', 0 );
$t_max_events = $f_all ? 0 : MAX_EVENTS + 1;
$t_end_time = time() - ( $f_days * SECONDS_PER_DAY );
$t_start_time = $t_end_time - ( 7 * SECONDS_PER_DAY );
$t_events = timeline_events( $t_start_time, $t_end_time, $t_max_events );
$t_events = timeline_events( $t_start_time, $t_end_time, $t_max_events, $g_timeline_filter, $g_timeline_user );
$t_collapse_block = is_collapsed( 'timeline' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
$t_url_page = $_SERVER["PHP_SELF"];
$t_url_params = $_GET;
if( isset( $t_url_params['all'] ) ) {
unset( $t_url_params['all'] );
}
?>

<div id="timeline" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>">
@@ -57,14 +78,16 @@
echo '&#160;&#160;';
echo '<div class="btn-group">';
echo ' <a class="btn btn-primary btn-xs btn-white btn-round" href="my_view_page.php?days=' .
( $f_days + 7 ) . '">' . lang_get( 'prev' ) . '</a>';
$t_url_params['days'] = $f_days + 7;
$t_href = $t_url_page . '?' . http_build_query( $t_url_params );
echo ' <a class="btn btn-primary btn-xs btn-white btn-round" href="' . $t_href . '">' . lang_get( 'prev' ) . '</a>';
$t_next_days = ( $f_days - 7 ) > 0 ? $f_days - 7 : 0;
if( $t_next_days != $f_days ) {
echo ' <a class="btn btn-primary btn-xs btn-white btn-round" href="my_view_page.php?days=' .
$t_next_days . '">' . lang_get( 'next' ) . '</a>';
$t_url_params['days'] = $t_next_days;
$t_href = $t_url_page . '?' . http_build_query( $t_url_params );
echo ' <a class="btn btn-primary btn-xs btn-white btn-round" href="' . $t_href . '">' . lang_get( 'next' ) . '</a>';
}
echo '</div>';
?>
@@ -82,8 +105,9 @@
timeline_print_events( $t_events );
echo '<div class="widget-toolbox">';
echo '<div class="btn-toolbar">';
echo '<a class="btn btn-primary btn-sm btn-white btn-round" href="my_view_page.php?days='
. $f_days . '&amp;all=1">' . lang_get( 'timeline_more' ) . '</a>';
$t_url_params['all'] = 1;
$t_href = $t_url_page . '?' . helper_url_query_string( $t_url_params );
echo '<a class="btn btn-primary btn-sm btn-white btn-round" href="' . $t_href . '">' . lang_get( 'timeline_more' ) . '</a>';
echo '</div>';
echo '</div>';
} else {
@@ -151,7 +151,13 @@

<?php if( $t_timeline_view_threshold_access ) { ?>
<div class="col-md-5 col-xs-12">
<?php include( $g_core_path . 'timeline_inc.php' ); ?>
<?php
# Build a simple filter that gets all bugs for current project
$g_timeline_filter = array();
$g_timeline_filter[FILTER_PROPERTY_HIDE_STATUS] = array( META_FILTER_NONE );
$g_timeline_filter = filter_ensure_valid_filter( $g_timeline_filter );
include( $g_core_path . 'timeline_inc.php' );
?>
<div class="space-10"></div>
</div>
<?php }

0 comments on commit e2d1de8

Please sign in to comment.
You can’t perform that action at this time.