コード例 #1
1
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if (substr($this->url, 0, 7) == 'mailto:') {
         $this->url = \StringUtil::encodeEmail($this->url);
     } else {
         $this->url = ampersand($this->url);
     }
     $embed = explode('%s', $this->embed);
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     // Use an image instead of the title
     if ($this->useImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             /** @var \FrontendTemplate|object $objTemplate */
             $objTemplate = new \FrontendTemplate('ce_hyperlink_image');
             $this->Template = $objTemplate;
             $this->Template->setData($this->arrData);
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
             $this->Template->linkTitle = specialchars($this->linkTitle);
         }
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
         $this->Template->attribute = ' rel="' . $this->rel . '"';
     } else {
         $this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
     }
     $this->Template->rel = $this->rel;
     // Backwards compatibility
     $this->Template->href = $this->url;
     $this->Template->embed_pre = $embed[0];
     $this->Template->embed_post = $embed[1];
     $this->Template->link = $this->linkTitle;
     $this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
     $this->Template->target = '';
     // Override the link target
     if ($this->target) {
         $this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Unset the title attributes in the back end (see #6258)
     if (TL_MODE == 'BE') {
         $this->Template->title = '';
         $this->Template->linkTitle = '';
     }
 }
コード例 #2
0
 public function storeFileMetaInformation($varValue, DataContainer $dc)
 {
     if ($dc->activeRecord->singleSRC == $varValue) {
         return $varValue;
     }
     $objFile = FilesModel::findByUuid($varValue);
     if ($objFile !== null) {
         $arrMeta = deserialize($objFile->meta);
         if (!empty($arrMeta)) {
             $objPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=(SELECT pid FROM " . ($dc->activeRecord->ptable ?: 'tl_article') . " WHERE id=?)")->execute($dc->activeRecord->pid);
             if ($objPage->numRows) {
                 $objModel = new PageModel();
                 $objModel->setRow($objPage->row());
                 $objModel->loadDetails();
                 // Convert the language to a locale (see #5678)
                 $strLanguage = str_replace('-', '_', $objModel->rootLanguage);
                 if (isset($arrMeta[$strLanguage])) {
                     Input::setPost('alt', $arrMeta[$strLanguage]['title']);
                     Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
                 }
             }
         }
     }
     return $varValue;
 }
 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && $this->User->homeDir) {
             $this->folderSRC = $this->User->homeDir;
         }
     }
     // Return if there is no folder defined
     if (empty($this->folderSRC)) {
         return '';
     }
     // Get the folders from the database
     $this->objFolder = \FilesModel::findByUuid($this->folderSRC);
     if ($this->objFolder === null) {
         if (!\Validator::isUuid($this->folderSRC[0])) {
             return '<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 #4632)
     if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
         if (strpos(dirname($file), $this->objFolder->path) !== FALSE) {
             \Controller::sendFileToBrowser($file);
         }
     }
     return parent::generate();
 }
コード例 #4
0
 public function generateStatic(array $arrOptions = array())
 {
     $this->arrOptions = array_merge($this->arrOptions, $arrOptions);
     $arrData = $this->getData($this->arrOptions);
     $strMarker = '';
     switch ($arrData['type']) {
         case 'MARKER':
             if ($arrData['markerType'] == 'ICON') {
                 $arrData['iconSRC'] = \FilesModel::findByUuid($arrData['iconSRC'])->path;
                 return array('icon:' . rawurlencode(\Environment::get('base') . $arrData['iconSRC']) . '|shadow:false|' => $arrData['singleCoords']);
             } else {
                 $strMarker = '&amp;markers=' . $arrData['singleCoords'];
             }
             break;
         case 'POLYLINE':
             if (is_array($arrData['multiCoords']) && count($arrData['multiCoords']) > 0) {
                 $strMarker .= '&amp;path=weight:' . $arrData['strokeWeight']['value'] . '|color:0x' . $arrData['strokeColor'] . dechex($arrData['strokeOpacity'] * 255);
                 foreach ($arrData['multiCoords'] as $coords) {
                     $strMarker .= '|' . str_replace(' ', '', $coords);
                 }
             }
             break;
         case 'POLYGON':
             if (is_array($arrData['multiCoords']) && count($arrData['multiCoords']) > 0) {
                 $strMarker .= '&amp;path=weight:' . $arrData['strokeWeight']['value'] . '|color:0x' . $arrData['strokeColor'] . dechex($arrData['strokeOpacity'] * 255) . '|fillcolor:0x' . $arrData['fillColor'] . dechex($arrData['fillOpacity'] * 255);
                 foreach ($arrData['multiCoords'] as $coords) {
                     $strMarker .= '|' . str_replace(' ', '', $coords);
                 }
                 $strMarker .= '|' . str_replace(' ', '', $arrData['multiCoords'][0]);
             }
             break;
     }
     return $strMarker;
 }
