1
|
|
|
<?php |
2
|
|
|
$ARCurrent->nolangcheck=true; |
3
|
|
|
if ($this->CheckLogin("layout") && $this->CheckConfig()) { |
4
|
|
|
set_time_limit(0); |
5
|
|
|
$this->resetloopcheck(); |
6
|
|
|
|
7
|
|
|
$repository = $this->getdata('repository'); |
8
|
|
|
$username = $this->getdata('username'); |
9
|
|
|
$password = $this->getdata('password'); |
10
|
|
|
$checkunder = $this->getdata('checkunder'); |
11
|
|
|
$revision = $this->getdata('revision'); |
12
|
|
|
|
13
|
|
|
if (!isset($repository) || $repository == '') { |
14
|
|
|
echo $ARnls['err:svn:enterURL']; |
15
|
|
|
flush(); |
16
|
|
|
return; |
17
|
|
|
} else { |
18
|
|
|
$repository = rtrim($repository, "/") . "/"; |
19
|
|
|
$fstore = $this->store->get_filestore_svn("templates"); |
20
|
|
|
$svn = $fstore->connect($this->id, $username, $password); |
21
|
|
|
$svn_info = $fstore->svn_info($svn); |
22
|
|
|
|
23
|
|
|
if ($svn_info['revision']) { |
24
|
|
|
echo $this->path . " is already under version control - update instead.\n"; |
25
|
|
|
} else { |
26
|
|
View Code Duplication |
if ($repoPath) { |
27
|
|
|
$repo_subpath = substr($this->path, strlen($repoPath)); |
28
|
|
|
} else { |
29
|
|
|
// This is also the first loop! |
30
|
|
|
ob_start(); // FIXME: the SVN library is being a cunt and echoing when it shouldn't. So we catch it and destroy it. |
31
|
|
|
$fstore->svn_accept_cert($svn, $repository); |
32
|
|
|
ob_end_clean(); |
33
|
|
|
$repo_subpath = ''; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$repository = rtrim($repository, "/") . "/" . $repo_subpath; |
37
|
|
|
|
38
|
|
|
$task = "Checking out"; |
39
|
|
|
if( $checkunder ) { |
40
|
|
|
$task = "Checking under"; |
41
|
|
|
} |
42
|
|
View Code Duplication |
if( !$repoPath ) { // echo on the first run |
43
|
|
|
echo "<span class='svn_headerline'>".$task." ".$repository." on ".$this->path."</span>\n\n"; |
44
|
|
|
flush(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
if( $checkunder ) { |
48
|
|
|
$result = $fstore->svn_checkunder($svn, $repository, $revision); |
49
|
|
|
} else { |
50
|
|
|
// Checkout the templates. |
51
|
|
|
$result = $fstore->svn_checkout($svn, $repository, $revision); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if ($result) { |
55
|
|
|
$last = array_pop($result); |
56
|
|
|
$templates = array(); |
57
|
|
|
foreach ($result as $item) { |
58
|
|
|
$templates[] = $item['name']; |
59
|
|
|
if( $item["filestate"] == "A" ) { |
60
|
|
|
$props = $fstore->svn_get_ariadne_props($svn, $item['name']); |
61
|
|
|
echo "<span class='svn_addtemplateline'>Adding ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
62
|
|
|
} elseif($item["filestate"] == "E") { |
63
|
|
|
$props = $fstore->svn_get_ariadne_props($svn, $item['name']); |
64
|
|
|
echo "<span class='svn_existingtemplateline'>Existing ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
flush(); |
68
|
|
|
} |
69
|
|
|
echo "<span class='svn_revisionline'>Done ".$last->path." Revision ".$last["revision"]."</span>\n\n"; |
70
|
|
|
|
71
|
|
|
$this->call( |
72
|
|
|
"system.svn.compile.templates.php", |
73
|
|
|
array( |
74
|
|
|
'templates' => $templates, |
75
|
|
|
'fstore' => $fstore, |
76
|
|
|
'svn' => $svn |
77
|
|
|
) |
78
|
|
|
); |
79
|
|
View Code Duplication |
} else { |
80
|
|
|
echo "<span class='svn_error'>Error: " . $svn['instance']->add->_stack->_errors[0]['params']['errstr'] . "</span>\n\n"; |
81
|
|
|
} |
82
|
|
|
// Run checkout on the existing subdirs. |
83
|
|
|
$arCallArgs['repoPath'] = $this->path; |
84
|
|
|
$arCallArgs['repository'] = $repository; |
85
|
|
|
$arCallArgs['checkunder'] = $checkunder; |
86
|
|
|
$arCallArgs['revision'] = $revision; |
87
|
|
|
$this->ls($this->path, "system.svn.checkout.recursive.php", $arCallArgs); |
88
|
|
|
|
89
|
|
|
// Create the dirs and checkout them if needed. |
90
|
|
|
$dirlist = $fstore->svn_list($svn, $revision); |
91
|
|
View Code Duplication |
if ($dirlist) { |
92
|
|
|
$arCallArgs['dirlist'] = $dirlist; |
93
|
|
|
$arCallArgs['svn'] = $svn; |
94
|
|
|
$arCallArgs['fstore'] = $fstore; |
95
|
|
|
$this->call("system.svn.checkout.dirs.php", $arCallArgs); |
96
|
|
|
} |
97
|
|
|
flush(); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
?> |
|
|
|
|
102
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.