Image to Post - Some core files
This commit is contained in:
parent
dbb90c7a99
commit
e7b109a7f2
2 changed files with 10 additions and 10 deletions
|
@ -313,17 +313,17 @@ abstract class DataHandlerExtension extends Extension
|
||||||
$existing = Image::by_id($event->replace_id);
|
$existing = Image::by_id($event->replace_id);
|
||||||
|
|
||||||
if (is_null($existing)) {
|
if (is_null($existing)) {
|
||||||
throw new UploadException("Image to replace does not exist!");
|
throw new UploadException("Post to replace does not exist!");
|
||||||
}
|
}
|
||||||
if ($existing->hash === $event->metadata['hash']) {
|
if ($existing->hash === $event->metadata['hash']) {
|
||||||
throw new UploadException("The uploaded image is the same as the one to replace.");
|
throw new UploadException("The uploaded post is the same as the one to replace.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// even more hax..
|
// even more hax..
|
||||||
$event->metadata['tags'] = $existing->get_tag_list();
|
$event->metadata['tags'] = $existing->get_tag_list();
|
||||||
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->metadata['hash']), $event->metadata);
|
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->metadata['hash']), $event->metadata);
|
||||||
if (is_null($image)) {
|
if (is_null($image)) {
|
||||||
throw new UploadException("Data handler failed to create image object from data");
|
throw new UploadException("Data handler failed to create post object from data");
|
||||||
}
|
}
|
||||||
if (empty($image->get_mime())) {
|
if (empty($image->get_mime())) {
|
||||||
throw new UploadException("Unable to determine MIME for ". $event->tmpname);
|
throw new UploadException("Unable to determine MIME for ". $event->tmpname);
|
||||||
|
@ -339,7 +339,7 @@ abstract class DataHandlerExtension extends Extension
|
||||||
} else {
|
} else {
|
||||||
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata);
|
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata);
|
||||||
if (is_null($image)) {
|
if (is_null($image)) {
|
||||||
throw new UploadException("Data handler failed to create image object from data");
|
throw new UploadException("Data handler failed to create post object from data");
|
||||||
}
|
}
|
||||||
if (empty($image->get_mime())) {
|
if (empty($image->get_mime())) {
|
||||||
throw new UploadException("Unable to determine MIME for ". $event->tmpname);
|
throw new UploadException("Unable to determine MIME for ". $event->tmpname);
|
||||||
|
|
|
@ -395,7 +395,7 @@ class Image
|
||||||
SET owner_id=:owner_id
|
SET owner_id=:owner_id
|
||||||
WHERE id=:id
|
WHERE id=:id
|
||||||
", ["owner_id"=>$owner->id, "id"=>$this->id]);
|
", ["owner_id"=>$owner->id, "id"=>$this->id]);
|
||||||
log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}");
|
log_info("core_image", "Owner for Post #{$this->id} set to {$owner->name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ class Image
|
||||||
}
|
}
|
||||||
if ($new_source != $old_source) {
|
if ($new_source != $old_source) {
|
||||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", ["source"=>$new_source, "id"=>$this->id]);
|
$database->execute("UPDATE images SET source=:source WHERE id=:id", ["source"=>$new_source, "id"=>$this->id]);
|
||||||
log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)");
|
log_info("core_image", "Source for Post #{$this->id} set to: $new_source (was $old_source)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ class Image
|
||||||
$sln = str_replace('"', "", $sln);
|
$sln = str_replace('"', "", $sln);
|
||||||
if (bool_escape($sln) !== $this->locked) {
|
if (bool_escape($sln) !== $this->locked) {
|
||||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$sln, "id"=>$this->id]);
|
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$sln, "id"=>$this->id]);
|
||||||
log_info("core_image", "Setting Image #{$this->id} lock to: $ln");
|
log_info("core_image", "Setting Post #{$this->id} lock to: $ln");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ class Image
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("core_image", "Tags for Image #{$this->id} set to: ".Tag::implode($tags));
|
log_info("core_image", "Tags for Post #{$this->id} set to: ".Tag::implode($tags));
|
||||||
$cache->delete("image-{$this->id}-tags");
|
$cache->delete("image-{$this->id}-tags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ class Image
|
||||||
global $database;
|
global $database;
|
||||||
$this->delete_tags_from_image();
|
$this->delete_tags_from_image();
|
||||||
$database->execute("DELETE FROM images WHERE id=:id", ["id"=>$this->id]);
|
$database->execute("DELETE FROM images WHERE id=:id", ["id"=>$this->id]);
|
||||||
log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')');
|
log_info("core_image", 'Deleted Post #'.$this->id.' ('.$this->hash.')');
|
||||||
|
|
||||||
unlink($this->get_image_filename());
|
unlink($this->get_image_filename());
|
||||||
unlink($this->get_thumb_filename());
|
unlink($this->get_thumb_filename());
|
||||||
|
@ -810,7 +810,7 @@ class Image
|
||||||
*/
|
*/
|
||||||
public function remove_image_only(): void
|
public function remove_image_only(): void
|
||||||
{
|
{
|
||||||
log_info("core_image", 'Removed Image File ('.$this->hash.')');
|
log_info("core_image", 'Removed Post File ('.$this->hash.')');
|
||||||
@unlink($this->get_image_filename());
|
@unlink($this->get_image_filename());
|
||||||
@unlink($this->get_thumb_filename());
|
@unlink($this->get_thumb_filename());
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue