<?php
namespace Claromentis\Gallery\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("_8000500334026c6175" . "96255d3914c33d" => base64_decode("WW91IGRvbid0IGhhdmUgcGVybWlzc2lvbi" . "B0byB2aWV3IHRoaXMgaW1hZ2U="), "_66e78cb3e" . "cbe9e2ac0e" . "f58fa36e76" . "2bb" => base64_decode("bGlrZXNfY29t" . "cG9uZW50Lm9i" . "amVjdF9pZA=="), "_4b5e91a0a6f7f822ac389a" . "d9a3fb0ee2" => base64_decode("c3VjY2Vzcw=" . "="), "_3c438e5e63445b53" . "f7de51913730eeab" => base64_decode("bnVsb" . "A=="), "_32283335abba069bb099a4714" . "598c28b" => base64_decode("Z2FsbGVyeS9pbmNsdWRlcy" . "9pbWFnZV9jb21tZW50cy5o" . "dG1s"), "_4be135064c4d55c13e6af60c45cb1fd" . "a" => base64_decode("Z2FsbGVyeS5wZXJtaXNzaW9uc" . "w=="), "_1c8a00652c6c89e9e0a7d896cb82a2" . "bd" => base64_decode("Y29tbWVudHNfY29tcG9" . "uZW50Lm9iamVjdF9pZA" . "=="), "_0c5123aa744f69bbc0e8b3ea2f6e84" . "7d" => base64_decode("bG1zZ" . "w=="), "ima" . "ge" => base64_decode("aW1hZ2U" . "="), "_5452ca1b" . "18704a7b6" . "c2d7e7a53" . "e4ae47" => base64_decode("Z2FsbGVyeS5ub" . "19pbWFnZV9pZA" . "=="), "_cd644f2" . "63509b3f" . "84690c7c" . "5d4bcdf1" . "8" => base64_decode("Z2FsbGVyeS9pbmNsdWRlcy" . "9pbWFnZV9tZXRhZGF0YS5o" . "dG1s"), "_e05e002" . "2a2e5ad3" . "44b9c4a0" . "d3f64e1a" . "5" => base64_decode("bWV" . "zc2" . "FnZ" . "Q=="), "_0bc7588938bfc7dc40d438d" . "105dcdf1c" => base64_decode("YW" . "xi" . "dW" . "0="), "_75d423257ba44815" . "5cc97033e61f426f" => base64_decode("Z2FsbGVyeS9pbmNsdWRlcy9pbWFn" . "ZV9saWtlcy5odG1s"));
use Claromentis\Gallery\GalleryPermissions;
use Claromentis\Core\Application;
use Claromentis\Core\Http\gpc;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Http\TemplaterCallResponse;
use Exception;
use Image;
use ImageAlbum;
use ImageLightbox;
use InvalidArgumentException;
use Claromentis\Core\Http\SymfonyRequest;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use TokenException;
class ImageDetailsController
{
    
    
    
    
    
    
    
    
    
    
    
    
    public function ValidateImage(SymfonyRequest $request)
    {
        global $g_application;
        $_84e255a4ec669726bc592e3153ce97c1 = $g_application[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4be135064c4d55c13e6af6" . "0c45cb1fda"]];
        if (!$request->attributes->has($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["i" . "m" . "a" . "g" . "e"]) || !$request->attributes->get($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["ima" . "ge"])) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_0c5123aa744f69bbc0e8b3e" . "a2f6e847d"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_5452ca1" . "b18704a7" . "b6c2d7e7" . "a53e4ae4" . "7"]));
        }
        $_0813911845a745577176d995fee240ad = $request->attributes->get($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["imag" . "e"]);
        $image = new Image();
        $image->Load($_0813911845a745577176d995fee240ad);
        if (!$image->GetId() || !$image->GetAlbumId()) {
            throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_0c5123aa744f6" . "9bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_5452ca1b1870" . "4a7b6c2d7e7a5" . "3e4ae47"]));
        }
        $_0bc7588938bfc7dc40d438d105dcdf1c = new ImageAlbum($image->GetAlbumID());
        if (!$_0bc7588938bfc7dc40d438d105dcdf1c->UserHasPermission(PERM_VIEW) && !$_84e255a4ec669726bc592e3153ce97c1->CanIManageAlbums()) {
            throw new Exception($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_8000500334026c617596255d3914" . "c33d"]);
        }
        $request->attributes->set($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["i" . "m" . "a" . "g" . "e"], $image);
        $request->attributes->set($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0bc7588938bfc7dc40d4" . "38d105dcdf1c"], $_0bc7588938bfc7dc40d438d105dcdf1c);
        return null;
    }
    
    
    
    
    
    
    
    
    public function GetComments(Application $app, $image)
    {
        $args = [$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_1c8a00652c6c89e9e0a7d89" . "6cb82a2bd"] => $image->GetId()];
        return new TemplaterCallResponse($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_32283335ab" . "ba069bb099a" . "4714598c28b"], $args);
    }
    
    
    
    
    
    
    
    
    
    
    public function GetMetadata(Application $app, Image $image)
    {
        
        
        global $args, $datasources;
        
        
        
        
        $_25941f62b00d37649aecb69932bb2fba = [0 => $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_3c438e5e63445b53f7de519" . "13730eeab"]];
        $_e0f99d1e2fd6c8ce39dd84c5242ed7ed = [];
        $_0bc7588938bfc7dc40d438d105dcdf1c = new ImageAlbum($image->GetAlbumId());
        $_95aa76f19a87d9905f9a740fac0bde2e = $image->GetImageTags();
        $_0bc7588938bfc7dc40d438d105dcdf1c->PrepareTagOptions($_e0f99d1e2fd6c8ce39dd84c5242ed7ed, $_25941f62b00d37649aecb69932bb2fba);
        $_0bc7588938bfc7dc40d438d105dcdf1c->GetTagsAsHTML($args, $datasources, $_95aa76f19a87d9905f9a740fac0bde2e, $_e0f99d1e2fd6c8ce39dd84c5242ed7ed);
        $image->ShowMetadataFields($_25941f62b00d37649aecb69932bb2fba, false);
        $_fd5a3a643834299cbdadfc3540ba0bcb = new TemplaterCallResponse($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_cd644f263509b3f84690c7c5d4" . "bcdf18"], $args);
        $_fd5a3a643834299cbdadfc3540ba0bcb->SetDatasrc($datasources);
        return $_fd5a3a643834299cbdadfc3540ba0bcb;
    }
    
    
    
    
    
    
    
    
    public function GetLikes(Application $app, $image)
    {
        $args = [$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_66e78cb3ecbe9e2a" . "c0ef58fa36e762bb"] => $image->GetId()];
        return new TemplaterCallResponse($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_75d423257ba4" . "48155cc97033e" . "61f426f"], $args);
    }
    
    
    
    
    
    
    
    
    
    
    public function Favorite(Application $app, ServerRequestInterface $request, $image)
    {
        gpc::CheckToken($request);
        $_b30480f39eddbe8df8bb6d564d5eb7b9 = new ImageLightbox($app->security->GetUserId());
        if (!$_b30480f39eddbe8df8bb6d564d5eb7b9->AddToLightbox([$image->GetId()])) {
            return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4b5e91a0a6" . "f7f822ac389" . "ad9a3fb0ee2"] => false, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_e05e0022a2e5ad344b9c4a0d" . "3f64e1a5"] => $_b30480f39eddbe8df8bb6d564d5eb7b9->GetErrMsg()], 500);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4b5e91a0a6f7f" . "822ac389ad9a3f" . "b0ee2"] => true]);
    }
    
    
    
    
    
    
    
    
    
    
    public function Unfavorite(Application $app, ServerRequestInterface $request, $image)
    {
        gpc::CheckToken($request);
        $_b30480f39eddbe8df8bb6d564d5eb7b9 = new ImageLightbox($app->security->GetUserId());
        if (!$_b30480f39eddbe8df8bb6d564d5eb7b9->DeleteFromLightbox([$image->GetId()])) {
            return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_4b5e91a0a6f7f822ac389ad9a3fb" . "0ee2"] => false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e05e0022a2" . "e5ad344b9c4" . "a0d3f64e1a5"] => $_b30480f39eddbe8df8bb6d564d5eb7b9->GetErrMsg()], 500);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4b5e91a0a6f7f822ac389ad" . "9a3fb0ee2"] => true]);
    }
}