1
|
|
|
<?php |
2
|
2 |
|
if ($this->CheckLogin("layout") && $this->CheckConfig()) { |
3
|
2 |
|
$this->resetloopcheck(); |
4
|
|
|
|
5
|
2 |
|
$fstore = $this->store->get_filestore_svn("templates"); |
6
|
2 |
|
$svn = $fstore->connect($this->id, $this->getdata("username"), $this->getdata("password")); |
7
|
|
|
|
8
|
2 |
|
$type = $this->getvar("type"); |
9
|
2 |
|
$function = $this->getvar("function"); |
10
|
2 |
|
$language = $this->getvar("language"); |
11
|
|
|
|
12
|
2 |
|
$filename = ''; |
13
|
|
|
|
14
|
2 |
View Code Duplication |
if ($type && $function && $language) { |
15
|
|
|
$filename = $type . "." . $function . "." . $language . ".pinp"; |
16
|
|
|
} |
17
|
|
|
|
18
|
2 |
|
$svn_info = $fstore->svn_info($svn); |
19
|
2 |
|
$repository = $svn_info['url']; |
20
|
2 |
|
$revision = $this->getdata("revision"); |
21
|
|
|
|
22
|
2 |
|
if (!isset($repository) || $repository == '') { |
23
|
|
|
echo $ARnls['err:svn:enterURL']; |
24
|
|
|
flush(); |
25
|
|
|
return; |
26
|
|
|
} else { |
27
|
2 |
|
$repository = rtrim($repository, "/") . "/" . $repo_subpath; |
28
|
|
|
|
29
|
2 |
|
$updating = $this->path; |
30
|
2 |
|
if( $filename ) { |
31
|
|
|
$updating .= $function . " {".$type.") [".$language."]"; |
32
|
|
|
} |
33
|
|
|
|
34
|
2 |
|
if(!$revision) { |
35
|
1 |
|
echo "\n<span class='svn_headerline'>Updating ".$this->path." from ".$repository."</span>\n"; |
36
|
1 |
|
} else { |
37
|
2 |
|
echo "\n<span class='svn_headerline'>Updating ".$this->path." to revision $revision from $repository</span>\n"; |
38
|
|
|
} |
39
|
2 |
|
flush(); |
40
|
|
|
|
41
|
2 |
|
$result = $fstore->svn_update($svn, $filename, $revision); |
42
|
2 |
|
if ($result) { |
43
|
2 |
|
$revisionentry = array_pop($result); |
44
|
2 |
|
$updated_templates = array(); |
45
|
2 |
|
$deleted_templates = array(); |
46
|
|
|
|
47
|
2 |
|
foreach ($result as $item) { |
48
|
2 |
|
switch ($item['filestate']) { |
49
|
2 |
|
case "A": |
50
|
2 |
|
case "U": |
51
|
2 |
|
case "M": |
52
|
2 |
|
case "G": |
53
|
1 |
|
$updated_templates[] = $item['name']; |
54
|
1 |
|
break; |
55
|
1 |
|
case "D": |
56
|
|
|
$deleted_templates[] = $item['name']; |
57
|
|
|
break; |
58
|
1 |
|
case "E": |
59
|
|
|
// existing template, no need for recompile |
60
|
|
|
break; |
61
|
1 |
|
case "Skipped": |
62
|
1 |
|
case "C": |
63
|
1 |
|
break; // Don't try to recompile conflicted templates |
64
|
|
|
default: |
65
|
|
|
$updated_templates[] = $item['name']; |
66
|
|
|
break; |
67
|
2 |
|
} |
68
|
2 |
|
$props = $fstore->svn_get_ariadne_props($svn, $item['name']); |
69
|
2 |
|
if( ar_error::isError($props)) { |
70
|
|
|
echo "<span>Error: ".$props->getMessage()."</span>"; |
71
|
2 |
|
} else if( $item["filestate"] == "A" ) { |
72
|
|
|
echo "<span class='svn_addtemplateline'>Added ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
73
|
2 |
View Code Duplication |
} elseif( $item["filestate"] == "U" ) { // substr to work around bugs in SVN.php |
74
|
1 |
|
echo "<span class='svn_revisionline'>Updated ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
75
|
2 |
|
} elseif( $item["filestate"] == "M" || $item["filestate"] == "G" ) { |
76
|
|
|
echo "<span class='svn_revisionline'>Merged ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
77
|
1 |
View Code Duplication |
} elseif( $item["filestate"] == "E" ) { |
78
|
|
|
echo "<span class='svn_revisionline'>Existing ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
79
|
1 |
|
} elseif( $item["filestate"] == "C" ) { |
80
|
1 |
|
echo "<span class='svn_revisionline'>Conflict ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."</span>\n"; |
81
|
1 |
|
} elseif( $item["filestate"] == "D" ) { |
82
|
|
|
// system.svn.delete.templates.php will report that this template has been deleted |
83
|
|
|
//echo "<span class='svn_deletetemplateline'>Deleting ".$item["name"]."</span>\n"; // we don't know the props since it's deleted. |
84
|
|
View Code Duplication |
} else { |
85
|
|
|
echo ($item["filestate"]?$item["filestate"]:"Unchanged ")." ".$this->path.$props["ar:function"]." (".$props["ar:type"].") [".$props["ar:language"]."] ".( $props["ar:default"] == '1' ? $ARnls["default"] : "")."\n"; |
86
|
|
|
} |
87
|
2 |
|
flush(); |
88
|
2 |
|
} |
89
|
|
|
//FIXME: add revision/rest output line |
90
|
2 |
|
$this->call( |
91
|
2 |
|
"system.svn.compile.templates.php", |
92
|
|
|
array( |
93
|
2 |
|
'templates' => $updated_templates, |
94
|
2 |
|
'fstore' => $fstore, |
95
|
|
|
'svn' => $svn |
96
|
2 |
|
) |
97
|
2 |
|
); |
98
|
|
|
|
99
|
2 |
|
$this->call( |
100
|
2 |
|
"system.svn.delete.templates.php", |
101
|
|
|
array( |
102
|
2 |
|
'templates' => $deleted_templates, |
103
|
2 |
|
'fstore' => $fstore, |
104
|
|
|
'svn' => $svn |
105
|
2 |
|
) |
106
|
2 |
|
); |
107
|
|
|
|
108
|
2 |
|
} |
109
|
2 |
|
if ($result === false || ar_error::isError($result)) { |
110
|
|
|
echo "Update failed.\n"; |
111
|
|
|
if (count($errs = $fstore->svnstack->getErrors())) { |
112
|
|
|
foreach ($errs as $err) { |
113
|
|
|
echo $err['message']."\n"; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
} |
118
|
2 |
|
} |
119
|
|
|
?> |
|
|
|
|
120
|
|
|
|
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.