コード例 #1
0
ファイル: art.php プロジェクト: 4otaku/4otaku
 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());
     }
 }
コード例 #2
0
ファイル: art.php プロジェクト: 4otaku/4otaku
 protected function image_variation($data)
 {
     $id = (int) $data['id'];
     $images = $data['image_variation'];
     $main_image = array_shift($images);
     if (empty($id) || empty($main_image)) {
         return;
     }
     $art = new Model_Art($id);
     $art->set_array(array('animated' => $main_image['animated'], 'extension' => $main_image['extension'], 'md5' => $main_image['md5'], 'resized' => $main_image['resized'], 'thumb' => $main_image['thumb']));
     if ($main_image['resized'] == 1) {
         $art->calculate_resize();
     }
     $art->commit();
     $art->clear_similar();
     foreach ($images as $image) {
         $art->add_similar($image);
     }
 }