]>
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
42 var $repositories = array();
45 * Root path to the repository
51 * Whether or not the path is a container
57 * Constructor: prepare for repository
59 * @param string Path to repository or container
60 * @param bool Whether the path is a container
62 function Repository($path, $iscontainer)
66 $this->path
= $viewsvn->fetch_sourcepath($path);
67 $this->container
= (bool)$iscontainer;
71 if ($dir = @opendir($this->path
))
73 while (($file = readdir($dir)) !== false)
75 if (is_dir($this->path
. $file) AND $file{0} != '.' AND is_dir($this->path
. $file . '/' . 'db'))
77 $this->repositories
[] = $file;
85 if (is_dir($this->path
. 'db'))
87 $this->repositories
[] = $this->path
;
91 sort($this->repositories
);
93 if (count($this->repositories
) < 1)
95 $viewsvn->trigger
->error('no valid repositories');
100 * Returns a list of repositories
104 * @return array List of repositories
106 function fetch_list()
108 return $this->repositories
;
112 * Returns a path to a repository
116 * @param string Repository name
118 * @return string Full path to the repository
120 function fetch_path($repository = '')
124 if (!in_array($repository, $this->fetch_list()))
126 $viewsvn->trigger
->error('invalid repository name');
129 if ($this->container
)
131 return 'file://' . $this->path
. $repository . '/';
135 return 'file://' . $this->path
. '/';
140 * Verifies a path inside a repository
144 * @param string Repository name
147 * @return bool Validity
149 function verify($repos, $path)
153 if ($repospath = $this->fetch_path($repos))
164 /*=====================================================================*\
165 || ###################################################################
168 || ###################################################################
169 \*=====================================================================*/