| 1 |
lars |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// +------------------------------------------------------------------------+
|
|
|
4 |
// | phpDocumentor |
|
|
|
5 |
// +------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver |
|
|
|
7 |
// | Email jeichorn@phpdoc.org, cellog@phpdoc.org |
|
|
|
8 |
// | Web http://www.phpdoc.org |
|
|
|
9 |
// | Mirror http://phpdocu.sourceforge.net/ |
|
|
|
10 |
// | PEAR http://pear.php.net/package/PhpDocumentor |
|
|
|
11 |
// +------------------------------------------------------------------------+
|
|
|
12 |
// | This source file is subject to version 3.00 of the PHP License, |
|
|
|
13 |
// | that is available at http://www.php.net/license/3_0.txt. |
|
|
|
14 |
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
15 |
// | obtain it through the world-wide-web, please send a note to |
|
|
|
16 |
// | license@php.net so we can mail you a copy immediately. |
|
|
|
17 |
// +------------------------------------------------------------------------+
|
|
|
18 |
//
|
|
|
19 |
/**
|
|
|
20 |
* CVS file adding iterator
|
|
|
21 |
*
|
|
|
22 |
* This file iterates over a directory, and adds everything to CVS that is
|
|
|
23 |
* found, ignoring any error messages, until all files in each directory
|
|
|
24 |
* and subdirectory have been added to cvs. It then commits the files to cvs
|
|
|
25 |
* @package phpDocumentor
|
|
|
26 |
* @author Greg Beaver <cellog@php.net>
|
|
|
27 |
* @copyright Copyright 2003, Greg Beaver
|
|
|
28 |
* @version 1.0
|
|
|
29 |
*/
|
|
|
30 |
/**#@+
|
|
|
31 |
* phpDocumentor include files. If you don't have phpDocumentor, go get it!
|
|
|
32 |
* Your php life will be changed forever
|
|
|
33 |
*/
|
|
|
34 |
$dir = realpath(dirname(__FILE__).'/..');
|
|
|
35 |
require_once("$dir/phpDocumentor/common.inc.php");
|
|
|
36 |
require_once("$dir/phpDocumentor/Io.inc");
|
|
|
37 |
/**#@-*/
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Physical location on this computer of the package to parse
|
|
|
41 |
* @global string $cvsadd_directory
|
|
|
42 |
*/
|
|
|
43 |
$cvsadd_directory = realpath('.');
|
|
|
44 |
/**
|
|
|
45 |
* Comma-separated list of files and directories to ignore
|
|
|
46 |
*
|
|
|
47 |
* This uses wildcards * and ? to remove extra files/directories that are
|
|
|
48 |
* not part of the package or release
|
|
|
49 |
* @global string $ignore
|
|
|
50 |
*/
|
|
|
51 |
$ignore = array('CVS/');
|
|
|
52 |
|
|
|
53 |
/******************************************************************************
|
|
|
54 |
* Don't change anything below here unless you're adventuresome *
|
|
|
55 |
*******************************************************************************/
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* @global Io $files
|
|
|
59 |
*/
|
|
|
60 |
$files = new Io;
|
|
|
61 |
|
|
|
62 |
$allfiles = $files->dirList($cvsadd_directory);
|
|
|
63 |
/**#@+
|
|
|
64 |
* Sorting functions for the file list
|
|
|
65 |
* @param string
|
|
|
66 |
* @param string
|
|
|
67 |
*/
|
|
|
68 |
function sortfiles($a, $b)
|
|
|
69 |
{
|
|
|
70 |
return strnatcasecmp($a['file'],$b['file']);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
function mystrucsort($a, $b)
|
|
|
74 |
{
|
|
|
75 |
if (is_numeric($a) && is_string($b)) return 1;
|
|
|
76 |
if (is_numeric($b) && is_string($a)) return -1;
|
|
|
77 |
if (is_numeric($a) && is_numeric($b))
|
|
|
78 |
{
|
|
|
79 |
if ($a > $b) return 1;
|
|
|
80 |
if ($a < $b) return -1;
|
|
|
81 |
if ($a == $b) return 0;
|
|
|
82 |
}
|
|
|
83 |
return strnatcasecmp($a,$b);
|
|
|
84 |
}
|
|
|
85 |
/**#@-*/
|
|
|
86 |
|
|
|
87 |
$struc = array();
|
|
|
88 |
foreach($allfiles as $file)
|
|
|
89 |
{
|
|
|
90 |
if ($files->checkIgnore(basename($file),dirname($file),$ignore, false))
|
|
|
91 |
{
|
|
|
92 |
// print 'Ignoring '.$file."<br>\n";
|
|
|
93 |
continue;
|
|
|
94 |
}
|
|
|
95 |
$path = substr(dirname($file),strlen(str_replace('\\','/',realpath($cvsadd_directory)))+1);
|
|
|
96 |
if (!$path) $path = '/';
|
|
|
97 |
$file = basename($file);
|
|
|
98 |
$ext = array_pop(explode('.',$file));
|
|
|
99 |
if (strlen($ext) == strlen($file)) $ext = '';
|
|
|
100 |
$struc[$path][] = array('file' => $file,'ext' => $ext);
|
|
|
101 |
}
|
|
|
102 |
uksort($struc,'strnatcasecmp');
|
|
|
103 |
foreach($struc as $key => $ind)
|
|
|
104 |
{
|
|
|
105 |
usort($ind,'sortfiles');
|
|
|
106 |
$struc[$key] = $ind;
|
|
|
107 |
}
|
|
|
108 |
$tempstruc = $struc;
|
|
|
109 |
$struc = array('/' => $tempstruc['/']);
|
|
|
110 |
$bv = 0;
|
|
|
111 |
foreach($tempstruc as $key => $ind)
|
|
|
112 |
{
|
|
|
113 |
$save = $key;
|
|
|
114 |
if ($key != '/')
|
|
|
115 |
{
|
|
|
116 |
$struc['/'] = setup_dirs($struc['/'], explode('/',$key), $tempstruc[$key]);
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
uksort($struc['/'],'mystrucsort');
|
|
|
120 |
/**
|
|
|
121 |
* Recursively add files to cvs
|
|
|
122 |
* @param array the sorted directory structure
|
|
|
123 |
*/
|
|
|
124 |
function addToCVS($struc)
|
|
|
125 |
{
|
|
|
126 |
foreach($struc as $dir => $files)
|
|
|
127 |
{
|
|
|
128 |
if ($dir === '/')
|
|
|
129 |
{
|
|
|
130 |
print 'processing '.$dir . "\n";
|
|
|
131 |
addToCVS($struc[$dir]);
|
|
|
132 |
return;
|
|
|
133 |
} else
|
|
|
134 |
{
|
|
|
135 |
if (!isset($files['file']))
|
|
|
136 |
{
|
|
|
137 |
print 'adding '.$dir . "\n";
|
|
|
138 |
system('cvs add '.$dir);
|
|
|
139 |
chdir($dir);
|
|
|
140 |
addToCVS($files);
|
|
|
141 |
chdir('..');
|
|
|
142 |
} else
|
|
|
143 |
{
|
|
|
144 |
print 'adding '.$files['file'] . "\n";
|
|
|
145 |
system('cvs add '.$files['file']);
|
|
|
146 |
system('cvs commit -m "" '.$files['file']);
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
addToCVS($struc);
|
|
|
152 |
print "\n".'done';
|
|
|
153 |
?>
|