/**
  * 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 = '';
     }
 }
Esempio n. 2
0
 /**
  * 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->multiSRC = array($this->User->homeDir);
         }
     } else {
         $this->multiSRC = deserialize($this->multiSRC);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
     if ($this->objFiles === null) {
         if (!\Validator::isUuid($this->multiSRC[0])) {
             return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         }
         return '';
     }
     return parent::generate();
 }
Esempio n. 3
0
 /**
  * __construct function.
  *
  * @access public
  * @param string
  * @return void
  */
 public function __construct($uuid)
 {
     if (!\Validator::isUuid($uuid)) {
         return;
     }
     $this->uuid = $uuid;
 }
Esempio n. 4
0
 /**
  * add uuids to tl_gallery_creator_pictures version added in 4.8.0
  */
 public static function addUuids()
 {
     // add field
     if (!\Database::getInstance()->fieldExists('uuid', 'tl_gallery_creator_pictures')) {
         \Database::getInstance()->query("ALTER TABLE `tl_gallery_creator_pictures` ADD `uuid` BINARY(16) NULL");
     }
     $objDB = \Database::getInstance()->execute("SELECT * FROM tl_gallery_creator_pictures WHERE uuid IS NULL");
     while ($objDB->next()) {
         if ($objDB->path == '') {
             continue;
         }
         if (is_file(TL_ROOT . '/' . $objDB->path)) {
             \Dbafs::addResource($objDB->path);
         } else {
             continue;
         }
         $oFile = new \File($objDB->path);
         $oFile->close();
         $fileModel = $oFile->getModel();
         if (\Validator::isUuid($fileModel->uuid)) {
             \Database::getInstance()->prepare("UPDATE tl_gallery_creator_pictures SET uuid=? WHERE id=?")->execute($fileModel->uuid, $objDB->id);
             $_SESSION["TL_CONFIRM"][] = "Added a valid file-uuid into tl_gallery_creator_pictures.uuid ID " . $objDB->id . ". Please check if all the galleries are running properly.";
         }
     }
 }
Esempio n. 5
0
 protected function addDummyImage(&$objTemplate, $arrArticle, $objModule)
 {
     if ($objTemplate->addImage) {
         return;
     }
     $objArchive = \NewsArchiveModel::findByPk($arrArticle['pid']);
     if ($objArchive === null) {
         return;
     }
     $objTemplate->addDummyImage = false;
     if ($objArchive->addDummyImage && $objArchive->dummyImageSingleSRC != '') {
         $objModel = \FilesModel::findByUuid($objArchive->dummyImageSingleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objArchive->dummyImageSingleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Override the default image size
             if ($objModule->imgSize != '') {
                 $size = deserialize($objModule->imgSize);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrArticle['size'] = $objModule->imgSize;
                 }
             }
             $arrArticle['singleSRC'] = $objModel->path;
             $this->addImageToTemplate($objTemplate, $arrArticle);
             $objTemplate->class .= ' dummy-image';
             $objTemplate->addDummyImage = true;
             $objTemplate->addImage = false;
         }
     }
 }
