From 18dd0159b2f8ebbf2580e385cd0481b701a8e214 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 9 Apr 2007 04:48:58 +0000 Subject: [PATCH] Properties now work: - Added Revision::getPropsForPath() - Added FormatPropList() to format a property array --- browse.php | 16 +++------------- includes/class_revision.php | 30 ++++++++++++++++++++++++++++++ includes/functions.php | 22 ++++++++++++++++++++++ view.php | 14 +++----------- 4 files changed, 58 insertions(+), 24 deletions(-) diff --git a/browse.php b/browse.php index bd8bc48..c892d22 100644 --- a/browse.php +++ b/browse.php @@ -37,19 +37,9 @@ $revision = new Revision($input->in['repos'], $input->in['rev']); // ################################################################### -/* -$show['props'] = false; -$proplist = ''; -if (sizeof($latest['properties']) > 0) -{ - $show['props'] = true; - foreach ($latest['properties'] AS $propname => $propval) - { - $data = sprintf($lang->string('Property %1$s set to %2$s'), $propname, $propval); - eval('$proplist .= "' . $template->fetch('property') . '";'); - } -} -*/ +$props = $revision->getPropsForPath($input->in['path']); +$show['props'] = (sizeof($props) > 0); +$proplist = FormatPropList($props); // ################################################################### diff --git a/includes/class_revision.php b/includes/class_revision.php index 30740cd..02e8693 100644 --- a/includes/class_revision.php +++ b/includes/class_revision.php @@ -65,6 +65,36 @@ class Revision $this->_fetchRevision($rev); } + // ################################################################### + /** + * Returns an array of properties for this revision at a certain path + * + * @param string Path + * + * @return array Array of properties + */ + public function getPropsForPath($path) + { + $output = BSRegister::Get('lib')->run('proplist -v -r' . $this->revision . ' ' . BSRegister::Get('lib')->arg($this->path . $path)); + unset($output[0]); + + $proplist = array(); + foreach ($output AS $line) + { + if (preg_match('#^\s+(.*)\s:(\s(.*))?#', $line, $matches)) + { + $curprop = $matches[1]; + $proplist["$curprop"] = $matches[2] . "\n"; + } + else + { + $proplist["$curprop"] .= $line . "\n"; + } + } + + return $proplist; + } + // ################################################################### /** * Gets the desired XML revision information from the repository diff --git a/includes/functions.php b/includes/functions.php index c159b23..ccdd8dc 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -47,6 +47,28 @@ function ConstructNavbar() return $html; } +// ################################################################### +/** +* Formats an array of properties into a compiled HTML template +* +* @param array Array of properties +* +* @return string Compiled HTML property list +*/ +function FormatPropList($props) +{ + if (sizeof($props) < 0) + { + return ''; + } + foreach ($props AS $propname => $propval) + { + $data = sprintf(_('Property %1$s set to %2$s'), $propname, $propval); + eval('$proplist .= "' . BSRegister::Get('template')->fetch('property') . '";'); + } + return $proplist; +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/view.php b/view.php index a8f5be5..e45180f 100644 --- a/view.php +++ b/view.php @@ -46,17 +46,9 @@ $catdata = $lib->run('cat -r' . $revision->revision . ' ' . $lib->arg($repos->fe // ################################################################### -$show['props'] = false; -$proplist = ''; -if (sizeof($latest['properties']) > 0) -{ - $show['props'] = true; - foreach ($latest['properties'] AS $propname => $propval) - { - $data = sprintf($lang->string('Property %1$s set to %2$s'), $propname, $propval); - eval('$proplist .= "' . $template->fetch('property') . '";'); - } -} +$props = $revision->getPropsForPath($input->in['path']); +$show['props'] = (sizeof($props) > 0); +$proplist = FormatPropList($props); // ################################################################### -- 2.43.5