php8 fixes
[web.mtrack] / MTrack / SCMFileEvent.php
1 <?php
2
3 class MTrackSCMFileEvent 
4 {
5   /** Name of affected file */
6     public $name;
7     /** Change status indicator */
8     public $status;
9     
10     // optional data 
11     public $oldperm;
12     public $newperm;
13     public $oldver;
14     public $added;
15     public $removed;
16     var $newver;
17      
18     /** when used in a string context, just return the filename.
19     * This simplifies explicit object vs. string interpretation
20     * throughout the SCM layer */
21     function __toString() {
22         return $this->name;
23     }
24
25     function changesToHtml()
26     {
27         switch($this->status) {
28             case 'D': return 'Deleted';
29             case 'M': return 'Changed lines : ' . ( $this->added ? '+' .$this->added  : '') . ' ' . ( $this->removed ? '-' .$this->removed  : '');
30             case 'A': return 'Added : ' . ( $this->added ? '+' .$this->added  : '') ;
31             default : '??' . $this->status;
32        }
33     }
34     
35     function nametoHtml()
36     {
37         return 
38             ($this->status == 'D' ? '<del>' : '') .
39             htmlspecialchars($this->name) . 
40             ($this->status == 'D' ? '</del>' : '');
41     }
42 }