public function check()
 {
     $checkFailed = '';
     $maxSize = intval($this->utilityFuncs->getSingle($this->settings['params'], 'maxSize'));
     $phpIniUploadMaxFileSize = $this->utilityFuncs->convertBytes(ini_get('upload_max_filesize'));
     if ($maxSize > $phpIniUploadMaxFileSize) {
         $this->utilityFuncs->throwException('error_check_filemaxsize', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($maxSize, ' Bytes| KB| MB| GB'), $this->formFieldName, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($phpIniUploadMaxFileSize, ' Bytes| KB| MB| GB'));
     }
     foreach ($_FILES as $sthg => &$files) {
         if (!is_array($files['name'][$this->formFieldName])) {
             $files['name'][$this->formFieldName] = array($files['name'][$this->formFieldName]);
         }
         if (strlen($files['name'][$this->formFieldName][0]) > 0 && $maxSize) {
             if (!is_array($files['size'][$this->formFieldName])) {
                 $files['size'][$this->formFieldName] = array($files['size'][$this->formFieldName]);
             }
             foreach ($files['size'][$this->formFieldName] as $size) {
                 if ($size > $maxSize) {
                     unset($files);
                     $checkFailed = $this->getCheckFailed();
                 }
             }
         }
     }
     return $checkFailed;
 }
Example #2
0
 /**
  * Show the maintenance overview
  */
 public function maintenanceOverviewAction()
 {
     /**
      * Check if an update is available
      */
     if ($this->dbUpgradeUtility->getAvailableUpdateMethod() != '') {
         $this->forward('dbUpdateNeeded');
     }
     $itemRepository = $this->objectManager->get('Tx_Yag_Domain_Repository_ItemRepository');
     /* @var $itemRepository Tx_Yag_Domain_Repository_ItemRepository */
     $galleryCount = $this->objectManager->get('Tx_Yag_Domain_Repository_GalleryRepository')->countAll();
     $albumCount = $this->objectManager->get('Tx_Yag_Domain_Repository_AlbumRepository')->countAll();
     $itemCount = $itemRepository->countAll();
     $itemSizeSum = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($itemRepository->getItemSizeSum());
     $includedCount = $this->objectManager->get('Tx_Yag_Domain_Repository_Extern_TTContentRepository')->countAllYagInstances();
     $firstItem = $itemRepository->getItemsAfterThisItem();
     if ($firstItem) {
         $firstItemUid = $firstItem->getUid();
     }
     $resolutionFileCache = Tx_Yag_Domain_FileSystem_ResolutionFileCacheFactory::getInstance();
     $this->view->assign('folderStatistics', array('galleryCount' => $galleryCount, 'albumCount' => $albumCount, 'itemCount' => $itemCount));
     $this->view->assign('globalStatistics', array('show' => $GLOBALS['BE_USER']->isAdmin(), 'itemSizeSum' => $itemSizeSum));
     $this->view->assign('firstItemUid', $firstItemUid);
     $this->view->assign('includedCount', $includedCount);
     $this->view->assign('resolutionFileCache', $resolutionFileCache);
 }
 /**
  * Renders a HTML Block with file information
  *
  * @param File $file
  * @return string
  */
 protected function renderFileInformationContent(File $file = null)
 {
     /** @var LanguageService $lang */
     $lang = $GLOBALS['LANG'];
     if ($file !== null) {
         $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
         $previewImage = $processedFile->getPublicUrl(true);
         $content = '';
         if ($file->isMissing()) {
             $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($file);
             $content .= $flashMessage->render();
         }
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
         $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
         $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
         $content .= $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', true) . ': ';
         $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', true) . '</h2>';
     }
     return $content;
 }
Example #4
0
 /**
  * Checks whether post_max_size
  *
  * @return void
  */
 protected function checkPostSize()
 {
     if ($this->returnBytes(ini_get('post_max_size')) < $this->returnBytes(ini_get('upload_max_filesize'))) {
         $this->reports[] = GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Environment Variables', GeneralUtility::formatSize($this->returnBytes(ini_get('post_max_size'))), 'Your post_max_size value (' . ini_get('post_max_size') . ')  is smaller than upload_max_filesize (' . ini_get('upload_max_filesize') . '). This might lead to problems when uploading ZIP files or big images!', Status::WARNING);
     } else {
         $this->reports[] = GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Environment Variables', GeneralUtility::formatSize($this->returnBytes(ini_get('post_max_size'))), 'Your post_max_size value (' . ini_get('post_max_size') . ') is equal or bigger than upload_max_filesize (' . ini_get('upload_max_filesize') . ')', Status::OK);
     }
 }
 /**
  * Processes a log record and adds memory usage information.
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $logRecord The log record to process
  * @return \TYPO3\CMS\Core\Log\LogRecord The processed log record with additional data
  * @see memory_get_usage()
  */
 public function processLogRecord(\TYPO3\CMS\Core\Log\LogRecord $logRecord)
 {
     $bytes = memory_get_usage($this->getRealMemoryUsage());
     if ($this->formatSize) {
         $size = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($bytes);
     } else {
         $size = $bytes;
     }
     $logRecord->addData(array('memoryUsage' => $size));
     return $logRecord;
 }
 public function contentPostProc($_funcRef, $_params)
 {
     $nbQueries = $GLOBALS['TYPO3_DB']->profiling();
     $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['typo3profiler']);
     $logTS = $GLOBALS['TT']->printTSlog();
     $logTS = preg_replace('/src="typo3/', 'src="/typo3', $logTS);
     $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_typo3profiler_page', 'page=' . intval($GLOBALS['TSFE']->id));
     $GLOBALS['TYPO3_DB']->exec_INSERTQuery('tx_typo3profiler_page', array('pid' => 0, 'parsetime' => $GLOBALS['TSFE']->scriptParseTime, 'page' => $GLOBALS['TSFE']->id, 'logts' => $logTS, 'size' => \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(strlen($GLOBALS['TSFE']->content)), 'nocache' => $GLOBALS['TSFE']->no_cache ? 1 : 0, 'userint' => count($GLOBALS['TSFE']->config['INTincScript']), 'nbqueries' => $nbQueries));
     if ($conf['debugbarenabled'] == 1) {
         Typo3profiler_Utility_Debugbar::render();
     }
 }
Example #7
0
 /**
  * Get size from file
  *
  * @param boolean $format If true, file size will be formatted
  * @throws \TYPO3\CMS\Install\ViewHelpers\Exception
  * @return integer File size
  */
 public function render($format = TRUE)
 {
     $absolutePathToFile = $this->renderChildren();
     if (!is_file($absolutePathToFile)) {
         throw new \TYPO3\CMS\Install\ViewHelpers\Exception('File not found', 1369563246);
     }
     $size = filesize($absolutePathToFile);
     if ($format) {
         $size = GeneralUtility::formatSize($size);
     }
     return $size;
 }
 /**
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  *
  * @return string
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $format = $arguments['format'];
     $absolutePathToFile = $renderChildrenClosure();
     if (!is_file($absolutePathToFile)) {
         throw new \TYPO3\CMS\Install\ViewHelpers\Exception('File not found', 1369563246);
     }
     $size = filesize($absolutePathToFile);
     if ($format) {
         $size = GeneralUtility::formatSize($size);
     }
     return $size;
 }
 /**
  * Renders the size of a file using \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize
  *
  * @param string $file Path to the file
  * @param string $format Labels for bytes, kilo, mega and giga separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value)
  * @param boolean $hideError Define if an error should be displayed if file not found
  * @param integer $fileSize File size
  * @return string
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
  */
 public function render($file = NULL, $format = '', $hideError = FALSE, $fileSize = NULL)
 {
     if (!is_file($file)) {
         $errorMessage = sprintf('Given file "%s" for %s is not valid', htmlspecialchars($file), get_class());
         \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($errorMessage, 'news', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_WARNING);
         if (!$hideError) {
             throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('Given file is not a valid file: ' . htmlspecialchars($file));
         }
     }
     if ($fileSize === NULL) {
         $result = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(filesize($file), $format);
     } else {
         $result = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileSize, $format);
     }
     return $result;
 }
