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 * Common functions that aren't Xquery-related and advanced query systems
29 * This is a utility class that should be accessed in a static fashion. It
30 * is responsbile for various parsing mechanisms, mainly.
37 // ###################################################################
39 * Prepares data for output
43 * @param string Standard data
45 * @return string Output-ready data
47 function format($string)
50 $string = htmlspecialchars($string);
53 $string = str_replace("\t", ' ', $string);
58 $string = preg_replace('#( +)#e', 'SVNCommon::format_spaces("\1")', $string);
63 $string = str_replace(' ', ' ', $string);
66 // convert advanced diff
67 $string = str_replace(array('{@+' . '+}', '{@-' . '-}'), array('<span class="diff_add_bit">', '<span class="diff_del_bit">'), $string);
68 $string = str_replace(array('{/@+' . '+}', '{/@-' . '-}'), '</span>', $string);
71 $string = nl2br($string);
76 // ###################################################################
78 * Counts the spaces and replaces two or more ones
82 * @param string Spaced string
84 * @return string 'd string
86 function format_spaces($thestring)
88 if (strlen($thestring) >= 2)
90 $thestring = str_replace(' ', ' ', $thestring);
96 // ###################################################################
98 * Prints the file changed list
102 * @public array List of file changes
103 * @public string The repository
104 * @public integer Current revision
106 * @return string Processed HTML
108 function construct_file_changes($changes, $repos, $revision)
114 foreach ($changes AS $file)
116 switch ($file['action'])
120 $tooltip = $viewsvn->lang
->string('Added');
123 $class = 'file_delete';
124 $tooltip = $viewsvn->lang
->string('Deleted');
127 $class = 'file_modify';
128 $tooltip = $viewsvn->lang
->string('Modified');
131 $class = 'file_replace';
132 $tooltip = $viewsvn->lang
->string('Replaced');
136 $show['from'] = (bool
)$file['from'];
140 $class = 'file_move';
141 $tooltip = 'Moved/Copied';
142 preg_match('#(.*):([0-9]+)#', $file['from'], $matches);
143 $link['from'] = $viewsvn->path
. '/view.php/' . $repos . '/' . $matches[1] . Paths
::fetch_rev_str(false
, $matches[2]);
146 $link['file'] = $viewsvn->path
. '/view.php/' . $repos . $file['value'] . Paths
::fetch_rev_str(false
, $revision);
148 eval('$files .= "' . $viewsvn->template
->fetch('file_change') . '";');
154 // ###################################################################
156 * Generates a clean revision number
160 * @param integer Revision number
162 * @return mixed Cleaned revision or HEAD
164 function rev($revision)
166 if (($revision = intval($revision)) < 1)
174 /*=====================================================================*\
175 || ###################################################################
178 || ###################################################################
179 \*=====================================================================*/