public function __construct($arrAttributes = null) { // check against arrAttributes, as 'onsubmit_callback' => 'multifileupload_moveFiles' does not provide valid attributes if ($arrAttributes !== null && !$arrAttributes['uploadFolder']) { throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['noUploadFolderDeclared'], $this->name)); } $arrAttributes['uploadAction'] = static::$uploadAction; if (TL_MODE == 'FE') { $arrAttributes['uploadActionParams'] = http_build_query(AjaxAction::getParams(MultiFileUpload::NAME, static::$uploadAction)); } $arrAttributes['addRemoveLinks'] = isset($arrAttributes['addRemoveLinks']) ? $arrAttributes['addRemoveLinks'] : true; if (!is_array($arrAttributes['value']) && !Validator::isBinaryUuid($arrAttributes['value'])) { $arrAttributes['value'] = json_decode($arrAttributes['value']); } // bin to string -> never pass binary to the widget!! if ($arrAttributes['value']) { if (is_array($arrAttributes['value'])) { $arrAttributes['value'] = array_map(function ($val) { return \Validator::isBinaryUuid($val) ? \StringUtil::binToUuid($val) : $val; }, $arrAttributes['value']); } else { $arrAttributes['value'] = array(\Validator::isBinaryUuid($arrAttributes['value']) ? \StringUtil::binToUuid($arrAttributes['value']) : $arrAttributes['value']); } } parent::__construct($arrAttributes); $this->objUploader = new MultiFileUpload($arrAttributes); // add onsubmit_callback: move files after form submission $GLOBALS['TL_DCA'][$this->strTable]['config']['onsubmit_callback']['multifileupload_moveFiles'] = array('HeimrichHannot\\MultiFileUpload\\FormMultiFileUpload', 'moveFiles'); Ajax::runActiveAction(MultiFileUpload::NAME, MultiFileUpload::ACTION_UPLOAD, $this); }
/** * Store the file information in the session * @param mixed * @return mixed */ protected function validator($varInput) { $varReturn = parent::validator($varInput); $arrReturn = array_filter((array) $varReturn); $intCount = 0; foreach ($arrReturn as $varFile) { // Get the file model if (\Validator::isBinaryUuid($varFile)) { $objModel = \FilesModel::findByUuid($varFile); if ($objModel === null) { continue; } $varFile = $objModel->path; } $objFile = new \File($varFile, true); $_SESSION['FILES'][$this->strName . '_' . $intCount++] = array('name' => $objFile->path, 'type' => $objFile->mime, 'tmp_name' => TL_ROOT . '/' . $objFile->path, 'error' => 0, 'size' => $objFile->size, 'uploaded' => true, 'uuid' => $objModel !== null ? \String::binToUuid($objFile->uuid) : ''); } return $varReturn; }
/** * XSS clean values * @param $varValue * @param bool $tidy If true, close tags without a closing tag * * @return mixed $varValue xssClean */ public static function xssClean($varValue, $tidy = false) { if (is_array($varValue)) { foreach ($varValue as $key => $value) { $varValue[$key] = static::xssClean($value, $tidy); } return $varValue; } // do not xss clean binary uuids if (\Validator::isBinaryUuid($varValue)) { return $varValue; } $varValue = preg_replace('/(&#[A-Za-z0-9]+);?/i', '$1;', $varValue); $varValue = \Input::xssClean($varValue, true); if ($tidy) { $varValue = static::doTidyClean($varValue); } return $varValue; }
/** * Send a lost password e-mail * * @param \MemberModel $objMember */ protected function sendPasswordLink($objMember) { $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification); if ($objNotification === null) { $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR); return; } $confirmationId = md5(uniqid(mt_rand(), true)); // Store the confirmation ID $objMember = \MemberModel::findByPk($objMember->id); $objMember->activation = $confirmationId; $objMember->save(); $arrTokens = array(); // Add member tokens foreach ($objMember->row() as $k => $v) { if (\Validator::isBinaryUuid($v)) { $v = \StringUtil::binToUuid($v); } $arrTokens['member_' . $k] = specialchars($v); } // FIX: Add salutation token $arrTokens['salutation_user'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], $objMember); // ENDFIX $arrTokens['recipient_email'] = $objMember->email; $arrTokens['domain'] = \Idna::decode(\Environment::get('host')); $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId; // FIX: Add custom change password jump to if (($objJumpTo = $this->objModel->getRelated('changePasswordJumpTo')) !== null) { $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Controller::generateFrontendUrl($objJumpTo->row(), '?token=' . $confirmationId); } // ENDFIX $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']); $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } StatusMessage::addSuccess(sprintf($GLOBALS['TL_LANG']['notification_center_plus']['sendPasswordLink']['messageSuccess'], $arrTokens['recipient_email']), $this->objModel->id); $this->reload(); }
if (\Validator::isBinaryUuid($objStores->logo)) { if (($objFile = \FilesModel::findByPk($objStores->logo)) !== null) { $objStores->logo = $objFile->path; } } // decode marker if (\Validator::isBinaryUuid($objStores->marker)) { if (($objFile = \FilesModel::findByPk($objStores->marker)) !== null) { $objStores->marker = $objFile->path; } } // add category marker //@todo make null $objStores->categoryMarker = false; if (($objCategory = Tastaturberuf\AnyStoresCategoryModel::findByPk($objStores->pid)) !== null) { if (\Validator::isBinaryUuid($objCategory->defaultMarker)) { if (($objFile = \FilesModel::findByPk($objCategory->defaultMarker)) !== null) { $objStores->categoryMarker = $objFile->path; } } } } $arrConfig = array('status' => 'OK', 'count' => (int) $objStores->count(), 'module' => array('latitude' => (double) $objModule->anystores_latitude, 'longitude' => (double) $objModule->anystores_longitude, 'zoom' => (int) $objModule->anystores_zoom, 'streetview' => (bool) $objModule->anystores_streetview, 'maptype' => (string) $objModule->anystores_maptype, 'defaultMarker' => (string) $objModule->anystores_defaultMarker), 'stores' => $objStores->fetchAll()); // decode global default marker $arrConfig['global']['defaultMarker'] = null; if (\Validator::isUuid(\Config::get('anystores_defaultMarker'))) { if (($objFile = \FilesModel::findByPk(\Config::get('anystores_defaultMarker'))) !== null) { $arrConfig['global']['defaultMarker'] = $objFile->path; } } $strJson = json_encode($arrConfig);
/** * Prepare serializsation. * * @param mixed $data The data being serialized. * * @return mixed */ private function prepareSerialize($data) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = $this->prepareSerialize($value); } } elseif (\Validator::isBinaryUuid($data)) { $data = \String::binToUuid($data); } return $data; }
/** * Compare versions */ public function compare() { $strBuffer = ''; $arrVersions = array(); $intTo = 0; $intFrom = 0; $objVersions = $this->Database->prepare("SELECT * FROM tl_version WHERE pid=? AND fromTable=? ORDER BY version DESC")->execute($this->intPid, $this->strTable); if ($objVersions->numRows < 2) { $strBuffer = '<p>There are no versions of ' . $this->strTable . '.id=' . $this->intPid . '</p>'; } else { $intIndex = 0; $from = array(); // Store the versions and mark the active one while ($objVersions->next()) { if ($objVersions->active) { $intIndex = $objVersions->version; } $arrVersions[$objVersions->version] = $objVersions->row(); $arrVersions[$objVersions->version]['info'] = $GLOBALS['TL_LANG']['MSC']['version'] . ' ' . $objVersions->version . ' (' . \Date::parse(\Config::get('datimFormat'), $objVersions->tstamp) . ') ' . $objVersions->username; } // To if (\Input::post('to') && isset($arrVersions[\Input::post('to')])) { $intTo = \Input::post('to'); $to = deserialize($arrVersions[\Input::post('to')]['data']); } elseif (\Input::get('to') && isset($arrVersions[\Input::get('to')])) { $intTo = \Input::get('to'); $to = deserialize($arrVersions[\Input::get('to')]['data']); } else { $intTo = $intIndex; $to = deserialize($arrVersions[$intTo]['data']); } // From if (\Input::post('from') && isset($arrVersions[\Input::post('from')])) { $intFrom = \Input::post('from'); $from = deserialize($arrVersions[\Input::post('from')]['data']); } elseif (\Input::get('from') && isset($arrVersions[\Input::get('from')])) { $intFrom = \Input::get('from'); $from = deserialize($arrVersions[\Input::get('from')]['data']); } elseif ($intIndex > 1) { $intFrom = $intIndex - 1; $from = deserialize($arrVersions[$intFrom]['data']); } // Only continue if both version numbers are set if ($intTo > 0 && $intFrom > 0) { \System::loadLanguageFile($this->strTable); $this->loadDataContainer($this->strTable); // Get the order fields $objDcaExtractor = \DcaExtractor::getInstance($this->strTable); $arrOrder = $objDcaExtractor->getOrderFields(); // Find the changed fields and highlight the changes foreach ($to as $k => $v) { if ($from[$k] != $to[$k]) { if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['inputType'] == 'password' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['doNotShow'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['hideInput']) { continue; } $blnIsBinary = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['inputType'] == 'fileTree' || in_array($k, $arrOrder); // Decrypt the values if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['encrypt']) { $to[$k] = \Encryption::decrypt($to[$k]); $from[$k] = \Encryption::decrypt($from[$k]); } // Convert serialized arrays into strings if (is_array($tmp = deserialize($to[$k])) && !is_array($to[$k])) { $to[$k] = $this->implodeRecursive($tmp, $blnIsBinary); } if (is_array($tmp = deserialize($from[$k])) && !is_array($from[$k])) { $from[$k] = $this->implodeRecursive($tmp, $blnIsBinary); } unset($tmp); // Convert binary UUIDs to their hex equivalents (see #6365) if ($blnIsBinary && \Validator::isBinaryUuid($to[$k])) { $to[$k] = \String::binToUuid($to[$k]); } if ($blnIsBinary && \Validator::isBinaryUuid($from[$k])) { $to[$k] = \String::binToUuid($from[$k]); } // Convert date fields if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'date') { $to[$k] = \Date::parse(\Config::get('dateFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('dateFormat'), $from[$k] ?: ''); } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'time') { $to[$k] = \Date::parse(\Config::get('timeFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('timeFormat'), $from[$k] ?: ''); } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'datim' || $k == 'tstamp') { $to[$k] = \Date::parse(\Config::get('datimFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('datimFormat'), $from[$k] ?: ''); } // Convert strings into arrays if (!is_array($to[$k])) { $to[$k] = explode("\n", $to[$k]); } if (!is_array($from[$k])) { $from[$k] = explode("\n", $from[$k]); } $objDiff = new \Diff($from[$k], $to[$k]); $strBuffer .= $objDiff->Render(new DiffRenderer(array('field' => $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['label'][0] ?: (isset($GLOBALS['TL_LANG']['MSC'][$k]) ? is_array($GLOBALS['TL_LANG']['MSC'][$k]) ? $GLOBALS['TL_LANG']['MSC'][$k][0] : $GLOBALS['TL_LANG']['MSC'][$k] : $k)))); } } } } // Identical versions if ($strBuffer == '') { $strBuffer = '<p>' . $GLOBALS['TL_LANG']['MSC']['identicalVersions'] . '</p>'; } /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_diff'); // Template variables $objTemplate->content = $strBuffer; $objTemplate->versions = $arrVersions; $objTemplate->to = $intTo; $objTemplate->from = $intFrom; $objTemplate->showLabel = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); \Config::set('debugMode', false); $objTemplate->output(); exit; }
/** * FrontendAjax constructor. * * @param int $intModuleId */ public static function run($intModuleId, $strToken) { if (!static::validateRequestToken($intModuleId, $strToken)) { static::respond(array('status' => 'error', 'message' => 'Invalid request token')); } $objModule = \ModuleModel::findByPk($intModuleId); if (!$objModule || $objModule->type !== 'anystores_map') { static::respond(array('status' => 'error', 'message' => 'Invalid module')); } // Hook to manipulate the module if (isset($GLOBALS['TL_HOOKS']['anystores_getAjaxModule']) && is_array($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'])) { foreach ($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'] as $callback) { \System::importStatic($callback[0])->{$callback[1]}($objModule); } } if (\Validator::isBinaryUuid($objModule->anystores_defaultMarker)) { $objFile = \FilesModel::findByPk($objModule->anystores_defaultMarker); $objModule->anystores_defaultMarker = $objFile ? $objFile->path : null; } // Find stores $objStores = AnyStoresModel::findPublishedByCategory(deserialize($objModule->anystores_categories)); if (!$objStores) { static::respond(array('status' => 'error', 'message' => 'No stores found')); } while ($objStores->next()) { // generate jump to if ($objModule->jumpTo) { if (($objLocation = \PageModel::findByPk($objModule->jumpTo)) !== null) { //@todo language parameter $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/'; $strStoreValue = $objStores->alias; $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue); } } // Encode email $objStores->email = \String::encodeEmail($objStores->email); // Encode opening times $objStores->opening_times = deserialize($objStores->opening_times); // decode logo if (\Validator::isBinaryUuid($objStores->logo)) { $objFile = \FilesModel::findByPk($objStores->logo); $objStores->logo = $objFile ? $objFile->path : null; } // decode marker if (\Validator::isBinaryUuid($objStores->marker)) { $objFile = \FilesModel::findByPk($objStores->marker); $objStores->marker = $objFile ? $objFile->path : null; } // add category marker $objStores->categoryMarker = null; if (($objCategory = AnyStoresCategoryModel::findByPk($objStores->pid)) !== null) { if (\Validator::isBinaryUuid($objCategory->defaultMarker)) { $objFile = \FilesModel::findByPk($objCategory->defaultMarker); if ($objFile) { $objStores->categoryMarker = $objFile->path; } } } // render html $strTemplate = $objModule->anystores_detailTpl ?: 'anystores_details'; $objTemplate = new \FrontendTemplate($strTemplate); $objTemplate->setData($objStores->current()->row()); $objStores->tiphtml = static::replaceInsertTags($objTemplate->parse()); } $arrRespond = array('status' => 'success', 'count' => (int) $objStores->count(), 'module' => array('latitude' => (double) $objModule->anystores_latitude, 'longitude' => (double) $objModule->anystores_longitude, 'zoom' => (int) $objModule->anystores_zoom, 'streetview' => (bool) $objModule->anystores_streetview, 'maptype' => (string) $objModule->anystores_maptype, 'defaultMarker' => (string) $objModule->anystores_defaultMarker), 'stores' => $objStores->fetchAll()); // decode global default marker $arrRespond['global']['defaultMarker'] = null; if (\Validator::isUuid(\Config::get('anystores_defaultMarker'))) { if (($objFile = \FilesModel::findByPk(\Config::get('anystores_defaultMarker'))) !== null) { $arrRespond['global']['defaultMarker'] = $objFile->path; } } static::respond($arrRespond); }
public static function prepareSpecialValueForPrint($varValue, $arrData, $strTable, $objDc, $objItem = null) { $varValue = deserialize($varValue); $arrOpts = $arrData['options']; $arrReference = $arrData['reference']; $strRegExp = $arrData['eval']['rgxp']; // get options if ((is_array($arrData['options_callback']) || is_callable($arrData['options_callback'])) && !$arrData['reference']) { if (is_array($arrData['options_callback'])) { $strClass = $arrData['options_callback'][0]; $strMethod = $arrData['options_callback'][1]; $objInstance = \Controller::importStatic($strClass); $arrOptionsCallback = @$objInstance->{$strMethod}($objDc); } elseif (is_callable($arrData['options_callback'])) { $arrOptionsCallback = @$arrData['options_callback']($objDc); } $arrOptions = !is_array($varValue) ? array($varValue) : $varValue; if ($varValue !== null && is_array($arrOptionsCallback)) { $varValue = array_intersect_key($arrOptionsCallback, array_flip($arrOptions)); } } if ($arrData['inputType'] == 'explanation') { $varValue = $arrData['eval']['text']; } elseif ($strRegExp == 'date') { $varValue = \Date::parse(\Config::get('dateFormat'), $varValue); } elseif ($strRegExp == 'time') { $varValue = \Date::parse(\Config::get('timeFormat'), $varValue); } elseif ($strRegExp == 'datim') { $varValue = \Date::parse(\Config::get('datimFormat'), $varValue); } elseif ($arrData['inputType'] == 'tag' && in_array('tags_plus', \ModuleLoader::getActive())) { if (($arrTags = \HeimrichHannot\TagsPlus\TagsPlus::loadTags($strTable, $objItem->id)) !== null) { $varValue = $arrTags; } } elseif (!is_array($varValue) && \Validator::isBinaryUuid($varValue)) { $strPath = Files::getPathFromUuid($varValue); $varValue = $strPath ? \Environment::get('url') . '/' . $strPath : \StringUtil::binToUuid($varValue); } elseif (is_array($varValue)) { $varValue = Arrays::flattenArray($varValue); $varValue = array_filter($varValue); // remove empty elements // transform binary uuids to paths $varValue = array_map(function ($varValue) { if (\Validator::isBinaryUuid($varValue)) { $strPath = Files::getPathFromUuid($varValue); if ($strPath) { return \Environment::get('url') . '/' . $strPath; } return \StringUtil::binToUuid($varValue); } return $varValue; }, $varValue); if (!$arrReference) { $varValue = array_map(function ($varValue) use($arrOpts) { return isset($arrOpts[$varValue]) ? $arrOpts[$varValue] : $varValue; }, $varValue); } $varValue = array_map(function ($varValue) use($arrReference) { if (is_array($arrReference)) { return isset($arrReference[$varValue]) ? is_array($arrReference[$varValue]) ? $arrReference[$varValue][0] : $arrReference[$varValue] : $varValue; } else { return $varValue; } }, $varValue); } else { if ($arrData['eval']['isBoolean'] || $arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) { $varValue = $varValue != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no']; } elseif (is_array($arrOpts) && array_is_assoc($arrOpts)) { $varValue = isset($arrOpts[$varValue]) ? $arrOpts[$varValue] : $varValue; } elseif (is_array($arrReference)) { $varValue = isset($arrReference[$varValue]) ? is_array($arrReference[$varValue]) ? $arrReference[$varValue][0] : $arrReference[$varValue] : $varValue; } } if (is_array($varValue)) { $varValue = implode(', ', $varValue); } // Convert special characters (see #1890) return specialchars($varValue); }
/** * @param $value * @return string */ public static function binToUuid($value) { // Convert bin to uuid if (\Validator::isBinaryUuid($value)) { return \StringUtil::binToUuid($value); } return $value; }
/** * Generate the widget and return it as string * @param array * @return string */ public function parse($arrAttributes = null) { $arrSet = array(); $arrValues = array(); if (!empty($this->varValue)) { // Can be an array $arrUuids = array(); $arrTemp = array(); $this->varValue = (array) $this->varValue; foreach ($this->varValue as $varFile) { if (\Validator::isBinaryUuid($varFile)) { $arrUuids[] = $varFile; } else { $arrTemp[] = $varFile; } } $objFiles = \FilesModel::findMultipleByUuids($arrUuids); // Get the database files if ($objFiles !== null) { while ($objFiles->next()) { $chunk = $this->generateFileItem($objFiles->path); if (strlen($chunk)) { $arrValues[$objFiles->uuid] = array('id' => in_array($objFiles->uuid, $arrTemp) ? $objFiles->uuid : \StringUtil::binToUuid($objFiles->uuid), 'value' => $chunk); $arrSet[] = $objFiles->uuid; } } } // Get the temporary files foreach ($arrTemp as $varFile) { $chunk = $this->generateFileItem($varFile); if (strlen($chunk)) { $arrValues[$varFile] = array('id' => in_array($varFile, $arrTemp) ? $varFile : \StringUtil::binToUuid($varFile), 'value' => $chunk); $arrSet[] = $varFile; } } } // Load the fonts for the drag hint (see #4838) $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true; // Parse the set array foreach ($arrSet as $k => $v) { if (in_array($v, $arrTemp)) { $strSet[$k] = $v; } else { $arrSet[$k] = \StringUtil::binToUuid($v); } } $this->set = implode(',', $arrSet); $this->sortable = count($arrValues) > 1; $this->orderHint = $GLOBALS['TL_LANG']['MSC']['dragItemsHint']; $this->values = $arrValues; $this->ajax = \Environment::get('isAjaxRequest') && \Input::post('action') !== 'toggleSubpalette'; $this->deleteTitle = specialchars($GLOBALS['TL_LANG']['MSC']['delete']); $this->extensions = json_encode(trimsplit(',', $this->arrConfiguration['extensions'])); $this->limit = $this->arrConfiguration['uploaderLimit'] ? $this->arrConfiguration['uploaderLimit'] : 0; $this->minSizeLimit = $this->arrConfiguration['minlength'] ? $this->arrConfiguration['minlength'] : 0; $this->sizeLimit = $this->arrConfiguration['maxlength'] ? $this->arrConfiguration['maxlength'] : 0; $this->chunkSize = $this->arrConfiguration['chunkSize'] ? $this->arrConfiguration['chunkSize'] : 0; $this->concurrent = $this->arrConfiguration['concurrent'] ? true : false; $this->maxConnections = $this->arrConfiguration['maxConnections'] ? $this->arrConfiguration['maxConnections'] : 3; return parent::parse($arrAttributes); }
/** * Generate the widget and return it as string * @param array * @return string */ public function parse($arrAttributes = null) { $arrSet = array(); $arrValues = array(); if (!empty($this->varValue)) { // Can be an array $arrUuids = array(); $arrTemp = array(); $this->varValue = (array) $this->varValue; foreach ($this->varValue as $varFile) { if (\Validator::isBinaryUuid($varFile)) { $arrUuids[] = $varFile; } else { $arrTemp[] = $varFile; } } $objFiles = \FilesModel::findMultipleByUuids($arrUuids); // Get the database files if ($objFiles !== null) { while ($objFiles->next()) { $chunk = $this->generateFileItem($objFiles->path); if (strlen($chunk)) { $arrValues[$objFiles->uuid] = array('id' => in_array($objFiles->uuid, $arrTemp) ? $objFiles->uuid : \String::binToUuid($objFiles->uuid), 'value' => $chunk); $arrSet[] = $objFiles->uuid; } } } // Get the temporary files foreach ($arrTemp as $varFile) { $chunk = $this->generateFileItem($varFile); if (strlen($chunk)) { $arrValues[$varFile] = array('id' => in_array($varFile, $arrTemp) ? $varFile : \String::binToUuid($varFile), 'value' => $chunk); $arrSet[] = $varFile; } } } // Load the fonts for the drag hint (see #4838) $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true; // Parse the set array foreach ($arrSet as $k => $v) { if (in_array($v, $arrTemp)) { $strSet[$k] = $v; } else { $arrSet[$k] = \String::binToUuid($v); } } $this->set = implode(',', $arrSet); $this->sortable = count($arrValues) > 1; $this->orderHint = $GLOBALS['TL_LANG']['MSC']['dragItemsHint']; $this->values = $arrValues; $this->ajax = \Environment::get('isAjaxRequest'); $this->deleteTitle = specialchars($GLOBALS['TL_LANG']['MSC']['delete']); $this->extensions = json_encode(trimsplit(',', $this->arrConfiguration['extensions'])); $this->limit = $this->arrConfiguration['uploaderLimit'] ? $this->arrConfiguration['uploaderLimit'] : 0; $this->sizeLimit = $this->arrConfiguration['maxlength'] ? $this->arrConfiguration['maxlength'] : 0; $this->chunkSize = $this->arrConfiguration['chunkSize'] ? $this->arrConfiguration['chunkSize'] : 0; $this->config = $this->arrConfiguration['uploaderConfig']; $this->texts = json_encode(array('text' => array('formatProgress' => $GLOBALS['TL_LANG']['MSC']['fineuploader_formatProgress'], 'failUpload' => $GLOBALS['TL_LANG']['MSC']['fineuploader_failUpload'], 'waitingForResponse' => $GLOBALS['TL_LANG']['MSC']['fineuploader_waitingForResponse'], 'paused' => $GLOBALS['TL_LANG']['MSC']['fineuploader_paused']), 'messages' => array('tooManyFilesError' => $GLOBALS['TL_LANG']['MSC']['fineuploader_tooManyFilesError'], 'unsupportedBrowser' => $GLOBALS['TL_LANG']['MSC']['fineuploader_unsupportedBrowser']), 'retry' => array('autoRetryNote' => $GLOBALS['TL_LANG']['MSC']['fineuploader_autoRetryNote']), 'deleteFile' => array('confirmMessage' => $GLOBALS['TL_LANG']['MSC']['fineuploader_confirmMessage'], 'deletingStatusText' => $GLOBALS['TL_LANG']['MSC']['fineuploader_deletingStatusText'], 'deletingFailedText' => $GLOBALS['TL_LANG']['MSC']['fineuploader_deletingFailedText']), 'paste' => array('namePromptMessage' => $GLOBALS['TL_LANG']['MSC']['fineuploader_namePromptMessage']))); $this->labels = array('drop' => $GLOBALS['TL_LANG']['MSC']['fineuploader_drop'], 'upload' => $GLOBALS['TL_LANG']['MSC']['fineuploader_upload'], 'processing' => $GLOBALS['TL_LANG']['MSC']['fineuploader_processing']); return parent::parse($arrAttributes); }
/** * * Add contao core tokens, as long as the cron job does not have these information * on sending mail in queue mode * * @param $arrTokens * @param $strLanguage * @return bool false if context_tokens has been set already (required by cron) */ protected function addContextTokens($objMessage, &$arrTokens, $strLanguage) { // add context tokens only once (queue will trigger this function again, and tokens might be overwritten) if (isset($arrTokens['context_tokens'])) { return false; } $arrTokens['context_tokens'] = true; // add environment variables as token $arrTokens['env_host'] = \Idna::decode(\Environment::get('host')); $arrTokens['env_http_host'] = \Idna::decode(\Environment::get('httpHost')); $arrTokens['env_url'] = \Idna::decode(\Environment::get('url')); $arrTokens['env_path'] = \Idna::decode(\Environment::get('base')); $arrTokens['env_request'] = \Idna::decode(\Environment::get('indexFreeRequest')); $arrTokens['env_ip'] = \Idna::decode(\Environment::get('ip')); $arrTokens['env_referer'] = \System::getReferer(); $arrTokens['env_files_url'] = TL_FILES_URL; $arrTokens['env_plugins_url'] = TL_ASSETS_URL; $arrTokens['env_script_url'] = TL_ASSETS_URL; // add date tokens $arrTokens['date'] = \Controller::replaceInsertTags('{{date}}'); $arrTokens['last_update'] = \Controller::replaceInsertTags('{{last_update}}'); if (TL_MODE == 'FE') { // add current page as token global $objPage; if ($objPage !== null) { foreach ($objPage->row() as $key => $value) { $arrTokens['page_' . $key] = $value; } if ($objPage->pageTitle == '') { $arrTokens['pageTitle'] = $objPage->title; } else { if ($objPage->parentPageTitle == '') { $arrTokens['parentPageTitle'] = $objPage->parentTitle; } else { if ($objPage->mainPageTitle == '') { $arrTokens['mainPageTitle'] = $objPage->mainTitle; } } } } // add user attributes as token if (FE_USER_LOGGED_IN) { $arrUserData = \FrontendUser::getInstance()->getData(); if (is_array($arrUserData)) { foreach ($arrUserData as $key => $value) { if (!is_array($value) && \Validator::isBinaryUuid($value)) { $value = \StringUtil::binToUuid($value); $objFile = \FilesModel::findByUuid($value); if ($objFile !== null) { $value = $objFile->path; } } $arrTokens['user_' . $key] = $value; } } } } }
/** * Manipulate the field definition for custom file trees. * * @param array $arrFieldDef The field definition to manipulate. * * @return void */ private function handleCustomFileTree(&$arrFieldDef) { if (strlen($this->get('file_uploadFolder'))) { // Set root path of file chooser depending on contao version. $objFile = null; if (\Validator::isStringUuid($this->get('file_uploadFolder')) || \Validator::isBinaryUuid($this->get('file_uploadFolder'))) { $objFile = \FilesModel::findByUuid($this->get('file_uploadFolder')); } // Check if we have a file. if ($objFile != null) { $arrFieldDef['eval']['path'] = $objFile->path; } else { // Fallback. $arrFieldDef['eval']['path'] = $this->get('file_uploadFolder'); } } if (strlen($this->get('file_validFileTypes'))) { $arrFieldDef['eval']['extensions'] = $this->get('file_validFileTypes'); } if (strlen($this->get('file_filesOnly'))) { $arrFieldDef['eval']['filesOnly'] = true; } }
/** * Stringify an uuid. * * @param mixed $uuid Given uuid. * * @return string */ private function stringifyUuid($uuid) { if (\Validator::isBinaryUuid($uuid)) { return \String::binToUuid($uuid); } return $uuid; }
/** * Contao 3 DBAFS Support. * * @param string $strId String uuid of the file. * * @return ToolboxFile */ public function addPathById($strId) { // Check if empty. if (empty($strId)) { return $this; } if (!\Validator::isBinaryUuid($strId)) { $this->pendingIds[] = self::stringToUuid($strId); return $this; } $this->pendingIds[] = $strId; return $this; }