public function contentDownloadAll($request)
 {
     $URLs = array();
     $signed_url = '';
     $smil_url = '';
     $required = array();
     $required['metadata_id'] = $request->parameters['metadata_id'];
     $required['child_id'] = '';
     $this->config = new Config\Config();
     $private_key_filename = '/var/www/api/v3/pk-APKAI6KQIZYCKQ2ZFREA.pem';
     $key_pair_id = 'APKAI6KQIZYCKQ2ZFREA';
     $domain = 'http://d12m6hc8l1otei.cloudfront.net/';
     $expires = time() + 60 * 60;
     $json = json_encode($request->parameters);
     $contentDownload = new ContentDownload();
     $jsonObj = json_decode($json);
     $jsonResMessage = $contentDownload->validateJsonForAll($jsonObj);
     if (!empty($jsonResMessage) || strlen($jsonResMessage) != 0 || $jsonResMessage != '') {
         //in case of missing parameters
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => $jsonResMessage);
         $this->errorLog->LogError('ContentDownloadController:contentDownloadData#' . json_encode($response));
         $this->outputError($response);
         return;
     }
     $contents = $contentDownload->getContentDownloadPathForAll($required);
     for ($i = 0; $i < count($contents); $i++) {
         $ext = pathinfo($contents[$i]['FileName'], PATHINFO_EXTENSION);
         switch ($ext) {
             case 'mp3':
                 //path for audio files
                 $asset_path[] = $domain . 'audio/' . $contents[$i]['FileName'];
                 break;
             case 'txt':
                 $asset_path[] = $domain . 'text/' . $contents[$i]['FileName'];
                 //path for text files
                 break;
             case '3gp':
             case 'mp4':
                 $asset_path[] = $domain . 'video/' . $contents[$i]['FileName'];
                 break;
             case 'jpg':
                 //path for image files
             //path for image files
             case 'jpeg':
                 //path for image files
             //path for image files
             case 'gif':
             case 'png':
                 $asset_path[] = $domain . 'wallpapers/' . $contents[$i]['FileName'];
                 break;
             case 'apk':
                 //path for audio files
             //path for audio files
             case 'jar':
                 //path for audio files
             //path for audio files
             case 'jad':
                 //path for audio files
                 $asset_path[] = $domain . 'games/' . $contents[$i]['FileName'];
                 break;
         }
     }
     for ($i = 0; $i < count($asset_path); $i++) {
         if (!empty($asset_path)) {
             $downloadingURL[] = $this->config->create_signed_url($asset_path[$i], $private_key_filename, $key_pair_id, $expires);
         }
     }
     if (empty($downloadingURL)) {
         //in case of non-existing package
         $response = array("status" => "SUCCESS", "status_code" => '200', 'msgs' => 'Download URLs not available');
         $this->outputSuccess($response);
         $this->successLog->LogInfo('ContentDownloadController:contentDownloadData#' . json_encode($response));
         return;
     }
     $response = array("status" => "SUCCESS", "status_code" => '200', 'Downloading URLs' => $downloadingURL);
     $this->outputSuccess($response);
     $this->successLog->LogInfo('ContentDownloadController:contentDownloadData#' . json_encode($response));
     return;
 }
예제 #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();
 }