當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IconUtility::getSpriteIconForResource方法代碼示例

本文整理匯總了PHP中TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForResource方法的典型用法代碼示例。如果您正苦於以下問題:PHP IconUtility::getSpriteIconForResource方法的具體用法?PHP IconUtility::getSpriteIconForResource怎麽用?PHP IconUtility::getSpriteIconForResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TYPO3\CMS\Backend\Utility\IconUtility的用法示例。


在下文中一共展示了IconUtility::getSpriteIconForResource方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: thumbCode

 /**
  * Returns a linked image-tag for thumbnail(s)/fileicons/truetype-font-previews from a database row with a list of image files in a field
  * All $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] extension are made to thumbnails + ttf file (renders font-example)
  * Thumbsnails are linked to the show_item.php script which will display further details.
  *
  * @param array $row Row is the database row from the table, $table.
  * @param string $table Table name for $row (present in TCA)
  * @param string $field Field is pointing to the list of image files
  * @param string $backPath Back path prefix for image tag src="" field
  * @param string $thumbScript Optional: $thumbScript - not used anymore since FAL
  * @param string $uploaddir Optional: $uploaddir is the directory relative to PATH_site where the image files from the $field value is found (Is by default set to the entry in $GLOBALS['TCA'] for that field! so you don't have to!)
  * @param boolean $abs If set, uploaddir is NOT prepended with "../
  * @param string $tparams Optional: $tparams is additional attributes for the image tags
  * @param integer $size Optional: $size is [w]x[h] of the thumbnail. 56 is default.
  * @param boolean $linkInfoPopup Whether to wrap with a link opening the info popup
  * @return string Thumbnail image tag.
  */
 public static function thumbCode($row, $table, $field, $backPath, $thumbScript = '', $uploaddir = NULL, $abs = 0, $tparams = '', $size = '', $linkInfoPopup = TRUE)
 {
     // Check and parse the size parameter
     $sizeParts = array(64, 64);
     if ($size = trim($size)) {
         $sizeParts = explode('x', $size . 'x' . $size);
         if (!(int) $sizeParts[0]) {
             $size = '';
         }
     }
     $thumbData = '';
     $fileReferences = static::resolveFileReferences($table, $field, $row);
     // FAL references
     if ($fileReferences !== NULL) {
         foreach ($fileReferences as $fileReferenceObject) {
             $fileObject = $fileReferenceObject->getOriginalFile();
             if ($fileObject->isMissing()) {
                 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                 $thumbData .= $flashMessage->render();
                 continue;
             }
             // Web image
             if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileReferenceObject->getExtension())) {
                 $imageUrl = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => $sizeParts[0], 'height' => $sizeParts[1]))->getPublicUrl(TRUE);
                 $imgTag = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($fileReferenceObject->getName()) . '" />';
             } else {
                 // Icon
                 $imgTag = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName()));
             }
             if ($linkInfoPopup) {
                 $onClick = 'top.launchView(\'_FILE\',\'' . $fileObject->getUid() . '\',\'' . $backPath . '\'); return false;';
                 $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $imgTag . '</a> ';
             } else {
                 $thumbData .= $imgTag;
             }
         }
     } else {
         // Find uploaddir automatically
         if (is_null($uploaddir)) {
             $uploaddir = $GLOBALS['TCA'][$table]['columns'][$field]['config']['uploadfolder'];
         }
         $uploaddir = rtrim($uploaddir, '/');
         // Traverse files:
         $thumbs = GeneralUtility::trimExplode(',', $row[$field], TRUE);
         $thumbData = '';
         foreach ($thumbs as $theFile) {
             if ($theFile) {
                 $fileName = trim($uploaddir . '/' . $theFile, '/');
                 try {
                     /** @var File $fileObject */
                     $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileName);
                     if ($fileObject->isMissing()) {
                         $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                         $thumbData .= $flashMessage->render();
                         continue;
                     }
                 } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $exception) {
                     /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
                     $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($exception->getMessage()), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                     $thumbData .= $flashMessage->render();
                     continue;
                 }
                 $fileExtension = $fileObject->getExtension();
                 if ($fileExtension == 'ttf' || GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
                     $imageUrl = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => $sizeParts[0], 'height' => $sizeParts[1]))->getPublicUrl(TRUE);
                     $image = '<img src="' . htmlspecialchars($imageUrl) . '" hspace="2" border="0" title="' . htmlspecialchars($fileObject->getName()) . '"' . $tparams . ' alt="" />';
                     if ($linkInfoPopup) {
                         $onClick = 'top.launchView(\'_FILE\', \'' . $fileName . '\',\'\',\'' . $backPath . '\');return false;';
                         $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $image . '</a> ';
                     } else {
                         $thumbData .= $image;
                     }
                 } else {
                     // Gets the icon
                     $fileIcon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName()));
                     if ($linkInfoPopup) {
                         $onClick = 'top.launchView(\'_FILE\', \'' . $fileName . '\',\'\',\'' . $backPath . '\'); return false;';
                         $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $fileIcon . '</a> ';
                     } else {
                         $thumbData .= $fileIcon;
                     }
                 }
             }