Example #10
0
 /**
  * User function for sys_file (element)
  *
  * @param array $PA the array with additional configuration options.
  * @param \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj the TCEforms parent object
  * @return string The HTML code for the TCEform field
  */
 public function renderFileInfo(array $PA, \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj)
 {
     $fileRecord = $PA['row'];
     if ($fileRecord['uid'] > 0) {
         $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileRecord['uid']);
         $processedFile = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
         $previewImage = $processedFile->getPublicUrl(TRUE);
         $content = '';
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($fileObject->getName()) . '</strong> (' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize())) . ')<br />';
         $content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($PA['table'], 'type', $fileObject->getType()) . ' (' . $fileObject->getMimeType() . ')<br />';
         $content .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', TRUE) . ': ' . htmlspecialchars($fileObject->getStorage()->getName()) . ' - ' . htmlspecialchars($fileObject->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', TRUE) . '</h2>';
     }
     return $content;
 }
Example #11
0
 /**
  * Checks if there was a request in the past which approached the memory limit
  *
  * @return \TYPO3\CMS\Reports\Status A status of whether the memory limit was approached by one of the requests
  */
 protected function getPhpPeakMemoryStatus()
 {
     /** @var $registry \TYPO3\CMS\Core\Registry */
     $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
     $peakMemoryUsage = $registry->get('core', 'reports-peakMemoryUsage');
     $memoryLimit = \TYPO3\CMS\Core\Utility\GeneralUtility::getBytesFromSizeMeasurement(ini_get('memory_limit'));
     $value = $GLOBALS['LANG']->getLL('status_ok');
     $message = '';
     $severity = \TYPO3\CMS\Reports\Status::OK;
     $bytesUsed = $peakMemoryUsage['used'];
     $percentageUsed = $memoryLimit ? number_format($bytesUsed / $memoryLimit * 100, 1) . '%' : '?';
     $dateOfPeak = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $peakMemoryUsage['tstamp']);
     $urlOfPeak = '<a href="' . htmlspecialchars($peakMemoryUsage['url']) . '">' . htmlspecialchars($peakMemoryUsage['url']) . '</a>';
     $clearFlagUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=clear_peak_memory_usage_flag';
     if ($peakMemoryUsage['used']) {
         $message = sprintf($GLOBALS['LANG']->getLL('status_phpPeakMemoryTooHigh'), \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($peakMemoryUsage['used']), $percentageUsed, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($memoryLimit), $dateOfPeak, $urlOfPeak);
         $message .= ' <a href="' . $clearFlagUrl . '">' . $GLOBALS['LANG']->getLL('status_phpPeakMemoryClearFlag') . '</a>.';
         $severity = \TYPO3\CMS\Reports\Status::WARNING;
         $value = $percentageUsed;
     }
     return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_phpPeakMemory'), $value, $message, $severity);
 }
 /**
  * bytes
  * Will return the size of a given number in Bytes	 *
  *
  * @param string $content Input value undergoing processing in this function.
  * @param array $conf stdWrap properties for bytes.
  * @return string The processed input value
  */
 public function stdWrap_bytes($content = '', $conf = array())
 {
     return GeneralUtility::formatSize($content, $conf['bytes.']['labels'], $conf['bytes.']['base']);
 }
Example #13
0
    /**
     * 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;
    }
Example #14
0
 /**
  * Displays an overview of the header-content.
  *
  * @return array The view data
  */
 public function displayContentOverview()
 {
     if (!isset($this->dat['header'])) {
         return [];
     }
     // Check extension dependencies:
     foreach ($this->dat['header']['extensionDependencies'] as $extKey) {
         if (!empty($extKey) && !ExtensionManagementUtility::isLoaded($extKey)) {
             $this->error('DEPENDENCY: The extension with key "' . $extKey . '" must be installed!');
         }
     }
     // Probably this is done to save memory space?
     unset($this->dat['files']);
     $viewData = [];
     // Traverse header:
     $this->remainHeader = $this->dat['header'];
     // If there is a page tree set, show that:
     if (is_array($this->dat['header']['pagetree'])) {
         reset($this->dat['header']['pagetree']);
         $lines = [];
         $this->traversePageTree($this->dat['header']['pagetree'], $lines);
         $viewData['dat'] = $this->dat;
         $viewData['update'] = $this->update;
         $viewData['showDiff'] = $this->showDiff;
         if (!empty($lines)) {
             foreach ($lines as &$r) {
                 $r['controls'] = $this->renderControls($r);
                 $r['fileSize'] = GeneralUtility::formatSize($r['size']);
                 $r['message'] = $r['msg'] && !$this->doesImport ? '<span class="text-danger">' . htmlspecialchars($r['msg']) . '</span>' : '';
             }
             $viewData['pagetreeLines'] = $lines;
         } else {
             $viewData['pagetreeLines'] = [];
         }
     }
     // Print remaining records that were not contained inside the page tree:
     if (is_array($this->remainHeader['records'])) {
         $lines = [];
         if (is_array($this->remainHeader['records']['pages'])) {
             $this->traversePageRecords($this->remainHeader['records']['pages'], $lines);
         }
         $this->traverseAllRecords($this->remainHeader['records'], $lines);
         if (!empty($lines)) {
             foreach ($lines as &$r) {
                 $r['controls'] = $this->renderControls($r);
                 $r['fileSize'] = GeneralUtility::formatSize($r['size']);
                 $r['message'] = $r['msg'] && !$this->doesImport ? '<span class="text-danger">' . htmlspecialchars($r['msg']) . '</span>' : '';
             }
             $viewData['remainingRecords'] = $lines;
         }
     }
     return $viewData;
 }
 /**
  * Substitute makers in the message text
  * Overrides the abstract
  *
  * @param string $message Message text with markers
  * @return string Message text with substituted markers
  */
 protected function substituteValues($message)
 {
     $message = str_replace('%maximum', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->maximum), $message);
     return $message;
 }
