/**
  * Add the html attribute to allowed elements
  *
  * @param \Template $objTemplate
  */
 public function parseTemplate($objTemplate)
 {
     if (!$objTemplate instanceof \FrontendTemplate || !$objTemplate->allowAjaxReload) {
         return;
     }
     // Determine whether we have a module or a content element by the vars given at this point
     if (\Module::findClass($objTemplate->type)) {
         $strType = 'mod';
     } elseif (\ContentElement::findClass($objTemplate->type)) {
         $strType = 'ce';
     } else {
         return;
     }
     // Some elements use the auto_item which we need to pass
     $strAutoItem = Input::getAutoItem('auto_item');
     // cssID is parsed in all common templates
     // Use cssID for our attribute
     $objTemplate->cssID .= sprintf(' data-ajax-reload-element="%s::%u"%s%s', $strType, $objTemplate->id, strlen($strAutoItem) ? sprintf(' data-ajax-reload-auto-item="%s"', $strAutoItem) : '', $objTemplate->ajaxReloadFormSubmit ? ' data-ajax-reload-form-submit=""' : '');
 }
Ejemplo n.º 2
0
 /**
  * Find a content element in the TL_CTE array and return the class name
  *
  * @param string $strName The content element name
  *
  * @return string The class name
  *
  * @deprecated Use ContentElement::findClass() instead
  */
 public static function findContentElement($strName)
 {
     return \ContentElement::findClass($strName);
 }
 /**
  * Generate a content element and return it as string
  *
  * @param mixed  $intId     A content element ID or a Model object
  * @param string $strColumn The column the element is in
  *
  * @return string The content element HTML markup
  */
 protected static function getContentElementAjax($intId, $strColumn = 'main')
 {
     if (is_object($intId)) {
         $objRow = $intId;
     } else {
         if (!strlen($intId) || $intId < 1) {
             return '';
         }
         $objRow = \ContentModel::findByPk($intId);
         if ($objRow === null) {
             return '';
         }
     }
     // Check the visibility (see #6311)
     if (!static::isVisibleElement($objRow)) {
         return '';
     }
     $strClass = \ContentElement::findClass($objRow->type);
     // Return if the class does not exist
     if (!class_exists($strClass)) {
         \System::log('Content element class "' . $strClass . '" (content element "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
         return '';
     }
     $objRow->typePrefix = 'ce_';
     $objElement = new $strClass($objRow, $strColumn);
     $strBuffer = AjaxInput::get('g') == '1' ? $objElement->generate() : $objElement->generateAjax();
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getContentElement']) && is_array($GLOBALS['TL_HOOKS']['getContentElement'])) {
         foreach ($GLOBALS['TL_HOOKS']['getContentElement'] as $callback) {
             $strBuffer = static::importStatic($callback[0])->{$callback}[1]($objRow, $strBuffer, $objElement);
         }
     }
     return $strBuffer;
 }