//.........這裏部分代碼省略.........
開發者ID:samuweiss,項目名稱:TYPO3-Site,代碼行數:101,代碼來源:BackendUtility.php

示例2: TBE_dragNDrop

    /**
     * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
     * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
     *
     * @param Folder $folder The folder path to expand
     * @param string $extensionList List of file extensions to show
     * @return string HTML output
     * @todo Define visibility
     */
    public function TBE_dragNDrop(Folder $folder, $extensionList = '')
    {
        if (!$folder) {
            return '';
        }
        if (!$folder->getStorage()->isPublic()) {
            // Print this warning if the folder is NOT a web folder
            return $this->barheader($GLOBALS['LANG']->getLL('files')) . $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
        }
        $out = '';
        // Read files from directory:
        $extensionList = $extensionList == '*' ? '' : $extensionList;
        $files = $this->getFilesInFolder($folder, $extensionList);
        $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
        $titleLen = (int) $GLOBALS['BE_USER']->uc['titleLen'];
        $picon = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
        $picon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
        $out .= $picon . '<br />';
        // Init row-array:
        $lines = array();
        // Add "drag-n-drop" message:
        $lines[] = '
			<tr>
				<td colspan="2">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td>
			</tr>';
        // Traverse files:
        foreach ($files as $fileObject) {
            $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
            // URL of image:
            $iUrl = GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
            // Show only web-images
            $fileExtension = strtolower($fileObject->getExtension());
            if (GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) {
                $imgInfo = array($fileObject->getProperty('width'), $fileObject->getProperty('height'));
                $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
                $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
                $filenameAndIcon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName() . $size));
                if (GeneralUtility::_GP('noLimit')) {
                    $maxW = 10000;
                    $maxH = 10000;
                } else {
                    $maxW = 380;
                    $maxH = 500;
                }
                $IW = $imgInfo[0];
                $IH = $imgInfo[1];
                if ($IW > $maxW) {
                    $IH = ceil($IH / $IW * $maxW);
                    $IW = $maxW;
                }
                if ($IH > $maxH) {
                    $IW = ceil($IW / $IH * $maxH);
                    $IH = $maxH;
                }
                // Make row:
                $lines[] = '
					<tr class="bgColor4">
						<td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
						<td nowrap="nowrap">' . ($imgInfo[0] != $IW ? '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('noLimit' => '1'))) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', TRUE) . '" alt="" />' . '</a>' : '') . $pDim . '&nbsp;</td>
					</tr>';
                $lines[] = '
					<tr>
						<td colspan="2"><img src="' . htmlspecialchars($iUrl) . '" data-htmlarea-file-uid="' . $fileObject->getUid() . '" width="' . htmlspecialchars($IW) . '" height="' . htmlspecialchars($IH) . '" border="1" alt="" /></td>
					</tr>';
                $lines[] = '
					<tr>
						<td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
					</tr>';
            }
        }
        // Finally, wrap all rows in a table tag:
        $out .= '


<!--
	File listing / Drag-n-drop
-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
				' . implode('', $lines) . '
			</table>';
        return $out;
    }
開發者ID:allipierre,項目名稱:Typo3,代碼行數:91,代碼來源:ElementBrowser.php