Example #16
0
 /**
  * Adds a files content to the export memory
  *
  * @param array $fI File information with three keys: "filename" = filename without path, "ID_absFile" = absolute filepath to the file (including the filename), "ID" = md5 hash of "ID_absFile". "relFileName" is optional for files attached to records, but mandatory for soft referenced files (since the relFileName determines where such a file should be stored!)
  * @param string $recordRef If the file is related to a record, this is the id on the form [table]:[id]. Information purposes only.
  * @param string $fieldname If the file is related to a record, this is the field name it was related to. Information purposes only.
  * @return void
  */
 public function export_addFile($fI, $recordRef = '', $fieldname = '')
 {
     if (!@is_file($fI['ID_absFile'])) {
         $this->error($fI['ID_absFile'] . ' was not a file! Skipping.');
         return;
     }
     if (filesize($fI['ID_absFile']) >= $this->maxFileSize) {
         $this->error($fI['ID_absFile'] . ' was larger (' . GeneralUtility::formatSize(filesize($fI['ID_absFile'])) . ') than the maxFileSize (' . GeneralUtility::formatSize($this->maxFileSize) . ')! Skipping.');
         return;
     }
     $fileInfo = stat($fI['ID_absFile']);
     $fileRec = array();
     $fileRec['filesize'] = $fileInfo['size'];
     $fileRec['filename'] = PathUtility::basename($fI['ID_absFile']);
     $fileRec['filemtime'] = $fileInfo['mtime'];
     //for internal type file_reference
     $fileRec['relFileRef'] = PathUtility::stripPathSitePrefix($fI['ID_absFile']);
     if ($recordRef) {
         $fileRec['record_ref'] = $recordRef . '/' . $fieldname;
     }
     if ($fI['relFileName']) {
         $fileRec['relFileName'] = $fI['relFileName'];
     }
     // Setting this data in the header
     $this->dat['header']['files'][$fI['ID']] = $fileRec;
     // ... and for the recordlisting, why not let us know WHICH relations there was...
     if ($recordRef && $recordRef !== '_SOFTREF_') {
         $refParts = explode(':', $recordRef, 2);
         if (!is_array($this->dat['header']['records'][$refParts[0]][$refParts[1]]['filerefs'])) {
             $this->dat['header']['records'][$refParts[0]][$refParts[1]]['filerefs'] = array();
         }
         $this->dat['header']['records'][$refParts[0]][$refParts[1]]['filerefs'][] = $fI['ID'];
     }
     $fileMd5 = md5_file($fI['ID_absFile']);
     if (!$this->saveFilesOutsideExportFile) {
         // ... and finally add the heavy stuff:
         $fileRec['content'] = GeneralUtility::getUrl($fI['ID_absFile']);
     } else {
         GeneralUtility::upload_copy_move($fI['ID_absFile'], $this->getTemporaryFilesPathForExport() . $fileMd5);
     }
     $fileRec['content_md5'] = $fileMd5;
     $this->dat['files'][$fI['ID']] = $fileRec;
     // For soft references, do further processing:
     if ($recordRef === '_SOFTREF_') {
         // RTE files?
         if ($RTEoriginal = $this->getRTEoriginalFilename(PathUtility::basename($fI['ID_absFile']))) {
             $RTEoriginal_absPath = PathUtility::dirname($fI['ID_absFile']) . '/' . $RTEoriginal;
             if (@is_file($RTEoriginal_absPath)) {
                 $RTEoriginal_ID = md5($RTEoriginal_absPath);
                 $fileInfo = stat($RTEoriginal_absPath);
                 $fileRec = array();
                 $fileRec['filesize'] = $fileInfo['size'];
                 $fileRec['filename'] = PathUtility::basename($RTEoriginal_absPath);
                 $fileRec['filemtime'] = $fileInfo['mtime'];
                 $fileRec['record_ref'] = '_RTE_COPY_ID:' . $fI['ID'];
                 $this->dat['header']['files'][$fI['ID']]['RTE_ORIG_ID'] = $RTEoriginal_ID;
                 // Setting this data in the header
                 $this->dat['header']['files'][$RTEoriginal_ID] = $fileRec;
                 $fileMd5 = md5_file($RTEoriginal_absPath);
                 if (!$this->saveFilesOutsideExportFile) {
                     // ... and finally add the heavy stuff:
                     $fileRec['content'] = GeneralUtility::getUrl($RTEoriginal_absPath);
                 } else {
                     GeneralUtility::upload_copy_move($RTEoriginal_absPath, $this->getTemporaryFilesPathForExport() . $fileMd5);
                 }
                 $fileRec['content_md5'] = $fileMd5;
                 $this->dat['files'][$RTEoriginal_ID] = $fileRec;
             } else {
                 $this->error('RTE original file "' . PathUtility::stripPathSitePrefix($RTEoriginal_absPath) . '" was not found!');
             }
         }
         // Files with external media?
         // This is only done with files grabbed by a softreference parser since it is deemed improbable that hard-referenced files should undergo this treatment.
         $html_fI = pathinfo(PathUtility::basename($fI['ID_absFile']));
         if ($this->includeExtFileResources && GeneralUtility::inList($this->extFileResourceExtensions, strtolower($html_fI['extension']))) {
             $uniquePrefix = '###' . md5($GLOBALS['EXEC_TIME']) . '###';
             if (strtolower($html_fI['extension']) === 'css') {
                 $prefixedMedias = explode($uniquePrefix, preg_replace('/(url[[:space:]]*\\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\\))/i', '\\1' . $uniquePrefix . '\\2' . $uniquePrefix . '\\3', $fileRec['content']));
             } else {
                 // html, htm:
                 $htmlParser = GeneralUtility::makeInstance(HtmlParser::class);
                 $prefixedMedias = explode($uniquePrefix, $htmlParser->prefixResourcePath($uniquePrefix, $fileRec['content'], array(), $uniquePrefix));
             }
             $htmlResourceCaptured = false;
             foreach ($prefixedMedias as $k => $v) {
                 if ($k % 2) {
                     $EXTres_absPath = GeneralUtility::resolveBackPath(PathUtility::dirname($fI['ID_absFile']) . '/' . $v);
                     $EXTres_absPath = GeneralUtility::getFileAbsFileName($EXTres_absPath);
                     if ($EXTres_absPath && GeneralUtility::isFirstPartOfStr($EXTres_absPath, PATH_site . $this->fileadminFolderName . '/') && @is_file($EXTres_absPath)) {
                         $htmlResourceCaptured = true;
                         $EXTres_ID = md5($EXTres_absPath);
                         $this->dat['header']['files'][$fI['ID']]['EXT_RES_ID'][] = $EXTres_ID;
                         $prefixedMedias[$k] = '{EXT_RES_ID:' . $EXTres_ID . '}';
                         // Add file to memory if it is not set already:
                         if (!isset($this->dat['header']['files'][$EXTres_ID])) {
                             $fileInfo = stat($EXTres_absPath);
                             $fileRec = array();
                             $fileRec['filesize'] = $fileInfo['size'];
                             $fileRec['filename'] = PathUtility::basename($EXTres_absPath);
                             $fileRec['filemtime'] = $fileInfo['mtime'];
                             $fileRec['record_ref'] = '_EXT_PARENT_:' . $fI['ID'];
                             // Media relative to the HTML file.
                             $fileRec['parentRelFileName'] = $v;
                             // Setting this data in the header
                             $this->dat['header']['files'][$EXTres_ID] = $fileRec;
                             // ... and finally add the heavy stuff:
                             $fileRec['content'] = GeneralUtility::getUrl($EXTres_absPath);
                             $fileRec['content_md5'] = md5($fileRec['content']);
                             $this->dat['files'][$EXTres_ID] = $fileRec;
                         }
                     }
                 }
             }
             if ($htmlResourceCaptured) {
                 $this->dat['files'][$fI['ID']]['tokenizedContent'] = implode('', $prefixedMedias);
             }
         }
     }
 }
 /**
  * Returns the info-string in the bottom of the result-row display (size, dates, path)
  *
  * @param 	array		Result row
  * @param 	array		Template array to modify
  * @return 	array		Modified template array
  * @todo Define visibility
  */
 public function makeInfo($row, $tmplArray)
 {
     $tmplArray['size'] = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row['item_size']);
     $tmplArray['created'] = $this->formatCreatedDate($row['item_crdate']);
     $tmplArray['modified'] = $this->formatModifiedDate($row['item_mtime']);
     $pathId = $row['data_page_id'] ? $row['data_page_id'] : $row['page_id'];
     $pathMP = $row['data_page_id'] ? $row['data_page_mp'] : '';
     $pI = parse_url($row['data_filename']);
     if ($pI['scheme']) {
         $targetAttribute = '';
         if ($GLOBALS['TSFE']->config['config']['fileTarget']) {
             $targetAttribute = ' target="' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"';
         }
         $tmplArray['path'] = '<a href="' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>' . htmlspecialchars($row['data_filename']) . '</a>';
     } else {
         $pathStr = htmlspecialchars($this->getPathFromPageId($pathId, $pathMP));
         $tmplArray['path'] = $this->linkPage($pathId, $pathStr, array('cHashParams' => $row['cHashParams'], 'data_page_type' => $row['data_page_type'], 'data_page_mp' => $pathMP, 'sys_language_uid' => $row['sys_language_uid']));
     }
     return $tmplArray;
 }
    /**
     * For TYPO3 Element Browser: Expand folder of files.
     *
     * @param Folder $folder The folder path to expand
     * @param array $extensionList List of fileextensions to show
     * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
     * @return string HTML output
     */
    public function renderFilesInFolder(Folder $folder, array $extensionList = [], $noThumbs = false)
    {
        if (!$folder->checkActionPermission('read')) {
            return '';
        }
        $lang = $this->getLanguageService();
        $titleLen = (int) $this->getBackendUser()->uc['titleLen'];
        if ($this->searchWord !== '') {
            $files = $this->fileRepository->searchByName($folder, $this->searchWord);
        } else {
            $extensionList = !empty($extensionList) && $extensionList[0] === '*' ? [] : $extensionList;
            $files = $this->getFilesInFolder($folder, $extensionList);
        }
        $filesCount = count($files);
        $lines = array();
        // Create the header of current folder:
        $folderIcon = $this->iconFactory->getIconForResource($folder, Icon::SIZE_SMALL);
        $lines[] = '
			<tr>
				<th class="col-title" nowrap="nowrap">' . $folderIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</th>
				<th class="col-control" nowrap="nowrap"></th>
				<th class="col-clipboard" nowrap="nowrap">
					<a href="#" class="btn btn-default" id="t3js-importSelection" title="' . $lang->getLL('importSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL) . '</a>
					<a href="#" class="btn btn-default" id="t3js-toggleSelection" title="' . $lang->getLL('toggleSelection', true) . '">' . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL) . '</a>
				</th>
				<th nowrap="nowrap">&nbsp;</th>
			</tr>';
        if ($filesCount === 0) {
            $lines[] = '
				<tr>
					<td colspan="4">No files found.</td>
				</tr>';
        }
        foreach ($files as $fileObject) {
            $fileExtension = $fileObject->getExtension();
            // Thumbnail/size generation:
            $imgInfo = array();
            if (!$noThumbs && GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']), strtolower($fileExtension))) {
                $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 64, 'height' => 64));
                $imageUrl = $processedFile->getPublicUrl(true);
                $imgInfo = array($fileObject->getProperty('width'), $fileObject->getProperty('height'));
                $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
                $clickIcon = '<img src="' . $imageUrl . '"' . ' width="' . $processedFile->getProperty('width') . '"' . ' height="' . $processedFile->getProperty('height') . '"' . ' hspace="5" vspace="5" border="1" />';
            } else {
                $clickIcon = '';
                $pDim = '';
            }
            // Create file icon:
            $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
            $icon = '<span title="' . htmlspecialchars($fileObject->getName() . $size) . '">' . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL) . '</span>';
            // Create links for adding the file:
            $filesIndex = count($this->elements);
            $this->elements['file_' . $filesIndex] = array('type' => 'file', 'table' => 'sys_file', 'uid' => $fileObject->getUid(), 'fileName' => $fileObject->getName(), 'filePath' => $fileObject->getUid(), 'fileExt' => $fileExtension, 'fileIcon' => $icon);
            if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
                $ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="0">';
                $ATag_alt = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="1">';
                $ATag_e = '</a>';
                $bulkCheckBox = '<label class="btn btn-default btn-checkbox"><input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /><span class="t3-icon fa"></span></label>';
            } else {
                $ATag = '';
                $ATag_alt = '';
                $ATag_e = '';
                $bulkCheckBox = '';
            }
            // Create link to showing details about the file in a window:
            $Ahref = BackendUtility::getModuleUrl('show_item', array('type' => 'file', 'table' => '_FILE', 'uid' => $fileObject->getCombinedIdentifier(), 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
            // Combine the stuff:
            $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
            // Show element:
            $lines[] = '
					<tr class="file_list_normal">
						<td class="col-title" nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
						<td class="col-control">
							<div class="btn-group">' . $ATag . '<span title="' . $lang->getLL('addToList', true) . '">' . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . '</span>' . $ATag_e . '
							<a href="' . htmlspecialchars($Ahref) . '" class="btn btn-default" title="' . $lang->getLL('info', true) . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</a>
						</td>
						<td class="col-clipboard" valign="top">' . $bulkCheckBox . '</td>
						<td nowrap="nowrap">&nbsp;' . $pDim . '</td>
					</tr>';
            if ($pDim) {
                $lines[] = '
					<tr>
						<td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
					</tr>';
            }
        }
        $out = '<h3>' . $lang->getLL('files', true) . ' ' . $filesCount . ':</h3>';
        $out .= GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this)->getFileSearchField($this->searchWord);
        $out .= '<div id="filelist">';
        $out .= $this->getBulkSelector($filesCount);
        // Wrap all the rows in table tags:
        $out .= '

	<!--
		Filelisting
	-->
			<table class="table table-striped table-hover" id="typo3-filelist">
				' . implode('', $lines) . '
			</table>';
        // Return accumulated content for filelisting:
        $out .= '</div>';
        return $out;
    }
