本文整理汇总了PHP中FilesModel::findMultipleByUuids方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesModel::findMultipleByUuids方法的具体用法?PHP FilesModel::findMultipleByUuids怎么用?PHP FilesModel::findMultipleByUuids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilesModel
的用法示例。
在下文中一共展示了FilesModel::findMultipleByUuids方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Return if there are no files
*
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->multiSRC = array($this->User->homeDir);
}
} else {
$this->multiSRC = deserialize($this->multiSRC);
}
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
return parent::generate();
}
示例2: getFiles
/**
* Collect all Songs per Playlist and return them as array
*
* @param object $objSongs
* @return array
*/
public function getFiles($objSongs)
{
$arrFiles = array();
$i = 0;
if ($objSongs === null) {
return;
}
while ($objSongs->next()) {
$arrSong = $objSongs->row();
$arrFiles[$i]['protected'] = $arrSong['protected'];
$arrFiles[$i]['groups'] = $arrSong['groups'];
$arrFiles[$i]['id'] = $arrSong['id'];
$arrFiles[$i]['interpreter'] = $arrSong['interpreter'];
$arrFiles[$i]['title'] = $arrSong['title'];
$arrFiles[$i]['album'] = $arrSong['album'];
$arrFiles[$i]['track'] = $arrSong['track'];
$arrFiles[$i]['files'] = array();
$arrUuids = deserialize($arrSong['file']);
$objSongFiles = \FilesModel::findMultipleByUuids($arrUuids);
while ($objSongFiles->next()) {
$arrSongFile = $objSongFiles->row();
$objFile = new \Contao\File($arrSongFile['path'], true);
$arrFiles[$i]['files'][] = array('file' => $arrSongFile['path'], 'type' => $objFile->mime);
}
$i++;
}
// sort out protected songs
$arrFiles = $this->sortOutProtected($arrFiles);
return $arrFiles;
}
示例3: generate
/**
* Return if there are no files
*
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->multiSRC = array($this->User->homeDir);
}
} else {
$this->multiSRC = deserialize($this->multiSRC);
}
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
while ($this->objFiles->next()) {
if ($file == $this->objFiles->path || dirname($file) == $this->objFiles->path) {
\Controller::sendFileToBrowser($file);
}
}
$this->objFiles->reset();
}
return parent::generate();
}
示例4: getAttachments
public function getAttachments()
{
// Token attachments
$arrAttachments = StringUtil::getTokenAttachments($this->objLanguage->attachment_tokens, $this->arrTokens);
// Add static attachments
$arrStaticAttachments = deserialize($this->objLanguage->attachments, true);
if (!empty($arrStaticAttachments)) {
$objFiles = \FilesModel::findMultipleByUuids($arrStaticAttachments);
if ($objFiles === null) {
return $arrAttachments;
}
while ($objFiles->next()) {
$arrAttachments[] = TL_ROOT . '/' . $objFiles->path;
}
}
return $arrAttachments;
}
示例5: getAllImages
/**
* @param $multiSRC
*/
public function getAllImages($multiSRC)
{
$this->multiSRC = $multiSRC;
$arrMultiSRC = $multiSRC ? deserialize($multiSRC) : array();
if (!$this->objFiles && is_array($arrMultiSRC)) {
$this->objFiles = \FilesModel::findMultipleByUuids($arrMultiSRC);
}
}
示例6: generate
/**
* Check the source folder
*
* @return string
*/
public function generate()
{
$this->multiSRC = deserialize($this->multiSRC);
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
return '';
}
return parent::generate();
}
示例7: compile
/**
* Generate the content element
*/
public function compile()
{
$newMultiSRC = array();
if (strlen(\Input::get('tag')) && !$this->tag_ignore || strlen($this->tag_filter)) {
$tagids = array();
$relatedlist = strlen(\Input::get('related')) ? preg_split("/,/", \Input::get('related')) : array();
$alltags = array_merge(array(\Input::get('tag')), $relatedlist);
$first = true;
if (strlen($this->tag_filter)) {
$headlinetags = preg_split("/,/", $this->tag_filter);
$tagids = $this->getFilterTags();
$first = false;
} else {
$headlinetags = array();
}
foreach ($alltags as $tag) {
if (strlen(trim($tag))) {
if (count($tagids)) {
$tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ? AND tid IN (" . join($tagids, ",") . ")")->execute('tl_files', $tag)->fetchEach('tid');
} else {
if ($first) {
$tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ?")->execute('tl_files', $tag)->fetchEach('tid');
$first = false;
}
}
}
}
while ($this->objFiles->next()) {
if ($this->objFiles->type == 'file') {
if (in_array($this->objFiles->id, $tagids)) {
array_push($newMultiSRC, $this->objFiles->uuid);
}
} else {
$objSubfiles = \FilesModel::findByPid($this->objFiles->uuid);
if ($objSubfiles === null) {
continue;
}
while ($objSubfiles->next()) {
if (in_array($objSubfiles->id, $tagids)) {
array_push($newMultiSRC, $objSubfiles->uuid);
}
}
}
}
$this->multiSRC = $newMultiSRC;
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
return '';
}
}
parent::compile();
}
示例8: generate
/**
* Check the source folder
* @return string
*/
public function generate()
{
$this->multiSRC = deserialize($this->multiSRC);
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
return parent::generate();
}
示例9: generate
public function generate(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular)
{
if (TL_MODE == 'BE') {
return;
}
$this->objPageBg = $this->searchForBackgroundImages($objPage);
// Return if there are no files
if (!$this->objPageBg) {
return;
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->objPageBg->paSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->objPageBg->paSRC[0])) {
\System::log($GLOBALS['TL_LANG']['ERR']['version2format'], __METHOD__, TL_ERROR);
}
return;
}
$this->order = $this->objPageBg->paOrder;
$this->compile($objPage);
}
示例10: getMultiMetaData
private function getMultiMetaData($multiSRC)
{
global $objPage;
$images = array();
$objFiles = \FilesModel::findMultipleByUuids(unserialize($multiSRC));
if ($objFiles !== null) {
while ($objFiles->next()) {
// Continue if the files has been processed or does not exist
if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
continue;
}
// Single files
if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path, true);
if (!$objFile->isGdImage) {
continue;
}
$images[$objFiles->path] = $this->getMetaData($objFiles->meta, $objPage->language);
} else {
$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);
if (!$objFile->isGdImage) {
continue;
}
$images[$objFile->path] = $this->getMetaData($objSubfiles->meta, $objPage->language);
}
}
}
}
// END if($objFiles !== null)
return $images;
}
示例11: generate
/**
* Return if there are no files
*
* @return string
*/
public function generate()
{
$this->multiSRC = deserialize($this->dk_msryMultiSRC);
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
return '';
}
// replace default (HTML) template with chosen one
if ($this->dk_msryHtmlTpl) {
$this->strTemplate = $this->dk_msryHtmlTpl;
}
// replace default (JS) template with chosen one
if ($this->dk_msryJsTpl) {
$this->strTemplateJs = $this->dk_msryJsTpl;
}
return parent::generate();
}
示例12: parentView
/**
* Show header of the parent table and list all records of the current table
*
* @return string
*/
protected function parentView()
{
$blnClipboard = false;
$arrClipboard = $this->Session->get('CLIPBOARD');
$table = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6 ? $this->ptable : $this->strTable;
$blnHasSorting = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['fields'][0] == 'sorting';
$blnMultiboard = false;
// Check clipboard
if (!empty($arrClipboard[$table])) {
$blnClipboard = true;
$arrClipboard = $arrClipboard[$table];
if (is_array($arrClipboard['id'])) {
$blnMultiboard = true;
}
}
// Load the fonts to display the paste hint
\Config::set('loadGoogleFonts', $blnClipboard);
// Load the language file and data container array of the parent table
\System::loadLanguageFile($this->ptable);
$this->loadDataContainer($this->ptable);
$return = '
<div id="tl_buttons">' . (\Input::get('nb') ? ' ' : ($this->ptable ? '
<a href="' . $this->getReferer(true, $this->ptable) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>' : (isset($GLOBALS['TL_DCA'][$this->strTable]['config']['backlink']) ? '
<a href="contao/main.php?' . $GLOBALS['TL_DCA'][$this->strTable]['config']['backlink'] . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>' : ''))) . ' ' . (\Input::get('act') != 'select' && !$blnClipboard && !$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'] ? '
<a href="' . $this->addToUrl($blnHasSorting ? 'act=paste&mode=create' : 'act=create&mode=2&pid=' . $this->intId) . '" class="header_new" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['new'][1]) . '" accesskey="n" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG'][$this->strTable]['new'][0] . '</a> ' : '') . ($blnClipboard ? '
<a href="' . $this->addToUrl('clipboard=1') . '" class="header_clipboard" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['clearClipboard']) . '" accesskey="x">' . $GLOBALS['TL_LANG']['MSC']['clearClipboard'] . '</a> ' : $this->generateGlobalButtons()) . '
</div>' . \Message::generate(true);
// Get all details of the parent record
$objParent = $this->Database->prepare("SELECT * FROM " . $this->ptable . " WHERE id=?")->limit(1)->execute(CURRENT_ID);
if ($objParent->numRows < 1) {
return $return;
}
$return .= (\Input::get('act') == 'select' ? '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_select" class="tl_form' . (\Input::get('act') == 'select' ? ' unselectable' : '') . '" method="post" novalidate>
<div class="tl_formbody">
<input type="hidden" name="FORM_SUBMIT" value="tl_select">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">' : '') . ($blnClipboard ? '
<div id="paste_hint">
<p>' . $GLOBALS['TL_LANG']['MSC']['selectNewPosition'] . '</p>
</div>' : '') . '
<div class="tl_listing_container parent_view">
<div class="tl_header click2edit toggle_select" onmouseover="Theme.hoverDiv(this,1)" onmouseout="Theme.hoverDiv(this,0)">';
// List all records of the child table
if (!\Input::get('act') || \Input::get('act') == 'paste' || \Input::get('act') == 'select') {
$this->import('BackendUser', 'User');
// Header
$imagePasteNew = \Image::getHtml('new.gif', $GLOBALS['TL_LANG'][$this->strTable]['pastenew'][0]);
$imagePasteAfter = \Image::getHtml('pasteafter.gif', $GLOBALS['TL_LANG'][$this->strTable]['pasteafter'][0]);
$imageEditHeader = \Image::getHtml('header.gif', $GLOBALS['TL_LANG'][$this->strTable]['editheader'][0]);
$return .= '
<div class="tl_content_right">' . (\Input::get('act') == 'select' ? '
<label for="tl_select_trigger" class="tl_select_label">' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</label> <input type="checkbox" id="tl_select_trigger" onclick="Backend.toggleCheckboxes(this)" class="tl_tree_checkbox">' : ($blnClipboard ? ' <a href="' . $this->addToUrl('act=' . $arrClipboard['mode'] . '&mode=2&pid=' . $objParent->id . (!$blnMultiboard ? '&id=' . $arrClipboard['id'] : '')) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['pasteafter'][0]) . '" onclick="Backend.getScrollOffset()">' . $imagePasteAfter . '</a>' : (!$GLOBALS['TL_DCA'][$this->ptable]['config']['notEditable'] && $this->User->canEditFieldsOf($this->ptable) ? '
<a href="' . preg_replace('/&(amp;)?table=[^& ]*/i', $this->ptable != '' ? '&table=' . $this->ptable : '', $this->addToUrl('act=edit')) . '" class="edit" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['editheader'][1]) . '">' . $imageEditHeader . '</a>' : '') . ($blnHasSorting && !$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'] ? ' <a href="' . $this->addToUrl('act=create&mode=2&pid=' . $objParent->id . '&id=' . $this->intId) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['pastenew'][0]) . '">' . $imagePasteNew . '</a>' : ''))) . '
</div>';
// Format header fields
$add = array();
$headerFields = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['headerFields'];
foreach ($headerFields as $v) {
$_v = deserialize($objParent->{$v});
// Translate UUIDs to paths
if ($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['inputType'] == 'fileTree') {
$objFiles = \FilesModel::findMultipleByUuids((array) $_v);
if ($objFiles !== null) {
$_v = $objFiles->fetchEach('path');
}
}
if (is_array($_v)) {
$_v = implode(', ', $_v);
} elseif ($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['eval']['multiple']) {
$_v = $_v != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no'];
} elseif ($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['eval']['rgxp'] == 'date') {
$_v = $_v ? \Date::parse(\Config::get('dateFormat'), $_v) : '-';
} elseif ($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['eval']['rgxp'] == 'time') {
$_v = $_v ? \Date::parse(\Config::get('timeFormat'), $_v) : '-';
} elseif ($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['eval']['rgxp'] == 'datim') {
$_v = $_v ? \Date::parse(\Config::get('datimFormat'), $_v) : '-';
} elseif ($v == 'tstamp') {
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dynamicPtable']) {
$ptable = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'];
$cond = $ptable == 'tl_article' ? "(ptable=? OR ptable='')" : "ptable=?";
// backwards compatibility
$objMaxTstamp = $this->Database->prepare("SELECT MAX(tstamp) AS tstamp FROM " . $this->strTable . " WHERE pid=? AND {$cond}")->execute($objParent->id, $ptable);
} else {
$objMaxTstamp = $this->Database->prepare("SELECT MAX(tstamp) AS tstamp FROM " . $this->strTable . " WHERE pid=?")->execute($objParent->id);
}
if (!$objMaxTstamp->tstamp) {
$objMaxTstamp->tstamp = $objParent->tstamp;
}
$_v = \Date::parse(\Config::get('datimFormat'), max($objParent->tstamp, $objMaxTstamp->tstamp));
} elseif (isset($GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['foreignKey'])) {
$arrForeignKey = explode('.', $GLOBALS['TL_DCA'][$this->ptable]['fields'][$v]['foreignKey'], 2);
//.........这里部分代码省略.........
示例13: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrSet = array();
$arrValues = array();
$blnHasOrder = $this->orderField != '' && is_array($this->{$this->orderField});
if (!empty($this->varValue)) {
$objFiles = \FilesModel::findMultipleByUuids((array) $this->varValue);
$allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
if ($objFiles !== null) {
while ($objFiles->next()) {
// File system and database seem not in sync
if (!file_exists(TL_ROOT . '/' . $objFiles->path)) {
continue;
}
$arrSet[$objFiles->id] = $objFiles->uuid;
// Show files and folders
if (!$this->isGallery && !$this->isDownloads) {
if ($objFiles->type == 'folder') {
$arrValues[$objFiles->uuid] = \Image::getHtml('folderC.gif') . ' ' . $objFiles->path;
} else {
$objFile = new \File($objFiles->path, true);
$strInfo = $objFiles->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
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 {
$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;
//.........这里部分代码省略.........
示例14: generate
/**
* {@inheritdoc}
*/
public function generate()
{
$values = array();
$icons = array();
if (!empty($this->varValue)) {
$files = \FilesModel::findMultipleByUuids((array) $this->varValue);
$this->renderList($icons, $files, $this->isGallery || $this->isDownloads);
$icons = $this->applySorting($icons);
// PHP 7 compatibility, see https://github.com/contao/core-bundle/issues/309
if (version_compare(VERSION . '.' . BUILD, '3.5.5', '>=')) {
$mapFunc = 'StringUtil::binToUuid';
} else {
$mapFunc = 'String::binToUuid';
}
foreach ($files as $model) {
$values[] = call_user_func($mapFunc, $model->uuid);
}
}
$template = new ContaoBackendViewTemplate($this->subTemplate);
$buffer = $template->setTranslator($this->getEnvironment()->getTranslator())->set('name', $this->strName)->set('id', $this->strId)->set('value', implode(',', $values))->set('hasOrder', $this->orderField != '' && is_array($this->orderFieldValue))->set('icons', $icons)->set('isGallery', $this->isGallery)->set('orderId', $this->orderId)->set('link', $this->generateLink($values))->parse();
if (!\Environment::get('isAjaxRequest')) {
$buffer = '<div>' . $buffer . '</div>';
}
return $buffer;
}
示例15: setUserFromDb
/**
* Set all user properties from a database record
*/
protected function setUserFromDb()
{
$this->intId = $this->id;
// Unserialize values
foreach ($this->arrData as $k => $v) {
if (!is_numeric($v)) {
$this->{$k} = deserialize($v);
}
}
$GLOBALS['TL_USERNAME'] = $this->username;
$GLOBALS['TL_LANGUAGE'] = str_replace('_', '-', $this->language);
\Config::set('showHelp', $this->showHelp);
\Config::set('useRTE', $this->useRTE);
\Config::set('useCE', $this->useCE);
\Config::set('thumbnails', $this->thumbnails);
\Config::set('backendTheme', $this->backendTheme);
// Inherit permissions
$always = array('alexf');
$depends = array('modules', 'themes', 'pagemounts', 'alpty', 'filemounts', 'fop', 'forms', 'formp');
// HOOK: Take custom permissions
if (!empty($GLOBALS['TL_PERMISSIONS']) && is_array($GLOBALS['TL_PERMISSIONS'])) {
$depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
}
// Overwrite user permissions if only group permissions shall be inherited
if ($this->inherit == 'group') {
foreach ($depends as $field) {
$this->{$field} = array();
}
}
// Merge permissions
$inherit = in_array($this->inherit, array('group', 'extend')) ? array_merge($always, $depends) : $always;
$time = \Date::floorToMinute();
foreach ((array) $this->groups as $id) {
$objGroup = $this->Database->prepare("SELECT * FROM tl_user_group WHERE id=? AND disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "')")->limit(1)->execute($id);
if ($objGroup->numRows > 0) {
foreach ($inherit as $field) {
$value = deserialize($objGroup->{$field}, true);
// The new page/file picker can return integers instead of arrays, so use empty() instead of is_array() and deserialize(true) here
if (!empty($value)) {
$this->{$field} = array_merge(is_array($this->{$field}) ? $this->{$field} : ($this->{$field} != '' ? array($this->{$field}) : array()), $value);
$this->{$field} = array_unique($this->{$field});
}
}
}
}
// Restore session
if (is_array($this->session)) {
$this->Session->setData($this->session);
} else {
$this->session = array();
}
// Make sure pagemounts and filemounts are set!
if (!is_array($this->pagemounts)) {
$this->pagemounts = array();
} else {
$this->pagemounts = array_filter($this->pagemounts);
}
if (!is_array($this->filemounts)) {
$this->filemounts = array();
} else {
$this->filemounts = array_filter($this->filemounts);
}
// Store the numeric file mounts
$this->arrFilemountIds = $this->filemounts;
// Convert the file mounts into paths (backwards compatibility)
if (!$this->isAdmin && !empty($this->filemounts)) {
$objFiles = \FilesModel::findMultipleByUuids($this->filemounts);
if ($objFiles !== null) {
$this->filemounts = $objFiles->fetchEach('path');
}
}
}