本文整理汇总了PHP中FilesModel::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesModel::findById方法的具体用法?PHP FilesModel::findById怎么用?PHP FilesModel::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilesModel
的用法示例。
在下文中一共展示了FilesModel::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* 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;
}
示例2: run
/**
* 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;
}
示例3: getTitle
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;
}
示例4: listJsFiles
/**
* 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";
}
示例5: getRowLabel
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}}');
}
示例6: getRowLabel
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}}');
}
示例7: getRowLabel
/**
* 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}}');
}
示例8: importFile
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';
//.........这里部分代码省略.........
示例9: prepareMailData
/**
* @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();
}
}
//.........这里部分代码省略.........
示例10: getTitle
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;
}
示例11: compile
/**
* 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) {
//.........这里部分代码省略.........
示例12: processSubmittedData
//.........这里部分代码省略.........
$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']);
}
示例13: getPictureInformationArray
//.........这里部分代码省略.........
// Fallback to the default thumb
$strImageSrc = $defaultThumbSRC;
}
//meta
$arrMeta = $objThis->getMetaData($objFileModel->meta, $objPage->language);
// Use the file name as title if none is given
if ($arrMeta['title'] == '') {
$arrMeta['title'] = specialchars($objFileModel->name);
}
}
// get thumb dimensions
$arrSize = unserialize($objThis->gc_size_detailview);
//Generate the thumbnails and the picture element
try {
$thumbSrc = \Image::create($strImageSrc, $arrSize)->executeResize()->getResizedPath();
$picture = \Picture::create($strImageSrc, $arrSize)->getTemplateData();
if ($thumbSrc !== $strImageSrc) {
$objFile = new \File(rawurldecode($thumbSrc), true);
}
} catch (\Exception $e) {
\System::log('Image "' . $strImageSrc . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);
$thumbSrc = '';
$picture = array('img' => array('src' => '', 'srcset' => ''), 'sources' => array());
}
$picture['alt'] = $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']);
$picture['title'] = $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']);
$objFileThumb = new \File(rawurldecode($thumbSrc));
$arrSize[0] = $objFileThumb->width;
$arrSize[1] = $objFileThumb->height;
$arrFile["thumb_width"] = $objFileThumb->width;
$arrFile["thumb_height"] = $objFileThumb->height;
// get some image params
if (is_file(TL_ROOT . '/' . $strImageSrc)) {
$objFileImage = new \File($strImageSrc);
if (!$objFileImage->isGdImage) {
return null;
}
$arrFile["path"] = $objFileImage->path;
$arrFile["basename"] = $objFileImage->basename;
// filename without extension
$arrFile["filename"] = $objFileImage->filename;
$arrFile["extension"] = $objFileImage->extension;
$arrFile["dirname"] = $objFileImage->dirname;
$arrFile["image_width"] = $objFileImage->width;
$arrFile["image_height"] = $objFileImage->height;
} else {
return null;
}
//check if there is a custom thumbnail selected
if ($objPicture->addCustomThumb && !empty($objPicture->customThumb)) {
$customThumbModel = \FilesModel::findByUuid($objPicture->customThumb);
if ($customThumbModel !== null) {
if (is_file(TL_ROOT . '/' . $customThumbModel->path)) {
$objFileCustomThumb = new \File($customThumbModel->path, true);
if ($objFileCustomThumb->isGdImage) {
$arrSize = unserialize($objThis->gc_size_detailview);
$thumbSrc = \Image::get($objFileCustomThumb->path, $arrSize[0], $arrSize[1], $arrSize[2]);
$objFileCustomThumb = new \File(rawurldecode($thumbSrc));
$arrSize[0] = $objFileCustomThumb->width;
$arrSize[1] = $objFileCustomThumb->height;
$arrFile["thumb_width"] = $objFileCustomThumb->width;
$arrFile["thumb_height"] = $objFileCustomThumb->height;
}
}
}
}
//exif
if ($GLOBALS['TL_CONFIG']['gc_read_exif']) {
try {
$exif = is_callable('exif_read_data') && TL_MODE == 'FE' ? exif_read_data($strImageSrc) : array('info' => "The function 'exif_read_data()' is not available on this server.");
} catch (Exception $e) {
$exif = array('info' => "The function 'exif_read_data()' is not available on this server.");
}
} else {
$exif = array('info' => "The function 'exif_read_data()' has not been activated in the Contao backend settings.");
}
//video-integration
$strMediaSrc = trim($objPicture->socialMediaSRC) != "" ? trim($objPicture->socialMediaSRC) : "";
if (\Validator::isUuid($objPicture->localMediaSRC)) {
//get path of a local Media
$objMovieFile = \FilesModel::findById($objPicture->localMediaSRC);
$strMediaSrc = $objMovieFile !== null ? $objMovieFile->path : $strMediaSrc;
}
$href = null;
if (TL_MODE == 'FE' && $objThis->gc_fullsize) {
$href = $strMediaSrc != "" ? $strMediaSrc : \System::urlEncode($strImageSrc);
}
//cssID
$cssID = deserialize($objPicture->cssID, true);
// build the array
$arrPicture = array('id' => $objPicture->id, 'pid' => $objPicture->pid, 'date' => $objPicture->date, 'owner' => $objPicture->owner, 'owners_name' => $objOwner->name, 'album_id' => $objPicture->pid, 'name' => specialchars($arrFile["basename"]), 'filename' => $arrFile["filename"], 'uuid' => $objPicture->uuid, 'path' => $arrFile["path"], 'basename' => $arrFile["basename"], 'dirname' => $arrFile["dirname"], 'extension' => $arrFile["extension"], 'alt' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'title' => $objPicture->title != '' ? specialchars($objPicture->title) : specialchars($arrMeta['title']), 'comment' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'caption' => $objPicture->comment != '' ? $objPage->outputFormat == 'xhtml' ? specialchars(\String::toXhtml($objPicture->comment)) : specialchars(\String::toHtml5($objPicture->comment)) : specialchars($arrMeta['caption']), 'href' => TL_FILES_URL . $href, 'single_image_url' => $objPageModel->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . \Input::get('items') . '/img/' . $arrFile["filename"], $objPage->language), 'image_src' => $arrFile["path"], 'media_src' => $strMediaSrc, 'socialMediaSRC' => $objPicture->socialMediaSRC, 'localMediaSRC' => $objPicture->localMediaSRC, 'addCustomThumb' => $objPicture->addCustomThumb, 'thumb_src' => isset($thumbSrc) ? TL_FILES_URL . $thumbSrc : '', 'size' => $arrSize, 'thumb_width' => $arrFile["thumb_width"], 'thumb_height' => $arrFile["thumb_height"], 'image_width' => $arrFile["image_width"], 'image_height' => $arrFile["image_height"], 'lightbox' => $objPage->outputFormat == 'xhtml' ? 'rel="lightbox[lb' . $objPicture->pid . ']"' : 'data-lightbox="lb' . $objPicture->pid . '"', 'tstamp' => $objPicture->tstamp, 'sorting' => $objPicture->sorting, 'published' => $objPicture->published, 'exif' => $exif, 'albuminfo' => $arrAlbumInfo, 'metaData' => $arrMeta, 'cssID' => $cssID[0] != '' ? $cssID[0] : '', 'cssClass' => $cssID[1] != '' ? $cssID[1] : '', 'externalFile' => $objPicture->externalFile, 'picture' => $picture);
//Fuegt dem Array weitere Eintraege hinzu, falls tl_gallery_creator_pictures erweitert wurde
$objPicture = \Database::getInstance()->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE id=?')->execute($intPictureId);
foreach ($objPicture->fetchAssoc() as $key => $value) {
if (!array_key_exists($key, $arrPicture)) {
$arrPicture[$key] = $value;
}
}
return $arrPicture;
}
示例14: convertDataForImportExportParseFields
/**
* @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;
}
示例15: listLinks
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;
}