Example #19
0
 /**
  * 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));
                     }
             }
         }
         $out .= $this->addelement(1, $theIcon, $theData);
     }
     return $out;
 }
 /**
  * @test
  * @dataProvider formatSizeDataProvider
  */
 public function formatSizeTranslatesBytesToHigherOrderRepresentation($size, $label, $expected)
 {
     $this->assertEquals($expected, Utility\GeneralUtility::formatSize($size, $label));
 }
Example #21
0
 /**
  * [Describe function...]
  *
  * @return 	[type]		...
  * @todo Define visibility
  */
 public function getPhashExternalDocs()
 {
     $recList[] = array($this->tableHead('Filename'), $this->tableHead('Size'), $this->tableHead('Words'), $this->tableHead('mtime'), $this->tableHead('Indexed'), $this->tableHead('Updated'), $this->tableHead('Parsetime'), $this->tableHead('#sec/gr/full'), $this->tableHead('#sub'), $this->tableHead('cHash'), $this->tableHead('phash'), $this->tableHead('Path'));
     // TYPO3 pages, unique
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'item_type<>\'0\'', 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid,freeIndexSetId', 'item_type');
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $cHash = count(unserialize($row['cHashParams'])) ? $this->formatCHash(unserialize($row['cHashParams'])) : '';
         $grListRec = $this->getGrlistRecord($row['phash']);
         $recList[] = array(htmlentities(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['item_title'], 30)), \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row['item_size']), $this->getNumberOfWords($row['phash']), BackendUtility::datetime($row['item_mtime']), BackendUtility::datetime($row['crdate']), $row['tstamp'] != $row['crdate'] ? BackendUtility::datetime($row['tstamp']) : '', $row['parsetime'], $this->getNumberOfSections($row['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row['phash']), $row['pcount'], $cHash, $row['phash'], htmlentities(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['data_filename'], 100)));
         if ($row['pcount'] > 1) {
             $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping=' . (int) $row['phash_grouping'] . ' AND phash<>' . (int) $row['phash']);
             while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
                 $cHash = count(unserialize($row2['cHashParams'])) ? $this->formatCHash(unserialize($row2['cHashParams'])) : '';
                 $grListRec = $this->getGrlistRecord($row2['phash']);
                 $recList[] = array('', '', $this->getNumberOfWords($row2['phash']), '', BackendUtility::datetime($row2['crdate']), $row2['tstamp'] != $row2['crdate'] ? BackendUtility::datetime($row2['tstamp']) : '', $row2['parsetime'], $this->getNumberOfSections($row2['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row2['phash']), '', $cHash, $row2['phash'], '');
             }
         }
     }
     return $recList;
 }
Example #22
0
 /**
  * Write gif and png test
  *
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function writeGifAndPng()
 {
     $this->setUpDatabaseConnectionMock();
     $imageProcessor = $this->initializeImageProcessor();
     $parseTimeStart = GeneralUtility::milliseconds();
     $testResults = array('gif' => array(), 'png' => array());
     // Gif
     $inputFile = $this->imageBasePath . 'TestInput/Test.gif';
     $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('write-gif');
     $imResult = $imageProcessor->imageMagickConvert($inputFile, 'gif', '', '', '', '', array(), true);
     if ($imResult !== null && is_file($imResult[3])) {
         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress']) {
             clearstatcache();
             $previousSize = GeneralUtility::formatSize(filesize($imResult[3]));
             $methodUsed = GraphicalFunctions::gifCompress($imResult[3], '');
             clearstatcache();
             $compressedSize = GeneralUtility::formatSize(filesize($imResult[3]));
             /** @var \TYPO3\CMS\Install\Status\StatusInterface $message */
             $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\InfoStatus::class);
             $message->setTitle('Compressed gif');
             $message->setMessage('Method used by compress: ' . $methodUsed . LF . ' Previous filesize: ' . $previousSize . '. Current filesize:' . $compressedSize);
         } else {
             /** @var \TYPO3\CMS\Install\Status\StatusInterface $message */
             $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\InfoStatus::class);
             $message->setTitle('Gif compression not enabled by [GFX][gif_compress]');
         }
         $testResults['gif']['message'] = $message;
         $testResults['gif']['title'] = 'Write gif';
         $testResults['gif']['outputFile'] = $imResult[3];
         $testResults['gif']['referenceFile'] = $this->imageBasePath . 'TestReference/Write-gif.gif';
         $testResults['gif']['command'] = $imageProcessor->IM_commands;
     } else {
         $testResults['gif']['error'] = $this->imageGenerationFailedMessage();
     }
     // Png
     $inputFile = $this->imageBasePath . 'TestInput/Test.png';
     $imageProcessor->IM_commands = array();
     $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('write-png');
     $imResult = $imageProcessor->imageMagickConvert($inputFile, 'png', '', '', '', '', array(), true);
     if ($imResult !== null) {
         $testResults['png']['title'] = 'Write png';
         $testResults['png']['outputFile'] = $imResult[3];
         $testResults['png']['referenceFile'] = $this->imageBasePath . 'TestReference/Write-png.png';
         $testResults['png']['command'] = $imageProcessor->IM_commands;
     } else {
         $testResults['png']['error'] = $this->imageGenerationFailedMessage();
     }
     $this->view->assign('testResults', $testResults);
     return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
 }
