browse.php now works without throwing PHP errors
[viewsvn.git] / includes / node.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * Node Controller
24 *
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.
29 *
30 * @author Iris Studios, Inc.
31 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
32 * @version $Revision$
33 * @package ViewSVN
34 *
35 */
36 class Node_Controller
37 {
38 /**
39 * Registry class
40 * @var object
41 * @access private
42 */
43 var $registry = null;
44
45 /**
46 * Xquery layer
47 * @var object
48 * @access private
49 */
50 var $xquery = null;
51
52 /**
53 * Xquery method library
54 * @var object
55 * @access private
56 */
57 var $library = null;
58
59 /**
60 * cacheV layer
61 * @var object
62 * @access private
63 */
64 var $cachev = null;
65
66 /**
67 * Full, universal path of the node
68 * @var string
69 * @access public
70 */
71 var $fullpath;
72
73 /**
74 * Repository of the path
75 * @var string
76 * @access public
77 */
78 var $repos;
79
80 /**
81 * The full path to the repository
82 * @var string
83 * @access public
84 */
85 var $repospath;
86
87 /**
88 * Relative path in the repository
89 * @var string
90 * @access public
91 */
92 var $path;
93
94 // ###################################################################
95 /**
96 * Constructor
97 *
98 * @access public
99 */
100 function Node_Controller($nodepath)
101 {
102 global $viewsvn;
103
104 // variables
105 $this->fullpath = $nodepath;
106
107 $temp = preg_split('#/#', $this->fullpath, -1, PREG_SPLIT_NO_EMPTY);
108
109 $this->repos = $temp[0];
110
111 unset($temp[0]);
112 $this->path = '/' . implode('/', $temp);
113
114 // objects
115 $this->registry =& $viewsvn;
116
117 $this->repospath = $this->registry->repos->fetch_path($this->repos);
118
119 require_once('./includes/shellcmd.php');
120 $this->xquery = new Shell($this);
121
122 require_once('./includes/svnlib.php');
123 $this->library = new SVNLib($this);
124
125 require_once('./includes/cachev.php');
126 $this->cachev = new cacheV($this);
127 }
128
129 // ###################################################################
130 /**
131 * Create path breadcrumb
132 *
133 * @access public
134 *
135 * @param string Universal path
136 * @param bool Add trailing slash
137 *
138 * @return string Breadcrumb HTML
139 */
140 function construct_breadcrumb($path, $doslash = true)
141 {
142 global $viewsvn, $cachev;
143
144 $html = '/ ';
145 $itembit = '/';
146
147 $temp = preg_split('#/#', $path, -1, PREG_SPLIT_NO_EMPTY);
148 $count = count($temp) - 1;
149
150 foreach ($temp AS $val => $item)
151 {
152 $itembit .= $item;
153 $itembit .= (($count != $val OR $cachev->isdir($itembit)) ? '/' : '');
154 $html .= '<a href="' . $this->controller->path . '/' . $this->controller->registry->paths->out('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
155 }
156
157 return $html;
158 }
159 }
160
161 /*=====================================================================*\
162 || ###################################################################
163 || # $HeadURL$
164 || # $Id$
165 || ###################################################################
166 \*=====================================================================*/
167 ?>