Beispiel #1
0
 public function process()
 {
     $title = $this->get('title');
     $text = $this->get('text');
     $filename = $this->get('filename');
     if (empty($title)) {
         throw new Error_Api('Пропущено обязательное поле: title', Error_Api::MISSING_INPUT);
     }
     $pack = $this->get_file($this->get('archive'), 'Пропущено обязательное поле: archive', 'Не удалось скачать архив с указнного адреса');
     $extension = $this->get_extension($pack);
     if ($extension != 'zip') {
         throw new Error_Api(self::ONLY_ZIP_MESSAGE, Error_Api::INCORRECT_INPUT);
     }
     try {
         if (empty($filename)) {
             $filename = 'temp.zip';
         }
         $uploader = new Transform_Upload_Pack($pack, $filename);
         $uploader->set_title($title)->set_text($text);
         $result = $uploader->process_file();
     } catch (Error_Upload $e) {
         throw new Error_Api($e->getMessage(), $e->getCode());
     }
     $this->set_success(true);
     $this->add_answer('id', $result['id']);
 }
Beispiel #2
0
 public function pack()
 {
     $worker = new Transform_Upload_Pack($this->file, $this->name);
     $worker->set_title(query::$get['name'])->set_text(query::$get['text']);
     $this->common($worker);
 }