Файл: concrete5.7.5.6/concrete/controllers/backend/block/action.php
Строк: 162
<?php
namespace ConcreteControllerBackendBlock;
use ConcreteCoreBlockBlockController;
use ConcreteCoreControllerAbstractController;
use ConcreteCoreHttpResponse;
use ConcreteCorePageTypeComposerControlBlockControl;
use ConcreteCorePageTypeComposerFormLayoutSetControl;
class Action extends AbstractController
{
public function add($cID, $arHandle, $btID, $action)
{
$c = Page::getByID($cID);
if (is_object($c) && !$c->isError()) {
$a = Area::getOrCreate($c, $arHandle);
if (is_object($a)) {
$ap = new Permissions($a);
$bt = BlockType::getByID($btID);
if (is_object($bt)) {
$controller = $bt->getController();
if ($controller->validateAddBlockPassThruAction($ap, $bt)) {
return $this->deliverResponse($controller, $action);
}
}
}
}
$response = new Response(t('Access Denied'));
return $response;
}
protected function deliverResponse(BlockController $controller, $action)
{
list($method, $parameters) = $controller->getPassThruActionAndParameters(array($action));
if ($controller->isValidControllerTask($method, $parameters)) {
$controller->on_start();
$response = $controller->runAction($method, $parameters);
if ($response instanceof SymfonyComponentHttpFoundationResponse) {
return $response;
} else {
$r = new Response($response);
return $r;
}
}
$response = new Response(t('Access Denied'));
return $response;
}
public function edit($cID, $arHandle, $bID, $action)
{
$c = Page::getByID($cID);
if (is_object($c) && !$c->isError()) {
$b = Block::getByID($bID, $c, $arHandle);
if (is_object($b)) {
$controller = $b->getController();
if ($controller->validateEditBlockPassThruAction($b)) {
return $this->deliverResponse($controller, $action);
}
}
}
$response = new Response(t('Access Denied'));
return $response;
}
public function add_composer($ptComposerFormLayoutSetControlID, $action)
{
$setControl = FormLayoutSetControl::getByID($ptComposerFormLayoutSetControlID);
if (is_object($setControl)) {
$formControl = $setControl->getPageTypeComposerControlObject();
if ($formControl instanceof BlockControl) {
$set = $setControl->getPageTypeComposerFormLayoutSetObject();
$type = $set->getPageTypeObject();
$controller = $formControl->getBlockTypeObject()->getController();
if ($controller->validateComposerAddBlockPassThruAction($type)) {
return $this->deliverResponse($controller, $action);
}
}
}
$response = new Response(t('Access Denied'));
return $response;
}
public function edit_composer($cID, $arHandle, $ptComposerFormLayoutSetControlID, $action)
{
$c = Page::getByID($cID);
$setControl = FormLayoutSetControl::getByID($ptComposerFormLayoutSetControlID);
if (is_object($setControl)) {
if (is_object($c) && !$c->isError()) {
$formControl = $setControl->getPageTypeComposerControlObject();
if ($formControl instanceof BlockControl) {
$b = $formControl->getPageTypeComposerControlBlockObject($c);
if (is_object($b)) {
$controller = $b->getController();
if ($controller->validateComposerEditBlockPassThruAction($b)) {
return $this->deliverResponse($controller, $action);
}
}
}
}
}
$response = new Response(t('Access Denied'));
return $response;
}
}