/**
  * Gets our attached files as an array of arrays with the elements "name"
  * and "size" of the attached file.
  *
  * The displayed file name is relative to the tx_seminars upload directory
  * and is linked to the actual file's URL.
  *
  * The file size will have, depending on the file size, one of the following
  * units appended: K for Kilobytes, M for Megabytes and G for Gigabytes.
  *
  * The returned array will be sorted like the files are sorted in the back-
  * end form.
  *
  * If this event is an event date, this function will return both the
  * topic's file and the date's files (in that order).
  *
  * Note: This functions' return values already are htmlspecialchared.
  *
  * @param tslib_pibase $plugin a tslib_pibase object for a live page
  *
  * @return array[] an array of arrays with the elements "name" and
  *               "size" of the attached file, will be empty if
  *               there are no attached files
  */
 public function getAttachedFiles(tslib_pibase $plugin)
 {
     if (!$this->hasAttachedFiles()) {
         return array();
     }
     if ($this->isTopicOkay()) {
         $filesFromTopic = $this->topic->getAttachedFiles($plugin);
     } else {
         $filesFromTopic = array();
     }
     $result = $filesFromTopic;
     $uploadFolderPath = PATH_site . 'uploads/tx_seminars/';
     $uploadFolderUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'uploads/tx_seminars/';
     $attachedFiles = t3lib_div::trimExplode(',', $this->getRecordPropertyString('attached_files'), TRUE);
     foreach ($attachedFiles as $attachedFile) {
         $matches = array();
         preg_match('/\\.(\\w+)$/', basename($attachedFile), $matches);
         $result[] = array('name' => $plugin->cObj->typoLink(htmlspecialchars(basename($attachedFile)), array('parameter' => $uploadFolderUrl . $attachedFile)), 'type' => htmlspecialchars(isset($matches[1]) ? $matches[1] : 'none'), 'size' => t3lib_div::formatSize(filesize($uploadFolderPath . $attachedFile)));
     }
     return $result;
 }
    /**
     * The main function in the class
     *
     * @return	string		HTML content
     */
    function cacheFiles()
    {
        $content = '';
        // CURRENT:
        $content .= '<strong>1: The current cache files:</strong>' . Tx_Extdeveval_Compatibility::viewArray(t3lib_extMgm::currentCacheFiles());
        // REMOVING?
        if (t3lib_div::_GP('REMOVE_temp_CACHED')) {
            $number = $this->removeCacheFiles();
            $content .= '<hr /><p><strong>2: Tried to remove ' . $number . ' cache files.</strong></p>';
        }
        if (t3lib_div::_GP('REMOVE_temp_CACHED_ALL')) {
            $content .= '<hr /><p><strong>2: Removing ALL "temp_CACHED_*" files:</strong></p>' . $this->removeALLtempCachedFiles();
        }
        $files = t3lib_div::getFilesInDir(PATH_typo3conf, 'php');
        $tRows = array();
        foreach ($files as $f) {
            $tRows[] = '<tr>
				<td>' . htmlspecialchars($f) . '</td>
				<td>' . t3lib_div::formatSize(filesize(PATH_typo3conf . $f)) . '</td>
			</tr>';
        }
        $content .= '<br /><strong>3: PHP files (now) in "' . PATH_typo3conf . '":</strong><br />
		<table border="1">' . implode('', $tRows) . '</table>

		<input type="submit" name="REMOVE_temp_CACHED" value="REMOVE current temp_CACHED files" />
		<input type="submit" name="REMOVE_temp_CACHED_ALL" value="REMOVE ALL temp_CACHED_* files" />
		<input type="submit" name="_" value="Refresh" />
		';
        return $content;
    }
 /**
  * Renders the size of a file using t3lib_div::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
  * @return string
  * @throws Tx_Fluid_Core_ViewHelper_Exception_InvalidVariableException
  */
 public function render($file, $format = '', $hideError = FALSE)
 {
     if (!is_file($file)) {
         $errorMessage = sprintf('Given file "%s" for %s is not valid', htmlspecialchars($file), get_class());
         t3lib_div::devLog($errorMessage, 'news', t3lib_div::SYSLOG_SEVERITY_WARNING);
         if (!$hideError) {
             throw new Tx_Fluid_Core_ViewHelper_Exception_InvalidVariableException('Given file is not a valid file: ' . htmlspecialchars($file));
         }
     }
     $fileSize = t3lib_div::formatSize(filesize($file), $format);
     return $fileSize;
 }
    /**
     * Displays an overview of the header-content.
     *
     * @return	string		HTML content
     */
    function displayContentOverview()
    {
        global $LANG;
        // Check extension dependencies:
        if (is_array($this->dat['header']['extensionDependencies'])) {
            foreach ($this->dat['header']['extensionDependencies'] as $extKey) {
                if (!t3lib_extMgm::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']);
        // Traverse header:
        $this->remainHeader = $this->dat['header'];
        if (is_array($this->remainHeader)) {
            // If there is a page tree set, show that:
            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', 1) . '</td>
					<td>' . $LANG->getLL('impexpcore_displaycon_title', 1) . '</td>
					<td>' . $LANG->getLL('impexpcore_displaycon_size', 1) . '</td>
					<td>' . $LANG->getLL('impexpcore_displaycon_message', 1) . '</td>
					' . ($this->update ? '<td>' . $LANG->getLL('impexpcore_displaycon_updateMode', 1) . '</td>' : '') . '
					' . ($this->update ? '<td>' . $LANG->getLL('impexpcore_displaycon_currentPath', 1) . '</td>' : '') . '
					' . ($this->showDiff ? '<td>' . $LANG->getLL('impexpcore_displaycon_result', 1) . '</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">' . t3lib_div::formatSize($r['size']) . '</td>
						<td nowrap="nowrap">' . ($r['msg'] && !$this->doesImport ? '<span class="typo3-red">' . 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', 1) . '</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 (count($lines)) {
                    $rows = array();
                    $rows[] = '
					<tr class="bgColor5 tableheader">
						<td>' . $LANG->getLL('impexpcore_displaycon_controls', 1) . '</td>
						<td>' . $LANG->getLL('impexpcore_displaycon_title', 1) . '</td>
						<td>' . $LANG->getLL('impexpcore_displaycon_size', 1) . '</td>
						<td>' . $LANG->getLL('impexpcore_displaycon_message', 1) . '</td>
						' . ($this->update ? '<td>' . $LANG->getLL('impexpcore_displaycon_updateMode', 1) . '</td>' : '') . '
						' . ($this->update ? '<td>' . $LANG->getLL('impexpcore_displaycon_currentPath', 1) . '</td>' : '') . '
						' . ($this->showDiff ? '<td>' . $LANG->getLL('impexpcore_displaycon_result', 1) . '</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">' . t3lib_div::formatSize($r['size']) . '</td>
							<td nowrap="nowrap">' . ($r['msg'] && !$this->doesImport ? '<span class="typo3-red">' . 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', 1) . '</strong>
						<br /><br />
						<table border="0" cellpadding="0" cellspacing="1">' . implode('', $rows) . '</table>';
                }
            }
        }
        return $out;
    }
    /**
     * 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	string		The folder path to expand
     * @param	string		List of fileextensions to show
     * @return	string		HTML output
     */
    function TBE_dragNDrop($expandFolder = 0, $extensionList = '')
    {
        global $BACK_PATH;
        $extensionList = $extensionList == '*' ? '' : $extensionList;
        $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
        $out = '';
        if ($expandFolder && $this->checkFolder($expandFolder)) {
            if ($this->isWebFolder($expandFolder)) {
                // Read files from directory:
                $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1);
                // $extensionList="",$prependPath=0,$order='')
                if (is_array($files)) {
                    $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
                    $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
                    $picon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
                    $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder), $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 $filepath) {
                        $fI = pathinfo($filepath);
                        // URL of image:
                        $iurl = $this->siteURL . t3lib_div::rawurlencodeFP(substr($filepath, strlen(PATH_site)));
                        // Show only web-images
                        if (t3lib_div::inList('gif,jpeg,jpg,png', strtolower($fI['extension']))) {
                            $imgInfo = @getimagesize($filepath);
                            $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
                            $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
                            $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
                            $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $ficon, 'width="18" height="16"') . ' class="absmiddle" title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
                            $filenameAndIcon = $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath), $titleLen));
                            if (t3lib_div::_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(t3lib_div::linkThisScript(array('noLimit' => '1'))) . '">' . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/icon_warning2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', 1) . '" alt="" />' . '</a>' : '') . $pDim . '&nbsp;</td>
								</tr>';
                            $lines[] = '
								<tr>
									<td colspan="2"><img src="' . $iurl . '" width="' . $IW . '" height="' . $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>';
                }
            } else {
                // Print this warning if the folder is NOT a web folder:
                $out .= $this->barheader($GLOBALS['LANG']->getLL('files'));
                $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
            }
        }
        return $out;
    }
    /**
     * Rich Text Editor (RTE) user element selector
     *
     * @param	[type]		$openKeys: ...
     * @return	[type]		...
     */
    function main_user($openKeys)
    {
        global $LANG, $BACK_PATH, $BE_USER;
        // Starting content:
        $content .= $this->doc->startPage($LANG->getLL('Insert Custom Element', 1));
        $RTEtsConfigParts = explode(':', t3lib_div::_GP('RTEtsConfigParams'));
        $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
        $thisConfig = t3lib_BEfunc::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 = t3lib_div::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' => $LANG->getLL('filesize') . ': ' . str_replace('&nbsp;', ' ', t3lib_div::formatSize(@filesize(PATH_site . $v['path'] . $filename))) . ', ' . $LANG->getLL('pixels', 1) . ': ' . $iInfo[0] . 'x' . $iInfo[1]);
                                            $c++;
                                        }
                                    }
                                }
                                break;
                        }
                        if (is_array($mArray)) {
                            if ($v['merge']) {
                                $v = t3lib_div::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 = '[' . $LANG->getLL('noTitle', 1) . ']';
                                } else {
                                    $title = $LANG->sL($title, 1);
                                }
                                $description = $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(' . $LANG->JScharCode($wrap[0]) . ',' . $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(' . $LANG->JScharCode($script) . ');';
                                        }
                                        break;
                                    case 'insert':
                                    default:
                                        $onClickEvent = 'insertHTML(' . $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 = '[' . $LANG->getLL('noTitle', 1) . ']';
                } else {
                    $title = $LANG->sL($title, 1);
                }
                //$lines[]='<tr><td colspan="3" class="bgColor5"><a href="'.t3lib_div::linkThisScript(array('OC_key' => ($openKeys[$openK]?'C|':'O|').$openK, 'editorNo' => $this->editorNo)).'" title="'.$LANG->getLL('expand',1).'"><img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/'.($openKeys[$openK]?'minus':'plus').'bullet.gif','width="18" height="16"').' title="'.$LANG->getLL('expand',1).'" /><strong>'.$title.'</strong></a></td></tr>';
                $lines[] = '<tr><td colspan="3" class="bgColor5"><a href="#" title="' . $LANG->getLL('expand', 1) . '" onClick="jumpToUrl(\'?OC_key=' . ($openKeys[$openK] ? 'C|' : 'O|') . $openK . '\');return false;"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/' . ($openKeys[$openK] ? 'minus' : 'plus') . 'bullet.gif', 'width="18" height="16"') . ' title="' . $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;
    }
 /**
  * @param	[type]		$expandFolder: ...
  * @param	[type]		$plainFlag: ...
  * @return	[type]		...
  */
 function expandFolder($expandFolder = 0, $plainFlag = 0, $noThumbs = 0)
 {
     global $LANG;
     $expandFolder = $expandFolder ? $expandFolder : t3lib_div::_GP("expandFolder");
     $out = "";
     $resolutionLimit_x = $this->thisConfig['typo3filemanager.']['maxPlainImages.']['width'];
     $resolutionLimit_y = $this->thisConfig['typo3filemanager.']['maxPlainImages.']['height'];
     if ($expandFolder) {
         $files = t3lib_div::getFilesInDir($expandFolder, $plainFlag ? "jpg,jpeg,gif,png" : $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"], 1, 1);
         // $extensionList="",$prependPath=0,$order="")
         if (is_array($files)) {
             reset($files);
             $titleLen = intval($GLOBALS["BE_USER"]->uc["titleLen"]);
             $picon = '<img src="' . $this->doc->backPath . 'gfx/i/_icon_webfolders.gif" width="18" height="16" alt="folder" />';
             $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder), $titleLen));
             $out .= '<span class="nobr">' . $picon . '</span><br />';
             $imgObj = t3lib_div::makeInstance("t3lib_stdGraphic");
             $imgObj->init();
             $imgObj->mayScaleUp = 0;
             $imgObj->tempPath = PATH_site . $imgObj->tempPath;
             $lines = array();
             while (list(, $filepath) = each($files)) {
                 $fI = pathinfo($filepath);
                 //$iurl = $this->siteUrl.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
                 $iurl = t3lib_div::rawUrlEncodeFP(substr($filepath, strlen(PATH_site)));
                 $imgInfo = $imgObj->getImageDimensions($filepath);
                 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"]));
                 $pDim = $imgInfo[0] . "x" . $imgInfo[1] . " pixels";
                 $size = " (" . t3lib_div::formatSize(filesize($filepath)) . "bytes, " . $pDim . ")";
                 $icon = '<img src="' . $this->doc->backPath . 'gfx/fileicons/' . $icon . '" style="width: 18px; height: 16px; border: none;" title="' . $fI["basename"] . $size . '" class="absmiddle" alt="' . $icon . '" />';
                 if (!$plainFlag) {
                     $ATag = '<a href="#" onclick="return jumpToUrl(\'?insertMagicImage=' . rawurlencode($filepath) . '\');">';
                 } else {
                     $ATag = '<a href="#" onclick="return insertImage(\'' . $iurl . '\',' . $imgInfo[0] . ',' . $imgInfo[1] . ');">';
                 }
                 $ATag_e = "</a>";
                 if ($plainFlag && ($imgInfo[0] > $resolutionLimit_x || $imgInfo[1] > $resolutionLimit_y)) {
                     $ATag = "";
                     $ATag_e = "";
                     $ATag2 = "";
                     $ATag2_e = "";
                 } else {
                     $ATag2 = '<a href="#" onclick="launchView(\'' . rawurlencode($filepath) . '\'); return false;">';
                     $ATag2_e = "</a>";
                 }
                 $filenameAndIcon = $ATag . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath), $titleLen)) . $ATag_e;
                 $lines[] = '<tr class="bgColor4"><td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td></tr><tr><td nowrap="nowrap" class="pixel">' . $pDim . '&nbsp;</td></tr>';
                 $lines[] = '<tr><td>' . ($noThumbs ? "" : $ATag2 . t3lib_BEfunc::getThumbNail($this->doc->backPath . 'thumbs.php', $filepath, 'hspace="5" vspace="5" border="1"', $this->thisConfig['typo3filemanager.']['thumbs.']['width'] . 'x' . $this->thisConfig['typo3filemanager.']['thumbs.']['height']) . $ATag2_e) . '</td></tr>';
                 $lines[] = '<tr><td><img src="clear.gif" style="width: 1px; height: 3px;" alt="clear" /></td></tr>';
             }
             $out .= '<table border="0" cellpadding="0" cellspacing="1">' . implode("", $lines) . '</table>';
         }
     }
     return $out;
 }
 /**
  * Formats a number to GB, Mb or Kb or just bytes
  *
  * @param	integer		Number of bytes to format.
  * @param	string		Labels for bytes, kilo, mega and giga separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value)
  * @return	string
  * @see t3lib_div::formatSize(), stdWrap()
  * @deprecated since TYPO3 3.6, will be removed in TYPO3 4.6 - Use t3lib_div::formatSize() instead
  */
 function bytes($sizeInBytes, $labels)
 {
     t3lib_div::logDeprecatedFunction();
     return t3lib_div::formatSize($sizeInBytes, $labels);
 }
    /**
     * View result
     *
     * @return    HTML with filelist and fileview
     */
    function view_result()
    {
        $this->makeFilesArray($this->saveKey);
        $keyA = array_keys($this->fileArray);
        asort($keyA);
        $filesOverview1 = array();
        $filesOverview2 = array();
        $filesContent = array();
        $filesOverview1[] = '<tr' . $this->bgCol(1) . '>
			<td><strong>' . $this->fw('Filename:') . '</strong></td>
			<td><strong>' . $this->fw('Size:') . '</strong></td>
			<td><strong>' . $this->fw('&nbsp;') . '</strong></td>
			<td><strong>' . $this->fw('Overwrite:') . '</strong></td>
		</tr>';
        foreach ($keyA as $fileName) {
            $data = $this->fileArray[$fileName];
            $fI = pathinfo($fileName);
            if (t3lib_div::inList('php,sql,txt,xml', strtolower($fI['extension']))) {
                $linkToFile = '<strong><a href="#' . md5($fileName) . '">' . $this->fw("&nbsp;View&nbsp;") . '</a></strong>';
                if ($fI['extension'] == 'xml') {
                    $data['content'] = $GLOBALS['LANG']->csConvObj->utf8_decode($data['content'], $GLOBALS['LANG']->charSet);
                }
                $filesContent[] = '<tr' . $this->bgCol(1) . '>
				<td><a name="' . md5($fileName) . '"></a><strong>' . $this->fw($fileName) . '</strong></td>
				</tr>
				<tr>
					<td>' . $this->preWrap($data['content'], $fI['extension']) . '</td>
				</tr>';
            } else {
                $linkToFile = $this->fw('&nbsp;');
            }
            $line = '<tr' . $this->bgCol(2) . '>
				<td>' . $this->fw($fileName) . '</td>
				<td>' . $this->fw(t3lib_div::formatSize($data['size'])) . '</td>
				<td>' . $linkToFile . '</td>
				<td>';
            if ($fileName == 'doc/wizard_form.dat' || $fileName == 'doc/wizard_form.html') {
                $line .= '<input type="hidden" name="' . $this->piFieldName('wizArray_upd') . '[save][overwrite_files][' . $fileName . ']" value="1" />';
            } else {
                $checked = '';
                if (!is_array($this->wizArray['save']['overwrite_files']) || isset($this->wizArray['save']['overwrite_files'][$fileName]) && $this->wizArray['save']['overwrite_files'][$fileName] == '1' || !isset($this->wizArray['save']['overwrite_files'][$fileName])) {
                    $checked = ' checked="checked"';
                }
                $line .= '<input type="hidden" name="' . $this->piFieldName('wizArray_upd') . '[save][overwrite_files][' . $fileName . ']" value="0" />';
                $line .= '<input type="checkbox" name="' . $this->piFieldName('wizArray_upd') . '[save][overwrite_files][' . $fileName . ']" value="1"' . $checked . ' />';
            }
            $line .= '</td>
			</tr>';
            if (strstr($fileName, '/')) {
                $filesOverview2[] = $line;
            } else {
                $filesOverview1[] = $line;
            }
        }
        $content = '<table border="0" cellpadding="1" cellspacing="2">' . implode('', $filesOverview1) . implode('', $filesOverview2) . '</table>';
        $content .= '<br /><input type="submit" name="' . $this->piFieldName('updateResult') . '" value="Update result" /><br />';
        $content .= $this->fw('<br /><strong>Author name:</strong> ' . $this->wizArray['emconf'][1]['author'] . '
							<br /><strong>Author email:</strong> ' . $this->wizArray['emconf'][1]['author_email']);
        $content .= '<br /><br />';
        if (!$this->EMmode) {
            $content .= '<input type="submit" name="' . $this->piFieldName('WRITE') . '" value="WRITE to \'' . $this->saveKey . '\'" />';
        } else {
            // $content.='
            // 	<strong>'.$this->fw('Write to location:').'</strong><br />
            // 	<select name="'.$this->piFieldName('loc').'">'.
            // 		'<option value="L" selected="selected">Local: '.$this->pObj->typePaths['L'].$this->saveKey.'/'.(@is_dir(PATH_site.$this->pObj->typePaths['L'].$this->saveKey)?' (OVERWRITE)':' (empty)').'</option>':'').
            // 	'</select>
            // 	<input type="submit" name="'.$this->piFieldName('WRITE').'" value="WRITE" onclick="return confirm(\'If the setting in the selectorbox says OVERWRITE\nthen the marked files of the current extension in that location will be OVERRIDDEN! \nPlease decide if you want to continue.\n\n(Remember, this is a *kickstarter* - NOT AN editor!)\');" />
            // ';
        }
        $this->afterContent = '<br /><table border="0" cellpadding="1" cellspacing="2">' . implode('', $filesContent) . '</table>';
        return $content;
    }
 /**
  * Handling files for group/select function
  *
  * @param	array		Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
  * @param	array		Configuration array from TCA of the field
  * @param	string		Current value of the field
  * @param	array		Array of uploaded files, if any
  * @param	string		Status ("update" or ?)
  * @param	string		tablename of record
  * @param	integer		UID of record
  * @param	string		Field identifier ([table:uid:field:....more for flexforms?]
  * @return	array		Modified value array
  * @see checkValue_group_select()
  */
 function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID)
 {
     if (!$this->bypassFileHandling) {
         // If filehandling should NOT be bypassed, do processing:
         // If any files are uploaded, add them to value array
         if (is_array($uploadedFileArray) && $uploadedFileArray['name'] && strcmp($uploadedFileArray['tmp_name'], 'none')) {
             $valueArray[] = $uploadedFileArray['tmp_name'];
             $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
         }
         // Creating fileFunc object.
         if (!$this->fileFunc) {
             $this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
             $this->include_filefunctions = 1;
         }
         // Setting permitted extensions.
         $all_files = array();
         $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
         $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ? $tcaFieldConf['disallowed'] : '*';
         $all_files['ftpspace'] = $all_files['webspace'];
         $this->fileFunc->init('', $all_files);
     }
     // If there is an upload folder defined:
     if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
         if (!$this->bypassFileHandling) {
             // If filehandling should NOT be bypassed, do processing:
             // For logging..
             $propArr = $this->getRecordProperties($table, $id);
             // Get destrination path:
             $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
             // If we are updating:
             if ($status == 'update') {
                 // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
                 // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
                 // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
                 // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
                 // Illustration of the problem comes here:
                 // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
                 // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
                 // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
                 // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
                 if ($this->autoVersioningUpdate === TRUE) {
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile === basename($theFile)) {
                             // If it is an already attached file...
                             $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
                         }
                     }
                 }
                 // Finding the CURRENT files listed, either from MM or from the current record.
                 $theFileValues = array();
                 if ($tcaFieldConf['MM']) {
                     // If MM relations for the files also!
                     $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                     /* @var $dbAnalysis t3lib_loadDBGroup */
                     $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
                     foreach ($dbAnalysis->itemArray as $item) {
                         if ($item['id']) {
                             $theFileValues[] = $item['id'];
                         }
                     }
                 } else {
                     $theFileValues = t3lib_div::trimExplode(',', $curValue, 1);
                 }
                 $currentFilesForHistory = implode(',', $theFileValues);
                 // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
                 if (count($theFileValues)) {
                     // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile && !strstr(t3lib_div::fixWindowsFilePath($theFile), '/')) {
                             $theFileValues = t3lib_div::removeArrayEntryByValue($theFileValues, $theFile);
                         }
                     }
                     // This array contains the filenames in the uploadfolder that should be deleted:
                     foreach ($theFileValues as $key => $theFile) {
                         $theFile = trim($theFile);
                         if (@is_file($dest . '/' . $theFile)) {
                             $this->removeFilesStore[] = $dest . '/' . $theFile;
                         } elseif ($theFile) {
                             $this->log($table, $id, 5, 0, 1, "Could not delete file '%s' (does not exist). (%s)", 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
                         }
                     }
                 }
             }
             // Traverse the submitted values:
             foreach ($valueArray as $key => $theFile) {
                 // NEW FILES? If the value contains '/' it indicates, that the file is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
                 if (strstr(t3lib_div::fixWindowsFilePath($theFile), '/')) {
                     // Init:
                     $maxSize = intval($tcaFieldConf['max_size']);
                     $cmd = '';
                     $theDestFile = '';
                     // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                     // Check various things before copying file:
                     if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
                         // File and destination must exist
                         // Finding size. For safe_mode we have to rely on the size in the upload array if the file is uploaded.
                         if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
                             $fileSize = $uploadedFileArray['size'];
                         } else {
                             $fileSize = filesize($theFile);
                         }
                         if (!$maxSize || $fileSize <= $maxSize * 1024) {
                             // Check file size:
                             // Prepare filename:
                             $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                             $fI = t3lib_div::split_fileref($theEndFileName);
                             // Check for allowed extension:
                             if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                 $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
                                 // If we have a unique destination filename, then write the file:
                                 if ($theDestFile) {
                                     t3lib_div::upload_copy_move($theFile, $theDestFile);
                                     // Hook for post-processing the upload action
                                     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
                                         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
                                             $hookObject = t3lib_div::getUserObj($classRef);
                                             if (!$hookObject instanceof t3lib_TCEmain_processUploadHook) {
                                                 throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_processUploadHook', 1279962349);
                                             }
                                             $hookObject->processUpload_postProcessAction($theDestFile, $this);
                                         }
                                     }
                                     $this->copiedFileMap[$theFile] = $theDestFile;
                                     clearstatcache();
                                     if (!@is_file($theDestFile)) {
                                         $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                     }
                                 } else {
                                     $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                 }
                             } else {
                                 $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                             }
                         } else {
                             $this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                         }
                     } else {
                         $this->log($table, $id, 5, 0, 1, 'The destination (%s) or the source file (%s) does not exist. (%s)', 14, array($dest, $theFile, $recFID), $propArr['event_pid']);
                     }
                     // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                     if (@is_file($theDestFile)) {
                         $info = t3lib_div::split_fileref($theDestFile);
                         $valueArray[$key] = $info['file'];
                         // The value is set to the new filename
                     } else {
                         unset($valueArray[$key]);
                         // The value is set to the new filename
                     }
                 }
             }
         }
         // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
         if ($tcaFieldConf['MM']) {
             $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
             /* @var $dbAnalysis t3lib_loadDBGroup */
             $dbAnalysis->tableArray['files'] = array();
             // dummy
             foreach ($valueArray as $key => $theFile) {
                 // explode files
                 $dbAnalysis->itemArray[]['id'] = $theFile;
             }
             if ($status == 'update') {
                 $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
                 $newFiles = implode(',', $dbAnalysis->getValueArray());
                 list(, , $recFieldName) = explode(':', $recFID);
                 if ($currentFilesForHistory != $newFiles) {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
                 } else {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = '';
                 }
             } else {
                 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);
                 // This will be traversed later to execute the actions
             }
             $valueArray = $dbAnalysis->countItems();
         }
         //store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
     } else {
         if (count($valueArray)) {
             if (!$this->bypassFileHandling) {
                 // If filehandling should NOT be bypassed, do processing:
                 $propArr = $this->getRecordProperties($table, $id);
                 // For logging..
                 foreach ($valueArray as &$theFile) {
                     // if alernative File Path is set for the file, then it was an import
                     if ($this->alternativeFilePath[$theFile]) {
                         // don't import the file if it already exists
                         if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
                             $theFile = PATH_site . $this->alternativeFilePath[$theFile];
                             // import the file
                         } elseif (@is_file($theFile)) {
                             $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
                             if (!@is_dir($dest)) {
                                 t3lib_div::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
                             }
                             // Init:
                             $maxSize = intval($tcaFieldConf['max_size']);
                             $cmd = '';
                             $theDestFile = '';
                             // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                             $fileSize = filesize($theFile);
                             if (!$maxSize || $fileSize <= $maxSize * 1024) {
                                 // Check file size:
                                 // Prepare filename:
                                 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                                 $fI = t3lib_div::split_fileref($theEndFileName);
                                 // Check for allowed extension:
                                 if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                     $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
                                     // Write the file:
                                     if ($theDestFile) {
                                         t3lib_div::upload_copy_move($theFile, $theDestFile);
                                         $this->copiedFileMap[$theFile] = $theDestFile;
                                         clearstatcache();
                                         if (!@is_file($theDestFile)) {
                                             $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                         }
                                     } else {
                                         $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                     }
                                 } else {
                                     $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                                 }
                             } else {
                                 $this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                             }
                             // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                             if (@is_file($theDestFile)) {
                                 $theFile = $theDestFile;
                                 // The value is set to the new filename
                             } else {
                                 unset($theFile);
                                 // The value is set to the new filename
                             }
                         }
                     }
                     $theFile = t3lib_div::fixWindowsFilePath($theFile);
                     if (t3lib_div::isFirstPartOfStr($theFile, PATH_site)) {
                         $theFile = substr($theFile, strlen(PATH_site));
                     }
                 }
             }
         }
     }
     return $valueArray;
 }
 /**
  * Renders the data columns
  *
  * @param	array		$item item array
  * @return	array
  */
 function getItemColumns($item)
 {
     $type = $item['__type'];
     // 	Columns rendering
     $columns = array();
     foreach ($this->columnList as $field => $descr) {
         switch ($field) {
             case 'perms':
                 if ($this->showUnixPerms) {
                     $columns[$field] = $this->getFilePermString($item[$type . '_perms']);
                 } else {
                     $columns[$field] = ($item[$type . '_readable'] ? 'R' : '') . ($item[$type . '_writable'] ? 'W' : '');
                 }
                 break;
             case 'size':
                 if ($type === 'file') {
                     $columns[$field] = (string) $item[$type . '_size'];
                 } else {
                     $columns[$field] = '';
                 }
                 break;
             case 'file_type':
                 $columns[$field] = strtoupper($item[$field]);
                 break;
             case 'mtime':
                 $columns[$field] = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $item[$type . '_mtime']);
                 break;
             case 'title':
                 if ($type === 'file') {
                     $columns[$field] = $this->linkWrapFile($this->cropTitle($item[$type . '_title'], $field), $item);
                 } else {
                     $columns[$field] = $this->linkWrapDir($this->cropTitle($item[$type . '_title'], $field), $item[$type . '_path_absolute']);
                 }
                 break;
             case '_CLIPBOARD_':
                 $columns[$field] = $this->clipboard_getItemControl($item);
                 break;
             case '_CONTROL_':
                 $columns[$field] = $this->getItemControl($item);
                 $this->columnTDAttr[$field] = ' nowrap="nowrap"';
                 break;
             default:
                 if (isset($item[$type . $field])) {
                     $content = $item[$type . $field];
                 } else {
                     $content = $item[$field];
                 }
                 $columns[$field] = htmlspecialchars(t3lib_div::fixed_lgd_cs($content, $this->titleLength));
                 break;
         }
         if ($columns[$field] === '') {
             $columns[$field] = '&nbsp;';
         }
     }
     // Thumbsnails?
     if ($this->showThumbs and $this->thumbnailPossible($item)) {
         $columns['title'] .= '<div style="margin:2px 0 2px 0;">' . $this->getThumbNail($item) . '</div>';
     }
     if (!$this->showDetailedSize) {
         $columns['size'] = t3lib_div::formatSize($columns['size']);
     }
     return $columns;
 }
 /**
  * Make upload array out of extension
  *
  * @param	string		Extension key
  * @param	array		Extension information array
  * @return	mixed		Returns array with extension upload array on success, otherwise an error string.
  */
 function makeUploadarray($extKey, $conf)
 {
     $extPath = tx_em_Tools::getExtPath($extKey, $conf['type']);
     if ($extPath) {
         // Get files for extension:
         $fileArr = array();
         $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $extPath, '', 0, 99, $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging']);
         // Calculate the total size of those files:
         $totalSize = 0;
         foreach ($fileArr as $file) {
             $totalSize += filesize($file);
         }
         // If the total size is less than the upper limit, proceed:
         if ($totalSize < $this->maxUploadSize) {
             // Initialize output array:
             $uploadArray = array();
             $uploadArray['extKey'] = $extKey;
             $uploadArray['EM_CONF'] = $conf['EM_CONF'];
             $uploadArray['misc']['codelines'] = 0;
             $uploadArray['misc']['codebytes'] = 0;
             $uploadArray['techInfo'] = $this->install->makeDetailedExtensionAnalysis($extKey, $conf, 1);
             // Read all files:
             foreach ($fileArr as $file) {
                 $relFileName = substr($file, strlen($extPath));
                 $fI = pathinfo($relFileName);
                 if ($relFileName != 'ext_emconf.php') {
                     // This file should be dynamically written...
                     $uploadArray['FILES'][$relFileName] = array('name' => $relFileName, 'size' => filesize($file), 'mtime' => filemtime($file), 'is_executable' => TYPO3_OS == 'WIN' ? 0 : is_executable($file), 'content' => t3lib_div::getUrl($file));
                     if (t3lib_div::inList('php,inc', strtolower($fI['extension']))) {
                         $uploadArray['FILES'][$relFileName]['codelines'] = count(explode(LF, $uploadArray['FILES'][$relFileName]['content']));
                         $uploadArray['misc']['codelines'] += $uploadArray['FILES'][$relFileName]['codelines'];
                         $uploadArray['misc']['codebytes'] += $uploadArray['FILES'][$relFileName]['size'];
                         // locallang*.php files:
                         if (substr($fI['basename'], 0, 9) == 'locallang' && strstr($uploadArray['FILES'][$relFileName]['content'], '$LOCAL_LANG')) {
                             $uploadArray['FILES'][$relFileName]['LOCAL_LANG'] = tx_em_Tools::getSerializedLocalLang($file, $uploadArray['FILES'][$relFileName]['content']);
                         }
                     }
                     $uploadArray['FILES'][$relFileName]['content_md5'] = md5($uploadArray['FILES'][$relFileName]['content']);
                 }
             }
             // Return upload-array:
             return $uploadArray;
         } else {
             return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_size'), $totalSize, t3lib_div::formatSize($this->maxUploadSize));
         }
     } else {
         return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_path'), $extKey);
     }
 }
    /**
     * Print the content on a pad. Called from ->printClipboard()
     *
     * @param	string		Pad reference
     * @return	array		Array with table rows for the clipboard.
     * @access private
     */
    function printContentFromTab($pad)
    {
        global $TBE_TEMPLATE;
        $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';
                    if ($table == '_FILE') {
                        // Rendering files/directories on the clipboard:
                        if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) {
                            $fI = pathinfo($v);
                            $icon = is_dir($v) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
                            $size = ' (' . t3lib_div::formatSize(filesize($v)) . 'bytes)';
                            $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($v) ? 'folder' : strtolower($fI['extension']), array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars($fI['basename'] . $size)));
                            $thumb = $this->clipData['_setThumb'] ? t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fI['extension']) ? t3lib_BEfunc::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(t3lib_div::fixed_lgd_cs(basename($v), $GLOBALS['BE_USER']->uc['titleLen'])), $v) . ($pad == 'normal' ? ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')</strong>' : '') . '&nbsp;' . ($thumb ? '<br />' . $thumb : '') . '</td>
									<td class="' . $bgColClass . '" align="center" nowrap="nowrap">' . '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $v . '\', \'\'); return false;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl('_FILE', t3lib_div::shortmd5($v))) . '#clip_head">' . t3lib_iconWorks::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 = t3lib_BEfunc::getRecordWSOL($table, $uid);
                        if (is_array($rec)) {
                            $lines[] = '
								<tr>
									<td class="' . $bgColClass . '">' . $this->linkItemText(t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec, $table)))), $rec, $table) . '</td>
									<td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . $this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::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;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>' . '<a href="' . htmlspecialchars($this->removeUrl($table, $uid)) . '#clip_head">' . t3lib_iconWorks::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;
    }
    /**
     * Renders the API listing for a single file, represented by the input array
     *
     * @param	array		Array with API information for a single file.
     * @return	array		Array with superindex / index / body content (keys 0/1)
     */
    function renderFileContent($fDat)
    {
        // Set anchor value:
        $anchor = md5($fDat['filename']);
        $this->fileSizeTotal += $fDat['filesize'];
        $this->funcClassesTotal += is_array($fDat['DAT']) ? count($fDat['DAT']) : '0';
        // Create file header content:
        $superIndex .= '
			<h3><a href="#s-' . $anchor . '">' . htmlspecialchars($fDat['filename']) . '</a></h3>
		';
        $index .= '
			<h3><a name="s-' . $anchor . '"></a><a href="#' . $anchor . '">' . htmlspecialchars($fDat['filename']) . '</a></h3>
			<p class="c-fileDescription">' . nl2br(htmlspecialchars(trim($fDat['header']['text']))) . '</p>';
        $content .= '

					<!--
						API content for file: ' . htmlspecialchars($fDat['filename']) . '
					-->
					<div class="c-header">
						<a name="' . $anchor . '"></a>
						<h3><a href="#top">' . htmlspecialchars($fDat['filename']) . '</a></h3>
						<p class="c-fileDescription">' . nl2br(htmlspecialchars(trim($fDat['header']['text']))) . '</p>

						<table border="0" cellpadding="0" cellspacing="1" class="c-details">
							<tr>
								<td class="c-Hcell">Filesize:</td>
								<td>' . t3lib_div::formatSize($fDat['filesize']) . '</td>
							</tr>
							<tr>
								<td class="c-Hcell">Func/Classes:</td>
								<td>' . (is_array($fDat['DAT']) ? count($fDat['DAT']) : 'N/A') . '</td>
							</tr>' . (is_array($fDat['header']['other']) ? '
							<tr>
								<td class="c-Hcell">Tags:</td>
								<td>' . nl2br(htmlspecialchars(implode(chr(10), $fDat['header']['other']))) . '</td>
							</tr>' : '') . '
						</table>
					</div>
			';
        // If there are classes/functions in the file, render API for those:
        if (is_array($fDat['DAT'])) {
            // Traverse list of classes/functions:
            foreach ($fDat['DAT'] as $k => $v) {
                if (is_array($v['sectionText']) && count($v['sectionText'])) {
                    // Section header:
                    $index .= '

							<h3 class="section">' . nl2br(htmlspecialchars(trim(implode(chr(10), $v['sectionText'])))) . '</h3>
							';
                }
                // Check, if the access tag is set to private (and if so, do not show):
                if ($v['cDat']['access'] != 'private' && !$v['cDat']['ignore'] || $this->showPrivateIgnoreFunc) {
                    // Set anchor value first:
                    $anchor = md5($fDat['filename'] . ':' . $v['header'] . $v['parentClass']);
                    $headerString = preg_replace('#\\{[[:space:]]*$#', '', $v['header']);
                    $tClass = 'c-' . (t3lib_div::isFirstPartOfStr(strtolower($v['header']), 'class') ? 'class' : 'function');
                    // Add header for function (title / description etc):
                    $index .= '
						<h4 class="' . $tClass . '"><a href="#' . $anchor . '">' . htmlspecialchars($headerString) . '</a></h4>';
                    $content .= '
					<!--
						Description for "' . htmlspecialchars($headerString) . '"
					-->
					<div class="' . $tClass . '">
						<a name="' . $anchor . '"></a>
						<h4><a href="#top">' . htmlspecialchars($headerString) . '</a></h4>
						<p class="c-funcDescription">' . nl2br(htmlspecialchars(trim($v['cDat']['text']))) . '</p>
						';
                    // Render details for the function/class:
                    // Parameters:
                    $tableRows = array();
                    if (is_array($v['cDat']['param'])) {
                        // Get argument names of current function:
                        $funcHeadParams = $this->splitFunctionHeader($v['header']);
                        // For each argument, render a row in the table:
                        foreach ($v['cDat']['param'] as $k2 => $pp) {
                            $tableRows[] = '
							<tr>
								<td class="c-Hcell">' . htmlspecialchars($funcHeadParams[$k2]) . '</td>
								<td class="c-vType">' . htmlspecialchars($pp[0]) . '</td>
								<td class="c-vDescr">' . htmlspecialchars(trim($pp[1])) . '</td>
							</tr>';
                        }
                    }
                    // Add "return" value:
                    $tableRows[] = '
							<tr>
								<td class="c-Hcell">Returns: </td>
								<td class="c-vType">' . htmlspecialchars($v['cDat']['return'][0]) . '</td>
								<td class="c-vDescr">' . htmlspecialchars(trim($v['cDat']['return'][1])) . '</td>
							</tr>';
                    // Add other tags:
                    if (is_array($v['cDat']['other'])) {
                        foreach ($v['cDat']['other'] as $k2 => $pp) {
                            $tableRows[] = '
							<tr>
								<td>&nbsp;</td>
								<td colspan="2" class="c-vDescr">' . htmlspecialchars($pp) . '</td>
							</tr>';
                        }
                    }
                    // Usage counts, if set:
                    $uCKey = 'H_' . t3lib_div::shortMD5($v['header']);
                    if (is_array($fDat['usageCount'][$uCKey])) {
                        // Add "TOTAL" usage:
                        $tableRows[] = '
							<tr>
								<td colspan="3"></td>
							</tr>
							<tr>
								<td class="c-Hcell">Total Usage:</td>
								<td class="c-vType">' . intval($fDat['usageCount'][$uCKey]['ALL']['TOTAL']) . '</td>
								<td class="c-vDescr">&nbsp;</td>
							</tr>';
                        // Add usage for single files:
                        foreach ($fDat['usageCount'][$uCKey] as $k3 => $v3) {
                            if (substr($k3, 0, 4) == 'MD5_') {
                                $tableRows[] = '
							<tr>
								<td class="c-vType">&nbsp;</td>
								<td class="c-vType">' . intval($fDat['usageCount'][$uCKey][$k3]['TOTAL']) . '</td>
								<td class="c-vDescr">' . htmlspecialchars($fDat['usageCount'][$uCKey][$k3]['fileName']) . '</td>
							</tr>';
                            }
                        }
                    }
                    // Add it all together:
                    $content .= '
						<table border="0" cellpadding="0" cellspacing="1" class="c-details">
							' . implode('
							', $tableRows) . '
						</table>';
                    // Adding todo to index:
                    if (is_array($v['cDat']['other_index']['@todo'])) {
                        $index .= '<p class="c-indexTags"><span class="typo3-red"><strong>@todo:</strong> ' . nl2br(htmlspecialchars(implode(chr(10), $v['cDat']['other_index']['@todo']))) . '</span></p>';
                    }
                    // Adding package tags to index:
                    if (is_array($v['cDat']['other_index']['@package'])) {
                        $index .= '<p class="c-indexTags"><span class="typo3-dimmed"><strong>@package:</strong> ' . nl2br(htmlspecialchars(implode(chr(10), $v['cDat']['other_index']['@package']))) . '</span></p>';
                    }
                    if (is_array($v['cDat']['other_index']['@subpackage'])) {
                        $index .= '<p class="c-indexTags"><span class="typo3-dimmed"><strong>@subpackage:</strong> ' . nl2br(htmlspecialchars(implode(chr(10), $v['cDat']['other_index']['@subpackage']))) . '</span></p>';
                    }
                    // Sample Content of function/class:
                    if (is_array($v['content'])) {
                        $content .= '
						<div class="php-content">
							<pre>' . highlight_string('<?php' . chr(10) . chr(10) . '	' . trim($v['header'] . chr(10) . $v['content'][0]) . chr(10) . chr(10) . '?>', 1) . '</pre>
						</div>
						';
                    }
                    // End with </div>
                    $content .= '
					</div>
					';
                }
            }
        }
        // Return index and content variables:
        return array($superIndex, $index, $content);
    }
 /**
  * Rendering preview output of a field value which is not shown as a form field but just outputted.
  *
  * @param	string		The value to output
  * @param	array		Configuration for field.
  * @param	string		Name of field.
  * @return	 string		HTML formatted output
  */
 function previewFieldValue($value, $config, $field = '')
 {
     if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) {
         // Ignore uploadfolder if internal_type is file_reference
         if ($config['config']['internal_type'] === 'file_reference') {
             $config['config']['uploadfolder'] = '';
         }
         $show_thumbs = TRUE;
         $table = 'tt_content';
         // Making the array of file items:
         $itemArray = t3lib_div::trimExplode(',', $value, 1);
         // Showing thumbnails:
         $thumbsnail = '';
         if ($show_thumbs) {
             $imgs = array();
             foreach ($itemArray as $imgRead) {
                 $imgP = explode('|', $imgRead);
                 $imgPath = rawurldecode($imgP[0]);
                 $rowCopy = array();
                 $rowCopy[$field] = $imgPath;
                 // Icon + clickmenu:
                 $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath);
                 $fileInformation = pathinfo($imgPath);
                 $fileIcon = t3lib_iconWorks::getSpriteIconForFile($imgPath, array('title' => htmlspecialchars($fileInformation['basename'] . ($absFilePath && @is_file($absFilePath) ? ' (' . t3lib_div::formatSize(filesize($absFilePath)) . 'bytes)' : ' - FILE NOT FOUND!'))));
                 $imgs[] = '<span class="nobr">' . t3lib_BEfunc::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon) . $imgPath . '</span>';
             }
             $thumbsnail = implode('<br />', $imgs);
         }
         return $thumbsnail;
     } else {
         return nl2br(htmlspecialchars($value));
     }
 }
 /**
  * Render a single row of information about a indexing entry.
  *
  * @param	array		Row from query (combined phash table with sections etc).
  * @param	boolean		Set if grouped to previous result; the icon of the element is not shown again.
  * @param	array		Array of index_grlist records.
  * @return	array		Array of table rows.
  * @see indexed_info()
  */
 function printPhashRow($row, $grouping = 0, $extraGrListRows)
 {
     $lines = array();
     // Title cell attributes will highlight TYPO3 pages with a slightly darker color (bgColor4) than attached medias. Also IF there are more than one section record for a phash row it will be red as a warning that something is wrong!
     $titleCellAttribs = $row['count_val'] != 1 ? ' bgcolor="red"' : ($row['item_type'] === '0' ? ' class="bgColor4"' : '');
     if ($row['item_type']) {
         $arr = unserialize($row['cHashParams']);
         $page = $arr['key'] ? ' [' . $arr['key'] . ']' : '';
     } else {
         $page = '';
     }
     $elTitle = $this->linkDetails($row['item_title'] ? htmlspecialchars(t3lib_div::fixed_lgd_cs($this->utf8_to_currentCharset($row['item_title']), 20) . $page) : '<em>[No Title]</em>', $row['phash']);
     $cmdLinks = $this->printRemoveIndexed($row['phash'], 'Clear phash-row') . $this->printReindex($row, 'Re-index element');
     switch ($this->pObj->MOD_SETTINGS['type']) {
         case 1:
             // Technical details:
             // Display icon:
             if (!$grouping) {
                 $lines[] = '<td>' . $this->makeItemTypeIcon($row['item_type'], $row['data_filename'] ? $row['data_filename'] : $row['item_title']) . '</td>';
             } else {
                 $lines[] = '<td>&nbsp;</td>';
             }
             // Title displayed:
             $lines[] = '<td' . $titleCellAttribs . '>' . $elTitle . '</td>';
             // Remove-indexing-link:
             $lines[] = '<td>' . $cmdLinks . '</td>';
             // Various data:
             $lines[] = '<td>' . $row['phash'] . '</td>';
             $lines[] = '<td>' . $row['contentHash'] . '</td>';
             if ($row['item_type'] === '0') {
                 $lines[] = '<td>' . ($row['data_page_id'] ? $row['data_page_id'] : '&nbsp;') . '</td>';
                 $lines[] = '<td>' . ($row['data_page_type'] ? $row['data_page_type'] : '&nbsp;') . '</td>';
                 $lines[] = '<td>' . ($row['sys_language_uid'] ? $row['sys_language_uid'] : '&nbsp;') . '</td>';
                 $lines[] = '<td>' . ($row['data_page_mp'] ? $row['data_page_mp'] : '&nbsp;') . '</td>';
             } else {
                 $lines[] = '<td colspan="4">' . htmlspecialchars($row['data_filename']) . '</td>';
             }
             $lines[] = '<td>' . $row['gr_list'] . $this->printExtraGrListRows($extraGrListRows) . '</td>';
             $lines[] = '<td>' . $this->printRootlineInfo($row) . '</td>';
             $lines[] = '<td>' . ($row['page_id'] ? $row['page_id'] : '&nbsp;') . '</td>';
             $lines[] = '<td>' . ($row['phash_t3'] != $row['phash'] ? $row['phash_t3'] : '&nbsp;') . '</td>';
             $lines[] = '<td>' . ($row['freeIndexUid'] ? $row['freeIndexUid'] . ($row['freeIndexSetId'] ? '/' . $row['freeIndexSetId'] : '') : '&nbsp;') . '</td>';
             $lines[] = '<td>' . ($row['recordUid'] ? $row['recordUid'] : '&nbsp;') . '</td>';
             // cHash parameters:
             $arr = unserialize($row['cHashParams']);
             if (!is_array($arr)) {
                 $arr = array('cHash' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.error', true));
             }
             $theCHash = $arr['cHash'];
             unset($arr['cHash']);
             if ($row['item_type']) {
                 // pdf...
                 $lines[] = '<td>' . ($arr['key'] ? 'Page ' . $arr['key'] : '') . '&nbsp;</td>';
             } elseif ($row['item_type'] == 0) {
                 $lines[] = '<td>' . htmlspecialchars(t3lib_div::implodeArrayForUrl('', $arr)) . '&nbsp;</td>';
             } else {
                 $lines[] = '<td class="bgColor">&nbsp;</td>';
             }
             $lines[] = '<td>' . $theCHash . '</td>';
             break;
         case 2:
             // Words and content:
             // Display icon:
             if (!$grouping) {
                 $lines[] = '<td>' . $this->makeItemTypeIcon($row['item_type'], $row['data_filename'] ? $row['data_filename'] : $row['item_title']) . '</td>';
             } else {
                 $lines[] = '<td>&nbsp;</td>';
             }
             // Title displayed:
             $lines[] = '<td' . $titleCellAttribs . '>' . $elTitle . '</td>';
             // Remove-indexing-link:
             $lines[] = '<td>' . $cmdLinks . '</td>';
             // Query:
             $ftrows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'index_fulltext', 'phash = ' . intval($row['phash']));
             $lines[] = '<td style="white-space: normal;">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($this->utf8_to_currentCharset($ftrows[0]['fulltextdata']), 3000)) . '<hr/><em>Size: ' . strlen($ftrows[0]['fulltextdata']) . '</em>' . '</td>';
             // Query:
             $ftrows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('index_words.baseword, index_rel.*', 'index_rel, index_words', 'index_rel.phash = ' . intval($row['phash']) . ' AND index_words.wid = index_rel.wid', '', '', '', 'baseword');
             $wordList = '';
             if (is_array($ftrows)) {
                 $indexed_words = array_keys($ftrows);
                 sort($indexed_words);
                 $wordList = htmlspecialchars($this->utf8_to_currentCharset(implode(' ', $indexed_words)));
                 $wordList .= '<hr/><em>Count: ' . count($indexed_words) . '</em>';
             }
             $lines[] = '<td style="white-space: normal;">' . $wordList . '</td>';
             break;
         default:
             // Overview
             // Display icon:
             if (!$grouping) {
                 $lines[] = '<td>' . $this->makeItemTypeIcon($row['item_type'], $row['data_filename'] ? $row['data_filename'] : $row['item_title']) . '</td>';
             } else {
                 $lines[] = '<td>&nbsp;</td>';
             }
             // Title displayed:
             $lines[] = '<td' . $titleCellAttribs . '>' . $elTitle . '</td>';
             // Remove-indexing-link:
             $lines[] = '<td>' . $cmdLinks . '</td>';
             $lines[] = '<td style="white-space: normal;">' . htmlspecialchars($this->utf8_to_currentCharset($row['item_description'])) . '...</td>';
             $lines[] = '<td>' . t3lib_div::formatSize($row['item_size']) . '</td>';
             $lines[] = '<td>' . t3lib_BEfunc::dateTimeAge($row['tstamp']) . '</td>';
             break;
     }
     return $lines;
 }
    /**
     * The main processing method if this class
     *
     * @return	string		Information of the template status or the taken actions as HTML string
     */
    function main()
    {
        global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        global $tmpl, $tplRow, $theConstants;
        $edit = $this->pObj->edit;
        $e = $this->pObj->e;
        t3lib_div::loadTCA('sys_template');
        // **************************
        // Checking for more than one template an if, set a menu...
        // **************************
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        // **************************
        // Initialize
        // **************************
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        if ($existTemplate) {
            $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
        }
        // **************************
        // Create extension template
        // **************************
        $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
        if ($newId) {
            // switch to new template
            t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId);
        }
        if ($existTemplate) {
            // Update template ?
            $POST = t3lib_div::_POST();
            if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                // Set the data to be saved
                $recData = array();
                $alternativeFileName = array();
                $resList = $tplRow['resources'];
                $tmp_upload_name = '';
                $tmp_newresource_name = '';
                // Set this to blank
                if (is_array($POST['data'])) {
                    foreach ($POST['data'] as $field => $val) {
                        switch ($field) {
                            case 'constants':
                            case 'config':
                            case 'title':
                            case 'sitetitle':
                            case 'description':
                                $recData['sys_template'][$saveId][$field] = $val;
                                break;
                            case 'resources':
                                $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
                                // If there is an uploaded file, move it for the sake of safe_mode.
                                if ($tmp_upload_name) {
                                    if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) {
                                        $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
                                        $resList = $tmp_upload_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'new_resource':
                                $newName = trim(t3lib_div::_GP('new_resource'));
                                if ($newName) {
                                    $newName .= '.' . t3lib_div::_GP('new_resource_ext');
                                    $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
                                    $alternativeFileName[$tmp_newresource_name] = $newName;
                                    $resList = $tmp_newresource_name . ',' . $resList;
                                }
                                break;
                            case 'makecopy_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file;
                                        $resList = $tmp_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'remove_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                    }
                                }
                                break;
                            case 'totop_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                        $resList = ',' . $file . $resList;
                                    }
                                }
                                break;
                        }
                    }
                }
                $resList = implode(',', t3lib_div::trimExplode(',', $resList, 1));
                if (strcmp($resList, $tplRow['resources'])) {
                    $recData['sys_template'][$saveId]['resources'] = $resList;
                }
                if (count($recData)) {
                    // Create new  tce-object
                    $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                    $tce->stripslashes_values = 0;
                    $tce->alternativeFileName = $alternativeFileName;
                    // Initialize
                    $tce->start($recData, array());
                    // Saved the stuff
                    $tce->process_datamap();
                    // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                    $tce->clear_cacheCmd('all');
                    // tce were processed successfully
                    $this->tce_processed = true;
                    // re-read the template ...
                    $this->initialize_editor($this->pObj->id, $template_uid);
                }
                // Unlink any uploaded/new temp files there was:
                t3lib_div::unlink_tempfile($tmp_upload_name);
                t3lib_div::unlink_tempfile($tmp_newresource_name);
                // If files has been edited:
                if (is_array($edit)) {
                    if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) {
                        // Check if there are resources, and that the file is in the resourcelist.
                        $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                        $fI = t3lib_div::split_fileref($edit['filename']);
                        if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                            // checks that have already been done.. Just to make sure
                            // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                            if (filesize($path) < 30720) {
                                // checks that have already been done.. Just to make sure
                                t3lib_div::writeFile($path, $edit['file']);
                                $theOutput .= $this->pObj->doc->spacer(10);
                                $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                                // Clear cache - the file has probably affected the template setup
                                // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                $tce->stripslashes_values = 0;
                                $tce->start(array(), array());
                                $tce->clear_cacheCmd('all');
                            }
                        }
                    }
                }
            }
            // hook	Post updating template/TCE processing
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
                $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
                if (is_array($postTCEProcessingHook)) {
                    $hookParameters = array('POST' => $POST, 'tce' => $tce);
                    foreach ($postTCEProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
            $theOutput .= $this->pObj->doc->spacer(5);
            $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
                $theOutput .= $this->pObj->doc->divider(5);
            }
            #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
            #if (!$numberOfRows)
            $numberOfRows = 35;
            // If abort pressed, nothing should be edited:
            if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                unset($e);
            }
            if ($e['title']) {
                $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[title]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
            }
            if ($e['sitetitle']) {
                $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
            }
            if ($e['description']) {
                $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[description]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
            }
            if ($e['resources']) {
                // Upload
                $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">';
                $outCode .= '<input type="Hidden" name="data[resources]" value="1">';
                $outCode .= '<input type="Hidden" name="e[resources]" value="1">';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
                // New
                $opt = explode(',', $this->pObj->textExtensions);
                $optTags = '';
                foreach ($opt as $extVal) {
                    $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>';
                }
                $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '>
					<select name="new_resource_ext">' . $optTags . '</select>';
                $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
                // Make copy
                $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
                }
                // Update resource list
                $rL = $this->procesResources($tplRow['resources'], 1);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
                }
            }
            if ($e['constants']) {
                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            if ($e['file']) {
                $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
                $fI = t3lib_div::split_fileref($e[file]);
                if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                    if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                        $fileContent = t3lib_div::getUrl($path);
                        $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                        $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                        $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                        $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                        $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                    } else {
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                    }
                }
            }
            if ($e['config']) {
                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>';
                if (t3lib_extMgm::isLoaded('tsconfig_help')) {
                    $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                    $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                    $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
                }
                $outCode .= '<input type="Hidden" name="e[config]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            // Processing:
            $outCode = '';
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
            $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
            // Edit all icon:
            $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
            $theOutput .= $this->pObj->doc->section('', $outCode);
            // hook	after compiling the output
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
                $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
                if (is_array($postOutputProcessingHook)) {
                    $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                    foreach ($postOutputProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
        } else {
            $theOutput .= $this->pObj->noTemplate(1);
        }
        return $theOutput;
    }
 /**
  * Upload of files (action=1)
  *
  * @param	array		$cmds['data'] is the ID-number (points to the global var that holds the filename-ref  ($GLOBALS['HTTP_POST_FILES']['upload_'.$id]['name']). $cmds['target'] is the target directory
  * @param	string		$id: $_FILES['upload_'.$id]
  * @return	string		Returns the new filename upon success
  */
 function func_upload($cmds, $id = false)
 {
     if ($id === false) {
         $id = $cmds['data'];
     }
     if (!$this->isInit) {
         return FALSE;
     }
     if (!$_FILES['upload_' . $id]['name']) {
         return;
     }
     // filename of the uploaded file
     $theFile = $_FILES['upload_' . $id]['tmp_name'];
     // filesize of the uploaded file
     $theFileSize = $_FILES['upload_' . $id]['size'];
     // The original filename
     $theName = tx_dam::file_makeCleanName($_FILES['upload_' . $id]['name']);
     #		$theName = $this->cleanFileName($_FILES['upload_'.$id]['name']);
     // main log entry
     $this->log['cmd']['upload'][$id] = array('errors' => array(), 'orig_filename' => $theName, 'target_file' => '', 'target_path' => $this->fileCmdMap['upload'][$id]['target']);
     // Check if the file is uploaded
     if (!(is_uploaded_file($theFile) && $theName)) {
         $this->writelog(1, 2, 106, 'The uploaded file did not exist!', '', 'upload', $id);
         return;
     }
     // check upload permissions
     if (!$this->actionPerms['uploadFile']) {
         $this->writelog(1, 1, 105, 'You are not allowed to upload files!', '', 'upload', $id);
         return;
     }
     // check if the file size exceed permissions
     $maxBytes = $this->getMaxUploadSize();
     if (!($theFileSize < $maxBytes)) {
         $this->writelog(1, 1, 104, 'The uploaded file exceeds the size-limit of %s (%s Bytes).', array(t3lib_div::formatSize($maxBytes), $maxBytes), 'upload', $id);
         return;
     }
     // Check the target dir
     $theTarget = $this->is_directory($cmds['target']);
     // check if target is inside of a mount point
     if (!($theTarget && $this->checkPathAgainstMounts($theTarget . '/'))) {
         $this->writelog(1, 1, 103, 'Destination path "%s" was not within your mountpoints!', array($theTarget . '/'), 'upload', $id);
         return;
     }
     // check if the file extension is allowed
     $fI = t3lib_div::split_fileref($theName);
     if (!$this->checkIfAllowed($fI['fileext'], $theTarget, $fI['file'])) {
         $this->writelog(1, 1, 102, 'Fileextension "%s" is not allowed in "%s"!', array($fI['fileext'], $theTarget . '/'), 'upload', $id);
         return;
     }
     // Create unique file name
     $theNewFile = $this->getUniqueName($theName, $theTarget, $this->dontCheckForUnique);
     if (!$theNewFile) {
         $this->writelog(1, 1, 101, 'No unique filename available in "%s"!', array($theTarget . '/'), 'upload', $id);
         return;
     }
     // move uploaded file to target location
     t3lib_div::upload_copy_move($theFile, $theNewFile);
     clearstatcache();
     // moving file did not work
     if (!@is_file($theNewFile)) {
         $this->writelog(1, 1, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', array($theTarget . '/'), 'upload', $id);
         return;
     }
     $this->internalUploadMap[$id] = $theNewFile;
     $this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', array($theName, $theNewFile, $id), 'upload', $id);
     // add file to log entry
     $this->log['cmd']['upload'][$id]['target_file'] = $theNewFile;
     return $theNewFile;
 }
示例#19
0
    /**
     * Main function. Will generate the information to display for the item set internally.
     *
     * @param	string		<a> tag closing/returning.
     * @return	void
     */
    function renderFileInfo($returnLinkTag)
    {
        // Initialize object to work on the image:
        $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
        $imgObj->init();
        $imgObj->mayScaleUp = 0;
        $imgObj->absPrefix = PATH_site;
        // Read Image Dimensions (returns false if file was not an image type, otherwise dimensions in an array)
        $imgInfo = '';
        $imgInfo = $imgObj->getImageDimensions($this->file);
        // File information
        $fI = t3lib_div::split_fileref($this->file);
        $ext = $fI['fileext'];
        $code = '';
        // Setting header:
        $fileName = t3lib_iconWorks::getSpriteIconForFile($ext) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $fI['file'];
        if (t3lib_div::isFirstPartOfStr($this->file, PATH_site)) {
            $code .= '<a href="../' . substr($this->file, strlen(PATH_site)) . '" target="_blank">' . $fileName . '</a>';
        } else {
            $code .= $fileName;
        }
        $code .= ' &nbsp;&nbsp;<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . t3lib_div::formatSize(@filesize($this->file)) . '<br />
			';
        if (is_array($imgInfo)) {
            $code .= '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels');
        }
        $this->content .= $this->doc->section('', $code);
        $this->content .= $this->doc->divider(2);
        // If the file was an image...:
        if (is_array($imgInfo)) {
            $imgInfo = $imgObj->imageMagickConvert($this->file, 'web', '346', '200m', '', '', '', 1);
            $imgInfo[3] = '../' . substr($imgInfo[3], strlen(PATH_site));
            $code = '<br />
				<div align="center">' . $returnLinkTag . $imgObj->imgTag($imgInfo) . '</a></div>';
            $this->content .= $this->doc->section('', $code);
        } else {
            $this->content .= $this->doc->spacer(10);
            $lowerFilename = strtolower($this->file);
            // Archive files:
            if (TYPO3_OS != 'WIN' && !$GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
                if ($ext == 'zip') {
                    $code = '';
                    $t = array();
                    t3lib_utility_Command::exec('unzip -l ' . $this->file, $t);
                    if (is_array($t)) {
                        reset($t);
                        next($t);
                        next($t);
                        next($t);
                        while (list(, $val) = each($t)) {
                            $parts = explode(' ', trim($val), 7);
                            $code .= '
								' . $parts[6] . '<br />';
                        }
                        $code = '
							<span class="nobr">' . $code . '
							</span>
							<br /><br />';
                    }
                    $this->content .= $this->doc->section('', $code);
                } elseif ($ext == 'tar' || $ext == 'tgz' || substr($lowerFilename, -6) == 'tar.gz' || substr($lowerFilename, -5) == 'tar.z') {
                    $code = '';
                    if ($ext == 'tar') {
                        $compr = '';
                    } else {
                        $compr = 'z';
                    }
                    $t = array();
                    t3lib_utility_Command::exec('tar t' . $compr . 'f ' . $this->file, $t);
                    if (is_array($t)) {
                        foreach ($t as $val) {
                            $code .= '
								' . $val . '<br />';
                        }
                        $code .= '
								 -------<br/>
								 ' . count($t) . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.files');
                        $code = '
							<span class="nobr">' . $code . '
							</span>
							<br /><br />';
                    }
                    $this->content .= $this->doc->section('', $code);
                }
            } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
                $this->content .= $this->doc->section('', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.cannotDisplayArchive'));
            }
            // Font files:
            if ($ext == 'ttf') {
                $thumbScript = 'thumbs.php';
                $check = basename($this->file) . ':' . filemtime($this->file) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                $params = '&file=' . rawurlencode($this->file);
                $params .= '&md5sum=' . t3lib_div::shortMD5($check);
                $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params;
                $thumb = '<br />
					<div align="center">' . $returnLinkTag . '<img src="' . htmlspecialchars($url) . '" border="0" title="' . htmlspecialchars(trim($this->file)) . '" alt="" /></a></div>';
                $this->content .= $this->doc->section('', $thumb);
            }
        }
        // References:
        $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'), $this->makeRef('_FILE', $this->file));
    }
