1
|
|
|
<?php |
2
|
|
|
ldDisablePostProcessing(); |
3
|
|
|
$ARCurrent->nolangcheck=true; |
4
|
|
|
if (!$this->validateFormSecret()) { |
5
|
|
|
error($ARnls['ariadne:err:invalidsession']); |
6
|
|
|
exit; |
7
|
|
|
} |
8
|
|
|
if ($this->CheckLogin('edit') && $this->CheckConfig()) { |
9
|
|
|
// FIXME: Check vars first; |
10
|
|
|
|
11
|
|
|
$oldurl = $this->getvar('oldurl'); |
12
|
|
|
$newurl = $this->getvar('newurl'); |
13
|
|
|
|
14
|
|
|
$oldreference = $this->getvar('oldreference'); |
15
|
|
|
$newreference = $this->getvar('newreference'); |
16
|
|
|
|
17
|
|
|
if ($oldurl && $newurl) { |
18
|
|
|
$rewrite_urls = array( |
19
|
|
|
$oldurl => $newurl |
20
|
|
|
); |
21
|
|
|
}; |
22
|
|
|
|
23
|
|
|
if ($oldreference && $newreference) { |
24
|
|
|
$rewrite_references = array( |
25
|
|
|
$oldreference => $newreference |
26
|
|
|
); |
27
|
|
|
}; |
28
|
|
|
|
29
|
|
|
if ($rewrite_urls || $rewrite_references) { |
|
|
|
|
30
|
|
|
$query = "object.path =~ '" . $this->path . "%' order by path ASC"; |
31
|
|
|
|
32
|
|
|
$total = $this->count_find($this->path, $query); |
33
|
|
|
$objects_left = $total; |
34
|
|
|
$offset = 0; |
35
|
|
|
|
36
|
|
|
// amount of objects to process in one run. Smaller stepsize |
37
|
|
|
// gives more updates but takes a bit longer. This way there |
38
|
|
|
// are usually 20 steps to give a nice resolution on the |
39
|
|
|
// updates. |
40
|
|
|
|
41
|
|
|
$stepsize = (int)($total/20); |
42
|
|
|
if ($stepsize < 5) { |
43
|
|
|
$stepsize = 5; |
44
|
|
|
} |
45
|
|
|
if ($stepsize > 100) { |
46
|
|
|
$stepsize = 100; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$current_object_path = $this->path; |
50
|
|
View Code Duplication |
if (strlen($current_object_path) > 25) { |
51
|
|
|
$current_object_path = substr($this->path, 0, 12) . "..." . substr($this->path, strlen($this->path) - 12, strlen($this->path)); |
52
|
|
|
} |
53
|
|
|
?> |
54
|
|
|
<div id="rewrite"><?php echo $ARnls["ariadne:rewriting"] . " " . $current_object_path; ?></div> |
55
|
|
|
<div id="progressbar"> |
56
|
|
|
<div id="progress"></div> |
57
|
|
|
<div id="progress_text">0/<?php echo $total; ?></div> |
58
|
|
|
</div> |
59
|
|
|
<?php |
60
|
|
|
|
61
|
|
|
do { |
62
|
|
|
flush(); |
63
|
|
|
set_time_limit(30); |
64
|
|
|
$objects = $this->find($this->path, $query, "system.get.phtml", array(), $stepsize, $offset); |
65
|
|
|
|
66
|
|
|
foreach ($objects as $object) { |
67
|
|
|
$error = false; |
68
|
|
|
$error = current($this->get($object->path, "system.rewrite.urls.php", array("rewrite_urls" => $rewrite_urls))); |
69
|
|
|
if (!$error) { |
70
|
|
|
$error = current($this->get($object->path, "system.rewrite.htmlblocks.php", array("rewrite_urls" => $rewrite_urls))); |
71
|
|
|
if (!$error) { |
72
|
|
|
$error = current($this->get($object->path, "system.rewrite.references.php", array("rewrite_references" => $rewrite_references))); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if ($error) { |
77
|
|
|
?> |
78
|
|
|
<script type="text/javascript"> |
79
|
|
|
alert("<?php echo addslashes($error); ?>"); |
80
|
|
|
</script> |
81
|
|
|
<?php |
82
|
|
|
return false; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$new_objects_left = $objects_left - sizeof($objects); |
88
|
|
|
$next_object_path = current($this->find($this->path, $query, "system.get.path.phtml", array(), 1, $offset)); |
89
|
|
|
if (strlen($next_object_path) > 25) { |
90
|
|
|
$next_object_path = substr($next_object_path, 0, 12) . "..." . substr($next_object_path, strlen($next_object_path) - 12, strlen($next_object_path)); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$objects_handled = $objects_left - $new_objects_left; |
94
|
|
|
$objects_skipped = $stepsize - $objects_handled; |
95
|
|
|
$offset += count( $objects ); |
96
|
|
|
$objects_left = $new_objects_left; |
97
|
|
|
$items_processed = $total-($objects_left-$offset); |
98
|
|
|
if ($items_processed > $total) { |
99
|
|
|
$items_processed = $total; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
//echo "Changed owner for $stepsize items<br>"; |
103
|
|
|
$progress = (int)(100*($offset)/$total); |
104
|
|
|
|
105
|
|
|
if ($progress < 0) { |
106
|
|
|
$progress = 0; |
107
|
|
|
} |
108
|
|
|
if ($progress > 100) { |
109
|
|
|
$progress = 100; |
110
|
|
|
} |
111
|
|
|
echo "<script type='text/javascript'>\n"; |
112
|
|
|
echo "document.getElementById('progress').style.width = '" . $progress . "%';\n"; |
113
|
|
|
echo "document.getElementById('progress_text').innerHTML = '" . $offset . "/" . $total . "';\n"; |
114
|
|
|
echo "document.getElementById('rewrite').innerHTML = '" . $ARnls["ariadne:rewriting"] . " " . $next_object_path . "';\n"; |
115
|
|
|
echo "</script>"; |
116
|
|
|
flush(); |
117
|
|
|
} while (count($objects) == $stepsize); |
118
|
|
|
|
119
|
|
|
?> |
120
|
|
|
<script type='text/javascript'> |
121
|
|
|
document.getElementById('progress_text').innerHTML = 'Done'; |
122
|
|
|
document.getElementById('progress').style.width = '100%'; |
123
|
|
|
document.getElementById('rewrite').innerHTML = '<?php echo $ARnls["ariadne:rewriting"] . " " . $current_object_path; ?>'; |
124
|
|
|
|
125
|
|
|
if ( window.opener && window.opener.muze && window.opener.muze.ariadne && window.opener.muze.ariadne.registry ) { |
126
|
|
|
window.opener.muze.ariadne.explore.objectadded(); |
127
|
|
|
} |
128
|
|
|
window.close(); |
129
|
|
|
</script> |
130
|
|
|
<?php |
131
|
|
|
} else { |
132
|
|
|
echo $ARnls['ariadne:err:rewrite.no_input']; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
?> |
136
|
|
|
|
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.