Example #23
0
 /**
  * Rendering preview output of a field value which is not shown as a form field but just outputted.
  *
  * @param string $value The value to output
  * @param array $config Configuration for field.
  * @param string $field Name of field.
  * @return string HTML formatted output
  */
 protected function previewFieldValue($value, $config, $field = '')
 {
     if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) {
         // Ignore upload folder if internal_type is file_reference
         if ($config['config']['internal_type'] === 'file_reference') {
             $config['config']['uploadfolder'] = '';
         }
         $table = 'tt_content';
         // Making the array of file items:
         $itemArray = GeneralUtility::trimExplode(',', $value, true);
         // Showing thumbnails:
         $thumbnail = '';
         $imgs = array();
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         foreach ($itemArray as $imgRead) {
             $imgParts = explode('|', $imgRead);
             $imgPath = rawurldecode($imgParts[0]);
             $rowCopy = array();
             $rowCopy[$field] = $imgPath;
             // Icon + click menu:
             $absFilePath = GeneralUtility::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath);
             $fileInformation = pathinfo($imgPath);
             $title = $fileInformation['basename'] . ($absFilePath && @is_file($absFilePath)) ? ' (' . GeneralUtility::formatSize(filesize($absFilePath)) . ')' : ' - FILE NOT FOUND!';
             $fileIcon = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForFileExtension($fileInformation['extension'], Icon::SIZE_SMALL)->render() . '</span>';
             $imgs[] = '<span class="text-nowrap">' . BackendUtility::thumbCode($rowCopy, $table, $field, '', 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($fileIcon, $absFilePath, 0, 1, '', '+copy,info,edit,view') : $fileIcon) . $imgPath . '</span>';
         }
         return implode('<br />', $imgs);
     } else {
         return nl2br(htmlspecialchars($value));
     }
 }
Example #24
0
    /**
     * get HTML to show the user, that he is connected with his dropbox account
     *
     * @return string
     */
    public function getHtmlForConnected()
    {
        try {
            /** @var \SFroemken\FalDropbox\Dropbox\Client $dropboxClient */
            $dropboxClient = $this->objectManager->get('SFroemken\\FalDropbox\\Dropbox\\Client', $this->configuration->getAccessToken(), 'TYPO3 CMS');
            $accountInfo = $dropboxClient->getAccountInfo();
            $content = '';
            $content .= '<div style="background-color: lightgreen;">You are now connected with your dropbox account</div>';
            $content .= '
			<table border="1" cellspacing="2" cellpadding="2">
				<tr>
					<td>Name</td>
					<td>' . $accountInfo['display_name'] . '</td>
				</tr>
				<tr>
					<td>E-Mail</td>
					<td>' . $accountInfo['email'] . '</td>
				</tr>
				<tr>
					<td>Quota</td>
					<td>' . GeneralUtility::formatSize($accountInfo['quota_info']['quota'], ' | KB| MB| GB') . '</td>
				</tr>
				<tr>
					<td>Used</td>
					<td>' . GeneralUtility::formatSize($accountInfo['quota_info']['normal'], ' | KB| MB| GB') . '</td>
				</tr>
			</table>
		';
        } catch (\Exception $e) {
            $this->registry->removeAllByNamespace('fal_dropbox');
            $content = $this->getHtmlForDropboxLink();
        }
        return $content;
    }