示例3: formatFileList

 /**
  * This returns tablerows for the files in the array $items['sorting'].
  *
  * @param File[] $files File items
  * @return string HTML table rows.
  */
 public function formatFileList(array $files)
 {
     $out = '';
     // first two keys are "0" (default) and "-1" (multiple), after that comes the "other languages"
     $allSystemLanguages = GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages();
     $systemLanguages = array_filter($allSystemLanguages, function ($languageRecord) {
         if ($languageRecord['uid'] === -1 || $languageRecord['uid'] === 0 || !$this->getBackendUser()->checkLanguageAccess($languageRecord['uid'])) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     foreach ($files as $fileObject) {
         // Initialization
         $this->counter++;
         $this->totalbytes += $fileObject->getSize();
         $ext = $fileObject->getExtension();
         $fileName = trim($fileObject->getName());
         // The icon with link
         $theIcon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileName . ' [' . (int) $fileObject->getUid() . ']'));
         if ($this->clickMenus) {
             $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
         }
         // Preparing and getting the data-array
         $theData = array();
         foreach ($this->fieldArray as $field) {
             switch ($field) {
                 case 'size':
                     $theData[$field] = GeneralUtility::formatSize($fileObject->getSize(), $this->getLanguageService()->getLL('byteSizeUnits', TRUE));
                     break;
                 case 'rw':
                     $theData[$field] = '' . (!$fileObject->checkActionPermission('read') ? ' ' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('read', TRUE) . '</strong>') . (!$fileObject->checkActionPermission('write') ? '' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('write', TRUE) . '</strong>');
                     break;
                 case 'fileext':
                     $theData[$field] = strtoupper($ext);
                     break;
                 case 'tstamp':
                     $theData[$field] = BackendUtility::date($fileObject->getModificationTime());
                     break;
                 case '_CONTROL_':
                     $theData[$field] = $this->makeEdit($fileObject);
                     break;
                 case '_CLIPBOARD_':
                     $theData[$field] = $this->makeClip($fileObject);
                     break;
                 case '_LOCALIZATION_':
                     if (!empty($systemLanguages) && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
                         $metaDataRecord = $fileObject->_getMetaData();
                         $translations = $this->getTranslationsForMetaData($metaDataRecord);
                         $languageCode = '';
                         foreach ($systemLanguages as $language) {
                             $languageId = $language['uid'];
                             $flagIcon = $language['flagIcon'];
                             if (array_key_exists($languageId, $translations)) {
                                 $flagButtonIcon = IconUtility::getSpriteIcon('actions-document-open', array('title' => sprintf($GLOBALS['LANG']->getLL('editMetadataForLanguage'), $language['title'])), array($flagIcon . '-overlay' => array()));
                                 $data = array('sys_file_metadata' => array($translations[$languageId]['uid'] => 'edit'));
                                 $editOnClick = BackendUtility::editOnClick(GeneralUtility::implodeArrayForUrl('edit', $data), $GLOBALS['BACK_PATH'], $this->listUrl());
                                 $languageCode .= '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '">' . $flagButtonIcon . '</a>';
                             } else {
                                 $parameters = ['justLocalized' => 'sys_file_metadata:' . $metaDataRecord['uid'] . ':' . $languageId, 'returnUrl' => $this->listURL()];
                                 $returnUrl = BackendUtility::getModuleUrl('record_edit', $parameters, $this->backPath) . BackendUtility::getUrlToken('editRecord');
                                 $href = $GLOBALS['SOBE']->doc->issueCommand('&cmd[sys_file_metadata][' . $metaDataRecord['uid'] . '][localize]=' . $languageId, $returnUrl);
                                 $flagButtonIcon = IconUtility::getSpriteIcon($flagIcon, array('title' => sprintf($GLOBALS['LANG']->getLL('createMetadataForLanguage'), $language['title'])), array($flagIcon . '-overlay' => array()));
                                 $languageCode .= '<a href="' . htmlspecialchars($href) . '" class="btn btn-default">' . $flagButtonIcon . '</a> ';
                             }
                         }
                         // Hide flag button bar when not translated yet
                         $theData[$field] = ' <div class="localisationData btn-group" data-fileid="' . $fileObject->getUid() . '"' . (empty($translations) ? ' style="display: none;"' : '') . '>' . $languageCode . '</div>';
                         $theData[$field] .= '<a class="btn btn-default filelist-translationToggler" data-fileid="' . $fileObject->getUid() . '">' . IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay', array('title' => $GLOBALS['LANG']->getLL('translateMetadata'))) . '</a>';
                     }
                     break;
                 case '_REF_':
                     $theData[$field] = $this->makeRef($fileObject);
                     break;
                 case 'file':
                     // Edit metadata of file
                     $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
                     if ($fileObject->isMissing()) {
                         $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                         $theData[$field] .= $flashMessage->render();
                         // Thumbnails?
                     } elseif ($this->thumbs && $this->isImage($ext)) {
                         $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
                         if ($processedFile) {
                             $thumbUrl = $processedFile->getPublicUrl(TRUE);
                             $theData[$field] .= '<br /><img src="' . $thumbUrl . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'title="' . htmlspecialchars($fileName) . '" alt="" />';
                         }
                     }
                     break;
                 default:
                     $theData[$field] = '';
                     if ($fileObject->hasProperty($field)) {
                         $theData[$field] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getProperty($field), $this->fixedL));
                     }
//.........這裏部分代碼省略.........
開發者ID:adrolli,項目名稱:TYPO3.CMS,代碼行數:101,代碼來源:FileList.php

示例4: getFolderTree

 /**
  * Fetches the data for the tree
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject the folderobject
  * @param int $depth Max depth (recursivity limit)
  * @param string $type HTML-code prefix for recursive calls.
  * @return int The count of items on the level
  * @see getBrowsableTree()
  */
 public function getFolderTree(\TYPO3\CMS\Core\Resource\Folder $folderObject, $depth = 999, $type = '')
 {
     $depth = (int) $depth;
     // This generates the directory tree
     /* array of \TYPO3\CMS\Core\Resource\Folder */
     if ($folderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
         $subFolders = array();
     } else {
         $subFolders = $folderObject->getSubfolders();
         $subFolders = \TYPO3\CMS\Core\Resource\Utility\ListUtility::resolveSpecialFolderNames($subFolders);
         uksort($subFolders, 'strnatcasecmp');
     }
     $totalSubFolders = count($subFolders);
     $HTML = '';
     $subFolderCounter = 0;
     foreach ($subFolders as $subFolderName => $subFolder) {
         $subFolderCounter++;
         // Reserve space.
         $this->tree[] = array();
         // Get the key for this space
         end($this->tree);
         $isLocked = $subFolder instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder;
         $treeKey = key($this->tree);
         $specUID = GeneralUtility::md5int($subFolder->getCombinedIdentifier());
         $this->specUIDmap[$specUID] = $subFolder->getCombinedIdentifier();
         $row = array('uid' => $specUID, 'path' => $subFolder->getCombinedIdentifier(), 'title' => $subFolderName, 'folder' => $subFolder);
         // Make a recursive call to the next level
         if (!$isLocked && $depth > 1 && $this->expandNext($specUID)) {
             $nextCount = $this->getFolderTree($subFolder, $depth - 1, $type);
             // Set "did expand" flag
             $isOpen = 1;
         } else {
             $nextCount = $isLocked ? 0 : $this->getNumberOfSubfolders($subFolder);
             // Clear "did expand" flag
             $isOpen = 0;
         }
         // Set HTML-icons, if any:
         if ($this->makeHTML) {
             $HTML = $this->PMicon($subFolder, $subFolderCounter, $totalSubFolders, $nextCount, $isOpen);
             $type = '';
             $role = $subFolder->getRole();
             if ($role !== FolderInterface::ROLE_DEFAULT) {
                 $row['_title'] = '<strong>' . $subFolderName . '</strong>';
             }
             $icon = IconUtility::getSpriteIconForResource($subFolder, array('title' => $subFolderName, 'folder-open' => (bool) $isOpen));
             $HTML .= $this->wrapIcon($icon, $subFolder);
         }
         // Finally, add the row/HTML content to the ->tree array in the reserved key.
         $this->tree[$treeKey] = array('row' => $row, 'HTML' => $HTML, 'hasSub' => $nextCount && $this->expandNext($specUID), 'isFirst' => $subFolderCounter == 1, 'isLast' => FALSE, 'invertedDepth' => $depth, 'bank' => $this->bank);
     }
     if ($subFolderCounter > 0) {
         $this->tree[$treeKey]['isLast'] = TRUE;
     }
     return $totalSubFolders;
 }
開發者ID:adrolli,項目名稱:TYPO3.CMS,代碼行數:64,代碼來源:FolderTreeView.php

示例5: printContentFromTab

    /**
     * Print the content on a pad. Called from ->printClipboard()
     *
     * @access private
     * @param string $pad Pad reference
     * @return array Array with table rows for the clipboard.
     * @todo Define visibility
     */
    public function printContentFromTab($pad)
    {
        $lines = array();
        if (is_array($this->clipData[$pad]['el'])) {
            foreach ($this->clipData[$pad]['el'] as $k => $v) {
                if ($v) {
                    list($table, $uid) = explode('|', $k);
                    $bgColClass = $table == '_FILE' && $this->fileMode || $table != '_FILE' && !$this->fileMode ? 'bgColor4-20' : 'bgColor4';
                    // Rendering files/directories on the clipboard
                    if ($table == '_FILE') {
                        $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($v);
                        if ($fileObject) {
                            $thumb = '';
                            $folder = $fileObject instanceof \TYPO3\CMS\Core\Resource\Folder;
                            $size = $folder ? '' : '(' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes)';
                            $icon = IconUtility::getSpriteIconForResource($fileObject, array('style' => 'margin: 0 20px;', 'title' => $fileObject->getName() . ' ' . $size));
                            if (!$folder && $this->clipData['_setThumb'] && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
                                $processedFile = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
                                if ($processedFile) {
                                    $thumbUrl = $processedFile->getPublicUrl(TRUE);
                                    $thumb .= '<br /><img src="' . htmlspecialchars($thumbUrl) . '" title="' . htmlspecialchars($fileObject->getName()) . '" alt="" />';
                                }
                            }
                            $lines[] = '
								<tr>
									<td class="' . $bgColClass . '">' . $icon . '</td>
									<td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . $this->linkItemText(htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $GLOBALS['BE_USER']->uc['titleLen'])), $fileObject->getName()) . ($pad == 'normal' ? ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')</strong>' : '') . '&nbsp;' . $thumb . '</td>
									<td class="' . $bgColClass . '" align="center" nowrap="nowrap">' . '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . $v . '\'); return false;') . '">' . IconUtility::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl('_FILE', GeneralUtility::shortmd5($v))) . '#clip_head">' . IconUtility::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>' . '</td>
								</tr>';
                        } else {
                            // If the file did not exist (or is illegal) then it is removed from the clipboard immediately:
                            unset($this->clipData[$pad]['el'][$k]);
                            $this->changed = 1;
                        }
                    } else {
                        // Rendering records:
                        $rec = BackendUtility::getRecordWSOL($table, $uid);
                        if (is_array($rec)) {
                            $lines[] = '
								<tr>
									<td class="' . $bgColClass . '">' . $this->linkItemText(IconUtility::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($rec, $table)))), $rec, $table) . '</td>
									<td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . $this->linkItemText(htmlspecialchars(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])), $rec, $table) . ($pad == 'normal' ? ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')</strong>' : '') . '&nbsp;</td>
									<td class="' . $bgColClass . '" align="center" nowrap="nowrap">' . '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . (int) $uid . '\'); return false;') . '">' . IconUtility::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl($table, $uid)) . '#clip_head">' . IconUtility::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>' . '</td>
								</tr>';
                            $localizationData = $this->getLocalizations($table, $rec, $bgColClass, $pad);
                            if ($localizationData) {
                                $lines[] = $localizationData;
                            }
                        } else {
                            unset($this->clipData[$pad]['el'][$k]);
                            $this->changed = 1;
                        }
                    }
                }
            }
        }
        if (!count($lines)) {
            $lines[] = '
								<tr>
									<td class="bgColor4"><img src="clear.gif" width="56" height="1" alt="" /></td>
									<td colspan="2" class="bgColor4" nowrap="nowrap" width="95%">&nbsp;<em>(' . $this->clLabel('clipNoEl') . ')</em>&nbsp;</td>
								</tr>';
        }
        $this->endClipboard();
        return $lines;
    }
