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
60 * Constructor: prepare for repository
62 * @param string Path to repository or container
63 * @param bool Whether the path is a container
65 function Repository($path, $iscontainer)
69 $this->path
= $viewsvn->fetch_sourcepath($path);
70 $this->container
= (bool
)$iscontainer;
74 if ($dir = @opendir($this->path
))
76 while (($file = readdir($dir)) !== false
)
78 if (is_dir($this->path
. $file) AND $file{0} != '.' AND is_dir($this->path
. $file . '/' . 'db'))
80 $this->repositories
[] = $file;
88 if (is_dir($this->path
. 'db'))
90 $this->repositories
[] = $this->path
;
94 sort($this->repositories
);
96 if (count($this->repositories
) < 1)
98 $viewsvn->trigger
->error($viewsvn->lang
->string('There are no valid repositories'));
103 * Returns a list of repositories
107 * @return array List of repositories
109 function fetch_list()
111 return $this->repositories
;
115 * Returns a path to a repository
119 * @param string Repository name
121 * @return string Full path to the repository
123 function fetch_path($repository = '')
127 if (!in_array($repository, $this->fetch_list()))
129 $viewsvn->trigger
->error($viewsvn->lang
->string('Invalid repository name specified'));
132 if ($this->container
)
134 return 'file://' . $this->path
. $repository . '/';
138 return 'file://' . $this->path
. '/';
143 * Verifies a path inside a repository
147 * @param string Repository name
150 * @return bool Validity
152 function verify($repos, $path)
156 if ($repospath = $this->fetch_path($repos))
167 /*=====================================================================*\
168 || ###################################################################
171 || ###################################################################
172 \*=====================================================================*/