コード例 #5
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \StringUtil::toXhtml($this->text);
     } else {
         $this->text = \StringUtil::toHtml5($this->text);
     }
     $this->Template->text = \StringUtil::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
     $classes = deserialize($this->mooClasses);
     $this->Template->toggler = $classes[0] ?: 'toggler';
     $this->Template->accordion = $classes[1] ?: 'accordion';
     $this->Template->headlineStyle = $this->mooStyle;
     $this->Template->headline = $this->mooHeadline;
 }
コード例 #6
0
ファイル: ContentText.php プロジェクト: juergen83/contao
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     // Add the static files URL to images
     if (TL_FILES_URL != '') {
         $path = \Config::get('uploadPath') . '/';
         $this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
     }
     $this->Template->text = \String::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
 }
コード例 #7
0
 protected function buildFileDir($objEntity = null)
 {
     if ($this->fileDir && ($objFolder = \FilesModel::findByUuid($this->fileDir))) {
         $objMember = \FrontendUser::getInstance();
         $strDir = $objFolder->path;
         if ($this->useHomeDir && FE_USER_LOGGED_IN && $objMember->assignDir && $objMember->homeDir) {
             $strDir = Files::getPathFromUuid($objMember->homeDir);
         }
         if (in_array('protected_homedirs', \ModuleLoader::getActive())) {
             if ($this->useProtectedHomeDir && $objMember->assignProtectedDir && $objMember->protectedHomeDir) {
                 $strDir = Files::getPathFromUuid($objMember->protectedHomeDir);
             }
         }
         if ($this->fileSubDirName) {
             $strDir .= '/' . $this->fileSubDirName;
         }
         if (isset($GLOBALS['TL_HOOKS']['exporter_modifyFileDir']) && is_array($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'])) {
             foreach ($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'] as $callback) {
                 $objCallback = \System::importStatic($callback[0]);
                 $strFixedDir = $objCallback->{$callback}[1]($strDir, $this);
                 $strDir = $strFixedDir ?: $strDir;
             }
         }
         return $strDir;
     }
     throw new \Exception('No exporter fileDir defined!');
 }
コード例 #8
0
 public function generateAddActions($arrData, $id, Watchlist $objWatchlist)
 {
     global $objPage;
     if ($objPage === null) {
         return;
     }
     if (\Validator::isUuid($id)) {
         $objFile = \FilesModel::findByUuid($id);
     } else {
         $objFile = \FilesModel::findBy('path', $id);
     }
     $objItem = new WatchlistItemModel();
     $objItem->pid = Watchlist::getInstance()->getId();
     $objItem->uuid = $objFile->uuid;
     $objItem->pageID = $objPage->id;
     $objItem->cid = $arrData['id'];
     $objItem->type = $arrData['type'];
     $objT = new \FrontendTemplate('watchlist_add_actions');
     $objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle()));
     $objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle'];
     $objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink'];
     $objT->active = $objWatchlist->isInList($strUuid);
     $objT->id = $strUuid;
     return $objT->parse();
 }
