Properties now work:
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 04:48:58 +0000 (04:48 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 04:48:58 +0000 (04:48 +0000)
- Added Revision::getPropsForPath()
- Added FormatPropList() to format a property array

browse.php
includes/class_revision.php
includes/functions.php
view.php

index bd8bc48606f31b57dfbef48d3e824ac73fa833e9..c892d2212b84cfca2c417baa329280bd7a24b7a9 100644 (file)
@@ -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 <strong>%1$s</strong> set to <em>%2$s</em>'), $propname, $propval);
-               eval('$proplist .= "' . $template->fetch('property') . '";');
-       }
-}
-*/
+$props = $revision->getPropsForPath($input->in['path']);
+$show['props'] = (sizeof($props) > 0);
+$proplist = FormatPropList($props);
 
 // ###################################################################
 
index 30740cdfed86d47af1c57180d2eb26571a50f254..02e869344e8153799c89b2d48bbb859ee9e76ca3 100644 (file)
@@ -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
index c159b2348ca8eb3139982528ec67e327190c3a2a..ccdd8dc55b832af8fd4be3f6d4c4d73ce43c0287 100644 (file)
@@ -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 <strong>%1$s</strong> set to <em>%2$s</em>'), $propname, $propval);
+               eval('$proplist .= "' . BSRegister::Get('template')->fetch('property') . '";');
+       }
+       return $proplist;
+}
+
 /*=====================================================================*\
 || ###################################################################
 || # $HeadURL$
index a8f5be5f80aa1a9be079afbee5c304f9b4234627..e45180f2563d0bdda22a3b7329cbb2b8d637ed95 100644 (file)
--- 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 <strong>%1$s</strong> set to <em>%2$s</em>'), $propname, $propval);
-               eval('$proplist .= "' . $template->fetch('property') . '";');
-       }
-}
+$props = $revision->getPropsForPath($input->in['path']);
+$show['props'] = (sizeof($props) > 0);
+$proplist = FormatPropList($props);
 
 // ###################################################################