]>
src.bluestatic.org Git - viewsvn.git/blob - includes/repository.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * Class that manages repositories and can produce lists of
30 * Repository class that can list repositories and prepare
39 * Array of valid repositories
43 var $repositories = array();
46 * Root path to the repository
53 * Whether or not the path is a container
59 // ###################################################################
61 * Constructor: prepare for repository
63 * @param string Path to repository or container
64 * @param bool Whether the path is a container
66 function Repository($path, $iscontainer)
70 $this->path
= $viewsvn->fetch_sourcepath($path);
71 $this->container
= (bool)$iscontainer;
75 if ($dir = @opendir($this->path
))
77 while (($file = readdir($dir)) !== false)
79 if (is_dir($this->path
. $file) AND $file{0} != '.' AND is_dir($this->path
. $file . '/' . 'db'))
81 $this->repositories
[] = $file;
89 if (is_dir($this->path
. 'db'))
91 $this->repositories
[] = $this->path
;
95 sort($this->repositories
);
97 if (sizeof($this->repositories
) < 1)
99 $viewsvn->trigger
->error($viewsvn->lang
->string('There are no valid repositories'));
103 // ###################################################################
105 * Returns a list of repositories
109 * @return array List of repositories
111 function fetch_list()
113 return $this->repositories
;
116 // ###################################################################
118 * Returns a path to a repository
122 * @param string Repository name
124 * @return string Full path to the repository
126 function fetch_path($repository = '')
130 if (!in_array($repository, $this->fetch_list()))
132 $viewsvn->trigger
->error($viewsvn->lang
->string('Invalid repository name specified'));
135 if ($this->container
)
137 return 'file://' . $this->path
. $repository;
141 return 'file://' . $this->path
;
145 // ###################################################################
147 * Verifies a path inside a repository
151 * @param string Repository name
154 * @return bool Validity
156 function verify($repos, $path)
160 if ($repospath = $this->fetch_path($repos))
171 /*=====================================================================*\
172 || ###################################################################
175 || ###################################################################
176 \*=====================================================================*/