phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: chora/inc class.cvslib.inc.php,1.6,1.7 class.cvs


From: Miles Lott <address@hidden>
Subject: [Phpgroupware-cvs] CVS: chora/inc class.cvslib.inc.php,1.6,1.7 class.cvslib_annotate.inc.php,1.1,1.2 class.cvslib_checkout.inc.php,1.1,1.2 class.cvslib_diff.inc.php,1.1,1.2 class.cvslib_directory.inc.php,1.1,1.2 class.cvslib_file.inc.php,1.1,1.2 class.cvslib_rev.inc.php,1.1,1.2 functions.inc.php,1.9,1.10 CVSLib.php,1.1,NONE version.php,1.1.1.1,NONE
Date: Sun, 28 Apr 2002 15:26:43 -0400

Update of /cvsroot/phpgroupware/chora/inc
In directory subversions:/tmp/cvs-serv25993/inc

Modified Files:
        class.cvslib.inc.php class.cvslib_annotate.inc.php 
        class.cvslib_checkout.inc.php class.cvslib_diff.inc.php 
        class.cvslib_directory.inc.php class.cvslib_file.inc.php 
        class.cvslib_rev.inc.php functions.inc.php 
Removed Files:
        CVSLib.php version.php 
Log Message:
Convert to phpgw object creation methods; remove old files



Index: class.cvslib.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.cvslib.inc.php        28 Apr 2002 18:09:06 -0000      1.6
--- class.cvslib.inc.php        28 Apr 2002 19:26:40 -0000      1.7
***************
*** 142,146 ****
                function queryDir($where)
                {
!                       $dir = new CVSLib_directory($this, $where);
                        return $dir;
                }
--- 142,146 ----
                function queryDir($where)
                {
!                       $dir = CreateObject('chora.cvslib_directory',$this, 
$where);
                        return $dir;
                }
***************
*** 185,189 ****
                }
        }
! 
        include(PHPGW_APP_INC . '/class.cvslib_checkout.inc.php');
        include(PHPGW_APP_INC . '/class.cvslib_directory.inc.php');
--- 185,189 ----
                }
        }
! /*
        include(PHPGW_APP_INC . '/class.cvslib_checkout.inc.php');
        include(PHPGW_APP_INC . '/class.cvslib_directory.inc.php');
***************
*** 194,196 ****
--- 194,197 ----
        include(PHPGW_APP_INC . '/class.cvslib_error.inc.php');
        include(PHPGW_APP_INC . '/class.cvslib_log.inc.php');
+ */
  ?>

Index: class.cvslib_annotate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_annotate.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_annotate.inc.php       28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_annotate.inc.php       28 Apr 2002 19:26:40 -0000      1.2
***************
*** 15,23 ****
         * @package chora
         */
