当前位置: 首页>>代码示例>>PHP>>正文


PHP System::urlEncode方法代码示例

本文整理汇总了PHP中System::urlEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP System::urlEncode方法的具体用法?PHP System::urlEncode怎么用?PHP System::urlEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System::urlEncode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cb_parseTemplate

 public function cb_parseTemplate(\Template &$objTemplate)
 {
     global $objPage;
     if (strpos($objTemplate->getName(), 'news_') === 0) {
         if ($objTemplate->source == 'singlefile') {
             $modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC);
             try {
                 if ($modelFile === null) {
                     throw new \Exception("no file");
                 }
                 $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
                 if (!in_array($modelFile->extension, $allowedDownload)) {
                     throw new Exception("download not allowed by extension");
                 }
                 $objFile = new \File($modelFile->path, true);
                 $strHref = \System::urlEncode($objFile->value);
             } catch (\Exception $e) {
                 $strHref = "";
             }
             $target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
             $objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']);
             $objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline);
         }
     }
 }
开发者ID:kikmedia,项目名称:contao,代码行数:25,代码来源:NewsSingleFile.php

示例2: addToPDFSearchIndex

 protected static function addToPDFSearchIndex($strFile, $arrParentSet)
 {
     $objFile = new \File($strFile);
     if (!Validator::isValidPDF($objFile)) {
         return false;
     }
     $objDatabase = \Database::getInstance();
     $objModel = $objFile->getModel();
     $arrMeta = \Frontend::getMetaData($objModel->meta, $arrParentSet['language']);
     // Use the file name as title if none is given
     if ($arrMeta['title'] == '') {
         $arrMeta['title'] = specialchars($objFile->basename);
     }
     $strHref = \Environment::get('base') . \Environment::get('request');
     // Remove an existing file parameter
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->value);
     $arrSet = array('pid' => $arrParentSet['pid'], 'tstamp' => time(), 'title' => $arrMeta['title'], 'url' => $strHref, 'filesize' => \System::getReadableSize($objFile->size, 2), 'checksum' => $objFile->hash, 'protected' => $arrParentSet['protected'], 'groups' => $arrParentSet['groups'], 'language' => $arrParentSet['language'], 'mime' => $objFile->mime);
     // Return if the file is indexed and up to date
     $objIndex = $objDatabase->prepare("SELECT * FROM tl_search WHERE pid=? AND checksum=?")->execute($arrSet['pid'], $arrSet['checksum']);
     // there are already indexed files containing this file (same checksum and filename)
     if ($objIndex->numRows) {
         // Return if the page with the file is indexed
         if (in_array($arrSet['pid'], $objIndex->fetchEach('pid'))) {
             return false;
         }
         $strContent = $objIndex->text;
     } else {
         try {
             // parse only for the first occurrence
             $parser = new \Smalot\PdfParser\Parser();
             $objPDF = $parser->parseFile($strFile);
             $strContent = $objPDF->getText();
         } catch (\Exception $e) {
             // Missing object refernce #...
             return false;
         }
     }
     // Put everything together
     $arrSet['text'] = $strContent;
     $arrSet['text'] = trim(preg_replace('/ +/', ' ', \String::decodeEntities($arrSet['text'])));
     // Update an existing old entry
     if ($objIndex->pid == $arrSet['pid']) {
         $objDatabase->prepare("UPDATE tl_search %s WHERE id=?")->set($arrSet)->execute($objIndex->id);
         $intInsertId = $objIndex->id;
     } else {
         $objInsertStmt = $objDatabase->prepare("INSERT INTO tl_search %s")->set($arrSet)->execute();
         $intInsertId = $objInsertStmt->insertId;
     }
     static::indexContent($arrSet, $intInsertId);
 }
开发者ID:heimrichhannot,项目名称:contao-search_plus,代码行数:53,代码来源:Search.php

