Overview

Packages

  • None
  • Vcs

Classes

  • Horde_Vcs
  • Horde_Vcs_Base
  • Horde_Vcs_Cvs
  • Horde_Vcs_Directory_Base
  • Horde_Vcs_Directory_Cvs
  • Horde_Vcs_Directory_Git
  • Horde_Vcs_Directory_Rcs
  • Horde_Vcs_Directory_Svn
  • Horde_Vcs_File_Base
  • Horde_Vcs_File_Cvs
  • Horde_Vcs_File_Git
  • Horde_Vcs_File_Rcs
  • Horde_Vcs_File_Svn
  • Horde_Vcs_Git
  • Horde_Vcs_Log_Base
  • Horde_Vcs_Log_Cvs
  • Horde_Vcs_Log_Git
  • Horde_Vcs_Log_Rcs
  • Horde_Vcs_Log_Svn
  • Horde_Vcs_Patchset
  • Horde_Vcs_Patchset_Base
  • Horde_Vcs_Patchset_Cvs
  • Horde_Vcs_Patchset_Git
  • Horde_Vcs_Patchset_Svn
  • Horde_Vcs_QuickLog_Base
  • Horde_Vcs_QuickLog_Cvs
  • Horde_Vcs_QuickLog_Git
  • Horde_Vcs_QuickLog_Rcs
  • Horde_Vcs_QuickLog_Svn
  • Horde_Vcs_Rcs
  • Horde_Vcs_Svn
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Base log class.
  4:  *
  5:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (LGPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  9:  *
 10:  * @package Vcs
 11:  */
 12: abstract class Horde_Vcs_Log_Base
 13: {
 14:     protected $_rep;
 15:     protected $_file;
 16:     protected $_files = array();
 17:     protected $_rev;
 18:     protected $_author;
 19:     protected $_tags = array();
 20:     protected $_date;
 21:     protected $_log;
 22:     protected $_state;
 23:     protected $_lines = '';
 24:     protected $_branch = array();
 25:     protected $_branches = array();
 26:     protected $_symbolicBranches = array();
 27: 
 28:     /**
 29:      * @var boolean
 30:      */
 31:     protected $_initialized;
 32: 
 33:     /**
 34:      * Constructor.
 35:      */
 36:     public function __construct($rev)
 37:     {
 38:         $this->_rev = $rev;
 39:     }
 40: 
 41:     abstract protected function _init();
 42: 
 43:     protected function _ensureInitialized()
 44:     {
 45:         if (!$this->_initialized) {
 46:             $this->_init();
 47:             $this->_initialized = true;
 48:         }
 49:     }
 50: 
 51:     /**
 52:      * When serializing, don't return the repository object
 53:      */
 54:     public function __sleep()
 55:     {
 56:         return array_diff(array_keys(get_object_vars($this)), array('_file', '_rep'));
 57:     }
 58: 
 59:     /**
 60:      * TODO
 61:      */
 62:     public function setRepository($rep)
 63:     {
 64:         $this->_rep = $rep;
 65:     }
 66: 
 67:     public function setFile(Horde_Vcs_File_Base $file)
 68:     {
 69:         $this->_file = $file;
 70:     }
 71: 
 72:     /**
 73:      * TODO
 74:      */
 75:     public function getRevision()
 76:     {
 77:         $this->_ensureInitialized();
 78:         return $this->_rev;
 79:     }
 80: 
 81:     /**
 82:      * TODO
 83:      */
 84:     public function getDate()
 85:     {
 86:         $this->_ensureInitialized();
 87:         return $this->_date;
 88:     }
 89: 
 90:     /**
 91:      * TODO
 92:      */
 93:     public function getAuthor()
 94:     {
 95:         $this->_ensureInitialized();
 96:         return $this->_author;
 97:     }
 98: 
 99:     /**
100:      * TODO
101:      */
102:     public function getMessage()
103:     {
104:         $this->_ensureInitialized();
105:         return $this->_log;
106:     }
107: 
108:     /**
109:      * Returns all branches that contain this log.
110:      *
111:      * @return array
112:      */
113:     public function getBranch()
114:     {
115:         $this->_ensureInitialized();
116:         return $this->_branch;
117:     }
118: 
119:     /**
120:      * TODO
121:      */
122:     public function getChanges()
123:     {
124:         $this->_ensureInitialized();
125:         return $this->_lines;
126:     }
127: 
128:     /**
129:      * TODO
130:      */
131:     public function getTags()
132:     {
133:         $this->_ensureInitialized();
134:         return $this->_tags;
135:     }
136: 
137:     /**
138:      * Given a branch revision number, this function remaps it
139:      * accordingly, and performs a lookup on the file object to
140:      * return the symbolic name(s) of that branch in the tree.
141:      *
142:      * @return array  Hash of symbolic names => branch numbers.
143:      */
144:     public function getSymbolicBranches()
145:     {
146:         $this->_ensureInitialized();
147:         return $this->_symbolicBranches;
148:     }
149: 
150:     protected function _setSymbolicBranches()
151:     {
152:         $this->_symbolicBranches = array();
153:         $branches = $this->_file->getBranches();
154: 
155:         foreach ($this->_branches as $branch) {
156:             if (($key = array_search($branch, $branches)) !== false) {
157:                 $this->_symbolicBranches[$key] = $branch;
158:             }
159:         }
160:     }
161: 
162:     /**
163:      * TODO
164:      */
165:     public function getFiles($file = null)
166:     {
167:         $this->_ensureInitialized();
168:         return is_null($file)
169:             ? $this->_files
170:             : (isset($this->_files[$file]) ? $this->_files[$file] : array());
171:     }
172: 
173:     public function getAddedLines()
174:     {
175:         $this->_ensureInitialized();
176:         $lines = 0;
177:         foreach ($this->_files as $file) {
178:             if (isset($file['added'])) {
179:                 $lines += $file['added'];
180:             }
181:         }
182:         return $lines;
183:     }
184: 
185:     public function getDeletedLines()
186:     {
187:         $this->_ensureInitialized();
188:         $lines = 0;
189:         foreach ($this->_files as $file) {
190:             if (isset($file['deleted'])) {
191:                 $lines += $file['deleted'];
192:             }
193:         }
194:         return $lines;
195:     }
196: 
197:     public function toHash()
198:     {
199:         return array(
200:             'revision' => $this->getRevision(),
201:             'author'   => $this->getAuthor(),
202:             'branch'   => $this->getBranch(),
203:             'date'     => $this->getDate(),
204:             'log'      => $this->getMessage(),
205:             'tag'      => $this->getTags(),
206:             'added'    => $this->getAddedLines(),
207:             'deleted'  => $this->getDeletedLines(),
208:         );
209:     }
210: }
211: 
API documentation generated by ApiGen