Example #25
0
    /**
     * 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 = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($v);
                        if ($fileObject) {
                            $thumb = '';
                            $folder = $fileObject instanceof \TYPO3\CMS\Core\Resource\Folder;
                            $size = $folder ? '' : '(' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize()) . 'bytes)';
                            $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($folder ? 'folder' : strtolower($fileObject->getExtension()), array('style' => 'margin: 0 20px;', 'title' => $fileObject->getName() . ' ' . $size));
                            if ($this->clipData['_setThumb'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
                                $thumb = '<br />' . \TYPO3\CMS\Backend\Utility\BackendUtility::getThumbNail($this->backPath . 'thumbs.php', $v, ' vspace="4"');
                            }
                            $lines[] = '
								<tr>
									<td class="' . $bgColClass . '">' . $icon . '</td>
									<td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . $this->linkItemText(htmlspecialchars(\TYPO3\CMS\Core\Utility\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;') . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl('_FILE', \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($v))) . '#clip_head">' . \TYPO3\CMS\Backend\Utility\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 = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid);
                        if (is_array($rec)) {
                            $lines[] = '
								<tr>
									<td class="' . $bgColClass . '">' . $this->linkItemText(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($rec, $table)))), $rec, $table) . '</td>
									<td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . $this->linkItemText(htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(\TYPO3\CMS\Backend\Utility\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 . '\', \'' . intval($uid) . '\'); return false;') . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl($table, $uid)) . '#clip_head">' . \TYPO3\CMS\Backend\Utility\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;
    }
Example #26
0
 /**
  * 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 = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
     if ($fileObject) {
         $folder = FALSE;
         $identifier = $fileObject->getCombinedIdentifier();
         if ($fileObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
             $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile('folder', array('class' => 'absmiddle', 'title' => htmlspecialchars($fileObject->getName())));
             $folder = TRUE;
         } else {
             $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileObject->getExtension(), array('class' => 'absmiddle', 'title' => htmlspecialchars($fileObject->getName() . ' (' . GeneralUtility::formatSize($fileObject->getSize()) . ')')));
         }
         // Edit
         if (!in_array('edit', $this->disabledItems) && !$folder && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension())) {
             $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'edit', 'edit_file.gif');
         }
         // Rename
         if (!in_array('rename', $this->disabledItems)) {
             $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
         }
         // Upload
         if (!in_array('upload', $this->disabledItems) && $folder) {
             $menuItems['upload'] = $this->FILE_upload($identifier);
         }
         // New
         if (!in_array('new', $this->disabledItems) && $folder) {
             $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
         }
         // Info
         if (!in_array('info', $this->disabledItems)) {
             $menuItems['info'] = $this->DB_info($identifier, '');
         }
         $menuItems[] = 'spacer';
         // Copy:
         if (!in_array('copy', $this->disabledItems)) {
             $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
         }
         // Cut:
         if (!in_array('cut', $this->disabledItems)) {
             $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
         }
         // Paste:
         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
         if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder) {
             $elArr = $this->clipObj->elFromTable('_FILE');
             $selItem = reset($elArr);
             $elInfo = array(basename($selItem), basename($path), $this->clipObj->currentMode());
             $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
         }
         $menuItems[] = 'spacer';
         // Delete:
         if (!in_array('delete', $this->disabledItems)) {
             $menuItems['delete'] = $this->FILE_delete($identifier);
         }
     }
     // Adding external elements to the menuItems array
     $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
     // Processing by external functions?
     $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
     // Return the printed elements:
     return $this->printItems($menuItems, $icon . $fileObject->getName());
 }
 /**
  * Provides status information on the deprecation log, whether it's enabled
  * and if so whether certain limits in file size are reached.
  *
  * @return \TYPO3\CMS\Reports\Status The deprecation log status.
  */
 protected function getDeprecationLogStatus()
 {
     $title = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLog');
     $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:disabled');
     $message = '';
     $severity = \TYPO3\CMS\Reports\Status::OK;
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:enabled');
         $message = '<p>' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogEnabled') . '</p>';
         $severity = \TYPO3\CMS\Reports\Status::NOTICE;
         $logFile = GeneralUtility::getDeprecationLogFileName();
         $logFileSize = 0;
         if (@file_exists($logFile)) {
             $logFileSize = filesize($logFile);
             $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogFile'), $this->getDeprecationLogFileLink()) . '</p>';
             $removeDeprecationLogFileUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=removeDeprecationLogFile';
             $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogSize'), GeneralUtility::formatSize($logFileSize)) . ' <a href="' . $removeDeprecationLogFileUrl . '">' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeleteLink') . '</a></p>';
         }
         if ($logFileSize > $this->deprecationLogFileSizeWarningThreshold) {
             $severity = \TYPO3\CMS\Reports\Status::WARNING;
         }
         if ($logFileSize > $this->deprecationLogFileSizeErrorThreshold) {
             $severity = \TYPO3\CMS\Reports\Status::ERROR;
         }
     }
     return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $title, $value, $message, $severity);
 }