示例3: generate

 public function generate(WatchlistItemModel $objItem, Watchlist $objWatchlist)
 {
     global $objPage;
     $objFileModel = \FilesModel::findById($objItem->uuid);
     if ($objFileModel === null) {
         return;
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #4632)
     if ($file != '' && $file == $objFileModel->path) {
         \Controller::sendFileToBrowser($file);
     }
     $objFile = new \File($objFileModel->path, true);
     $objContent = \ContentModel::findByPk($objItem->cid);
     $objT = new \FrontendTemplate('watchlist_view_download');
     $objT->setData($objFileModel->row());
     $linkTitle = specialchars($objFile->name);
     // use generate for download & downloads as well
     if ($objContent->type == 'download' && $objContent->linkTitle != '') {
         $linkTitle = $objContent->linkTitle;
     }
     $arrMeta = deserialize($objFileModel->meta);
     // Language support
     if (($arrLang = $arrMeta[$GLOBALS['TL_LANGUAGE']]) != '') {
         $linkTitle = $arrLang['title'] ? $arrLang['title'] : $linkTitle;
     }
     $strHref = \Controller::generateFrontendUrl($objPage->row());
     // Remove an existing file parameter (see #5683)
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->path);
     $objT->link = ($objItemTitle = $objItem->title) ? $objItemTitle : $linkTitle;
     $objT->title = specialchars($objContent->titleText ?: $linkTitle);
     $objT->href = $strHref;
     $objT->filesize = \System::getReadableSize($objFile->filesize, 1);
     $objT->icon = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
     $objT->mime = $objFile->mime;
     $objT->extension = $objFile->extension;
     $objT->path = $objFile->dirname;
     $objT->actions = $this->generateEditActions($objItem, $objWatchlist);
     return $objT->parse();
 }
开发者ID:heimrichhannot,项目名称:contao-watchlist,代码行数:43,代码来源:WatchlistItemDownload.php

示例4: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     $objFile = new \File($this->singleSRC);
     if ($this->linkTitle == '') {
         $this->linkTitle = specialchars($objFile->basename);
     }
     $strHref = \Environment::get('request');
     // Remove an existing file parameter (see #5683)
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= (strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->value);
     $this->Template->link = $this->linkTitle;
     $this->Template->title = specialchars($this->titleText ?: sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename));
     $this->Template->href = $strHref;
     $this->Template->filesize = $this->getReadableSize($objFile->filesize, 1);
     $this->Template->icon = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
     $this->Template->mime = $objFile->mime;
     $this->Template->extension = $objFile->extension;
     $this->Template->path = $objFile->dirname;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:24,代码来源:ContentDownload.php

