/**
  * Return all modals grouped by archive
  *
  * @param  \DataContainer $dc
  *
  * @return array
  */
 public function getModalOptions(\DataContainer $dc)
 {
     $arrOptions = array();
     $objModal = ModalModel::findAll();
     if ($objModal === null) {
         return $arrOptions;
     }
     while ($objModal->next()) {
         if (($objArchive = $objModal->getRelated('pid')) === null) {
             continue;
         }
         $arrOptions[$objArchive->title][$objModal->id] = $objModal->title;
     }
     return $arrOptions;
 }
Example #2
0
 /**
  * @param \HeimrichHannot\Teaser\ContentLinkTeaser $objElement
  * @param bool $blnShowMore
  *
  * @return bool true if teaser modal link is valid
  */
 public function generateModalTeaserLink(&$objElement, $blnShowMore)
 {
     if ($objElement->source != 'modal' && !$objElement->modal) {
         return $blnShowMore;
     }
     $objModal = ModalModel::findByPk($objElement->modal);
     if ($objModal === null) {
         return false;
     }
     $arrConfig = static::getModalConfig($objModal);
     $blnAjax = true;
     $objElement->setHref(ModalController::generateModalUrl($objModal->row(), $objElement->jumpTo, $blnAjax));
     $objElement->setTitle($objModal->title);
     if ($blnAjax && is_array($arrConfig['link']['attributes'])) {
         $objElement->setLinkAttributes($arrConfig['link']['attributes']);
     }
     return true;
 }
 /**
  * Get the config for a given modal
  *
  * @param ModalModel $objModal
  * @param null       $objLayout
  *
  * @return array The configuration array
  */
 public static function getModalConfig(ModalModel $objModal, $objLayout = null)
 {
     $default = static::getDefaultModalType();
     $arrTypes = $GLOBALS['TL_MODALS'];
     $arrConfig = array();
     $strType = '';
     // default config
     if (isset($arrTypes[$default])) {
         $strType = $default;
     }
     // overwrite by tl_layout
     if ($objLayout->customModal && isset($arrTypes[$objLayout->modal])) {
         $strType = $objLayout->modal;
     }
     // overwrite by tl_modal_archive
     if (($objArchive = $objModal->getRelated('pid')) !== null && $objArchive->customModal && isset($arrTypes[$objArchive->modal])) {
         $strType = $objArchive->modal;
     }
     // overwrite by tl_modal
     if ($objModal->customModal && isset($arrTypes[$objModal->modal])) {
         $strType = $objModal->modal;
     }
     if (is_array($arrTypes[$strType])) {
         $arrConfig = array_merge(array('type' => $strType), $arrTypes[$strType]);
     }
     return $arrConfig;
 }