]>
src.bluestatic.org Git - viewsvn.git/blob - includes/controller.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 \*=====================================================================*/
25 * This class represents one node in SVN. For each node that you need
26 * to display information about, create a new instance of this class.
27 * Generally, however, this one instance should be able to handle
28 * the needs of the entire class.
30 * @author Iris Studios, Inc.
31 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
53 * Xquery method library
67 * Full, universal path of the node
74 * Repository of the path
81 * The full path to the repository
88 * Relative path in the repository
95 * The current revision number
102 * The current revision as a string argument
108 // ###################################################################
114 function Controller($nodepath)
119 $this->fullpath
= $nodepath;
121 $temp = preg_split('#/#', $this->fullpath
, -1, PREG_SPLIT_NO_EMPTY
);
123 $this->repos
= $temp[0];
126 $this->path
= '/' . implode('/', $temp);
129 $this->registry
=& $viewsvn;
131 $this->repospath
= $this->registry
->repos
->fetch_path($this->repos
);
133 $this->revnum
= Paths
::fetch_rev_num();
134 $this->revstr
= Paths
::fetch_rev_str();
136 require_once('./includes/shellcmd.php');
137 $this->xquery
= new Shell($this);
139 require_once('./includes/svnlib.php');
140 $this->library
= new SVNLib($this);
142 require_once('./includes/cachev.php');
143 $this->cachev
= new cacheV($this);
146 // ###################################################################
148 * Produces a link href that allows for a completely different path
149 * than the one in the controller. This is used for navigating upstream.
153 * @param string Base path (e.g. browse.php)
154 * @param string New relative path
156 * @return string Constructed path
158 function href_struct($base, $path)
160 $url = Paths
::fetch_arguments($base);
161 $path = Paths
::sanitize($path);
163 return $this->registry
->path
. '/' . $url[0] . '/' . $this->repos
. ($path{0} != '/' ? '/' : '') . $path . ($url[1] ? '?' . $url[1] : '');
166 // ###################################################################
168 * Compounds a path by adding another level. This is used for navigating
173 * @param string Base path (e.g. browse.php)
174 * @param string Attach path (or none for current)
175 * @param bool Attach a given revision string, null for none
177 * @return string Constructed path
179 function href_compound($base, $attach = null, $revstr = null)
181 $url = Paths
::fetch_arguments($base . ($revstr === null ? ((strpos($base, '?') !== false) ? '&' . $this->revstr
: $this->revstr
) : $revstr));
182 $attach = Paths
::sanitize($attach);
184 if ($attach === null)
190 $path = $this->path
. (($attach[0] != '/' AND $this->path
[ strlen($this->path
) - 1 ] != '/') ? '/' : '') . $attach;
193 return $this->href_struct($base . ($url[1] ? '?' . $url[1] : ''), $path);
196 // ###################################################################
198 * Constructs a repository browser link
202 * @param string Base path
203 * @param string Browser path, separated using '/'
205 * @return string Link path
207 function out($base, $addpath = null)
211 if ($addpath === null)
213 $addpath = $this->path
;
216 $url = Paths
::fetch_arguments($base);
217 $addpath = Paths
::sanitize($addpath);
220 if ($this->registry
->paths
->type
== 1)
222 return $url[0] . '?path=' . $addpath . ($url[1] ? '&' . $url[1] : '');
224 // advanced path system
225 else if ($this->registry
->paths
->type
== 2)
227 return $url[0] . '/' . $this->repos
. ($addpath{0} != '/' ? '/' : '') . $addpath . ($url[1] ? '?' . $url[1] : '');
231 // ###################################################################
233 * Create path breadcrumb
237 * @return string Breadcrumb HTML
239 function construct_breadcrumb()
243 $temp = preg_split('#/#', $this->fullpath
, -1, PREG_SPLIT_NO_EMPTY
);
244 $count = sizeof($temp) - 1;
246 foreach ($temp AS $val => $item)
249 $itembit .= (($count != $val OR $this->cachev
->isdir($itembit)) ? '/' : '');
250 $html .= '<a href="' . $this->href_struct('browse.php' . $this->revstr
, ($val == 0 ? '' : $itembit)) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
257 /*=====================================================================*\
258 || ###################################################################
261 || ###################################################################
262 \*=====================================================================*/