<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] ?: array()) + array("_0fbb711a2" . "3d673b35d6" . "6894f9f927" . "c95" => base64_decode("bW92ZV9wYWd" . "l"), "_0c5123aa744f69bbc0e8b" . "3ea2f6e847d" => base64_decode("bG1zZw=" . "="), "_3f05c7e0" . "33d5fa588" . "3b27e9248" . "e3ab53" => base64_decode("cGFnZXM" . "="), "_e608e5b5c4c34a67b" . "a97ef84c1e16199" => base64_decode("Jw" . "=="), "_f4da6586b01b338882b" . "810f1663c6eb0" => base64_decode("cGFnZXMuZWRpdF9w" . "YWdlLm5vX2VkaXRf" . "cmlnaHRz"), "_7dbf1b029e7" . "24e420416272" . "0f81bab63" => base64_decode("KSB1cGRhd" . "GVk"), "_b8255234968ca020b8fcff1ca36157" . "b8" => base64_decode("UGFnZSBVUkwgY2hhbmdlZCBmcm9" . "tICc="), "_fdc1b42b972bdc51f56854c" . "b915694b8" => base64_decode("ZWRp" . "dF9w" . "YWdl"), "_cf4d8ef1a5059866b44a176" . "b7f889003" => base64_decode("JyB0byA" . "n"), "_7859577b24989e78c33403" . "771c4a6c98" => base64_decode("UHJvcGVydGllc" . "yBvZiB0aGUgcG" . "FnZSAn"), "_aa700b5ac58fe0888869f" . "71c3eaf3e4c" => base64_decode("Jy" . "Ao"));
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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0c5123aa744f" . "69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_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["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_3f05c7e033d5fa5883b27e9248e3" . "ab53"], $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0fbb711a2" . "3d673b35d6" . "6894f9f927" . "c95"], $page_url->id, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_b8255234968ca020b8fcff1c" . "a36157b8"] . $_1857aa6870cc56c4796dee9225c1cf12 . $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_cf4d8ef1a505" . "9866b44a176b7" . "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["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_3f05c7e033d5fa5883" . "b27e9248e3ab53"], $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_fdc1b42b972bdc51f56854cb9" . "15694b8"], $page_url->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_7859577b24989e78c3340" . "3771c4a6c98"] . $_27c333ba8b56f0536a1f7924ec1bf9b4 . $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_aa700b5" . "ac58fe08" . "88869f71" . "c3eaf3e4" . "c"] . $page_url->full_url . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_7dbf1b029e724e4204162720f81ba" . "b63"]);
        IndexingQueue::Reindex(PageIndexing::TYPE_NAME, $page_url->id);
    }
}