開發者ID:khanhdeux,項目名稱:typo3test,代碼行數:74,代碼來源:Clipboard.php

示例6: getResourceHeader

 /**
  * Like ->getHeader() but for files and folders
  * Returns the icon with the path of the file/folder set in the alt/title attribute. Shows the name after the icon.
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource
  * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
  * @param bool $enableClickMenu If TRUE, render click menu code around icon image
  * @return string
  */
 public function getResourceHeader(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $tWrap = array('', ''), $enableClickMenu = TRUE)
 {
     try {
         $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier();
         $iconImgTag = IconUtility::getSpriteIconForResource($resource, array('title' => htmlspecialchars($path)));
     } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $e) {
         $iconImgTag = '';
     }
     if ($enableClickMenu && $resource instanceof \TYPO3\CMS\Core\Resource\File) {
         $metaData = $resource->_getMetaData();
         $iconImgTag = $this->wrapClickMenuOnIcon($iconImgTag, 'sys_file_metadata', $metaData['uid']);
     }
     return '<span class="typo3-moduleHeader">' . $iconImgTag . $tWrap[0] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($resource->getName(), 45)) . $tWrap[1] . '</span>';
 }
開發者ID:khanhdeux,項目名稱:typo3test,代碼行數:23,代碼來源:DocumentTemplate.php

