Example #1
0
 /**
  * Generate media attribute
  *
  * @param \Isotope\Interfaces\IsotopeProduct $objProduct
  * @param array $arrOptions
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $strPoster = null;
     $arrFiles = deserialize($objProduct->{$this->field_name}, true);
     // Return if there are no files
     if (empty($arrFiles) || !is_array($arrFiles)) {
         return '';
     }
     // Get the file entries from the database
     $objFiles = \FilesModel::findMultipleByIds($arrFiles);
     if (null === $objFiles) {
         return '';
     }
     // Find poster
     while ($objFiles->next()) {
         if (in_array($objFiles->extension, trimsplit(',', $GLOBALS['TL_CONFIG']['validImageTypes']))) {
             $strPoster = $objFiles->uuid;
             $arrFiles = array_diff($arrFiles, array($objFiles->uuid));
         }
     }
     $objContentModel = new \ContentModel();
     $objContentModel->type = 'media';
     $objContentModel->cssID = serialize(array('', $this->field_name));
     $objContentModel->playerSRC = serialize($arrFiles);
     $objContentModel->posterSRC = $strPoster;
     if ($arrOptions['autoplay']) {
         $objContentModel->autoplay = '1';
     }
     if ($arrOptions['width'] || $arrOptions['height']) {
         $objContentModel->playerSize = serialize(array($arrOptions['width'], $arrOptions['height']));
     }
     $objElement = new \ContentMedia($objContentModel);
     return $objElement->generate();
 }
Example #2
0
 /**
  * Parse an item and return it as string
  * @param object
  * @param boolean
  * @param string
  * @param integer
  * @param object
  * @return string
  */
 public function parseSermon($objSermon, $blnAddArchive = false, $strClass = '', $intCount = 0, $objConfig)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate($objConfig->template);
     $objTemplate->setData($objSermon->row());
     $objTemplate->sermonId = standardize(\String::restoreBasicEntities($objSermon->title));
     $objTemplate->class = ($objSermon->cssClass != '' ? ' ' . $objSermon->cssClass : '') . $strClass;
     $objTemplate->count = $intCount;
     // see #5708
     $objTemplate->date = \Date::parse($objPage->dateFormat, $objSermon->date);
     $objTemplate->subject = $objSermon->title;
     $objTemplate->speakerLabel = $GLOBALS['TL_LANG']['MSC']['preacher'];
     $objTemplate->moderatorLabel = $GLOBALS['TL_LANG']['MSC']['moderator'];
     $objTemplate->addImage = false;
     // Add an image
     if ($objSermon->addImage && $objSermon->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objSermon->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objSermon->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrSermon = $objSermon->row();
             $arrSermon['singleSRC'] = $objModel->path;
             $this->addImageToTemplate($objTemplate, $arrSermon);
         }
     }
     // Add the audio file
     if ($objSermon->audioSingleSRC != '') {
         /*$this->import('getid3');
         			$getID3 = new \getID3();
         
         			$ThisFileInfo = $getID3->analyze($objAudioModel = \FilesModel::findByUuid($objSermon->audioSingleSRC)->path);
         			print_r($ThisFileInfo['tags']['id3v2']);*/
         $objAudio = $objSermon;
         $objAudio->playerSRC = serialize(array($objSermon->audioSingleSRC));
         $contentPlayer = new \ContentMedia($objAudio);
         $objTemplate->player = $contentPlayer->generate();
     }
     if ($objSermon->getRelated('pid')->showRssFeed) {
         $linkedRssFeed = \SermonFeedModel::findByPk($objSermon->getRelated('pid')->linkedRssFeed);
         if ($linkedRssFeed) {
             $objTemplate->feedHref = sprintf("%s/share/%s.xml", \Environment::get('path'), $linkedRssFeed->alias);
         }
     }
     $objTemplate->addReference = false;
     // Add an Reference
     switch ($objSermon->addReference) {
         case 'none':
             $objTemplate->addReference = false;
             break;
         case 'file':
             $objTemplate->addReference = true;
             $objDownload = $objSermon;
             $objDownload->singleSRC = $objSermon->fileSingleSRC;
             $contentDownload = new \ContentDownload($objDownload);
             $objTemplate->reference = $contentDownload->generate();
             break;
         case 'link':
             $objTemplate->addReference = true;
             $contentHyperlink = new \ContentHyperlink($objSermon);
             $objTemplate->reference = $contentHyperlink->generate();
             break;
     }
     //Syndication Facebook
     $objRedirectPage = \PageModel::findByPk($objSermon->getRelated('pid')->jumpTo);
     //Download Predigt
     $objDownload = $objSermon;
     $objDownload->singleSRC = $objSermon->audioSingleSRC;
     $objDownload->linkTitle = '<img src="files/layout/icons/download.png" width="20" height="20" alt="">';
     $objDownload->titleText = $GLOBALS['TL_LANG']['sermoner']['downloadTitle'];
     $contentDownload = new \ContentDownload($objDownload);
     $objTemplate->sermonDownload = $contentDownload->generate();
     $objTemplate->encUrl = rawurlencode(\Environment::get('base') . ampersand($this->generateFrontendUrl($objRedirectPage->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objSermon->alias != '' ? $objSermon->alias : $objSermon->id))));
     $objTemplate->encTitle = rawurlencode($objSermon->title);
     return $objTemplate->parse();
 }