コード例 #9
0
ファイル: AnyStores.php プロジェクト: pedal123/anyStores
 /**
  * @deprecated
  */
 public static function loadStoreDetails(array $arrStore, $jumpTo = null)
 {
     //load country names
     //@todo load only once. not every time.
     $arrCountryNames = \System::getCountries();
     //full localized country name
     //@todo rename country to countrycode in database
     $arrStore['countrycode'] = $arrStore['country'];
     $arrStore['country'] = $arrCountryNames[$arrStore['countrycode']];
     // generate jump to
     if ($jumpTo) {
         if (($objLocation = \PageModel::findByPk($jumpTo)) !== null) {
             //@todo language parameter
             $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
             $strStoreValue = $arrStore['alias'];
             $arrStore['href'] = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
         }
     }
     // opening times
     $arrStore['opening_times'] = deserialize($arrStore['opening_times']);
     // store logo
     //@todo change size and properties in module
     if ($arrStore['logo']) {
         if (($objLogo = \FilesModel::findByUuid($arrStore['logo'])) !== null) {
             $arrLogo = $objLogo->row();
             $arrMeta = deserialize($arrLogo['meta']);
             $arrLogo['meta'] = $arrMeta[$GLOBALS['TL_LANGUAGE']];
             $arrStore['logo'] = $arrLogo;
         } else {
             $arrStore['logo'] = null;
         }
     }
     return $arrStore;
 }
コード例 #10
0
 /**
  * Collect the images from page
  * @param object
  * @param object
  */
 public function collectPageImages($objPage, $objLayout)
 {
     if (!$objLayout->socialImages) {
         return;
     }
     // Initialize the array
     if (!is_array($GLOBALS['SOCIAL_IMAGES'])) {
         $GLOBALS['SOCIAL_IMAGES'] = array();
     }
     // Add the current page image
     if ($objPage->socialImage && ($objImage = \FilesModel::findByUuid($objPage->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) {
         array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path);
     } else {
         $objTrail = \PageModel::findParentsById($objPage->id);
         if ($objTrail !== null) {
             while ($objTrail->next()) {
                 // Add the image
                 if ($objTrail->socialImage && ($objImage = \FilesModel::findByUuid($objTrail->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) {
                     array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path);
                     break;
                 }
             }
         }
     }
 }
コード例 #11
0
 /**
  * Return if the file does not exist
  *
  * @return string
  */
 public function generate()
 {
     // Return if there is no file
     if ($this->singleSRC == '') {
         return '';
     }
     $objFile = \FilesModel::findByUuid($this->singleSRC);
     if ($objFile === null) {
         if (!\Validator::isUuid($this->singleSRC)) {
             return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         }
         return '';
     }
     $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
     // Return if the file type is not allowed
     if (!in_array($objFile->extension, $allowedDownload)) {
         return '';
     }
     $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);
     }
     $this->singleSRC = $objFile->path;
     return parent::generate();
 }
コード例 #12
0
ファイル: ContentYouTube.php プロジェクト: iCodr8/core
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->size = '';
     // Set the size
     if ($this->playerSize != '') {
         $size = deserialize($this->playerSize);
         if (is_array($size)) {
             $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
         }
     }
     $this->Template->poster = false;
     // Optional poster
     if ($this->posterSRC != '') {
         if (($objFile = \FilesModel::findByUuid($this->posterSRC)) !== null) {
             $this->Template->poster = $objFile->path;
         }
     }
     // Check for SSL (see #6900)
     $protocol = \Environment::get('ssl') ? 'https://' : 'http://';
     $objFile = new \stdClass();
     $objFile->mime = 'video/x-youtube';
     $objFile->path = $protocol . 'www.youtube.com/watch?v=' . $this->youtube;
     $this->Template->isVideo = true;
     $this->Template->files = array($objFile);
     $this->Template->autoplay = $this->autoplay;
 }