示例7: getSingleField_typeGroup


//.........這裏部分代碼省略.........
                    }
                }
                // Making the array of file items:
                $itemArray = GeneralUtility::trimExplode(',', $PA['itemFormElValue'], TRUE);
                $fileFactory = ResourceFactory::getInstance();
                // Correct the filename for the FAL items
                foreach ($itemArray as &$fileItem) {
                    list($fileUid, $fileLabel) = explode('|', $fileItem);
                    if (MathUtility::canBeInterpretedAsInteger($fileUid)) {
                        $fileObject = $fileFactory->getFileObject($fileUid);
                        $fileLabel = $fileObject->getName();
                    }
                    $fileItem = $fileUid . '|' . $fileLabel;
                }
                // Showing thumbnails:
                $thumbsnail = '';
                if ($show_thumbs) {
                    $imgs = array();
                    foreach ($itemArray as $imgRead) {
                        $imgP = explode('|', $imgRead);
                        $imgPath = rawurldecode($imgP[0]);
                        // FAL icon production
                        if (MathUtility::canBeInterpretedAsInteger($imgP[0])) {
                            $fileObject = $fileFactory->getFileObject($imgP[0]);
                            if ($fileObject->isMissing()) {
                                $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                                $imgs[] = $flashMessage->render();
                            } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
                                $imageUrl = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array())->getPublicUrl(TRUE);
                                $imgTag = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($fileObject->getName()) . '" />';
                                $imgs[] = '<span class="nobr">' . $imgTag . htmlspecialchars($fileObject->getName()) . '</span>';
                            } else {
                                // Icon
                                $imgTag = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName()));
                                $imgs[] = '<span class="nobr">' . $imgTag . htmlspecialchars($fileObject->getName()) . '</span>';
                            }
                        } else {
                            $rowCopy = array();
                            $rowCopy[$field] = $imgPath;
                            $thumbnailCode = '';
                            try {
                                $thumbnailCode = BackendUtility::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['uploadfolder'], 0, ' align="middle"');
                                $thumbnailCode = '<span class="nobr">' . $thumbnailCode . $imgPath . '</span>';
                            } catch (\Exception $exception) {
                                /** @var $flashMessage FlashMessage */
                                $message = $exception->getMessage();
                                $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($message), '', FlashMessage::ERROR, TRUE);
                                $class = 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService';
                                /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
                                $flashMessageService = GeneralUtility::makeInstance($class);
                                $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
                                $defaultFlashMessageQueue->enqueue($flashMessage);
                                $logMessage = $message . ' (' . $table . ':' . $row['uid'] . ')';
                                GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
                            }
                            $imgs[] = $thumbnailCode;
                        }
                    }
                    $thumbsnail = implode('<br />', $imgs);
                }
                // Creating the element:
                $params = array('size' => $size, 'dontShowMoveIcons' => $maxitems <= 1, 'autoSizeMax' => MathUtility::forceIntegerInRange($config['autoSizeMax'], 0), 'maxitems' => $maxitems, 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"', 'info' => $info, 'thumbnails' => $thumbsnail, 'readOnly' => $disabled, 'noBrowser' => $noList || isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'browser'), 'noList' => $noList, 'noDelete' => $noDelete);
                $item .= $this->dbFileIcons($PA['itemFormElName'], 'file', implode(',', $tempFT), $itemArray, '', $params, $PA['onFocus'], '', '', '', $config);
                if (!$disabled && !(isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'upload'))) {
                    // Adding the upload field:
                    if ($this->edit_docModuleUpload && $config['uploadfolder']) {
開發者ID:Mr-Robota,項目名稱:TYPO3.CMS,代碼行數:67,代碼來源:FormEngine.php

示例8: formatFileList

 /**
  * This returns tablerows for the files in the array $items['sorting'].
  *
  * @param \TYPO3\CMS\Core\Resource\File[] $files File items
  * @return string HTML table rows.
  * @todo Define visibility
  */
 public function formatFileList(array $files)
 {
     $out = '';
     // first two keys are "0" (default) and "-1" (multiple), after that comes the "other languages"
     $allSystemLanguages = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TranslationConfigurationProvider')->getSystemLanguages();
     $systemLanguages = array_filter($allSystemLanguages, function ($languageRecord) {
         if ($languageRecord['uid'] === -1 || $languageRecord['uid'] === 0 || !$GLOBALS['BE_USER']->checkLanguageAccess($languageRecord['uid'])) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     foreach ($files as $fileObject) {
         list($flag, $code) = $this->fwd_rwd_nav();
         $out .= $code;
         if ($flag) {
             // Initialization
             $this->counter++;
             $this->totalbytes += $fileObject->getSize();
             $ext = $fileObject->getExtension();
             $fileName = trim($fileObject->getName());
             // The icon with link
             $theIcon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileName));
             if ($this->clickMenus) {
                 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
             }
             // Preparing and getting the data-array
             $theData = array();
             foreach ($this->fieldArray as $field) {
                 switch ($field) {
                     case 'size':
                         $theData[$field] = GeneralUtility::formatSize($fileObject->getSize(), $GLOBALS['LANG']->getLL('byteSizeUnits', TRUE));
                         break;
                     case 'rw':
                         $theData[$field] = '' . (!$fileObject->checkActionPermission('read') ? ' ' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('read', TRUE) . '</strong></span>') . (!$fileObject->checkActionPermission('write') ? '' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('write', TRUE) . '</strong></span>');
                         break;
                     case 'fileext':
                         $theData[$field] = strtoupper($ext);
                         break;
                     case 'tstamp':
                         $theData[$field] = BackendUtility::date($fileObject->getProperty('modification_date'));
                         break;
                     case '_CLIPBOARD_':
                         $temp = '';
                         if ($this->bigControlPanel) {
                             $temp .= $this->makeEdit($fileObject);
                         }
                         $temp .= $this->makeClip($fileObject);
                         if (!empty($systemLanguages)) {
                             $temp .= '<a class="filelist-translationToggler" data-fileid="' . $fileObject->getUid() . '">' . IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay') . '</a>';
                         }
                         $theData[$field] = $temp;
                         break;
                     case '_REF_':
                         $theData[$field] = $this->makeRef($fileObject);
                         break;
                     case 'file':
                         $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
                         if ($fileObject->isMissing()) {
                             $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                             $theData[$field] .= $flashMessage->render();
                             // Thumbnails?
                         } elseif ($this->thumbs && $this->isImage($ext)) {
                             $processedFile = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
                             if ($processedFile) {
                                 $thumbUrl = $processedFile->getPublicUrl(TRUE);
                                 $theData[$field] .= '<br /><img src="' . $thumbUrl . '" title="' . htmlspecialchars($fileName) . '" alt="" />';
                             }
                         }
                         if (!empty($systemLanguages)) {
                             $metaDataRecord = $fileObject->_getMetaData();
                             $translations = $this->getTranslationsForMetaData($metaDataRecord);
                             $languageCode = '';
                             foreach ($systemLanguages as $language) {
                                 $languageId = $language['uid'];
                                 $flagIcon = $language['flagIcon'];
                                 if (array_key_exists($languageId, $translations)) {
                                     $flagButtonIcon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $fileName), array($flagIcon . '-overlay' => array()));
                                     $data = array('sys_file_metadata' => array($translations[$languageId]['uid'] => 'edit'));
                                     $editOnClick = BackendUtility::editOnClick(GeneralUtility::implodeArrayForUrl('edit', $data), $GLOBALS['BACK_PATH'], $this->listUrl());
                                     $languageCode .= sprintf('<a href="#" onclick="%s">%s</a>', htmlspecialchars($editOnClick), $flagButtonIcon);
                                 } else {
                                     $href = $GLOBALS['SOBE']->doc->issueCommand('&cmd[sys_file_metadata][' . $metaDataRecord['uid'] . '][localize]=' . $languageId, $this->backPath . 'alt_doc.php?justLocalized=' . rawurlencode('sys_file_metadata:' . $metaDataRecord['uid'] . ':' . $languageId) . '&returnUrl=' . rawurlencode($this->listURL()) . BackendUtility::getUrlToken('editRecord'));
                                     $flagButtonIcon = IconUtility::getSpriteIcon($flagIcon);
                                     $languageCode .= sprintf('<a href="%s">%s</a> ', htmlspecialchars($href), $flagButtonIcon);
                                 }
                             }
                             // Hide flag button bar when not translated yet
                             $theData[$field] .= '<div class="localisationData" data-fileid="' . $fileObject->getUid() . '"' . (empty($translations) ? ' style="display: none;"' : '') . '>' . $languageCode . '</div>';
                         }
                         break;
                     default:
                         $theData[$field] = '';
//.........這裏部分代碼省略.........
開發者ID:allipierre,項目名稱:Typo3,代碼行數:101,代碼來源:FileList.php

示例9: printFileClickMenu

 /**
  * Make 1st level clickmenu:
  *
  * @param string $combinedIdentifier The combined identifier
  * @return string HTML content
  * @see \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject()
  * @todo Define visibility
  */
 public function printFileClickMenu($combinedIdentifier)
 {
     $menuItems = array();
     $combinedIdentifier = rawurldecode($combinedIdentifier);
     $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
     if ($fileObject) {
         $folder = FALSE;
         $isStorageRoot = FALSE;
         $isOnline = TRUE;
         $userMayViewStorage = FALSE;
         $userMayEditStorage = FALSE;
         $identifier = $fileObject->getCombinedIdentifier();
         if ($fileObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
             $icon = IconUtility::getSpriteIconForResource($fileObject, array('class' => 'absmiddle', 'title' => htmlspecialchars($fileObject->getName())));
             $folder = TRUE;
             if ($fileObject->getIdentifier() === $fileObject->getStorage()->getRootLevelFolder()->getIdentifier()) {
                 $isStorageRoot = TRUE;
                 if ($GLOBALS['BE_USER']->check('tables_select', 'sys_file_storage')) {
                     $userMayViewStorage = TRUE;
                 }
                 if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_file_storage')) {
                     $userMayEditStorage = TRUE;
                 }
             }
             if (!$fileObject->getStorage()->isOnline()) {
                 $isOnline = FALSE;
             }
         } else {
             $icon = IconUtility::getSpriteIconForResource($fileObject, array('class' => 'absmiddle', 'title' => htmlspecialchars($fileObject->getName() . ' (' . GeneralUtility::formatSize($fileObject->getSize()) . ')')));
         }
         // Hide
         if (!in_array('hide', $this->disabledItems) && $isStorageRoot && $userMayEditStorage) {
             $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
             $menuItems['hide'] = $this->DB_changeFlag('sys_file_storage', $record, 'is_online', $this->label($record['is_online'] ? 'offline' : 'online'), 'hide');
         }
         // Edit
         if (!in_array('edit', $this->disabledItems) && $fileObject->checkActionPermission('write')) {
             if (!$folder && !$isStorageRoot && $fileObject->isIndexed()) {
                 $metaData = $fileObject->_getMetaData();
                 $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
             }
             if (!$folder && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension()) && $fileObject->checkActionPermission('write')) {
                 $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'editcontent', 'edit_file.gif');
             } elseif ($isStorageRoot && $userMayEditStorage) {
                 $menuItems['edit'] = $this->DB_edit('sys_file_storage', $fileObject->getStorage()->getUid());
             }
         }
         // Rename
         if (!in_array('rename', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
             $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
         }
         // Upload
         if (!in_array('upload', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
             $menuItems['upload'] = $this->FILE_upload($identifier);
         }
         // New
         if (!in_array('new', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
             $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
         }
         // Info
         if (!in_array('info', $this->disabledItems) && $fileObject->checkActionPermission('read')) {
             if ($isStorageRoot && $userMayViewStorage) {
                 $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
             } elseif (!$folder) {
                 $menuItems['info'] = $this->fileInfo($identifier);
             }
         }
         $menuItems[] = 'spacer';
         // Copy:
         if (!in_array('copy', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
             $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
         }
         // Cut:
         if (!in_array('cut', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
             $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
         }
         // Paste:
         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
         if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
             $elArr = $this->clipObj->elFromTable('_FILE');
             $selItem = reset($elArr);
             $elInfo = array(basename($selItem), basename($identifier), $this->clipObj->currentMode());
             $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
         }
         $menuItems[] = 'spacer';
         // Delete:
         if (!in_array('delete', $this->disabledItems) && $fileObject->checkActionPermission('delete')) {
             if ($isStorageRoot && $userMayEditStorage) {
                 $elInfo = array(GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $GLOBALS['BE_USER']->uc['titleLen']));
                 $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
             } elseif (!$isStorageRoot) {
                 $menuItems['delete'] = $this->FILE_delete($identifier);
//.........這裏部分代碼省略.........
開發者ID:samuweiss,項目名稱:TYPO3-Site,代碼行數:101,代碼來源:ClickMenu.php


注:本文中的TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。