Пример #1
0
 public function show()
 {
     global $objPage;
     $back = \Controller::generateFrontendUrl($objPage->row(), null, null, true);
     $blnAjax = false;
     $objModal = new Modal($this->objModal, $this->arrConfig);
     $objModal->setBackLink($back);
     $objResponse = new ResponseSuccess();
     $objResponse->setResult(new ResponseData($objModal->generate(), array('id' => $this->objModal->id)));
     $objResponse->setUrl(AjaxAction::removeAjaxParametersFromUrl(Request::getInstance()->getRequestUri()));
     return $objResponse;
 }
 /**
  * Hook upon PageRegular to register modal and render them
  *
  * @param $objPage
  * @param $objLayout
  * @param $objPageRegular
  *
  * @return void
  */
 public function generatePageWithModal($objPage, $objLayout, &$objPageRegular)
 {
     // Do not handle the page if no modal item has been specified or page is no regular
     if (!\Input::get('modals') || $objPage->type != 'regular') {
         return;
     }
     $objModel = ModalModel::findPublishedByIdOrAliasWithoutLinkedPage(\Input::get('modals'));
     if ($objModel === null && $objPage->linkModal) {
         $objModel = ModalModel::findPublishedByIdOrAlias($objPage->modal);
     }
     $blnCheck = true;
     if ($objModel === null) {
         $blnCheck = false;
     }
     $objModel = $objModel->current();
     $arrConfig = static::getModalConfig($objModel, $objLayout, $objPage);
     Ajax::runActiveAction(Modal::MODAL_NAME, 'redirect', new ModalAjax($objModel->current(), $arrConfig));
     Ajax::runActiveAction(Modal::MODAL_NAME, 'show', new ModalAjax($objModel->current(), $arrConfig));
     if (empty($arrConfig)) {
         $blnCheck = false;
     }
     if (!$blnCheck) {
         /** @var \PageError404 $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
     }
     $back = \Controller::generateFrontendUrl($objPage->row(), null, null, true);
     $objModal = new Modal($objModel, $arrConfig);
     $objModal->setBackLink($back);
     // render modal within main, as it is the most commonly used region and enabled within contao by default
     $strBuffer = $objModal->generate();
     $objPageRegular->Template->main .= $strBuffer;
 }