示例#20
0
 /**
  * A test has ended.
  *
  * @param PHPUnit_Framework_Test $test the test that has ended
  * @param float $time ?
  *
  * @return void
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     $this->memoryUsageEndOfTest = memory_get_usage();
     if ($test instanceof PHPUnit_Framework_TestCase) {
         /** @var $test  PHPUnit_Framework_TestCase */
         // Tests with the same name are a sign of data provider usage.
         $testNameParts = explode(' ', $test->getName());
         $testName = get_class($test) . ':' . $testNameParts[0];
         if ($testName !== $this->previousTestName) {
             $this->currentDataProviderNumber = 0;
             $this->currentTestNumber++;
             $this->previousTestName = $testName;
         } else {
             $this->currentDataProviderNumber++;
             $this->totalNumberOfDetectedDataProviderTests++;
         }
     }
     if ($this->totalNumberOfTests - $this->totalNumberOfDetectedDataProviderTests > 0) {
         $percentDone = 100.0 * $this->currentTestNumber / ($this->totalNumberOfTests - $this->totalNumberOfDetectedDataProviderTests);
     } else {
         $percentDone = 0.0;
     }
     $leakedMemory = $this->memoryUsageEndOfTest - $this->memoryUsageStartOfTest;
     $this->totalLeakedMemory += $leakedMemory;
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $this->testAssertions += $test->getNumAssertions();
     }
     $output = '</div>';
     if ($this->enableShowMemoryAndTime === TRUE) {
         $output .= '<span class="memory-leak small-font"><strong>Memory leak:</strong> ' . t3lib_div::formatSize($leakedMemory) . 'B </span>' . '<span class="time-usages small-font"><strong>Time:</strong> ' . sprintf('%.4f', $time) . ' sec.</span><br />';
     }
     $output .= '</div>' . '<script type="text/javascript">/*<![CDATA[*/document.getElementById("progress-bar").style.width = "' . $percentDone . '%";/*]]>*/</script>';
     $this->outputService->output($output);
     $this->outputService->flushOutputBuffer();
 }
    /**
     * Fills the file specific markers:
     *
     *  ###[fieldname]_minSize###
     *  ###[fieldname]_maxSize###
     *  ###[fieldname]_allowedTypes###
     *  ###[fieldname]_maxCount###
     *  ###[fieldname]_fileCount###
     *  ###[fieldname]_remainingCount###
     *
     *  ###[fieldname]_uploadedFiles###
     *  ###total_uploadedFiles###
     *
     * @param array &$markers Reference to the markers array
     * @return void
     */
    public function fillFileMarkers(&$markers)
    {
        $settings = $this->parseSettings();
        $flexformValue = Tx_Formhandler_StaticFuncs::pi_getFFvalue($this->cObj->data['pi_flexform'], 'required_fields', 'sMISC');
        if ($flexformValue) {
            $fields = t3lib_div::trimExplode(',', $flexformValue);
            if (is_array($settings['validators.'])) {
                // Searches the index of Tx_Formhandler_Validator_Default
                foreach ($settings['validators.'] as $index => $validator) {
                    if ($validator['class'] == 'Tx_Formhandler_Validator_Default') {
                        break;
                    }
                }
            } else {
                $index = 1;
            }
            // Adds the value.
            foreach ($fields as $idx => $field) {
                $settings['validators.'][$index . '.']['config.']['fieldConf.'][$field . '.']['errorCheck.'] = array();
                $settings['validators.'][$index . '.']['config.']['fieldConf.'][$field . '.']['errorCheck.']['1'] = 'required';
            }
        }
        $sessionFiles = Tx_Formhandler_Globals::$session->get('files');
        //parse validation settings
        if (is_array($settings['validators.'])) {
            foreach ($settings['validators.'] as $key => $validatorSettings) {
                if (is_array($validatorSettings['config.']) && is_array($validatorSettings['config.']['fieldConf.'])) {
                    foreach ($validatorSettings['config.']['fieldConf.'] as $fieldname => $fieldSettings) {
                        $replacedFieldname = str_replace('.', '', $fieldname);
                        if (is_array($fieldSettings['errorCheck.'])) {
                            foreach ($fieldSettings['errorCheck.'] as $key => $check) {
                                switch ($check) {
                                    case 'fileMinSize':
                                        $minSize = $fieldSettings['errorCheck.'][$key . '.']['minSize'];
                                        $markers['###' . $replacedFieldname . '_minSize###'] = t3lib_div::formatSize($minSize, ' Bytes | KB | MB | GB');
                                        break;
                                    case 'fileMaxSize':
                                        $maxSize = $fieldSettings['errorCheck.'][$key . '.']['maxSize'];
                                        $markers['###' . $replacedFieldname . '_maxSize###'] = t3lib_div::formatSize($maxSize, ' Bytes | KB | MB | GB');
                                        break;
                                    case 'fileAllowedTypes':
                                        $types = $fieldSettings['errorCheck.'][$key . '.']['allowedTypes'];
                                        $markers['###' . $replacedFieldname . '_allowedTypes###'] = $types;
                                        break;
                                    case 'fileMaxCount':
                                        $maxCount = $fieldSettings['errorCheck.'][$key . '.']['maxCount'];
                                        $markers['###' . $replacedFieldname . '_maxCount###'] = $maxCount;
                                        $fileCount = count($sessionFiles[str_replace('.', '', $fieldname)]);
                                        $markers['###' . $replacedFieldname . '_fileCount###'] = $fileCount;
                                        $remaining = $maxCount - $fileCount;
                                        $markers['###' . $replacedFieldname . '_remainingCount###'] = $remaining;
                                        break;
                                    case 'fileMinCount':
                                        $minCount = $fieldSettings['errorCheck.'][$key . '.']['minCount'];
                                        $markers['###' . $replacedFieldname . '_minCount###'] = $minCount;
                                        break;
                                    case 'required':
                                    case 'fileRequired':
                                    case 'jmRecaptcha':
                                    case 'captcha':
                                    case 'srFreecap':
                                    case 'mathguard':
                                        $requiredSign = Tx_Formhandler_StaticFuncs::getSingle($settings, 'requiredSign');
                                        if (strlen($requiredSign) === 0) {
                                            $requiredSign = '*';
                                        }
                                        $markers['###required_' . $replacedFieldname . '###'] = $requiredSign;
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (is_array($sessionFiles)) {
            $singleWrap = $settings['singleFileMarkerTemplate.']['singleWrap'];
            $totalMarkerSingleWrap = $settings['totalFilesMarkerTemplate.']['singleWrap'];
            $totalWrap = $settings['singleFileMarkerTemplate.']['totalWrap'];
            $totalMarkersTotalWrap = $settings['totalFilesMarkerTemplate.']['totalWrap'];
            foreach ($sessionFiles as $field => $files) {
                foreach ($files as $idx => $fileInfo) {
                    $filename = $fileInfo['name'];
                    $thumb = '';
                    if (intval($settings['singleFileMarkerTemplate.']['showThumbnails']) === 1 || intval($settings['singleFileMarkerTemplate.']['showThumbnails']) === 2) {
                        $imgConf['image.'] = $settings['singleFileMarkerTemplate.']['image.'];
                        $thumb = $this->getThumbnail($imgConf, $fileInfo);
                    }
                    $text = Tx_Formhandler_StaticFuncs::getSingle($settings['files.'], 'customRemovalText');
                    if (strlen($text) === 0) {
                        $text = 'X';
                    }
                    $link = '';
                    $uploadedFileName = $fileInfo['uploaded_name'];
                    if (!$uploadedFileName) {
                        $uploadedFileName = $fileInfo['name'];
                    }
                    if (Tx_Formhandler_Globals::$ajaxHandler && $settings['files.']['enableAjaxFileRemoval']) {
                        $link = Tx_Formhandler_Globals::$ajaxHandler->getFileRemovalLink($text, $field, $uploadedFileName);
                    } elseif ($settings['files.']['enableFileRemoval']) {
                        $submitName = 'step-' . Tx_Formhandler_Globals::$session->get('currentStep') . '-reload';
                        if (Tx_Formhandler_Globals::$formValuesPrefix) {
                            $submitName = Tx_Formhandler_Globals::$formValuesPrefix . '[' . $submitName . ']';
                        }
                        $onClick = "\n\t\t\t\t\t\t\tdocument.getElementById('removeFile-" . Tx_Formhandler_Globals::$randomID . "').value='" . $uploadedFileName . "';\n\t\t\t\t\t\t\tdocument.getElementById('removeFileField-" . Tx_Formhandler_Globals::$randomID . "').value='" . $field . "';\n\t\t\t\t\t\t\tdocument.getElementById('submitField-" . Tx_Formhandler_Globals::$randomID . "').name='" . $submitName . "';\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t";
                        if (Tx_Formhandler_Globals::$formID) {
                            $onClick .= "document.getElementById('" . Tx_Formhandler_Globals::$formID . "').submit();";
                        } else {
                            $onClick .= 'document.forms[0].submit();';
                        }
                        $onClick .= 'return false;';
                        $link = '<a 
								href="javascript:void(0)" 
								class="formhandler_removelink" 
								onclick="' . str_replace(array("\n", '	'), '', $onClick) . '"
								>' . $text . '</a>';
                    }
                    if (strlen($singleWrap) > 0 && strstr($singleWrap, '|')) {
                        $wrappedFilename = str_replace('|', $filename . $link, $singleWrap);
                        $wrappedThumb = str_replace('|', $thumb . $link, $singleWrap);
                        $wrappedThumbFilename = str_replace('|', $thumb . ' ' . $filename . $link, $singleWrap);
                    } else {
                        $wrappedFilename = $filename . $link;
                        $wrappedThumb = $thumb . $link;
                        $wrappedThumbFilename = $thumb . ' ' . $filename . $link;
                    }
                    if (intval($settings['singleFileMarkerTemplate.']['showThumbnails']) === 1) {
                        $markers['###' . $field . '_uploadedFiles###'] .= $wrappedThumb;
                    } elseif (intval($settings['singleFileMarkerTemplate.']['showThumbnails']) === 2) {
                        $markers['###' . $field . '_uploadedFiles###'] .= $wrappedThumbFilename;
                    } else {
                        $markers['###' . $field . '_uploadedFiles###'] .= $wrappedFilename;
                    }
                    $uploadedFileName = $fileInfo['name'];
                    if (!$uploadedFileName) {
                        $uploadedFileName = $fileInfo['uploaded_name'];
                    }
                    if (intval($settings['totalFilesMarkerTemplate.']['showThumbnails']) === 1 || intval($settings['totalFilesMarkerTemplate.']['showThumbnails']) === 2) {
                        $imgConf['image.'] = $settings['totalFilesMarkerTemplate.']['image.'];
                        if (!$imgconf['image.']) {
                            $imgConf['image.'] = $settings['singleFileMarkerTemplate.']['image.'];
                        }
                        $thumb = $this->getThumbnail($imgConf, $fileInfo);
                    }
                    if (strlen($totalMarkerSingleWrap) > 0 && strstr($totalMarkerSingleWrap, '|')) {
                        $wrappedFilename = str_replace('|', $filename . $link, $totalMarkerSingleWrap);
                        $wrappedThumb = str_replace('|', $thumb . $link, $totalMarkerSingleWrap);
                        $wrappedThumbFilename = str_replace('|', $thumb . ' ' . $filename . $link, $totalMarkerSingleWrap);
                    } else {
                        $wrappedFilename = $filename . $link;
                        $wrappedThumb = $thumb . $link;
                        $wrappedThumbFilename = $thumb . $filename . $link;
                    }
                    if (intval($settings['totalFilesMarkerTemplate.']['showThumbnails']) === 1) {
                        $markers['###total_uploadedFiles###'] .= $wrappedThumb;
                    } elseif (intval($settings['totalFilesMarkerTemplate.']['showThumbnails']) === 2) {
                        $markers['###total_uploadedFiles###'] .= wrappedThumbFilename;
                    } else {
                        $markers['###total_uploadedFiles###'] .= $wrappedFilename;
                    }
                }
                if (strlen($totalWrap) > 0 && strstr($totalWrap, '|')) {
                    $markers['###' . $field . '_uploadedFiles###'] = str_replace('|', $markers['###' . $field . '_uploadedFiles###'], $totalWrap);
                }
                $markers['###' . $field . '_uploadedFiles###'] = '<div id="Tx_Formhandler_UploadedFiles_' . $field . '">' . $markers['###' . $field . '_uploadedFiles###'] . '</div>';
            }
            if (strlen($totalMarkersTotalWrap) > 0 && strstr($totalMarkersTotalWrap, '|')) {
                $markers['###total_uploadedFiles###'] = str_replace('|', $markers['###total_uploadedFiles###'], $totalMarkersTotalWrap);
            }
            $markers['###TOTAL_UPLOADEDFILES###'] = $markers['###total_uploadedFiles###'];
            $markers['###total_uploadedfiles###'] = $markers['###total_uploadedFiles###'];
        }
        $requiredSign = Tx_Formhandler_StaticFuncs::getSingle($settings, 'requiredSign');
        if (strlen($requiredSign) === 0) {
            $requiredSign = '*';
        }
        $markers['###required###'] = $requiredSign;
        $markers['###REQUIRED###'] = $markers['###required###'];
    }
示例#22
0
 /**
  * Renders and outputs the code coverage report.
  *
  * @return void
  */
 protected function renderCodeCoverage()
 {
     $this->coverage->stop();
     $codeCoverageDirectory = PATH_site . 'typo3temp/codecoverage/';
     if (!is_readable($codeCoverageDirectory) && !is_dir($codeCoverageDirectory)) {
         t3lib_div::mkdir($codeCoverageDirectory);
     }
     $coverageReport = new PHP_CodeCoverage_Report_HTML();
     $coverageReport->process($this->coverage, $codeCoverageDirectory);
     $this->outputService->output('<p><a target="_blank" href="../typo3temp/codecoverage/index.html">' . 'Click here to access the Code Coverage report</a></p>' . '<p>Memory peak usage: ' . t3lib_div::formatSize(memory_get_peak_usage()) . 'B<p/>');
 }
示例#23
0
    /**
     * Export part of module
     *
     * @param	array		Content of POST VAR tx_impexp[]..
     * @return	void		Setting content in $this->content
     */
    function exportData($inData)
    {
        global $TCA, $LANG;
        // BUILDING EXPORT DATA:
        // Processing of InData array values:
        $inData['pagetree']['maxNumber'] = t3lib_div::intInRange($inData['pagetree']['maxNumber'], 1, 10000, 100);
        $inData['listCfg']['maxNumber'] = t3lib_div::intInRange($inData['listCfg']['maxNumber'], 1, 10000, 100);
        $inData['maxFileSize'] = t3lib_div::intInRange($inData['maxFileSize'], 1, 10000, 1000);
        $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/', '', preg_replace('/\\.(t3d|xml)$/', '', $inData['filename'])));
        if (strlen($inData['filename'])) {
            $inData['filename'] .= $inData['filetype'] == 'xml' ? '.xml' : '.t3d';
        }
        // Set exclude fields in export object:
        if (!is_array($inData['exclude'])) {
            $inData['exclude'] = array();
        }
        // Saving/Loading/Deleting presets:
        $this->processPresets($inData);
        // Create export object and configure it:
        $this->export = t3lib_div::makeInstance('tx_impexp');
        $this->export->init(0, 'export');
        $this->export->setCharset($LANG->charSet);
        $this->export->maxFileSize = $inData['maxFileSize'] * 1024;
        $this->export->excludeMap = (array) $inData['exclude'];
        $this->export->softrefCfg = (array) $inData['softrefCfg'];
        $this->export->extensionDependencies = (array) $inData['extension_dep'];
        $this->export->showStaticRelations = $inData['showStaticRelations'];
        $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources'];
        // Static tables:
        if (is_array($inData['external_static']['tables'])) {
            $this->export->relStaticTables = $inData['external_static']['tables'];
        }
        // Configure which tables external relations are included for:
        if (is_array($inData['external_ref']['tables'])) {
            $this->export->relOnlyTables = $inData['external_ref']['tables'];
        }
        $this->export->setHeaderBasics();
        // Meta data setting:
        $this->export->setMetaData($inData['meta']['title'], $inData['meta']['description'], $inData['meta']['notes'], $GLOBALS['BE_USER']->user['username'], $GLOBALS['BE_USER']->user['realName'], $GLOBALS['BE_USER']->user['email']);
        if ($inData['meta']['thumbnail']) {
            $tempDir = $this->userTempFolder();
            if ($tempDir) {
                $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1);
                $theThumb = $thumbnails[$inData['meta']['thumbnail']];
                if ($theThumb) {
                    $this->export->addThumbnail($theThumb);
                }
            }
        }
        // Configure which records to export
        if (is_array($inData['record'])) {
            foreach ($inData['record'] as $ref) {
                $rParts = explode(':', $ref);
                $this->export->export_addRecord($rParts[0], t3lib_BEfunc::getRecord($rParts[0], $rParts[1]));
            }
        }
        // Configure which tables to export
        if (is_array($inData['list'])) {
            foreach ($inData['list'] as $ref) {
                $rParts = explode(':', $ref);
                if ($GLOBALS['BE_USER']->check('tables_select', $rParts[0])) {
                    $res = $this->exec_listQueryPid($rParts[0], $rParts[1], t3lib_div::intInRange($inData['listCfg']['maxNumber'], 1));
                    while ($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                        $this->export->export_addRecord($rParts[0], $subTrow);
                    }
                }
            }
        }
        // Pagetree
        if (isset($inData['pagetree']['id'])) {
            if ($inData['pagetree']['levels'] == -1) {
                // Based on click-expandable tree
                $pagetree = t3lib_div::makeInstance('localPageTree');
                $tree = $pagetree->ext_tree($inData['pagetree']['id'], $this->filterPageIds($this->export->excludeMap));
                $this->treeHTML = $pagetree->printTree($tree);
                $idH = $pagetree->buffer_idH;
            } elseif ($inData['pagetree']['levels'] == -2) {
                // Only tables on page
                $this->addRecordsForPid($inData['pagetree']['id'], $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']);
            } else {
                // Based on depth
                // Drawing tree:
                // If the ID is zero, export root
                if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) {
                    $sPage = array('uid' => 0, 'title' => 'ROOT');
                } else {
                    $sPage = t3lib_BEfunc::getRecordWSOL('pages', $inData['pagetree']['id'], '*', ' AND ' . $this->perms_clause);
                }
                if (is_array($sPage)) {
                    $pid = $inData['pagetree']['id'];
                    $tree = t3lib_div::makeInstance('t3lib_pageTree');
                    $tree->init('AND ' . $this->perms_clause . $this->filterPageIds($this->export->excludeMap));
                    $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $sPage);
                    $tree->tree[] = array('row' => $sPage, 'HTML' => $HTML);
                    $tree->buffer_idH = array();
                    if ($inData['pagetree']['levels'] > 0) {
                        $tree->getTree($pid, $inData['pagetree']['levels'], '');
                    }
                    $idH = array();
                    $idH[$pid]['uid'] = $pid;
                    if (count($tree->buffer_idH)) {
                        $idH[$pid]['subrow'] = $tree->buffer_idH;
                    }
                    $pagetree = t3lib_div::makeInstance('localPageTree');
                    $this->treeHTML = $pagetree->printTree($tree->tree);
                }
            }
            // In any case we should have a multi-level array, $idH, with the page structure here (and the HTML-code loaded into memory for nice display...)
            if (is_array($idH)) {
                $flatList = $this->export->setPageTree($idH);
                // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
                foreach ($flatList as $k => $value) {
                    $this->export->export_addRecord('pages', t3lib_BEfunc::getRecord('pages', $k));
                    $this->addRecordsForPid($k, $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']);
                }
            }
        }
        // After adding ALL records we set relations:
        for ($a = 0; $a < 10; $a++) {
            $addR = $this->export->export_addDBRelations($a);
            if (!count($addR)) {
                break;
            }
        }
        // Finally files are added:
        $this->export->export_addFilesFromRelations();
        // MUST be after the DBrelations are set so that files from ALL added records are included!
        // If the download button is clicked, return file
        if ($inData['download_export'] || $inData['save_export']) {
            switch ((string) $inData['filetype']) {
                case 'xml':
                    $out = $this->export->compileMemoryToFileContent('xml');
                    $fExt = '.xml';
                    break;
                case 't3d':
                    $this->export->dontCompress = 1;
                default:
                    $out = $this->export->compileMemoryToFileContent();
                    $fExt = ($this->export->doOutputCompress() ? '-z' : '') . '.t3d';
                    break;
            }
            // Filename:
            $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_' . substr(preg_replace('/[^[:alnum:]_]/', '-', $inData['download_export_name']), 0, 20) . '_' . date('d-m-H-i-s') . $fExt;
            // Export for download:
            if ($inData['download_export']) {
                $mimeType = 'application/octet-stream';
                Header('Content-Type: ' . $mimeType);
                Header('Content-Length: ' . strlen($out));
                Header('Content-Disposition: attachment; filename=' . basename($dlFile));
                echo $out;
                exit;
            }
            // Export by saving:
            if ($inData['save_export']) {
                $savePath = $this->userSaveFolder();
                $fullName = $savePath . $dlFile;
                if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) {
                    t3lib_div::writeFile($fullName, $out);
                    $this->content .= $this->doc->section($LANG->getLL('exportdata_savedFile'), sprintf($LANG->getLL('exportdata_savedInSBytes', 1), substr($savePath . $dlFile, strlen(PATH_site)), t3lib_div::formatSize(strlen($out))), 0, 1);
                } else {
                    $this->content .= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'), sprintf($LANG->getLL('exportdata_badPathS', 1), $fullName), 0, 1, 2);
                }
            }
        }
        // OUTPUT to BROWSER:
        // Now, if we didn't make download file, show configuration form based on export:
        $menuItems = array();
        // Export configuration
        $row = array();
        $this->makeConfigurationForm($inData, $row);
        $menuItems[] = array('label' => $LANG->getLL('tableselec_configuration'), 'content' => '
				<table border="0" cellpadding="1" cellspacing="1">
					' . implode('
					', $row) . '
				</table>
			');
        // File options
        $row = array();
        $this->makeSaveForm($inData, $row);
        $menuItems[] = array('label' => $LANG->getLL('exportdata_filePreset'), 'content' => '
				<table border="0" cellpadding="1" cellspacing="1">
					' . implode('
					', $row) . '
				</table>
			');
        // File options
        $row = array();
        $this->makeAdvancedOptionsForm($inData, $row);
        $menuItems[] = array('label' => $LANG->getLL('exportdata_advancedOptions'), 'content' => '
				<table border="0" cellpadding="1" cellspacing="1">
					' . implode('
					', $row) . '
				</table>
			');
        // Generate overview:
        $overViewContent = $this->export->displayContentOverview();
        // Print errors that might be:
        $errors = $this->export->printErrorLog();
        $menuItems[] = array('label' => $LANG->getLL('exportdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0);
        // Add hidden fields and create tabs:
        $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_export', -1);
        $content .= '<input type="hidden" name="tx_impexp[action]" value="export" />';
        $this->content .= $this->doc->section('', $content, 0, 1);
        // Output Overview:
        $this->content .= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'), $overViewContent, 0, 1);
    }
 /**
  * Provides status information on the deprecation log, whether it's enabled
  * and if so whether certain limits in file size are reached.
  *
  * @return	tx_reports_reports_status_Status	The deprecation log status.
  */
 protected function getDeprecationLogStatus()
 {
     $title = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLog');
     $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disabled');
     $message = '';
     $severity = tx_reports_reports_status_Status::OK;
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enabled');
         $message = '<p>' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogEnabled') . '</p>';
         $severity = tx_reports_reports_status_Status::NOTICE;
         $logFile = t3lib_div::getDeprecationLogFileName();
         $logFileSize = 0;
         if (file_exists($logFile)) {
             $logFileSize = filesize($logFile);
             $message .= '<p> ' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogFile'), $this->getDeprecationLogFileLink()) . '</p>';
         }
         if ($logFileSize > $this->deprecationLogFileSizeWarningThreshold) {
             $severity = tx_reports_reports_status_Status::WARNING;
         }
         if ($logFileSize > $this->deprecationLogFileSizeErrorThreshold) {
             $severity = tx_reports_reports_status_Status::ERROR;
         }
         if ($severity > tx_reports_reports_status_Status::OK) {
             $message .= '<p> ' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogSize'), t3lib_div::formatSize($logFileSize)) . '</p>';
         }
     }
     return t3lib_div::makeInstance('tx_reports_reports_status_Status', $title, $value, $message, $severity);
 }
示例#25
0
	/**
	 * Render display of a Template Object
	 *
	 * @param	array		Template Object record to render
	 * @param	array		Array of all Template Objects (passed by reference. From here records are unset)
	 * @param	integer		Scope of DS
	 * @param	boolean		If set, the function is asked to render children to template objects (and should not call it self recursively again).
	 * @return	string		HTML content
	 */
	function renderTODisplay($toObj, $scope, $children=0)	{

			// Put together the records icon including content sensitive menu link wrapped around it:
		$recordIcon = t3lib_iconWorks::getSpriteIconForRecord('tx_templavoila_tmplobj', array(), array('title' => $toObj->getKey()));
		$recordIcon = $this->doc->wrapClickMenuOnIcon($recordIcon, 'tx_templavoila_tmplobj', $toObj->getKey(), 1, '&callingScriptId='.rawurlencode($this->doc->scriptID));

			// Preview icon:
		if ($toObj->getIcon())	{
			if (isset($this->modTSconfig['properties']['toPreviewIconThumb']) && $this->modTSconfig['properties']['toPreviewIconThumb'] != '0') {
					$path = realpath(dirname(__FILE__) . '/' . preg_replace('/\w+\/\.\.\//', '', $GLOBALS['BACK_PATH'] . $toObj->getIcon()));
					$path = str_replace(realpath(PATH_site) . '/', PATH_site, $path);
					if($path == FALSE) {
						$icon = $GLOBALS['LANG']->getLL('noicon', 1);
					} else {
						$icon = t3lib_BEfunc::getThumbNail($this->doc->backPath . 'thumbs.php', $path,
							'hspace="5" vspace="5" border="1"',
							strpos($this->modTSconfig['properties']['toPreviewIconThumb'], 'x') ? $this->modTSconfig['properties']['toPreviewIconThumb'] : '');
					}
				} else {
					$icon = '<img src="' . $this->doc->backPath . $toObj->getIcon() . '" alt="" />';
				}
		} else {
			$icon = $GLOBALS['LANG']->getLL('noicon', 1);
		}

			// Mapping status / link:
		$linkUrl = '../cm1/index.php?table=tx_templavoila_tmplobj&uid=' . $toObj->getKey() . '&_reload_from=1&id=' . $this->id . '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));

		$fileReference = t3lib_div::getFileAbsFileName($toObj->getFileref());
		if (@is_file($fileReference))	{
			$this->tFileList[$fileReference]++;
			$fileRef = '<a href="'.htmlspecialchars($this->doc->backPath.'../'.substr($fileReference,strlen(PATH_site))).'" target="_blank">'.htmlspecialchars($toObj->getFileref()).'</a>';
			$fileMsg = '';
			$fileMtime = filemtime($fileReference);
		} else {
			$fileRef = htmlspecialchars($toObj->getFileref());
			$fileMsg = '<div class="typo3-red">ERROR: File not found</div>';
			$fileMtime = 0;
		}

		$mappingStatus = $mappingStatus_index = '';
		if ($fileMtime && $toObj->getFilerefMtime()) {
			if ($toObj->getFilerefMD5() != '') {
				$modified = (@md5_file($fileReference) != $toObj->getFilerefMD5());
			} else {
				$modified = ($toObj->getFilerefMtime() != $fileMtime);
			}
			if ($modified)	{
				$mappingStatus = $mappingStatus_index = t3lib_iconWorks::getSpriteIcon('status-dialog-warning');
				$mappingStatus.= sprintf($GLOBALS['LANG']->getLL('towasupdated', 1), t3lib_BEfunc::datetime($toObj->getTstamp()));
				$this->setErrorLog($scope, 'warning', sprintf($GLOBALS['LANG']->getLL('warning_mappingstatus', 1), $mappingStatus, $toObj->getLabel()));
			} else {
				$mappingStatus = $mappingStatus_index = t3lib_iconWorks::getSpriteIcon('status-dialog-ok');
				$mappingStatus.= $GLOBALS['LANG']->getLL('mapping_uptodate', 1);
			}
			$mappingStatus .= '<br/><input type="button" onclick="jumpToUrl(\'' . htmlspecialchars($linkUrl) . '\');" value="' . $GLOBALS['LANG']->getLL('update_mapping', 1) . '" />';
		} elseif (!$fileMtime) {
			$mappingStatus = $mappingStatus_index = t3lib_iconWorks::getSpriteIcon('status-dialog-error');
			$mappingStatus.= $GLOBALS['LANG']->getLL('notmapped', 1);
			$this->setErrorLog($scope, 'fatal', sprintf($GLOBALS['LANG']->getLL('warning_mappingstatus', 1), $mappingStatus, $toObj->getLabel()));

			$mappingStatus .= $GLOBALS['LANG']->getLL('updatemapping_info');
			$mappingStatus .= '<br/><input type="button" onclick="jumpToUrl(\'' . htmlspecialchars($linkUrl) . '\');" value="' . $GLOBALS['LANG']->getLL('map', 1) . '" />';
		} else {
			$mappingStatus = '';
			$mappingStatus .= '<input type="button" onclick="jumpToUrl(\'' . htmlspecialchars($linkUrl) . '\');" value="' . $GLOBALS['LANG']->getLL('remap', 1) . '" />';
			$mappingStatus .= '&nbsp;<input type="button" onclick="jumpToUrl(\'' . htmlspecialchars($linkUrl . '&_preview=1') . '\');" value="' . $GLOBALS['LANG']->getLL('preview', 1) . '" />';
		}

		if ($this->MOD_SETTINGS['set_details'])	{
			$XMLinfo = $this->DSdetails($toObj->getLocalDataprotXML(TRUE));
		}

			// Format XML if requested
		if ($this->MOD_SETTINGS['set_details'])	{
			if ($toObj->getLocalDataprotXML(TRUE))	{
				require_once(PATH_t3lib.'class.t3lib_syntaxhl.php');
				$hlObj = t3lib_div::makeInstance('t3lib_syntaxhl');
				$lpXML = '<pre>'.str_replace(chr(9),'&nbsp;&nbsp;&nbsp;',$hlObj->highLight_DS($toObj->getLocalDataprotXML(TRUE))).'</pre>';
			} else $lpXML = '';
		}
		$lpXML.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[tx_templavoila_tmplobj]['.$toObj->getKey().']=edit&columnsOnly=localprocessing',$this->doc->backPath)).'">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';

			// Compile info table:
		$tableAttribs = ' border="0" cellpadding="1" cellspacing="1" width="98%" style="margin-top: 3px;" class="lrPadding"';

			// Links:
		$toTitle = '<a href="' . htmlspecialchars($linkUrl) . '">' . htmlspecialchars($GLOBALS['LANG']->sL($toObj->getLabel())) . '</a>';
		$editLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[tx_templavoila_tmplobj]['.$toObj->getKey().']=edit',$this->doc->backPath)).'">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';

		$fRWTOUres = array();

		if (!$children)	{
			if ($this->MOD_SETTINGS['set_details'])	{
				$fRWTOUres = $this->findRecordsWhereTOUsed($toObj,$scope);
			}

			$content.='
			<table'.$tableAttribs.'>
				<tr class="bgColor4-20">
					<td colspan="3">'.
						$recordIcon.
						$toTitle.
						$editLink.
						'</td>
				</tr>
				<tr class="bgColor4">
					<td rowspan="'.($this->MOD_SETTINGS['set_details'] ? 7 : 4).'" style="width: 100px; text-align: center;">'.$icon.'</td>
					<td style="width:200px;">' . $GLOBALS['LANG']->getLL('filereference', 1) . ':</td>
					<td>'.$fileRef.$fileMsg.'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('description', 1) . ':</td>
					<td>'.htmlspecialchars($toObj->getDescription()).'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('mappingstatus', 1) . ':</td>
					<td>'.$mappingStatus.'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('localprocessing_xml') . ':</td>
					<td>
						'.$lpXML.($toObj->getLocalDataprotXML(TRUE) ?
						t3lib_div::formatSize(strlen($toObj->getLocalDataprotXML(TRUE))).' bytes'.
						($this->MOD_SETTINGS['set_details'] ? '<hr/>'.$XMLinfo['HTML'] : '') : '').'
					</td>
				</tr>'.($this->MOD_SETTINGS['set_details'] ? '
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('usedby', 1) . ':</td>
					<td>'.$fRWTOUres['HTML'].'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('created', 1) . ':</td>
					<td>' . t3lib_BEfunc::datetime($toObj->getCrdate()) . ' ' . $GLOBALS['LANG']->getLL('byuser', 1) . ' [' . $toObj->getCruser() . ']</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('updated', 1) . ':</td>
					<td>'.t3lib_BEfunc::datetime($toObj->getTstamp()).'</td>
				</tr>' : '').'
			</table>
			';
		} else {
			$content.='
			<table'.$tableAttribs.'>
				<tr class="bgColor4-20">
					<td colspan="3">'.
						$recordIcon.
						$toTitle.
						$editLink.
						'</td>
				</tr>
				<tr class="bgColor4">
					<td style="width:200px;">' . $GLOBALS['LANG']->getLL('filereference', 1) . ':</td>
					<td>'.$fileRef.$fileMsg.'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('mappingstatus', 1) . ':</td>
					<td>'.$mappingStatus.'</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('rendertype', 1) . ':</td>
					<td>' . $this->getProcessedValue('tx_templavoila_tmplobj', 'rendertype', $toObj->getRendertype()) . '</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('language', 1) . ':</td>
					<td>' . $this->getProcessedValue('tx_templavoila_tmplobj', 'sys_language_uid', $toObj->getSyslang()) . '</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('localprocessing_xml') . ':</td>
					<td>
						'.$lpXML.($toObj->getLocalDataprotXML(TRUE) ?
						t3lib_div::formatSize(strlen($toObj->getLocalDataprotXML(TRUE))).' bytes'.
						($this->MOD_SETTINGS['set_details'] ? '<hr/>'.$XMLinfo['HTML'] : '') : '').'
					</td>
				</tr>'.($this->MOD_SETTINGS['set_details'] ? '
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('created', 1) . ':</td>
					<td>'.t3lib_BEfunc::datetime($toObj->getCrdate()) . ' ' . $GLOBALS['LANG']->getLL('byuser', 1) . ' [' . $toObj->getCruser() . ']</td>
				</tr>
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('updated', 1) . ':</td>
					<td>'.t3lib_BEfunc::datetime($toObj->getTstamp()).'</td>
				</tr>' : '').'
			</table>
			';
		}

			// Traverse template objects which are not children of anything:
		if(!$childRen) {
			$toRepo = t3lib_div::makeInstance('tx_templavoila_templateRepository');
			$toChildren = $toRepo->getTemplatesByParentTemplate($toObj);
		} else {
			$toChildren = array();
		}

		if (!$children && count($toChildren))	{
			$TOchildrenContent = '';
			foreach($toChildren as $toChild)	{
				$rTODres = $this->renderTODisplay($toChild, $scope, 1);
				$TOchildrenContent.= $rTODres['HTML'];
			}
			$content.='<div style="margin-left: 102px;">'.$TOchildrenContent.'</div>';
		}

			// Return content
		return array('HTML' => $content, 'mappingStatus' => $mappingStatus_index, 'usage' => $fRWTOUres['usage']);
	}
 /**
  * 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
  */
 function makeInfo($row, $tmplArray)
 {
     $tmplArray['size'] = t3lib_div::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;
 }
    /**
     * Renders header table row with media type and previewer
     *
     * @param	array		$PA An array with additional configuration options.
     * @param	object		$fobj TCEForms object reference
     * @return	string		The HTML code for the TCEform field
     */
    function tx_dam_mediaType($PA, &$fobj)
    {
        global $TCA;
        $this->tceforms =& $PA['pObj'];
        $config = $PA['fieldConf']['config'];
        $row = $PA['row'];
        $table = $PA['table'];
        // TODO overlay all fields to be safe
        foreach (array('media_type', 'file_name', 'file_path', 'file_size', 'hpixels', 'vpixels') as $field) {
            $row[$field] = $this->tceforms->getLanguageOverlayRawValue($table, $row, $field, $TCA[$table]['columns'][$field]);
        }
        $itemMediaInfo = '';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:lang/locallang_general.xml:LGL.title', true) . '<br />' . '<strong>' . htmlspecialchars($row['title']) . '</strong></div>';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_name', true) . '<br />' . '<strong>' . htmlspecialchars($row['file_name']) . '</strong></div>';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_path', true) . '<br />' . '<strong>' . htmlspecialchars($row['file_path']) . '</strong></div>';
        if ($row['media_type'] == TXDAM_mtype_image) {
            $out = '';
            $out .= $row['hpixels'] ? $row['hpixels'] . 'x' . $row['vpixels'] . ' px, ' : '';
            $out .= t3lib_div::formatSize($row['file_size']);
            $out .= $row['color_space'] ? ', ' . $this->tceforms->sL(t3lib_befunc::getLabelFromItemlist($PA['table'], 'color_space', $row['color_space']), true) : '';
            $itemMediaInfo .= '<div class="tableRow"><nobr>' . htmlspecialchars($out) . '</nobr></div>';
        }
        $itemMediaTypeIcon = tx_dam_guiFunc::getMediaTypeIconBox($row);
        $itemMediaInfoTable = '
			<table border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td valign="top">' . $itemMediaTypeIcon . '</td>
					<td valign="top" align="left" style="padding-left:25px;">' . $itemMediaInfo . '
					</td>
				</tr>
			</table>';
        $fieldTemplate = '
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="5" alt="" /></td>
			</tr>
			<tr>
				<td nowrap="nowrap"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /></td>
				<td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
			</tr>
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="15" alt="" /></td>
			</tr>
			';
        $itemMediaInfoTable = $this->tceforms->intoTemplate(array('NAME' => '', 'ID' => $row['uid'], 'FIELD' => $PA['field'], 'TABLE' => $PA['table'], 'ITEM' => $itemMediaInfoTable, 'HELP_ICON' => ''), $fieldTemplate);
        //
        // previewer
        //
        $itemPreviewer = '';
        $headerCode = '';
        $previewer = NULL;
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['previewerClasses'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['previewerClasses'] as $idName => $classRessource) {
                if (is_object($previewer = t3lib_div::getUserObj($classRessource))) {
                    if ($previewer->isValid($row, '200', 'topright')) {
                        $outArr = $previewer->render($row, '200', 'topright');
                        $itemPreviewer = $outArr['htmlCode'];
                        $headerCode = $outArr['headerCode'];
                        break;
                    }
                }
            }
            unset($previewer);
            $previewer = NULL;
        }
        // todo: header code should go into header - really - but how
        //
        // all together now
        //
        $out = '
			<tr>
				<td colspan="2">
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td valign="top">
								<table border="0" cellpadding="0" cellspacing="0">' . $itemMediaInfoTable . '
								</table>
							</td>
							<td width="1%" valign="top" align="center" style="padding: 0px 10px 0px 10px">' . $headerCode . $itemPreviewer . '</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="5" alt="" /></td>
			</tr>';
        return $out;
    }
示例#28
0
    function catXMLExportImportAction($l10ncfgObj)
    {
        global $LANG, $BACK_PATH, $BE_USER;
        $allowedSettingFiles = array('across' => 'acrossL10nmgrConfig.dst', 'dejaVu' => 'dejaVuL10nmgrConfig.dvflt', 'memoq' => 'memoQ.mqres', 'transit' => 'StarTransit_XML_UTF_TYPO3.FFD', 'sdltrados2007' => 'SDLTradosTagEditor.ini', 'sdltrados2009' => 'TYPO3_l10nmgr.sdlfiletype', 'sdlpassolo' => 'SDLPassolo.xfg');
        /** @var $service tx_l10nmgr_l10nBaseService */
        $service = t3lib_div::makeInstance('tx_l10nmgr_l10nBaseService');
        $info = '<br/>';
        $info .= '<input type="submit" value="' . $LANG->getLL('general.action.refresh.button.title') . '" name="_" /><br /><br/>';
        $info .= '<div id="ddtabs" class="basictab" style="border:0px solid gray;margin:0px;">
                                <ul style="border:0px solid #999999; ">
                                <li><a onClick="expandcontent(\'sc1\', this)" style="margin:0px;">' . $LANG->getLL('export.xml.headline.title') . '</a></li>
                                <li><a onClick="expandcontent(\'sc2\', this)" style="margin:0px;">' . $LANG->getLL('import.xml.headline.title') . '</a></li>
                                <li><a onClick="expandcontent(\'sc3\', this)" style="margin:0px;">' . $LANG->getLL('file.settings.downloads.title') . '</a></li>
                                <li><a onClick="expandcontent(\'sc4\', this)" style="margin:0px;">' . $LANG->getLL('l10nmgr.documentation.title') . '</a></li>
				</ul></div>';
        $info .= '<div id="tabcontentcontainer" style="height:150px;border:1px solid gray;padding-right:5px;width:100%;">';
        $info .= '<div id="sc1" class="tabcontent">';
        //$info .= '<div id="sc1" class="tabcontent">';
        $_selectOptions = array('0' => '-default-');
        $_selectOptions = $_selectOptions + $this->MOD_MENU["lang"];
        $info .= '<input type="checkbox" value="1" name="check_exports" /> ' . $LANG->getLL('export.xml.check_exports.title') . '<br />';
        $info .= '<input type="checkbox" value="1" name="no_check_xml" /> ' . $LANG->getLL('export.xml.no_check_xml.title') . '<br />';
        $info .= '<input type="checkbox" value="1" name="check_utf8" /> ' . $LANG->getLL('export.xml.checkUtf8.title') . '<br />';
        $info .= $LANG->getLL('export.xml.source-language.title') . $this->_getSelectField("export_xml_forcepreviewlanguage", '0', $_selectOptions) . '<br />';
        // Add the option to send to FTP server, if FTP information is defined
        if (!empty($this->lConf['ftp_server']) && !empty($this->lConf['ftp_server_username']) && !empty($this->lConf['ftp_server_password'])) {
            $info .= '<input type="checkbox" value="1" name="ftp_upload" id="tx_l10nmgr_ftp_upload" /> <label for="tx_l10nmgr_ftp_upload">' . $GLOBALS['LANG']->getLL('export.xml.ftp.title') . '</label>';
        }
        $info .= '<br /><br/>';
        $info .= '<input type="submit" value="Export" name="export_xml" /><br /><br /><br/>';
        $info .= '</div>';
        $info .= '<div id="sc2" class="tabcontent">';
        $info .= '<input type="checkbox" value="1" name="make_preview_link" /> ' . $LANG->getLL('import.xml.make_preview_link.title') . '<br />';
        $info .= '<input type="checkbox" value="1" name="import_delL10N" /> ' . $LANG->getLL('import.xml.delL10N.title') . '<br />';
        $info .= '<input type="checkbox" value="1" name="import_oldformat" /> ' . $LANG->getLL('import.xml.old-format.title') . '<br /><br />';
        $info .= '<input type="file" size="60" name="uploaded_import_file" /><br /><br /><input type="submit" value="Import" name="import_xml" /><br /><br /> ';
        $info .= '</div>';
        $info .= '<div id="sc3" class="tabcontent">';
        $info .= $this->doc->icons(1) . $LANG->getLL('file.settings.available.title');
        for (reset($allowedSettingFiles); list($settingId, $settingFileName) = each($allowedSettingFiles);) {
            $currentFile = t3lib_div::resolveBackPath($BACK_PATH . t3lib_extMgm::extRelPath('l10nmgr') . 'settings/' . $settingFileName);
            if (is_file($currentFile) && is_readable($currentFile)) {
                $size = t3lib_div::formatSize((int) filesize($currentFile), ' Bytes| KB| MB| GB');
                $info .= '<br/><a href="' . t3lib_div::rawUrlEncodeFP($currentFile) . '" title="' . $LANG->getLL('file.settings.download.title') . '" target="_blank">' . $LANG->getLL('file.settings.' . $settingId . '.title') . ' (' . $size . ')' . '</a> ';
            }
        }
        $info .= '</div>';
        $info .= '<div id="sc4" class="tabcontent">';
        $info .= '<a href="' . t3lib_extMgm::extRelPath('l10nmgr') . 'doc/manual.sxw" target="_new">Download</a>';
        $info .= '</div>';
        $info .= '</div>';
        $actionInfo = '';
        // Read uploaded file:
        if (t3lib_div::_POST('import_xml') && $_FILES['uploaded_import_file']['tmp_name'] && is_uploaded_file($_FILES['uploaded_import_file']['tmp_name'])) {
            $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['uploaded_import_file']['tmp_name']);
            /** @var $factory tx_l10nmgr_translationDataFactory */
            $factory = t3lib_div::makeInstance('tx_l10nmgr_translationDataFactory');
            //print "<pre>";
            //var_dump($GLOBALS['BE_USER']->user);
            //print "</pre>";
            if (t3lib_div::_POST('import_oldformat') == '1') {
                //Support for the old Format of XML Import (without pageGrp element)
                $actionInfo .= $LANG->getLL('import.xml.old-format.message');
                $translationData = $factory->getTranslationDataFromOldFormatCATXMLFile($uploadedTempFile);
                $translationData->setLanguage($this->sysLanguage);
                $service->saveTranslation($l10ncfgObj, $translationData);
                $actionInfo .= '<br/><br/>' . $this->doc->icons(1) . 'Import done<br/><br/>(Command count:' . $service->lastTCEMAINCommandsCount . ')';
            } else {
                // Relevant processing of XML Import with the help of the Importmanager
                /** @var $importManager tx_l10nmgr_CATXMLImportManager */
                $importManager = t3lib_div::makeInstance('tx_l10nmgr_CATXMLImportManager', $uploadedTempFile, $this->sysLanguage, $xmlString = "");
                if ($importManager->parseAndCheckXMLFile() === false) {
                    $actionInfo .= '<br/><br/>' . $this->doc->header($LANG->getLL('import.error.title')) . $importManager->getErrorMessages();
                } else {
                    if (t3lib_div::_POST('import_delL10N') == '1') {
                        $actionInfo .= $LANG->getLL('import.xml.delL10N.message') . '<br/>';
                        $delCount = $importManager->delL10N($importManager->getDelL10NDataFromCATXMLNodes($importManager->xmlNodes));
                        $actionInfo .= sprintf($LANG->getLL('import.xml.delL10N.count.message'), $delCount) . '<br/><br/>';
                    }
                    if (t3lib_div::_POST('make_preview_link') == '1') {
                        $pageIds = $importManager->getPidsFromCATXMLNodes($importManager->xmlNodes);
                        $actionInfo .= '<b>' . $LANG->getLL('import.xml.preview_links.title') . '</b><br/>';
                        /** @var $mkPreviewLinks tx_l10nmgr_mkPreviewLinkService */
                        $mkPreviewLinks = t3lib_div::makeInstance('tx_l10nmgr_mkPreviewLinkService', $t3_workspaceId = $importManager->headerData['t3_workspaceId'], $t3_sysLang = $importManager->headerData['t3_sysLang'], $pageIds);
                        $actionInfo .= $mkPreviewLinks->renderPreviewLinks($mkPreviewLinks->mkPreviewLinks());
                    }
                    $translationData = $factory->getTranslationDataFromCATXMLNodes($importManager->getXMLNodes());
                    $translationData->setLanguage($this->sysLanguage);
                    //$actionInfo.="<pre>".var_export($GLOBALS['BE_USER'],true)."</pre>";
                    unset($importManager);
                    $service->saveTranslation($l10ncfgObj, $translationData);
                    $actionInfo .= '<br/>' . $this->doc->icons(-1) . $LANG->getLL('import.xml.done.message') . '<br/><br/>(Command count:' . $service->lastTCEMAINCommandsCount . ')';
                }
            }
            t3lib_div::unlink_tempfile($uploadedTempFile);
        }
        // If export of XML is asked for, do that (this will exit and push a file for download, or upload to FTP is option is checked)
        if (t3lib_div::_POST('export_xml')) {
            // Save user prefs
            $BE_USER->pushModuleData('l10nmgr/cm1/checkUTF8', t3lib_div::_POST('check_utf8'));
            // Render the XML
            /** @var $viewClass tx_l10nmgr_CATXMLView */
            $viewClass = t3lib_div::makeInstance('tx_l10nmgr_CATXMLView', $l10ncfgObj, $this->sysLanguage);
            $export_xml_forcepreviewlanguage = intval(t3lib_div::_POST('export_xml_forcepreviewlanguage'));
            if ($export_xml_forcepreviewlanguage > 0) {
                $viewClass->setForcedSourceLanguage($export_xml_forcepreviewlanguage);
            }
            if ($this->MOD_SETTINGS['onlyChangedContent']) {
                $viewClass->setModeOnlyChanged();
            }
            if ($this->MOD_SETTINGS['noHidden']) {
                $viewClass->setModeNoHidden();
            }
            // Check the export
            if (t3lib_div::_POST('check_exports') == '1' && $viewClass->checkExports() == FALSE) {
                /** @var $flashMessage t3lib_FlashMessage */
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('export.process.duplicate.message'), $LANG->getLL('export.process.duplicate.title'), t3lib_FlashMessage::INFO);
                $actionInfo .= $flashMessage->render();
                $actionInfo .= $viewClass->renderExports();
            } else {
                // Upload to FTP
                if (t3lib_div::_POST('ftp_upload') == '1') {
                    try {
                        $filename = $this->uploadToFtp($viewClass);
                        // Send a mail notification
                        $this->emailNotification($filename, $l10ncfgObj, $this->sysLanguage);
                        // Prepare a success message for display
                        $title = $GLOBALS['LANG']->getLL('export.ftp.success');
                        $message = sprintf($GLOBALS['LANG']->getLL('export.ftp.success.detail'), $this->lConf['ftp_server_path'] . $filename);
                        $status = t3lib_FlashMessage::OK;
                    } catch (Exception $e) {
                        // Prepare an error message for display
                        $title = $GLOBALS['LANG']->getLL('export.ftp.error');
                        $message = $e->getMessage() . ' (' . $e->getCode() . ')';
                        $status = t3lib_FlashMessage::ERROR;
                    }
                    /** @var $flashMessage t3lib_FlashMessage */
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, $title, $status);
                    $actionInfo .= $flashMessage->render();
                    $actionInfo .= $viewClass->renderInternalMessagesAsFlashMessage($status);
                    // Download the XML file
                } else {
                    try {
                        $filename = $this->downloadXML($viewClass);
                        // Prepare a success message for display
                        $link = sprintf('<a href="%s" target="_blank">%s</a>', t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $filename, $filename);
                        $title = $GLOBALS['LANG']->getLL('export.download.success');
                        $message = sprintf($GLOBALS['LANG']->getLL('export.download.success.detail'), $link);
                        $status = t3lib_FlashMessage::OK;
                    } catch (Exception $e) {
                        // Prepare an error message for display
                        $title = $GLOBALS['LANG']->getLL('export.download.error');
                        $message = $e->getMessage() . ' (' . $e->getCode() . ')';
                        $status = t3lib_FlashMessage::ERROR;
                    }
                    /** @var $flashMessage t3lib_FlashMessage */
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, $title, $status);
                    $actionInfo .= $flashMessage->render();
                    $actionInfo .= $viewClass->renderInternalMessagesAsFlashMessage($status);
                }
            }
        }
        if (!empty($actionInfo)) {
            $info .= $this->doc->header($LANG->getLL('misc.messages.title'));
            $info .= $actionInfo;
        }
        $info .= '</div>';
        return $info;
    }
示例#29
0
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 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(t3lib_div::fixed_lgd_cs($row["item_title"], 30)), t3lib_div::formatSize($row["item_size"]), $this->getNumberOfWords($row["phash"]), t3lib_BEfunc::datetime($row["item_mtime"]), t3lib_BEfunc::datetime($row["crdate"]), $row["tstamp"] != $row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : "", $row["parsetime"], $this->getNumberOfSections($row["phash"]) . "/" . $grListRec[0]["pcount"] . "/" . $this->getNumberOfFulltext($row["phash"]), $row["pcount"], $cHash, $row["phash"], htmlentities(t3lib_div::fixed_lgd_cs($row["data_filename"], 100)));
         if ($row["pcount"] > 1) {
             $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping=' . intval($row['phash_grouping']) . ' AND phash!=' . intval($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"]), "", t3lib_BEfunc::datetime($row2["crdate"]), $row2["tstamp"] != $row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : "", $row2["parsetime"], $this->getNumberOfSections($row2["phash"]) . "/" . $grListRec[0]["pcount"] . "/" . $this->getNumberOfFulltext($row2["phash"]), "", $cHash, $row2["phash"], "");
             }
         }
         //		debug($row);
     }
     return $recList;
 }