Example #28
0
 /**
  * This prints a single result row, including a recursive call for subrows.
  *
  * @param array $row Search result row
  * @param integer $headerOnly 1=Display only header (for sub-rows!), 2=nothing at all
  * @return string HTML code
  */
 protected function compileSingleResultRow($row, $headerOnly = 0)
 {
     $specRowConf = $this->getSpecialConfigForResultRow($row);
     $resultData = $row;
     $resultData['headerOnly'] = $headerOnly;
     $resultData['CSSsuffix'] = $specRowConf['CSSsuffix'] ? '-' . $specRowConf['CSSsuffix'] : '';
     if ($this->multiplePagesType($row['item_type'])) {
         $dat = unserialize($row['cHashParams']);
         $pp = explode('-', $dat['key']);
         if ($pp[0] != $pp[1]) {
             $resultData['titleaddition'] = ', ' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.page', 'indexed_search') . ' ' . $dat['key'];
         } else {
             $resultData['titleaddition'] = ', ' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.pages', 'indexed_search') . ' ' . $pp[0];
         }
     }
     $title = $resultData['item_title'] . $resultData['titleaddition'];
     // If external media, link to the media-file instead.
     if ($row['item_type']) {
         if ($row['show_resume']) {
             // Can link directly.
             $targetAttribute = '';
             if ($GLOBALS['TSFE']->config['config']['fileTarget']) {
                 $targetAttribute = ' target="' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"';
             }
             $title = '<a href="' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>' . htmlspecialchars($title) . '</a>';
         } else {
             // Suspicious, so linking to page instead...
             $copiedRow = $row;
             unset($copiedRow['cHashParams']);
             $title = $this->linkPage($row['page_id'], $title, $copiedRow);
         }
     } else {
         // Else the page:
         // Prepare search words for markup in content:
         if ($this->settings['forwardSearchWordsInResultLink']) {
             $markUpSwParams = array('no_cache' => 1);
             foreach ($this->searchWords as $d) {
                 $markUpSwParams['sword_list'][] = $d['sword'];
             }
         } else {
             $markUpSwParams = array();
         }
         $title = $this->linkPage($row['data_page_id'], $title, $row, $markUpSwParams);
     }
     $resultData['title'] = $title;
     $resultData['icon'] = $this->makeItemTypeIcon($row['item_type'], '', $specRowConf);
     $resultData['rating'] = $this->makeRating($row);
     $resultData['description'] = $this->makeDescription($row, $this->searchData['extResume'] && !$headerOnly ? 0 : 1);
     $resultData['language'] = $this->makeLanguageIndication($row);
     $resultData['size'] = GeneralUtility::formatSize($row['item_size']);
     $resultData['created'] = $row['item_crdate'];
     $resultData['modified'] = $row['item_mtime'];
     $pI = parse_url($row['data_filename']);
     if ($pI['scheme']) {
         $targetAttribute = '';
         if ($GLOBALS['TSFE']->config['config']['fileTarget']) {
             $targetAttribute = ' target="' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"';
         }
         $resultData['path'] = '<a href="' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>' . htmlspecialchars($row['data_filename']) . '</a>';
     } else {
         $pathId = $row['data_page_id'] ?: $row['page_id'];
         $pathMP = $row['data_page_id'] ? $row['data_page_mp'] : '';
         $pathStr = htmlspecialchars($this->getPathFromPageId($pathId, $pathMP));
         $resultData['path'] = $this->linkPage($pathId, $pathStr, array('cHashParams' => $row['cHashParams'], 'data_page_type' => $row['data_page_type'], 'data_page_mp' => $pathMP, 'sys_language_uid' => $row['sys_language_uid']));
         // check if the access is restricted
         if (is_array($this->requiredFrontendUsergroups[$id]) && count($this->requiredFrontendUsergroups[$id])) {
             $resultData['access'] = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('indexed_search') . 'pi/res/locked.gif" width="12" height="15" vspace="5" title="' . sprintf(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.memberGroups', 'indexed_search'), implode(',', array_unique($this->requiredFrontendUsergroups[$id]))) . '" alt="" />';
         }
     }
     // If there are subrows (eg. subpages in a PDF-file or if a duplicate page
     // is selected due to user-login (phash_grouping))
     if (is_array($row['_sub'])) {
         $resultData['subresults'] = array();
         if ($this->multiplePagesType($row['item_type'])) {
             $resultData['subresults']['header'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherMatching', 'indexed_search');
             foreach ($row['_sub'] as $subRow) {
                 $resultData['subresults']['items'][] = $this->compileSingleResultRow($subRow, 1);
             }
         } else {
             $resultData['subresults']['header'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherMatching', 'indexed_search');
             $resultData['subresults']['info'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherPageAsWell', 'indexed_search');
         }
     }
     return $resultData;
 }
Example #29
0
    /**
     * Displays an overview of the header-content.
     *
     * @return string HTML content
     */
    public function displayContentOverview()
    {
        // Check extension dependencies:
        if (is_array($this->dat['header']['extensionDependencies'])) {
            foreach ($this->dat['header']['extensionDependencies'] as $extKey) {
                if (!empty($extKey) && !ExtensionManagementUtility::isLoaded($extKey)) {
                    $this->error('DEPENDENCY: The extension with key "' . $extKey . '" must be installed!');
                }
            }
        }
        // Probably this is done to save memory space?
        unset($this->dat['files']);
        $out = '';
        // Traverse header:
        if (is_array($this->dat['header'])) {
            $this->remainHeader = $this->dat['header'];
            // If there is a page tree set, show that:
            $lang = $this->getLanguageService();
            if (is_array($this->dat['header']['pagetree'])) {
                reset($this->dat['header']['pagetree']);
                $lines = array();
                $this->traversePageTree($this->dat['header']['pagetree'], $lines);
                $rows = array();
                $rows[] = '
				<tr class="bgColor5 tableheader">
					<td>' . $lang->getLL('impexpcore_displaycon_controls', true) . '</td>
					<td>' . $lang->getLL('impexpcore_displaycon_title', true) . '</td>
					<td>' . $lang->getLL('impexpcore_displaycon_size', true) . '</td>
					<td>' . $lang->getLL('impexpcore_displaycon_message', true) . '</td>
					' . ($this->update ? '<td>' . $lang->getLL('impexpcore_displaycon_updateMode', true) . '</td>' : '') . '
					' . ($this->update ? '<td>' . $lang->getLL('impexpcore_displaycon_currentPath', true) . '</td>' : '') . '
					' . ($this->showDiff ? '<td>' . $lang->getLL('impexpcore_displaycon_result', true) . '</td>' : '') . '
				</tr>';
                foreach ($lines as $r) {
                    $rows[] = '
					<tr class="' . $r['class'] . '">
						<td>' . $this->renderControls($r) . '</td>
						<td nowrap="nowrap">' . $r['preCode'] . $r['title'] . '</td>
						<td nowrap="nowrap">' . GeneralUtility::formatSize($r['size']) . '</td>
						<td nowrap="nowrap">' . ($r['msg'] && !$this->doesImport ? '<span class="text-danger">' . htmlspecialchars($r['msg']) . '</span>' : '') . '</td>
						' . ($this->update ? '<td nowrap="nowrap">' . $r['updateMode'] . '</td>' : '') . '
						' . ($this->update ? '<td nowrap="nowrap">' . $r['updatePath'] . '</td>' : '') . '
						' . ($this->showDiff ? '<td>' . $r['showDiffContent'] . '</td>' : '') . '
					</tr>';
                }
                $out = '
					<strong>' . $lang->getLL('impexpcore_displaycon_insidePagetree', true) . '</strong>
					<br /><br />
					<table border="0" cellpadding="0" cellspacing="1">' . implode('', $rows) . '</table>
					<br /><br />';
            }
            // Print remaining records that were not contained inside the page tree:
            $lines = array();
            if (is_array($this->remainHeader['records'])) {
                if (is_array($this->remainHeader['records']['pages'])) {
                    $this->traversePageRecords($this->remainHeader['records']['pages'], $lines);
                }
                $this->traverseAllRecords($this->remainHeader['records'], $lines);
                if (!empty($lines)) {
                    $rows = array();
                    $rows[] = '
					<tr class="bgColor5 tableheader">
						<td>' . $lang->getLL('impexpcore_displaycon_controls', true) . '</td>
						<td>' . $lang->getLL('impexpcore_displaycon_title', true) . '</td>
						<td>' . $lang->getLL('impexpcore_displaycon_size', true) . '</td>
						<td>' . $lang->getLL('impexpcore_displaycon_message', true) . '</td>
						' . ($this->update ? '<td>' . $lang->getLL('impexpcore_displaycon_updateMode', true) . '</td>' : '') . '
						' . ($this->update ? '<td>' . $lang->getLL('impexpcore_displaycon_currentPath', true) . '</td>' : '') . '
						' . ($this->showDiff ? '<td>' . $lang->getLL('impexpcore_displaycon_result', true) . '</td>' : '') . '
					</tr>';
                    foreach ($lines as $r) {
                        $rows[] = '<tr class="' . $r['class'] . '">
							<td>' . $this->renderControls($r) . '</td>
							<td nowrap="nowrap">' . $r['preCode'] . $r['title'] . '</td>
							<td nowrap="nowrap">' . GeneralUtility::formatSize($r['size']) . '</td>
							<td nowrap="nowrap">' . ($r['msg'] && !$this->doesImport ? '<span class="text-danger">' . htmlspecialchars($r['msg']) . '</span>' : '') . '</td>
							' . ($this->update ? '<td nowrap="nowrap">' . $r['updateMode'] . '</td>' : '') . '
							' . ($this->update ? '<td nowrap="nowrap">' . $r['updatePath'] . '</td>' : '') . '
							' . ($this->showDiff ? '<td>' . $r['showDiffContent'] . '</td>' : '') . '
						</tr>';
                    }
                    $out .= '
						<strong>' . $lang->getLL('impexpcore_singlereco_outsidePagetree', true) . '</strong>
						<br /><br />
						<table border="0" cellpadding="0" cellspacing="1">' . implode('', $rows) . '</table>';
                }
            }
        }
        return $out;
    }
Example #30
0
    /**
     * Rich Text Editor (RTE) user element selector
     *
     * @param 	[type]		$openKeys: ...
     * @return 	[type]		...
     * @todo Define visibility
     */
    public function main_user($openKeys)
    {
        // Starting content:
        $content = $this->doc->startPage($GLOBALS['LANG']->getLL('Insert Custom Element', 1));
        $RTEtsConfigParts = explode(':', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RTEtsConfigParams'));
        $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
        $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        if (is_array($thisConfig['userElements.'])) {
            $categories = array();
            foreach ($thisConfig['userElements.'] as $k => $value) {
                $ki = intval($k);
                $v = $thisConfig['userElements.'][$ki . '.'];
                if (substr($k, -1) == '.' && is_array($v)) {
                    $subcats = array();
                    $openK = $ki;
                    if ($openKeys[$openK]) {
                        $mArray = '';
                        switch ((string) $v['load']) {
                            case 'images_from_folder':
                                $mArray = array();
                                if ($v['path'] && @is_dir(PATH_site . $v['path'])) {
                                    $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir(PATH_site . $v['path'], 'gif,jpg,jpeg,png', 0, '');
                                    if (is_array($files)) {
                                        $c = 0;
                                        foreach ($files as $filename) {
                                            $iInfo = @getimagesize(PATH_site . $v['path'] . $filename);
                                            $iInfo = $this->calcWH($iInfo, 50, 100);
                                            $ks = (string) (100 + $c);
                                            $mArray[$ks] = $filename;
                                            $mArray[$ks . '.'] = array('content' => '<img src="' . $this->siteUrl . $v['path'] . $filename . '" />', '_icon' => '<img src="' . $this->siteUrl . $v['path'] . $filename . '" ' . $iInfo[3] . ' />', 'description' => $GLOBALS['LANG']->getLL('filesize') . ': ' . str_replace('&nbsp;', ' ', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(@filesize(PATH_site . $v['path'] . $filename))) . ', ' . $GLOBALS['LANG']->getLL('pixels', 1) . ': ' . $iInfo[0] . 'x' . $iInfo[1]);
                                            $c++;
                                        }
                                    }
                                }
                                break;
                        }
                        if (is_array($mArray)) {
                            if ($v['merge']) {
                                $v = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($mArray, $v);
                            } else {
                                $v = $mArray;
                            }
                        }
                        foreach ($v as $k2 => $dummyValue) {
                            $k2i = intval($k2);
                            if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
                                $title = trim($v[$k2i]);
                                if (!$title) {
                                    $title = '[' . $GLOBALS['LANG']->getLL('noTitle', 1) . ']';
                                } else {
                                    $title = $GLOBALS['LANG']->sL($title, 1);
                                }
                                $description = $GLOBALS['LANG']->sL($v[$k2i . '.']['description'], 1) . '<br />';
                                if (!$v[$k2i . '.']['dontInsertSiteUrl']) {
                                    $v[$k2i . '.']['content'] = str_replace('###_URL###', $this->siteUrl, $v[$k2i . '.']['content']);
                                }
                                $logo = $v[$k2i . '.']['_icon'] ? $v[$k2i . '.']['_icon'] : '';
                                $onClickEvent = '';
                                switch ((string) $v[$k2i . '.']['mode']) {
                                    case 'wrap':
                                        $wrap = explode('|', $v[$k2i . '.']['content']);
                                        $onClickEvent = 'wrapHTML(' . $GLOBALS['LANG']->JScharCode($wrap[0]) . ',' . $GLOBALS['LANG']->JScharCode($wrap[1]) . ',false);';
                                        break;
                                    case 'processor':
                                        $script = trim($v[$k2i . '.']['submitToScript']);
                                        if (substr($script, 0, 4) != 'http') {
                                            $script = $this->siteUrl . $script;
                                        }
                                        if ($script) {
                                            $onClickEvent = 'processSelection(' . $GLOBALS['LANG']->JScharCode($script) . ');';
                                        }
                                        break;
                                    case 'insert':
                                    default:
                                        $onClickEvent = 'insertHTML(' . $GLOBALS['LANG']->JScharCode($v[$k2i . '.']['content']) . ');';
                                        break;
                                }
                                $A = array('<a href="#" onClick="' . $onClickEvent . 'return false;">', '</a>');
                                $subcats[$k2i] = '<tr>
									<td><img src="clear.gif" width="18" height="1" /></td>
									<td class="bgColor4" valign="top">' . $A[0] . $logo . $A[1] . '</td>
									<td class="bgColor4" valign="top">' . $A[0] . '<strong>' . $title . '</strong><br />' . $description . $A[1] . '</td>
								</tr>';
                            }
                        }
                        ksort($subcats);
                    }
                    $categories[$ki] = implode('', $subcats);
                }
            }
            ksort($categories);
            // Render menu of the items:
            $lines = array();
            foreach ($categories as $k => $v) {
                $title = trim($thisConfig['userElements.'][$k]);
                $openK = $k;
                if (!$title) {
                    $title = '[' . $GLOBALS['LANG']->getLL('noTitle', 1) . ']';
                } else {
                    $title = $GLOBALS['LANG']->sL($title, 1);
                }
                $lines[] = '<tr><td colspan="3" class="bgColor5"><a href="#" title="' . $GLOBALS['LANG']->getLL('expand', 1) . '" onClick="jumpToUrl(\'?OC_key=' . ($openKeys[$openK] ? 'C|' : 'O|') . $openK . '\');return false;"><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/' . ($openKeys[$openK] ? 'minus' : 'plus') . 'bullet.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('expand', 1) . '" /><strong>' . $title . '</strong></a></td></tr>';
                $lines[] = $v;
            }
            $content .= '<table border="0" cellpadding="1" cellspacing="1">' . implode('', $lines) . '</table>';
        }
        $content .= $this->doc->endPage();
        return $content;
    }