本文整理汇总了PHP中StringUtil::binToUuid方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::binToUuid方法的具体用法?PHP StringUtil::binToUuid怎么用?PHP StringUtil::binToUuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::binToUuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDownloadElement
public function getDownloadElement($strTag)
{
$params = preg_split('/::/', $strTag);
if (is_array($params) && !empty($params)) {
if (strpos($params[0], 'download') === 0) {
$singleSRC = strip_tags($params[1]);
// remove <span> etc, otherwise Validator::isuuid fail
$objDownload = new \stdClass();
if (strpos($singleSRC, '/') !== false) {
if (($objFile = FilesModel::findByPath($singleSRC)) !== null && $objFile->uuid) {
$singleSRC = \StringUtil::binToUuid($objFile->uuid);
}
}
$objDownload->singleSRC = $singleSRC;
$objDownload->linkTitle = strip_tags($params[2]);
// remove <span> etc
$objDownload->cssID[1] = 'inserttag_download ' . strip_tags($params[3]);
$objDownload->cssID[0] = strip_tags($params[4]);
$objContentDownload = new \ContentDownloadInserttag($objDownload);
$output = $objContentDownload->generate();
if ($params[0] == 'download') {
return $output;
}
if ($params[0] == 'download_link') {
return $objContentDownload->Template->href;
}
if ($params[0] == 'download_size') {
return $objContentDownload->Template->filesize;
}
return '';
}
}
return false;
}
示例2: __construct
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);
}
示例3: getDefaultAttachmentSRC
public static function getDefaultAttachmentSRC($blnReturnPath = false)
{
$objFolder = new \Folder('files/submissions/uploads');
if ($blnReturnPath) {
return $objFolder->path;
}
if (\Validator::isUuid($objFolder->getModel()->uuid)) {
return class_exists('Contao\\StringUtil') ? \StringUtil::binToUuid($objFolder->getModel()->uuid) : \String::binToUuid($objFolder->getModel()->uuid);
}
return null;
}
示例4: format
/**
* {@inheritDoc}
*/
public function format($value, $fieldName, array $fieldDefinition, $context = null)
{
if (is_array($value)) {
$value = array_values(array_filter(array_map(function ($value) {
return $value ? \StringUtil::binToUuid($value) : '';
}, $value)));
} else {
$value = $value ? \StringUtil::binToUuid($value) : '';
}
return $value;
}
示例5: saveCallback
/**
* Save callback for the DCA fields.
* Converts any file path to a {{file::*}} insert tag.
*
* @param mixed $varValue The ipnut value
*
* @return string The processed value
*/
public function saveCallback($varValue)
{
// search for the file
if (($objFile = \FilesModel::findOneByPath(urldecode($varValue))) !== null) {
// convert the uuid
if (version_compare(VERSION . '.' . BUILD, '3.5.1', '<')) {
$uuid = \String::binToUuid($objFile->uuid);
} else {
$uuid = \StringUtil::binToUuid($objFile->uuid);
}
// convert to insert tag
$varValue = "{{file::{$uuid}}}";
}
// return the value
return $varValue;
}
示例6: sendPasswordLink
/**
* 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();
}
开发者ID:heimrichhannot,项目名称:contao-notification_center_plus,代码行数:45,代码来源:ModulePasswordNotificationCenterPlus.php
示例7: validate
//.........这里部分代码省略.........
}
// File was not uploaded
if (!is_uploaded_file($file['tmp_name'])) {
if ($file['error'] == 1 || $file['error'] == 2) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
} elseif ($file['error'] == 3) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filepartial'], $file['name']));
} elseif ($file['error'] > 0) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['fileerror'], $file['error'], $file['name']));
}
unset($_FILES[$this->strName]);
return;
}
// File is too big
if ($file['size'] > $maxlength_kb) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
unset($_FILES[$this->strName]);
return;
}
$objFile = new \File($file['name']);
$uploadTypes = \StringUtil::trimsplit(',', strtolower($this->extensions));
// File type is not allowed
if (!in_array($objFile->extension, $uploadTypes)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
unset($_FILES[$this->strName]);
return;
}
if (($arrImageSize = @getimagesize($file['tmp_name'])) != false) {
// Image exceeds maximum image width
if ($arrImageSize[0] > \Config::get('imageWidth')) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filewidth'], $file['name'], \Config::get('imageWidth')));
unset($_FILES[$this->strName]);
return;
}
// Image exceeds maximum image height
if ($arrImageSize[1] > \Config::get('imageHeight')) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['fileheight'], $file['name'], \Config::get('imageHeight')));
unset($_FILES[$this->strName]);
return;
}
}
// Store file in the session and optionally on the server
if (!$this->hasErrors()) {
$_SESSION['FILES'][$this->strName] = $_FILES[$this->strName];
if ($this->storeFile) {
$intUploadFolder = $this->uploadFolder;
// Overwrite the upload folder with user's home directory
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$intUploadFolder = $this->User->homeDir;
}
}
$objUploadFolder = \FilesModel::findByUuid($intUploadFolder);
// The upload folder could not be found
if ($objUploadFolder === null) {
throw new \Exception("Invalid upload folder ID {$intUploadFolder}");
}
$strUploadFolder = $objUploadFolder->path;
// Store the file if the upload folder exists
if ($strUploadFolder != '' && is_dir(TL_ROOT . '/' . $strUploadFolder)) {
$this->import('Files');
// Do not overwrite existing files
if ($this->doNotOverwrite && file_exists(TL_ROOT . '/' . $strUploadFolder . '/' . $file['name'])) {
$offset = 1;
$arrAll = scan(TL_ROOT . '/' . $strUploadFolder);
$arrFiles = preg_grep('/^' . preg_quote($objFile->filename, '/') . '.*\\.' . preg_quote($objFile->extension, '/') . '/', $arrAll);
foreach ($arrFiles as $strFile) {
if (preg_match('/__[0-9]+\\.' . preg_quote($objFile->extension, '/') . '$/', $strFile)) {
$strFile = str_replace('.' . $objFile->extension, '', $strFile);
$intValue = intval(substr($strFile, strrpos($strFile, '_') + 1));
$offset = max($offset, $intValue);
}
}
$file['name'] = str_replace($objFile->filename, $objFile->filename . '__' . ++$offset, $file['name']);
}
// Move the file to its destination
$this->Files->move_uploaded_file($file['tmp_name'], $strUploadFolder . '/' . $file['name']);
$this->Files->chmod($strUploadFolder . '/' . $file['name'], \Config::get('defaultFileChmod'));
$strUuid = null;
$strFile = $strUploadFolder . '/' . $file['name'];
// Generate the DB entries
if (\Dbafs::shouldBeSynchronized($strFile)) {
$objModel = \FilesModel::findByPath($strFile);
if ($objModel === null) {
$objModel = \Dbafs::addResource($strFile);
}
$strUuid = \StringUtil::binToUuid($objModel->uuid);
// Update the hash of the target folder
\Dbafs::updateFolderHashes($strUploadFolder);
}
// Add the session entry (see #6986)
$_SESSION['FILES'][$this->strName] = array('name' => $file['name'], 'type' => $file['type'], 'tmp_name' => TL_ROOT . '/' . $strFile, 'error' => $file['error'], 'size' => $file['size'], 'uploaded' => true, 'uuid' => $strUuid);
// Add a log entry
$this->log('File "' . $strUploadFolder . '/' . $file['name'] . '" has been uploaded', __METHOD__, TL_FILES);
}
}
}
unset($_FILES[$this->strName]);
}
示例8: show
/**
* Return all non-excluded fields of a record as HTML table
*
* @return string
*/
public function show()
{
if (!strlen($this->intId)) {
return '';
}
$objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->intId);
if ($objRow->numRows < 1) {
return '';
}
$count = 1;
$return = '';
$row = $objRow->row();
// Get the order fields
$objDcaExtractor = \DcaExtractor::getInstance($this->strTable);
$arrOrder = $objDcaExtractor->getOrderFields();
// Get all fields
$fields = array_keys($row);
$allowedFields = array('id', 'pid', 'sorting', 'tstamp');
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'])) {
$allowedFields = array_unique(array_merge($allowedFields, array_keys($GLOBALS['TL_DCA'][$this->strTable]['fields'])));
}
// Use the field order of the DCA file
$fields = array_intersect($allowedFields, $fields);
// Show all allowed fields
foreach ($fields as $i) {
if (!in_array($i, $allowedFields) || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['inputType'] == 'password' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['doNotShow'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['hideInput']) {
continue;
}
// Special treatment for table tl_undo
if ($this->strTable == 'tl_undo' && $i == 'data') {
continue;
}
$value = deserialize($row[$i]);
// Decrypt the value
if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['encrypt']) {
$value = \Encryption::decrypt($value);
}
$class = $count++ % 2 == 0 ? ' class="tl_bg"' : '';
// Get the field value
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['foreignKey'])) {
$temp = array();
$chunks = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['foreignKey'], 2);
foreach ((array) $value as $v) {
$objKey = $this->Database->prepare("SELECT " . $chunks[1] . " AS value FROM " . $chunks[0] . " WHERE id=?")->limit(1)->execute($v);
if ($objKey->numRows) {
$temp[] = $objKey->value;
}
}
$row[$i] = implode(', ', $temp);
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['inputType'] == 'fileTree' || in_array($i, $arrOrder)) {
if (is_array($value)) {
foreach ($value as $kk => $vv) {
$value[$kk] = $vv ? \StringUtil::binToUuid($vv) : '';
}
$row[$i] = implode(', ', $value);
} else {
$row[$i] = $value ? \StringUtil::binToUuid($value) : '';
}
} elseif (is_array($value)) {
foreach ($value as $kk => $vv) {
if (is_array($vv)) {
$vals = array_values($vv);
$value[$kk] = $vals[0] . ' (' . $vals[1] . ')';
}
}
$row[$i] = implode(', ', $value);
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['rgxp'] == 'date') {
$row[$i] = $value ? \Date::parse(\Config::get('dateFormat'), $value) : '-';
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['rgxp'] == 'time') {
$row[$i] = $value ? \Date::parse(\Config::get('timeFormat'), $value) : '-';
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['rgxp'] == 'datim' || in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['flag'], array(5, 6, 7, 8, 9, 10)) || $i == 'tstamp') {
$row[$i] = $value ? \Date::parse(\Config::get('datimFormat'), $value) : '-';
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['multiple']) {
$row[$i] = $value != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no'];
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['inputType'] == 'textarea' && ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['allowHtml'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['preserveTags'])) {
$row[$i] = specialchars($value);
} elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['reference'])) {
$row[$i] = isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['reference'][$row[$i]]) ? is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['reference'][$row[$i]]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['reference'][$row[$i]][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['reference'][$row[$i]] : $row[$i];
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['options'])) {
$row[$i] = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['options'][$row[$i]];
} else {
$row[$i] = $value;
}
// Label
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['label'])) {
$label = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['label']) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['label'][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$i]['label'];
} else {
$label = is_array($GLOBALS['TL_LANG']['MSC'][$i]) ? $GLOBALS['TL_LANG']['MSC'][$i][0] : $GLOBALS['TL_LANG']['MSC'][$i];
}
if ($label == '') {
$label = $i;
}
$return .= '
<tr>
<td' . $class . '><span class="tl_label">' . $label . ': </span></td>
//.........这里部分代码省略.........
示例9: generate
//.........这里部分代码省略.........
$image = 'placeholder.png';
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objFiles->path, 80, 60, 'center_center');
}
$arrValues[$objFiles->uuid] = \Image::getHtml($image, '', 'class="gimage" title="' . specialchars($strInfo) . '"');
} else {
$arrValues[$objFiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
} else {
if ($objFiles->type == 'folder') {
$objSubfiles = \FilesModel::findByPid($objFiles->uuid);
if ($objSubfiles === null) {
continue;
}
while ($objSubfiles->next()) {
// Skip subfolders
if ($objSubfiles->type == 'folder') {
continue;
}
$objFile = new \File($objSubfiles->path, true);
$strInfo = '<span class="dirname">' . dirname($objSubfiles->path) . '/</span>' . $objFile->basename . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
if ($this->isGallery) {
// Only show images
if ($objFile->isImage) {
$image = 'placeholder.png';
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objSubfiles->path, 80, 60, 'center_center');
}
$arrValues[$objSubfiles->uuid] = \Image::getHtml($image, '', 'class="gimage" title="' . specialchars($strInfo) . '"');
}
} else {
// Only show allowed download types
if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
$arrValues[$objSubfiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
}
} else {
$objFile = new \File($objFiles->path, true);
$strInfo = '<span class="dirname">' . dirname($objFiles->path) . '/</span>' . $objFile->basename . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
if ($this->isGallery) {
// Only show images
if ($objFile->isImage) {
$image = 'placeholder.png';
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objFiles->path, 80, 60, 'center_center');
}
$arrValues[$objFiles->uuid] = \Image::getHtml($image, '', 'class="gimage" title="' . specialchars($strInfo) . '"');
}
} else {
// Only show allowed download types
if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
$arrValues[$objFiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
}
}
}
}
// Apply a custom sort order
if ($blnHasOrder) {
$arrNew = array();
foreach ((array) $this->{$this->orderField} as $i) {
if (isset($arrValues[$i])) {
$arrNew[$i] = $arrValues[$i];
unset($arrValues[$i]);
}
}
if (!empty($arrValues)) {
foreach ($arrValues as $k => $v) {
$arrNew[$k] = $v;
}
}
$arrValues = $arrNew;
unset($arrNew);
}
}
// Load the fonts for the drag hint (see #4838)
\Config::set('loadGoogleFonts', true);
// Convert the binary UUIDs
$strSet = implode(',', array_map('StringUtil::binToUuid', $arrSet));
$strOrder = $blnHasOrder ? implode(',', array_map('StringUtil::binToUuid', $this->{$this->orderField})) : '';
$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) > 1 ? '
<p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . '
<ul id="sort_' . $this->strId . '" class="' . trim(($blnHasOrder ? 'sortable ' : '') . ($this->isGallery ? 'sgallery' : '')) . '">';
foreach ($arrValues as $k => $v) {
$return .= '<li data-id="' . \StringUtil::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=' . $this->activeRecord->id . '&value=' . implode(',', array_keys($arrSet)) . '&rt=' . REQUEST_TOKEN . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':768,\'title\':\'' . specialchars(str_replace("'", "\\'", $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['label'][0])) . '\',\'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;
}
示例10: save
/**
* Save the current value
*
* @param mixed $varValue
*/
protected function save($varValue)
{
if (\Input::post('FORM_SUBMIT') != $this->strTable) {
return;
}
$arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField];
// Make sure that checkbox values are boolean
if ($arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) {
$varValue = $varValue ? true : false;
}
if ($varValue != '') {
// Convert binary UUIDs (see #6893)
if ($arrData['inputType'] == 'fileTree') {
$varValue = deserialize($varValue);
if (!is_array($varValue)) {
$varValue = \StringUtil::binToUuid($varValue);
} else {
$varValue = serialize(array_map('StringUtil::binToUuid', $varValue));
}
}
// Convert date formats into timestamps
if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) {
$objDate = new \Date($varValue, \Date::getFormatFromRgxp($arrData['eval']['rgxp']));
$varValue = $objDate->tstamp;
}
// Handle entities
if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea') {
$varValue = deserialize($varValue);
if (!is_array($varValue)) {
$varValue = \StringUtil::restoreBasicEntities($varValue);
} else {
$varValue = serialize(array_map('StringUtil::restoreBasicEntities', $varValue));
}
}
}
// Trigger the save_callback
if (is_array($arrData['save_callback'])) {
foreach ($arrData['save_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this);
} elseif (is_callable($callback)) {
$varValue = $callback($varValue, $this);
}
}
}
$strCurrent = $this->varValue;
// Handle arrays and strings
if (is_array($strCurrent)) {
$strCurrent = serialize($strCurrent);
} elseif (is_string($strCurrent)) {
$strCurrent = html_entity_decode($this->varValue, ENT_QUOTES, \Config::get('characterSet'));
}
// Save the value if there was no error
if ((strlen($varValue) || !$arrData['eval']['doNotSaveEmpty']) && $strCurrent != $varValue) {
\Config::persist($this->strField, $varValue);
$deserialize = deserialize($varValue);
$prior = is_bool(\Config::get($this->strField)) ? \Config::get($this->strField) ? 'true' : 'false' : \Config::get($this->strField);
// Add a log entry
if (!is_array(deserialize($prior)) && !is_array($deserialize)) {
if ($arrData['inputType'] == 'password' || $arrData['inputType'] == 'textStore') {
$this->log('The global configuration variable "' . $this->strField . '" has been changed', __METHOD__, TL_CONFIGURATION);
} else {
$this->log('The global configuration variable "' . $this->strField . '" has been changed from "' . $prior . '" to "' . $varValue . '"', __METHOD__, TL_CONFIGURATION);
}
}
// Set the new value so the input field can show it
$this->varValue = $deserialize;
\Config::set($this->strField, $deserialize);
}
}
示例11: implodeRecursive
/**
* Implode a multi-dimensional array recursively
*
* @param mixed $var
* @param boolean $binary
*
* @return string
*/
protected function implodeRecursive($var, $binary = false)
{
if (!is_array($var)) {
return $binary ? \StringUtil::binToUuid($var) : $var;
} elseif (!is_array(current($var))) {
return implode(', ', $binary ? array_map('StringUtil::binToUuid', $var) : $var);
} else {
$buffer = '';
foreach ($var as $k => $v) {
$buffer .= $k . ": " . $this->implodeRecursive($v) . "\n";
}
return trim($buffer);
}
}
示例12: binToUuid
/**
* @param $value
* @return string
*/
public static function binToUuid($value)
{
// Convert bin to uuid
if (\Validator::isBinaryUuid($value)) {
return \StringUtil::binToUuid($value);
}
return $value;
}
示例13: 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] = \StringUtil::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 \StringUtil::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;
}
示例14: parse
/**
* Generate the widget and return it as string
* @param array
* @return string
*/
public function parse($arrAttributes = null)
{
if (!$this->blnValuesPrepared) {
$arrSet = array();
$arrValues = array();
$arrUuids = array();
$arrTemp = array();
if (!empty($this->varValue)) {
// Can be an array
$this->varValue = (array) $this->varValue;
foreach ($this->varValue as $varFile) {
if (\Validator::isUuid($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;
}
}
}
// 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->values = $arrValues;
$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;
$this->blnValuesPrepared = true;
}
return parent::parse($arrAttributes);
}
示例15: addContextTokens
/**
*
* 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;
}
}
}
}
}