Ejemplo n.º 1
0
 public function performAction()
 {
     $user = AuthService::getInstance()->getUser();
     $album = new Album();
     $album->userId = $user->id;
     $album->title = $this->title;
     $album->created = time();
     $album->updated = $album->created;
     $album->imagesCount = 0;
     $album->save();
     Router::redirect($this->io->makeAnchor(Catalog::createState()));
 }
Ejemplo n.º 2
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.º 3
0
 static function setUpColumns($columns)
 {
     $columns->id = Column::AUTO_ID;
     $columns->albumId = Column::cast(Album::columns()->id)->copy()->setFlag(Column::NOT_NULL, false);
     $columns->height = Column::INTEGER + Column::SIZE_2B + Column::NOT_NULL;
     $columns->width = Column::INTEGER + Column::SIZE_2B + Column::NOT_NULL;
     $columns->path = Column::STRING + Column::NOT_NULL;
     $columns->url = Column::STRING + Column::NOT_NULL;
     $columns->hash = Column::create(Column::STRING)->setStringLength(32, true)->setUnique();
 }
Ejemplo n.º 4
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.º 5
0
 public function performAction()
 {
     if (!($user = AuthService::getInstance()->getUser())) {
         throw new \Exception('Authenticated user required');
     }
     $this->response->success('CATALOGE!');
     /** @var Album[] $albums */
     $albums = Album::statement()->where('? = ?', Album::columns()->userId, $user->id)->query()->fetchAll();
     $this->response->addContent(new Form(Create::createState(), $this->io));
     $details = Details::createState();
     if ($albums) {
         $this->response->addContent(new Rows(Processor::create($albums)->map(function (Album $album) use($details) {
             $row = array();
             $details->albumId = $album->id;
             $anchor = $this->io->makeAnchor($details);
             $row['Title'] = new Anchor($album->title, $anchor);
             $row['Created'] = date('Y-m-d H:i:s', $album->created);
             $row['Updated'] = date('Y-m-d H:i:s', $album->updated);
             $row['Images'] = $album->imagesCount;
             return $row;
         })));
     }
 }
Ejemplo n.º 6
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;
 }