Basic SVNCommon lib setup
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 28 Aug 2005 20:22:04 +0000 (20:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 28 Aug 2005 20:22:04 +0000 (20:22 +0000)
includes/svnlib.php

index 451cbcfba9202ff8c5051397d9f2dc00952f3f4f..6f0e835171ea75d0f6b053801d4893ed488aeb1b 100644 (file)
@@ -31,6 +31,12 @@ class SVNLib
        */
        var $svnpath;
        
+       /**
+       * Common command system
+       * @var  object
+       */
+       var $common;
+       
        /**
        * Constructor: validate SVN path
        *
@@ -42,6 +48,8 @@ class SVNLib
                
                $this->svnpath = $viewsvn->shell->cmd($svnpath);
                
+               $this->common =& new SVNCommon();
+               
                $access = $viewsvn->shell->exec($this->svnpath . ' --version');
                
                if (!$access)
@@ -274,6 +282,56 @@ class SVNLib
        }
 }
 
+/**
+* Commonly executed SVN commands that return data
+* used in many parts of the system
+*
+* @package     ViewSVN
+* @version     $Id$
+*/
+class SVNCommon
+{
+       /**
+       * Registry object
+       * @var  object
+       */
+       var $registry;
+       
+       /**
+       * Constructor: bind with registry
+       */
+       function SVNCommon()
+       {
+               global $viewsvn;
+               
+               $this->registry =& $viewsvn;
+       }
+       
+       /**
+       * Checks to see if the given universal path is
+       * a directory
+       *
+       * @access       public
+       *
+       * @param        string  Universal path
+       *
+       * @return       bool    Directory or not
+       */
+       function isdir($path)
+       {
+               $output = $this->registry->svn->cat($this->registry->paths->fetch_repos($path), $this->registry->paths->fetch_path($path), 'HEAD');
+               $output = implode("\n", $output);
+               if (strpos($output, 'svn:') === false)
+               {
+                       return false;
+               }
+               else
+               {
+                       return true;
+               }
+       }
+}
+
 /**
 * Annotation/blame system; constructs an array
 * that is ready for output