コード例 #13
0
 /**
  * Parse the icon and prepare it for the Template
  * @param array
  * @return array
  */
 protected function parseIcon($icon)
 {
     $arrIcon = array();
     //Check for image
     if ($icon['iconfile'] != '') {
         $objFile = \FilesModel::findByUuid($icon['iconfile']);
         if ($objFile != null) {
             if (is_file(TL_ROOT . '/' . $objFile->path)) {
                 $arrIcon['hasImage'] = true;
                 $arrIcon['img'] = $objFile->path;
             }
         }
     }
     //Add Foundation icon class
     if (!$arrIcon['hasImage'] && $icon['iconclass'] != '') {
         $arrIcon['iconclass'] = 'fi-' . $icon['iconclass'];
     }
     if ($icon['iconclass_custom'] != '') {
         $arrIcon['class'] .= ' ' . $icon['iconclass_custom'];
     }
     if ($icon['icon_label'] != '') {
         $arrIcon['label'] .= $icon['icon_label'];
     }
     $arrIcon['href'] = $icon['icon_href'];
     return $arrIcon;
 }
コード例 #14
0
ファイル: NewsSingleFile.php プロジェクト: kikmedia/contao
 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);
         }
     }
 }
コード例 #15
0
 public function getPictureFromDB($strTable, $strColumn, $strWhereParam, $strObjID)
 {
     $query = "SELECT " . $strColumn . " FROM " . $strTable . "WHERE " . $strWhereParam . "=?";
     $objPicture = $this->Database->prepare($query)->execute($strObjID);
     $objFile = \FilesModel::findByUuid($objPicture->{$strColumn});
     return $objFile->path;
 }
コード例 #16
0
ファイル: Leads.php プロジェクト: terminal42/contao-leads
 /**
  * Get the label for a form value to store in lead table.
  *
  * @param mixed $varValue
  * @param \Database\Result $objField
  *
  * @return mixed
  */
 public static function prepareLabel($varValue, $objField)
 {
     // Run for all values in an array
     if (is_array($varValue)) {
         foreach ($varValue as $k => $v) {
             $varValue[$k] = self::prepareLabel($v, $objField);
         }
         return $varValue;
     }
     // File upload
     if ($objField->type == 'upload') {
         $objFile = \FilesModel::findByUuid($varValue);
         if ($objFile !== null) {
             return $objFile->path;
         }
     }
     // Convert timestamps into date format
     if ($varValue != '' && in_array($objField->rgxp, array('date', 'time', 'datim'))) {
         $varValue = \Date::parse($GLOBALS['TL_CONFIG'][$objField->rgxp . 'Format'], $varValue);
     }
     if ($objField->options != '') {
         $arrOptions = deserialize($objField->options, true);
         foreach ($arrOptions as $arrOption) {
             if ($arrOption['value'] == $varValue && $arrOption['label'] != '') {
                 $varValue = $arrOption['label'];
             }
         }
     }
     return $varValue;
 }
コード例 #17
0
 /**
  * Generate module
  */
 protected function compile()
 {
     if (TL_MODE == 'BE') {
         // Im Backend-Modus
         $this->strTemplate = 'be_wildcard';
         $this->Template = new \BackendTemplate($this->strTemplate);
         if ($this->headline) {
             $this->Template->title = $this->headline;
         }
         $this->Template->wildcard = $this->text;
         $this->Template->wildcard .= '<hr style="margin: 0 15px 5px;" />';
         $this->cmh = unserialize($this->cmHeadline);
         $this->cm_headline = $this->cmh['value'];
         if ($this->cm_headline) {
             $this->Template->wildcard .= '<h1>' . $this->cm_headline . "</h1>";
         }
         $this->Template->wildcard .= $this->cmText;
         return;
     }
     // Im Frontend-Modus
     // CSS einbinden
     $GLOBALS['TL_CSS'][] = 'system/modules/content-memory/assets/ce_content-memory.css';
     $this->Template->headline = $this->headline;
     $this->Template->hl = $this->hl;
     $this->Template->textvorn = $this->text;
     $this->cmh = unserialize($this->cmHeadline);
     $this->cm_headline = $this->cmh['value'];
     $this->cm_hl = $this->cmh['unit'];
     $this->Template->cmheadline = $this->cm_headline;
     $this->Template->cmhl = $this->cm_hl;
     $this->Template->texthint = $this->cmText;
     //$this->Template->addImage = false;
     //$this->Template->cmAddImage = false;
     // add an image to the front side
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->textvorn = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
     // add an image to the back side
     if ($this->cmAddImage && $this->cmSingleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->cmSingleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->cmSingleSRC)) {
                 $this->Template->texthint = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->cmSingleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
 }
