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