Esempio n. 6
0
 /**
  * @param $file
  *
  * @return bool|FilesModel
  * @throws \RuntimeException
  */
 public static function getFileModel($file)
 {
     if (empty($file)) {
         /**
          * No file model source given
          */
         return false;
     } elseif (\Validator::isUuid($file)) {
         /**
          * Get file by DBAFS UUID
          */
         $file = FilesModel::findByUuid($file, array('uncached' => true));
     } else {
         /**
          * Search the old way
          */
         return parent::getFileModel($file);
     }
     /**
      * Get path from model
      */
     if ($file instanceof FilesModel) {
         return $file;
     }
     return false;
 }
 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();
 }
 /**
  * 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();
 }
Esempio n. 9
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;
 }
Esempio n. 10
0
 /**
  * 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);
         }
     }
 }
 /**
  * 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->multiSRC = array($this->User->homeDir);
         }
     } else {
         $this->multiSRC = deserialize($this->multiSRC);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
     if ($this->objFiles === null) {
         if (!\Validator::isUuid($this->multiSRC[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))) {
         while ($this->objFiles->next()) {
             if ($file == $this->objFiles->path || dirname($file) == $this->objFiles->path) {
                 \Controller::sendFileToBrowser($file);
             }
         }
         $this->objFiles->reset();
     }
     return parent::generate();
 }
 /**
  * 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($GLOBALS['TL_CONFIG']['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();
 }
 /**
  * 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);
         }
     }
 }
 public function onCreate($strTable, $insertID, $arrSet, \DataContainer $dc)
 {
     if (($objModel = SubmissionArchiveModel::findByPk($insertID)) === null) {
         return;
     }
     if (($uuid = Submissions::getDefaultAttachmentSRC()) !== null && \Validator::isUuid($uuid)) {
         $objModel->attachmentUploadFolder = class_exists('Contao\\StringUtil') ? \StringUtil::uuidToBin($uuid) : \String::uuidToBin($uuid);
     }
     $objModel->save();
 }
Esempio n. 15
0
 /**
  * Find multiple files by their IDs or UUIDs (backwards compatibility)
  *
  * @param array $arrIds     An array of IDs or UUIDs
  * @param array $arrOptions An optional options array
  *
  * @return \Model\Collection|null A collection of models or null if there are no files
  */
 public static function findMultipleByIds($arrIds, array $arrOptions = array())
 {
     if (!is_array($arrIds) || empty($arrIds)) {
         return null;
     }
     if (\Validator::isUuid(current($arrIds))) {
         return static::findMultipleByUuids($arrIds, $arrOptions);
     }
     return parent::findMultipleByIds($arrIds, $arrOptions);
 }
 /**
  * Transforms a value from the original representation to a transformed representation.
  * An example might be transforming a unix timestamp to a human readable date format.
  *
  * @param mixed $value The value in the original representation
  *
  * @return mixed The value in the transformed representation
  *
  * @throws TransformationFailedException When the transformation fails.
  */
 public function transform($value)
 {
     if (!\Validator::isUuid($value)) {
         return $value;
     }
     $filesModel = \FilesModel::findByUUid($value);
     if (null === $filesModel) {
         return $value;
     }
     return $filesModel->path;
 }
 public static function getDefaultAttachmentSRC($blnReturnPath = false)
 {
     $objFolder = new \Folder('files/submissions/uploads');
     if ($blnReturnPath) {
         return $objFolder->path;
     }
     if (\Validator::isUuid($objFolder->getModel()->uuid)) {
         return class_exists('Contao\\StringUtil') ? \StringUtil::binToUuid($objFolder->getModel()->uuid) : \String::binToUuid($objFolder->getModel()->uuid);
     }
     return null;
 }
 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();
 }
Esempio n. 19
0
 /**
  * Run database migrations
  *
  * @return void
  */
 public static function run()
 {
     $database = \Database::getInstance();
     // Copy license key from extension repository
     if (!\Config::get('rocksolid_slider_license') && $database->tableExists('tl_repository_installs') && $database->fieldExists('lickey', 'tl_repository_installs') && $database->fieldExists('extension', 'tl_repository_installs')) {
         $result = $database->prepare('SELECT lickey FROM tl_repository_installs WHERE extension = \'rocksolid-slider-pro\'')->execute();
         if ($result && Slider::checkLicense((string) $result->lickey)) {
             \Config::getInstance()->add('$GLOBALS[\'TL_CONFIG\'][\'rocksolid_slider_license\']', (string) $result->lickey);
         }
     }
     // Fix the singleSRC data type for Contao 3.1 and below
     if (version_compare(VERSION, '3.2', '<') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'varchar') {
                 $database->query('ALTER TABLE tl_rocksolid_slide CHANGE singleSRC singleSRC varchar(255) NOT NULL default \'\'');
                 $database->query('UPDATE tl_rocksolid_slide SET singleSRC = trim(trailing CHAR(0x00) from singleSRC)');
             }
         }
     }
     // Update the multiSRC and orderSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slider')) {
         $needUpdate = true;
         $result = $database->prepare('SELECT multiSRC FROM tl_rocksolid_slider WHERE multiSRC != \'\'')->execute();
         if (!$result->count()) {
             $needUpdate = false;
         }
         while ($result->next()) {
             foreach (deserialize($result->multiSRC, true) as $value) {
                 if (\Validator::isUuid($value)) {
                     $needUpdate = false;
                     break 2;
                 }
             }
         }
         if ($needUpdate) {
             \Database\Updater::convertMultiField('tl_rocksolid_slider', 'multiSRC');
             \Database\Updater::convertOrderField('tl_rocksolid_slider', 'orderSRC');
         }
     }
     // Update the singleSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'binary') {
                 \Database\Updater::convertSingleField('tl_rocksolid_slide', 'singleSRC');
             }
         }
     }
 }
