/** * Generate the widget and return it as string * * @return string */ public function generate() { global $objPage; if ($objPage->outputFormat == 'html5') { $blnIsHtml5 = true; } $blnSwitchOrder = (bool) $this->efgSwitchButtonOrder; $strButtonBack = ''; $strButtonSubmit = ''; if ($this->efgAddBackButton && ($this->formTotalPages > 1 && $this->formActivePage > 1 || TL_MODE == 'BE')) { if ($this->efgBackImageSubmit && $this->efgBackSingleSRC != '') { $objFileModel = \FilesModel::findById($this->efgBackSingleSRC); $strButtonBack .= sprintf('<input type="image"%s src="%s" id="ctrl_%s_back" class="submit back%s" alt="%s" title="%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_BACK"' : '', $objFileModel->path, $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->efgBackSlabel), specialchars($this->efgBackSlabel), specialchars('submit_back'), $this->getAttributes(), $this->strTagEnding); } else { $strButtonBack .= sprintf('<input type="submit"%s id="ctrl_%s_back" class="submit back%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_BACK"' : '', $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->efgBackSlabel), $this->getAttributes(), $this->strTagEnding); } } if ($this->imageSubmit && $this->singleSRC != '') { $objFileModel = \FilesModel::findById($this->singleSRC); $strButtonSubmit .= sprintf('<input type="image"%s src="%s" id="ctrl_%s" class="submit next%s" alt="%s" title="%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_NEXT"' : '', $objFileModel->path, $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->slabel), specialchars($this->slabel), specialchars('submit_next'), $this->getAttributes(), $this->strTagEnding); } else { $strButtonSubmit .= sprintf('<input type="submit"%s id="ctrl_%s" class="submit next%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_NEXT"' : '', $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->slabel), $this->getAttributes(), $this->strTagEnding); } return $blnSwitchOrder ? $strButtonSubmit . $strButtonBack : $strButtonBack . $strButtonSubmit; }
/** * Run the controller */ public function run() { $strFile = \Input::get('file', true); if ($strFile != '') { // Make sure there are no attempts to hack the file system if (preg_match('@^\\.+@i', $strFile) || preg_match('@\\.+/@i', $strFile) || preg_match('@(://)+@i', $strFile)) { header('HTTP/1.1 404 Not Found'); die('Invalid file name'); } // Limit downloads to the files directory if (!preg_match('@^' . preg_quote(\Config::get('uploadPath'), '@') . '@i', $strFile)) { header('HTTP/1.1 404 Not Found'); die('Invalid path'); } // Check whether the file exists if (!is_file(TL_ROOT . '/' . $strFile)) { header('HTTP/1.1 404 Not Found'); die('File not found'); } // find the path in the database if (($objFile = \FilesModel::findOneByPath($strFile)) !== null) { // authenticate the frontend user \FrontendUser::getInstance()->authenticate(); // check if file is protected if (!\Controller::isVisibleElement($objFile)) { $objHandler = new $GLOBALS['TL_PTY']['error_403'](); $objHandler->generate($strFile); } elseif ($objFile->pid) { // check if parent folders are proteced do { $objFile = \FilesModel::findById($objFile->pid); if (!\Controller::isVisibleElement($objFile)) { $objHandler = new $GLOBALS['TL_PTY']['error_403'](); $objHandler->generate($strFile); } } while ($objFile->pid); } } // get the file $objFile = new \File($strFile); // Make sure no output buffer is active // @see http://ch2.php.net/manual/en/function.fpassthru.php#74080 while (@ob_end_clean()) { } // Prevent session locking (see #2804) session_write_close(); // Disable zlib.output_compression (see #6717) @ini_set('zlib.output_compression', 'Off'); // Set headers header('Content-Type: ' . $objFile->mime); header('Content-Length: ' . $objFile->filesize); // Disable maximum execution time @ini_set('max_execution_time', 0); // Output the file readfile(TL_ROOT . '/' . $objFile->path); } // Stop the script (see #4565) exit; }
public function getTitle(WatchlistItemModel $objItem) { $objFileModel = \FilesModel::findById($objItem->uuid); if ($objFileModel === null) { return; } $objFile = new \File($objFileModel->path, true); $linkTitle = $objFile->name; $arrMeta = deserialize($objFileModel->meta); // Language support if (($arrLang = $arrMeta[$GLOBALS['TL_LANGUAGE']]) != '') { $linkTitle = $arrLang['title'] ? $arrLang['title'] : $linkTitle; } return $linkTitle; }
/** * Add the type of input field * @param array * @return string */ public function listJsFiles($arrRow) { $objFiles = FilesModel::findById($arrRow['src']); // Return if there is no result if ($objFiles === null) { return ''; } // Show files and folders if ($objFiles->type == 'folder') { $thumbnail = $this->generateImage('folderC.gif'); } else { $objFile = new \File($objFiles->path, true); $thumbnail = $this->generateImage($objFile->icon); } return '<div class="tl_content_left" style="line-height:21px"><div style="float:left; margin-right:2px;">' . $thumbnail . '</div>' . $objFiles->name . '<span style="color:#b3b3b3;padding-left:3px">[' . str_replace($objFiles->name, '', $objFiles->path) . ']</span></div>' . "\n"; }
public function getRowLabel($row) { if ($row['image']) { $objFile = \FilesModel::findById($row['image']); if ($objFile !== null) { $preview = $objFile->path; $image = '<img src="' . $this->getImage($preview, 65, 45, 'center_center') . '" alt="' . htmlspecialchars($label) . '" style="display: inline-block;vertical-align: top;*display:inline;zoom:1;padding-right:8px;" />'; } } if ($row['title']) { $text = '<span class="name">' . $row['title'] . '</span>'; } $objData = \Database::getInstance()->prepare('SELECT COUNT(id) as cc FROM tl_link_data WHERE pid = ?')->execute($row['id']); if ($objData->cc > 0) { $text .= ' (' . $objData->cc . ')'; } return $image . $text; // return $this->replaceInsertTags('{{image::/' . $objFile->path . '?width=55&height=65}}'); }
public function getRowLabel($row) { if ($row['previewStandardImage']) { $objFile = \FilesModel::findById($row['previewStandardImage']); if ($objFile !== null) { $preview = $objFile->path; $image = '<img src="' . $this->getImage($preview, 65, 45, 'center_center') . '" alt="' . htmlspecialchars($label) . '" style="display: inline-block;vertical-align: top;*display:inline;zoom:1;padding-right:8px;" />'; } } if ($row['title']) { $text = '<span class="name"><strong>' . $row['title'] . '</strong></span>'; } if ($row['previewImageSize']) { $arrTemp = deserialize($row['previewImageSize']); $text .= ' - <span >' . $arrTemp[0] . ', ' . $arrTemp[1] . ', ' . $arrTemp[2] . '</span>'; } //'fields' => array('title', 'previewImageSize', 'previewImageMargin', 'previewConsiderOrientation'), return $text . $image; // return $this->replaceInsertTags('{{image::/' . $objFile->path . '?width=55&height=65}}'); }
/** * Generate a song row and return it as HTML string * @param array * @return string */ public function getRowLabel($row) { if ($row['linkSource']) { $objFileFind = \FilesModel::findById($row['linkSource']); $objFile = new \File($objFileFind->path, true); if ($row['previewImage'] != '') { $objFileFind = \FilesModel::findById($row['previewImage']); $preview = '' . $objFileFind->path; } else { $d_path = 'assets/images/download_extended/'; $preview = $d_path . substr(preg_replace('/[^a-zA-Z0-9]/', '', $objFile->filename), 0, 8) . '-' . substr(md5($objFile->path), 0, 8) . '.jpg'; } $image = '<img src="' . $this->getImage($preview, 110, 120, 'proportional') . '" alt="' . htmlspecialchars($label) . '" style="display: inline-block;vertical-align: top;*display:inline;zoom:1;margin-right:8px;border:1px solid #ccc;" />'; } $text = '<div class="name" style="display: inline-block;vertical-align: top;">'; if ($row['title']) { $text .= '<strong>' . $row['title'] . '</strong>'; } $text .= '</div>'; return $image . $text; // $out = $this->replaceInsertTags('{{image::/' . $row['vorschaubild'] . '?width=55&height=65}}'); }
public function importFile() { if (\Input::get('key') != 'import') { return ''; } if (null === $this->arrImportIgnoreFields) { $this->arrImportIgnoreFields = array('id', 'pid', 'tstamp', 'form', 'ip', 'date', 'confirmationSent', 'confirmationDate', 'import_source'); } if (null === $this->arrImportableFields) { $arrFdFields = array_merge($this->arrBaseFields, $this->arrDetailFields); $arrFdFields = array_diff($arrFdFields, $this->arrImportIgnoreFields); foreach ($arrFdFields as $strFdField) { $this->arrImportableFields[$strFdField] = $GLOBALS['TL_DCA']['tl_formdata']['fields'][$strFdField]['label'][0]; } } $arrSessionData = $this->Session->get('EFG'); if (null == $arrSessionData) { $arrSessionData = array(); } $this->Session->set('EFG', $arrSessionData); // Import CSV if ($_POST['FORM_SUBMIT'] == 'tl_formdata_import') { $this->loadDataContainer('tl_files'); $strMode = 'preview'; $arrSessionData['import'][$this->strFormKey]['separator'] = $_POST['separator']; $arrSessionData['import'][$this->strFormKey]['csv_has_header'] = $_POST['csv_has_header'] == '1' ? '1' : ''; $this->Session->set('EFG', $arrSessionData); if (intval(\Input::post('import_source')) == 0) { \Message::addError($GLOBALS['TL_LANG']['tl_formdata']['error_select_source']); \Controller::reload(); } $objFileModel = \FilesModel::findById(\Input::post('import_source')); $objFile = new \File($objFileModel->path, true); if ($objFile->extension != 'csv') { \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension)); setcookie('BE_PAGE_OFFSET', 0, 0, '/'); \Controller::reload(); } // Get separator switch (\Input::post('separator')) { case 'semicolon': $strSeparator = ';'; break; case 'tabulator': $strSeparator = '\\t'; break; case 'comma': default: $strSeparator = ','; break; } if ($_POST['FORM_MODE'] == 'import') { $strMode = 'import'; $time = time(); $intTotal = null; $intInvalid = 0; $intValid = 0; $arrImportCols = \Input::post('import_cols'); $arrSessionData['import'][$this->strFormKey]['import_cols'] = $arrImportCols; $this->Session->set('EFG', $arrSessionData); $arrMapFields = array_flip($arrImportCols); if (isset($arrMapFields['__IGNORE__'])) { unset($arrMapFields['__IGNORE__']); } $blnUseCsvHeader = $arrSessionData['import'][$this->strFormKey]['csv_has_header'] == '1' ? true : false; $arrEntries = array(); $resFile = $objFile->handle; $timeNow = time(); $strFormTitle = $this->Formdata->arrFormsDcaKey[substr($this->strFormKey, 3)]; $strAliasField = strlen($this->Formdata->arrStoringForms[substr($this->strFormKey, 3)]['efgAliasField']) ? $this->Formdata->arrStoringForms[substr($this->strFormKey, 3)]['efgAliasField'] : ''; $objForm = \FormModel::findOneBy('title', $strFormTitle); if ($objForm !== null) { $arrFormFields = $this->Formdata->getFormfieldsAsArray($objForm->id); } while (($arrRow = @fgetcsv($resFile, null, $strSeparator)) !== false) { if (null === $intTotal) { $intTotal = 0; if ($blnUseCsvHeader) { continue; } } $strAlias = ''; if (isset($arrRow[$arrMapFields['alias']]) && strlen($arrRow[$arrMapFields['alias']])) { $strAlias = $arrRow[$arrMapFields['alias']]; } elseif (isset($arrRow[$arrMapFields[$strAliasField]]) && strlen($arrRow[$arrMapFields[$strAliasField]])) { \Input::setPost($strAliasField, $arrRow[$arrMapFields[$strAliasField]]); } $arrDetailSets = array(); // prepare base data $arrSet = array('tstamp' => $timeNow, 'fd_member' => 0, 'fd_user' => intval($this->User->id), 'form' => $strFormTitle, 'ip' => \Environment::get('ip'), 'date' => $timeNow, 'published' => $GLOBALS['TL_DCA']['tl_formdata']['fields']['published']['default'] == '1' ? '1' : ''); foreach ($arrMapFields as $strField => $intCol) { if (in_array($strField, $this->arrImportIgnoreFields)) { continue; } if (in_array($strField, $this->arrBaseFields)) { $arrField = $GLOBALS['TL_DCA']['tl_formdata']['fields'][$strField]; if (in_array($strField, $this->arrOwnerFields)) { switch ($strField) { case 'fd_user': $array = 'arrUsers'; break; case 'fd_member': $array = 'arrMembers'; break; case 'fd_user_group': $array = 'arrUserGroups'; break; case 'fd_member_group': $array = 'arrMemberGroups'; break; } if (is_numeric($arrRow[$intCol]) && array_key_exists($arrRow[$intCol], $this->{$array})) { $varValue = $arrRow[$intCol]; } elseif (is_string($arrRow[$intCol])) { $varValue = intval(array_search($arrRow[$intCol], $this->{$array})); } } elseif ($strField == 'published') { if ($arrRow[$intCol] == $arrField['label'][0] || intval($arrRow[$intCol]) == 1) { $varValue = '1'; } else { $varValue = ''; } } elseif ($strField == 'alias') { continue; } else { $varValue = $arrRow[$intCol]; } $arrSet[$strField] = $varValue; } } // prepare details data foreach ($arrMapFields as $strField => $intCol) { if (in_array($strField, $this->arrImportIgnoreFields)) { continue; } if (in_array($strField, $this->arrDetailFields)) { // $arrField = array_merge($arrFormFields[$strField], $GLOBALS['TL_DCA']['tl_formdata']['fields'][$strField]); $arrField = $GLOBALS['TL_DCA']['tl_formdata']['fields'][$strField]; $varValue = $this->Formdata->prepareImportValueForDatabase($arrRow[$intCol], $arrField); // prepare details data $arrDetailSet = array('sorting' => $arrFormFields[$strField]['sorting'], 'tstamp' => $timeNow, 'ff_id' => $arrField['ff_id'], 'ff_name' => $strField, 'value' => $varValue); $arrDetailSets[] = $arrDetailSet; } } $intNewId = 0; $blnSaved = true; if (!empty($arrDetailSets)) { $objNewFormdata = \Database::getInstance()->prepare("INSERT INTO tl_formdata %s")->set($arrSet)->execute(); $intNewId = $objNewFormdata->insertId; $strAlias = $this->Formdata->generateAlias($strAlias, $this->strFormFilterValue, $intNewId); if (strlen($strAlias)) { \Database::getInstance()->prepare("UPDATE tl_formdata %s WHERE id=?")->set(array('alias' => $strAlias))->execute($intNewId); } foreach ($arrDetailSets as $kD => $arrDetailSet) { $arrDetailSet['pid'] = $intNewId; try { $objNewFormdataDetails = \Database::getInstance()->prepare("INSERT INTO tl_formdata_details %s")->set($arrDetailSet)->execute(); } catch (\Exception $ee) { $blnSaved = false; } } if ($blnSaved === false && $intNewId > 0) { \Database::getInstance()->prepare("DELETE FROM tl_formdata WHERE id=?")->execute($intNewId); } } else { $blnSaved = false; } if ($blnSaved) { $intValid++; } else { $intInvalid++; } $intTotal++; } \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_formdata']['import_confirm'], $intValid)); if ($intInvalid > 0) { \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_formdata']['import_invalid'], $intInvalid)); } // Add a log entry $this->log('Imported file "' . $objFile->filename . '" into form data "' . $strFormTitle . '", created ' . $intValid . ' new records', __METHOD__, TL_GENERAL); setcookie('BE_PAGE_OFFSET', 0, 0, '/'); \Controller::reload(); } // Generate preview and form to select import fields if ($strMode == 'preview') { return $this->formImportPreview($objFile, $strSeparator); } } return $this->formImportSource(); }
/** * @param object $objMailProperties Mail properties * @param array $arrSubmitted Submitted data * @param array $arrFiles Array of files * @param array $arrForm Form configuration data * @param array $arrFormFields Form fields * @return object */ public function prepareMailData($objMailProperties, $arrSubmitted, $arrFiles, $arrForm, $arrFormFields) { $sender = $objMailProperties->sender; $senderName = $objMailProperties->senderName; $subject = $objMailProperties->subject; $arrRecipients = $objMailProperties->recipients; $replyTo = $objMailProperties->replyTo; $messageText = $objMailProperties->messageText; $messageHtml = $objMailProperties->messageHtml; $messageHtmlTmpl = $objMailProperties->messageHtmlTmpl; $attachments = $objMailProperties->attachments; $blnSkipEmptyFields = $objMailProperties->skipEmptyFields; if (\Validator::isUuid($messageHtmlTmpl) || is_numeric($messageHtmlTmpl) && $messageHtmlTmpl > 0) { $objFileModel = \FilesModel::findById($messageHtmlTmpl); if ($objFileModel !== null) { $messageHtmlTmpl = $objFileModel->path; } } if ($messageHtmlTmpl != '') { $fileTemplate = new \File($messageHtmlTmpl); if ($fileTemplate->mime == 'text/html') { $messageHtml = $fileTemplate->getContent(); } } // Prepare insert tags to handle separate from 'condition tags' if (!empty($messageText)) { $messageText = preg_replace(array('/\\{\\{/', '/\\}\\}/'), array('__BRCL__', '__BRCR__'), $messageText); } if (!empty($messageHtml)) { $messageHtml = preg_replace(array('/\\{\\{/', '/\\}\\}/'), array('__BRCL__', '__BRCR__'), $messageHtml); } if (!empty($subject)) { $subject = preg_replace(array('/\\{\\{/', '/\\}\\}/'), array('__BRCL__', '__BRCR__'), $subject); } if (!empty($sender)) { $sender = preg_replace(array('/\\{\\{/', '/\\}\\}/'), array('__BRCL__', '__BRCR__'), $sender); } if (!empty($senderName)) { $senderName = preg_replace(array('/\\{\\{/', '/\\}\\}/'), array('__BRCL__', '__BRCR__'), $senderName); } $blnEvalSender = $this->replaceConditionTags($sender); $blnEvalSenderName = $this->replaceConditionTags($senderName); $blnEvalSubject = $this->replaceConditionTags($subject); $blnEvalMessageText = $this->replaceConditionTags($messageText); $blnEvalMessageHtml = $this->replaceConditionTags($messageHtml); // Replace tags in messageText, messageHtml ... $tags = array(); preg_match_all('/__BRCL__.*?__BRCR__/si', $messageText . $messageHtml . $subject . $sender . $senderName, $tags); // Replace tags of type {{form::<form field name>}} // .. {{form::uploadfieldname?attachment=true}} // .. {{form::fieldname?label=Label for this field: }} foreach ($tags[0] as $tag) { $elements = explode('::', preg_replace(array('/^__BRCL__/i', '/__BRCR__$/i'), array('', ''), $tag)); switch (strtolower($elements[0])) { // Formdata field case 'form': $strKey = $elements[1]; list($strKey, $arrTagParams) = explode('?', $strKey); if (!empty($arrTagParams)) { $arrTagParams = $this->parseInsertTagParams($tag); } $arrField = $arrFormFields[$strKey]; $arrField['efgMailSkipEmpty'] = $blnSkipEmptyFields; $strType = $arrField['formfieldType']; if (!isset($arrFormFields[$strKey]) && in_array($strKey, $this->arrBaseFields)) { $arrField = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$strKey]; $strType = $arrField['inputType']; } $strLabel = ''; $strVal = ''; if ($arrTagParams && !empty($arrTagParams['label'])) { $strLabel = $arrTagParams['label']; } if (in_array($strType, $this->arrFFstorable)) { if ($strType == 'efgImageSelect') { $varText = array(); $varHtml = array(); if (TL_MODE == 'BE') { $varVal = $this->prepareDatabaseValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } else { $varVal = $this->preparePostValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } if (is_string($varVal)) { $varVal = array($varVal); } if (!empty($varVal)) { foreach ($varVal as $strVal) { if (strlen($strVal)) { $varText[] = \Environment::get('base') . $strVal; $varHtml[] = '<img src="' . $strVal . '"' . $this->getEmptyTagEnd(); } } } if (empty($varText) && $blnSkipEmptyFields) { $strLabel = ''; } $messageText = str_replace($tag, $strLabel . implode(', ', $varText), $messageText); $messageHtml = str_replace($tag, $strLabel . implode(' ', $varHtml), $messageHtml); } elseif ($strType == 'upload') { $varText = array(); $varHtml = array(); if (TL_MODE == 'BE') { if (strlen($arrSubmitted[$strKey])) { if (!array_key_exists($strKey, $arrFiles)) { $objFile = new \File($arrSubmitted[$strKey]); if ($objFile->size) { $arrFiles[$strKey] = array('tmp_name' => TL_ROOT . '/' . $objFile->path, 'file' => TL_ROOT . '/' . $objFile->path, 'name' => $objFile->basename, 'mime' => $objFile->mime); } } } } // Add file as attachment if ($arrTagParams && $arrTagParams['attachment']) { if (!empty($arrFiles[$strKey]['tmp_name']) && is_file($arrFiles[$strKey]['tmp_name'])) { if (!isset($attachments[$arrFiles[$strKey]['tmp_name']])) { $attachments[$arrFiles[$strKey]['tmp_name']] = array('name' => $arrFiles[$strKey]['name'], 'file' => $arrFiles[$strKey]['tmp_name'], 'mime' => $arrFiles[$strKey]['type']); } } $varVal = array(); } else { if (TL_MODE == 'BE') { $varVal = $this->prepareDatabaseValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } else { $varVal = $this->preparePostValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } } if (is_string($varVal)) { $varVal = array($varVal); } if (!empty($varVal)) { foreach ($varVal as $strVal) { if (strlen($strVal)) { $varText[] = basename($strVal); $varHtml[] = basename($strVal); } } } if (empty($varText) && $blnSkipEmptyFields) { $strLabel = ''; } $subject = str_replace($tag, $strLabel . implode(', ', $varText), $subject); $messageText = str_replace($tag, $strLabel . implode(', ', $varText), $messageText); $messageHtml = str_replace($tag, $strLabel . implode(', ', $varHtml), $messageHtml); } else { if (TL_MODE == 'BE') { $strVal = $this->prepareDatabaseValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } else { $strVal = $this->preparePostValueForMail($arrSubmitted[$strKey], $arrField, $arrFiles[$strKey]); } if (empty($strVal) && $blnSkipEmptyFields) { $strLabel = ''; } $messageText = str_replace($tag, $strLabel . $strVal, $messageText); if (is_string($strVal) && !empty($strVal) && !is_bool(strpos($strVal, "\n"))) { $strVal = $this->formatMultilineValue($strVal); } $messageHtml = str_replace($tag, $strLabel . $strVal, $messageHtml); } } // Replace insert tags in subject if (!empty($subject)) { $subject = str_replace($tag, $strVal, $subject); } // Replace insert tags in sender if (!empty($sender)) { $sender = str_replace($tag, $strVal, $sender); } // Replace insert tags in senderName if (!empty($senderName)) { $senderName = str_replace($tag, $strVal, $senderName); } break; } } // Replace standard insert tags and eval condition tags if (!empty($messageText)) { $messageText = preg_replace(array('/__BRCL__/', '/__BRCR__/'), array('{{', '}}'), $messageText); $messageText = $this->replaceInsertTags($messageText, false); if ($blnEvalMessageText) { $messageText = $this->evalConditionTags($messageText, $arrSubmitted, $arrFiles, $arrForm); } $messageText = strip_tags($messageText); $messageText = html_entity_decode($messageText, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); } if (!empty($messageHtml)) { $messageHtml = preg_replace(array('/__BRCL__/', '/__BRCR__/'), array('{{', '}}'), $messageHtml); $messageHtml = $this->replaceInsertTags($messageHtml, false); if ($blnEvalMessageHtml) { $messageHtml = $this->evalConditionTags($messageHtml, $arrSubmitted, $arrFiles, $arrForm); } } // Replace insert tags in subject if (!empty($subject)) { $subject = preg_replace(array('/__BRCL__/', '/__BRCR__/'), array('{{', '}}'), $subject); $subject = $this->replaceInsertTags($subject, false); if ($blnEvalSubject) { $subject = $this->evalConditionTags($subject, $arrSubmitted, $arrFiles, $arrForm); } } // Replace insert tags in sender if (!empty($sender)) { $sender = preg_replace(array('/__BRCL__/', '/__BRCR__/'), array('{{', '}}'), $sender); $sender = trim($this->replaceInsertTags($sender, false)); if ($blnEvalSender) { $sender = $this->evalConditionTags($sender, $arrSubmitted, $arrFiles, $arrForm); } } // Replace insert tags in senderName if (!empty($senderName)) { $senderName = preg_replace(array('/__BRCL__/', '/__BRCR__/'), array('{{', '}}'), $senderName); $senderName = trim($this->replaceInsertTags($senderName, false)); if ($blnEvalSenderName) { $senderName = $this->evalConditionTags($senderName, $arrSubmitted, $arrFiles, $arrForm); } } // Replace insert tags in replyTo if (!empty($replyTo)) { $replyTo = $this->replaceInsertTags($replyTo, false); } $objMailProperties->sender = $sender; $objMailProperties->senderName = $senderName; $objMailProperties->subject = $subject; $objMailProperties->recipients = $arrRecipients; $objMailProperties->replyTo = $replyTo; $objMailProperties->messageText = $messageText; $objMailProperties->messageHtmlTmpl = $messageHtmlTmpl; $objMailProperties->messageHtml = $messageHtml; $objMailProperties->attachments = $attachments; return $objMailProperties; }
public function getTitle(WatchlistItemModel $objItem) { $objFileModel = \FilesModel::findById($objItem->uuid); if ($objFileModel === null) { return; } $objFile = new \File($objFileModel->path, true); $objContent = \ContentModel::findByPk($objItem->cid); $linkTitle = specialchars($objFile->name); // use generate for download & downloads as well if ($objContent->type == 'download' && $objContent->linkTitle != '') { $linkTitle = $objContent->linkTitle; } $arrMeta = deserialize($objFileModel->meta); // Language support if (($arrLang = $arrMeta[$GLOBALS['TL_LANGUAGE']]) != '') { $linkTitle = $arrLang['title'] ? $arrLang['title'] : $linkTitle; } return $linkTitle; }
/** * Generate module */ protected function compile() { $objParams = $this->Database->prepare("SELECT * FROM tl_module WHERE id=?")->limit(1)->execute($this->id); //delirius_linkliste_categories if ($objParams->delirius_linkliste_categories == '') { return; } $arrCat = deserialize($objParams->delirius_linkliste_categories); $strAnd = implode(',', $arrCat); // random, order, title if ($objParams->delirius_linkliste_fesort == 'random') { $strOrder = ' b.sorting, RAND()'; } elseif ($objParams->delirius_linkliste_fesort == 'order') { $strOrder = ' b.sorting, a.sorting'; } elseif ($objParams->delirius_linkliste_fesort == 'title') { $strOrder = ' b.sorting, a.url_title'; } else { $strOrder = ' b.sorting, a.url'; } if ($objParams->delirius_linkliste_template == '') { $objParams->delirius_linkliste_template = 'linkliste_standard'; } $this->Template = new FrontendTemplate($objParams->delirius_linkliste_template); /* imagesize */ $imgSize = deserialize($this->delirius_linkliste_imagesize); $this->Template->delirius_linkliste_imagesize = $image_size; /* standard image */ if ($objParams->delirius_linkliste_standardfavicon == '') { $this->Template->standardfavicon_path = 'system/modules/delirius_linkliste/html/icon.png'; } else { $objFile = \FilesModel::findById($objParams->delirius_linkliste_standardfavicon); if ($objFile === null) { $this->Template->standardfavicon_path = 'system/modules/delirius_linkliste/html/icon.png'; if (!\Validator::isUuid($objData->image)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } else { $this->Template->standardfavicon_path = $objFile->path; } } // Check for javascript framework if (TL_MODE == 'FE') { /** @type PageModel $objPage */ global $objPage; $this->Template->jquery = false; $this->Template->mootools = false; if ($objPage->getRelated('layout')->addJQuery) { $this->Template->jquery = true; } if ($objPage->getRelated('layout')->addMooTools) { $this->Template->mootools = true; } } $arrLinks = array(); $query = ' SELECT a.*, b.title AS categorietitle, b.description AS categoriedescription, b.image AS categorieimage FROM tl_link_data a, tl_link_category b WHERE a.pid=b.id AND b.id IN (' . $strAnd . ') AND b.published = "1" AND a.published = "1" ORDER BY FIELD(b.id,' . $strAnd . '),' . $strOrder; $objData = $this->Database->execute($query); $query_cc = ' SELECT a.pid, COUNT(a.id) as cc FROM tl_link_data a, tl_link_category b WHERE a.pid=b.id AND b.id IN (' . $strAnd . ') AND b.published = "1" AND a.published = "1" GROUP BY a.pid'; $objCount = Database::getInstance()->prepare($query_cc)->execute(); while ($objCount->next()) { $arrCount[$objCount->pid] = $objCount->cc; } $j = 0; while ($objData->next()) { $j++; $countcat = $arrCount[$objData->pid]; $class = ($j % 2 == 0 ? ' odd' : ' even') . ($j == 1 ? ' first' : ''); if ($j == $countcat) { $class .= ' last'; $j = 0; } /* replace URL {{url::*}} */ if (strstr($objData->url, 'link_url')) { $objData->url = $this->replaceInsertTags($objData->url); } $arrNew = array('class' => $class, 'categorietitle' => trim($objData->categorietitle), 'categoriedescription' => trim($objData->categoriedescription), 'categorieimage' => trim($objData->categorieimage), 'categoriecount' => $countcat, 'url_protocol' => trim($objData->url_protocol), 'url' => trim($objData->url), 'target' => trim($objData->target), 'url_text' => trim($objData->url_text), 'url_title' => trim($objData->url_title), 'description' => trim($objData->description)); if (strlen($arrNew['url_text']) == '') { $arrNew['url_text'] = $arrNew['url']; } if (strlen($objData->image) == 0) { $arrNew['image'] = ''; $arrNew['image_path'] = $this->Template->standardfavicon_path; $this->Template->standardfavicon = \Image::getHtml(\Image::get($this->Template->standardfavicon_path, $imgSize[0], $imgSize[1], $imgSize[2]), $arrNew['url_text'], 'class="favicon-img"'); } else { $objFile = \FilesModel::findById($objData->image); if ($objFile === null) { $arrNew['image'] = ''; $arrNew['image_path'] = $this->Template->standardfavicon_path; if (!\Validator::isUuid($objData->image)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } else { $arrNew['image_path'] = \Image::get($objFile->path, $imgSize[0], $imgSize[1], $imgSize[2]); $arrNew['image'] = \Image::getHtml($arrNew['image_path'], $arrNew['url_text'], 'class="favicon-img"'); } } $arrNew['categorieimage'] = ''; if (strlen($objData->categorieimage) != 0) { $objFile = \FilesModel::findById($objData->categorieimage); $arrNew['categorieimage'] = $objFile->path; } $arrLinks[$objData->categorietitle][] = $arrNew; } $this->Template->linkliste = $arrLinks; $this->Template->favicon = $objParams->delirius_linkliste_favicon; $this->Template->showimage = $objParams->delirius_linkliste_showimage; }
/** * Process submitted form data * Send mail, store data in backend * @param array $arrSubmitted Submitted data * @param array|bool $arrForm Form configuration * @param array|bool $arrFiles Files uploaded * @param array|bool $arrLabels Form field labels * @return void */ public function processSubmittedData($arrSubmitted, $arrForm = false, $arrFiles = false, $arrLabels = false) { // Form config if (!$arrForm) { return; } $arrFormFields = array(); $this->import('FrontendUser', 'Member'); $this->import('Formdata'); $this->strFdDcaKey = 'fd_' . (!empty($arrForm['alias']) ? $arrForm['alias'] : str_replace('-', '_', standardize($arrForm['title']))); $this->Formdata->FdDcaKey = $this->strFdDcaKey; // Get params of related listing formdata $intListingId = intval($_SESSION['EFP']['LISTING_MOD']['id']); if ($intListingId > 0) { $objListing = \Database::getInstance()->prepare("SELECT * FROM tl_module WHERE id=?")->execute($intListingId); if ($objListing->numRows) { $arrListing = $objListing->fetchAssoc(); // Mail delivery defined in frontend listing module $arrForm['sendConfirmationMailOnFrontendEditing'] = $arrListing['efg_fe_no_confirmation_mail'] ? false : true; $arrForm['sendFormattedMailOnFrontendEditing'] = $arrListing['efg_fe_no_formatted_mail'] ? false : true; } } if (!empty($arrListing['efg_DetailsKey'])) { $this->strFormdataDetailsKey = $arrListing['efg_DetailsKey']; } $blnFEedit = false; $intOldId = 0; $strRedirectTo = ''; $strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request')); $strUrlParams = ''; $blnQuery = false; foreach (preg_split('/&(amp;)?/', $_SERVER['QUERY_STRING']) as $fragment) { if (strlen($fragment)) { if (strncasecmp($fragment, $this->strFormdataDetailsKey, strlen($this->strFormdataDetailsKey)) !== 0 && strncasecmp($fragment, 'act', 3) !== 0) { $strUrlParams .= (!$blnQuery ? '' : '&') . $fragment; $blnQuery = true; } } } if (in_array($arrListing['efg_fe_edit_access'], array('public', 'groupmembers', 'member'))) { if (\Input::get('act') == 'edit') { $blnFEedit = true; $objCheck = \Database::getInstance()->prepare("SELECT id FROM tl_formdata WHERE id=? OR alias=?")->execute(\Input::get($this->strFormdataDetailsKey), \Input::get($this->strFormdataDetailsKey)); if ($objCheck->numRows == 1) { $intOldId = intval($objCheck->id); } else { $this->log('Could not identify record by ID "' . \Input::get($this->strFormdataDetailsKey) . '"', __METHOD__, TL_GENERAL); } } } // Types of form fields with storable data $arrFFstorable = $this->Formdata->arrFFstorable; if (($arrForm['storeFormdata'] || $arrForm['sendConfirmationMail'] || $arrForm['sendFormattedMail']) && !empty($arrSubmitted)) { $timeNow = time(); $this->loadDataContainer($this->strFdDcaKey); $this->loadDataContainer('tl_formdata_details'); $this->loadDataContainer('tl_files'); $arrFormFields = $this->Formdata->getFormfieldsAsArray($arrForm['id']); $arrBaseFields = array(); $arrDetailFields = array(); if (!empty($GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['baseFields'])) { $arrBaseFields = $GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['baseFields']; } if (!empty($GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['detailFields'])) { $arrDetailFields = $GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['detailFields']; } $arrHookFields = array_merge($arrBaseFields, $arrDetailFields); $arrToSave = array(); foreach ($arrSubmitted as $k => $varVal) { if (in_array($k, array('id'))) { continue; } elseif (in_array($k, $arrHookFields) || in_array($k, array_keys($arrFormFields)) || in_array($k, array('FORM_SUBMIT', 'MAX_FILE_SIZE'))) { $arrToSave[$k] = $varVal; } } // HOOK: process efg form data callback if (array_key_exists('processEfgFormData', $GLOBALS['TL_HOOKS']) && is_array($GLOBALS['TL_HOOKS']['processEfgFormData'])) { foreach ($GLOBALS['TL_HOOKS']['processEfgFormData'] as $key => $callback) { $this->import($callback[0]); $arrResult = $this->{$callback}[0]->{$callback}[1]($arrToSave, $arrFiles, $intOldId, $arrForm, $arrLabels); if (!empty($arrResult)) { $arrSubmitted = $arrResult; $arrToSave = $arrSubmitted; } } } } // Formdata storage if ($arrForm['storeFormdata'] && !empty($arrSubmitted)) { $blnStoreOptionsValue = $arrForm['efgStoreValues'] ? true : false; // Get old record on frontend editing if ($intOldId > 0) { $arrOldData = $this->Formdata->getFormdataAsArray($intOldId); $arrOldFormdata = $arrOldData['fd_base']; $arrOldFormdataDetails = $arrOldData['fd_details']; } // Prepare record tl_formdata $arrSet = array('form' => $arrForm['title'], 'tstamp' => $timeNow, 'date' => $timeNow, 'ip' => \System::anonymizeIp(\Environment::get('ip')), 'published' => $GLOBALS['TL_DCA']['tl_formdata']['fields']['published']['default'] ? '1' : '', 'fd_member' => intval($this->Member->id), 'fd_member_group' => intval($this->Member->groups[0]), 'fd_user' => intval($this->User->id), 'fd_user_group' => intval($this->User->groups[0])); // Keep some values from existing record on frontend editing if ($intOldId > 0) { $arrSet['form'] = $arrOldFormdata['form']; $arrSet['be_notes'] = $arrOldFormdata['be_notes']; $arrSet['fd_member'] = $arrOldFormdata['fd_member']; $arrSet['fd_member_group'] = $arrOldFormdata['fd_member_group']; if (intval($this->Member->id) > 0) { $arrSet['fd_member'] = intval($this->Member->id); if (count($this->Member->groups) == 1 && intval($this->Member->groups[0]) > 0) { $arrSet['fd_member_group'] = intval($this->Member->groups[0]); } } else { $arrSet['fd_member'] = 0; } $arrSet['fd_user'] = $arrOldFormdata['fd_user']; $arrSet['fd_user_group'] = $arrOldFormdata['fd_user_group']; // Set published to value of old record, if no default value is defined if (!isset($GLOBALS['TL_DCA']['tl_formdata']['fields']['published']['default'])) { $arrSet['published'] = $arrOldFormdata['published']; } } // Store formdata: Update or insert and delete if ($blnFEedit && strlen($arrListing['efg_fe_keep_id'])) { $intNewId = $intOldId; \Database::getInstance()->prepare("UPDATE tl_formdata %s WHERE id=?")->set($arrSet)->execute($intOldId); \Database::getInstance()->prepare("DELETE FROM tl_formdata_details WHERE pid=?")->execute($intOldId); } else { $objNewFormdata = \Database::getInstance()->prepare("INSERT INTO tl_formdata %s")->set($arrSet)->execute(); $intNewId = $objNewFormdata->insertId; // Update related comments if (in_array('comments', \ModuleLoader::getActive())) { \Database::getInstance()->prepare("UPDATE tl_comments %s WHERE `source` = 'tl_formdata' AND parent=?")->set(array('parent' => $intNewId))->execute($intOldId); } } // Store details data foreach ($arrFormFields as $k => $arrField) { $strType = $arrField['formfieldType']; $strVal = ''; if (in_array($strType, $arrFFstorable)) { if ($blnStoreOptionsValue) { $arrField['eval']['efgStoreValues'] = true; } else { $arrField['eval']['efgStoreValues'] = false; } // Set rgxp 'date' for field type 'calendar' if not set if ($strType == 'calendar') { if (!isset($arrField['rgxp'])) { $arrField['rgxp'] = 'date'; } } elseif ($strType == 'xdependentcalendarfields') { $arrField['rgxp'] = 'date'; $arrField['dateFormat'] = $arrField['xdateformat']; } $strVal = $this->Formdata->preparePostValueForDatabase($arrSubmitted[$k], $arrField, $arrFiles[$k]); // Special treatment for type upload // Keep old file on frontend editing, if no new file has been uploaded if ($strType == 'upload') { if ($intOldId) { if (!$arrFiles[$k]['name']) { if (strlen($arrOldFormdataDetails[$k]['value'])) { $strVal = $arrOldFormdataDetails[$k]['value']; } } } } if (isset($arrSubmitted[$k]) || $strType == 'upload' && strlen($strVal)) { // Prepare data $arrFieldSet = array('pid' => $intNewId, 'sorting' => $arrField['sorting'], 'tstamp' => $timeNow, 'ff_id' => $arrField['id'], 'ff_name' => $arrField['name'], 'value' => $strVal); $objNewFormdataDetails = \Database::getInstance()->prepare("INSERT INTO tl_formdata_details %s")->set($arrFieldSet)->execute(); } } } // Delete old record after frontend editing if ($blnFEedit) { if (!isset($arrListing['efg_fe_keep_id']) || $arrListing['efg_fe_keep_id'] != "1") { if ($intNewId > 0 && intval($intOldId) > 0 && intval($intNewId) != intval($intOldId)) { \Database::getInstance()->prepare("DELETE FROM tl_formdata_details WHERE pid=?")->execute($intOldId); \Database::getInstance()->prepare("DELETE FROM tl_formdata WHERE id=?")->execute($intOldId); } } $strRedirectTo = preg_replace('/\\?.*$/', '', \Environment::get('request')); } // Auto-generate alias $strAlias = $this->Formdata->generateAlias($arrOldFormdata['alias'], $arrForm['title'], $intNewId); if (strlen($strAlias)) { $arrUpd = array('alias' => $strAlias); \Database::getInstance()->prepare("UPDATE tl_formdata %s WHERE id=?")->set($arrUpd)->execute($intNewId); } } // Store data in the session to display on confirmation page unset($_SESSION['EFP']['FORMDATA']); $blnSkipEmptyFields = $arrForm['confirmationMailSkipEmpty'] ? true : false; foreach ($arrFormFields as $k => $arrField) { $strType = $arrField['formfieldType']; $strVal = ''; if (in_array($strType, $arrFFstorable)) { $strVal = $this->Formdata->preparePostValueForMail($arrSubmitted[$k], $arrField, $arrFiles[$k], $blnSkipEmptyFields); } $_SESSION['EFP']['FORMDATA'][$k] = $strVal; } $_SESSION['EFP']['FORMDATA']['_formId_'] = $arrForm['id']; // Confirmation Mail if ($blnFEedit && !$arrForm['sendConfirmationMailOnFrontendEditing']) { $arrForm['sendConfirmationMail'] = false; } if ($arrForm['sendConfirmationMail']) { $objMailProperties = new \stdClass(); $objMailProperties->subject = ''; $objMailProperties->sender = ''; $objMailProperties->senderName = ''; $objMailProperties->replyTo = ''; $objMailProperties->recipients = array(); $objMailProperties->messageText = ''; $objMailProperties->messageHtmlTmpl = ''; $objMailProperties->messageHtml = ''; $objMailProperties->attachments = array(); $objMailProperties->skipEmptyFields = false; $objMailProperties->skipEmptyFields = $arrForm['confirmationMailSkipEmpty'] ? true : false; // Set the sender as given in form configuration list($senderName, $sender) = \String::splitFriendlyEmail($arrForm['confirmationMailSender']); $objMailProperties->sender = $sender; $objMailProperties->senderName = $senderName; // Set the 'reply to' address, if given in form configuration if (!empty($arrForm['confirmationMailReplyto'])) { list($replyToName, $replyTo) = \String::splitFriendlyEmail($arrForm['confirmationMailReplyto']); $objMailProperties->replyTo = strlen($replyToName) ? $replyToName . ' <' . $replyTo . '>' : $replyTo; } // Set recipient(s) $recipientFieldName = $arrForm['confirmationMailRecipientField']; $varRecipient = $arrSubmitted[$recipientFieldName]; if (is_array($varRecipient)) { $arrRecipient = $varRecipient; } else { $arrRecipient = trimsplit(',', $varRecipient); } if (!empty($arrForm['confirmationMailRecipient'])) { $varRecipient = $arrForm['confirmationMailRecipient']; $arrRecipient = array_merge($arrRecipient, trimsplit(',', $varRecipient)); } $arrRecipient = array_filter(array_unique($arrRecipient)); if (!empty($arrRecipient)) { foreach ($arrRecipient as $kR => $recipient) { list($recipientName, $recipient) = \String::splitFriendlyEmail($this->replaceInsertTags($recipient, false)); $arrRecipient[$kR] = strlen($recipientName) ? $recipientName . ' <' . $recipient . '>' : $recipient; } } $objMailProperties->recipients = $arrRecipient; // Check if we want custom attachments... (Thanks to Torben Schwellnus) if ($arrForm['addConfirmationMailAttachments']) { if ($arrForm['confirmationMailAttachments']) { $arrCustomAttachments = deserialize($arrForm['confirmationMailAttachments'], true); if (!empty($arrCustomAttachments)) { foreach ($arrCustomAttachments as $varFile) { $objFileModel = \FilesModel::findById($varFile); if ($objFileModel !== null) { $objFile = new \File($objFileModel->path); if ($objFile->size) { $objMailProperties->attachments[TL_ROOT . '/' . $objFile->path] = array('file' => TL_ROOT . '/' . $objFile->path, 'name' => $objFile->basename, 'mime' => $objFile->mime); } } } } } } $objMailProperties->subject = \String::decodeEntities($arrForm['confirmationMailSubject']); $objMailProperties->messageText = \String::decodeEntities($arrForm['confirmationMailText']); $objMailProperties->messageHtmlTmpl = $arrForm['confirmationMailTemplate']; // Replace Insert tags and conditional tags $objMailProperties = $this->Formdata->prepareMailData($objMailProperties, $arrSubmitted, $arrFiles, $arrForm, $arrFormFields); // Send Mail $blnConfirmationSent = false; if (!empty($objMailProperties->recipients)) { $objMail = new \Email(); $objMail->from = $objMailProperties->sender; if (!empty($objMailProperties->senderName)) { $objMail->fromName = $objMailProperties->senderName; } if (!empty($objMailProperties->replyTo)) { $objMail->replyTo($objMailProperties->replyTo); } $objMail->subject = $objMailProperties->subject; if (!empty($objMailProperties->attachments)) { foreach ($objMailProperties->attachments as $strFile => $varParams) { $strContent = file_get_contents($varParams['file'], false); $objMail->attachFileFromString($strContent, $varParams['name'], $varParams['mime']); } } if (!empty($objMailProperties->messageText)) { $objMail->text = $objMailProperties->messageText; } if (!empty($objMailProperties->messageHtml)) { $objMail->html = $objMailProperties->messageHtml; } foreach ($objMailProperties->recipients as $recipient) { $objMail->sendTo($recipient); $blnConfirmationSent = true; } } if ($blnConfirmationSent && isset($intNewId) && intval($intNewId) > 0) { $arrUpd = array('confirmationSent' => '1', 'confirmationDate' => $timeNow); $res = \Database::getInstance()->prepare("UPDATE tl_formdata %s WHERE id=?")->set($arrUpd)->execute($intNewId); } } // Information (formatted) Mail if ($blnFEedit && !$arrForm['sendFormattedMailOnFrontendEditing']) { $arrForm['sendFormattedMail'] = false; } if ($arrForm['sendFormattedMail']) { $objMailProperties = new \stdClass(); $objMailProperties->subject = ''; $objMailProperties->sender = ''; $objMailProperties->senderName = ''; $objMailProperties->replyTo = ''; $objMailProperties->recipients = array(); $objMailProperties->messageText = ''; $objMailProperties->messageHtmlTmpl = ''; $objMailProperties->messageHtml = ''; $objMailProperties->attachments = array(); $objMailProperties->skipEmptyFields = false; $objMailProperties->skipEmptyFields = $arrForm['formattedMailSkipEmpty'] ? true : false; // Set the admin e-mail as "from" address $objMailProperties->sender = $GLOBALS['TL_ADMIN_EMAIL']; $objMailProperties->senderName = $GLOBALS['TL_ADMIN_NAME']; // Get 'reply to' address, if form contains field named 'email' if (isset($arrSubmitted['email']) && !empty($arrSubmitted['email']) && !is_bool(strpos($arrSubmitted['email'], '@'))) { $replyTo = $arrSubmitted['email']; // add name if (isset($arrSubmitted['name']) && !empty($arrSubmitted['name'])) { $replyTo = '"' . $arrSubmitted['name'] . '" <' . $arrSubmitted['email'] . '>'; } $objMailProperties->replyTo = $replyTo; } // Set recipient(s) $varRecipient = $arrForm['formattedMailRecipient']; if (is_array($varRecipient)) { $arrRecipient = $varRecipient; } else { $arrRecipient = trimsplit(',', $varRecipient); } $arrRecipient = array_filter(array_unique($arrRecipient)); if (!empty($arrRecipient)) { foreach ($arrRecipient as $kR => $recipient) { list($recipientName, $recipient) = \String::splitFriendlyEmail($this->replaceInsertTags($recipient, false)); $arrRecipient[$kR] = strlen($recipientName) ? $recipientName . ' <' . $recipient . '>' : $recipient; } } $objMailProperties->recipients = $arrRecipient; // Check if we want custom attachments... (Thanks to Torben Schwellnus) if ($arrForm['addFormattedMailAttachments']) { if ($arrForm['formattedMailAttachments']) { $arrCustomAttachments = deserialize($arrForm['formattedMailAttachments'], true); if (is_array($arrCustomAttachments)) { foreach ($arrCustomAttachments as $varFile) { $objFileModel = \FilesModel::findById($varFile); if ($objFileModel !== null) { $objFile = new \File($objFileModel->path); if ($objFile->size) { $objMailProperties->attachments[TL_ROOT . '/' . $objFile->path] = array('file' => TL_ROOT . '/' . $objFile->path, 'name' => $objFile->basename, 'mime' => $objFile->mime); } } } } } } $objMailProperties->subject = \String::decodeEntities($arrForm['formattedMailSubject']); $objMailProperties->messageText = \String::decodeEntities($arrForm['formattedMailText']); $objMailProperties->messageHtmlTmpl = $arrForm['formattedMailTemplate']; // Replace Insert tags and conditional tags $objMailProperties = $this->Formdata->prepareMailData($objMailProperties, $arrSubmitted, $arrFiles, $arrForm, $arrFormFields); // Send Mail $blnInformationSent = false; if (!empty($objMailProperties->recipients)) { $objMail = new \Email(); $objMail->from = $objMailProperties->sender; if (!empty($objMailProperties->senderName)) { $objMail->fromName = $objMailProperties->senderName; } if (!empty($objMailProperties->replyTo)) { $objMail->replyTo($objMailProperties->replyTo); } $objMail->subject = $objMailProperties->subject; if (!empty($objMailProperties->attachments)) { foreach ($objMailProperties->attachments as $strFile => $varParams) { $strContent = file_get_contents($varParams['file'], false); $objMail->attachFileFromString($strContent, $varParams['name'], $varParams['mime']); } } if (!empty($objMailProperties->messageText)) { $objMail->text = $objMailProperties->messageText; } if (!empty($objMailProperties->messageHtml)) { $objMail->html = $objMailProperties->messageHtml; } foreach ($objMailProperties->recipients as $recipient) { $objMail->sendTo($recipient); $blnInformationSent = true; } } } // Redirect after frontend editing if ($blnFEedit) { if (!empty($strRedirectTo)) { $strRed = preg_replace(array('/\\/' . $this->strFormdataDetailsKey . '\\/' . \Input::get($this->strFormdataDetailsKey) . '/i', '/' . $this->strFormdataDetailsKey . '=' . \Input::get($this->strFormdataDetailsKey) . '/i', '/act=edit/i'), array('', '', ''), $strUrl) . (!empty($strUrlParams) ? '?' . $strUrlParams : ''); \Controller::redirect($strRed); } } }
/** * Returns the information-array about an album * * @param null $intPictureId * @param $objThis * @return array|null */ public static function getPictureInformationArray($intPictureId = null, $objThis) { if ($intPictureId < 1) { return; } global $objPage; $defaultThumbSRC = $objThis->defaultThumb; if (\Config::get('gc_error404_thumb') !== '') { $objFile = \FilesModel::findByUuid(\Config::get('gc_error404_thumb')); if ($objFile !== null) { if (\Validator::isUuid(\Config::get('gc_error404_thumb'))) { if (is_file(TL_ROOT . '/' . $objFile->path)) { $defaultThumbSRC = $objFile->path; } } } } // Get the page model $objPageModel = \PageModel::findByPk($objPage->id); $objPicture = \Database::getInstance()->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE id=?')->execute($intPictureId); //Alle Informationen zum Album in ein array packen $objAlbum = \Database::getInstance()->prepare('SELECT * FROM tl_gallery_creator_albums WHERE id=?')->execute($objPicture->pid); $arrAlbumInfo = $objAlbum->fetchAssoc(); //Bild-Besitzer $objOwner = \Database::getInstance()->prepare('SELECT name FROM tl_user WHERE id=?')->execute($objPicture->owner); $strImageSrc = ''; $arrMeta = array(); $objFileModel = \FilesModel::findByUuid($objPicture->uuid); if ($objFileModel == null) { $strImageSrc = $defaultThumbSRC; } else { $strImageSrc = $objFileModel->path; if (!is_file(TL_ROOT . '/' . $strImageSrc)) { // Fallback to the default thumb $strImageSrc = $defaultThumbSRC; } //meta $arrMeta = $objThis->getMetaData($objFileModel->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars($objFileModel->name); } } // get thumb dimensions $arrSize = unserialize($objThis->gc_size_detailview); //Generate the thumbnails and the picture element try { $thumbSrc = \Image::create($strImageSrc, $arrSize)->executeResize()->getResizedPath(); $picture = \Picture::create($strImageSrc, $arrSize)->getTemplateData(); if ($thumbSrc !== $strImageSrc) { $objFile = new \File(rawurldecode($thumbSrc), true); } } catch (\Exception $e) { \System::log('Image "' . $strImageSrc . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR); $thumbSrc = ''; $picture = array('img' => array('src' => '', 'srcset' => ''), 'sources' => array()); } $picture['alt'] = $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']); $picture['title'] = $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']); $objFileThumb = new \File(rawurldecode($thumbSrc)); $arrSize[0] = $objFileThumb->width; $arrSize[1] = $objFileThumb->height; $arrFile["thumb_width"] = $objFileThumb->width; $arrFile["thumb_height"] = $objFileThumb->height; // get some image params if (is_file(TL_ROOT . '/' . $strImageSrc)) { $objFileImage = new \File($strImageSrc); if (!$objFileImage->isGdImage) { return null; } $arrFile["path"] = $objFileImage->path; $arrFile["basename"] = $objFileImage->basename; // filename without extension $arrFile["filename"] = $objFileImage->filename; $arrFile["extension"] = $objFileImage->extension; $arrFile["dirname"] = $objFileImage->dirname; $arrFile["image_width"] = $objFileImage->width; $arrFile["image_height"] = $objFileImage->height; } else { return null; } //check if there is a custom thumbnail selected if ($objPicture->addCustomThumb && !empty($objPicture->customThumb)) { $customThumbModel = \FilesModel::findByUuid($objPicture->customThumb); if ($customThumbModel !== null) { if (is_file(TL_ROOT . '/' . $customThumbModel->path)) { $objFileCustomThumb = new \File($customThumbModel->path, true); if ($objFileCustomThumb->isGdImage) { $arrSize = unserialize($objThis->gc_size_detailview); $thumbSrc = \Image::get($objFileCustomThumb->path, $arrSize[0], $arrSize[1], $arrSize[2]); $objFileCustomThumb = new \File(rawurldecode($thumbSrc)); $arrSize[0] = $objFileCustomThumb->width; $arrSize[1] = $objFileCustomThumb->height; $arrFile["thumb_width"] = $objFileCustomThumb->width; $arrFile["thumb_height"] = $objFileCustomThumb->height; } } } } //exif if ($GLOBALS['TL_CONFIG']['gc_read_exif']) { try { $exif = is_callable('exif_read_data') && TL_MODE == 'FE' ? exif_read_data($strImageSrc) : array('info' => "The function 'exif_read_data()' is not available on this server."); } catch (Exception $e) { $exif = array('info' => "The function 'exif_read_data()' is not available on this server."); } } else { $exif = array('info' => "The function 'exif_read_data()' has not been activated in the Contao backend settings."); } //video-integration $strMediaSrc = trim($objPicture->socialMediaSRC) != "" ? trim($objPicture->socialMediaSRC) : ""; if (\Validator::isUuid($objPicture->localMediaSRC)) { //get path of a local Media $objMovieFile = \FilesModel::findById($objPicture->localMediaSRC); $strMediaSrc = $objMovieFile !== null ? $objMovieFile->path : $strMediaSrc; } $href = null; if (TL_MODE == 'FE' && $objThis->gc_fullsize) { $href = $strMediaSrc != "" ? $strMediaSrc : \System::urlEncode($strImageSrc); } //cssID $cssID = deserialize($objPicture->cssID, true); // build the array $arrPicture = array('id' => $objPicture->id, 'pid' => $objPicture->pid, 'date' => $objPicture->date, 'owner' => $objPicture->owner, 'owners_name' => $objOwner->name, 'album_id' => $objPicture->pid, 'name' => specialchars($arrFile["basename"]), 'filename' => $arrFile["filename"], 'uuid' => $objPicture->uuid, 'path' => $arrFile["path"], 'basename' => $arrFile["basename"], 'dirname' => $arrFile["dirname"], 'extension' => $arrFile["extension"], 'alt' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'title' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'comment' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'caption' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'href' => TL_FILES_URL . $href, 'single_image_url' => $objPageModel->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . \Input::get('items') . '/img/' . $arrFile["filename"], $objPage->language), 'image_src' => $arrFile["path"], 'media_src' => $strMediaSrc, 'socialMediaSRC' => $objPicture->socialMediaSRC, 'localMediaSRC' => $objPicture->localMediaSRC, 'addCustomThumb' => $objPicture->addCustomThumb, 'thumb_src' => isset($thumbSrc) ? TL_FILES_URL . $thumbSrc : '', 'size' => $arrSize, 'thumb_width' => $arrFile["thumb_width"], 'thumb_height' => $arrFile["thumb_height"], 'image_width' => $arrFile["image_width"], 'image_height' => $arrFile["image_height"], 'lightbox' => $objPage->outputFormat == 'xhtml' ? 'rel="lightbox[lb' . $objPicture->pid . ']"' : 'data-lightbox="lb' . $objPicture->pid . '"', 'tstamp' => $objPicture->tstamp, 'sorting' => $objPicture->sorting, 'published' => $objPicture->published, 'exif' => $exif, 'albuminfo' => $arrAlbumInfo, 'metaData' => $arrMeta, 'cssID' => $cssID[0] != '' ? $cssID[0] : '', 'cssClass' => $cssID[1] != '' ? $cssID[1] : '', 'externalFile' => $objPicture->externalFile, 'picture' => $picture); //Fuegt dem Array weitere Eintraege hinzu, falls tl_gallery_creator_pictures erweitert wurde $objPicture = \Database::getInstance()->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE id=?')->execute($intPictureId); foreach ($objPicture->fetchAssoc() as $key => $value) { if (!array_key_exists($key, $arrPicture)) { $arrPicture[$key] = $value; } } return $arrPicture; }
/** * @param bool $import True for import, false for export * @param array $data Data of element or parent list item * @param array $config Fields configuration * @param array $idMappingData ID mapping for imported database rows * @param string $fieldPrefix * @return array Converted $data */ protected function convertDataForImportExportParseFields($import, $data, $config, $idMappingData, $fieldPrefix = 'rsce_field_') { foreach ($data as $fieldName => $value) { $fieldConfig = $this->getNestedConfig($fieldPrefix . $fieldName, $config); if (empty($fieldConfig['inputType'])) { continue; } if ($fieldConfig['inputType'] === 'list') { for ($dataKey = 0; isset($value[$dataKey]); $dataKey++) { $data[$fieldName][$dataKey] = $this->convertDataForImportExportParseFields($import, $value[$dataKey], $config, $idMappingData, $fieldPrefix . $fieldName . '__' . $dataKey . '__'); } } else { if ($value && ($fieldConfig['inputType'] === 'fileTree' || $fieldConfig['inputType'] === 'fineUploader')) { if (empty($fieldConfig['eval']['multiple'])) { if ($import) { $file = \FilesModel::findByPath(\Config::get('uploadPath') . '/' . preg_replace('(^files/)', '', $value)); if ($file) { $data[$fieldName] = \String::binToUuid($file->uuid); } } else { $file = \FilesModel::findById($value); if ($file) { $data[$fieldName] = 'files/' . preg_replace('(^' . preg_quote(\Config::get('uploadPath')) . '/)', '', $file->path); } } } else { $data[$fieldName] = serialize(array_map(function ($value) use($import) { if ($import) { $file = \FilesModel::findByPath(\Config::get('uploadPath') . '/' . preg_replace('(^files/)', '', $value)); if ($file) { return \String::binToUuid($file->uuid); } } else { $file = \FilesModel::findById($value); if ($file) { return 'files/' . preg_replace('(^' . preg_quote(\Config::get('uploadPath')) . '/)', '', $file->path); } } return $value; }, deserialize($value, true))); } } else { if ($fieldConfig['inputType'] === 'imageSize' && $value && $import) { $value = deserialize($value, true); if (!empty($value[2]) && is_numeric($value[2]) && !empty($idMappingData['tl_image_size'][$value[2]])) { $value[2] = $idMappingData['tl_image_size'][$value[2]]; $data[$fieldName] = serialize($value); } } } } } return $data; }
public function listLinks($arrRow) { if (\Input::get('key') == 'checklink' && \Input::get('id') != '') { $objData = $this->Database->prepare("SELECT url,id FROM tl_link_data WHERE pid = ?")->execute(\Input::get('id')); while ($objData->next()) { $this->checkLink($objData->id, $objData->url); } $this->redirect($this->getReferer()); } if ($arrRow['image']) { $objFile = \FilesModel::findById($arrRow['image']); if ($objFile !== null) { $preview = $objFile->path; $image = '<img src="' . $this->getImage($preview, 65, 45, 'center_center') . '" alt="' . htmlspecialchars($label) . '" style="display: inline-block;vertical-align: top;*display:inline;zoom:1;padding-right:8px;" />'; } } $query = ' SELECT * FROM tl_link_data WHERE id = ? '; $objData = $this->Database->prepare($query)->execute($arrRow['id']); if ($objData->be_warning > 0) { $warning = ' <span class="linkliste_orange" title="Warning"> ' . $objData->be_text . ' </span>'; } if ($objData->be_error > 0) { $error = ' <span class="linkliste_red" title="Error"> ' . $objData->be_text . ' </span>'; } if (strstr($arrRow['url'], 'link_url')) { $arrRow['url'] = $this->replaceInsertTags($arrRow['url']); } $line = ''; $line .= '<div>'; $line .= $image; $line .= '<a href="' . $arrRow['url'] . '" title="' . $arrRow['url'] . '"' . LINK_NEW_WINDOW . '>' . ($arrRow['url_text'] != '' ? $arrRow['url_text'] : $arrRow['url']) . '</a>' . $warning . $error; $line .= "</div>"; $line .= "<div>"; $line .= $arrRow['description']; $line .= "</div>"; $line .= "\n"; return $line; }
/** * Generate module */ protected function compile() { $objParams = \Database::getInstance()->prepare("SELECT * FROM tl_module WHERE id=?")->limit(1)->execute($this->id); // template if ($objParams->delirius_slogan_template === '') { $objParams->delirius_slogan_template = 'slogan_list_tableless'; } $this->Template = new FrontendTemplate($objParams->delirius_slogan_template); // load css if ($objParams->delirius_slogan_css !== '') { $this->Template->css = $objParams->delirius_slogan_css; } $imageSize = deserialize($objParams->delirius_slogan_imagesize); if ($objParams->delirius_slogan_fields != '') { $arrFields = deserialize($objParams->delirius_slogan_fields); } if ($objParams->delirius_slogan_number > 0) { $strLimit = ' LIMIT ' . $objParams->delirius_slogan_number; } else { $strLimit = ''; } if ($objParams->delirius_slogan_order === 'random') { $strOrder = ' RAND()'; } else { $strOrder = ' b.sorting,a.sorting'; } if ($objParams->delirius_slogan_category != '') { $arrCat = deserialize($objParams->delirius_slogan_category); $strAnd = ' AND b.id IN (' . implode(',', $arrCat) . ') '; } $arrSlogan = array(); $query = ' SELECT ' . implode(',', $arrFields) . ' FROM tl_slogan_data a, tl_slogan_category b WHERE a.pid=b.id ' . $strAnd . ' AND a.published = ? ORDER BY ' . $strOrder . $strLimit; $objData = \Database::getInstance()->prepare($query)->execute(1); while ($objData->next()) { $imageSrc = ''; if ($objData->image) { $objFile = \FilesModel::findById($objData->image); if ($imageSize) { $imageSrc = $this->getImage($objFile->path, $imageSize[0], $imageSize[1], $imageSize[2]); $imagesize = ' width="' . $imageSize[0] . '" height="' . $imageSize[1] . '"'; } else { $imageSrc = $objFile->path; $imagesize = ''; } } $arrNew = array('id' => trim($objData->id), 'categorytitle' => trim($objData->categorytitle), 'title' => trim($objData->title), 'teaser' => trim($objData->teaser), 'slogan' => trim($objData->slogan), 'image' => $imageSrc, 'imageSize' => $imagesize, 'author' => trim($objData->author)); $arrSlogan[] = $arrNew; } $this->Template->slogan = $arrSlogan; }
/** * Generate the widget and return it as string * * @return string */ public function generate() { $arrSet = array(); $arrValues = array(); $blnHasOrder = $this->strOrderField != '' && is_array($this->{$this->strOrderField}); $arrImage = deserialize($GLOBALS['TL_CONFIG']['avatar_maxdims']); if (!empty($this->varValue)) { $objFiles = \FilesModel::findMultipleByUuids((array) $this->varValue); $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); if ($objFiles !== null) { while ($objFiles->next()) { // File system and database seem not in sync if (!file_exists(TL_ROOT . '/' . $objFiles->path)) { continue; } $arrSet[] = $objFiles->uuid; if ($objFiles->type == 'folder') { continue; } $objFile = new \File($objFiles->path, true); $strInfo = $objFiles->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>'; $arrValues[$objFiles->uuid] = \Image::getHtml(\Image::get($objFiles->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"'); } } } if (count($arrValues) === 0) { $objFile = \FilesModel::findById($GLOBALS['TL_CONFIG']['avatar_fallback_image']); $strInfo = $objFile->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>'; $arrValues[$objFile->uuid] = \Image::getHtml(\Image::get($objFile->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"'); } // Load the fonts for the drag hint (see #4838) $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true; // Convert the binary UUIDs $strSet = implode(',', array_map('String::binToUuid', $arrSet)); $strOrder = $blnHasOrder ? implode(',', array_map('String::binToUuid', $this->{$this->strOrderField})) : ''; $return = '<input type="hidden" name="' . $this->strName . '" id="ctrl_' . $this->strId . '" value="' . $strSet . '">' . ($blnHasOrder ? ' <input type="hidden" name="' . $this->strOrderName . '" id="ctrl_' . $this->strOrderId . '" value="' . $strOrder . '">' : '') . ' <div class="selector_container">' . ($blnHasOrder && count($arrValues) ? ' <p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . ' <ul id="sort_' . $this->strId . '" class="' . trim(($blnHasOrder ? 'sortable ' : '') . ($this->blnIsGallery ? 'sgallery' : '')) . '">'; foreach ($arrValues as $k => $v) { $return .= $k ? '<li data-id="' . \String::binToUuid($k) . '">' . $v . '</li>' : ''; } $return .= '</ul> <p><a href="contao/file.php?do=' . \Input::get('do') . '&table=' . $this->strTable . '&field=' . $this->strField . '&act=show&id=' . \Input::get('id') . '&value=' . $strSet . '&rt=' . REQUEST_TOKEN . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\'' . specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['filepicker'])) . '\',\'url\':this.href,\'id\':\'' . $this->strId . '\'});return false">' . $GLOBALS['TL_LANG']['MSC']['changeSelection'] . '</a></p>' . ($blnHasOrder ? ' <script>Backend.makeMultiSrcSortable("sort_' . $this->strId . '", "ctrl_' . $this->strOrderId . '")</script>' : '') . ' </div>'; if (!\Environment::get('isAjaxRequest')) { $return = '<div>' . $return . '</div>'; } return $return; }