1: <?php
2: /**
3: * CVS directory class that stores information about the files in a single
4: * directory in the repository.
5: *
6: * Copyright 2000-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Anil Madhavapeddy <anil@recoil.org>
12: * @author Michael Slusarz <slusarz@horde.org>
13: * @author Jan Schneider <jan@horde.org>
14: * @package Vcs
15: */
16: class Horde_Vcs_Directory_Cvs extends Horde_Vcs_Directory_Rcs
17: {
18: /**
19: * A list of Horde_Vcs_File_Base objects representing all files inside this
20: * and any Attic/ sub directory.
21: *
22: * @var array
23: */
24: protected $_mergedFiles = array();
25:
26: /**
27: * Constructor.
28: *
29: * @param Horde_Vcs_Base $rep A repository object.
30: * @param string $dn Path to the directory.
31: * @param array $opts Any additional options:
32: * - 'showattic': (boolean) Parse any Attic/
33: * sub-directory contents too.
34: *
35: * @throws Horde_Vcs_Exception
36: */
37: public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array())
38: {
39: parent::__construct($rep, $dn, $opts);
40:
41: /* If we want to merge the attic, add it in here. */
42: if (!empty($opts['showattic'])) {
43: try {
44: $atticDir = new Horde_Vcs_Directory_Cvs($rep, $dn . '/Attic',
45: $opts, $this);
46: $this->_mergedFiles = array_merge($this->_files,
47: $atticDir->getFiles());
48: } catch (Horde_Vcs_Exception $e) {
49: }
50: }
51: }
52:
53: /**
54: * Returns a list of all files inside this directory.
55: *
56: * @return array A list of Horde_Vcs_File_Base objects.
57: */
58: public function getFiles($showdeleted = false)
59: {
60: return ($showdeleted && $this->_mergedFiles)
61: ? $this->_mergedFiles
62: : $this->_files;
63: }
64:
65: /**
66: * Sorts the the directory contents.
67: *
68: * @param integer $how A Horde_Vcs::SORT_* constant where * can be:
69: * NONE, NAME, AGE, REV for sorting by name, age or
70: * revision.
71: * @param integer $dir A Horde_Vcs::SORT_* constant where * can be:
72: * ASCENDING, DESCENDING for the order of the sort.
73: */
74: public function applySort($how = Horde_Vcs::SORT_NONE,
75: $dir = Horde_Vcs::SORT_ASCENDING)
76: {
77: parent::applySort($how, $dir);
78:
79: if (isset($this->_mergedFiles)) {
80: $this->_doFileSort($this->_mergedFiles, $how);
81: if ($dir == Horde_Vcs::SORT_DESCENDING) {
82: $this->_mergedFiles = array_reverse($this->_mergedFiles);
83: }
84: }
85: }
86:
87: /**
88: * Returns a list of all branches in this directory.
89: *
90: * @return array A branch list.
91: */
92: public function getBranches()
93: {
94: return array('HEAD');
95: }
96: }
97: