/** * Deletes all files older than a specific time in a temporary upload folder. * Settings for the threshold time and the folder are made in TypoScript. * * Here is an example: * <code> * plugin.Tx_Formhandler.settings.files.clearTempFilesOlderThanHours = 24 * plugin.Tx_Formhandler.settings.files.tmpUploadFolder = uploads/formhandler/tmp * </code> * * @param integer $olderThan Delete files older than $olderThan hours. * @return void * @author Reinhard Führicht <*****@*****.**> */ protected function clearTempFiles($uploadFolder, $olderThanValue, $olderThanUnit) { if (!$olderThanValue) { return; } //build absolute path to upload folder $path = Tx_Formhandler_StaticFuncs::getDocumentRoot() . $uploadFolder; //read files in directory $tmpFiles = t3lib_div::getFilesInDir($path); Tx_Formhandler_StaticFuncs::debugMessage('cleaning_temp_files', array($path)); //calculate threshold timestamp //hours * 60 * 60 = millseconds $threshold = Tx_Formhandler_StaticFuncs::getTimestamp($olderThanValue, $olderThanUnit); //for all files in temp upload folder foreach ($tmpFiles as $idx => $file) { //if creation timestamp is lower than threshold timestamp //delete the file $creationTime = filemtime($path . $file); //fix for different timezones $creationTime += date('O') / 100 * 60; if ($creationTime < $threshold) { unlink($path . $file); Tx_Formhandler_StaticFuncs::debugMessage('deleting_file', array($file)); } } }
public function tearDown() { $tmpFiles = t3lib_div::getFilesInDir($this->testDir); foreach ($tmpFiles as $tmpFile) { //unlink($this->testDir . $tmpFile); } //rmdir($this->testDir); }
function registerPngFix($params, $parent) { // handle stupid IE6 $userAgent = t3lib_div::getIndpEnv('HTTP_USER_AGENT'); if (!(strpos($userAgent, 'MSIE 6') === false) && strpos($userAgent, 'Opera') === false && strpos($userAgent, 'MSIE 7') === false) { //make sure we match IE6 but not Opera or IE7 $files = t3lib_div::getFilesInDir(PATH_typo3 . 'sysext/t3skin/stylesheets/ie6', 'css', 0, 1); foreach ($files as $fileName) { $params['pageRenderer']->addCssFile($parent->backPath . 'sysext/t3skin/stylesheets/ie6/' . $fileName); } // load files of spriteGenerator for ie6 $files = t3lib_div::getFilesInDir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6/', 'css', 0, 1); foreach ($files as $fileName) { $params['pageRenderer']->addCssFile($parent->backPath . '../' . t3lib_SpriteManager::$tempPath . 'ie6/' . $fileName); } } }
/** * Manipulating the input array, $params, adding new selectorbox items. * * @param array array of select field options (reference) * @param object parent object (reference) * @return void */ function main(&$params, &$pObj) { // get the current page ID $thePageId = $params['row']['pid']; $template = t3lib_div::makeInstance('t3lib_tsparser_ext'); // do not log time-performance information $template->tt_track = 0; $template->init(); $sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); $rootLine = $sys_page->getRootLine($thePageId); // generate the constants/config + hierarchy info for the template. $template->runThroughTemplates($rootLine); $template->generateConfig(); // get value for the path containing the template files $readPath = t3lib_div::getFileAbsFileName($template->setup['plugin.']['tx_ttaddress_pi1.']['templatePath']); // if that direcotry is valid and is a directory then select files in it if (@is_dir($readPath)) { $template_files = t3lib_div::getFilesInDir($readPath, 'tmpl,html,htm', 1, 1); $parseHTML = t3lib_div::makeInstance('t3lib_parseHTML'); foreach ($template_files as $htmlFilePath) { // reset vars $selectorBoxItem_title = ''; $selectorBoxItem_icon = ''; // read template content $content = t3lib_div::getUrl($htmlFilePath); // ... and extract content of the title-tags $parts = $parseHTML->splitIntoBlock('title', $content); $titleTagContent = $parseHTML->removeFirstAndLastTag($parts[1]); // set the item label $selectorBoxItem_title = trim($titleTagContent . ' (' . basename($htmlFilePath) . ')'); // try to look up an image icon for the template $fI = t3lib_div::split_fileref($htmlFilePath); $testImageFilename = $readPath . $fI['filebody'] . '.gif'; if (@is_file($testImageFilename)) { $selectorBoxItem_icon = '../' . substr($testImageFilename, strlen(PATH_site)); } // finally add the new item $params['items'][] = array($selectorBoxItem_title, basename($htmlFilePath), $selectorBoxItem_icon); } } }
/** * Recursively gather all files and folders of a path. * Usage: 5 * * @param array $fileArr: Empty input array (will have files added to it) * @param string $path: The path to read recursively from (absolute) (include trailing slash!) * @param string $extList: Comma list of file extensions: Only files with extensions in this list (if applicable) will be selected. * @param boolean $regDirs: If set, directories are also included in output. * @param integer $recursivityLevels: The number of levels to dig down... * @return array An array with the found files/directories. */ function getAllFilesAndFoldersInPath($fileArr, $path, $extList = '', $regDirs = 0, $recursivityLevels = 99) { if ($regDirs) { $fileArr[] = $path; } $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path, $extList, 1, 1)); $dirs = t3lib_div::get_dirs($path); if (is_array($dirs) && $recursivityLevels > 0) { foreach ($dirs as $subdirs) { if ((string) $subdirs != '') { $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $path . $subdirs . '/', $extList, $regDirs, $recursivityLevels - 1); } } } return $fileArr; }
/** * Renders the template selector. * * @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page. * @param string $templateType: The template type, 'tmplobj' or 't3d' * @return string HTML output containing a table with the template selector */ function renderTemplateSelector($positionPid, $templateType = 'tmplobj') { global $LANG, $TYPO3_DB; $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid); $tmplHTML = array(); switch ($templateType) { case 'tmplobj': // Create the "Default template" entry $previewIconFilename = $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif'; $previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />'; $description = htmlspecialchars($LANG->getLL('template_descriptiondefault')); $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titledefault')) . '</h3></td></tr> <tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>'; $tTO = 'tx_templavoila_tmplobj'; $tDS = 'tx_templavoila_datastructure'; $where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . $tDS . '.scope=1' . $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS); $res = $TYPO3_DB->exec_SELECTquery($tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', $where); while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) { // Check if preview icon exists, otherwise use default icon: $tmpFilename = 'uploads/tx_templavoila/' . $row['previewicon']; $previewIconFilename = @is_file(PATH_site . $tmpFilename) ? $GLOBALS['BACK_PATH'] . '../' . $tmpFilename : $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif'; // Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376 $previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $row['uid'] . '" src="' . $previewIconFilename . '" title="" />'; $description = $row['description'] ? htmlspecialchars($row['description']) : $LANG->getLL('template_nodescriptionavailable'); $tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($row['title']) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>'; } $tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />'; break; case 't3d': if (t3lib_extMgm::isLoaded('impexp')) { // Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests. $templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/'; $files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1); // Traverse the files found: foreach ($files as $absPath) { // Initialize the import object: $import = $this->getImportObject(); if ($import->loadFile($absPath)) { if (is_array($import->dat['header']['pagetree'])) { // This means there are pages in the file, we like that...: // Page tree: reset($import->dat['header']['pagetree']); $pageTree = current($import->dat['header']['pagetree']); // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension']; t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; } else { t3lib_div::unlink_tempfile($fileName); $iconTag = ''; } } } $aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">'; $aTagE = '</a>'; $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr> <tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p> <em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/> File: ' . basename($absPath) . '</em></td></tr></table>'; } } } } break; } if (is_array($tmplHTML) && count($tmplHTML)) { $counter = 0; $content .= '<table>'; foreach ($tmplHTML as $single) { $content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : ''); $counter++; if ($counter > 1) { $counter = 0; } } $content .= '</table>'; } return $content; }
function getFiles($conf, $folder, $sort = 'ASC', $limit = '', $hash = 0) { $files = t3lib_div::getFilesInDir($folder, $conf['main.']['file_extensions'], 1, 1); // Get all pictures (sort by name ASC AND with folders) // 1. sort array switch ($sort) { // sortmode case 'random': // shuffle array shuffle($files); break; case 'DESC': // alphabetical descendening arsort($files); break; case 'newest': // newest or // newest or case 'oldest': // oldest files if (is_array($files)) { // if files is an array $newarray = array(); foreach ($files as $value) { // one loop for every file $newarray[filemtime($value)] = $value; // $array[time] = pic.jpg } if ($sort == 'newest') { krsort($newarray); } // sort from key if ($sort == 'oldest') { ksort($newarray); } // sort from key $files = $newarray; // overwrite files array } break; case strpos($method, '"') !== false: // " found $files[0] = $folder . str_replace('"', '', $sort); // special picture break; default: // default // default case 'ASC': // or ASC - so do nothing break; } // 2. rewrite keys of array $array = array(); if (is_array($files)) { // if the array is filled foreach ($files as $key => $value) { // one loop for every key // rewrite key in new array if (!$hash) { $array[] = $value; } else { $array[] = $this->hashCode($value); } // with hashcode instead of filename } } // 3. return whole or part of array if (!empty($array)) { // if there is an entry if (empty($limit)) { // no limit return $array; // return complete array } else { // there is an entry for limit if (strlen($limit) > 6) { // return only a special picture like pic.jpg $temparray = array(); if (is_array($array)) { // if is array foreach ($array as $key => $value) { // one loop for every picture in array if ($this->hashCode($value) == $limit) { // if hash fits, return picture $temparray[] = $value; // $temparray[0] = fileadmin/pic.jpg return $temparray; } } } } else { // cut after X return array_slice($array, 0, $limit); // return only the first X values of the array } } } }
/** * this method calls the main methods from the handler classes * merges the results with the data from the skin, and cache it * * @return void */ protected function rebuildCache() { // ask the handlerClass to kindly rebuild our data $this->handler->generate(); // get all Icons registered from skins, merge with core-Icon-List $availableSkinIcons = (array) $GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames']; foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinName => $skinData) { $availableSkinIcons = array_merge($availableSkinIcons, (array) $skinData['availableSpriteIcons']); } // merge icon names whith them provided by the skin, // registered from "complete sprites" and the ones detected // by the handlerclass $this->iconNames = array_merge($availableSkinIcons, (array) $GLOBALS['TBE_STYLES']['spritemanager']['spriteIconsAvailable'], $this->handler->getAvailableIconNames()); // serialize found icons, and cache them to file $cacheString = addslashes(serialize($this->iconNames)); $fileContent = '<?php $GLOBALS[\'TBE_STYLES\'][\'spriteIconApi\'][\'iconsAvailable\'] = unserialize(stripslashes(\'' . $cacheString . '\')); ?>'; // delete old cache files $oldFiles = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', 1); foreach ($oldFiles as $file) { @unlink($file); } // and write the new one t3lib_div::writeFile($this->tempFileName, $fileContent); }
/** * Main Task center module * * @return string HTML content. */ public function main() { $content = ''; $id = intval(t3lib_div::_GP('display')); // if a preset is found, it is rendered using an iframe if ($id > 0) { $url = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id; return $this->taskObject->urlInIframe($url, 1); } else { // header $content .= $this->taskObject->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description')); $thumbnails = $lines = array(); // Thumbnail folder and files: $tempDir = $this->userTempFolder(); if ($tempDir) { $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1); } $clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $usernames = t3lib_BEfunc::getUserNames(); // Create preset links: $presets = $this->getPresets(); // if any presets found if (is_array($presets)) { foreach ($presets as $key => $presetCfg) { $configuration = unserialize($presetCfg['preset_data']); $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']]; $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']'; $icon = 'EXT:impexp/export.gif'; $description = array(); // is public? if ($presetCfg['public']) { $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes'); } // owner $description[] = $GLOBALS['LANG']->getLL('task.owner') . ': ' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? $GLOBALS['LANG']->getLL('task.own') : '[' . htmlspecialchars($usernames[$presetCfg['user_uid']]['username']) . ']'); // page & path if ($configuration['pagetree']['id']) { $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id']; $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20)); } else { $description[] = $GLOBALS['LANG']->getLL('single-record'); } // Meta information if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) { $metaInformation = ''; if ($configuration['meta']['title']) { $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />'; } if ($configuration['meta']['description']) { $metaInformation .= htmlspecialchars($configuration['meta']['description']); } if ($configuration['meta']['notes']) { $metaInformation .= '<br /><br /> <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>'; } $description[] = '<br />' . $metaInformation; } // collect all preset information $lines[$key] = array('icon' => $icon, 'title' => $title, 'descriptionHtml' => implode('<br />', $description), 'link' => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']); } // render preset list $content .= $this->taskObject->renderListMenu($lines); } else { // no presets found $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('no-presets'), '', t3lib_FlashMessage::NOTICE); $content .= $flashMessage->render(); } } return $content; }
/** * Add all *.css files of the directory $path to the stylesheets * * @param string directory to add * @return void */ function addStyleSheetDirectory($path) { // calculation needed, when TYPO3 source is used via a symlink // absolute path to the stylesheets $filePath = dirname(t3lib_div::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path; // clean the path $resolvedPath = t3lib_div::resolveBackPath($filePath); // read all files in directory and sort them alphabetically $files = t3lib_div::getFilesInDir($resolvedPath, 'css', FALSE, 1); foreach ($files as $file) { $this->pageRenderer->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all'); } }
/** * Rename "icon_" files in typo3temp/ * Function for development purposes. * * @return void */ function renameIconsInTypo3Temp() { $files = t3lib_div::getFilesInDir(PATH_site . 'typo3temp/', 'gif,png', 1); foreach ($files as $filename) { if (t3lib_div::isFirstPartOfStr(basename($filename), 'icon_')) { $dir = dirname($filename) . '/'; $reg = array(); if (preg_match('#icon_[[:alnum:]]+_([[:alnum:]_]+).(gif|png).(gif|png)#', basename($filename), $reg)) { if (@is_file($filename)) { $newFile = $dir . $reg[1] . '.' . $reg[3]; debug($newFile, 1); rename($filename, $newFile); } } } } }
/** * 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(' ', ' ', 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; }
/** * tx_adgallery_pi1::displayItemsList() * * @return */ public function displayItemsList() { $content = ''; $contentList = ''; $res = $this->getAllItems(); $markerArrayGlobal = array(); $iItem = 1; $markerArrayTemp = array(); // Normal mode with selected files if ($this->conf['displayType'] == 0) { $files = t3lib_div::trimExplode(',', $this->conf['classicimages']); $titles = t3lib_div::trimExplode(chr(10), $this->conf['classicimagestitles']); $alt_texts = t3lib_div::trimExplode(chr(10), $this->conf['classicimagesalttexts']); foreach ($files as $file) { $markerArray = array(); $item['file_path'] = trim($this->imageDir); $item['file_name'] = $file; $item['title'] = count($titles) >= $iItem ? $titles[$iItem - 1] : ''; $item['alt_text'] = count($alt_texts) >= $iItem ? $alt_texts[$iItem - 1] : ''; $item['description'] = $item['file_path'] . $file; $item = $this->processItemList($item); $item['i'] = $iItem++; $markerArray = array_merge($markerArray, $this->misc->convertToMarkerArray($item)); $markerArrayTemp[] = $markerArray; unset($markerArray); } } else { if ($this->conf['displayType'] == 3) { // Normal mode without DAM $path = rtrim(trim(PATH_site . $this->conf['classicimagespath']), '/'); $files = t3lib_div::getFilesInDir($path, 'png,gif,jpg,jpeg', 0, 1); foreach ($files as $file) { $markerArray = array(); $item['file_path'] = trim($this->conf['classicimagespath']); $item['file_name'] = $file; $item['title'] = $file; $item['alt_text'] = ''; $item['description'] = ''; $item = $this->processItemList($item); $item['i'] = $iItem++; $markerArray = array_merge($markerArray, $this->misc->convertToMarkerArray($item)); $markerArrayTemp[] = $markerArray; unset($markerArray); } } else { if ($this->conf['displayType'] == 4) { while ($item = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository'); $file = $fileRepository->findByUid($item['uid']); $storageConfiguration = $file->getStorage()->getConfiguration(); $basePath = rtrim($storageConfiguration['basePath'], '/'); $markerArray = array(); $item['file_path'] = $basePath . dirname($item['identifier']) . '/'; $item['file_name'] = $item['name']; $item['title'] = $item['title']; $item['alt_text'] = $item['alternative']; $item = $this->processItemList($item); $item['i'] = $iItem++; $markerArray = array_merge($markerArray, $this->misc->convertToMarkerArray($item)); $markerArrayTemp[] = $markerArray; unset($markerArray); } $GLOBALS['TYPO3_DB']->sql_free_result($res); } else { if (version_compare(TYPO3_version, '6.2.0', '<')) { // Mode with DAM directory or DAM category while ($item = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $markerArray = array(); $item = $this->processItemList($item); $item['i'] = $iItem++; $markerArray = array_merge($markerArray, $this->misc->convertToMarkerArray($item)); $markerArrayTemp[] = $markerArray; unset($markerArray); } $GLOBALS['TYPO3_DB']->sql_free_result($res); } else { foreach ($res as $file) { $item = $file->getProperties(); $storageConfiguration = $file->getStorage()->getConfiguration(); $basePath = rtrim($storageConfiguration['basePath'], '/'); $markerArray = array(); $item['file_path'] = $basePath . dirname($item['identifier']) . '/'; $item['file_name'] = $item['name']; $item['title'] = $item['title']; $item['alt_text'] = $item['alternative']; $item = $this->processItemList($item); $item['i'] = $iItem++; $markerArray = array_merge($markerArray, $this->misc->convertToMarkerArray($item)); $markerArrayTemp[] = $markerArray; unset($markerArray); } } } } } // 0 item if (count($markerArrayTemp) == 0) { return $content; } $contentList = $this->template->renderAllTemplate($markerArrayTemp, '###ADGALLERY_LIST###'); unset($markerArrayTemp); $markerArrayGlobal['###ADGALLERY_LIST###'] = $contentList; $markerArrayGlobal = array_merge($markerArrayGlobal, $this->extraGlobalMarker()); $content .= $this->template->renderAllTemplate($markerArrayGlobal, '###ADGALLERY_GLOBAL###'); return $content; }
/** * Removing temp_CACHED files for installation * * @param string KEY pointing to installation * @return string HTML content */ function rmCachedFiles($exp) { $all = $this->globalSiteInfo[$exp]; $content = ' <h2>' . htmlspecialchars($all['siteInfo']['sitename'] . ' (DB: ' . $all['siteInfo']['TYPO3_db']) . ')</h2> <hr /> <h3>typo3conf/temp_CACHED_* files:</h3>'; $path = $all['siteInfo']['SA_PATH'] . '/typo3conf/'; if (@is_dir($path)) { $filesInDir = t3lib_div::getFilesInDir($path, 'php', 1); foreach ($filesInDir as $kk => $vv) { if (t3lib_div::isFirstPartOfStr(basename($vv), 'temp_CACHED_')) { if (strstr(basename($vv), 'ext_localconf.php') || strstr(basename($vv), 'ext_tables.php')) { $content .= 'REMOVED: ' . $vv . '<br />'; unlink($vv); if (file_exists($vv)) { $content .= $this->error('ERROR: File still exists, so could not be removed anyways!') . '<br />'; } } } } } else { $content .= $this->error('ERROR: ' . $path . ' was not a directory!'); } 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 . ' </td></tr><tr><td nowrap="nowrap" class="pixel">' . $pDim . ' </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; }
/** * Recursively gather all files and folders of a path. * Usage: 5 * * @param array $fileArr: Empty input array (will have files added to it) * @param string $path: The path to read recursively from (absolute) (include trailing slash!) * @param string $extList: Comma list of file extensions: Only files with extensions in this list (if applicable) will be selected. * @param boolean $regDirs: If set, directories are also included in output. * @param integer $recursivityLevels: The number of levels to dig down... * @param string $excludePattern: regex pattern of files/directories to exclude * @return array An array with the found files/directories. */ public static function getAllFilesAndFoldersInPath(array $fileArr, $path, $extList = '', $regDirs = 0, $recursivityLevels = 99, $excludePattern = '') { if ($regDirs) { $fileArr[] = $path; } $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path, $extList, 1, 1, $excludePattern)); $dirs = t3lib_div::get_dirs($path); if (is_array($dirs) && $recursivityLevels > 0) { foreach ($dirs as $subdirs) { if ((string) $subdirs != '' && (!strlen($excludePattern) || !preg_match('/^' . $excludePattern . '$/', $subdirs))) { $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $path . $subdirs . '/', $extList, $regDirs, $recursivityLevels - 1, $excludePattern); } } } return $fileArr; }
/** * Searching for filename pattern recursively in the specified dir. * * @param string Base directory * @param string Match pattern * @param array Array of matching files, passed by reference * @param integer Depth to recurse * @return array Array with various information about the search result * @see func_filesearch() */ function findFile($basedir, $pattern, &$matching_files, $depth) { $files_searched = 0; $dirs_searched = 0; $dirs_error = 0; // Traverse files: $files = t3lib_div::getFilesInDir($basedir, '', 1); if (is_array($files)) { $files_searched += count($files); foreach ($files as $value) { if (preg_match('/' . $pattern . '/i', basename($value))) { $matching_files[] = substr($value, strlen(PATH_site)); } } } // Traverse subdirs if ($depth > 0) { $dirs = t3lib_div::get_dirs($basedir); if (is_array($dirs)) { $dirs_searched += count($dirs); foreach ($dirs as $value) { $inf = $this->findFile($basedir . $value . '/', $pattern, $matching_files, $depth - 1); $dirs_searched += $inf[0]; $files_searched += $inf[1]; $dirs_error = $inf[2]; } } } else { $dirs = t3lib_div::get_dirs($basedir); if (is_array($dirs) && count($dirs)) { $dirs_error = 1; // Means error - there were further subdirs! } } return array($dirs_searched, $files_searched, $dirs_error); }
/** * Returns the login box image, whether the default or an image from the rotation folder. * * @return string HTML image tag. */ function makeLoginBoxImage() { $loginboxImage = ''; if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) { // Look for rotation image folder: $absPath = t3lib_div::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']); // Get rotation folder: $dir = t3lib_div::getFileAbsFileName($absPath); if ($dir && @is_dir($dir)) { // Get files for rotation into array: $files = t3lib_div::getFilesInDir($dir, 'png,jpg,gif'); // Pick random file: $randImg = array_rand($files, 1); // Get size of random file: $imgSize = @getimagesize($dir . $files[$randImg]); $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author']) && $GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : ''; // Create image tag: if (is_array($imgSize)) { $loginboxImage = '<img src="' . htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'] . $files[$randImg]) . '" ' . $imgSize[3] . ' id="loginbox-image" alt="' . $imgAuthor . '" title="' . $imgAuthor . '" />'; } } } else { // If no rotation folder configured, print default image: if (strstr(TYPO3_version, '-dev')) { // development version $loginImage = 'loginbox_image_dev.png'; $imagecopy = 'You are running a development version of TYPO3 ' . TYPO3_branch; } else { $loginImage = 'loginbox_image.jpg'; $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)'; } $loginboxImage = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/' . $loginImage, 'width="200" height="133"') . ' id="loginbox-image" alt="' . $imagecopy . '" title="' . $imagecopy . '" />'; } // Return image tag: return $loginboxImage; }
/** * 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 . ' </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 . ' </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; }
/** * Call handler class, merge results with skin data and cache it. * * @return void */ protected function rebuildCache() { // Generate CSS and TCA files, build icon set register $this->handler->generate(); // Get all icons registered from skins, merge with core icon list $availableSkinIcons = (array) $GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames']; foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinName => $skinData) { $availableSkinIcons = array_merge($availableSkinIcons, (array) $skinData['availableSpriteIcons']); } // Merge icon names provided by the skin, with // registered "complete sprites" and the handler class $this->iconNames = array_merge($availableSkinIcons, (array) $GLOBALS['TBE_STYLES']['spritemanager']['spriteIconsAvailable'], $this->handler->getAvailableIconNames()); // Create serialized cache data $cacheString = addslashes(serialize($this->iconNames)); $fileContent = '<?php $GLOBALS[\'TBE_STYLES\'][\'spriteIconApi\'][\'iconsAvailable\'] = unserialize(stripslashes(\'' . $cacheString . '\')); ?>'; // Clean up cache directory $oldFiles = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', TRUE); foreach ($oldFiles as $file) { @unlink($file); } // Write new cache file t3lib_div::writeFile($this->tempFileName, $fileContent); }
/** * Main Task center module * * @return string HTML content. */ function main() { if ($id = t3lib_div::_GP('display')) { return $this->urlInIframe($this->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id, 1); } else { // Thumbnail folder and files: $tempDir = $this->userTempFolder(); if ($tempDir) { $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1); } $clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $usernames = t3lib_BEfunc::getUserNames(); // Create preset links: $presets = $this->getPresets(); $opt = array(); $opt[] = ' <tr class="bgColor5 tableheader"> <td>Icon:</td> <td>Preset Title:</td> <td>Public</td> <td>Owner:</td> <td>Page:</td> <td>Path:</td> <td>Meta data:</td> </tr>'; if (is_array($presets)) { foreach ($presets as $presetCfg) { $configuration = unserialize($presetCfg['preset_data']); $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']]; $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']'; $opt[] = ' <tr class="bgColor4"> <td>' . ($thumbnailFile ? '<img src="' . $this->backPath . '../' . substr($tempDir, strlen(PATH_site)) . basename($thumbnailFile) . '" hspace="2" width="70" style="border: solid black 1px;" alt="" /><br />' : ' ') . '</td> <td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display=' . $presetCfg['uid'] . '">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 30)) . '</a> </td> <td>' . ($presetCfg['public'] ? 'Yes' : ' ') . '</td> <td>' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? 'Own' : '[' . $usernames[$presetCfg['user_uid']]['username'] . ']') . '</td> <td>' . ($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : ' ') . '</td> <td>' . htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20) : '[Single Records]') . '</td> <td> <strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />' . htmlspecialchars($configuration['meta']['description']) . ($configuration['meta']['notes'] ? '<br /><br /><strong>Notes:</strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>' : '') . ' </td> </tr>'; } $content = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">' . implode('', $opt) . '</table>'; } } // Output: $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section('Export presets', $content, 0, 1); return $theOutput; }
/** * Gets a single extension info * * @param $extKey * @param $path * @param $list * @param string $type * @return void */ public function singleExtInfo($extKey, $path, &$list, $type = '') { if (@is_file($path . $extKey . '/ext_emconf.php')) { $relPath = '../' . substr($path, strlen(PATH_site)); $directLink = 'mod.php?M=tools_em'; $emConf = tx_em_Tools::includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey); $manual = $path . $extKey . '/doc/manual.sxw'; $manualRelPath = $relPath . $extKey . '/doc/manual.sxw'; if ($type === '') { $type = tx_em_Tools::getExtTypeFromPath($path); } if (is_array($emConf)) { $key = count($list); $loaded = t3lib_extMgm::isLoaded($extKey); $exist = $this->findIndex($extKey, $list); if ($exist !== FALSE) { $key = $exist; $list[$key] = array('doubleInstall' => $list[$key]['doubleInstall'], 'doubleInstallShort' => $list[$key]['doubleInstallShort']); } $list[$key]['extkey'] = $extKey; $list[$key]['path'] = $path . $extKey; $list[$key]['nodePath'] = substr($path . $extKey, strlen(PATH_site)); $list[$key]['doubleInstall'] = $list[$key]['doubleInstall'] ? $list[$key]['doubleInstall'] . '/' . $this->types[$type] : $this->types[$type]; $list[$key]['doubleInstallShort'] .= $type; $list[$key] = t3lib_div::array_merge_recursive_overrule($list[$key], $emConf); if (@is_file($path . $extKey . '/class.ext_update.php')) { $list[$key]['updateModule'] = TRUE; } else { $list[$key]['updateModule'] = FALSE; } $list[$key]['type'] = $this->types[$type]; $list[$key]['typeShort'] = $type; $list[$key]['installed'] = $loaded ? 1 : 0; $state = htmlspecialchars($emConf['state']); $list[$key]['state'] = $this->states[$state]; $list[$key]['stateCls'] = 'state-' . $state; $list[$key]['title'] = htmlspecialchars($list[$key]['title']); $list[$key]['description'] = htmlspecialchars($list[$key]['description']); $list[$key]['author'] = htmlspecialchars($list[$key]['author']); $list[$key]['author_email'] = htmlspecialchars($list[$key]['author_email']); $list[$key]['files'] = t3lib_div::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging); $list[$key]['reviewstate'] = $this->xmlHandler->getReviewState($extKey, $list[$key]['version']); $list[$key]['download'] = '<a href="' . htmlspecialchars($directLink . '&CMD[doBackup]=1&SET[singleDetails]=backup&CMD[showExt]=' . $extKey) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-download') . '</a>'; $list[$key]['doc'] = ''; if ($list[$key]['docPath']) { $manual = $path . $extKey . '/' . $list[$key]['docPath'] . '/manual.sxw'; $manualRelPath = $relPath . $extKey . '/' . $list[$key]['docPath'] . '/manual.sxw'; } if (@is_file($manual)) { $list[$key]['doc'] = '<a href="' . htmlspecialchars($manualRelPath) . '" target="_blank">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-documentation') . '</a>'; } $list[$key]['icon'] = @is_file($path . $extKey . '/ext_icon.gif') ? '<img src="' . $relPath . $extKey . '/ext_icon.gif" alt="" height="16" />' : '<img src="clear.gif" alt="" width="16" height="16" />'; $list[$key]['categoryShort'] = $list[$key]['category']; $list[$key]['category'] = isset($this->categories[$list[$key]['category']]) ? $this->categories[$list[$key]['category']] : $list[$key]['category']; $list[$key]['required'] = t3lib_div::inList(t3lib_extMgm::getRequiredExtensionList(), $extKey); $constraints = $this->humanizeConstraints($list[$key]['constraints']); $list[$key]['depends'] = $constraints['depends']; $list[$key]['conflicts'] = $constraints['conflicts']; $list[$key]['suggests'] = $constraints['suggests']; unset($list[$key]['_md5_values_when_last_written']); } } }
/** * Import part of module * * @param array Content of POST VAR tx_impexp[].. * @return void Setting content in $this->content */ function importData($inData) { global $TCA, $LANG, $BE_USER; $access = is_array($this->pageinfo) ? 1 : 0; if ($this->id && $access || $BE_USER->user['admin'] && !$this->id) { if ($BE_USER->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } $import = t3lib_div::makeInstance('tx_impexp'); $import->init(0, 'import'); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: $menuItems = array(); // Make input selector: $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; // must have trailing slash. $filesInDir = t3lib_div::getFilesInDir(PATH_site . $path, 't3d,xml', 1, 1); $userPath = $this->userSaveFolder(); //Files from User-Dir $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInUserDir, $filesInDir); if (is_dir(PATH_site . $path . 'export/')) { $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1)); } $tempFolder = $this->userTempFolder(); if ($tempFolder) { $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInDir, $temp_filesInDir); } // Configuration $row = array(); $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ? '<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' /> <label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ? ' <hr/> <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' /> <label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em> ' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' /> <label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em> <br/><br/> ' . ($GLOBALS['BE_USER']->isAdmin() ? ' <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' /> <label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? ' <br/> <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' /> <label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/> <em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . ' </td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . (!$inData['import_file'] ? '<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ? ' - <input type="submit" value="' . ($inData['do_update'] ? $LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . ' <input type="hidden" name="tx_impexp[action]" value="import" /></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' /> <label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em> </td> </tr>'; $menuItems[] = array('label' => $LANG->getLL('importdata_import', 1), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Upload file: $tempFolder = $this->userTempFolder(); if ($tempFolder) { $row = array(); $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_browse', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="file" name="upload_1"' . $this->doc->formWidth(35) . ' size="40" /> <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" /> <input type="hidden" name="file[upload][1][data]" value="1" /><br /> <input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" /> <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label> </td> </tr>'; if (t3lib_div::_POST('_upload')) { $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td> <td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td> </tr>'; } $menuItems[] = array('label' => $LANG->getLL('importdata_upload'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); } // Perform import or preview depending: $overviewContent = ''; $extensionInstallationMessage = ''; $emURL = ''; $inFile = t3lib_div::getFileAbsFileName($inData['file']); if ($inFile && @is_file($inFile)) { $trow = array(); if ($import->loadFile($inFile, 1)) { // Check extension dependencies: $extKeysToInstall = array(); if (is_array($import->dat['header']['extensionDependencies'])) { foreach ($import->dat['header']['extensionDependencies'] as $extKey) { if (!t3lib_extMgm::isLoaded($extKey)) { $extKeysToInstall[] = $extKey; } } } if (count($extKeysToInstall)) { $passParams = t3lib_div::_POST('tx_impexp'); unset($passParams['import_mode']); unset($passParams['import_file']); $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id . t3lib_div::implodeArrayForUrl('tx_impexp', $passParams); $emURL = $this->doc->backPath . 'mod/tools/em/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl); $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.'; } if ($inData['import_file']) { if (!count($extKeysToInstall)) { $import->importData($this->id); t3lib_BEfunc::setUpdateSignal('updatePageTree'); } else { t3lib_utility_Http::redirect($emURL); } } $import->display_import_pid_record = $this->pageinfo; $overviewContent = $import->displayContentOverview(); } // Meta data output: $trow[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td> </tr>'; $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/> ' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td> </tr>'; // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension']; t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td> <td>' . $iconTag . '</td> </tr>'; } else { t3lib_div::unlink_tempfile($fileName); } } } $menuItems[] = array('label' => $LANG->getLL('importdata_metaData_1387'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $trow) . ' </table> '); } // Print errors that might be: $errors = $import->printErrorLog(); $menuItems[] = array('label' => $LANG->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Output tabs: $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_import', -1); if ($extensionInstallationMessage) { $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content; } $this->content .= $this->doc->section('', $content, 0, 1); // Print overview: if ($overviewContent) { $this->content .= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1); } } }
/** * Loads all StyleSheets Files registered through * t3lib_SpriteManager::::addIconSprite * * In fact the stylesheet-files are copied to t3lib_SpriteManager::tempPath * where they automatically will be included from via template.php and * t3lib_compressor. * * @return void */ protected function loadRegisteredSprites() { // saves which CSS Files are currently "allowed to be in place" $allowedCssFilesinTempDir = array(basename($this->cssTcaFile)); // process every registeres file foreach ((array) $GLOBALS['TBE_STYLES']['spritemanager']['cssFiles'] as $file) { $fileName = basename($file); // file should be present $allowedCssFilesinTempDir[] = $fileName; // get-Cache Filename $unique = md5($fileName . filemtime(PATH_site . $file) . filesize(PATH_site . $file)); $cacheFile = PATH_site . t3lib_SpriteManager::$tempPath . $fileName . $unique . '.css'; if (!file_exists($cacheFile)) { copy(PATH_site . $file, $cacheFile); } } // get all .css files in dir $cssFilesPresentInTempDir = t3lib_div::getFilesInDir(PATH_site . t3lib_SpriteManager::$tempPath, '.css', 0); // and delete old ones which are not needed anymore $filesToDelete = array_diff($cssFilesPresentInTempDir, $allowedCssFilesinTempDir); foreach ($filesToDelete as $file) { unlink(PATH_site . t3lib_SpriteManager::$tempPath . $file); } }
/** * unlink compiled files which have no equal source less-file * Only for mode "PHP-Compiler" */ protected function unlinkGeneratedFilesWithNoSourceFile( $sourceFiles ) { // all available sourcefiles //$sourceFiles = t3lib_div::getFilesInDir($this->lessfolder, "less"); // build array with md5 values from sourcefiles $srcArr = array( ); foreach( $sourceFiles as $file ) { $filename = array_pop( explode( '/', $file ) ); $md5 = md5( $filename . md5_file( $file ) ); $srcArr[] .= $md5; } // unlink every css file, which have no equal less-file // checked by comparing md5-string from filename with md5_file(sourcefile) foreach( t3lib_div::getFilesInDir( $this->outputfolder, "css" ) as $cssFile ) { $md5str = substr( substr( $cssFile, 0, -4 ), -32 ); if( !in_array( $md5str, $srcArr ) ) { unlink( $this->outputfolder . $cssFile ); } } }
/** * Removes TinyMCE gzip cache files and TYPO3 cache files. * * @return void */ function removeCachedFiles() { $path = PATH_site . 'typo3temp/tinymce_rte/'; if (is_dir($path)) { // Remove TinyMCE gzip cache files. $cfiles = t3lib_div::getFilesInDir($path); foreach ($cfiles as $cfile) { if (preg_match('/tiny_mce_\\w{32}\\.gz/', $cfile)) { @unlink($path . $cfile); } } } // Remove TYPO3 cache files. t3lib_extMgm::removeCacheFiles(); }
/** * Returns an array with all files and folders in $extPath * * @param array $fileArr * @param string $extPath * @return array Array with files and folders * @access private */ function getAllFilesAndFoldersInPath($fileArr, $extPath) { $extList = ''; $fileArr[] = $extPath; $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($extPath, $extList, 1, 1)); $dirs = t3lib_div::get_dirs($extPath); if (is_array($dirs)) { reset($dirs); while (list(, $subdirs) = each($dirs)) { if ($subdirs) { $fileArr = $this->getAllFilesAndFoldersInPath($fileArr, $extPath . $subdirs . '/'); } } } return $fileArr; }
/** * Gathers all extensions in $path * * @param string Absolute path to local, global or system extensions * @param array Array with information for each extension key found. Notice: passed by reference * @param array Categories index: Contains extension titles grouped by various criteria. * @param string Path-type: L, G or S * @return void "Returns" content by reference * @access private * @see getInstalledExtensions() */ function getInstExtList($path, &$list, &$cat, $type) { if (@is_dir($path)) { $extList = t3lib_div::get_dirs($path); if (is_array($extList)) { foreach ($extList as $extKey) { if (@is_file($path . $extKey . '/ext_emconf.php')) { $emConf = $this->includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey); if (is_array($emConf)) { if (is_array($list[$extKey])) { $list[$extKey] = array('doubleInstall' => $list[$extKey]['doubleInstall']); } $list[$extKey]['doubleInstall'] .= $type; $list[$extKey]['type'] = $type; $list[$extKey]['EM_CONF'] = $emConf; $list[$extKey]['files'] = t3lib_div::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging); $this->setCat($cat, $list[$extKey], $extKey); } } } } } }
/** * Unlink (delete) cache files - ALL, including those not current, made by another sitepath. * * @return string Status Message */ function removeALLtempCachedFiles() { $path = PATH_typo3conf; if (is_dir($path)) { $filesInDir = t3lib_div::getFilesInDir($path, 'php', 1); reset($filesInDir); while (list($kk, $vv) = each($filesInDir)) { if (t3lib_div::isFirstPartOfStr(basename($vv), 'temp_CACHED_')) { if (strstr(basename($vv), 'ext_localconf.php') || strstr(basename($vv), 'ext_tables.php')) { $content .= 'REMOVED: ' . $vv . '<br />'; unlink($vv); if (file_exists($vv)) { $content .= '<strong><font color="red">ERROR: File still exists, so could not be removed anyways!</font></strong><br />'; } } } } } return $content; }
/** * Renders the template selector. * * @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page. * @param string $templateType: The template type, 'tmplobj' or 't3d' * @return string HTML output containing a table with the template selector */ function renderTemplateSelector($positionPid, $templateType = 'tmplobj') { global $LANG, $TYPO3_DB; $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid); $tmplHTML = array(); $defaultIcon = $this->doc->backPath . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif'; // look for TCEFORM.pages.tx_templavoila_ds.removeItems / TCEFORM.pages.tx_templavoila_to.removeItems $disallowedPageTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_ds'); $disallowedDesignTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_to'); switch ($templateType) { case 'tmplobj': // Create the "Default template" entry //Fetch Default TO $fakeRow = array('uid' => abs($positionPid)); $defaultTO = $this->pObj->apiObj->getContentTree_fetchPageTemplateObject($fakeRow); // Create the "Default template" entry if ($defaultTO['previewicon']) { $previewIconFilename = @is_file(PATH_site . 'uploads/tx_templavoila/' . $defaultTO['previewicon']) ? $GLOBALS['BACK_PATH'] . '../' . 'uploads/tx_templavoila/' . $defaultTO['previewicon'] : $defaultIcon; } else { $previewIconFilename = $defaultIcon; } $previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />'; $description = $defaultTO['description'] ? htmlspecialchars($defaultTO['description']) : $LANG->getLL('template_descriptiondefault', 1); $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"> <tr> <td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titleInherit')) . '</h3> </td> </tr><tr> <td valign="top">' . $previewIcon . '</td> <td width="120" valign="top"> <p><h4>' . htmlspecialchars($LANG->sL($defaultTO['title'])) . '</h4>' . $LANG->sL($description) . '</p> </td> </tr> </table>'; $dsRepo = t3lib_div::makeInstance('tx_templavoila_datastructureRepository'); $toRepo = t3lib_div::makeInstance('tx_templavoila_templateRepository'); $dsList = $dsRepo->getDatastructuresByStoragePidAndScope($storageFolderPID, tx_templavoila_datastructure::SCOPE_PAGE); foreach ($dsList as $dsObj) { if (t3lib_div::inList($disallowedPageTemplateItems, $dsObj->getKey()) || !$dsObj->isPermittedForUser()) { continue; } $toList = $toRepo->getTemplatesByDatastructure($dsObj, $storageFolderPID); foreach ($toList as $toObj) { if ($toObj->getKey() === $defaultTO['uid'] || !$toObj->isPermittedForUser() || t3lib_div::inList($disallowedDesignTemplateItems, $toObj->getKey())) { continue; } $tmpFilename = $toObj->getIcon(); $previewIconFilename = @is_file(PATH_site . substr($tmpFilename, 3)) ? $GLOBALS['BACK_PATH'] . $tmpFilename : $defaultIcon; // Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376 $previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $toObj->getKey() . '" src="' . $previewIconFilename . '" title="" />'; $description = $toObj->getDescription() ? htmlspecialchars($toObj->getDescription()) : $LANG->getLL('template_nodescriptionavailable'); $tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($toObj->getLabel()) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $LANG->sL($description) . '</p></td></tr></table>'; } } $tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />'; break; case 't3d': if (t3lib_extMgm::isLoaded('impexp')) { // Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests. $templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/'; $files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1); // Traverse the files found: foreach ($files as $absPath) { // Initialize the import object: $import = $this->getImportObject(); if ($import->loadFile($absPath)) { if (is_array($import->dat['header']['pagetree'])) { // This means there are pages in the file, we like that...: // Page tree: reset($import->dat['header']['pagetree']); $pageTree = current($import->dat['header']['pagetree']); // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension']; t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; } else { t3lib_div::unlink_tempfile($fileName); $iconTag = ''; } } } $aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">'; $aTagE = '</a>'; $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr> <tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p> <em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/> File: ' . basename($absPath) . '</em></td></tr></table>'; } } } } break; } if (is_array($tmplHTML) && count($tmplHTML)) { $counter = 0; $content .= '<table>'; foreach ($tmplHTML as $single) { $content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : ''); $counter++; if ($counter > 1) { $counter = 0; } } $content .= '</table>'; } return $content; }