Пример #1
1
 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);
 }
Пример #2
0
 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));
 }
Пример #3
0
 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));
 }
Пример #4
0
 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)));
 }
Пример #5
0
 static function finalize()
 {
     $error = trim(ob_get_clean(), " \r\n");
     if ($error) {
         static::$response = so_output::error($error);
     }
     if (!static::$response) {
         static::$response = so_output::error('Empty response');
     }
     so_front::make()->send(static::$response);
 }
Пример #6
0
 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)));
 }
Пример #7
0
 function get_resource($data)
 {
     return so_output::ok()->content(array('@so_page_uri' => (string) $this->uri, $this->model));
 }
Пример #8
0
 function get_resource($data)
 {
     return so_output::missed("Missed handler for [{$this->uri}]");
 }
Пример #9
0
 function get_resource($data = null)
 {
     $url = (string) $this->image['@hyoo_image_search_unescapedUrl'];
     return so_output::moved($url)->cache(true);
 }
Пример #10
0
 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;
 }
Пример #11
0
 function post_resource($data)
 {
     $authorCurrent = hyoo_author::make();
     if ($this->key && $this !== $authorCurrent) {
         return so_output::forbidden("User [{$this->name}] is already registered");
     }
     $this->about = $data['hyoo_author_about'] ?: $this->about;
     $this->key = so_crypt::hash($this->uri, so_user::make()->key);
     $this->exists = true;
     so_cookie::make('hyoo_author_name')->value = $this->name;
     #return so_output::ok( 'Updated' );
     return so_output::created((string) $this);
 }
Пример #12
0
 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);
 }