/
TimelineEvent.class.php
96 lines (86 loc) · 2.71 KB
/
TimelineEvent.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* Mantis Column Handling
* @copyright Copyright 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
* @package MantisBT
*/
/**
* Base class for timeline events.
*
* @package MantisBT
* @subpackage classes
*/
class TimelineEvent {
protected $timestamp;
protected $user_id;
/**
* @param integer $p_timestamp Timestamp representing the time the event occurred.
* @param integer $p_user_id An user identifier.
*/
public function __construct( $p_timestamp, $p_user_id ) {
$this->timestamp = $p_timestamp;
$this->user_id = $p_user_id;
}
/**
* Whether to skip this timeline event.
* This normally implements access checks for the event.
* @return boolean
*/
public function skip() {
return false;
}
/**
* Returns html string to display
* @return string
*/
public function html() {
return '';
}
/**
* Formats a timestamp in the timeline for display.
* @param integer $p_timestamp Integer representing timestamp to format.
* @return string
*/
public function format_timestamp( $p_timestamp ) {
$t_normal_date_format = config_get( 'normal_date_format' );
return date( $t_normal_date_format, $p_timestamp );
}
/**
* Returns html string representing the beginning block of a timeline entry
* @param string $p_action_icon Icon name for Font Awesome
* @return string
*/
public function html_start( $p_action_icon = 'fa-check' ) {
$t_avatar = Avatar::get( $this->user_id, 40 );
$t_html = '<div class="profile-activity clearfix">';
if( !empty( $t_avatar ) ) {
$t_html .= prepare_avatar( $t_avatar, 'profile-activity', 40 );
} else {
$t_html .= '<i class="pull-left thumbicon fa ' . $p_action_icon . ' btn-primary no-hover"></i>';
}
return $t_html;
}
/**
* Returns html string representing the ending block of a timeline entry
* @return string
*/
public function html_end() {
$t_html = '<div class="time"><i class="ace-icon fa fa-clock-o bigger-110"></i> ' . $this->format_timestamp( $this->timestamp ) . '</div>';
$t_html .= '</div>';
return $t_html;
}
}