]>
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
109 * The revision number in context for this node. For instance, r40 may be passed, but the file only has revision 38 (and that's what this would be)
115 // ###################################################################
119 * @param string The path of the node
121 function Controller($nodepath)
126 $this->fullpath
= $nodepath;
128 $temp = preg_split('#/#', $this->fullpath
, -1, PREG_SPLIT_NO_EMPTY
);
130 $this->repos
= $temp[0];
133 $this->path
= '/' . implode('/', $temp);
136 $this->registry
=& $viewsvn;
138 $this->repospath
= $this->registry
->repos
->fetch_path($this->repos
);
140 $this->revnum
= Paths
::fetch_rev_num();
141 $this->revstr
= Paths
::fetch_rev_str();
143 require_once('./includes/shellcmd.php');
144 $this->xquery
= new Shell($this);
146 require_once('./includes/svnlib.php');
147 $this->library
= new SVNLib($this);
149 require_once('./includes/cachev.php');
150 $this->cachev
= new cacheV($this);
152 $this->revctx
= $this->cachev
->fetch_revision_context($this->revnum
);
153 $this->revctx
= $this->revctx
['revision'];
156 // ###################################################################
158 * Produces a link href that allows for a completely different path
159 * than the one in the controller. This is used for navigating upstream.
163 * @param string Base path (e.g. browse.php)
164 * @param string New relative path
166 * @return string Constructed path
168 function href_struct($base, $path)
170 $url = Paths
::fetch_arguments($base);
171 $path = Paths
::sanitize($path);
173 return $this->registry
->path
. '/' . $url[0] . '/' . $this->repos
. ($path{0} != '/' ? '/' : '') . $path . ($url[1] ? '?' . $url[1] : '');
176 // ###################################################################
178 * Compounds a path by adding another level. This is used for navigating
183 * @param string Base path (e.g. browse.php)
184 * @param string Attach path (or none for current)
185 * @param bool Attach a given revision string, null for none
187 * @return string Constructed path
189 function href_compound($base, $attach = null, $revstr = null)
191 $url = Paths
::fetch_arguments($base . ($revstr === null ? ((strpos($base, '?') !== false) ? '&' . $this->revstr
: $this->revstr
) : $revstr));
193 if ($attach === null)
199 $attach = Paths
::sanitize($attach);
200 $path = $this->path
. (($attach[0] != '/' AND $this->path
[ strlen($this->path
) - 1 ] != '/') ? '/' : '') . $attach;
203 return $this->href_struct($base . ($url[1] ? '?' . $url[1] : ''), $path);
206 // ###################################################################
208 * Create path breadcrumb
212 * @return string Breadcrumb HTML
214 function construct_breadcrumb()
218 $temp = preg_split('#/#', $this->fullpath
, -1, PREG_SPLIT_NO_EMPTY
);
219 $count = sizeof($temp) - 1;
221 foreach ($temp AS $val => $item)
224 $itembit .= (($count != $val OR $this->cachev
->isdir($itembit)) ? '/' : '');
225 $html .= '<a href="' . $this->href_struct('browse.php' . $this->revstr
, ($val == 0 ? '' : $itembit)) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
232 /*=====================================================================*\
233 || ###################################################################
236 || ###################################################################
237 \*=====================================================================*/