当前位置: 首页>>代码示例>>PHP>>正文


PHP String::binToUuid方法代码示例

本文整理汇总了PHP中String::binToUuid方法的典型用法代码示例。如果您正苦于以下问题:PHP String::binToUuid方法的具体用法?PHP String::binToUuid怎么用?PHP String::binToUuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String::binToUuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 protected function __construct()
 {
     $this->strIp = !\Config::get('disableIpCheck') ? \Environment::get('ip') : '';
     $this->strName = FE_USER_LOGGED_IN ? WATCHLIST_SESSION_FE : WATCHLIST_SESSION_BE;
     $this->strHash = sha1(session_id() . $this->strIp . $this->strName);
     if (($this->objModel = WatchlistModel::findByHashAndName($this->strHash, $this->strName)) === null) {
         $this->objModel = new WatchlistModel();
         $this->objModel->hash = $this->strHash;
         $this->objModel->name = $this->strName;
         $this->objModel->tstamp = time();
         $this->objModel->pid = \FrontendUser::getInstance()->id;
         $this->objModel->sessionID = session_id();
         $this->objModel->ip = $this->strIp;
         $this->objModel->save();
     }
     $objItems = WatchlistItemModel::findBy('pid', $this->objModel->id);
     if ($objItems !== null) {
         while ($objItems->next()) {
             // set key by unique uuid
             $strKey = \String::binToUuid($objItems->uuid);
             $this->arrItems[$strKey] = $objItems->current();
             $this->arrIds[] = $strKey;
         }
     }
 }
开发者ID:heimrichhannot,项目名称:contao-watchlist,代码行数:25,代码来源:Watchlist.php

示例2: 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;
 }
开发者ID:heimrichhannot,项目名称:contao-submissions,代码行数:11,代码来源:Submissions.php

示例3: generateEditActions

 public function generateEditActions(WatchlistItemModel $objItem, Watchlist $objWatchlist)
 {
     $objPage = \PageModel::findByPk($objItem->pageID);
     if ($objPage === null) {
         return;
     }
     $objT = new \FrontendTemplate('watchlist_edit_actions');
     $objT->delHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_DELETE . '&id=' . \String::binToUuid($objItem->uuid) . '&title=' . urlencode($objItem->title));
     $objT->delTitle = $GLOBALS['TL_LANG']['WATCHLIST']['delTitle'];
     $objT->delLink = $GLOBALS['TL_LANG']['WATCHLIST']['delLink'];
     $objT->id = \String::binToUuid($objItem->uuid);
     return $objT->parse();
 }
开发者ID:heimrichhannot,项目名称:contao-watchlist,代码行数:13,代码来源:WatchlistItemDefault.php

示例4: 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;
 }
开发者ID:fritzmg,项目名称:contao-filepicker-uuid,代码行数:24,代码来源:FilepickerUuid.php

示例5: validator

 /**
  * 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;
 }
开发者ID:revision6,项目名称:contao-avatar,代码行数:24,代码来源:FormAvatar.php

示例6: parse

 /**
  * 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);
 }
开发者ID:kikmedia,项目名称:contao-fineuploader,代码行数:66,代码来源:FineUploaderWidget.php

示例7: saveFile

 /**
  * Save path in file, not a uuid by save dca
  *
  * @param
  *        	uuid
  */
 public function saveFile($value)
 {
     return strlen($value) == 16 ? \String::binToUuid($value) : $value;
 }
开发者ID:bziemons,项目名称:contao-avatar,代码行数:10,代码来源:AvatarBackend.php

示例8: 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->efgImageUseHomeDir && 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, true);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     foreach ($this->multiSRC as $k => $v) {
         if (\Validator::isUuid($v)) {
             if (strlen($v) == 16) {
                 $this->multiSRC[$k] = \String::binToUuid($v);
             }
         }
     }
     // 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();
 }
开发者ID:Jobu,项目名称:core,代码行数:36,代码来源:EfgFormGallery.php