示例5: generateImageContaoLogic

 public static function generateImageContaoLogic($image, $width, $height, $mode = '', $target = null, $force = false)
 {
     if ($image == '') {
         return null;
     }
     $image = rawurldecode($image);
     // Check whether the file exists
     if (!is_file(TL_ROOT . '/' . $image)) {
         \System::log('Image "' . $image . '" could not be found', __METHOD__, TL_ERROR);
         return null;
     }
     $objFile = new \File($image, true);
     $arrAllowedTypes = trimsplit(',', strtolower(\Config::get('validImageTypes')));
     // Check the file type
     if (!in_array($objFile->extension, $arrAllowedTypes)) {
         \System::log('Image type "' . $objFile->extension . '" was not allowed to be processed', __METHOD__, TL_ERROR);
         return null;
     }
     // No resizing required
     if (($objFile->width == $width || !$width) && ($objFile->height == $height || !$height)) {
         // Return the target image (thanks to Tristan Lins) (see #4166)
         if ($target) {
             // Copy the source image if the target image does not exist or is older than the source image
             if (!file_exists(TL_ROOT . '/' . $target) || $objFile->mtime > filemtime(TL_ROOT . '/' . $target)) {
                 \Files::getInstance()->copy($image, $target);
             }
             return \System::urlEncode($target);
         }
         return \System::urlEncode($image);
     }
     // No mode given
     if ($mode == '') {
         // Backwards compatibility
         if ($width && $height) {
             $mode = 'center_top';
         } else {
             $mode = 'proportional';
         }
     }
     // Backwards compatibility
     if ($mode == 'crop') {
         $mode = 'center_center';
     }
     $strCacheKey = substr(md5('-w' . $width . '-h' . $height . '-' . $image . '-' . $mode . '-' . $objFile->mtime), 0, 8);
     $strCacheName = 'assets/images/' . substr($strCacheKey, -1) . '/' . $objFile->filename . '-' . $strCacheKey . '.' . $objFile->extension;
     // Check whether the image exists already
     if (!\Config::get('debugMode')) {
         // Custom target (thanks to Tristan Lins) (see #4166)
         if ($target && !$force) {
             if (file_exists(TL_ROOT . '/' . $target) && $objFile->mtime <= filemtime(TL_ROOT . '/' . $target)) {
                 return \System::urlEncode($target);
             }
         }
         // Regular cache file
         if (file_exists(TL_ROOT . '/' . $strCacheName)) {
             // Copy the cached file if it exists
             if ($target) {
                 \Files::getInstance()->copy($strCacheName, $target);
                 return \System::urlEncode($target);
             }
             return \System::urlEncode($strCacheName);
         }
     }
     // Return the path to the original image if the GDlib cannot handle it
     if (!extension_loaded('gd') || !$objFile->isGdImage || $objFile->width > \Config::get('gdMaxImgWidth') || $objFile->height > \Config::get('gdMaxImgHeight') || !$width && !$height || $width > \Config::get('gdMaxImgWidth') || $height > \Config::get('gdMaxImgHeight')) {
         return \System::urlEncode($image);
     }
     $intPositionX = 0;
     $intPositionY = 0;
     $intWidth = $width;
     $intHeight = $height;
     // Mode-specific changes
     if ($intWidth && $intHeight) {
         switch ($mode) {
             case 'proportional':
                 if ($objFile->width >= $objFile->height) {
                     unset($height, $intHeight);
                 } else {
                     unset($width, $intWidth);
                 }
                 break;
             case 'box':
                 if (round($objFile->height * $width / $objFile->width) <= $intHeight) {
                     unset($height, $intHeight);
                 } else {
                     unset($width, $intWidth);
                 }
                 break;
         }
     }
     $strNewImage = null;
     $strSourceImage = null;
     // Resize width and height and crop the image if necessary
     if ($intWidth && $intHeight) {
         if ($intWidth * $objFile->height != $intHeight * $objFile->width) {
             $intWidth = max(round($objFile->width * $height / $objFile->height), 1);
             $intPositionX = -intval(($intWidth - $width) / 2);
             if ($intWidth < $width) {
                 $intWidth = $width;
                 $intHeight = max(round($objFile->height * $width / $objFile->width), 1);
//.........这里部分代码省略.........
开发者ID:terhuerne,项目名称:contao-kraken.io,代码行数:101,代码来源:krakenIoInterface.php

示例6: compile


//.........这里部分代码省略.........
         }
     } elseif ($objParams->previewGenerateImage) {
         if (!is_file(TL_ROOT . '/' . $preview) || filemtime(TL_ROOT . '/' . $preview) < time() - 604800) {
             if (class_exists('Imagick', false) && !extension_loaded('imagick')) {
                 //!@todo Imagick PHP-Funktionen verwenden, falls vorhanden
             } else {
                 $strFirst = $objFile->extension == 'pdf' ? '[0]' : '';
                 @exec(sprintf('PATH=\\$PATH:%s;export PATH;%s/convert %s/%s' . $strFirst . ' %s/%s 2>&1', $objParams->pathImageMagick, $objParams->pathImageMagick, TL_ROOT, escapeshellarg($objFile->path), TL_ROOT, $preview), $convert_output, $convert_code);
                 if (!is_file(TL_ROOT . '/' . $preview)) {
                     $convert_output = implode("<br />", $convert_output);
                     $reason = 'ImageMagick Exit Code: ' . $convert_code;
                     if ($convert_code == 127) {
                         $reason = 'ImageMagick is not available at ' . $objParams->pathImageMagick;
                     }
                     if (strpos($convert_output, 'gs: command not found')) {
                         $reason = 'Unable to read PDF due to GhostScript error.';
                     }
                     $this->log('Creating preview from "' . $objFile->path . '" failed! ' . $reason . "\n\n" . $convert_output, 'ContentPreviewDownload compile()', TL_ERROR);
                     if (TL_MODE == 'BE') {
                         $this->linkTitle .= $GLOBALS['TL_LANG']['MSC']['creatingPreviewFailed'];
                     }
                 }
             }
         }
     } elseif ($objParams->previewStandardImage) {
         $objImage = \FilesModel::findByUuid($objParams->previewStandardImage);
         if ($objImage !== null && is_file(TL_ROOT . '/' . $objImage->path)) {
             $preview = $objImage->path;
         }
     }
     if (is_file(TL_ROOT . '/' . $preview)) {
         //            $imgIndividualSize = deserialize($this->size);
         $imgDefaultSize = deserialize($objParams->previewImageSize);
         $arrImageSize = getimagesize(TL_ROOT . '/' . $preview);
         if ($imgIndividualSize[0] > 0 || $imgIndividualSize[1] > 0) {
             // individualSize
             $imgSize = $imgIndividualSize;
         } elseif ($imgDefaultSize[0] > 0 || $imgDefaultSize[1] > 0) {
             // preferences -> defaultSize
             if ($objParams->previewConsiderOrientation && $arrImageSize[0] >= $arrImageSize[1]) {
                 $imgSize = array($imgDefaultSize[1], $imgDefaultSize[0], $imgDefaultSize[2]);
             } else {
                 $imgSize = $imgDefaultSize;
             }
         } else {
             $imgSize = array(0, 0, 'proportional');
         }
         $src = $this->getImage($preview, $imgSize[0], $imgSize[1], $imgSize[2]);
         if (($imgSize = @getimagesize(TL_ROOT . '/' . $src)) !== false) {
             $this->Template->preview = $src;
             $this->Template->previewImgSize = ' ' . $imgSize[3];
         }
     }
     $arrMetainfo = array();
     if ($objParams->previewExtension) {
         $arrMetainfo['extension'] = strtoupper($objFile->extension);
     }
     if ($objParams->previewFilesizeD) {
         $intSize = $objFile->filesize;
         for ($i = 0; $intSize >= 1000; $i++) {
             $intSize /= 1000;
         }
         $arrMetainfo['filesize_dec'] = static::getFormattedNumber($intSize, 1) . ' ' . str_replace(array('KiB', 'i'), array('kB', ''), $GLOBALS['TL_LANG']['UNITS'][$i]);
     }
     if ($objParams->previewFilesizeB) {
         $arrMetainfo['filesize_bin'] = $this->getReadableSize($objFile->filesize, 1);
     }
     $strHref = \Environment::get('request');
     // Remove an existing file parameter (see #5683)
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->value);
     $this->Template->margin = $this->generateMargin(deserialize($objParams->previewImageMargin), 'margin');
     // Float image
     if ($objParams->previewImageFloating) {
         $this->Template->floatClass = ' float_' . $objParams->previewImageFloating;
     }
     // Icon
     if ($objParams->previewIcon) {
         $this->Template->icon = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
     }
     /*
             if ($objParams->previewFilesizeD)
             {
                 $this->Template->filesize = $arrMetainfo['filesize_dec'];
             } elseif ($objParams->previewFilesizeB)
             {
                 $this->Template->filesize = $arrMetainfo['filesize_bin'];
             }
     */
     $this->Template->link = $this->linkTitle;
     $this->Template->description = $this->description;
     $this->Template->title = specialchars($this->titleText ?: $this->linkTitle);
     $this->Template->href = $strHref;
     $this->Template->mime = $objFile->mime;
     $this->Template->extension = $objFile->extension;
     $this->Template->arrMetainfo = $arrMetainfo;
     $this->Template->path = $objFile->dirname;
 }