コード例 #18
0
 /**
  * getPa2Image function.
  *
  * @access public
  * @return object
  */
 public function getPa2Image()
 {
     $objFile = \FilesModel::findByUuid($this->uuid);
     if ($objFile !== null) {
         // Deserialize meta data
         $objFile->meta = deserialize($objFile->meta);
         return $objFile;
     }
 }
コード例 #19
0
 /**
  * Add an image to each record
  *
  * @param array  $row
  * @param string $label
  *
  * @return string
  */
 public function addPreviewImage($row, $label)
 {
     if ($row['screenshot'] != '') {
         $objFile = FilesModel::findByUuid($row['screenshot']);
         if ($objFile !== null) {
             $label = Image::getHtml(Image::get($objFile->path, 160, 120, 'center_top'), '', 'class="theme_preview"') . ' ' . $label;
         }
     }
     return $label;
 }
コード例 #20
0
ファイル: tl_theme.php プロジェクト: Mozan/core-bundle
 /**
  * Add an image to each record
  *
  * @param array  $row
  * @param string $label
  *
  * @return string
  */
 public function addPreviewImage($row, $label)
 {
     if ($row['screenshot'] != '') {
         $objFile = FilesModel::findByUuid($row['screenshot']);
         if ($objFile !== null) {
             $label = '<img src="' . TL_FILES_URL . Image::get($objFile->path, 160, 120, 'center_top') . '" width="160" height="120" alt="" class="theme_preview">' . $label;
         }
     }
     return $label;
 }
コード例 #21
0
ファイル: tl_theme.php プロジェクト: contao/core-bundle
 /**
  * Add an image to each record
  *
  * @param array  $row
  * @param string $label
  *
  * @return string
  */
 public function addPreviewImage($row, $label)
 {
     if ($row['screenshot'] != '') {
         $objFile = FilesModel::findByUuid($row['screenshot']);
         if ($objFile !== null) {
             $label = Image::getHtml(\System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $objFile->path, array(160, 120, 'center_top'))->getUrl(TL_ROOT), '', 'class="theme_preview"') . ' ' . $label;
         }
     }
     return $label;
 }
コード例 #22
0
 public function myParseArticles($objTemplate, $arrRow, $objModule)
 {
     $objUser = \UserModel::findById($arrRow['author']);
     $objTemplate->username = $objUser->name;
     $objTemplate->signature = $objUser->text;
     if ($objUser->addImage) {
         $objFile = \FilesModel::findByUuid($objUser->userSRC);
         $objTemplate->userSRC = $objFile->path;
     }
 }
 public function generateLinks(&$arrSubmitted, &$arrLabels, $data)
 {
     $this->import('Database');
     $files = $this->Input->get('attachfiles');
     if ($files == "") {
         $files = $this->Input->post('attachfiles');
     }
     // get JSON-data
     $retValue = '';
     if ($files != "") {
         foreach ($files as $file) {
             $tmp = split('"elemID"', $file);
             $file = '{"elemID"' . $tmp[1];
             if ($obj = json_decode($file)) {
                 $myElem = $obj->elemID;
                 $objDatabase = \Database::getInstance();
                 $myElemData = $objDatabase->prepare("SELECT * FROM tl_form_field WHERE id = " . $myElem)->execute();
                 $doLink = false;
                 if (!$myElemData->next()) {
                     if ($myElemData->sendcase == 'link') {
                         $doLink = true;
                     }
                     // pruefen, ob Dateien als Link hinterlegt werden sollen
                 }
                 if ($doLink) {
                     $addToFile = $obj->addToFile;
                     // get uploadFolder
                     $myElemData = $this->Database->prepare("SELECT * FROM tl_form_field WHERE id = " . $myElem)->execute();
                     $uploadFolder = '';
                     if ($myElemData->next()) {
                         if ($myElemData->storeFileSimple) {
                             $tmpFolder = $myElemData->uploadFolder;
                         }
                         $objUploadFolder = \FilesModel::findByUuid($tmpFolder);
                         $uploadFolder = $objUploadFolder->path;
                     }
                     $uploaded = $obj->files;
                     // Array
                     foreach ($uploaded as $curFile) {
                         if (file_exists(TL_ROOT . '/' . $uploadFolder . '/' . $addToFile . '/' . $curFile)) {
                             if (!$retValue == '') {
                                 $retValue .= "<br>";
                             }
                             $retValue .= '/' . $uploadFolder . '/' . $addToFile . '/' . $curFile;
                         }
                     }
                     $arrSubmittedArray[$myElemData->name] = $retValue;
                 } else {
                     unset($arrSubmittedArray[$myElemData->name]);
                     unset($arrLabelsArray[$myElemData->name]);
                 }
             }
         }
     }
 }
