php8
[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      
17     /** when used in a string context, just return the filename.
18     * This simplifies explicit object vs. string interpretation
19     * throughout the SCM layer */
20     function __toString() {
21         return $this->name;
22     }
23
24     function changesToHtml()
25     {
26         switch($this->status) {
27             case 'D': return 'Deleted';
28             case 'M': return 'Changed lines : ' . ( $this->added ? '+' .$this->added  : '') . ' ' . ( $this->removed ? '-' .$this->removed  : '');
29             case 'A': return 'Added : ' . ( $this->added ? '+' .$this->added  : '') ;
30             default : '??' . $this->status;
31        }
32     }
33     
34     function nametoHtml()
35     {
36         return 
37             ($this->status == 'D' ? '<del>' : '') .
38             htmlspecialchars($this->name) . 
39             ($this->status == 'D' ? '</del>' : '');
40     }
41 }