Ejemplo n.º 1
0
 public function performAction()
 {
     ob_end_clean();
     $id = $this->albumId;
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Content-Type: application/json");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     try {
         $album = Album::findByPrimaryKey($id);
         if (!$album) {
             throw new \Exception('Album not found');
         }
         $user = AuthService::getInstance()->getUser();
         $fileStorage = FileStorage::getInstance();
         $fileStorage->receiveAction($user->urlName . '/' . $album->title);
         foreach (FileStorage::getInstance()->savedFiles as $filePath => $fileUrl) {
             $image = new Image();
             $image->albumId = $album->id;
             $image->path = $filePath;
             $image->url = $fileUrl;
             $image->save();
             $album->imagesCount++;
         }
         $album->save();
         echo '{"jsonrpc" : "2.0", "result" : null, "id" : "id"}';
     } catch (\Exception $exception) {
         $result = array('jsonrpc' => '2.0', 'error' => array('code' => $exception->getCode(), 'message' => $exception->getMessage()), 'id' => 'id');
         echo json_encode($result);
     }
     exit;
 }
Ejemplo n.º 2
0
 public function performAction()
 {
     $album = Album::findByPrimaryKey($this->albumId);
     if (!$album) {
         throw new \Exception('Album not found');
     }
     $images = Image::statement()->where('? = ?', Image::columns()->albumId, $this->albumId)->query()->fetchAll();
     if ($images) {
         $this->response->addContent(new Rows(Processor::create($images)->map(function (Image $image) {
             $row = array();
             $row['Path'] = $image->path;
             $row['Url'] = $image->url;
             return $row;
         })));
     }
     $uploadHandler = Upload::createState();
     $uploadHandler->albumId = $this->albumId;
     $uploadUrl = (string) $this->io->makeAnchor($uploadHandler);
     $this->response->addContent(new Form($uploadUrl));
 }
Ejemplo n.º 3
0
 static function setUpColumns($columns)
 {
     $columns->imageId = Image::columns()->id;
     $columns->exifTagId = ExifTag::columns()->id;
     $columns->exifValue = Column::STRING;
 }
Ejemplo n.º 4
0
 public function getTables()
 {
     /** @var Table[] $tables */
     $tables = array(Identity::table(), IdentityProvider::table(), Session::table(), User::table(), UserIdentity::table(), Album::table(), ExifTag::table(), Image::table(), ImageExif::table());
     return $tables;
 }