开发者ID:delirius,项目名称:download_extended,代码行数:101,代码来源:ContentDownloadExtended.php

示例7: addEnclosuresToTemplate

 /**
  * Add enclosures to a template
  *
  * @param object $objTemplate The template object to add the enclosures to
  * @param array  $arrItem     The element or module as array
  * @param string $strKey      The name of the enclosures field in $arrItem
  */
 public static function addEnclosuresToTemplate($objTemplate, $arrItem, $strKey = 'enclosure')
 {
     $arrEnclosures = deserialize($arrItem[$strKey]);
     if (!is_array($arrEnclosures) || empty($arrEnclosures)) {
         return;
     }
     $objFiles = \FilesModel::findMultipleByUuids($arrEnclosures);
     if ($objFiles === null) {
         if (!\Validator::isUuid($arrEnclosures[0])) {
             foreach (array('details', 'answer', 'text') as $key) {
                 if (isset($objTemplate->{$key})) {
                     $objTemplate->{$key} = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
                 }
             }
         }
         return;
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #5178)
     if ($file != '') {
         while ($objFiles->next()) {
             if ($file == $objFiles->path) {
                 static::sendFileToBrowser($file);
             }
         }
         $objFiles->reset();
     }
     /** @var \PageModel $objPage */
     global $objPage;
     $arrEnclosures = array();
     $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
     // Add download links
     while ($objFiles->next()) {
         if ($objFiles->type == 'file') {
             if (!in_array($objFiles->extension, $allowedDownload) || !is_file(TL_ROOT . '/' . $objFiles->path)) {
                 continue;
             }
             $objFile = new \File($objFiles->path, true);
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language);
             if (empty($arrMeta) && $objPage->rootFallbackLanguage !== null) {
                 $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
             }
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars($objFile->basename);
             }
             $arrEnclosures[] = array('link' => $arrMeta['title'], 'filesize' => static::getReadableSize($objFile->filesize), 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'href' => $strHref, 'enclosure' => $objFiles->path, 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta);
         }
     }
     $objTemplate->enclosure = $arrEnclosures;
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:64,代码来源:Controller.php

