Exemple #1
0
 protected function author($data)
 {
     $worker = new Transform_Meta();
     $author = $worker->parse($data['author'], def::user('author'));
     $author = $worker->author($author);
     $this->model['author'] = $author;
 }
Exemple #2
0
 public function process()
 {
     $tag = $this->get('tag');
     $type = $this->get('type');
     if (empty($tag)) {
         throw new Error_Api('Пропущено обязательное поле: tag', Error_Api::MISSING_INPUT);
     }
     if (empty($type)) {
         throw new Error_Api('Пропущено обязательное поле: type', Error_Api::MISSING_INPUT);
     }
     if (!array_key_exists($type, $this->types)) {
         throw new Error_Api('Неправильно заполнено поле: type', Error_Api::INCORRECT_INPUT);
     }
     $color = $this->types[$type];
     $tag = trim(undo_safety($tag));
     $args = array($tag, '|' . $tag . '|', $tag);
     $exists = Database::get_field('tag', 'alias', 'name = ? or locate(?, variants) or alias = ?', $args);
     if ($exists) {
         $alias = $exists;
     } else {
         $alias = Transform_Meta::make_alias($tag);
         Database::insert('tag', array('alias' => $alias, 'name' => $tag, 'variants' => '|'));
         $this->add_error(Error_Api::UNKNOWN_TAG);
     }
     Database::update('tag', array('color' => $color), 'alias = ?', $alias);
     $this->set_success(true);
     $this->add_answer('tag', $alias);
 }
Exemple #3
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!is_array($post['images'])) {
         $this->writer->set_message('Не все обязательные поля заполнены.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     if (query::$url[2] == 'pool' && is_numeric(query::$url[3])) {
         $pool = new Model_Art_Pool(query::$url[3]);
         if (!$pool->correct_password($post['password'])) {
             $this->writer->set_message('Неправильный пароль от группы.')->set_error(Error_Create::INCORRECT_INPUT);
             return;
         }
     } else {
         $pool = false;
     }
     $worker = new Transform_Meta();
     $parsed_tags = $worker->parse_array($post['tag']);
     $tags = $worker->add_tags($parsed_tags);
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $similar = $this->check_similar($post['images']);
     foreach ($post['images'] as $image_key => $image) {
         if (empty($image['tags'])) {
             $local_tags = $tags;
         } else {
             $parsed_tags = $worker->parse_array($image['tags']);
             $local_tags = $worker->add_tags($parsed_tags);
         }
         $art = new Model_Art();
         $art->set_array(array('md5' => $image['md5'], 'thumb' => $image['thumb'], 'extension' => $image['extension'], 'resized' => $image['resized'], 'animated' => (int) $image['animated'], 'author' => $author, 'category' => $category, 'tag' => $local_tags, 'source' => $post['source']));
         $art->insert();
         if (!empty($similar[$image_key])) {
             foreach ($similar[$image_key] as $item) {
                 $art->add_similar($item);
             }
         }
         if (!empty($pool)) {
             $pool->add_art($art);
         }
         // TODO: перемести input__common::transfer в Model_Common
         if (!empty($post['transfer_to'])) {
             input__common::transfer(array('sure' => 1, 'do' => array('art', 'transfer'), 'where' => $post['transfer_to'], 'id' => $art->get_id()));
         }
     }
     $this->writer->set_success();
     if (count($post['images']) > 1) {
         $this->writer->set_message('Ваши изображения успешно добавлены, и доступны в ' . '<a href="/art/' . def::area(1) . '/">очереди на премодерацию</a>.');
     } else {
         $this->writer->set_message('Ваше изображение успешно добавлено, и доступно по адресу ' . '<a href="/art/' . $art->get_id() . '/">http://4otaku.org/art/' . $art->get_id() . '/</a> или в ' . '<a href="/art/' . def::area(1) . '/">очереди на премодерацию</a>.')->set_param('id', $art->get_id());
     }
 }