!       class CVSLib_Annotate
        {
                var $file, $CVS, $tmpfile;
  
!               function CVSLib_Annotate($rep, $file)
                {
                        $this->CVS = $rep;
--- 15,23 ----
         * @package chora
         */
!       class cvslib_annotate
        {
                var $file, $CVS, $tmpfile;
  
!               function cvslib_annotate($rep, $file)
                {
                        $this->CVS = $rep;
***************
*** 28,32 ****
                {
                        /* Make sure that the file values for this object is 
valid */
!                       if (!is_object($this->file) || $this->file->id() != 
CVSLIB_FILE)
                        {
                                return false;
--- 28,32 ----
                {
                        /* Make sure that the file values for this object is 
valid */
!                       if(!is_object($this->file) || $this->file->id() != 
CVSLIB_FILE)
                        {
                                return false;
***************
*** 34,43 ****
  
                        /* Make sure that the cvsrep parameter is valid */
!                       if (!is_object($this->CVS) || $this->CVS->id() != 
CVSLIB_REPOSITORY)
                        {
                                return false;
                        }
  
!                       if (!CVSLib_Rev::valid($rev))
                        {
                                return false;
--- 34,43 ----
  
                        /* Make sure that the cvsrep parameter is valid */
!                       if(!is_object($this->CVS) || $this->CVS->id() != 
CVSLIB_REPOSITORY)
                        {
                                return false;
                        }
  
!                       if(!CVSLib_Rev::valid($rev))
                        {
                                return false;
***************
*** 58,65 ****
                        $out[] = "Argument $where";
                        $dirs = explode('/', dirname($where));
!                       while (sizeof($dirs))
                        {
!                               $out[] = 'Directory '.implode('/',$dirs);
!                               $out[] = "$cvsroot/".implode('/',$dirs);
                                array_pop($dirs);
                        }
--- 58,65 ----
                        $out[] = "Argument $where";
                        $dirs = explode('/', dirname($where));
!                       while(sizeof($dirs))
                        {
!                               $out[] = 'Directory ' . implode('/', $dirs);
!                               $out[] = "$cvsroot/" . implode('/', $dirs);
                                array_pop($dirs);
                        }
***************
*** 76,80 ****
                        pclose($pipe);
  
!                       if (!($fl = fopen($this->tmpfile, 'r')))
                        {
                                $this->_clean();
--- 76,80 ----
                        pclose($pipe);
  
!                       if(!($fl = fopen($this->tmpfile, 'rb')))
                        {
                                $this->_clean();
***************
*** 84,96 ****
                        $lines = array();
                        $line = fgets($fl, 4096);
!                       if (!preg_match("|^E\s+Annotations for $where|", $line))
                        {
                                $this->_clean();
!                               return new 
CVSLib_Error(CVSLIB_INTERNAL_ERROR,"Unable to annotate; server said: $line");
                        }
  
                        while($line = fgets($fl, 4096))
                        {
!                               if 
(preg_match('/^M\s+([\d\.]+)\s+\((\w+)\s+(\d+-\w+-\d+)\):.(.*)$/',$line, $regs))
                                {
                                        $entry = array();
--- 84,100 ----
                        $lines = array();
                        $line = fgets($fl, 4096);
!                       if(!preg_match("|^E\s+Annotations for $where|", $line))
                        {
                                $this->_clean();
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_INTERNAL_ERROR,
!                                       "Unable to annotate; server said: $line"
!                               );
                        }
  
                        while($line = fgets($fl, 4096))
                        {
!                               
if(preg_match('/^M\s+([\d\.]+)\s+\((\w+)\s+(\d+-\w+-\d+)\):.(.*)$/',$line, 
$regs))
                                {
                                        $entry = array();
***************
*** 122,126 ****
                function _clean()
                {
!                       if (isset($this->tmpfile))
                        {
                                @unlink($this->tmpfile);
--- 126,130 ----
                function _clean()
                {
!                       if(isset($this->tmpfile))
                        {
                                @unlink($this->tmpfile);

Index: class.cvslib_checkout.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_checkout.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_checkout.inc.php       28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_checkout.inc.php       28 Apr 2002 19:26:40 -0000      1.2
***************
*** 28,40 ****
                function get($CVS, $fullname, $rev)
                {
!                       if (!CVSLib_Rev::valid($rev))
                        {
!                               return new CVSLib_Error(CVSLIB_INTERNAL_ERROR, 
"Invalid revision number");
                        }
  
!                       if (!($RCS = popen($CVS->conf['paths']['co']." -p$rev 
'$fullname' 2>&1", 'r')))
                        {
!                               return new CVSLib_Error(CVSLIB_INTERNAL_ERROR,
!                               "Couldn't perform checkout of the requested 
file");
                        }
  
--- 28,48 ----
                function get($CVS, $fullname, $rev)
                {
!                       $_rev = CreateObject('chora.cvslib_rev');
!                       if(!$_rev->valid($rev))
                        {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_INTERNAL_ERROR,
!                                       'Invalid revision number'
!                               );
                        }
  
!                       if(!($RCS = popen($CVS->conf['paths']['co']." -p$rev 
'$fullname' 2>&1", 'r')))
                        {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_INTERNAL_ERROR,
!                                       "Couldn't perform checkout of the 
requested file"
!                               );
                        }
  
***************
*** 45,51 ****
  
                        $co = fgets($RCS, 1024);
!                       if (!preg_match('/^([\S ]+),v\s+-->\s+st(andar)?d 
?out(put)?\s*$/', $co, $regs) || $regs[1] != $fullname)
                        {
!                               return new CVSLib_Error(CVSLIB_INTERNAL_ERROR, 
"Unexpected output from CVS Checkout: $co");
                        }
  
--- 53,63 ----
  
                        $co = fgets($RCS, 1024);
!                       if(!preg_match('/^([\S ]+),v\s+-->\s+st(andar)?d 
?out(put)?\s*$/', $co, $regs) || $regs[1] != $fullname)
                        {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_INTERNAL_ERROR,
!                                       "Unexpected output from CVS Checkout: 
$co"
!                               );
                        }
  

Index: class.cvslib_diff.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_diff.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_diff.inc.php   28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_diff.inc.php   28 Apr 2002 19:26:40 -0000      1.2
***************
*** 15,19 ****
         * @package chora
         */
!       class CVSLib_Diff
        {
                /*
--- 15,19 ----
         * @package chora
         */
!       class cvslib_diff
        {
                /*
***************
*** 29,33 ****
                {
                        /* Make sure that the file parameter is valid */
!                       if (!is_object($file) || $file->id() != CVSLIB_FILE)
                        {
                                return false;
--- 29,33 ----
                {
                        /* Make sure that the file parameter is valid */
!                       if(!is_object($file) || $file->id() != CVSLIB_FILE)
                        {
                                return false;
***************
*** 35,39 ****
  
                        /* Make sure that the cvsrep parameter is valid */
!                       if (!is_object($cvsrep) || $cvsrep->id() != 
CVSLIB_REPOSITORY)
                        {
                                return false;
--- 35,39 ----
  
                        /* Make sure that the cvsrep parameter is valid */
!                       if(!is_object($cvsrep) || $cvsrep->id() != 
CVSLIB_REPOSITORY)
                        {
                                return false;
***************
*** 47,51 ****
                        $diff = array();
                        $options = '-kk ';
!                       switch ($type)
                        {
                                case CVSLIB_DIFF_CONTEXT:
--- 47,51 ----
                        $diff = array();
                        $options = '-kk ';
!                       switch($type)
                        {
                                case CVSLIB_DIFF_CONTEXT:
***************
*** 66,70 ****
                        // be compatible with some diffs - avsm
                        $command = $cvsrep->conf['paths']['rcsdiff']." $options 
-r$rev1 -r$rev2 '$fullName' 2>&1";
!                       if (!($diffStream = popen($command, 'r')))
                        {
                                return false;
--- 66,70 ----
                        // be compatible with some diffs - avsm
                        $command = $cvsrep->conf['paths']['rcsdiff']." $options 
-r$rev1 -r$rev2 '$fullName' 2>&1";
!                       if(!($diffStream = popen($command, 'r')))
                        {
                                return false;
***************
*** 99,106 ****
                        {
                                /* Look for a header which indicates the start 
of a diff chunk */
!                               if (preg_match('/^@@ 
\-([0-9]+).*\+([0-9]+).*@@(.*)/', $line, $regs))
                                {
                                        /* Push any previous header information 
to the return stack */
!                                       if (isset($data))
                                        {
                                                $ret[] = $data;
--- 99,106 ----
                        {
                                /* Look for a header which indicates the start 
of a diff chunk */
!                               if(preg_match('/^@@ 
\-([0-9]+).*\+([0-9]+).*@@(.*)/', $line, $regs))
                                {
                                        /* Push any previous header information 
to the return stack */
!                                       if(isset($data))
                                        {
                                                $ret[] = $data;
***************
*** 115,123 ****
                                        $state = CVSLIB_DIFF_DUMP;
                                }
!                               elseif ($state != CVSLIB_DIFF_EMPTY)
                                {
                                        /* We are in a chunk, so split out the 
action (+/-) and the line */
                                        preg_match('/^([\+\- ])(.*)/', $line, 
$regs);
!                                       if (sizeof($regs) > 2)
                                        {
                                                $action = $regs[1];
--- 115,123 ----
                                        $state = CVSLIB_DIFF_DUMP;
                                }
!                               elseif($state != CVSLIB_DIFF_EMPTY)
                                {
                                        /* We are in a chunk, so split out the 
action (+/-) and the line */
                                        preg_match('/^([\+\- ])(.*)/', $line, 
$regs);
!                                       if(sizeof($regs) > 2)
                                        {
                                                $action = $regs[1];
***************
*** 130,137 ****
                                        }
  
!                                       if ($action == '+')
                                        {
                                                /* This is just an addition 
line */
!                                               if ($state == CVSLIB_DIFF_DUMP 
|| $state == CVSLIB_DIFF_ADD)
                                                {
                                                        /* Start adding to the 
addition stack */
--- 130,137 ----
                                        }
  
!                                       if($action == '+')
                                        {
                                                /* This is just an addition 
line */
!                                               if($state == CVSLIB_DIFF_DUMP 
|| $state == CVSLIB_DIFF_ADD)
                                                {
                                                        /* Start adding to the 
addition stack */
***************
*** 146,150 ****
                                                }
                                        }
!                                       elseif ($action == '-')
                                        {
                                                /* This is a removal line */
--- 146,150 ----
                                                }
                                        }
!                                       elseif($action == '-')
                                        {
                                                /* This is a removal line */
***************
*** 155,159 ****
                                        {
                                                /* An empty block with no 
action */
!                                               switch ($state)
                                                {
                                                        case CVSLIB_DIFF_ADD:
--- 155,159 ----
                                        {
                                                /* An empty block with no 
action */
!                                               switch($state)
                                                {
                                                        case CVSLIB_DIFF_ADD:
***************
*** 177,181 ****
  
                        /* Just flush any remaining entries in the columns 
stack */
!                       switch ($state)
                        {
                                case CVSLIB_DIFF_ADD:
--- 177,181 ----
  
                        /* Just flush any remaining entries in the columns 
stack */
!                       switch($state)
                        {
                                case CVSLIB_DIFF_ADD:
***************
*** 192,196 ****
                        }
  
!                       if (isset($data))
                        {
                                $ret[] = $data;
--- 192,196 ----
                        }
  
!                       if(isset($data))
                        {
                                $ret[] = $data;

Index: class.cvslib_directory.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_directory.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_directory.inc.php      28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_directory.inc.php      28 Apr 2002 19:26:40 -0000      1.2
***************
*** 1,4 ****
! <?php 
! 
  /*  See the README file that came with this library for more
   *  information, and read the inline documentation.
--- 1,3 ----
! <?php
  /*  See the README file that came with this library for more
   *  information, and read the inline documentation.
***************
*** 8,225 ****
   */
  
! /**
!  * CVSLib directory class.
!  *
!  * @author  Anil Madhavapeddy <address@hidden>
!  * @version $Revision$
!  * @since   Chora 0.1
!  * @package chora
!  */
! class CVSLib_Directory {
  
!     var $dirName, $rep, $files, $atticFiles, $mergedFiles, $dirs, $parent, 
$moduleName;
  
!     /**
!       * Create a CVS Directory object to store information
!       * about the files in a single directory in the repository
!       *
!       * @param rp CVSLIB_Repository object this directory is part of
!       * @param dn Path to the directory
!       * @param pn Optional parent CVSLib_Directory to this one
!       */
!     function CVSLib_Directory($rp, $dn, $pn="") {
!         $this->parent  = $pn;
!         $this->rep     = $rp;
!         $this->moduleName = $dn;
!         $this->dirName = $rp->cvsRoot()."/$dn";
!         $this->files   = array();
!         $this->dirs    = array(); 
!     }
! 
!     /**
!       * Return what class this is for identification purposes
!       * @return CVSLIB_DIRECTORY constant
!       */
!     function id() {
!         return CVSLIB_DIRECTORY;
!     }
!     
!     /**
!       * Return fully qualified pathname to this directory
!       * with no trailing /
!       * @return Pathname of this directory
!       */
!     function queryDir() {
!         return $this->dirName;
!     }
! 
!     function queryDirList() {
!         reset ($this->dirs);
!         return $this->dirs;
!     }
! 
!     function queryFileList($flags = CVSLIB_ATTIC_HIDE) {
!         if ($flags == CVSLIB_ATTIC_SHOW && isset($this->mergedFiles)) {
!             return $this->mergedFiles;
!         } else {
!             return $this->files;
!         }
!     }
! 
!     /**
!       * Tell the object to open and browse its current directory, and
!       * retrieve a list of all the objects in there.  It then populates
!       * the file/directory stack and makes it available for retrieval.
!       * @return CVSLib_Error object on an error, 1 on success. 
!       */
!     function browseDir($flags = CVSLIB_LOG_QUICK, $attic = CVSLIB_ATTIC_HIDE) 
{
! 
!         /* Make sure we are trying to list a directory */
!         if (address@hidden($this->dirName)) {
!              return new CVSLib_Error(CVSLIB_NOT_FOUND, "Unable to find 
directory");
!         }
!  
!         /* Open the directory for reading its contents */
!         if (!($DIR = @opendir($this->dirName))) {
!              $errmsg = (!empty($php_errormsg)) ? $php_errormsg : 'Permission 
Denied';
!              return new CVSLib_Error(CVSLIB_PERMISSION_DENIED, "$where: 
$errmsg");
!         }
! 
!         /* Maintain two arrays - one of all the files, and the other of dirs 
*/
!         $fileList = array();
! 
!         while (($name = readdir($DIR)) !== false) {
!             /* Drop the special files, we know they exist */
!             if ($name == '.' || $name == '..' || $name == 'Attic') {
!                 continue;
!             }
!             /* Check to see if we have a directory */
!             else if (@is_dir($this->queryDir()."/$name")) {
!                 array_push($this->dirs, $name);
!             }
!             /* Check to see if we have a repository file */
!             else if (preg_match('/,v$/',$name)) {
!                 array_push($fileList, preg_replace('/,v$/','',$name));
!             }
!             /* Otherwise we have an illegal file in our repository, just 
ignore it */
!         }
! 
!         /* Close the filehandle; we've now got a list of dirs and files */
!         closedir($DIR);
! 
!               @reset($fileList);
!               while(list(,$fname) = @each($fileList))
!               {
!             /* Spawn a new file object to represent this file */
!             $fl = new CVSLib_File($this->rep, $this->queryDir() . "/$fname", 
$flags);
!             $retVal = $fl->getBrowseInfo();
!  
!             /* Check for an error; if there is one, then return it */
!             if (is_object($retVal) && $retVal->id() == CVSLIB_ERROR) {
!                 return $fl;
!             }
!             /* Push the created file object on the directory file stack */
!             else if ($fl->id() == CVSLIB_FILE) {
!                 array_push($this->files, $fl);
!             }
!             else {
!                 /* TODO- We should never reach here - throw a consistency
!                  * CVSLib_Error in the future - avsm */
!             }
!         }
! 
!         /* If we want to merge the attic, add it in here */
!         if ($attic = CVSLIB_ATTIC_SHOW) {
!             $atticDir = new CVSLib_Directory($this->rep, 
$this->moduleName.'/Attic', $this);
!             if ($atticDir->browseDir($flags, CVSLIB_ATTIC_HIDE) == 1) {
!                 $this->atticFiles = $atticDir->queryFileList();
!                 $this->mergedFiles = array_merge($this->files, 
$this->atticFiles);
!             }
!         }
!         return 1;
!     }
! 
!     /**
!       * Sort the contents of the directory in a given fashion and order
!       * @param how Of the form CVSLIB_SORT_* where * can be: 
!       *       NONE, NAME, AGE, REV for sorting by name, age or revision
!       * @param dir Of the form CVSLIB_SORT_* where * can be:
!       *       ASCENDING, DESCENDING for the order of the sort
!       */
!     function applySort($how=CVSLIB_SORT_NONE, $dir=CVSLIB_SORT_ASCENDING) {
!         // assume by name for the moment
!         sort($this->dirs);
!         reset($this->dirs);
!         $this->doFileSort($this->files, $how, $dir);
!         reset($this->files);
!         if (isset($this->atticFiles)) {
!             $this->doFileSort($this->atticFiles, $how, $dir);
!             reset($this->atticFiles);
!         }
!         if (isset($this->mergedFiles)) {
!             $this->doFileSort($this->mergedFiles, $how, $dir);
!             reset($this->mergedFiles);
!         }
!         if ($dir == CVSLIB_SORT_DESCENDING) {
!             $this->dirs=array_reverse($this->dirs);
!             $this->files=array_reverse($this->files);
!         }
!     }
! 
!     function doFileSort(&$fileList, $how = CVSLIB_SORT_NONE, 
$dir=CVSLIB_SORT_ASCENDING) { 
!         switch ($how) {
!          case CVSLIB_SORT_NONE:
!             break;
!          case CVSLIB_SORT_AGE:
!             usort($fileList, array($this, "fileAgeSort"));
!             break;
!          case CVSLIB_SORT_NAME:
!             usort($fileList, array($this, "fileNameSort"));
!             break;
!          case CVSLIB_SORT_AUTHOR:
!             usort($fileList, array($this, "fileAuthorSort"));
!             break;
!          case CVSLIB_SORT_REV:
!             usort($fileList, array($this, "fileRevSort"));
!             break;
!          default:
!             break;
!         }
!     }
! 
!     /**
!       * Sort function for ascending age
!       */
!     function fileAgeSort($a, $b) {
!         $aa = $a->queryLastLog();
!         $bb = $b->queryLastLog();
!         if ($aa->queryDate() == $bb->queryDate()) return 0;
!         else return ($aa->queryDate() < $bb->queryDate())?1:-1;
!     }
! 
!     /**
!       * Sort function by author name
!       */
!     function fileAuthorSort($a, $b) {
!         $aa = $a->queryLastLog();
!         $bb = $b->queryLastLog();
!         if ($aa->queryAuthor() == $bb->queryAuthor()) return 0;
!         else return ($aa->queryAuthor() > $bb->queryAuthor())?1:-1;
!     }
! 
!     /**
!       * Sort function for ascending file-name
!       */
!     function fileNameSort($a, $b) {
!         if ($a->name == $b->name) return 0;
!         else return ($a->name < $b->name)?-1:1;
!     }
! 
!     /**
!       * Sort function for ascending revision
!       */
!     function fileRevSort($a, $b) {
!         return CVSLib_Rev::cmp($a->queryHead(), $b->queryHead());
!     }
! }
  ?>
--- 7,293 ----
   */
  
!       /**
!       * CVSLib directory class.
!       *
!       * @author  Anil Madhavapeddy <address@hidden>
!       * @version $Revision$
!       * @since   Chora 0.1
!       * @package chora
!       */
!       class cvslib_directory
!       {
!               var $dirName, $rep, $files, $atticFiles, $mergedFiles, $dirs, 
$parent, $moduleName;
! 
!               /**
!               * Create a CVS Directory object to store information
!               * about the files in a single directory in the repository
!               *
!               * @param rp CVSLIB_Repository object this directory is part of
!               * @param dn Path to the directory
!               * @param pn Optional parent CVSLib_Directory to this one
!               */
!               function CVSLib_Directory($rp, $dn, $pn='')
!               {
!                       $this->parent  = $pn;
!                       $this->rep     = $rp;
!                       $this->moduleName = $dn;
!                       $this->dirName = $rp->cvsRoot() . "/$dn";
!                       $this->files   = array();
!                       $this->dirs    = array(); 
!               }
! 
!               /**
!               * Return what class this is for identification purposes
!               * @return CVSLIB_DIRECTORY constant
!               */
!               function id()
!               {
!                       return CVSLIB_DIRECTORY;
!               }
  
!               /**
!               * Return fully qualified pathname to this directory
!               * with no trailing /
!               * @return Pathname of this directory
!               */
!               function queryDir()
!               {
!                       return $this->dirName;
!               }
! 
!               function queryDirList()
!               {
!                       reset ($this->dirs);
!                       return $this->dirs;
!               }
  
!               function queryFileList($flags = CVSLIB_ATTIC_HIDE)
!               {
!                       if($flags == CVSLIB_ATTIC_SHOW && 
isset($this->mergedFiles))
!                       {
!                               return $this->mergedFiles;
!                       }
!                       else
!                       {
!                               return $this->files;
!                       }
!               }
! 
!               /**
!               * Tell the object to open and browse its current directory, and
!               * retrieve a list of all the objects in there.  It then 
populates
!               * the file/directory stack and makes it available for retrieval.
!               * @return CVSLib_Error object on an error, 1 on success. 
!               */
!               function browseDir($flags = CVSLIB_LOG_QUICK, $attic = 
CVSLIB_ATTIC_HIDE)
!               {
!                       /* Make sure we are trying to list a directory */
!                       if(address@hidden($this->dirName))
!                       {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_NOT_FOUND,
!                                       'Unable to find directory'
!                               );
!                       }
! 
!                       /* Open the directory for reading its contents */
!                       if(!($DIR = @opendir($this->dirName)))
!                       {
!                               $errmsg = (!empty($php_errormsg)) ? 
$php_errormsg : 'Permission Denied';
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_PERMISSION_DENIED,
!                                       "$where: $errmsg"
!                               );
!                       }
! 
!                       /* Maintain two arrays - one of all the files, and the 
other of dirs */
!                       $fileList = array();
! 
!                       while(($name = readdir($DIR)) !== false)
!                       {
!                               /* Drop the special files, we know they exist */
!                               if($name == '.' || $name == '..' || $name == 
'Attic')
!                               {
!                                       continue;
!                               }
!                               /* Check to see if we have a directory */
!                               elseif(@is_dir($this->queryDir()."/$name"))
!                               {
!                                       array_push($this->dirs, $name);
!                               }
!                               /* Check to see if we have a repository file */
!                               elseif(preg_match('/,v$/',$name))
!                               {
!                                       array_push($fileList, 
preg_replace('/,v$/','',$name));
!                               }
!                               /* Otherwise we have an illegal file in our 
repository, just ignore it */
!                       }
! 
!                       /* Close the filehandle; we've now got a list of dirs 
and files */
!                       closedir($DIR);
! 
!                       @reset($fileList);
!                       while(list(,$fname) = @each($fileList))
!                       {
!                               /* Spawn a new file object to represent this 
file */
!                               $fl = CreateObject(
!                                       'chora.cvslib_file',
!                                       $this->rep,
!                                       $this->queryDir() . "/$fname",
!                                       $flags
!                               );
!                               $retVal = $fl->getBrowseInfo();
! 
!                               /* Check for an error; if there is one, then 
return it */
!                               if(is_object($retVal) && $retVal->id() == 
CVSLIB_ERROR)
!                               {
!                                       return $fl;
!                               }
!                               /* Push the created file object on the 
directory file stack */
!                               elseif($fl->id() == CVSLIB_FILE)
!                               {
!                                       array_push($this->files, $fl);
!                               }
!                               else
!                               {
!                                       /* TODO- We should never reach here - 
throw a consistency
!                                       * CVSLib_Error in the future - avsm */
!                               }
!                       }
! 
!                       /* If we want to merge the attic, add it in here */
!                       if($attic = CVSLIB_ATTIC_SHOW)
!                       {
!                               $atticDir = CreateObject(
!                                       'chora.cvslib_directory',
!                                       $this->rep,
!                                       $this->moduleName . '/Attic',
!                                       $this
!                               );
!                               if($atticDir->browseDir($flags, 
CVSLIB_ATTIC_HIDE) == 1)
!                               {
!                                       $this->atticFiles = 
$atticDir->queryFileList();
!                                       $this->mergedFiles = 
array_merge($this->files, $this->atticFiles);
!                               }
!                       }
!                       return 1;
!               }
! 
!               /**
!               * Sort the contents of the directory in a given fashion and 
order
!               * @param how Of the form CVSLIB_SORT_* where * can be: 
!               *       NONE, NAME, AGE, REV for sorting by name, age or 
revision
!               * @param dir Of the form CVSLIB_SORT_* where * can be:
!               *       ASCENDING, DESCENDING for the order of the sort
!               */
!               function applySort($how=CVSLIB_SORT_NONE, 
$dir=CVSLIB_SORT_ASCENDING)
!               {
!                       // assume by name for the moment
!                       sort($this->dirs);
!                       reset($this->dirs);
!                       $this->doFileSort($this->files, $how, $dir);
!                       reset($this->files);
!                       if(isset($this->atticFiles))
!                       {
!                               $this->doFileSort($this->atticFiles, $how, 
$dir);
!                               reset($this->atticFiles);
!                       }
!                       if(isset($this->mergedFiles))
!                       {
!                               $this->doFileSort($this->mergedFiles, $how, 
$dir);
!                               reset($this->mergedFiles);
!                       }
!                       if($dir == CVSLIB_SORT_DESCENDING)
!                       {
!                               $this->dirs=array_reverse($this->dirs);
!                               $this->files=array_reverse($this->files);
!                       }
!               }
! 
!               function doFileSort(&$fileList, $how = CVSLIB_SORT_NONE, 
$dir=CVSLIB_SORT_ASCENDING)
!               {
!                       switch($how)
!                       {
!                               case CVSLIB_SORT_NONE:
!                                       break;
!                               case CVSLIB_SORT_AGE:
!                                       usort($fileList, array($this, 
"fileAgeSort"));
!                                       break;
!                               case CVSLIB_SORT_NAME:
!                                       usort($fileList, array($this, 
"fileNameSort"));
!                                       break;
!                               case CVSLIB_SORT_AUTHOR:
!                                       usort($fileList, array($this, 
"fileAuthorSort"));
!                                       break;
!                               case CVSLIB_SORT_REV:
!                                       usort($fileList, array($this, 
"fileRevSort"));
!                                       break;
!                               default:
!                                       break;
!                       }
!               }
! 
!               /**
!               * Sort function for ascending age
!               */
!               function fileAgeSort($a, $b)
!               {
!                       $aa = $a->queryLastLog();
!                       $bb = $b->queryLastLog();
!                       if($aa->queryDate() == $bb->queryDate())
!                       {
!                               return 0;
!                       }
!                       else
!                       {
!                               return ($aa->queryDate() < 
$bb->queryDate())?1:-1;
!                       }
!               }
! 
!               /**
!               * Sort function by author name
!               */
!               function fileAuthorSort($a, $b)
!               {
!                       $aa = $a->queryLastLog();
!                       $bb = $b->queryLastLog();
!                       if($aa->queryAuthor() == $bb->queryAuthor())
!                       {
!                               return 0;
!                       }
!                       else
!                       {
!                               return ($aa->queryAuthor() > 
$bb->queryAuthor())?1:-1;
!                       }
!               }
! 
!               /**
!               * Sort function for ascending file-name
!               */
!               function fileNameSort($a, $b)
!               {
!                       if($a->name == $b->name)
!                       {
!                               return 0;
!                       }
!                       else
!                       {
!                               return ($a->name < $b->name)?-1:1;
!                       }
!               }
! 
!               /**
!               * Sort function for ascending revision
!               */
!               function fileRevSort($a, $b)
!               {
!                       $rev = CreateObject('chora.cvslib_rev');
!                       return $rev->cmp(
!                               $a->queryHead(),
!                               $b->queryHead()
!                       );
!               }
!       }
  ?>

Index: class.cvslib_file.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_file.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_file.inc.php   28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_file.inc.php   28 Apr 2002 19:26:40 -0000      1.2
***************
*** 1,4 ****
! <?php 
! 
  /*  See the README file that came with this library for more
   *  information, and read the inline documentation.
--- 1,3 ----
! <?php
  /*  See the README file that came with this library for more
   *  information, and read the inline documentation.
***************
*** 8,266 ****
   */
  
! /**
!  * CVSLib file class.
!  *
!  * @author  Anil Madhavapeddy <address@hidden>
!  * @version $Revision$
!  * @since   Chora 0.1
!  * @package chora
!  */
! class CVSLib_File {
!     var $rep, $dir, $name, $logs, $revs, $head, $flags, $symrev, $revsym, 
$branches;
! 
!     /**
!       * Create a repository file object, and give
!       * it information about what its parent directory
!       * and repository objects are
!       * @param rp The CVSLIB_Repository object this is part of
!       * @param fl Full path to this file
!       */
!     function CVSLib_File($rp, $fl, $flags= CVSLIB_LOG_FULL) {
!         $fl .= ',v';
!         $this->name = basename($fl);
!         $this->dir = dirname($fl);
!         $this->rep = $rp;
!         $this->logs = array();
!         $this->flags = $flags;
!         $this->revs = array();
!         $this->branches = array();
!     }
! 
!     /**
!       * Return what class this is for identification purposes
!       * @return CVSLIB_FILE constant
!       */
!     function id() {
!         return CVSLIB_FILE;
!     }
! 
!     /**
!       * If this file is present in an Attic directory, this indicates it
!       * @return true if file is in the Attic, and false otherwise
!       */
!     function isAtticFile() {
!         return substr($this->dir,-5) == 'Attic';
!     }
! 
!     /**
!       * Returns the name of the current file as in the repository
!       * @return Filename (without the path)
!       */
!     function queryRepositoryName() {
!         return $this->name;
!     }
! 
!     /**
!       * Returns name of the current file without the repository
!       * extensions (usually ,v)
!       * @return Filename without repository extension
!       */
! 
!     function queryName() {
!         return preg_replace('/,v$/', '', $this->name);
!     }
! 
!     /**
!       * Return the last revision of the current file
!       * on the HEAD branch
!       * @return Last revision of the current file
!       */
!     function queryRevision() {
!         return $this->revs[0];
!     }
! 
!     /** Return the HEAD revision number for this file
!       * @return HEAD revision number
!       */
!     function queryHead() {
!         return $this->head;
!     }
! 
!     /*
!      * Return the last CVSLib_Log object in the file
!      * @return CVSLib_Log of the last entry in the file
!      */
!     function queryLastLog() {
!         return $this->logs[$this->revs[0]];
!     }
! 
!     /* Sort the list of CVSLib_Log objects that this file contains
!      * @param how CVSLIB_SORT_REV (sort by revision), 
!      *            CVSLIB_SORT_NAME (sort by author name),
!      *            CVSLIB_SORT_AGE (sort by commit date)
!      */ 
!     function applySort($how = CVSLIB_SORT_REV) {
!         switch ($how) {
!         case CVSLIB_SORT_REV:
!             $func = 'Revision'; 
!             break;
!         case CVSLIB_SORT_NAME:
!             $func = 'Name';
!             break;
!         case CVSLIB_SORT_AGE:
!             $func = 'Age';
!             break;
!         default:
!             $func = 'Revision';
!         }
!         uasort($this->logs,array($this,"sortBy$func"));
!         return true;
!     } 
! 
!     /* The sortBy*() functions are internally used by applySort
!      */
!     function sortByRevision($a, $b) {
!         return CVSLib_Rev::cmp($b->rev,$a->rev);
!     }
! 
!     function sortByAge($a, $b) {
!         if ($a->date == $b->date) return 0;
!         return ($a->date < $b->date)?1:-1;
!     }
! 
!     function sortByName($a , $b) {
!         if ($a->author == $b->author) return 0;
!         return ($a->author < $b->author)?-1:1;
!     }
!  
!     /**
!       * Populate the object with information about the revisions
!       * logs and dates of the file
!       *
!       * @return CVSLib_Error object on error, or true on success
!       */
!     function getBrowseInfo() {
!         /* Check that we are actually in the filesystem */
!         if (!is_file($this->queryFullPath())) {
!             return new CVSLib_Error(CVSLIB_NOT_FOUND,'File Not Found');
!         }
! 
!         /* Call the RCS rlog command to retrieve the file information */
!         $flag = ($this->flags == CVSLIB_LOG_QUICK) ? ' -r ' : ' ';
!         $cmd = $this->rep->conf['paths']['rlog'] . $flag . 
escapeShellCmd($this->queryFullPath());
! 
!         /* Try and execute it, and retrieve the output into a variable */
!         if (!($pstream = popen($cmd, 'r'))) {
!              return new CVSLib_Error(CVSLIB_INTERNAL_ERROR,
!                "Failed to spawn rlog to retrieve file log information");
!         }
!         $accum = array();
!         $symrev = array();
!         $revsym = array();
!         $state = CVSLIB_LOG_INIT;
!         while ($line = fgets($pstream, 4096)) {
!             switch ($state) {
!             case CVSLIB_LOG_INIT:
!                 if (preg_match("/^head: (.*)$/",$line,$head)) {
!                     $this->head = $head[1];
!                 } else if (preg_match("/^branch:/",$line)) {
!                     $state=CVSLIB_LOG_REVISION;
!                 }
!                 break;
!             case CVSLIB_LOG_REVISION:
!                 if (preg_match("/^----------/",$line)) {
!                     $state = CVSLIB_LOG_INFO;
!                     $this->symrev = $symrev;
!                     $this->revsym = $revsym;
!                 } else if (preg_match("/^\s+([^:]+):\s+([\d\.]+)/", $line 
,$regs)) {
!                     /* Check to see if this is a branch */
!                     if (preg_match('/^(\d+(\.\d+)+)\.0\.(\d+)$/',$regs[2])) {
!                         $branchRev = CVSLib_Rev::toBranch($regs[2]);
!                         if (!isset($this->branches[$branchRev])) {
!                            $this->branches[$branchRev] = $regs[1];
!                         }
!                     } else {
!                         $symrev[$regs[1]] = $regs[2];
!                         if (empty($revsym[$regs[2]])) 
$revsym[$regs[2]]=array();
!                         array_push($revsym[$regs[2]],$regs[1]);
!                     }
!                 }
!                 break;
!             case CVSLIB_LOG_INFO:
!                if 
(!preg_match("/^----------------------------|^==============================/", 
$line)) {
!                    array_push($accum, $line);
!                } else if (sizeof($accum) > 0) {
!                    // spawn a new CVSLib_Log object and add it to the logs 
hash
!                    $log = new CVSLib_Log($this->rep, $this);
!                    $err = $log->processLog($accum);
!                    // TODO: error checks - avsm
!                    $this->logs[$log->queryRevision()] = $log;
!                    array_push($this->revs, $log->queryRevision());
!                    $accum = array();
!                }
!                break;
!             }
!         }
!         return true;
!     }
!   
!     /**
!       * Return a text description of how long its been since the
!       * file has been last modified.
!       *
!       * @param date Number of seconds since epoch we wish to display
!       * @param long If true, display a more verbose date
!       * @return String with the human-readable date
!       */
!     function readableTime($date, $long = false) {
!         $secs = time() - $date;
!         $i = 0;
!         $desc = array(1 => 'second',
!                       60 => 'minute',
!                       3600 => 'hour',
!                       86400 => 'day',
!                       604800 => 'week',
!                       2628000 => 'month',
!                       31536000 => 'year');
! 
!         if ($secs < 2) return "very little time";
! 
!         while (list($k,) = each($desc)) $breaks[] = $k;
!         sort($breaks);
! 
!         while ($i < count($breaks) && $secs >= (2 * $breaks[$i])) $i++;
!         $i--;
!         $break = $breaks[$i];
! 
!         $val = intval($secs / $break);
!         $retval = $val.' '.$desc[$break].($val>1?'s':'');
!         if ($long && $i > 0) {
!             $rest = $secs % $break;
!             $break = $breaks[--$i];
!             $rest = intval($rest/$break);
!             if ($rest > 0) {
!                 $resttime = $rest.' '.$desc[$break].($rest > 1?'s':'');
!                 $retval .= ", $resttime";
!             }
!         }
! 
!         return $retval;
!     }
! 
!     /**
!       * Return the fully qualified filename of this object
!       * @return Fully qualified filename of this object
!       */
!     function queryFullPath() {
!         return $this->dir."/".$this->name;
!     }
! 
!    /**
!      * Return the name of this file relative to its CVSROOT
!      * @return Pathname relative to CVSROOT
!      */
!     function queryModulePath() {
!         return preg_replace('|^'. $this->rep->cvsRoot() . '/?(.*),v$|', '\1', 
$this->queryFullPath());
!     }
! }
  ?>
--- 7,329 ----
   */
  
!       /**
!        * CVSLib file class.
!        *
!        * @author  Anil Madhavapeddy <address@hidden>
!        * @version $Revision$
!        * @since   Chora 0.1
!        * @package chora
!        */
!       class cvslib_file
!       {
!               var $rep, $dir, $name, $logs, $revs, $head, $flags, $symrev, 
$revsym, $branches;
! 
!               /**
!               * Create a repository file object, and give
!               * it information about what its parent directory
!               * and repository objects are
!               * @param rp The CVSLIB_Repository object this is part of
!               * @param fl Full path to this file
!               */
!               function cvslib_file($rp, $fl, $flags= CVSLIB_LOG_FULL)
!               {
!                       $fl .= ',v';
!                       $this->name = basename($fl);
!                       $this->dir = dirname($fl);
!                       $this->rep = $rp;
!                       $this->logs = array();
!                       $this->flags = $flags;
!                       $this->revs = array();
!                       $this->branches = array();
!               }
! 
!               /**
!               * Return what class this is for identification purposes
!               * @return CVSLIB_FILE constant
!               */
!               function id()
!               {
!                       return CVSLIB_FILE;
!               }
! 
!               /**
!               * If this file is present in an Attic directory, this indicates 
it
!               * @return true if file is in the Attic, and false otherwise
!               */
!               function isAtticFile()
!               {
!                       return substr($this->dir,-5) == 'Attic';
!               }
! 
!               /**
!               * Returns the name of the current file as in the repository
!               * @return Filename (without the path)
!               */
!               function queryRepositoryName()
!               {
!                       return $this->name;
!               }
! 
!               /**
!               * Returns name of the current file without the repository
!               * extensions (usually ,v)
!               * @return Filename without repository extension
!               */
! 
!               function queryName()
!               {
!                       return preg_replace('/,v$/', '', $this->name);
!               }
! 
!               /**
!               * Return the last revision of the current file
!               * on the HEAD branch
!               * @return Last revision of the current file
!               */
!               function queryRevision()
!               {
!                       return $this->revs[0];
!               }
! 
!               /** Return the HEAD revision number for this file
!               * @return HEAD revision number
!               */
!               function queryHead()
!               {
!                       return $this->head;
!               }
! 
!               /*
!               * Return the last CVSLib_Log object in the file
!               * @return CVSLib_Log of the last entry in the file
!               */
!               function queryLastLog()
!               {
!                       return $this->logs[$this->revs[0]];
!               }
! 
!               /* Sort the list of CVSLib_Log objects that this file contains
!               * @param how CVSLIB_SORT_REV (sort by revision), 
!               *            CVSLIB_SORT_NAME (sort by author name),
!               *            CVSLIB_SORT_AGE (sort by commit date)
!               */ 
!               function applySort($how = CVSLIB_SORT_REV)
!               {
!                       switch ($how)
!                       {
!                               case CVSLIB_SORT_REV:
!                                       $func = 'Revision'; 
!                                       break;
!                               case CVSLIB_SORT_NAME:
!                                       $func = 'Name';
!                                       break;
!                               case CVSLIB_SORT_AGE:
!                                       $func = 'Age';
!                                       break;
!                               default:
!                                       $func = 'Revision';
!                       }
!                       uasort($this->logs,array($this,"sortBy$func"));
!                       return true;
!               } 
! 
!               /* The sortBy*() functions are internally used by applySort
!               */
!               function sortByRevision($a, $b)
!               {
!                       return CVSLib_Rev::cmp($b->rev,$a->rev);
!               }
! 
!               function sortByAge($a, $b)
!               {
!                       if ($a->date == $b->date)
!                       {
!                               return 0;
!                       }
!                       return ($a->date < $b->date)?1:-1;
!               }
! 
!               function sortByName($a , $b)
!               {
!                       if ($a->author == $b->author)
!                       {
!                               return 0;
!                       }
!                       return ($a->author < $b->author)?-1:1;
!               }
! 
!               /**
!               * Populate the object with information about the revisions
!               * logs and dates of the file
!               *
!               * @return CVSLib_Error object on error, or true on success
!               */
!               function getBrowseInfo()
!               {
!                       /* Check that we are actually in the filesystem */
!                       if(!is_file($this->queryFullPath()))
!                       {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_NOT_FOUND,
!                                       'File Not Found'
!                               );
!                       }
! 
!                       /* Call the RCS rlog command to retrieve the file 
information */
!                       $flag = ($this->flags == CVSLIB_LOG_QUICK) ? ' -r ' : ' 
';
!                       $cmd = $this->rep->conf['paths']['rlog'] . $flag . 
escapeShellCmd($this->queryFullPath());
! 
!                       /* Try and execute it, and retrieve the output into a 
variable */
!                       if(!($pstream = popen($cmd, 'r')))
!                       {
!                               return CreateObject(
!                                       'chora.cvslib_error',
!                                       CVSLIB_INTERNAL_ERROR,
!                                       'Failed to spawn rlog to retrieve file 
log information'
!                               );
!                       }
!                       $accum = array();
!                       $symrev = array();
!                       $revsym = array();
!                       $state = CVSLIB_LOG_INIT;
!                       while($line = fgets($pstream, 4096))
!                       {
!                               switch($state)
!                               {
!                                       case CVSLIB_LOG_INIT:
!                                               if(preg_match("/^head: 
(.*)$/",$line,$head))
!                                               {
!                                                       $this->head = $head[1];
!                                               }
!                                               
elseif(preg_match("/^branch:/",$line))
!                                               {
!                                                       
$state=CVSLIB_LOG_REVISION;
!                                               }
!                                               break;
!                                       case CVSLIB_LOG_REVISION:
!                                               
if(preg_match("/^----------/",$line))
!                                               {
!                                                       $state = 
CVSLIB_LOG_INFO;
!                                                       $this->symrev = $symrev;
!                                                       $this->revsym = $revsym;
!                                               }
!                                               
elseif(preg_match("/^\s+([^:]+):\s+([\d\.]+)/", $line ,$regs))
!                                               {
!                                                       /* Check to see if this 
is a branch */
!                                                       
if(preg_match('/^(\d+(\.\d+)+)\.0\.(\d+)$/',$regs[2]))
!                                                       {
!                                                               $branchRev = 
ExecMethod('chora.cvslib_rev.toBranch',$regs[2]);
!                                                               
if(!isset($this->branches[$branchRev]))
!                                                               {
!                                                                       
$this->branches[$branchRev] = $regs[1];
!                                                               }
!                                                       }
!                                                       else
!                                                       {
!                                                               
$symrev[$regs[1]] = $regs[2];
!                                                               
if(empty($revsym[$regs[2]]))
!                                                               {
!                                                                       
$revsym[$regs[2]]=array();
!                                                               }
!                                                               
array_push($revsym[$regs[2]],$regs[1]);
!                                                       }
!                                               }
!                                               break;
!                                       case CVSLIB_LOG_INFO:
!                                               
if(!preg_match("/^----------------------------|^==============================/",
 $line))
!                                               {
!                                                       array_push($accum, 
$line);
!                                               }
!                                               elseif(sizeof($accum) > 0)
!                                               {
!                                                       // spawn a new 
cvslib_log object and add it to the logs hash
!                                                       $log = 
CreateObject('chora.cvslib_log', $this->rep, $this);
!                                                       $err = 
$log->processLog($accum);
!                                                       // TODO: error checks - 
avsm
!                                                       
$this->logs[$log->queryRevision()] = $log;
!                                                       array_push($this->revs, 
$log->queryRevision());
!                                                       $accum = array();
!                                               }
!                                               break;
!                               }
!                       }
!                       return true;
!               }
! 
!               /**
!               * Return a text description of how long its been since the
!               * file has been last modified.
!               *
!               * @param date Number of seconds since epoch we wish to display
!               * @param long If true, display a more verbose date
!               * @return String with the human-readable date
!               */
!               function readableTime($date, $long = false)
!               {
!                       $secs = time() - $date;
!                       $i = 0;
!                       $desc = array(
!                               1        => 'second',
!                               60       => 'minute',
!                               3600     => 'hour',
!                               86400    => 'day',
!                               604800   => 'week',
!                               2628000  => 'month',
!                               31536000 => 'year'
!                       );
! 
!                       if($secs < 2)
!                       {
!                               return lang('very little time');
!                       }
! 
!                       while(list($k,) = each($desc))
!                       {
!                               $breaks[] = $k;
!                       }
!                       sort($breaks);
! 
!                       while($i < count($breaks) && $secs >= (2 * $breaks[$i]))
!                       {
!                               $i++;
!                       }
!                       $i--;
!                       $break = $breaks[$i];
! 
!                       $val = intval($secs / $break);
!                       $retval = $val . ' ' . $desc[$break] . ($val>1 ? 's' : 
'');
!                       if($long && $i > 0)
!                       {
!                               $rest = $secs % $break;
!                               $break = $breaks[--$i];
!                               $rest = intval($rest/$break);
!                               if($rest > 0)
!                               {
!                                       $resttime = $rest . ' ' . $desc[$break] 
. ($rest > 1 ? 's' : '');
!                                       $retval .= ", $resttime";
!                               }
!                       }
! 
!                       return $retval;
!               }
! 
!               /**
!               * Return the fully qualified filename of this object
!               * @return Fully qualified filename of this object
!               */
!               function queryFullPath()
!               {
!                       return $this->dir . '/' . $this->name;
!               }
! 
!               /**
!               * Return the name of this file relative to its CVSROOT
!               * @return Pathname relative to CVSROOT
!               */
!               function queryModulePath()
!               {
!                       return preg_replace('|^'. $this->rep->cvsRoot() . 
'/?(.*),v$|', '\1', $this->queryFullPath());
!               }
!       }
  ?>

Index: class.cvslib_rev.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/class.cvslib_rev.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.cvslib_rev.inc.php    28 Apr 2002 18:09:06 -0000      1.1
--- class.cvslib_rev.inc.php    28 Apr 2002 19:26:40 -0000      1.2
***************
*** 1,4 ****
  <?php
- 
  /*  See the README file that came with this library for more
   *  information, and read the inline documentation.
--- 1,3 ----
***************
*** 8,137 ****
   */
  
! /**
!  * CVSLib revisions class.
!  *
!  * @author  Anil Madhavapeddy <address@hidden>
!  * @version $Revision$
!  * @since   Chora 0.1
!  * @package chora
!  */
! class CVSLib_Rev {
! 
!     /*
!      * Validation function to ensure that a revision number is
!      * of the right form
!      * @param val Value to check.
!      * @return boolean true if it is a revision number
!      */
!     function valid($val) {
!         return $val && preg_match('/^[\d\.]+$/',$val);
!     }
! 
!     /*
!      * Given a revision number, remove a given number
!      * of portions from it.  For example, if we remove
!      * 2 portions of 1.2.3.4, we are left with 1.2
!      * @param val input revision
!      * @param amount number of portions to strip
!      * @return stripped revision number
!      */
!     function strip($val, $amount) {
!         if (!CVSLib_Rev::valid($val)) return false;
!         $revs = explode('.',$val);
!         while ($amount--) array_pop($revs);
!         return implode('.',$revs);
!     }
! 
!     /*
!      * The size of a revision number is the number
!      * of portions it has.   For example, 1,2.3.4
!      * is of size 4.
!      * @param input revision number to determine size of
!      * @param size of revision number
!      */
!     function sizeof($val) {
!         if (!CVSLib_Rev::valid($val)) return false;
!         return sizeof(explode('.',$val));
!     }
!  
!     /*
!      * Given a valid revision number, this will 
!      * return the revision number from which it 
!      * branched.  If it cannot be determined, then
!      * false is returned.
!      * @param input revision number
!      * @return branch point revision, or false
!      */
!     function branchPoint($val) {
!         /* Check if we have a valid revision number */
!         if (!CVSLib_Rev::valid($val)) return false;
!         /* If its on the trunk, or is an odd size, ret false */
!         if (CVSLib_Rev::sizeof($val)<3 || (CVSLib_Rev::sizeof($val)%2)) 
return false;
!         /* Strip off two revision portions, and return it */
!         return CVSLib_Rev::strip($val, 2); 
!     }
! 
!     /**
!       * Compare two input numbers, and return an integer
!       * with the sign of their difference.
!       * @param a The first input number
!       * @param b The second input number
!       * @return -1,0,1 depending on the sign of their difference
!       */
!     function numrel ($a, $b) {
!         if ($a < $b) {
!             return -1;
!         } else if ($a == $b) {
!             return 0;
!         } else {
!             return 1;
!         }
!     }
! 
!     /**
!       * Given two CVS revision numbers, this figures out which
!       * one is greater than the other by stepping along the
!       * decimal points until a difference is found, at which
!       * point a sign comparison of the two is returned.
!       *
!       * @param rev1 Period delimited revision number
!       * @param rev2 Second period delimited revision number
!       * @see numrel
!       * @return 1 if the first is greater, -1 if the second if greater,
!       *         and 0 if they are equal
!       */
!     function cmp ($rev1, $rev2) {
!         $r1 = explode('.', $rev1);
!         $r2 = explode('.', $rev2);
!         while (($a = array_shift($r1)) && ($b = array_shift($r2))) {
!             if ($a != $b) {
!                 return CVSLib_Rev::numrel($a, $b);
!             }
!         }
! 
!         if ($r1) { 
!             return 1; 
!         } else if ($r2) { 
!             return -1; 
!         } else {
!             return 0;
!         }
!     }
! 
!     /*
!      * Given a revision number of the form x.y.0.z, this remaps it
!      * into the appropriate branch number, which is x.y.z
!      * @param $rev Even-digit revision number of a branch
!      * @return Odd-digit Branch number
!      */
!     function toBranch($rev) {
!         /* Check if we have a valid revision number */
!         if (!CVSLib_Rev::valid($rev)) return false;
!        
!         $parts = explode('.',$rev);
!         $last = array_splice($parts, -2);
!         $parts[] = $last[1];
!         return implode('.',$parts);
!     }
! 
! }
--- 7,172 ----
   */
  
!       /**
!       * CVSLib revisions class.
!       *
!       * @author  Anil Madhavapeddy <address@hidden>
!       * @version $Revision$
!       * @since   Chora 0.1
!       * @package chora
!       */
!       class CVSLib_Rev
!       {
!               /*
!               * Validation function to ensure that a revision number is
!               * of the right form
!               * @param val Value to check.
!               * @return boolean true if it is a revision number
!               */
!               function valid($val)
!               {
!                       return $val && preg_match('/^[\d\.]+$/',$val);
!               }
! 
!               /*
!               * Given a revision number, remove a given number
!               * of portions from it.  For example, if we remove
!               * 2 portions of 1.2.3.4, we are left with 1.2
!               * @param val input revision
!               * @param amount number of portions to strip
!               * @return stripped revision number
!               */
!               function strip($val, $amount)
!               {
!                       if(!$this->valid($val))
!                       {
!                               return False;
!                       }
!                       $revs = explode('.',$val);
!                       while ($amount--) array_pop($revs);
!                       return implode('.',$revs);
!               }
! 
!               /*
!               * The size of a revision number is the number
!               * of portions it has.   For example, 1,2.3.4
!               * is of size 4.
!               * @param input revision number to determine size of
!               * @param size of revision number
!               */
!               function sizeof($val)
!               {
!                       if(!$this->valid($val))
!                       {
!                               return False;
!                       }
!                       return sizeof(explode('.',$val));
!               }
! 
!               /*
!               * Given a valid revision number, this will 
!               * return the revision number from which it 
!               * branched.  If it cannot be determined, then
!               * false is returned.
!               * @param input revision number
!               * @return branch point revision, or false
!               */
!               function branchPoint($val)
!               {
!                       /* Check if we have a valid revision number */
!                       if(!$this->valid($val))
!                       {
!                               return False;
!                       }
! 
!                       /* If its on the trunk, or is an odd size, ret false */
!                       if($this->sizeof($val) < 3 || ($this->sizeof($val)%2))
!                       {
!                               return False;
!                       }
! 
!                       /* Strip off two revision portions, and return it */
!                       return $this->strip($val, 2); 
!               }
! 
!               /**
!               * Compare two input numbers, and return an integer
!               * with the sign of their difference.
!               * @param a The first input number
!               * @param b The second input number
!               * @return -1,0,1 depending on the sign of their difference
!               */
!               function numrel($a, $b)
!               {
!                       if($a < $b)
!                       {
!                               return -1;
!                       }
!                       elseif($a == $b)
!                       {
!                               return 0;
!                       }
!                       else
!                       {
!                               return 1;
!                       }
!               }
! 
!               /**
!               * Given two CVS revision numbers, this figures out which
!               * one is greater than the other by stepping along the
!               * decimal points until a difference is found, at which
!               * point a sign comparison of the two is returned.
!               *
!               * @param rev1 Period delimited revision number
!               * @param rev2 Second period delimited revision number
!               * @see numrel
!               * @return 1 if the first is greater, -1 if the second if 
greater,
!               *         and 0 if they are equal
!               */
!               function cmp ($rev1, $rev2)
!               {
!                       $r1 = explode('.', $rev1);
!                       $r2 = explode('.', $rev2);
!                       while (($a = array_shift($r1)) && ($b = 
array_shift($r2)))
!                       {
!                               if($a != $b)
!                               {
!                                       return $this->numrel($a, $b);
!                               }
!                       }
! 
!                       if($r1)
!                       { 
!                               return 1; 
!                       }
!                       elseif($r2)
!                       {
!                               return -1; 
!                       }
!                       else
!                       {
!                               return 0;
!                       }
!               }
! 
!               /*
!               * Given a revision number of the form x.y.0.z, this remaps it
!               * into the appropriate branch number, which is x.y.z
!               * @param $rev Even-digit revision number of a branch
!               * @return Odd-digit Branch number
!               */
!               function toBranch($rev)
!               {
!                       /* Check if we have a valid revision number */
!                       if(!$this->valid($rev))
!                       {
!                               return False;
!                       }
! 
!                       $parts = explode('.',$rev);
!                       $last = array_splice($parts, -2);
!                       $parts[] = $last[1];
!                       return implode('.',$parts);
!               }
!       }
! ?>

Index: functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/chora/inc/functions.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** functions.inc.php   20 Sep 2001 21:50:06 -0000      1.9
--- functions.inc.php   28 Apr 2002 19:26:40 -0000      1.10
***************
*** 91,95 ****
        );
  
!       include(PHPGW_APP_INC  . '/version.php');
  
        /* Variable we wish to propagate across web pages
--- 91,95 ----
        );
  
!       define('CHORA_VERSION', '0.4.2-cvs');
  
        /* Variable we wish to propagate across web pages
***************
*** 120,126 ****
        /* See if any have been passed as GET variables, and if
         * so, assign them into the acts array */
!       while (list($key,)=each($acts))
        {
!               if (!empty($$key))
                {
                        $acts[$key]=$$key;
--- 120,126 ----
        /* See if any have been passed as GET variables, and if
         * so, assign them into the acts array */
!       while(list($key,)=each($acts))
        {
!               if(!empty($$key))
                {
                        $acts[$key]=$$key;
***************
*** 143,147 ****
        $conf['options']['cvsRootName'] = $cvsrootopts['name'];
  
-       //$CVS = new CVSLib($conf, $mime);
        $CVS = CreateObject('chora.cvslib',$conf,$mime);
  
--- 143,146 ----
***************
*** 156,162 ****
                @reset($GLOBALS['acts']);
                $ret = array();
!               while (list($key,$val) = @each($GLOBALS['acts']))
                {
!                       if ($val != $GLOBALS['defaultActs'][$key])
                        {
                                $ret[$key]=$val;
--- 155,161 ----
                @reset($GLOBALS['acts']);
                $ret = array();
!               while(list($key,$val) = @each($GLOBALS['acts']))
                {
!                       if($val != $GLOBALS['defaultActs'][$key])
                        {
                                $ret[$key]=$val;
***************
*** 198,202 ****
        * @return The processed text with <A HREF> tags
        */
!       function htmlify ($text)
        {
                /* TODO: cleanup all this - avsm */
--- 197,201 ----
        * @return The processed text with <A HREF> tags
        */
!       function htmlify($text)
        {
                /* TODO: cleanup all this - avsm */
***************
*** 211,215 ****
        function showAuthorName($name, $fullname=false)
        {
!               if (!isset($GLOBALS['cvsusers']))
                {
                        $cvsusers = $GLOBALS['CVS']->parseCVSUsers();
--- 210,214 ----
        function showAuthorName($name, $fullname=false)
        {
!               if(!isset($GLOBALS['cvsusers']))
                {
                        $cvsusers = $GLOBALS['CVS']->parseCVSUsers();
***************
*** 220,224 ****
                }
  
!               if (is_array($cvsusers) && isset($cvsusers[$name]))
                {
                        return '<a 
href="mailto:'.$cvsusers[$name]['mail'].'">'.($fullname?$cvsusers[$name]['name']:$name).'</a>'.($fullname?"
 <i>($name)</i>":'');
--- 219,223 ----
                }
  
!               if(is_array($cvsusers) && isset($cvsusers[$name]))
                {
                        return '<a 
href="mailto:'.$cvsusers[$name]['mail'].'">'.($fullname?$cvsusers[$name]['name']:$name).'</a>'.($fullname?"
 <i>($name)</i>":'');
***************
*** 236,240 ****
        * @param errmsg The verbose error message to be displayed
        */
!       function fatal ($errcode, $errmsg)
        {
                //header("Status: $errcode");
--- 235,239 ----
        * @param errmsg The verbose error message to be displayed
        */
!       function fatal($errcode, $errmsg)
        {
                //header("Status: $errcode");
***************
*** 251,255 ****
        function checkError($e)
        {
!               if (is_object($e) && $e->id()==CVSLIB_ERROR)
                {
                        fatal($e->error_header(), $e->error_body());
--- 250,254 ----
        function checkError($e)
        {
!               if(is_object($e) && $e->id()==CVSLIB_ERROR)
                {
                        fatal($e->error_header(), $e->error_body());
***************
*** 263,267 ****
                while(list($key,$val) = @each($GLOBALS['cvsroots']))
                {
!                       if ($cvsroot != $val['location'])
                        {
                                $arg = (($GLOBALS['defaultActs']['rt'] == 
$key)?'':$key);
--- 262,266 ----
                while(list($key,$val) = @each($GLOBALS['cvsroots']))
                {
!                       if($cvsroot != $val['location'])
                        {
                                $arg = (($GLOBALS['defaultActs']['rt'] == 
$key)?'':$key);
***************
*** 270,274 ****
                }
  
!               if (sizeof($arr))
                {
                        return 'Other Repositories: '.implode(' , ', $arr);
--- 269,273 ----
                }
  
!               if(sizeof($arr))
                {
                        return 'Other Repositories: '.implode(' , ', $arr);
***************
*** 287,298 ****
                $argarr = array();
  
!               while (list($key, $val)=each($arglist))
                {
!                       if ($val)
                        {
                                $argarr[] = $key . '=' . $val;
                        }
                }
!               if (sizeof($argarr)>0)
                {
                        $url = $url . '?' . implode('&',$argarr);
--- 286,297 ----
                $argarr = array();
  
!               while(list($key, $val)=each($arglist))
                {
!                       if($val)
                        {
                                $argarr[] = $key . '=' . $val;
                        }
                }
!               if(sizeof($argarr)>0)
                {
                        $url = $url . '?' . implode('&',$argarr);
***************
*** 304,313 ****
                }
  
!               if (!empty($implodedQuery))
                {
                        $url = $url . $glue . $implodedQuery;
                }
  
!               if (!empty($anchor))
                {
                        $url .= '#' . $anchor;
--- 303,312 ----
                }
  
!               if(!empty($implodedQuery))
                {
                        $url = $url . $glue . $implodedQuery;
                }
  
!               if(!empty($anchor))
                {
                        $url .= '#' . $anchor;

--- CVSLib.php DELETED ---

--- version.php DELETED ---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]