/**
  * Rebuild Vimeo cache
  *
  * @param DataContainer $dc
  */
 public function rebuildVimeoCache(DataContainer $dc)
 {
     $rebuilder = new Rebuilder();
     try {
         $result = $rebuilder->rebuildElementCache(ContentModel::findByPk($dc->id));
     } catch (\InvalidArgumentException $e) {
         return;
     } catch (\RuntimeException $e) {
         System::log(sprintf('Unable to rebuild Vimeo cache of element ID %s: %s', $dc->id, $e->getMessage()), __METHOD__, TL_ERROR);
         $result = false;
     }
     if ($result === true) {
         Message::addConfirmation($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheConfirm']);
     } elseif ($result === false) {
         Message::addError($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheError']);
     }
 }
예제 #2
0
 /**
  * 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
  */
 public static function getContentElement($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)) {
         static::log('Content element class "' . $strClass . '" (content element "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
         return '';
     }
     $objRow->typePrefix = 'ce_';
     /** @var \ContentElement $objElement */
     $objElement = new $strClass($objRow, $strColumn);
     $strBuffer = $objElement->generate();
     // 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);
         }
     }
     // Disable indexing if protected
     if ($objElement->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) {
         $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
     }
     return $strBuffer;
 }
예제 #3
0
 /**
  * Handle the element AJAX action
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 protected function handleElementAction()
 {
     // Throw an error if content element could not be found
     if (($contentElement = ContentModel::findByPk(Input::post('id'))) === null) {
         System::log(sprintf('Unable to find the content element ID %s', Input::post('id')), __METHOD__, TL_ERROR);
         header('HTTP/1.1 400 Bad Request');
         die('Bad Request');
     }
     $dataProvider = $this->getBatchProvider();
     $callback = static::getCallbackInstance($contentElement->type);
     if (!$callback->rebuild($dataProvider, $contentElement)) {
         header('HTTP/1.1 400 Bad Request');
         die('Bad Request');
     }
     header('HTTP/1.1 200 OK');
     die('OK');
 }