<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_0c5123aa744f69bbc0e8b3e" . "a2f6e847d" => base64_decode("bG" . "1z" . "Zw" . "=="), "_7859577b" . "24989e78c" . "33403771c" . "4a6c98" => base64_decode("UHJvcGVydGllcyBvZi" . "B0aGUgcGFnZSAn"), "_7dbf1b029e724e4204162720f81b" . "ab63" => base64_decode("KSB1c" . "GRhdG" . "Vk"), "_0fbb711a23d673b35d66894f9f92" . "7c95" => base64_decode("bW92ZV" . "9wYWdl"), "_3f05c7e03" . "3d5fa5883b" . "27e9248e3a" . "b53" => base64_decode("cGFn" . "ZXM="), "_f4da6586b01b338882" . "b810f1663c6eb0" => base64_decode("cGFnZXMuZWRp" . "dF9wYWdlLm5v" . "X2VkaXRfcmln" . "aHRz"), "_b8255234968ca020b8fcff1ca3615" . "7b8" => base64_decode("UGFnZSBVUkwgY2hhbmdlZCBmcm9tIC" . "c="), "_fdc1b42b972bdc51f56854cb915694b" . "8" => base64_decode("ZWRpd" . "F9wYW" . "dl"), "_e608e5b5c4c34a" . "67ba97ef84c1e16" . "199" => base64_decode("Jw=" . "="), "_cf4d8ef1a5059866" . "b44a176b7f889003" => base64_decode("JyB0byA" . "n"), "_aa700b5ac58fe08888" . "69f71c3eaf3e4c" => base64_decode("JyA" . "o"));
use Claromentis\Core\Acl\Acl;
use Claromentis\Core\Audit\Audit;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Pages\Exception\AccessDeniedException;
use Claromentis\Pages\Facade\ChangePageUrl;
use Claromentis\Pages\Model\PageUrl;
use Claromentis\Pages\PagesAcl;
use Claromentis\Pages\Repository\MenuItemRepository;
use Claromentis\Pages\Repository\PagesRepository;
use Claromentis\Pages\Repository\UrlRepository;
use Claromentis\Pages\Search\Indexing\PageIndexing;
use Claromentis\Search\Indexing\IndexingQueue;
use Date;




class UpdatePage
{
    protected $acl;
    protected $pages_repository;
    protected $url_repository;
    protected $change_url;
    protected $menu_repository;
    protected Audit $audit;
    public function __construct(PagesAcl $acl, ChangePageUrl $_c121337f7e56ded6207acc20784760c8, UrlRepository $_0ffc8e5433da0b1c27f79e871fb130bc, PagesRepository $_15c0717e770727776c3990dfe554a36b, MenuItemRepository $_068f775abfb0a9ebf75eaa65d57173c2, Audit $audit)
    {
        $this->acl = $acl;
        $this->pages_repository = $_15c0717e770727776c3990dfe554a36b;
        $this->url_repository = $_0ffc8e5433da0b1c27f79e871fb130bc;
        $this->change_url = $_c121337f7e56ded6207acc20784760c8;
        $this->menu_repository = $_068f775abfb0a9ebf75eaa65d57173c2;
        $this->audit = $audit;
    }
    public function UpdatePage(SecurityContext $context, PageUrl $page_url, $_27c333ba8b56f0536a1f7924ec1bf9b4, $_448e49be8059922f8a72387fe2ac1b35, $_fc1e44753723dce3f72da7914fc0941a, $_15dde8dee00152b4494d40d1d6753747, $_30113cae8b9629aea64a4c01fb054e3a = false, $_d1bb137f6c52d5fc1ab4a2d9807c4652 = true, $_25983d06eff5f52f829961d6bf1a7a70 = false, $_530826b7c3a64c47e1d2f603285d5fed = false)
    {
        if (!$this->acl->CanEditPageProperties($context, $page_url->active_page_id) && !$_530826b7c3a64c47e1d2f603285d5fed) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0c5123aa744f69bbc0e8b3ea2f" . "6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_f4da6586b0" . "1b338882b81" . "0f1663c6eb0"]));
        }
        $_221da17e3055fae8d3ff516b832a5f3b = $this->pages_repository->GetById($page_url->active_page_id);
        if ($_221da17e3055fae8d3ff516b832a5f3b->title !== $_27c333ba8b56f0536a1f7924ec1bf9b4) {
            $_221da17e3055fae8d3ff516b832a5f3b->SetTitle($_27c333ba8b56f0536a1f7924ec1bf9b4);
            $_d43c6db6d25c2749f65bc7bc28bd8df3 = $this->menu_repository->GetByUrlId($page_url->id);
            if ($_d43c6db6d25c2749f65bc7bc28bd8df3) {
                $_d43c6db6d25c2749f65bc7bc28bd8df3->SetTitle($_27c333ba8b56f0536a1f7924ec1bf9b4);
            }
        }
        $_221da17e3055fae8d3ff516b832a5f3b->SetShowTitleMenu($_fc1e44753723dce3f72da7914fc0941a, $_15dde8dee00152b4494d40d1d6753747);
        $_221da17e3055fae8d3ff516b832a5f3b->SetInherited($_30113cae8b9629aea64a4c01fb054e3a);
        if (!$_25983d06eff5f52f829961d6bf1a7a70) {
            $_221da17e3055fae8d3ff516b832a5f3b->SetModifiedBy($context->GetUserId());
            $_d230962d9a57dc6ba2b774d9ba3bb81e = new Date();
            $_221da17e3055fae8d3ff516b832a5f3b->SetModifiedByDate($_d230962d9a57dc6ba2b774d9ba3bb81e->getDate());
        }
        $_1857aa6870cc56c4796dee9225c1cf12 = $page_url->full_url;
        $this->change_url->ChangeUrlFragment($page_url, $_448e49be8059922f8a72387fe2ac1b35, $_d1bb137f6c52d5fc1ab4a2d9807c4652);
        if ($_1857aa6870cc56c4796dee9225c1cf12 !== $page_url->full_url) {
            $this->audit->Success($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_3f05c7e033d5fa5883b27e9248e" . "3ab53"], $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0fbb711a23d673b35d66894" . "f9f927c95"], $page_url->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_b825523" . "4968ca02" . "0b8fcff1" . "ca36157b" . "8"] . $_1857aa6870cc56c4796dee9225c1cf12 . $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_cf4d8ef1a5059866b44a176b7" . "f889003"] . $page_url->full_url . $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_e608e5b5c4c34a67ba97ef84c1e161" . "99"]);
        }
        $this->pages_repository->Save($_221da17e3055fae8d3ff516b832a5f3b);
        if (isset($_d43c6db6d25c2749f65bc7bc28bd8df3)) {
            $this->menu_repository->Save($_d43c6db6d25c2749f65bc7bc28bd8df3);
        }
        $this->audit->Success($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_3f05c7e" . "033d5fa5" . "883b27e9" . "248e3ab5" . "3"], $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_fdc1b42b9" . "72bdc51f56" . "854cb91569" . "4b8"], $page_url->id, $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_7859577b2498" . "9e78c33403771" . "c4a6c98"] . $_27c333ba8b56f0536a1f7924ec1bf9b4 . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_aa700b5ac58" . "fe0888869f71" . "c3eaf3e4c"] . $page_url->full_url . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_7dbf1b0" . "29e724e4" . "20416272" . "0f81bab6" . "3"]);
        IndexingQueue::Reindex(PageIndexing::TYPE_NAME, $page_url->id);
    }
}