Exemple #4
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для новости.');
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $item = new Model_News();
     $item->set_array(array('title' => $post['title'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'image' => $post['image']['image'], 'extension' => $post['image']['extension'], 'author' => $author, 'category' => $category));
     $item->insert();
     $this->writer->set_success()->set_message('Ваша новость успешно добавлена, и доступна по адресу ' . '<a href="/news/' . $item->get_id() . '/">http://4otaku.org/news/' . $item->get_id() . '/</a>.');
 }
Exemple #5
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title'] || !$post['link'] && !$post['torrent']) {
         $this->writer->set_message('Не все обязательные поля заполнены.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $parsed_tags = $worker->parse_array($post['tag']);
     $tags = $worker->add_tags($parsed_tags);
     $category = $worker->category($post['category']);
     $language = $worker->language($post['language']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $links = Transform_Link::parse($post['link']);
     $extras = Transform_Link::parse($post['bonus_link']);
     $images = $post['image'];
     $torrents = $post['torrent'];
     $files = $post['file'];
     $item = new Model_Post();
     $item->set_array(array('title' => $post['title'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'author' => $author, 'category' => $category, 'language' => $language, 'tag' => $tags));
     foreach ($images as $image) {
         $image = explode('.', $image);
         $image = new Model_Post_Image(array('file' => $image[0], 'extension' => $image[1]));
         $item->add_image($image);
     }
     foreach ($links as $link) {
         $link = new Model_Post_Link($link);
         $item->add_link($link);
     }
     foreach ($torrents as $torrent) {
         $torrent = new Model_Post_Torrent($torrent);
         $item->add_torrent($torrent);
     }
     foreach ($extras as $extra) {
         $extra = new Model_Post_Extra($extra);
         $item->add_extra($extra);
     }
     foreach ($files as $file) {
         $file = new Model_Post_File($file);
         $item->add_file($file);
     }
     $item->insert();
     // TODO: перемести input__common::transfer в Model_Common
     if (!empty($post['transfer_to'])) {
         input__common::transfer(array('sure' => 1, 'do' => array('post', 'transfer'), 'where' => $post['transfer_to'], 'id' => $item->get_id()));
     }
     $this->writer->set_success()->set_message('Ваша запись успешно добавлена, и доступна по адресу ' . '<a href="/post/' . $item->get_id() . '/">http://4otaku.org/post/' . $item->get_id() . '/</a> или в ' . '<a href="/post/' . def::area(1) . '/">мастерской</a>.')->set_param('id', $item->get_id());
 }
Exemple #6
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для видео.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     if (!$post['link']) {
         $this->writer->set_message('Вы не предоставили ссылки, или же ссылка почему-то битая.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     $test = new Transform_Video($post['link']);
     if (!$test->enable_nico()->get_html()) {
         $this->writer->set_message('Ссылка не ведет на видео, либо этот видеохостинг не поддерживается')->set_error(Error_Create::INCORRECT_INPUT);
         return;
     }
     $already_have = Database::get_field('video', 'id', 'link = ?', $post['link']);
     if ($already_have) {
         $error = 'Это видео уже у нас есть, оно находится по адресу <a href="/video/' . $already_have . '/">http://4otaku.org/video/' . $already_have . '/</a>.';
         $this->writer->set_message($error)->set_error(Error_Create::ALREADY_EXISTS);
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $parsed_tags = $worker->parse_array($post['tag']);
     $tags = $worker->add_tags($parsed_tags);
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $item = new Model_Video();
     $item->set_array(array('title' => $post['title'], 'link' => $post['link'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'author' => $author, 'category' => $category, 'tag' => $tags));
     $item->insert();
     // TODO: перемести input__common::transfer в Model_Common
     if (!empty($post['transfer_to'])) {
         input__common::transfer(array('sure' => 1, 'do' => array('video', 'transfer'), 'where' => $post['transfer_to'], 'id' => $item->get_id()));
     }
     $this->writer->set_success()->set_message('Ваша видео успешно добавлено, и доступно по адресу ' . '<a href="/video/' . $item->get_id() . '/">http://4otaku.org/video/' . $item->get_id() . '/</a> или в ' . '<a href="/video/' . def::area(1) . '/">очереди на премодерацию</a>.')->set_param('id', $item->get_id());
 }