コード例 #24
0
 /**
  * Get a transition icon.
  *
  * Try to get the transition icon from the config. Use the default one if none is defined.
  *
  * @param Transition $transition The workflow transition.
  *
  * @return string
  */
 public static function getTransitionIcon(Transition $transition)
 {
     $icon = $transition->getConfigValue('icon');
     if ($icon) {
         $model = \FilesModel::findByUuid($icon);
         if ($model) {
             return $model->path;
         }
     }
     return 'system/modules/workflow/assets/img/transition.png';
 }
コード例 #25
0
ファイル: ContentImage.php プロジェクト: Mozan/core-bundle
 /**
  * Return if the image does not exist
  *
  * @return string
  */
 public function generate()
 {
     if ($this->singleSRC == '') {
         return '';
     }
     $objFile = \FilesModel::findByUuid($this->singleSRC);
     if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
         return '';
     }
     $this->singleSRC = $objFile->path;
     return parent::generate();
 }
コード例 #26
0
 protected function compile()
 {
     $objArticle = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives);
     $objAuthor = \UserModel::findById($objArticle->author);
     if ($objAuthor->addImage) {
         $objFile = \FilesModel::findByUuid($objAuthor->userSRC);
         $this->addImageToTemplate($this->Template, array('singleSRC' => $objFile->path, 'alt' => 'Screenshot of Music Academy', 'size' => $this->imgSize));
     }
     foreach ($objAuthor->row() as $k => $v) {
         $this->Template->{$k} = $v;
     }
 }
