]>
src.bluestatic.org Git - viewsvn.git/blob - repository.php
8c8b6e85d9ac364bc25cd7ff5dd02ebb260f4eb4
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 * Whether or not the path is a container
50 // ###################################################################
52 * Constructor: prepare for repository
54 * @param mixed Path to repository or container
55 * @param bool Whether the path is a container
56 * @param array Array of paths to include (only applicable with containers)
58 function __construct($path, $iscontainer, $include)
62 if (is_array($include) AND sizeof($include) > 0 AND $iscontainer)
64 $this->container
= (sizeof($include) > 1);
65 foreach ($include AS $repos)
67 $this->repositories
[$repos] = BSFunctions
::FetchSourcePath(BSFunctions
::FetchSourcePath($path) . $repos);
72 $path = BSFunctions
::FetchSourcePath($path);
73 $this->container
= (bool)$iscontainer;
76 if ($dir = @opendir($path))
78 while (($file = readdir($dir)) !== false)
80 if (is_dir($path . $file) AND $file{0} != '.' AND is_dir($path . $file . '/' . 'db'))
82 $this->repositories
[$file] = $path . $file;
90 if (is_dir($path . 'db'))
92 $this->repositories
[basename($path)] = $path;
97 ksort($this->repositories
);
99 if (sizeof($this->repositories
) < 1)
101 $viewsvn->trigger
->error(_('There are no valid repositories'));
105 // ###################################################################
107 * Returns a list of repositories
109 * @return array List of repositories
111 public function fetchList()
113 return array_keys($this->repositories
);
116 // ###################################################################
118 * Returns a path to a repository
120 * @param string Repository name
122 * @return string Full path to the repository
124 public function fetchPath($repository = '')
128 if (!isset($this->repositories
[$repository]))
130 $viewsvn->trigger
->error(_('Invalid repository name specified'));
133 return 'file://' . $this->repositories
[$repository];
136 // ###################################################################
138 * Verifies a path inside a repository
140 * @param string Repository name
143 * @return bool Validity
145 public function verify($repos, $path)
149 if ($repospath = $this->fetchPath($repos))
160 /*=====================================================================*\
161 || ###################################################################
164 || ###################################################################
165 \*=====================================================================*/