/** * @return string */ public function generate() { if (TL_MODE === 'BE') { $template = new \BackendTemplate('be_wildcard'); $template->wildcard = '### ANTRAGO Event-Details ###'; $template->title = 'Event Details'; //"Kategorien: " . implode(', ',deserialize($this->arrData['ac_categories'])); return $template->parse(); } // hole event details; $url = $_SERVER["REQUEST_URI"]; $id = explode("veranstaltung=", $url)[1]; $this->configuration = AntragoConnector::getAntragoConfiguration($this->arrData['ac_event_details_config']); $db = \Database::getInstance(); $this->product = $db->prepare("SELECT * FROM tl_antrago_products WHERE productId=?")->execute($id)->fetchAssoc(); $this->formConfig = array('showRegisterForm' => $this->arrData['ac_event_details_show_register'], 'showApplicationForm' => $this->arrData['ac_event_details_show_applicationform']); // contact $this->contact = $db->prepare("SELECT * FROM tl_antrago_contacts WHERE id =?")->execute($this->product['productContact'])->fetchAssoc(); $oContactImage = \FilesModel::findByPk($this->contact['image']); // Add cover image if ($oContactImage !== null) { $sImage = \Image::get($oContactImage->path, '80', '100', 'center_center'); } $this->contact['image'] = $sImage; return parent::generate(); }
/** * Generate the module */ protected function compile() { $intList = $this->athletes_group; $objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList); //$objMembers = \MembersModel; // Return if no Members were found if (!$objMembers->numRows) { return; } $strLink = ''; // Generate a jumpTo link if ($this->jumpTo > 0) { $objJump = \PageModel::findByPk($this->jumpTo); if ($objJump !== null) { $strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s'); } } $arrMembers = array(); // Generate Members while ($objMembers->next()) { $strPhoto = ''; $objPhoto = \FilesModel::findByPk($objMembers->photo); // Add photo image if ($objPhoto !== null) { $strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center')); } $arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : ''); } $this->Template->members = $arrMembers; }
/** * Update FileTree fields */ public function updateFileTreeFields() { $objDatabase = \Database::getInstance(); $arrFields = array('singleSRC', 'imgSRC'); // Check the column type $objDesc = $objDatabase->query("DESC tl_downloadarchiveitems singleSRC"); // Change the column type if ($objDesc->Type != 'binary(16)') { foreach ($arrFields as $field) { $objFiles = $objDatabase->execute("SELECT id,{$field} FROM tl_downloadarchiveitems"); $objDatabase->query("ALTER TABLE tl_downloadarchiveitems CHANGE {$field} {$field} binary(16) NULL"); #$objDatabase->query("UPDATE tl_downloadarchiveitems SET $field=NULL WHERE $field='' OR $field=0"); while ($objFiles->next()) { $objHelper = $this->generateHelperObject($this->changePath($objFiles->{$field})); // UUID already if ($objHelper->isUuid) { continue; } // Numeric ID to UUID if ($objHelper->isNumeric) { $objFile = \FilesModel::findByPk($objHelper->value); $objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id); } else { $objFile = \FilesModel::findByPath($objHelper->value); $objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id); } } } } }
protected function updateFileField($table) { $database = \Database::getInstance(); if (!$database->tableExists($table)) { return; } if ($database->fieldExists('file', $table)) { // get the field description $desc = $database->query('DESC ' . $table . ' file'); // convert the field into a blob if ($desc->Type != 'blob') { $database->query('ALTER TABLE `' . $table . '` CHANGE `file` `file` blob NULL'); $database->query('UPDATE `' . $table . '` SET `file`=NULL WHERE `file`=\'\' OR `file`=0'); } // select fields with numeric values $resultSet = $database->query('SELECT id, file FROM ' . $table . ' WHERE file REGEXP \'^[0-9]+$\''); while ($resultSet->next()) { // Numeric ID to UUID $file = \FilesModel::findByPk($resultSet->file); if ($file) { $database->prepare('UPDATE `' . $table . '` SET file=? WHERE id=?')->execute($file->uuid, $resultSet->id); } } } }
/** * Return if the file does not exist * @return string */ public function generate() { // Return if there is no file if ($this->singleSRC == '') { return ''; } // Check for version 3 format if (!is_numeric($this->singleSRC)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } $objFile = \FilesModel::findByPk($this->singleSRC); if ($objFile === null) { 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) { $this->sendFileToBrowser($file); } $this->singleSRC = $objFile->path; return parent::generate(); }
/** * Generate the content element */ protected function compile() { 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 = $GLOBALS['TL_CONFIG']['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 != '') { if (!is_numeric($this->singleSRC)) { $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } else { $objModel = \FilesModel::findByPk($this->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { $this->singleSRC = $objModel->path; $this->addImageToTemplate($this->Template, $this->arrData); } } } }
/** * Generate sprite from given data */ public function generateSprite(\DataContainer $row) { // Get the theme meta data $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->execute($row->id); if ($objTheme->numRows < 1) { return; } if ($objTheme->spritegen_enable != false) { // Replace the numeric folder IDs $objInputFolder = FilesModel::findByPk($objTheme->spritegen_source); $objOutputFolder = FilesModel::findByPk($objTheme->spritegen_output_folder); if ($objInputFolder !== null) { // Provide settings for SpriteGen() $cssSprites = new \SpriteGen(); $cssSprites->addImageFolder(TL_ROOT . '/' . $objInputFolder->path); $cssSprites->setOutputFolder(TL_ROOT . '/' . $objOutputFolder->path); $cssSprites->setCacheTime(0); $cssSprites->useDatabase($objTheme->spritegen_modify_selectors, unserialize($objTheme->spritegen_selectors)); // Generate Sprite $cssSprites->generateSprite($objTheme->spritegen_output_file, $objTheme->id, true, $objTheme->spritegen_direction, $objTheme->spritegen_output_width); // Display success confirmation \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['spritegen_successful']); $this->log('Generated image and style sheet for sprite ' . $objTheme->spritegen_output_file, __METHOD__, CRON); } } }
/** * 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] . 'px" height="' . $size[1] . 'px"'; } } $this->Template->poster = false; // Optional poster if ($this->posterSRC != '') { if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) { $this->Template->poster = $objFile->path; } } // Pre-sort the array by preference if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) { $this->Template->isVideo = true; $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null); } else { $this->Template->isVideo = false; $arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null); } $this->objFiles->reset(); // Pass File objects to the template while ($this->objFiles->next()) { $objFile = new \File($this->objFiles->path); $arrFiles[$objFile->extension] = $objFile; } $this->Template->files = array_values(array_filter($arrFiles)); $this->Template->autoplay = $this->autoplay; }
/** * Generate a song row and return it as HTML string * @param array * @return string */ public function generateItemRow($arrRow) { $objImage = \FilesModel::findByPk($arrRow['singleSRC']); if ($objImage !== null) { $strImage = \Image::getHtml(\Image::get($objImage->path, '30', '30', 'center_center')); } return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . '</div>'; }
public function generateActRow($arrRow) { $objImage = \FilesModel::findByPk($arrRow['singleSRC']); if ($objImage !== null) { $strImage = \Image::getHtml(\Image::get($objImage->path, '25', '33', 'center_center')); } return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . ' <br /><span style="padding-left:3px;color:#b3b3b3;">[' . $arrRow['post'] . ']</span></div>'; }
protected function parseExtJs($objLayout, &$arrReplace) { $arrJs = array(); $objJs = ExtJsModel::findMultipleByIds(deserialize($objLayout->extjs)); if ($objJs === null) { return false; } $cache = !$GLOBALS['TL_CONFIG']['debugMode']; while ($objJs->next()) { $objFiles = ExtJsFileModel::findMultipleByPid($objJs->id); if ($objFiles === null) { continue; } $strChunk = ''; $strFile = 'assets/js/' . $objJs->title . '.js'; $strFileMinified = str_replace('.js', '.min.js', $strFile); $objGroup = new \File($strFile, file_exists(TL_ROOT . '/' . $strFile)); $objGroupMinified = new \File($strFileMinified, file_exists(TL_ROOT . '/' . $strFile)); $rewrite = $objJs->tstamp > $objGroup->mtime || $objGroup->size == 0 || $cache && $objGroupMinified->size == 0; while ($objFiles->next()) { $objFileModel = \FilesModel::findByPk($objFiles->src); if ($objFileModel === null || !file_exists(TL_ROOT . '/' . $objFileModel->path)) { continue; } $objFile = new \File($objFileModel->path); $strChunk .= $objFile->getContent() . "\n"; if ($objFile->mtime > $objGroup->mtime) { $rewrite = true; } } // simple file caching if ($rewrite) { $objGroup->write($strChunk); $objGroup->close(); // minify js if ($cache) { $objGroup = new \File($strFileMinified); $objMinify = new \MatthiasMullie\Minify\JS(); $objMinify->add($strChunk); $objGroup->write(rtrim($objMinify->minify(), ";") . ";"); // append semicolon, otherwise "(intermediate value)(...) is not a function" $objGroup->close(); } } $arrJs[] = $cache ? "{$strFileMinified}|static" : "{$strFile}"; } // HOOK: add custom css if (isset($GLOBALS['TL_HOOKS']['parseExtJs']) && is_array($GLOBALS['TL_HOOKS']['parseExtJs'])) { foreach ($GLOBALS['TL_HOOKS']['parseExtJs'] as $callback) { $arrJs = static::importStatic($callback[0])->{$callback}[1]($arrJs); } } if ($objJs->addBootstrap) { $this->addTwitterBootstrap(); } // inject extjs before other plugins, otherwise bootstrap may not work $GLOBALS['TL_JAVASCRIPT'] = is_array($GLOBALS['TL_JAVASCRIPT']) ? array_merge($GLOBALS['TL_JAVASCRIPT'], $arrJs) : $arrJs; }
/** * Generate the module */ protected function compile() { $objFaq = \FaqModel::findPublishedByPids($this->faq_categories); if ($objFaq === null) { $this->Template->faq = array(); return; } global $objPage; $arrFaq = array_fill_keys($this->faq_categories, array()); // Add FAQs while ($objFaq->next()) { $objTemp = (object) $objFaq->row(); // Clean RTE output if ($objPage->outputFormat == 'xhtml') { $objFaq->answer = \String::toXhtml($objFaq->answer); } else { $objFaq->answer = \String::toHtml5($objFaq->answer); } $objTemp->answer = \String::encodeEmail($objFaq->answer); $objTemp->addImage = false; // Add an image if ($objFaq->addImage && $objFaq->singleSRC != '') { if (!is_numeric($objFaq->singleSRC)) { $objTemp->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } else { $objModel = \FilesModel::findByPk($objFaq->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { $objFaq->singleSRC = $objModel->path; $this->addImageToTemplate($objTemp, $objFaq->row()); } } } $objTemp->enclosure = array(); // Add enclosure if ($objFaq->addEnclosure) { $this->addEnclosuresToTemplate($objTemp, $objFaq->row()); } $objTemp->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name); // Order by PID $arrFaq[$objFaq->pid]['items'][] = $objTemp; $arrFaq[$objFaq->pid]['headline'] = $objFaq->category; } $arrFaq = array_values(array_filter($arrFaq)); $limit_i = count($arrFaq) - 1; // Add classes first, last, even and odd for ($i = 0; $i <= $limit_i; $i++) { $class = ($i == 0 ? 'first ' : '') . ($i == $limit_i ? 'last ' : '') . ($i % 2 == 0 ? 'even' : 'odd'); $arrFaq[$i]['class'] = trim($class); $limit_j = count($arrFaq[$i]['items']) - 1; for ($j = 0; $j <= $limit_j; $j++) { $class = ($j == 0 ? 'first ' : '') . ($j == $limit_j ? 'last ' : '') . ($j % 2 == 0 ? 'even' : 'odd'); $arrFaq[$i]['items'][$j]->class = trim($class); } } $this->Template->faq = $arrFaq; $this->Template->request = $this->getIndexFreeRequest(true); $this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop']; }
/** * Return array of person * * @param object $objPerson * @param array $arrSize * @return array */ protected function getArrayOfPerson($objPerson, $arrSize) { $arrData = $objPerson->row(); $objFile = \FilesModel::findByPk($objPerson->image); $arrData['singleSRC'] = $objFile->path; $arrData['size'] = $arrSize; $arrData['alt'] = $objPerson->firstname . ' ' . $objPerson->lastname; return $arrData; }
/** * Insert a teaser image to the template * @param object * @param array * @return void * called from parseArticles HOOK */ public function addTeaserImage($objTemplate, $row) { if (!$objTemplate->teaser_addImage) { return; } // original image setting $addNewsImage = $objTemplate->addImage; $addTeaserImage = $objTemplate->teaser_addImage; // overwrite image sizes if set in module if ($row['size'] != '') { $objTemplate->size = $row['size']; $objTemplate->teaser_size = $row['size']; } // teaser image if ($addTeaserImage) { // fetch teaser image $objFile = \FilesModel::findByPk($objTemplate->teaser_singleSRC); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return; } $objTemplate->teaser_singleSRC = $objFile->path; $arrTeaserImage = array('singleSRC' => $objTemplate->teaser_singleSRC, 'size' => $objTemplate->teaser_size, 'alt' => $objTemplate->teaser_alt, 'imageUrl' => $objTemplate->teaser_imageUrl, 'fullsize' => $objTemplate->teaser_fullsize, 'floating' => $objTemplate->teaser_floating, 'imagemargin' => $objTemplate->teaser_imagemargin, 'linkedimage' => $objTemplate->teaser_linkedimage); } // news image if ($addNewsImage) { // store news image data $arrNewsImage = array('singleSRC' => $objTemplate->singleSRC, 'size' => $objTemplate->size, 'alt' => $objTemplate->alt, 'imageUrl' => $objTemplate->imageUrl, 'fullsize' => $objTemplate->fullsize, 'floating' => $objTemplate->floating, 'imagemargin' => $objTemplate->imagemaring); } // Add teaser image. if ($addTeaserImage) { //Use contao internal function. (overwrites news image values) parent::addImageToTemplate($objTemplate, $arrTeaserImage); // set template vars $objTemplate->teaser_imgSize = $objTemplate->imgSize; $objTemplate->teaser_src = $objTemplate->src; $objTemplate->teaser_attributes = $objTemplate->attributes; $objTemplate->teaser_addBefore = $objTemplate->addBefore; $objTemplate->teaser_margin = $objTemplate->margin; $objTemplate->teaser_title = $objTemplate->title; $objTemplate->teaser_alt = $objTemplate->alt; $objTemplate->teaser_href = $objTemplate->href; $objTemplate->teaser_float = $objTemplate->float; $objTemplate->teaser_floatClass = $objTemplate->floatClass; // link to post if ($objTemplate->teaser_linkedimage && TL_MODE == 'FE') { $objTemplate->teaser_href = $objTemplate->link; $objTemplate->teaser_attributes = $objTemplate->teaser_fullsize ? LINK_NEW_WINDOW : ''; } } // Add news image. if ($addNewsImage) { // restore news image in template parent::addImageToTemplate($objTemplate, $arrNewsImage); } $objTemplate->addImage = $addNewsImage; $objTemplate->teaser_addImage = $addTeaserImage; }
/** * Generate the content element */ protected function compile() { global $objPage; if (substr($this->url, 0, 7) == 'mailto:') { $this->url = \String::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 != '' && is_numeric($this->singleSRC)) { $objModel = \FilesModel::findByPk($this->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { $this->Template = new \FrontendTemplate('ce_hyperlink_image'); $this->Template->setData($this->arrData); $objFile = new \File($objModel->path); if ($objFile->isGdImage) { $size = deserialize($this->size); $intMaxWidth = TL_MODE == 'BE' ? 320 : $GLOBALS['TL_CONFIG']['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; } } } 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->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"'; } }
/** * Add an image to each record * @param array $row * @param string $label * @param DataContainer $dc * @param array $args * * @return array */ public function addImage($row, $label, DataContainer $dc, $args) { $objImage = \FilesModel::findByPk($row['singleSRC']); if ($objImage !== null) { $strImage = \Image::getHtml(\Image::get($objImage->path, '80', '60', 'center_center')); } $args[0] = $strImage; return $args; }
/** * Add an image to each record * @param array * @param string * @return string */ public function addPreviewImage($row, $label) { if ($row['screenshot'] != '') { $objFile = FilesModel::findByPk($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; }
public function listPerson($row) { if ($row['image'] != null) { $objFile = \FilesModel::findByPk(deserialize($row['image'])); $singleSRC = $objFile->path; $sReturn = '<figure style="float: left; margin-right: 1em;"><img src="' . Image::get($singleSRC, 80, 80, 'center_top') . '"></figure>'; } $sReturn .= '<div>' . $row['lastname'] . ', ' . $row['firstname'] . '</div>'; return $sReturn; }
public function generateLabel($row, $label) { $sReturn = ''; $objFile = \FilesModel::findByPk(deserialize($row['logo'])); if ($objFile->path != '') { $sReturn = '<figure style="float: left; margin-right: 1em;"><img src="' . Image::get($objFile->path, 80, 50, 'center_center') . '"></figure>'; } $sReturn .= '<div>' . $label . '</div>'; return $sReturn; }
/** * Add teaser image to template * @param array * @param array * @param integer * @param integer * @return array * called from getAllEvents HOOK */ public function addTeaserImage($arrEvents, $arrCalendars, $intStart, $intEnd, $objModule) { $arrReturn = array(); foreach ($arrEvents as $date => $startDate) { foreach ($startDate as $time => $events) { foreach ($events as $i => $event) { if ($event['teaser_addImage']) { // overwrite image size if set in module $size = deserialize($event['teaser_size']); if ($objModule->size != '') { $size = deserialize($objModule->imgSize); } // fetch teaser image $objFile = \FilesModel::findByPk($event['teaser_singleSRC']); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return; } $event['teaser_singleSRC'] = $objFile->path; // create psydo template object to call addImageToTemplate Function $objTemplate = new \FrontendTemplate($objModule->cal_template); $arrTeaserImage = array('singleSRC' => $event['teaser_singleSRC'], 'size' => $event['teaser_size'], 'alt' => $event['teaser_alt'], 'imageUrl' => $event['teaser_imageUrl'], 'fullsize' => $event['teaser_fullsize'], 'floating' => $event['teaser_floating'], 'imagemargin' => $event['teaser_imagemargin'], 'linkedimage' => $event['teaser_linkedimage']); parent::addImageToTemplate($objTemplate, $arrTeaserImage); // set vars $event['teaser_singleSRC'] = $objTemplate->singleSRC; $event['teaser_src'] = $objTemplate->src; $event['teaser_href'] = $objTemplate->href; $event['teaser_alt'] = $objTemplate->alt; $event['teaser_title'] = $objTemplate->title; $event['teaser_imageUrl'] = $objTemplate->imageUrl; $event['teaser_fullsize'] = $objTemplate->fullsize; $event['teaser_float'] = $objTemplate->float; $event['teaser_floatClass'] = $objTemplate->floatClass; $event['teaser_margin'] = $objTemplate->margin; $event['teaser_imgSize'] = $objTemplate->imgSize; $event['teaser_attributes'] = $objTemplate->attributes; $event['teaser_addBefore'] = $objTemplate->addBefore; // Link to post, overwrite all other link settings if ($event['teaser_linkedimage'] && TL_MODE == "FE") { $event['teaser_href'] = $event['href']; $event['teaser_attributes'] = $objTemplate->fullsize ? LINK_NEW_WINDOW : ''; } // remove temp. template unset($objTemplate); } // set $arrReturn[$date][$time][$i] = $event; } } } $arrEvents = $arrReturn; return $arrEvents; }
/** * Initialize the object * @param string * @param integer */ public function __construct($strTable, $intPid) { parent::__construct(); $this->strTable = $strTable; $this->intPid = $intPid; // Store the path if it is an editable file if ($strTable == 'tl_files') { $objFile = \FilesModel::findByPk($intPid); if ($objFile !== null && in_array($objFile->extension, trimsplit(',', \Config::get('editableFiles')))) { $this->strPath = $objFile->path; } } }
/** * Generate the content element */ protected function compile() { // Accordion start if ($this->mooType == 'mooStart') { if (TL_MODE == 'FE') { $this->strTemplate = 'ce_accordion_start'; $this->Template = new \FrontendTemplate($this->strTemplate); $this->Template->setData($this->arrData); } else { $this->strTemplate = 'be_wildcard'; $this->Template = new \BackendTemplate($this->strTemplate); $this->Template->title = $this->mooHeadline; } } elseif ($this->mooType == 'mooStop') { if (TL_MODE == 'FE') { $this->strTemplate = 'ce_accordion_stop'; $this->Template = new \FrontendTemplate($this->strTemplate); $this->Template->setData($this->arrData); } else { $this->strTemplate = 'be_wildcard'; $this->Template = new \BackendTemplate($this->strTemplate); } } else { global $objPage; // Clean RTE output if ($objPage->outputFormat == 'xhtml') { $this->text = \String::toXhtml($this->text); } else { $this->text = \String::toHtml5($this->text); } $this->Template->text = \String::encodeEmail($this->text); $this->Template->addImage = false; // Add an image if ($this->addImage && $this->singleSRC != '') { if (!is_numeric($this->singleSRC)) { $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } else { $objModel = \FilesModel::findByPk($this->singleSRC); if ($objModel !== null && 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; }
/** * Return if the image does not exist * @return string */ public function generate() { if ($this->singleSRC == '') { return ''; } if (!is_numeric($this->singleSRC)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } $objFile = \FilesModel::findByPk($this->singleSRC); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return ''; } $this->singleSRC = $objFile->path; return parent::generate(); }
/** * Generate the widget and return it as string * @return string */ public function generate() { if ($this->imageSubmit) { // Check for version 3 format if ($this->singleSRC != '' && !is_numeric($this->singleSRC)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } $objModel = \FilesModel::findByPk($this->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { return sprintf('<input type="image" src="%s" id="ctrl_%s" class="submit%s" title="%s" alt="%s"%s%s', $objModel->path, $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', specialchars($this->slabel), specialchars($this->slabel), $this->getAttributes(), $this->strTagEnding); } } // Return the regular button return sprintf('<input type="submit" id="ctrl_%s" class="submit%s" value="%s"%s%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', specialchars($this->slabel), $this->getAttributes(), $this->strTagEnding); }
public function addLinksToTemplate(\FrontendTemplate $objTemplate, \stdClass $objConfig, $intParent) { $objTemplate->LinksToUs = array(); $objEnvironment = \Environment::getInstance(); $folder = \FilesModel::findByPk($objConfig->bannerFolder); $bannerFolder = TL_ROOT . "/" . $folder->path; $handle = opendir($bannerFolder); while ($file = readdir($handle)) { $filelist[] = $file; } asort($filelist); $count = 0; if ($objConfig->template == '') { $objConfig->template = 'links2us_banner'; } $objEntry = new \FrontendTemplate($objConfig->template); while (list($a, $file) = each($filelist)) { if (exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_GIF || exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_JPEG || exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_PNG) { if ($objConfig->bannerSize) { $dimension = getimagesize($bannerFolder . "/" . $file); $dimensionXL = $GLOBALS['TL_LANG']['MSC']['size'] . $dimension[0] . "x" . $dimension[1]; $bannerInfo = $dimensionXL; } if ($objConfig->bannerByte) { $filesize = filesize($bannerFolder . "/" . $file); $filesize = number_format($filesize / 1024, 2); $filesizeXL = $GLOBALS['TL_LANG']['MSC']['bytes'] . $filesize . "kb"; $bannerInfo = $filesizeXL; } if ($objConfig->bannerSize && $objConfig->bannerByte) { $bannerInfo = $dimensionXL . " ( " . $filesize . "kb ) "; } $objEntry->bannerSRC = $objEnvironment->base . $folder->path . "/" . $file; $objEntry->bCount = $count; $objEntry->toClipboard = $objConfig->toClipboard; $objEntry->bannerInfo = $bannerInfo; $arrLinkBanners[] = $objEntry->parse(); ++$count; } } $objTemplate->backLink = $objConfig->backLink; $objTemplate->LinkBanners = $arrLinkBanners; $objTemplate->color = ' ' . $objConfig->modColor; $objTemplate->TeaserText = $objConfig->TeaserText; $objTemplate->displayTextLink = $objConfig->displayTextLink; $objTemplate->CopytoClip = $objConfig->toClipboard; $objTemplate->backInfo = '<p class="backlink">Links2Us by <a href="http://jedo-style.de">jedo Style</a></p>'; }
/** * Generate the module */ protected function parseLink($objLink, $strClass = '', $intCount = 0) { $objTemplate = new \FrontendTemplate($this->links_template); $objTemplate->setData($objLink->row()); $strImage = ''; $objImage = \FilesModel::findByPk($objLink->singleSRC); $size = deserialize($this->imgSize); // Add image if ($objImage !== null) { $strImage = \Image::getHtml(\Image::get($objImage->path, $size[0], $size[1], $size[2])); } $objTemplate->class = $strClass; $objTemplate->linkTitle = $objLink->linkTitle ? $objLink->linkTitle : $objLink->title; $objTemplate->image = $strImage; return $objTemplate->parse(); }
public function generateCustomizePage(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular) { $externalJavascript = deserialize($objLayout->externalJavascript, true); $layoutHasFooter = $objLayout->rows; $footerMode = $objLayout->footerAtBottom && ($layoutHasFooter == "2rwf" || $layoutHasFooter == "3rw") ? true : false; // TODO: enable fullpage script here // TODO: enable isotope here!!?? if ($footerMode) { $GLOBALS['TL_CSS'][] = 'system/modules/zdps_customize/assets/css/footer.css||static'; } if (is_array($externalJavascript) && count($externalJavascript) > 0) { foreach ($externalJavascript as $jsFile) { $objFile = \FilesModel::findByPk($jsFile); $GLOBALS['TL_JAVASCRIPT'][] = $objFile->path . '|static'; } } }
/** * Add image to template * @param object * @param boolean */ public function __construct($objTemplate, $isCE = false) { $articleHref = $objTemplate->href; $arrImage = array(); // handle include articles if ($isCE) { $objDatabase = \Database::getInstance(); $objArticle = $objDatabase->prepare("SELECT * FROM tl_article WHERE id=?")->limit(1)->execute($objTemplate->article); if (!$objArticle->addImage) { return; } $arrImage = $objArticle->row(); // fetch teaser image $objFile = \FilesModel::findByPk($arrImage['singleSRC']); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return; } $arrImage['singleSRC'] = $objFile->path; } // regular article if (!$isCE && $objTemplate->addImage) { // fetch teaser image $objFile = \FilesModel::findByPk($objTemplate->singleSRC); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return; } $objTemplate->singleSRC = $objFile->path; $arrImage = array('addImage' => $objTemplate->addImage, 'singleSRC' => $objTemplate->singleSRC, 'alt' => $objTemplate->alt, 'size' => $objTemplate->size, 'imagemargin' => $objTemplate->imagemargin, 'floating' => $objTemplate->floating, 'fullsize' => $objTemplate->fullsize, 'caption' => $objTemplate->caption, 'linkedimage' => $objTemplate->linkedimage, 'imageUrl' => $objTemplate->imageUrl); } if (count($arrImage) < 1) { return; } // add image to template parent::addImageToTemplate($objTemplate, $arrImage); $objTemplate->imageHref = $arrImage['imageUrl']; $objTemplate->href = $articleHref; // prepare for lightbox if ($arrImage['fullsize'] && !$arrImage['linkedimage'] && !$arrImage['imageUrl']) { $objTemplate->imageHref = $arrImage['singleSRC']; } // link to article if ($arrImage['linkedimage'] && TL_MODE == 'FE') { $objTemplate->imageHref = $articleHref; $objTemplate->attributes = $objTemplate->fullsize ? LINK_NEW_WINDOW : ''; } }
/** * Set image files * @param array */ public function setFiles($varValue) { $this->arrFiles = array(); $varValue = deserialize($varValue); if (is_array($varValue) && !empty($varValue)) { foreach ($varValue as $file) { $this->addImage($file); } } // No image available, add placeholder from store configuration if (empty($this->arrFiles)) { $objPlaceholder = \FilesModel::findByPk($this->placeholder); if (null !== $objPlaceholder && is_file(TL_ROOT . '/' . $objPlaceholder->path)) { $this->addImage(array('src' => $objPlaceholder->path), false); } } }
public function bbParseBackendTemplate($strContent, $strTemplate) { if (isset($GLOBALS['TL_CONFIG']['branding_backend_css']) && !empty($GLOBALS['TL_CONFIG']['branding_backend_css'])) { if (VERSION > 3.2) { $objFile = FilesModel::findByUuid($GLOBALS['TL_CONFIG']['branding_backend_css']); } elseif (VERSION > 3.0) { $objFile = FilesModel::findByPk($GLOBALS['TL_CONFIG']['branding_backend_css']); } else { $objFile = new stdClass(); $objFile->path = $GLOBALS['TL_CONFIG']['branding_backend_css']; } if (isset($objFile->path)) { $strContent = str_replace('</head>', '<link rel="stylesheet" href="' . $objFile->path . '"></head>', $strContent); } } return $strContent; }