image specific tags on mass upload form
This commit is contained in:
parent
1db23314b8
commit
285b78c185
@ -112,7 +112,6 @@ class Upload extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
// event handling {{{
|
||||
public function onPageRequest($event) {
|
||||
global $config, $page, $user;
|
||||
|
||||
@ -187,16 +186,15 @@ class Upload extends Extension {
|
||||
else {
|
||||
/* Regular Upload Image */
|
||||
if(count($_FILES) + count($_POST) > 0) {
|
||||
$tags = Tag::explode($_POST['tags']);
|
||||
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
||||
$ok = true;
|
||||
foreach($_FILES as $file) {
|
||||
reset($_FILES); // rewind to first element in array.
|
||||
foreach($_FILES as $name => $file) {
|
||||
$tags = $this->tags_for_upload_slot(int_escape(substr($name, 4)));
|
||||
$ok = $ok & $this->try_upload($file, $tags, $source);
|
||||
}
|
||||
foreach($_POST as $name => $value) {
|
||||
reset($_POST); // rewind to first element in array.
|
||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||
$tags = $this->tags_for_upload_slot(int_escape(substr($name, 3)));
|
||||
$ok = $ok & $this->try_transload($value, $tags, $source);
|
||||
}
|
||||
}
|
||||
@ -223,7 +221,17 @@ class Upload extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
private function tags_for_upload_slot($id) {
|
||||
if(isset($_POST["tags$id"])) {
|
||||
$tags = array_merge(Tag::explode($_POST['tags']), Tag::explode($_POST["tags$id"]));
|
||||
}
|
||||
else {
|
||||
$tags = Tag::explode($_POST['tags']);
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
// do things {{{
|
||||
|
||||
/**
|
||||
|
@ -20,9 +20,9 @@ class UploadTheme extends Themelet {
|
||||
".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')."
|
||||
<table id='large_upload_form' class='vert'>
|
||||
$upload_list
|
||||
<tr><td width='20'>Tags<td colspan='3'><input name='tags' type='text' placeholder='tagme' class='autocomplete_tags'></td></tr>
|
||||
<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
|
||||
<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>
|
||||
<tr><td width='20'>Tags<td colspan='5'><input name='tags' type='text' placeholder='tagme' class='autocomplete_tags'></td></tr>
|
||||
<tr><td>Source</td><td colspan='5'><input name='source' type='text'></td></tr>
|
||||
<tr><td colspan='6'><input id='uploadbutton' type='submit' value='Post'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<small>(Max file size is $max_kb)</small>
|
||||
@ -48,6 +48,7 @@ class UploadTheme extends Themelet {
|
||||
<tr>
|
||||
<td colspan='2'>Files</td>
|
||||
<td colspan='2'>URLs</td>
|
||||
<td colspan='2'>Image-Specific Tags</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
@ -56,15 +57,24 @@ class UploadTheme extends Themelet {
|
||||
<tr>
|
||||
<td colspan='2'><input type='file' name='data$i'></td>
|
||||
<td colspan='2'><input type='text' name='url$i'</td>
|
||||
<td colspan='2'><input type='text' name='tags$i'></td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td colspan='4'>Files</td>
|
||||
<td colspan='2'>Image-Specific Tags</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
for($i=0; $i<$upload_count; $i++) {
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td colspan='4'><input type='file' name='data$i'></td>
|
||||
<td colspan='2'><input type='text' name='tags$i'></td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user