示例9: run

 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     if ($this->strFile == '') {
         die('No file given');
     }
     // Make sure there are no attempts to hack the file system
     if (preg_match('@^\\.+@i', $this->strFile) || preg_match('@\\.+/@i', $this->strFile) || preg_match('@(://)+@i', $this->strFile)) {
         die('Invalid file name');
     }
     // Limit preview to the files directory
     if (!preg_match('@^' . preg_quote(Config::get('uploadPath'), '@') . '@i', $this->strFile)) {
         die('Invalid path');
     }
     // Check whether the file exists
     if (!file_exists(TL_ROOT . '/' . $this->strFile)) {
         die('File not found');
     }
     // Check whether the file is mounted (thanks to Marko Cupic)
     if (!$this->User->hasAccess($this->strFile, 'filemounts')) {
         die('Permission denied');
     }
     // Open the download dialogue
     if (Input::get('download')) {
         $objFile = new File($this->strFile, true);
         $objFile->sendToBrowser();
     }
     // Add the resource (see #6880)
     if (($objModel = FilesModel::findByPath($this->strFile)) === null) {
         $objModel = Dbafs::addResource($this->strFile);
     }
     $this->Template = new BackendTemplate('be_popup');
     $this->Template->uuid = String::binToUuid($objModel->uuid);
     // see #5211
     // Add the file info
     if (is_dir(TL_ROOT . '/' . $this->strFile)) {
         $objFile = new Folder($this->strFile, true);
     } else {
         $objFile = new File($this->strFile, true);
         // Image
         if ($objFile->isGdImage) {
             $this->Template->isImage = true;
             $this->Template->width = $objFile->width;
             $this->Template->height = $objFile->height;
             $this->Template->src = $this->urlEncode($this->strFile);
         }
         $this->Template->href = ampersand(Environment::get('request'), true) . '&amp;download=1';
         $this->Template->filesize = $this->getReadableSize($objFile->filesize) . ' (' . number_format($objFile->filesize, 0, $GLOBALS['TL_LANG']['MSC']['decimalSeparator'], $GLOBALS['TL_LANG']['MSC']['thousandsSeparator']) . ' Byte)';
     }
     $this->Template->icon = $objFile->icon;
     $this->Template->mime = $objFile->mime;
     $this->Template->ctime = Date::parse(Config::get('datimFormat'), $objFile->ctime);
     $this->Template->mtime = Date::parse(Config::get('datimFormat'), $objFile->mtime);
     $this->Template->atime = Date::parse(Config::get('datimFormat'), $objFile->atime);
     $this->Template->path = $this->strFile;
     $this->output();
 }
开发者ID:iCodr8,项目名称:core,代码行数:59,代码来源:popup.php

示例10: validate


//.........这里部分代码省略.........
             $this->log('File "' . $file['name'] . '" could not be uploaded (error ' . $file['error'] . ')', __METHOD__, TL_ERROR);
         }
         unset($_FILES[$this->strName]);
         return;
     }
     // File is too big
     if ($this->maxlength > 0 && $file['size'] > $this->maxlength) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb));
         $this->log('File "' . $file['name'] . '" exceeds the maximum file size of ' . $maxlength_kb, __METHOD__, TL_ERROR);
         unset($_FILES[$this->strName]);
         return;
     }
     $strExtension = pathinfo($file['name'], PATHINFO_EXTENSION);
     $uploadTypes = trimsplit(',', $this->extensions);
     // File type is not allowed
     if (!in_array(strtolower($strExtension), $uploadTypes)) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $strExtension));
         $this->log('File type "' . $strExtension . '" is not allowed to be uploaded (' . $file['name'] . ')', __METHOD__, TL_ERROR);
         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')));
             $this->log('File "' . $file['name'] . '" exceeds the maximum image width of ' . \Config::get('imageWidth') . ' pixels', __METHOD__, TL_ERROR);
             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')));
             $this->log('File "' . $file['name'] . '" exceeds the maximum image height of ' . \Config::get('imageHeight') . ' pixels', __METHOD__, TL_ERROR);
             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];
         $this->log('File "' . $file['name'] . '" uploaded successfully', __METHOD__, TL_FILES);
         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;
                     $pathinfo = pathinfo($file['name']);
                     $name = $pathinfo['filename'];
                     $arrAll = scan(TL_ROOT . '/' . $strUploadFolder);
                     $arrFiles = preg_grep('/^' . preg_quote($name, '/') . '.*\\.' . preg_quote($pathinfo['extension'], '/') . '/', $arrAll);
                     foreach ($arrFiles as $strFile) {
                         if (preg_match('/__[0-9]+\\.' . preg_quote($pathinfo['extension'], '/') . '$/', $strFile)) {
                             $strFile = str_replace('.' . $pathinfo['extension'], '', $strFile);
                             $intValue = intval(substr($strFile, strrpos($strFile, '_') + 1));
                             $offset = max($offset, $intValue);
                         }
                     }
                     $file['name'] = str_replace($name, $name . '__' . ++$offset, $file['name']);
                 }
                 $this->Files->move_uploaded_file($file['tmp_name'], $strUploadFolder . '/' . $file['name']);
                 $this->Files->chmod($strUploadFolder . '/' . $file['name'], \Config::get('defaultFileChmod'));
                 // Generate the DB entries
                 $strFile = $strUploadFolder . '/' . $file['name'];
                 $objFile = \FilesModel::findByPath($strFile);
                 // Existing file is being replaced (see #4818)
                 if ($objFile !== null) {
                     $objFile->tstamp = time();
                     $objFile->path = $strFile;
                     $objFile->hash = md5_file(TL_ROOT . '/' . $strFile);
                     $objFile->save();
                 } else {
                     $objFile = \Dbafs::addResource($strFile);
                 }
                 // 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' => \String::binToUuid($objFile->uuid));
                 // Add a log entry
                 $this->log('File "' . $file['name'] . '" has been moved to "' . $strUploadFolder . '"', __METHOD__, TL_FILES);
             }
         }
     }
     unset($_FILES[$this->strName]);
 }
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:FormFileUpload.php

