File: cvslist.php

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (232 lines) | stat: -rw-r--r-- 5,966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
/*
  +----------------------------------------------------------------------+
  | PHP Version 4                                                        |
  +----------------------------------------------------------------------+
  | Copyright (c) 1997-2010 The PHP Group                                |
  +----------------------------------------------------------------------+
  | This source file is subject to version 3.0 of the PHP license,       |
  | that is bundled with this package in the file LICENSE, and is        |
  | available through the world-wide-web at the following url:           |
  | http://www.php.net/license/3_0.txt.                                  |
  | If you did not receive a copy of the PHP license and are unable to   |
  | obtain it through the world-wide-web, please send a note to          |
  | license@php.net so we can mail you a copy immediately.               |
  +----------------------------------------------------------------------+
  | Authors : Salah Faya <visualmind@php.net>                            |
  +----------------------------------------------------------------------+

  $Id: cvslist.php 293138 2010-01-05 10:21:11Z rquadling $
*/
//-- The PHPDOC Online XML Editing Tool 
//--- Purpose: lists the folders and files in the left frame

//------- Initialization
require 'base.php';
$user = sessionCheck();

$lang = $user['phpdocLang'];
$translationPath = $phpdocLangs[$lang]['DocCVSPath'];

//------- Folder navigation vars
$path = '';
$file = '';
if (isset($_REQUEST['path'])) {
	$path = $_REQUEST['path'];
	if (isset($_REQUEST['file'])) {
		$file = $_REQUEST['file'];
	}
}

// Prevent wrong paths 
if (strstr($path, '.') || $file=='..' || $file=='.') {
	exit;
}


// Path Slashes
if (!$path) $path = '/';
if (substr($path, -1)!='/') $path .= '/';


// Usually, the path are based on english cvs
$target = CVS_ROOT_PATH . 'en/' . $path . $file;


//------- Decide what to do

// If file is selected, redirect to the editor..

if ($file) {
	// Find in user path first (editing cached file by default)
	$ffile = $user['cache'].getCacheName($path.$file);
	if (file_exists($ffile)) {
		header("location: editxml.php?file=$path$file&source=upath");
		exit;
	}

	// Find in translated path (edit the translated file)
	$ffile = "$translationPath$path$file";
	if (file_exists($ffile)) {
		header("location: editxml.php?file=$path$file&source=apath");
		exit;
	}

	// So it's a new file? Use the english source
	if (file_exists($target)) {
		header("location: editxml.php?file=$path$file&source=epath");
		exit;
	}
} else {

	// No file selected, Listing (from english cvs)
	$d = opendir($target);
	while($f = readdir($d)) {
		if (is_dir($target.$f)) {
			if (in_array($f, $ignoreListingFolders)) continue;
			$dirs[] = $f;
		} elseif ((substr($f, -4)=='.xml' || substr($f, -4)=='.ent') && !in_array($f, $ignoreListingFiles)) {
			$files[] = $f;
		}
	}

}


//------- Functions 
function printPathAsLinks($path) {
	global $lang;

	$px = explode('/', $path);
	$pp = '';
	foreach($px as $i=>$p) {
		$pp .= $p.'/';
		if (!$p && !$i) $p = $lang;  
		print "<a href='?path=$pp'>$p</a>";
		if ($p || !$i) print '/';
	}
	print '<br>';
}


function printDirectories($dirs, $path) {
	sort($dirs);
	foreach($dirs as $dir) {
		print "<a href='?path=$path$dir'><img src='images/dir.png' width=16 height=16 border=0 align=absmiddle> $dir</a> <br>";
	}
}

function printFiles($files, $path) {
	global $translationPath, $user;
	
	sort($files);
	foreach($files as $fl) {
		$status = getTranslationStatus($path.$fl);
		if ($status['translated']) {
			if ($status['fileEnRevision'] && $status['lastEnRevision'] && $status['distance']>=0) {
				if (!$status['backward']) {
					$title = 'Up to date';
					$img = 'images/up2date.png';
				} else {
					$title = 'Outdated '.$status['fileEnRevision'].' / '.$status['lastEnRevision'];
					$img = 'images/r'.($status['backward']+1).'.png';
				}
			} else {
				$title = 'EN-Revision is incorrect or missing';
				$img = 'images/unknown.png';
			}
		} else {
			$title = 'Not translated yet';
			$img = 'images/notyet.png';
		}

		print "<a href='?path=$path&file=$fl' target=fileframe><img src='images/text.png' width=16 height=16 border=0 align=absmiddle> $fl</a> <img src='$img' border=0 align=absmiddle alt='$title'><br>";
	}

	// Lists the user's cached files
	if (file_exists($user['cache']."files.txt")) {
		print '<hr>';
		print 'Cached files:<br>';
		$ff = file($user['cache']."files.txt");
		foreach($ff as $f) {
			$fx = explode('|', $f);
			if (!isset($cf[$fx[2]])) {
				print "<a href='editxml.php?file=$fx[2]&source=upath' target=fileframe>$fx[2]</a><br>";
				$cf[$fx[2]] = true;
			}
		}
	}
	
}


//------- Output
?>
<html>
<body bgcolor="#FFFFFF">
<style type="text/css">
body {
	font-family: Tahoma;
	font-size: 12px;
}
a:link    { 
	text-decoration: none;
	color: #000066;
}

a:hover   { 
	text-decoration: none;
	color: #ff0000;
}

a:active  { 
	text-decoration: none;
	color: #ff0000;
}

a:visited { 
	text-decoration: none;
	color: #000066;
}

	</style>
<div style="width: 400px;">
Listing:
<?php

printPathAsLinks($path);

printDirectories($dirs, $path);

printFiles($files, $path);

?>
<hr>

<form action=login.php method=post target=_top>
<?php 
if ($requireLogin) { ?>
	<input type=hidden name=email value="<?php print $user['email']; ?>"><br>
<?php } ?>
Switch language:<br> 
<select name=lang onchange="if (this.value) this.form.submit();">
<option value=''></option>
<?php
foreach($phpdocLangs as $lng=>$langInfo) {
	if ($lng==$lang) $sel = " selected"; else $sel = '';
	print "<option value='$lng'$sel>$lng</option>";
}
?>
</select>
</form>

<hr>
Legend:<br>
<img src=images/notyet.png> Not yet translated<br>
<img src=images/up2date.png> File is translated and up to date<br>
<img src=images/unknown.png> EN-Revision is incorrect or missing<br>
<img src=images/r6.png> How much is outdated-<br> gauge (hover it for revision).

</div>
</body>
</html>