示例8: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $files = array();
     $auxDate = array();
     $objFiles = $this->objFiles;
     $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
     // Get all files
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                 continue;
             }
             $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
             if (empty($arrMeta)) {
                 if ($this->metaIgnore) {
                     continue;
                 } elseif ($objPage->rootFallbackLanguage !== null) {
                     $arrMeta = $this->getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
                 }
             }
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars($objFile->basename);
             }
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             // Add the image
             $files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                     continue;
                 }
                 $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 if (empty($arrMeta)) {
                     if ($this->metaIgnore) {
                         continue;
                     } elseif ($objPage->rootFallbackLanguage !== null) {
                         $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->rootFallbackLanguage);
                     }
                 }
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars($objFile->basename);
                 }
                 $strHref = \Environment::get('request');
                 // Remove an existing file parameter (see #5683)
                 if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                     $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
                 }
                 $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objSubfiles->path);
                 // Add the image
                 $files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     switch ($this->sortBy) {
         default:
         case 'name_asc':
             uksort($files, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($files, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC);
             break;
         case 'date_desc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_DESC);
             break;
         case 'meta':
             // Backwards compatibility
         // Backwards compatibility
//.........这里部分代码省略.........
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:101,代码来源:ContentDownloads.php

示例9: addDownloadsFromProductDownloadsToTemplate

 public static function addDownloadsFromProductDownloadsToTemplate($objTemplate)
 {
     $arrDownloads = array();
     // array for downloadfiles from db
     $arrFiles = array();
     // contains queryresults from db
     $strTable = "tl_iso_download";
     // name of download table
     global $objPage;
     $arrOptions = array('order' => 'sorting ASC');
     $arrFiles = \Isotope\Model\Download::findBy('pid', $objTemplate->id, $arrOptions);
     if ($arrFiles === null) {
         return $arrDownloads;
     }
     while ($arrFiles->next()) {
         $objModel = \FilesModel::findByUuid($arrFiles->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($arrFiles->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $objFile = new \File($objModel->path, true);
             $file = \Input::get('file', true);
             // Send the file to the browser and do not send a 404 header (see #4632)
             if ($file != '' && $file == $objFile->path) {
                 \Controller::sendFileToBrowser($file);
             }
             $arrMeta = \Frontend::getMetaData($objModel->meta, $objPage->language);
             if (empty($arrMeta)) {
                 if ($objPage->rootFallbackLanguage !== null) {
                     $arrMeta = \Frontend::getMetaData($objModel->meta, $objPage->rootFallbackLanguage);
                 }
             }
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->path);
             $objDownload = new \stdClass();
             $objDownload->id = $objModel->id;
             $objDownload->uuid = $objModel->uuid;
             $objDownload->name = $objFile->basename;
             $objDownload->formedname = preg_replace(array('/_/', '/.\\w+$/'), array(' ', ''), $objFile->basename);
             $objDownload->title = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename));
             $objDownload->link = $arrMeta['title'];
             $objDownload->filesize = \System::getReadableSize($objFile->filesize, 1);
             $objDownload->icon = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
             $objDownload->href = $strHref;
             $objDownload->mime = $objFile->mime;
             $objDownload->extension = $objFile->extension;
             $objDownload->path = $objFile->dirname;
             $objDownload->class = 'isotope-download isotope-download-file';
             $objT = new \FrontendTemplate('isotope_download_from_attribute');
             $objT->setData((array) $objDownload);
             $objDownload->output = $objT->parse();
             $arrDownloads[] = $objDownload;
         }
     }
     $objTemplate->downloads = $arrDownloads;
 }
开发者ID:heimrichhannot,项目名称:contao-isotope_plus,代码行数:61,代码来源:DownloadHelper.php

示例10: getPictureInformationArray


