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 get_resource($data = null) { $articleList = array(); foreach ($this->map as $article) { $articleList[] = $article->teaser; } return so_output::ok()->content(array('@so_page_uri' => (string) $this, '@so_page_author' => (string) $this->author, 'hyoo_article_list' => array('@so_uri' => (string) $this->uri, '@hyoo_article_author' => (string) $this->author, $articleList), $this->author->teaser)); }
function get_resource() { ob_start(); phpinfo(); $html = ob_get_clean(); $doc = new \DOMDocument('1.0', 'utf-8'); $doc->loadHTML($html . '<style> .v{ background: #eee } a:link { background: none } </style>'); $dom = so_dom::make($doc)->select('/*/*'); return so_output::ok()->content(array('html' => $dom)); }
function get_resource($data = null) { $articleList = array(); $authorHash = array(); foreach ($this->map as $article) { $articleList[] = $article->teaser; $author = $article->author; $authorHash[(string) $author] = $author->teaser; } return so_output::ok()->content(array('@so_page_uri' => (string) $this->uri, 'hyoo_article_list' => array('@so_uri' => (string) $this->uri, $articleList), array_values($authorHash))); }
function post_resource($data) { $result = eval($data['code']); $lang = 'text'; if ($result instanceof \DOMNode) { $result = so_dom::make($result); } if ($result instanceof so_dom) { $lang = 'sgml'; } if (is_array($result) || is_bool($result) || is_null($result)) { $result = var_export($result, true); $lang = 'php'; } return so_output::ok()->content(array('so_console_result' => array('@so_console_lang' => $lang, '@so_console_content' => (string) $result))); }
function get_resource($data) { return so_output::ok()->content(array('@so_page_uri' => (string) $this->uri, $this->model)); }
function get_resource() { $output = so_output::ok(); $output->content = array('@so_page_uri' => (string) $this->uri, '@so_page_title' => (string) $this->text, 'hyoo_search' => array('@so_uri' => (string) $this->uri, '@hyoo_search_text' => (string) $this->text, '@hyoo_search_frame' => (string) $this->frame)); return $output; }
function get_resource($data = null) { $output = $this->exists ? so_output::ok() : so_output::missed(); $output->content = array('@so_page_uri' => (string) $this->uri, '@so_page_title' => (string) $this->name, $this->link); return $output; }
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); }