コード例 #27
0
 /**
  * @param      $varUuid
  * @param bool $blnCheckExists
  *
  * @return null|string Return the path of the file, or null if not exists
  */
 public static function getPathFromUuid($varUuid, $blnCheckExists = true)
 {
     if (($objFile = \FilesModel::findByUuid($varUuid)) !== null) {
         if (!$blnCheckExists) {
             return $objFile->path;
         }
         if (file_exists(TL_ROOT . '/' . $objFile->path)) {
             return $objFile->path;
         }
     }
     return null;
 }
 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     // add the scripts
     $GLOBALS['TL_CSS'][] = 'assets/accessible-html5-video-player/css/px-video.css|static';
     $GLOBALS['TL_JAVASCRIPT'][] = 'assets/accessible-html5-video-player/js/px-video.js|static';
     // set the size
     $this->Template->size = '';
     if ($this->playerSize != '') {
         $size = deserialize($this->playerSize);
         if (is_array($size)) {
             $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
         }
     }
     // optional preview
     $this->Template->preview = false;
     if ($this->previewSRC != '') {
         if (($objFile = \FilesModel::findByUuid($this->previewSRC)) !== null) {
             $this->Template->preview = $objFile->path;
         }
     }
     // optional caption
     $this->Template->caption = false;
     if ($this->captionSRC != '') {
         if (($objFile = \FilesModel::findByUuid($this->captionSRC)) !== null) {
             $this->Template->caption = $objFile->path;
         }
     }
     // pre-sort the array by preference
     $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null);
     $this->objFiles->reset();
     // convert the language to a locale
     $strLanguage = str_replace('-', '_', $objPage->language);
     // pass File objects to the template
     while ($this->objFiles->next()) {
         $arrMeta = deserialize($this->objFiles->meta);
         if (is_array($arrMeta) && isset($arrMeta[$strLanguage])) {
             $strTitle = $arrMeta[$strLanguage]['title'];
         } else {
             $strTitle = $this->objFiles->name;
         }
         $objFile = new \File($this->objFiles->path, true);
         $objFile->title = specialchars($strTitle);
         $arrFiles[$objFile->extension] = $objFile;
     }
     $this->Template->files = array_values(array_filter($arrFiles));
     $this->Template->autoplay = $this->autoplay;
     // labels
     $this->Template->lang = $GLOBALS['TL_LANGUAGE'];
     $this->Template->label = $GLOBALS['TL_LANG']['MSC']['avpCaption'];
     $this->Template->download = $GLOBALS['TL_LANG']['MSC']['avpDownload'];
 }
コード例 #29
0
    /**
     * Add the type of input field
     * @param array
     * @return string
     */
    public function listFiles($arrRow)
    {
        $time = time();
        $objFile = \FilesModel::findByUuid($arrRow['singleSRC']);
        $key = $arrRow['published'] && ($arrRow['start'] == '' || $arrRow['start'] < $time) && ($arrRow['stop'] == '' || $arrRow['stop'] > $time) ? 'published' : 'unpublished';
        return '
<div class="cte_type ' . $key . '"><strong>' . $arrRow['title'] . '</strong></div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? '
h52' : '') . 'block">
' . $objFile->path . '<br /><br />
' . $arrRow['description'] . '
</div>' . "\n";
    }
コード例 #30
0
 protected function parseMember($objMember)
 {
     global $objPage;
     $objT = new \FrontendTemplate('memberlist_default');
     $objT->setData($objMember->row());
     $strUrl = $this->generateMemberUrl($objMember);
     $objT->addImage = false;
     // Add an image
     if ($objMember->addImage && $objMember->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objMember->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objMember->singleSRC)) {
                 $objMember->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)
             $arrMember = $objMember->row();
             // Override the default image size
             if ($this->size != '') {
                 $size = deserialize($this->size);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrMember['size'] = $this->size;
                 }
             }
             $arrMember['singleSRC'] = $objModel->path;
             \Controller::addImageToTemplate($objT, $arrMember);
         }
     }
     $arrTitle = array($objMember->academicTitle, $objMember->firstname, $objMember->lastname);
     $objT->titleCombined = empty($arrTitle) ? '' : implode(' ', $arrTitle);
     $arrLocation = array($objMember->postal, $objMember->city);
     $objT->locationCombined = empty($arrLocation) ? '' : implode(' ', $arrLocation);
     $objT->websiteLink = $objMember->website;
     $objT->websiteTitle = $GLOBALS['TL_LANG']['MSC']['memberlist']['websiteTitle'];
     // Add http:// to the website
     if ($objMember->website != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $objMember->website)) {
         $objT->websiteLink = 'http://' . $objMember->website;
     }
     if ($this->mlSource == 'external') {
         // Encode e-mail addresses
         if (substr($this->mlUrl, 0, 7) == 'mailto:') {
             $strUrl = \String::encodeEmail($this->mlUrl);
         } else {
             $strUrl = ampersand($this->mlUrl);
         }
     }
     $objT->link = $strUrl;
     $objT->linkTarget = $this->mlTarget ? $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"' : '';
     $objT->linkTitle = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['openMember'], $objT->titleCombined));
     return $objT->parse();
 }