Esempio n. 20
0
 /**
  * Check the source folder
  * @return string
  */
 public function generate()
 {
     $this->multiSRC = deserialize($this->multiSRC);
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
     if ($this->objFiles === null) {
         if (!\Validator::isUuid($this->multiSRC[0])) {
             return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         }
         return '';
     }
     return parent::generate();
 }
 protected function compile()
 {
     $this->Template->changeFile = $this->getSetting(BOOTSTRAPPER_OPTION_CHANGEFILE);
     $this->Template->removeFile = $this->getSetting(BOOTSTRAPPER_OPTION_REMOVEFILE);
     $this->Template->fileIconClass = $this->getSetting(BOOTSTRAPPER_OPTION_FILEICONCLASS);
     // if upload succeeded a valid uuid must exist in activeRecord
     $this->uploaded = \Validator::isUuid($this->objWidget->activeRecord->{$this->objWidget->name});
     if ($this->uploaded) {
         $this->Template->filename = $_SESSION['FILES'][$this->objWidget->name]['name'];
         $this->Template->value = $this->objWidget->activeRecord->{$this->objWidget->name};
         $this->Template->fileClass = BOOTSTRAPPER_FILE_EXISTS_CLASS;
     } else {
         $this->Template->fileClass = BOOTSTRAPPER_FILE_NEW_CLASS;
     }
     $this->Template->uploaded = $this->uploaded;
 }
