3 // +------------------------------------------------------------------------+
\r
5 // +------------------------------------------------------------------------+
\r
6 // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver |
\r
7 // | Email jeichorn@phpdoc.org, cellog@phpdoc.org |
\r
8 // | Web http://www.phpdoc.org |
\r
9 // | Mirror http://phpdocu.sourceforge.net/ |
\r
10 // | PEAR http://pear.php.net/package/PhpDocumentor |
\r
11 // +------------------------------------------------------------------------+
\r
12 // | This source file is subject to version 3.00 of the PHP License, |
\r
13 // | that is available at http://www.php.net/license/3_0.txt. |
\r
14 // | If you did not receive a copy of the PHP license and are unable to |
\r
15 // | obtain it through the world-wide-web, please send a note to |
\r
16 // | license@php.net so we can mail you a copy immediately. |
\r
17 // +------------------------------------------------------------------------+
\r
20 * CVS file adding iterator
\r
22 * This file iterates over a directory, and adds everything to CVS that is
\r
23 * found, ignoring any error messages, until all files in each directory
\r
24 * and subdirectory have been added to cvs. It then commits the files to cvs
\r
25 * @package phpDocumentor
\r
26 * @author Greg Beaver <cellog@php.net>
\r
27 * @copyright Copyright 2003, Greg Beaver
\r
31 * phpDocumentor include files. If you don't have phpDocumentor, go get it!
\r
32 * Your php life will be changed forever
\r
34 $dir = realpath(dirname(__FILE__).'/..');
\r
35 require_once("$dir/phpDocumentor/common.inc.php");
\r
36 require_once("$dir/phpDocumentor/Io.inc");
\r
40 * Physical location on this computer of the package to parse
\r
41 * @global string $cvsadd_directory
\r
43 $cvsadd_directory = realpath('.');
\r
45 * Comma-separated list of files and directories to ignore
\r
47 * This uses wildcards * and ? to remove extra files/directories that are
\r
48 * not part of the package or release
\r
49 * @global string $ignore
\r
51 $ignore = array('CVS/');
\r
53 /******************************************************************************
\r
54 * Don't change anything below here unless you're adventuresome *
\r
55 *******************************************************************************/
\r
62 $allfiles = $files->dirList($cvsadd_directory);
\r
64 * Sorting functions for the file list
\r
68 function sortfiles($a, $b)
\r
70 return strnatcasecmp($a['file'],$b['file']);
\r
73 function mystrucsort($a, $b)
\r
75 if (is_numeric($a) && is_string($b)) return 1;
\r
76 if (is_numeric($b) && is_string($a)) return -1;
\r
77 if (is_numeric($a) && is_numeric($b))
\r
79 if ($a > $b) return 1;
\r
80 if ($a < $b) return -1;
\r
81 if ($a == $b) return 0;
\r
83 return strnatcasecmp($a,$b);
\r
88 foreach($allfiles as $file)
\r
90 if ($files->checkIgnore(basename($file),dirname($file),$ignore, false))
\r
92 // print 'Ignoring '.$file."<br>\n";
\r
95 $path = substr(dirname($file),strlen(str_replace('\\','/',realpath($cvsadd_directory)))+1);
\r
96 if (!$path) $path = '/';
\r
97 $file = basename($file);
\r
98 $ext = array_pop(explode('.',$file));
\r
99 if (strlen($ext) == strlen($file)) $ext = '';
\r
100 $struc[$path][] = array('file' => $file,'ext' => $ext);
\r
102 uksort($struc,'strnatcasecmp');
\r
103 foreach($struc as $key => $ind)
\r
105 usort($ind,'sortfiles');
\r
106 $struc[$key] = $ind;
\r
108 $tempstruc = $struc;
\r
109 $struc = array('/' => $tempstruc['/']);
\r
111 foreach($tempstruc as $key => $ind)
\r
116 $struc['/'] = setup_dirs($struc['/'], explode('/',$key), $tempstruc[$key]);
\r
119 uksort($struc['/'],'mystrucsort');
\r
121 * Recursively add files to cvs
\r
122 * @param array the sorted directory structure
\r
124 function addToCVS($struc)
\r
126 foreach($struc as $dir => $files)
\r
130 print 'processing '.$dir . "\n";
\r
131 addToCVS($struc[$dir]);
\r
135 if (!isset($files['file']))
\r
137 print 'adding '.$dir . "\n";
\r
138 system('cvs add '.$dir);
\r
144 print 'adding '.$files['file'] . "\n";
\r
145 system('cvs add '.$files['file']);
\r
146 system('cvs commit -m "" '.$files['file']);
\r