Working on Replace Image feature.
Added link to page, fixed foreach loop.
This commit is contained in:
parent
f3b6fde7a5
commit
62cc7e0e5e
2 changed files with 12 additions and 8 deletions
|
@ -27,6 +27,9 @@ class ImageIOTheme {
|
|||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
$html .= "<a href='".make_link("upload/replace/".$i_image_id)."'>Replace Image</a>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,18 +84,19 @@ class Upload implements Extension {
|
|||
|
||||
if(count($_FILES) + count($_POST) > 0)
|
||||
{
|
||||
if (count($_FILES) + count($_POST) > 1) {
|
||||
if (count($_FILES) > 1) {
|
||||
throw new UploadException("Can not upload more than one image for replacing.");
|
||||
}
|
||||
|
||||
if($this->can_upload($user)) {
|
||||
/* This could be changed so that it doesn't use foreach loops.. */
|
||||
foreach($_FILES as $file) {
|
||||
$ok = $ok & $this->try_upload($_FILES, $tags, $source, $image_id);
|
||||
}
|
||||
foreach($_POST as $name => $value) {
|
||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||
$ok = $ok & $this->try_transload($value, $tags, $source, $image_id);
|
||||
if (count($_FILES)) {
|
||||
$ok = $this->try_upload($_FILES, $tags, $source, $image_id);
|
||||
} else {
|
||||
foreach($_POST as $name => $value) {
|
||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||
$ok = $this->try_transload($value, $tags, $source, $image_id);
|
||||
break; // leave the foreach loop.
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Could replace with a page saying the image replace was successful? */
|
||||
|
|
Reference in a new issue