Esempio n. 22
0
 /**
  * Parse the template file and return it as string
  *
  * @param array $arrAttributes An optional attributes array
  *
  * @return string The template markup
  */
 public function parse($arrAttributes = null)
 {
     if ($this->tableless) {
         $this->strClass = trim('submit_container ' . $this->strClass);
     }
     if ($this->imageSubmit && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->src = $objModel->path;
         }
     }
     return parent::parse($arrAttributes);
 }
 /**
  * Return if the image does not exist
  *
  * @return string
  */
 public function generate()
 {
     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 '';
     }
     if (!is_file(TL_ROOT . '/' . $objFile->path)) {
         return '';
     }
     $this->singleSRC = $objFile->path;
     return parent::generate();
 }
 /**
  * Generate the content element
  * This is mostly adapted from Contao\ContentHyperlink::compile()
  */
 protected function _compileHyperlink()
 {
     global $objPage;
     $embed = explode('%s', $this->embed);
     // 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)) {
             $objFile = new \File($objModel->path, true);
             if ($objFile->isGdImage) {
                 $size = deserialize($this->size);
                 $intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth');
                 // Adjust the image size
                 if ($intMaxWidth > 0 && ($size[0] > $intMaxWidth || !$size[0] && $objFile->width > $intMaxWidth)) {
                     $size[0] = $intMaxWidth;
                     $size[1] = floor($intMaxWidth * $objFile->height / $objFile->width);
                 }
                 $src = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
                 if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
                     $this->Template->arrSize = $imgSize;
                     $this->Template->imgSize = ' ' . $imgSize[3];
                 }
                 $this->Template->src = TL_FILES_URL . $src;
                 $this->Template->alt = specialchars($this->alt);
                 $this->Template->linkTitle = specialchars($this->linkTitle);
                 $this->Template->caption = $this->caption;
             }
         }
     }
     $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);
     // Unset the title attributes in the back end (see #6258)
     if (TL_MODE == 'BE') {
         $this->Template->title = '';
         $this->Template->linkTitle = '';
     }
 }
 /**
  * Parse the template file and return it as string
  * @param array
  * @return string
  */
 public function parse($arrAttributes = null)
 {
     if ($this->formcontrol_template) {
         $this->strTemplate = $this->formcontrol_template;
         $this->type = 'regular';
         // Image button
         if ($this->imageSubmit && $this->singleSRC != '') {
             $objModel = \FilesModel::findByUuid($this->singleSRC);
             if ($objModel === null) {
                 if (!\Validator::isUuid($this->singleSRC)) {
                     return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
                 }
             } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
                 $this->type = 'image';
                 $this->src = $objModel->path;
             }
         }
     }
     return parent::parse($arrAttributes);
 }
 public function generate(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular)
 {
     if (TL_MODE == 'BE') {
         return;
     }
     $this->objPageBg = $this->searchForBackgroundImages($objPage);
     // Return if there are no files
     if (!$this->objPageBg) {
         return;
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByUuids($this->objPageBg->paSRC);
     if ($this->objFiles === null) {
         if (!\Validator::isUuid($this->objPageBg->paSRC[0])) {
             \System::log($GLOBALS['TL_LANG']['ERR']['version2format'], __METHOD__, TL_ERROR);
         }
         return;
     }
     $this->order = $this->objPageBg->paOrder;
     $this->compile($objPage);
 }
 private function prepareStyleData($arrData)
 {
     $arrKeyOutOfUse = array('ol_icon');
     foreach ($arrData as $key => $value) {
         if (in_array($key, $arrKeyOutOfUse)) {
             unset($arrData[$key]);
             continue;
         }
         if (is_array(deserialize($value))) {
             $arrData[$key] = deserialize($value);
         }
         if (\Validator::isUuid($value)) {
             // add ressource link
             $objFile = \FilesModel::findByUuid($value);
             if ($objFile !== null) {
                 $arrData[$key] = $objFile->path;
             }
         }
     }
     return $arrData;
 }
 /**
  * Extend the parent method
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         return $this->altContent;
     }
     if ($this->source != 'external') {
         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>';
             }
         } elseif (!is_file(TL_ROOT . '/' . $objFile->path)) {
             return '';
         } else {
             $this->singleSRC = $objFile->path;
         }
     }
     return parent::generate();
 }
 protected function generateFields($objItem)
 {
     $arrItem = parent::generateFields($objItem);
     if (in_array('member_content_archives', \ModuleLoader::getActive())) {
         $arrFilterTags = deserialize($this->memberContentArchiveTags, true);
         $arrItem['fields']['memberContent'] = '';
         if (($objMemberContentArchives = \HeimrichHannot\MemberContentArchives\MemberContentArchiveModel::findBy(array('mid=?', 'published=?'), array($objItem->memberId ?: $objItem->id, true))) !== null) {
             while ($objMemberContentArchives->next()) {
                 if (in_array($objMemberContentArchives->tag, $arrFilterTags)) {
                     $arrItem['fields']['memberContentId'] = $objMemberContentArchives->id;
                     $objElement = \ContentModel::findPublishedByPidAndTable($objMemberContentArchives->id, 'tl_member_content_archive');
                     if ($objElement !== null) {
                         while ($objElement->next()) {
                             $arrItem['fields']['memberContent'] .= \Controller::getContentElement($objElement->current());
                         }
                     }
                 }
             }
             if ($objMemberContentArchives->tag == $this->memberContentArchiveTeaserTag) {
                 $arrItem['fields']['memberContentTitle'] = $objMemberContentArchives->title;
                 $arrItem['fields']['memberContentTeaser'] = $objMemberContentArchives->teaser;
             }
             // override member fields
             $arrOverridableMemberFields = deserialize(\Config::get('overridableMemberFields'));
             if (!empty($arrOverridableMemberFields)) {
                 foreach ($arrOverridableMemberFields as $strField) {
                     $strFieldOverride = 'member' . ucfirst($strField);
                     if ($objMemberContentArchives->{$strFieldOverride}) {
                         if (\Validator::isUuid($objMemberContentArchives->{$strFieldOverride})) {
                             $objMemberContentArchives->{$strFieldOverride} = Files::getPathFromUuid($objMemberContentArchives->{$strFieldOverride});
                         }
                         $arrItem['fields'][$strField] = $objMemberContentArchives->{$strFieldOverride};
                     }
                 }
             }
         }
     }
     return $arrItem;
 }
 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Get the file entries from the database
     $this->arrImages = deserialize($this->images, true);
     if (!sizeof($this->arrImages)) {
         return '';
     }
     foreach ($this->arrImages as $k => $arrImage) {
         $objFile = \FilesModel::findByUuid($arrImage['singleSRC']);
         if ($objFile === null) {
             if (!\Validator::isUuid($arrImage['singleSRC'])) {
                 return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
             return '';
         }
         if (!is_file(TL_ROOT . '/' . $objFile->path)) {
             return '';
         }
         $this->arrImages[$k]['singleSRC'] = $objFile->path;
     }
     return parent::generate();
 }