//.........这里部分代码省略.........
             // Fallback to the default thumb
             $strImageSrc = $defaultThumbSRC;
         }
         //meta
         $arrMeta = $objThis->getMetaData($objFileModel->meta, $objPage->language);
         // Use the file name as title if none is given
         if ($arrMeta['title'] == '') {
             $arrMeta['title'] = specialchars($objFileModel->name);
         }
     }
     // get thumb dimensions
     $arrSize = unserialize($objThis->gc_size_detailview);
     //Generate the thumbnails and the picture element
     try {
         $thumbSrc = \Image::create($strImageSrc, $arrSize)->executeResize()->getResizedPath();
         $picture = \Picture::create($strImageSrc, $arrSize)->getTemplateData();
         if ($thumbSrc !== $strImageSrc) {
             $objFile = new \File(rawurldecode($thumbSrc), true);
         }
     } catch (\Exception $e) {
         \System::log('Image "' . $strImageSrc . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);
         $thumbSrc = '';
         $picture = array('img' => array('src' => '', 'srcset' => ''), 'sources' => array());
     }
     $picture['alt'] = $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']);
     $picture['title'] = $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']);
     $objFileThumb = new \File(rawurldecode($thumbSrc));
     $arrSize[0] = $objFileThumb->width;
     $arrSize[1] = $objFileThumb->height;
     $arrFile["thumb_width"] = $objFileThumb->width;
     $arrFile["thumb_height"] = $objFileThumb->height;
     // get some image params
     if (is_file(TL_ROOT . '/' . $strImageSrc)) {
         $objFileImage = new \File($strImageSrc);
         if (!$objFileImage->isGdImage) {
             return null;
         }
         $arrFile["path"] = $objFileImage->path;
         $arrFile["basename"] = $objFileImage->basename;
         // filename without extension
         $arrFile["filename"] = $objFileImage->filename;
         $arrFile["extension"] = $objFileImage->extension;
         $arrFile["dirname"] = $objFileImage->dirname;
         $arrFile["image_width"] = $objFileImage->width;
         $arrFile["image_height"] = $objFileImage->height;
     } else {
         return null;
     }
     //check if there is a custom thumbnail selected
     if ($objPicture->addCustomThumb && !empty($objPicture->customThumb)) {
         $customThumbModel = \FilesModel::findByUuid($objPicture->customThumb);
         if ($customThumbModel !== null) {
             if (is_file(TL_ROOT . '/' . $customThumbModel->path)) {
                 $objFileCustomThumb = new \File($customThumbModel->path, true);
                 if ($objFileCustomThumb->isGdImage) {
                     $arrSize = unserialize($objThis->gc_size_detailview);
                     $thumbSrc = \Image::get($objFileCustomThumb->path, $arrSize[0], $arrSize[1], $arrSize[2]);
                     $objFileCustomThumb = new \File(rawurldecode($thumbSrc));
                     $arrSize[0] = $objFileCustomThumb->width;
                     $arrSize[1] = $objFileCustomThumb->height;
                     $arrFile["thumb_width"] = $objFileCustomThumb->width;
                     $arrFile["thumb_height"] = $objFileCustomThumb->height;
                 }
             }
         }
     }
     //exif
     if ($GLOBALS['TL_CONFIG']['gc_read_exif']) {
         try {
             $exif = is_callable('exif_read_data') && TL_MODE == 'FE' ? exif_read_data($strImageSrc) : array('info' => "The function 'exif_read_data()' is not available on this server.");
         } catch (Exception $e) {
             $exif = array('info' => "The function 'exif_read_data()' is not available on this server.");
         }
     } else {
         $exif = array('info' => "The function 'exif_read_data()' has not been activated in the Contao backend settings.");
     }
     //video-integration
     $strMediaSrc = trim($objPicture->socialMediaSRC) != "" ? trim($objPicture->socialMediaSRC) : "";
     if (\Validator::isUuid($objPicture->localMediaSRC)) {
         //get path of a local Media
         $objMovieFile = \FilesModel::findById($objPicture->localMediaSRC);
         $strMediaSrc = $objMovieFile !== null ? $objMovieFile->path : $strMediaSrc;
     }
     $href = null;
     if (TL_MODE == 'FE' && $objThis->gc_fullsize) {
         $href = $strMediaSrc != "" ? $strMediaSrc : \System::urlEncode($strImageSrc);
     }
     //cssID
     $cssID = deserialize($objPicture->cssID, true);
     // build the array
     $arrPicture = array('id' => $objPicture->id, 'pid' => $objPicture->pid, 'date' => $objPicture->date, 'owner' => $objPicture->owner, 'owners_name' => $objOwner->name, 'album_id' => $objPicture->pid, 'name' => specialchars($arrFile["basename"]), 'filename' => $arrFile["filename"], 'uuid' => $objPicture->uuid, 'path' => $arrFile["path"], 'basename' => $arrFile["basename"], 'dirname' => $arrFile["dirname"], 'extension' => $arrFile["extension"], 'alt' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'title' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'comment' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'caption' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'href' => TL_FILES_URL . $href, 'single_image_url' => $objPageModel->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . \Input::get('items') . '/img/' . $arrFile["filename"], $objPage->language), 'image_src' => $arrFile["path"], 'media_src' => $strMediaSrc, 'socialMediaSRC' => $objPicture->socialMediaSRC, 'localMediaSRC' => $objPicture->localMediaSRC, 'addCustomThumb' => $objPicture->addCustomThumb, 'thumb_src' => isset($thumbSrc) ? TL_FILES_URL . $thumbSrc : '', 'size' => $arrSize, 'thumb_width' => $arrFile["thumb_width"], 'thumb_height' => $arrFile["thumb_height"], 'image_width' => $arrFile["image_width"], 'image_height' => $arrFile["image_height"], 'lightbox' => $objPage->outputFormat == 'xhtml' ? 'rel="lightbox[lb' . $objPicture->pid . ']"' : 'data-lightbox="lb' . $objPicture->pid . '"', 'tstamp' => $objPicture->tstamp, 'sorting' => $objPicture->sorting, 'published' => $objPicture->published, 'exif' => $exif, 'albuminfo' => $arrAlbumInfo, 'metaData' => $arrMeta, 'cssID' => $cssID[0] != '' ? $cssID[0] : '', 'cssClass' => $cssID[1] != '' ? $cssID[1] : '', 'externalFile' => $objPicture->externalFile, 'picture' => $picture);
     //Fuegt dem Array weitere Eintraege hinzu, falls tl_gallery_creator_pictures erweitert wurde
     $objPicture = \Database::getInstance()->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE id=?')->execute($intPictureId);
     foreach ($objPicture->fetchAssoc() as $key => $value) {
         if (!array_key_exists($key, $arrPicture)) {
             $arrPicture[$key] = $value;
         }
     }
     return $arrPicture;
 }
