1: <?php
2: /* Need to define this outside of class since constants in class can not be
3: * assigned from a function return. */
4: define('VC_WINDOWS', !strncasecmp(PHP_OS, 'WIN', 3));
5:
6: /**
7: * Version Control generalized library.
8: *
9: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
10: *
11: * See the enclosed file COPYING for license information (LGPL). If you
12: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
13: *
14: * @package Vcs
15: */
16: class Horde_Vcs
17: {
18: /* Sorting options */
19: const SORT_NONE = 0; // don't sort
20: const SORT_AGE = 1; // sort by age
21: const SORT_NAME = 2; // sort by filename
22: const SORT_REV = 3; // sort by revision number
23: const SORT_AUTHOR = 4; // sort by author name
24:
25: const SORT_ASCENDING = 0; // ascending order
26: const SORT_DESCENDING = 1; // descending order
27:
28: /**
29: * Attempts to return a concrete Horde_Vcs instance based on $driver.
30: *
31: * @param mixed $driver The type of concrete Horde_Vcs subclass to return.
32: * The code is dynamically included.
33: * @param array $params A hash containing any additional configuration
34: * or parameters a subclass might need.
35: *
36: * @return Horde_Vcs The newly created concrete instance.
37: * @throws Horde_Vcs_Exception
38: */
39: static public function factory($driver, $params = array())
40: {
41: $class = 'Horde_Vcs_' . $driver;
42: if (class_exists($class)) {
43: return new $class($params);
44: }
45:
46: throw new Horde_Vcs_Exception($class . ' not found.');
47: }
48: }
49: