1
|
|
|
<?php |
2
|
6 |
|
$ARCurrent->nolangcheck=true; |
3
|
6 |
|
if ($this->CheckLogin("layout") && $this->CheckConfig()) { |
4
|
6 |
|
set_time_limit(0); |
5
|
6 |
|
$this->resetloopcheck(); |
6
|
|
|
|
7
|
6 |
|
$repository = $this->getdata('repository'); |
8
|
6 |
|
$username = $this->getdata('username'); |
9
|
6 |
|
$password = $this->getdata('password'); |
10
|
6 |
|
$checkunder = $this->getdata('checkunder'); |
11
|
6 |
|
$revision = $this->getdata('revision'); |
12
|
|
|
|
13
|
6 |
|
if (!isset($repository) || $repository == '') { |
14
|
|
|
echo $ARnls['err:svn:enterURL']; |
15
|
|
|
flush(); |
16
|
|
|
return; |
17
|
|
|
} else { |
18
|
6 |
|
$repository = rtrim($repository, "/") . "/"; |
19
|
6 |
|
$fstore = $this->store->get_filestore_svn("templates"); |
20
|
6 |
|
$svn = $fstore->connect($this->id, $username, $password); |
21
|
6 |
|
$svn_info = $fstore->svn_info($svn); |
22
|
|
|
|
23
|
6 |
|
if ($svn_info['revision']) { |
24
|
|
|
echo $this->path . " is already under version control - update instead.\n"; |
25
|
|
|
} else { |
26
|
|
|
|
27
|
6 |
View Code Duplication |
if ($repoPath) { |
28
|
|
|
$repo_subpath = substr($this->path, strlen($repoPath)); |
29
|
|
|
} else { |
30
|
|
|
// This is also the first loop! |
31
|
6 |
|
ob_start(); // FIXME: the SVN library is being a cunt and echoing when it shouldn't. So we catch it and destroy it. |
32
|
6 |
|
$fstore->svn_accept_cert($svn, $repository); |
33
|
6 |
|
ob_end_clean(); |
34
|
6 |
|
$repo_subpath = ''; |
35
|
|
|
} |
36
|
|
|
|
37
|
6 |
|
$repository = rtrim($repository, "/") . "/" . $repo_subpath; |
38
|
|
|
|
39
|
6 |
|
$task = "Checking out"; |
40
|
6 |
|
if( $checkunder ) { |
41
|
|
|
$task = "Checking under"; |
42
|
|
|
} |
43
|
6 |
View Code Duplication |
if( !$repoPath ) { // echo on the first run |
44
|
6 |
|
echo "<span class='svn_headerline'>".$task." ".$repository." on ".$this->path."</span>\n\n"; |
45
|
6 |
|
flush(); |
46
|
6 |
|
} |
47
|
|
|
|
48
|
6 |
View Code Duplication |
if( $checkunder ) { |
49
|
|
|
$result = $fstore->svn_checkunder($svn, $repository, $revision); |
50
|
|
|
} else { |
51
|
|
|
// Checkout the templates. |
52
|
6 |
|
$result = $fstore->svn_checkout($svn, $repository, $revision); |
53
|
|
|
} |
54
|
6 |
|
$last = array_pop($result); |
55
|
|
|
|
56
|
6 |
|
if ($result) { |
|
|
|
|
57
|
6 |
|
$templates = array(); |
58
|
6 |
|
foreach ($result as $item) { |
59
|
6 |
|
$templates[] = $item['name']; |
60
|
6 |
|
if( $item["filestate"] == "A" ) { |
61
|
6 |
|
$props = $fstore->svn_get_ariadne_props($svn, $item['name']); |
62
|
6 |
|
echo "<span class='svn_addtemplateline'>Adding ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "").( $props["ar:private"] == '1' ? " " . $ARnls["ariadne:template:private"] : "") . "</span>\n"; |
63
|
6 |
|
} |
64
|
6 |
|
flush(); |
65
|
6 |
|
} |
66
|
6 |
|
echo "<span class='svn_revisionline'>Done ".$this->path." Revision ".$last["revision"]."</span>\n\n"; |
67
|
|
|
|
68
|
6 |
|
$res = $this->call( |
69
|
6 |
|
"system.svn.compile.templates.php", |
70
|
|
|
array( |
71
|
6 |
|
'templates' => $templates, |
72
|
6 |
|
'fstore' => $fstore, |
73
|
|
|
'svn' => $svn |
74
|
6 |
|
) |
75
|
6 |
|
); |
76
|
6 |
View Code Duplication |
} else { |
77
|
|
|
echo "<span class='svn_error'>Error: " . $svn['instance']->add->_stack->_errors[0]['params']['errstr'] . "</span>\n\n"; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
6 |
|
} |
82
|
|
|
?> |
|
|
|
|
83
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.