开发者ID:Aiod,项目名称:gallery_creator,代码行数:101,代码来源:GcHelpers.php

示例11: getFileData

 /**
  * Get all data for a file
  */
 private function getFileData($objFile, $objElements, $objPage)
 {
     $arrMeta = $this->getMetaData($objElements->meta, $objPage->language);
     // Use the file name as title if none is given
     if ($arrMeta['title'] == '') {
         $arrMeta['title'] = specialchars($objFile->basename);
     }
     // Use the title as link if none is given
     if ($arrMeta['link'] == '') {
         $arrMeta['link'] = $arrMeta['title'];
     }
     $strHref = \Environment::get('request');
     // Remove an existing file parameter (see #5683)
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objElements->path);
     return array('id' => $objFile->id, 'uuid' => $objFile->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['link'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
 }
开发者ID:hofff,项目名称:contao-recursive-download-folder,代码行数:22,代码来源:ContentRecursiveDownloadFolder.php

示例12: generate

 /**
  * Generate download attributes
  * @param IsotopeProduct
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     global $objPage;
     $arrFiles = deserialize($objProduct->{$this->field_name});
     // 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 '';
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #4632)
     if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
         while ($objFiles->next()) {
             if ($file == $objFiles->path || dirname($file) == $objFiles->path) {
                 \Controller::sendFileToBrowser($file);
             }
         }
         $objFiles->reset();
     }
     $files = array();
     $auxDate = array();
     $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
     // Get all files
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                 continue;
             }
             $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
             }
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             // Add the image
             $files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->id);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                     continue;
                 }
                 $arrMeta = \Frontend::getMetaData($objSubfiles->meta, $objPage->language);
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
                 }
                 $strHref = \Environment::get('request');
                 // Remove an existing file parameter (see #5683)
                 if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                     $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
                 }
                 $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objSubfiles->path);
                 // Add the image
                 $files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     $sortBy = $arrOptions['sortBy'] ?: $this->sortBy;
     switch ($sortBy) {
         default:
         case 'name_asc':
             uksort($files, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($files, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC);
//.........这里部分代码省略.........
开发者ID:Aziz-JH,项目名称:core,代码行数:101,代码来源:Downloads.php

示例13: generateFiles

 /**
  * Generate an XML files and save them to the root directory
  *
  * @param array
  */
 protected function generateFiles($arrFeed)
 {
     $arrArchives = deserialize($arrFeed['archives']);
     if (!is_array($arrArchives) || empty($arrArchives)) {
         return;
     }
     $strType = 'generateItunes';
     $strLink = $arrFeed['feedBase'] ?: \Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new iTunesFeed($strFile);
     $objFeed->link = $strLink;
     $objFeed->podcastUrl = $strLink . 'share/' . $strFile . '.xml';
     $objFeed->title = $arrFeed['title'];
     $objFeed->subtitle = $arrFeed['subtitle'];
     $objFeed->description = $this->cleanHtml($arrFeed['description']);
     $objFeed->explicit = $arrFeed['explicit'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->author = $arrFeed['author'];
     $objFeed->owner = $arrFeed['owner'];
     $objFeed->email = $arrFeed['email'];
     $objFeed->category = $arrFeed['category'];
     $objFeed->published = $arrFeed['tstamp'];
     //Add Feed Image
     $objFile = \FilesModel::findByUuid($arrFeed['image']);
     if ($objFile !== null) {
         $objFeed->imageUrl = \Environment::get('base') . $objFile->path;
     }
     // Get the items
     if ($arrFeed['maxItems'] > 0) {
         $objPodcasts = \NewsPodcastsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
     } else {
         $objPodcasts = \NewsPodcastsModel::findPublishedByPids($arrArchives);
     }
     // Parse the items
     if ($objPodcasts !== null) {
         $arrUrls = array();
         while ($objPodcasts->next()) {
             $jumpTo = $objPodcasts->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = \PageModel::findWithDetails($jumpTo);
                 // A jumpTo page is set but does no longer exist (see #5781)
                 if ($objParent === null) {
                     $arrUrls[$jumpTo] = false;
                 } else {
                     $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/%s' : '/items/%s', $objParent->language);
                 }
             }
             // Skip the event if it requires a jumpTo URL but there is none
             if ($arrUrls[$jumpTo] === false && $objPodcasts->source == 'default') {
                 continue;
             }
             $strUrl = $arrUrls[$jumpTo];
             $objItem = new \FeedItem();
             $objItem->headline = $this->cleanHtml($objPodcasts->headline);
             $objItem->subheadline = $this->cleanHtml($objPodcasts->subheadline !== null ? $objPodcasts->subheadline : $objPodcasts->description);
             $objItem->link = $strLink . sprintf($strUrl, $objPodcasts->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objPodcasts->alias : $objPodcasts->id);
             $objItem->published = $objPodcasts->date;
             $objAuthor = $objPodcasts->getRelated('author');
             $objItem->author = $objAuthor->name;
             $objItem->description = $this->cleanHtml($objPodcasts->teaser);
             $objItem->explicit = $objPodcasts->explicit;
             // Add the article image as enclosure
             $objItem->addEnclosure($objFeed->imageUrl);
             // Add the Audio File
             if ($objPodcasts->podcast) {
                 $objFile = \FilesModel::findByUuid($objPodcasts->podcast);
                 if ($objFile !== null) {
                     // Add statistics service
                     if (!empty($arrFeed['addStatistics'])) {
                         // If no trailing slash given, add one
                         $statisticsPrefix = rtrim($arrFeed['statisticsPrefix'], '/') . '/';
                         $podcastPath = $statisticsPrefix . \Environment::get('host') . '/' . preg_replace('(^https?://)', '', $objFile->path);
                     } else {
                         $podcastPath = \Environment::get('base') . \System::urlEncode($objFile->path);
                     }
                     $objItem->podcastUrl = $podcastPath;
                     // Prepare the duration / prefer linux tool mp3info
                     $mp3file = new GetMp3Duration(TL_ROOT . '/' . $objFile->path);
                     if ($this->checkMp3InfoInstalled()) {
                         $shell_command = 'mp3info -p "%S" ' . escapeshellarg(TL_ROOT . '/' . $objFile->path);
                         $duration = shell_exec($shell_command);
                     } else {
                         $duration = $mp3file->getDuration();
                     }
                     $objPodcastFile = new \File($objFile->path, true);
                     $objItem->length = $objPodcastFile->size;
                     $objItem->type = $objPodcastFile->mime;
                     $objItem->duration = $mp3file->formatTime($duration);
                 }
             }
//.........这里部分代码省略.........
开发者ID:stefansl,项目名称:news_podcasts,代码行数:101,代码来源:NewsPodcasts.php

示例14: getHtml

 /**
  * Generate an image tag and return it as string
  *
  * @param string $src        The image path
  * @param string $alt        An optional alt attribute
  * @param string $attributes A string of other attributes
  *
  * @return string The image HTML tag
  */
 public static function getHtml($src, $alt = '', $attributes = '')
 {
     $src = static::getPath($src);
     if ($src == '' || !is_file(TL_ROOT . '/' . $src)) {
         return '';
     }
     $objFile = new \File($src, true);
     $static = strncmp($src, 'assets/', 7) === 0 ? TL_ASSETS_URL : TL_FILES_URL;
     return '<img src="' . $static . \System::urlEncode($src) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . specialchars($alt) . '"' . ($attributes != '' ? ' ' . $attributes : '') . '>';
 }
开发者ID:eknoes,项目名称:core,代码行数:19,代码来源:Image.php

示例15: getHtml

 /**
  * Generate an image tag and return it as string
  *
  * @param string $src        The image path
  * @param string $alt        An optional alt attribute
  * @param string $attributes A string of other attributes
  *
  * @return string The image HTML tag
  */
 public static function getHtml($src, $alt = '', $attributes = '')
 {
     $src = static::getPath($src);
     if ($src == '') {
         return '';
     }
     if (!is_file(TL_ROOT . '/' . $src)) {
         // Handle public bundle resources
         if (file_exists(TL_ROOT . '/web/' . $src)) {
             $src = 'web/' . $src;
         } else {
             return '';
         }
     }
     $objFile = new \File($src);
     // Strip the web/ prefix (see #337)
     if (strncmp($src, 'web/', 4) === 0) {
         $src = substr($src, 4);
     }
     $static = strncmp($src, 'assets/', 7) === 0 ? TL_ASSETS_URL : TL_FILES_URL;
     return '<img src="' . $static . \System::urlEncode($src) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . \StringUtil::specialchars($alt) . '"' . ($attributes != '' ? ' ' . $attributes : '') . '>';
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:31,代码来源:Image.php


注:本文中的System::urlEncode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。