示例11: generate

    /**
     * Generate the widget and return it as string
     *
     * @return string
     */
    public function generate()
    {
        $arrSet = array();
        $arrValues = array();
        $blnHasOrder = $this->strOrderField != '' && is_array($this->{$this->strOrderField});
        $arrImage = deserialize($GLOBALS['TL_CONFIG']['avatar_maxdims']);
        if (!empty($this->varValue)) {
            $objFiles = \FilesModel::findMultipleByUuids((array) $this->varValue);
            $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
            if ($objFiles !== null) {
                while ($objFiles->next()) {
                    // File system and database seem not in sync
                    if (!file_exists(TL_ROOT . '/' . $objFiles->path)) {
                        continue;
                    }
                    $arrSet[] = $objFiles->uuid;
                    if ($objFiles->type == 'folder') {
                        continue;
                    }
                    $objFile = new \File($objFiles->path, true);
                    $strInfo = $objFiles->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>';
                    $arrValues[$objFiles->uuid] = \Image::getHtml(\Image::get($objFiles->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"');
                }
            }
        }
        if (count($arrValues) === 0) {
            $objFile = \FilesModel::findById($GLOBALS['TL_CONFIG']['avatar_fallback_image']);
            $strInfo = $objFile->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>';
            $arrValues[$objFile->uuid] = \Image::getHtml(\Image::get($objFile->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"');
        }
        // Load the fonts for the drag hint (see #4838)
        $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true;
        // Convert the binary UUIDs
        $strSet = implode(',', array_map('String::binToUuid', $arrSet));
        $strOrder = $blnHasOrder ? implode(',', array_map('String::binToUuid', $this->{$this->strOrderField})) : '';
        $return = '<input type="hidden" name="' . $this->strName . '" id="ctrl_' . $this->strId . '" value="' . $strSet . '">' . ($blnHasOrder ? '
<input type="hidden" name="' . $this->strOrderName . '" id="ctrl_' . $this->strOrderId . '" value="' . $strOrder . '">' : '') . '
<div class="selector_container">' . ($blnHasOrder && count($arrValues) ? '
<p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . '
<ul id="sort_' . $this->strId . '" class="' . trim(($blnHasOrder ? 'sortable ' : '') . ($this->blnIsGallery ? 'sgallery' : '')) . '">';
        foreach ($arrValues as $k => $v) {
            $return .= $k ? '<li data-id="' . \String::binToUuid($k) . '">' . $v . '</li>' : '';
        }
        $return .= '</ul>
<p><a href="contao/file.php?do=' . \Input::get('do') . '&amp;table=' . $this->strTable . '&amp;field=' . $this->strField . '&amp;act=show&amp;id=' . \Input::get('id') . '&amp;value=' . $strSet . '&amp;rt=' . REQUEST_TOKEN . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\'' . specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['filepicker'])) . '\',\'url\':this.href,\'id\':\'' . $this->strId . '\'});return false">' . $GLOBALS['TL_LANG']['MSC']['changeSelection'] . '</a></p>' . ($blnHasOrder ? '
<script>Backend.makeMultiSrcSortable("sort_' . $this->strId . '", "ctrl_' . $this->strOrderId . '")</script>' : '') . '
</div>';
        if (!\Environment::get('isAjaxRequest')) {
            $return = '<div>' . $return . '</div>';
        }
        return $return;
    }
开发者ID:bziemons,项目名称:contao-avatar,代码行数:57,代码来源:AvatarFileUpload.php

示例12: prepareSerialize

 /**
  * 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;
 }
开发者ID:netzmacht,项目名称:contao-workflow,代码行数:18,代码来源:StateRepository.php

示例13: convertValuesToMetaModels

 /**
  * Convert an array of values stored in the database (array of bin uuid) to a value to be handled by MetaModels.
  *
  * The output array will have the following layout:
  * array(
  *   'bin'   => array() // list of the binary ids.
  *   'value' => array() // list of the uuids.
  *   'path' => array() // list of the paths.
  * )
  *
  * @param array $values The binary uuid values to convert.
  *
  * @return array
  *
  * @throws \InvalidArgumentException When the input array is invalid.
  */
 public static function convertValuesToMetaModels($values)
 {
     if (!is_array($values)) {
         throw new \InvalidArgumentException('Invalid uuid list.');
     }
     $result = array('bin' => array(), 'value' => array(), 'path' => array());
     $models = \FilesModel::findMultipleByUuids(array_filter($values));
     if ($models === null) {
         return $result;
     }
     foreach ($models as $value) {
         $result['bin'][] = $value->uuid;
         $result['value'][] = \String::binToUuid($value->uuid);
         $result['path'][] = $value->path;
     }
     return $result;
 }
开发者ID:zonky2,项目名称:core,代码行数:33,代码来源:ToolboxFile.php

示例14: getFilePath

 protected function getFilePath($file)
 {
     $uuid = \String::binToUuid($file);
     $objFile = \FilesModel::findByUuid($uuid);
     return \Environment::get('base') . $objFile->path;
 }
开发者ID:contao2app,项目名称:contao2app,代码行数:6,代码来源:c2aFrontend.php

示例15: generate


//.........这里部分代码省略.........
                               $image = 'placeholder.png';
                               if ($objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) {
                                   $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->isGdImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
                               if ($this->isGallery) {
                                   // Only show images
                                   if ($objFile->isGdImage) {
                                       $image = 'placeholder.png';
                                       if ($objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) {
                                           $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->isGdImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
                           if ($this->isGallery) {
                               // Only show images
                               if ($objFile->isGdImage) {
                                   $image = 'placeholder.png';
                                   if ($objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) {
                                       $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 ($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('String::binToUuid', $arrSet));
       $strOrder = $blnHasOrder ? implode(',', array_map('String::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="' . \String::binToUuid($k) . '">' . $v . '</li>';
       }
       $return .= '</ul>
   <p><a href="contao/file.php?do=' . \Input::get('do') . '&amp;table=' . $this->strTable . '&amp;field=' . $this->strField . '&amp;act=show&amp;id=' . $this->activeRecord->id . '&amp;value=' . implode(',', array_keys($arrSet)) . '&amp;rt=' . REQUEST_TOKEN . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':768,\'title\':\'' . specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['filepicker'])) . '\',\'url\':this.href,\'id\':\'' . $this->strId . '\'});return false">' . $GLOBALS['TL_LANG']['MSC']['changeSelection'] . '</a></p>' . ($blnHasOrder ? '
   <script>Backend.makeMultiSrcSortable("sort_' . $this->strId . '", "ctrl_' . $this->strOrderId . '")</script>' : '') . '
 </div>';
       if (!\Environment::get('isAjaxRequest')) {
           $return = '<div>' . $return . '</div>';
       }
       return $return;
   }
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:FileTree.php


注:本文中的String::binToUuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。