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 private $repositories = array();
45 * Root path to the repository
51 * Whether or not the path is a container
56 // ###################################################################
58 * Constructor: prepare for repository
60 * @param string Path to repository or container
61 * @param bool Whether the path is a container
63 function __construct($path, $iscontainer)
67 $this->path
= BSFunctions
::FetchSourcePath($path);
68 $this->container
= (bool
)$iscontainer;
72 if ($dir = @opendir($this->path
))
74 while (($file = readdir($dir)) !== false
)
76 if (is_dir($this->path
. $file) AND $file{0} != '.' AND is_dir($this->path
. $file . '/' . 'db'))
78 $this->repositories
[] = $file;
86 if (is_dir($this->path
. 'db'))
88 $this->repositories
[] = $this->path
;
92 sort($this->repositories
);
94 if (sizeof($this->repositories
) < 1)
96 $viewsvn->trigger
->error(_('There are no valid repositories'));
100 // ###################################################################
102 * Returns a list of repositories
104 * @return array List of repositories
106 public function fetchList()
108 return $this->repositories
;
111 // ###################################################################
113 * Returns a path to a repository
115 * @param string Repository name
117 * @return string Full path to the repository
119 public function fetchPath($repository = '')
123 if (!in_array($repository, $this->repositories
))
125 $viewsvn->trigger
->error(_('Invalid repository name specified'));
128 if ($this->container
)
130 return 'file://' . $this->path
. $repository;
134 return 'file://' . $this->path
;
138 // ###################################################################
140 * Verifies a path inside a repository
142 * @param string Repository name
145 * @return bool Validity
147 public function verify($repos, $path)
151 if ($repospath = $this->fetchPath($repos))
162 /*=====================================================================*\
163 || ###################################################################
166 || ###################################################################
167 \*=====================================================================*/