Checking in inital code base
[viewsvn.git] / includes / repository.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # ViewSVN [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 /**
14 * Class that manages repositories and can produce lists of
15 * repositories
16 *
17 * @pacakge ViewSVN
18 */
19
20 /**
21 * Repository class that can list repositories and prepare
22 * them for use
23 *
24 * @package DeskPRO
25 * @version $Id$
26 */
27 class Repository
28 {
29 /**
30 * Constructor: prepare for repository
31 *
32 * @param string Path to repository or container
33 * @param bool Whether the path is a container
34 */
35 function Repository($path, $iscontainer)
36 {
37 global $viewsvn;
38
39 $repos = array();
40
41 $path = $viewsvn->fetch_sourcepath($path);
42
43 if ($iscontainer)
44 {
45 if ($dir = @opendir($path))
46 {
47 while (($file = readdir($dir)) !== false)
48 {
49 if (is_dir($path . $file) AND $file{0} != '.' AND is_dir($path . $file . '/' . 'db'))
50 {
51 $repos[] = $file;
52 }
53 }
54 closedir($dir);
55 }
56 }
57 else
58 {
59 if (is_dir($path . 'db'))
60 {
61 $repos[] = $path;
62 }
63 }
64
65 if (count($repos) < 1)
66 {
67 $viewsvn->trigger->error('no valid repositories');
68 }
69 }
70 }
71
72 /*=====================================================================*\
73 || ###################################################################
74 || # $HeadURL$
75 || # $Id$
76 || ###################################################################
77 \*=====================================================================*/
78 ?>