示例#30
0
 /**
  * Make 1st level clickmenu:
  *
  * @param	string		The absolute path
  * @return	string		HTML content
  */
 function printFileClickMenu($path)
 {
     $menuItems = array();
     if (file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
         $fI = pathinfo($path);
         $size = ' (' . t3lib_div::formatSize(filesize($path)) . 'bytes)';
         $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($path) ? 'folder' : strtolower($fI['extension']), array('class' => 'absmiddle', 'title' => htmlspecialchars($fI['basename'] . $size)));
         // edit
         if (!in_array('edit', $this->disabledItems) && is_file($path) && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fI['extension'])) {
             $menuItems['edit'] = $this->FILE_launch($path, 'file_edit.php', 'edit', 'edit_file.gif');
         }
         // rename
         if (!in_array('rename', $this->disabledItems)) {
             $menuItems['rename'] = $this->FILE_launch($path, 'file_rename.php', 'rename', 'rename.gif');
         }
         // upload
         if (!in_array('upload', $this->disabledItems) && is_dir($path)) {
             $menuItems['upload'] = $this->FILE_upload($path);
         }
         // new
         if (!in_array('new', $this->disabledItems) && is_dir($path)) {
             $menuItems['new'] = $this->FILE_launch($path, 'file_newfolder.php', 'new', 'new_file.gif');
         }
         // info
         if (!in_array('info', $this->disabledItems)) {
             $menuItems['info'] = $this->DB_info($path, '');
         }
         $menuItems[] = 'spacer';
         // copy:
         if (!in_array('copy', $this->disabledItems)) {
             $menuItems['copy'] = $this->FILE_copycut($path, 'copy');
         }
         // cut:
         if (!in_array('cut', $this->disabledItems)) {
             $menuItems['cut'] = $this->FILE_copycut($path, 'cut');
         }
         // Paste:
         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
         if (!in_array('paste', $this->disabledItems) && $elFromAllTables && is_dir($path)) {
             $elArr = $this->clipObj->elFromTable('_FILE');
             reset($elArr);
             $selItem = current($elArr);
             $elInfo = array(basename($selItem), basename($path), $this->clipObj->currentMode());
             $menuItems['pasteinto'] = $this->FILE_paste($path, $selItem, $elInfo);
         }
         $menuItems[] = 'spacer';
         // delete:
         if (!in_array('delete', $this->disabledItems)) {
             $menuItems['delete'] = $this->FILE_delete($path);
         }
     }
     // Adding external elements to the menuItems array
     $menuItems = $this->processingByExtClassArray($menuItems, $path, 0);
     // Processing by external functions?
     $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
     // Return the printed elements:
     return $this->printItems($menuItems, $icon . basename($path));
 }