function post_resource($data) { if ($this->storage->dir->exists) { return so_output::conflict('Image already exists'); } $this->storage->dir->exists = true; $image = new \Imagick((string) $data['file']); $image->writeImage((string) $this->fileOrinal); $size = $image->getImageGeometry(); if ($size['width'] > 800 or $size['height'] > 600) { $image->adaptiveResizeImage(800, 600, true); } $image->writeImage((string) $this->fileMaximal); $size = $image->getImageGeometry(); if ($size['width'] > 100 or $size['height'] > 100) { $image->adaptiveResizeImage(100, 100, true); } $image->writeImage((string) $this->filePreview); return so_output::ok()->content($this->model); }
function move_resource($data) { $name = strtr($data['hyoo_article_name'], array("\n" => '', "\r" => '')); $force = $data['so_conflict_force'] == 'true'; $target = hyoo_article::makeInstance()->name($name)->primary(); if ($target === $this) { return so_output::ok('Same name'); } if ($target->exists && !$force) { return so_output::conflict('Article already exists'); } $target->content = $this->content; $target->annotation = $this->annotation; $target->exists = true; if ($this->exists && $target->author === $this->author) { $this->content = " /Article moved to [new location\\{$target}]/.\n"; $this->exists = false; } return so_output::created((string) $target); }