/** * Initializes the identifier prefix when setting the cache. * * @param t3lib_cache_frontend_Frontend $cache The frontend for this backend * @return void * @author Robert Lemke <*****@*****.**> */ public function setCache(t3lib_cache_frontend_Frontend $cache) { parent::setCache($cache); $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default'); $pathHash = t3lib_div::shortMD5(PATH_site . $processUser['name'], 12); $this->identifierPrefix = 'TYPO3_' . $pathHash; }
/** * @param $str * @param $table * @param string $uid * @return string */ private function wrapClickMenuOnIcon($str, $table, $uid = '') { $listFr = 1; $addParams = ''; $enDisItems = ''; $returnOnClick = FALSE; $backPath = rawurlencode($GLOBALS['BACK_PATH']) . '|' . t3lib_div::shortMD5($GLOBALS['BACK_PATH'] . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']); $onClick = 'showClickmenu("' . $table . '","' . $uid . '","' . $listFr . '","' . str_replace('+', '%2B', $enDisItems) . '","' . str_replace('&', '&', addcslashes($backPath, '"')) . '","' . str_replace('&', '&', addcslashes($addParams, '"')) . '");return false;'; return $returnOnClick ? $onClick : '<a href="#" onclick="' . htmlspecialchars($onClick) . '" oncontextmenu="' . htmlspecialchars($onClick) . '">' . $str . '</a>'; }
function getCacheID($cache_id = null) { // If caching is disabled in TYPO3 make sure it's disabled in Smarty as well if ($GLOBALS['TSFE']->no_cache || t3lib_div::_GP('no_cache')) { $this->caching = false; return; // Exit here } // If cHash is set, use it for the cache_id if (t3lib_div::_GP('cHash')) { return t3lib_div::_GP('cHash'); } // Otherwise create a unique cache_id from POST/GET vars // TODO: Observe how well Smarty caching works in the context of TYPO3. Disabling caching is generally recommended... return $cache_id ? $cache_id : t3lib_div::shortMD5(serialize(array_merge(t3lib_div::_GET(), t3lib_div::_POST()))); }
/** * Render list of files. * * @param array List of files. See t3lib_div::getFilesInDir * @param string If set a header with a folder icon and folder name are shown * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown. * @return string HTML output */ function fileList($files, $folderName = '', $noThumbs = 0) { global $LANG, $BACK_PATH; $out = ''; // Listing the files: if (is_array($files)) { // Create headline (showing number of files): $filesCount = count($files); $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', $filesCount)); $out .= $this->getBulkSelector($filesCount); $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); // Create the header of current folder: if ($folderName) { $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($folderName), $titleLen)); $out .= $picon . '<br />'; } // Init graphic object for reading file dimensions: $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic'); $imgObj->init(); $imgObj->mayScaleUp = 0; $imgObj->tempPath = PATH_site . $imgObj->tempPath; // Traverse the file list: $lines = array(); foreach ($files as $filepath) { $fI = pathinfo($filepath); // Thumbnail/size generation: if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fI['extension'])) && !$noThumbs) { $imgInfo = $imgObj->getImageDimensions($filepath); $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels'; $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH . 'thumbs.php', $filepath, 'hspace="5" vspace="5" border="1"'); } else { $clickIcon = ''; $pDim = ''; } // Create file icon: $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"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" class="absmiddle" alt="" />'; // Create links for adding the file: if (strstr($filepath, ',') || strstr($filepath, '|')) { // In case an invalid character is in the filepath, display error message: $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |')); $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(" . $eMsg . ");return false;\">"; $bulkCheckBox = ''; } else { // If filename is OK, just add it: $filesIndex = count($this->elements); $this->elements['file_' . $filesIndex] = array('md5' => t3lib_div::shortMD5($filepath), 'type' => 'file', 'fileName' => $fI['basename'], 'filePath' => $filepath, 'fileExt' => $fI['extension'], 'fileIcon' => $ficon); $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_{$filesIndex}');\">"; $ATag_alt = substr($ATag, 0, -4) . ",1);\">"; $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> '; } $ATag_e = '</a>'; // Create link to showing details about the file in a window: $Ahref = $BACK_PATH . 'show_item.php?table=' . rawurlencode($filepath) . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')); $ATag2 = '<a href="' . htmlspecialchars($Ahref) . '">'; $ATag2_e = '</a>'; // Combine the stuff: $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath), $titleLen)) . $ATag_e; // Show element: if ($pDim) { // Image... $lines[] = ' <tr class="bgColor4"> <td nowrap="nowrap">' . $filenameAndIcon . ' </td> <td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td> <td nowrap="nowrap">' . ($ATag2 . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $LANG->getLL('info', 1) . '" alt="" /> ' . $LANG->getLL('info', 1) . $ATag2_e) . '</td> <td nowrap="nowrap"> ' . $pDim . '</td> </tr>'; $lines[] = ' <tr> <td colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td> </tr>'; } else { $lines[] = ' <tr class="bgColor4"> <td nowrap="nowrap">' . $filenameAndIcon . ' </td> <td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td> <td nowrap="nowrap">' . ($ATag2 . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $LANG->getLL('info', 1) . '" alt="" /> ' . $LANG->getLL('info', 1) . $ATag2_e) . '</td> <td> </td> </tr>'; } $lines[] = ' <tr> <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td> </tr>'; } // Wrap all the rows in table tags: $out .= ' <!-- File listing --> <table cellpadding="0" cellspacing="0" id="typo3-fileList"> ' . implode('', $lines) . ' </table>'; } // Return accumulated content for filelisting: return $out; }
/** * @param string $input Input string to be md5-hashed * @param int $len The string-length of the output * @return string Substring of the resulting md5-hash, being $len chars long (from beginning) */ public function shortMD5($input, $len = 10) { /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */ return t3lib_div::shortMD5($input, $len); }
/** * 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> </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"> </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"> </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); }
/** * Calculates the cHash value of input GET array (for constructing cHash values if needed) * * @param array Array of GET parameters to encode * @return void * @deprecated since TYPO3 4.3, this function will be removed in TYPO3 4.6, use directly t3lib_div::calculateCHash() */ function makeCHash($paramArray) { t3lib_div::logDeprecatedFunction(); $addQueryParams = t3lib_div::implodeArrayForUrl('', $paramArray); $pA = t3lib_div::cHashParams($addQueryParams); return t3lib_div::shortMD5(serialize($pA)); }
/** * Render list of files. * * @param array List of folder. See $this->getFolderInDir() * @param string If set a header with a folder icon and folder name are shown * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown. * @return string HTML output */ function folderList($folder, $folderName = '', $noThumbs = 0) { global $LANG, $BACK_PATH; $out = ''; // Listing the files: if (is_array($folder)) { // Create headline (showing number of files): $out .= $this->barheader(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:file_newfolder.php.folders') . ' (%s):', count($folder))); $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); $folderIcon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"'); // todo: use modes? # $fileadminDir = PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; $fcount = count($folder); $folder = array_merge(array(md5($folderName) => $folderName), $folder); // Traverse the file list: $lines = array(); foreach ($folder as $filepath) { $path_parts = t3lib_div::split_fileref($filepath); # $shortFilepath = preg_replace('#^'.preg_quote($fileadminDir).'#','', $filepath); $shortFilepath = preg_replace('#^' . preg_quote(PATH_site) . '#', '', $filepath); if (count($lines) == 0) { $treeLine = ''; } elseif (count($lines) < $fcount) { $LN = 'join'; $treeLine = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' alt="" />'; } else { $LN = 'joinbottom'; $treeLine = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' alt="" />'; } // Create folder icon: $icon = $folderIcon . ' title="' . htmlspecialchars($path_parts['file']) . '" class="absmiddle" alt="" />'; // Create links for adding the file: if (strstr($filepath, ',') || strstr($filepath, '|')) { // In case an invalid character is in the filepath, display error message: $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |')); $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(" . $eMsg . ");return false;\">"; } else { // If filename is OK, just add it: $ATag = "<a href=\"#\" onclick=\"return insertElement('','" . t3lib_div::shortMD5($filepath) . "', 'file', '" . rawurlencode($shortFilepath) . "', unescape('" . rawurlencode($shortFilepath) . "'), '" . '' . "', '" . '' . "');\">"; $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">"; } $ATag_e = '</a>'; // Combine the stuff: $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs($path_parts['file'], $titleLen)) . $ATag_e; $lines[] = ' <tr class="bgColor4"> <td nowrap="nowrap">' . $treeLine . $filenameAndIcon . ' </td> <td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td> </tr>'; } // Wrap all the rows in table tags: $out .= ' <!-- File listing --> <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList"> ' . implode('', $lines) . ' </table>'; } // Return accumulated content for filelisting: return $out; }
/** * Transformation handler: 'ts_images' / direction: "db" * Processing images inserted in the RTE. * This is used when content goes from the RTE to the database. * Images inserted in the RTE has an absolute URL applied to the src attribute. This URL is converted to a relative URL * If it turns out that the URL is from another website than the current the image is read from that external URL and moved to the local server. * Also "magic" images are processed here. * * @param string The content from RTE going to Database * @return string Processed content */ function TS_images_db($value) { // Split content by <img> tags and traverse the resulting array for processing: $imgSplit = $this->splitTags('img', $value); foreach ($imgSplit as $k => $v) { if ($k % 2) { // image found, do processing: // Init $attribArray = $this->get_tag_attributes_classic($v, 1); $siteUrl = $this->siteUrl(); $sitePath = str_replace(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl); $absRef = trim($attribArray['src']); // It's always a absolute URL coming from the RTE into the Database. // make path absolute if it is relative and we have a site path wich is not '/' $pI = pathinfo($absRef); if ($sitePath and !$pI['scheme'] && t3lib_div::isFirstPartOfStr($absRef, $sitePath)) { // if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl $absRef = substr($absRef, strlen($sitePath)); $absRef = $siteUrl . $absRef; } // External image from another URL? In that case, fetch image (unless disabled feature). if (!t3lib_div::isFirstPartOfStr($absRef, $siteUrl) && !$this->procOptions['dontFetchExtPictures']) { $externalFile = $this->getUrl($absRef); // Get it if ($externalFile) { $pU = parse_url($absRef); $pI = pathinfo($pU['path']); if (t3lib_div::inList('gif,png,jpeg,jpg', strtolower($pI['extension']))) { $filename = t3lib_div::shortMD5($absRef) . '.' . $pI['extension']; $origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename; $C_origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension']; if (!@is_file($origFilePath)) { t3lib_div::writeFile($origFilePath, $externalFile); t3lib_div::writeFile($C_origFilePath, $externalFile); } $absRef = $siteUrl . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension']; $attribArray['src'] = $absRef; $params = t3lib_div::implodeAttributes($attribArray, 1); $imgSplit[$k] = '<img ' . $params . ' />'; } } } // Check image as local file (siteURL equals the one of the image) if (strpos($absRef, 'http://') === FALSE and strpos($absRef, 'https://') === FALSE and strpos($absRef, 'ftp://') === FALSE) { //XCLASS changed from: if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) { $path = rawurldecode(substr($absRef, strlen($siteUrl))); // Rel-path, rawurldecoded for special characters. $path = $absRef; //XCLASS added $filepath = t3lib_div::getFileAbsFileName($path); // Abs filepath, locked to relative path of this project. // Check file existence (in relative dir to this installation!) if ($filepath && @is_file($filepath)) { // If "magic image": $pathPre = $this->rteImageStorageDir() . 'RTEmagicC_'; if (t3lib_div::isFirstPartOfStr($path, $pathPre)) { // Find original file: $pI = pathinfo(substr($path, strlen($pathPre))); $filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension'])); $origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename; if (@is_file($origFilePath)) { $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic'); $imgObj->init(); $imgObj->mayScaleUp = 0; $imgObj->tempPath = PATH_site . $imgObj->tempPath; $curInfo = $imgObj->getImageDimensions($filepath); // Image dimensions of the current image $curWH = $this->getWHFromAttribs($attribArray); // Image dimensions as set in the image tag // Compare dimensions: if ($curWH[0] != $curInfo[0] || $curWH[1] != $curInfo[1]) { $origImgInfo = $imgObj->getImageDimensions($origFilePath); // Image dimensions of the current image $cW = $curWH[0]; $cH = $curWH[1]; $cH = 1000; // Make the image based on the width solely... $imgI = $imgObj->imageMagickConvert($origFilePath, $pI['extension'], $cW . 'm', $cH . 'm'); if ($imgI[3]) { $fI = pathinfo($imgI[3]); @copy($imgI[3], $filepath); // Override the child file // Removing width and heigth form style attribute $attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']); $attribArray['width'] = $imgI[0]; $attribArray['height'] = $imgI[1]; $params = t3lib_div::implodeAttributes($attribArray, 1); $imgSplit[$k] = '<img ' . $params . ' />'; } } } } elseif ($this->procOptions['plainImageMode']) { // If "plain image" has been configured: // Image dimensions as set in the image tag, if any $curWH = $this->getWHFromAttribs($attribArray); if ($curWH[0]) { $attribArray['width'] = $curWH[0]; } if ($curWH[1]) { $attribArray['height'] = $curWH[1]; } // Removing width and heigth form style attribute $attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']); // Finding dimensions of image file: $fI = @getimagesize($filepath); // Perform corrections to aspect ratio based on configuration: switch ((string) $this->procOptions['plainImageMode']) { case 'lockDimensions': $attribArray['width'] = $fI[0]; $attribArray['height'] = $fI[1]; break; case 'lockRatioWhenSmaller': // If the ratio has to be smaller, then first set the width...: if ($attribArray['width'] > $fI[0]) { $attribArray['width'] = $fI[0]; } case 'lockRatio': if ($fI[0] > 0) { $attribArray['height'] = round($attribArray['width'] * ($fI[1] / $fI[0])); } break; } // Compile the image tag again: $params = t3lib_div::implodeAttributes($attribArray, 1); $imgSplit[$k] = '<img ' . $params . ' />'; } } else { // Remove image if it was not found in a proper position on the server! // Commented out; removing the image tag might not be that logical... #$imgSplit[$k]=''; } } // Convert abs to rel url if ($imgSplit[$k]) { $attribArray = $this->get_tag_attributes_classic($imgSplit[$k], 1); $absRef = trim($attribArray['src']); if (t3lib_div::isFirstPartOfStr($absRef, $siteUrl)) { $attribArray['src'] = $this->relBackPath . substr($absRef, strlen($siteUrl)); if (!isset($attribArray['alt'])) { $attribArray['alt'] = ''; } // Must have alt-attribute for XHTML compliance. $imgSplit[$k] = '<img ' . t3lib_div::implodeAttributes($attribArray, 1, 1) . ' />'; } } } } return implode('', $imgSplit); }
/** * Store the setfixed vars and return a replacement hash */ public function storeFixedPiVars($vars) { // Create a unique hash value if (class_exists('t3lib_cacheHash')) { $cacheHash = t3lib_div::makeInstance('t3lib_cacheHash'); $regHash_calc = $cacheHash->calculateCacheHash($vars); $regHash_calc = substr($regHash_calc, 0, 20); } else { // t3lib_div::cHashParams is deprecated in TYPO3 4.7 $regHash_array = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('', $vars)); $regHash_calc = t3lib_div::shortMD5(serialize($regHash_array), 20); } // and store it with a serialized version of the array in the DB $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($regHash_calc, 'cache_md5params')); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $insertFields = array('md5hash' => $regHash_calc, 'tstamp' => time(), 'type' => 99, 'params' => serialize($vars)); $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields); } $GLOBALS['TYPO3_DB']->sql_free_result($res); return $regHash_calc; }
/** * Creates a visual response to the TemplaVoila blocks on the page. * * @param [type] $content: ... * @param [type] $srcPointer: ... * @param [type] $DSrec: ... * @param [type] $TOrec: ... * @param [type] $row: ... * @param [type] $table: ... * @return [type] ... */ function visualID($content,$srcPointer,$DSrec,$TOrec,$row,$table) { // Create table rows: $tRows = array(); switch ($table) { case 'pages': $tRows[] = '<tr style="background-color: #ABBBB4;"> <td colspan="2"><b>Page:</b> '.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],30)).' <em>[UID:'.$row['uid'].']</em></td> </tr>'; break; case 'tt_content': $tRows[] = '<tr style="background-color: #ABBBB4;"> <td colspan="2"><b>Flexible Content:</b> '.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],30)).' <em>[UID:'.$row['uid'].']</em></td> </tr>'; break; default: $tRows[] = '<tr style="background-color: #ABBBB4;"> <td colspan="2">Table "'.$table.'" <em>[UID:'.$row['uid'].']</em></td> </tr>'; break; } // Draw data structure: if (is_numeric($srcPointer)) { $tRows[] = '<tr> <td valign="top"><b>Data Structure:</b></td> <td>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($DSrec['title'],30)).' <em>[UID:'.$srcPointer.']</em>'. ($DSrec['previewicon'] ? '<br/><img src="uploads/tx_templavoila/'.$DSrec['previewicon'].'" alt="" />' : ''). '</td> </tr>'; } else { $tRows[] = '<tr> <td valign="top"><b>Data Structure:</b></td> <td>'.htmlspecialchars($srcPointer).'</td> </tr>'; } // Template Object: $tRows[] = '<tr> <td valign="top"><b>Template Object:</b></td> <td>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($TOrec['title'],30)).' <em>[UID:'.$TOrec['uid'].']</em>'. ($TOrec['previewicon'] ? '<br/><img src="uploads/tx_templavoila/'.$TOrec['previewicon'].'" alt="" />' : ''). '</td> </tr>'; if ($TOrec['description']) { $tRows[] = '<tr> <td valign="top" nowrap="nowrap"> Description:</td> <td>'.htmlspecialchars($TOrec['description']).'</td> </tr>'; } $tRows[] = '<tr> <td valign="top" nowrap="nowrap"> Template File:</td> <td>'.htmlspecialchars($TOrec['fileref']).'</td> </tr>'; $tRows[] = '<tr> <td valign="top" nowrap="nowrap"> Render type:</td> <td>'.htmlspecialchars($TOrec['rendertype'] ? $TOrec['rendertype'] : 'Normal').'</td> </tr>'; $tRows[] = '<tr> <td valign="top" nowrap="nowrap"> Language:</td> <td>'.htmlspecialchars($TOrec['sys_language_uid'] ? $TOrec['sys_language_uid'] : 'Default').'</td> </tr>'; $tRows[] = '<tr> <td valign="top" nowrap="nowrap"> Local Proc.:</td> <td>'.htmlspecialchars($TOrec['localprocessing'] ? 'Yes' : '-').'</td> </tr>'; // Compile information table: $infoArray = '<table style="border:1px solid black; background-color: #D9D5C9; font-family: verdana,arial; font-size: 10px;" border="0" cellspacing="1" cellpadding="1"> '.implode('',$tRows).' </table>'; // Compile information: $id = 'templavoila-preview-'.t3lib_div::shortMD5(microtime()); $content = '<div style="text-align: left; position: absolute; display:none; filter: alpha(Opacity=90);" id="'.$id.'"> '.$infoArray.' </div> <div id="'.$id.'-wrapper" style="" onmouseover=" document.getElementById(\''.$id.'\').style.display=\'block\'; document.getElementById(\''.$id.'-wrapper\').attributes.getNamedItem(\'style\').nodeValue = \'border: 2px dashed #333366;\'; " onmouseout=" document.getElementById(\''.$id.'\').style.display=\'none\'; document.getElementById(\''.$id.'-wrapper\').attributes.getNamedItem(\'style\').nodeValue = \'\'; ">'. $content. '</div>'; return $content ; }
/** * Sends a header "Location" to jumpUrl, if jumpurl is set. * Will exit if a location header is sent (for instance if jumpUrl was triggered) * * "jumpUrl" is a concept where external links are redirected from the index_ts.php script, which first logs the URL. * This feature is only interesting if config.sys_stat is used. * * @return void */ function jumpUrl() { if ($this->jumpurl) { if (t3lib_div::_GP('juSecure')) { $hArr = array($this->jumpurl, t3lib_div::_GP('locationData'), $this->TYPO3_CONF_VARS['SYS']['encryptionKey']); $calcJuHash = t3lib_div::shortMD5(serialize($hArr)); $locationData = t3lib_div::_GP('locationData'); $juHash = t3lib_div::_GP('juHash'); if ($juHash == $calcJuHash) { if ($this->locDataCheck($locationData)) { $this->jumpurl = rawurldecode($this->jumpurl); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed. // Deny access to files that match TYPO3_CONF_VARS[SYS][fileDenyPattern] and whose parent directory is typo3conf/ (there could be a backup file in typo3conf/ which does not match against the fileDenyPattern) if (t3lib_div::verifyFilenameAgainstDenyPattern($this->jumpurl) && basename(dirname($this->jumpurl)) !== 'typo3conf') { if (@is_file($this->jumpurl)) { $mimeType = t3lib_div::_GP('mimeType'); $mimeType = $mimeType ? $mimeType : 'application/octet-stream'; header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: ' . $mimeType); header('Content-Disposition: attachment; filename=' . basename($this->jumpurl)); readfile($this->jumpurl); exit; } else { die('jumpurl Secure: "' . $this->jumpurl . '" was not a valid file!'); } } else { die('jumpurl Secure: The requested file type was not allowed to be accessed through jumpUrl (fileDenyPattern)!'); } } else { die('jumpurl Secure: locationData, ' . $locationData . ', was not accessible.'); } } else { die('jumpurl Secure: Calculated juHash did not match the submitted juHash.'); } } else { $TSConf = $this->getPagesTSconfig(); if ($TSConf['TSFE.']['jumpUrl_transferSession']) { $uParts = parse_url($this->jumpurl); $params = '&FE_SESSION_KEY=' . rawurlencode($this->fe_user->id . '-' . md5($this->fe_user->id . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey'])); $this->jumpurl .= ($uParts['query'] ? '' : '?') . $params; // Add the session parameter ... } if ($TSConf['TSFE.']['jumpURL_HTTPStatusCode']) { switch (intval($TSConf['TSFE.']['jumpURL_HTTPStatusCode'])) { case 301: $statusCode = t3lib_utility_Http::HTTP_STATUS_301; break; case 302: $statusCode = t3lib_utility_Http::HTTP_STATUS_302; break; case 307: $statusCode = t3lib_utility_Http::HTTP_STATUS_307; break; case 303: default: $statusCode = t3lib_utility_Http::HTTP_STATUS_303; break; } } t3lib_utility_Http::redirect($this->jumpurl, $statusCode); } } }
/** * Checks whether a given string is a valid cHash. * If the hash is valid it will be returned as is, an empty string will be * returned otherwise. * * @param string The cHash to check for validity * @return string The passed cHash if valid, an empty string if invalid * @see tslib_fe->makeCacheHash */ protected function filterInvalidContentHash($cHash) { $urlParameters = t3lib_div::_GET(); $cHashParameters = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('', $urlParameters)); if (SOLR_COMPAT) { $calculatedCHash = t3lib_div::shortMD5(serialize($cHashParameters)); } else { $calculatedCHash = t3lib_div::calculateCHash($cHashParameters); } return $calculatedCHash == $cHash ? $cHash : ''; }
/** * Processing of the storage command LOAD, SAVE, REMOVE * * @param string Name of the module to store the settings for. Default: $GLOBALS['SOBE']->MCONF['name'] (current module) * @return string Storage message. Also set in $this->msg */ function processStoreControl($mconfName = '') { $this->initStorage(); $storeControl = t3lib_div::_GP('storeControl'); $storeIndex = $storeControl['STORE']; $msg = ''; $saveSettings = FALSE; $writeArray = array(); if (is_array($storeControl)) { if ($this->writeDevLog) { t3lib_div::devLog('Store command: ' . t3lib_div::arrayToLogString($storeControl), 't3lib_modSettings', 0); } // // processing LOAD // if ($storeControl['LOAD'] and $storeIndex) { $writeArray = $this->getStoredData($storeIndex, $writeArray); $saveSettings = TRUE; $msg = "'" . $this->storedSettings[$storeIndex]['title'] . "' preset loaded!"; // // processing SAVE // } elseif ($storeControl['SAVE']) { if (trim($storeControl['title'])) { // get the data to store $newEntry = $this->compileEntry($storeControl); // create an index for the storage array if (!$storeIndex) { $storeIndex = t3lib_div::shortMD5($newEntry['title']); } // add data to the storage array $this->storedSettings[$storeIndex] = $newEntry; $saveSettings = TRUE; $msg = "'" . $newEntry['title'] . "' preset saved!"; } else { $msg = 'Please enter a name for the preset!'; } // // processing REMOVE // } elseif ($storeControl['REMOVE'] and $storeIndex) { // Removing entry $msg = "'" . $this->storedSettings[$storeIndex]['title'] . "' preset entry removed!"; unset($this->storedSettings[$storeIndex]); $saveSettings = TRUE; } $this->msg = $msg; if ($saveSettings) { $this->writeStoredSetting($writeArray, $mconfName); } } return $this->msg; }
/** * Returns single image tag to thumbnail using a thumbnail script (like thumbs.php) * Usage: 3 * * @param string $thumbScript must point to "thumbs.php" relative to the script position * @param string $theFile must be the proper reference to the file thumbs.php should show * @param string $tparams are additional attributes for the image tag * @param integer $size is the size of the thumbnail send along to "thumbs.php" * @return string Image tag */ public static function getThumbNail($thumbScript, $theFile, $tparams = '', $size = '') { $check = basename($theFile) . ':' . filemtime($theFile) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; $params = '&file=' . rawurlencode($theFile); $params .= trim($size) ? '&size=' . trim($size) : ''; $params .= '&md5sum=' . t3lib_div::shortMD5($check); $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params; $th = '<img src="' . htmlspecialchars($url) . '" title="' . trim(basename($theFile)) . '"' . ($tparams ? " " . $tparams : "") . ' alt="" />'; return $th; }
/** * 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 .= ' <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)); }
function getNewsCountForCategory($catID) { $sum = false; if (isset($this->categoryCountCache[$catID])) { $sum = $this->categoryCountCache[$catID]; } if ($sum !== false) { // t3lib_div::devLog('CACHE HIT (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', - 1, array()); } else { if ($this->tt_news_obj->cache_categoryCount) { $hash = t3lib_div::shortMD5(serialize($catID . $this->newsSelConf['pidInList'] . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields . $this->clause), 30); $sum = $this->tt_news_obj->cache->get($hash); } if ($sum === false) { if ($this->tt_news_obj->writeCachingInfoToDevlog) { t3lib_div::devLog('CACHE MISS (single count) (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', 2, array()); } $result = array(); $result['sum'] = 0; $news_clause = ''; if (is_object($this->tt_news_obj)) { $news_clause .= ' AND ' . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields; if ($this->newsSelConf['pidInList']) { $news_clause .= ' AND tt_news.pid IN (' . $this->newsSelConf['pidInList'] . ') '; } } tx_ttnews_div::getNewsCountForSubcategory($result, $catID, $news_clause, $this->clause); $sum = $result['sum']; } $this->categoryCountCache[$catID] = (int) $sum; if ($this->tt_news_obj->cache_categoryCount) { $this->tt_news_obj->cache->set($hash, (string) $sum, 'categoryCounts'); } } return $sum; }
function createMap() { // Generate unique ids for containing div and Yahoo $sMapId = t3lib_div::shortMD5('map' . time()); $sYahooId = 'yahoo_' . t3lib_div::shortMD5('yahoo' . time()); // Generate map object $this->oMap = new GoogleMapAPI($sMapId, $sYahooId); // Set Google API key $this->oMap->setAPIKey($this->lConf['google_api_key']); // Set properties of map: // Width $this->oMap->setWidth($this->lConf['width']); // Height $this->oMap->setHeight($this->lConf['height']); // Type of map $this->oMap->setMapType($this->lConf['type']); // Show type controls? if ($this->lConf['type_controls'] == 'show') { $this->oMap->enableTypeControls(); } else { $this->oMap->disableTypeControls(); } // Show navigation controls? switch ($this->lConf['nav_controls']) { case 'none': $this->oMap->disableMapControls(); break; case 'small': $this->oMap->enableMapControls(); $this->oMap->setControlSize('small'); break; case 'large': default: $this->oMap->enableMapControls(); $this->oMap->setControlSize('large'); break; } // Marker icon if ($this->lConf['marker_icon'] != '' && $this->lConf['marker_shadow'] != '') { $this->oMap->setMarkerIcon($this->lConf['marker_icon'], $this->lConf['marker_shadow'], $this->lConf['marker_spot_x'], $this->lConf['marker_spot_y'], $this->lConf['marker_info_x'], $this->lConf['marker_info_y']); } // Set language labels for map $lDirLabels = $this->oMap->getDirectionsText(); $lDirLabels['dir_text'] = $this->pi_getLL('map.directions.dir_text'); $lDirLabels['dir_tohere'] = $this->pi_getLL('map.directions.dir_tohere'); $lDirLabels['dir_fromhere'] = $this->pi_getLL('map.directions.dir_fromhere'); $lDirLabels['dir_to'] = $this->pi_getLL('map.directions.dir_to'); $lDirLabels['button_to'] = $this->pi_getLL('map.directions.button_to'); $lDirLabels['dir_from'] = $this->pi_getLL('map.directions.dir_from'); $lDirLabels['button_from'] = $this->pi_getLL('map.directions.button_from'); $this->oMap->setDirectionsText($lDirLabels); $this->oMap->setBrowserAlert($this->pi_getLL('map.browseralert')); $this->oMap->setJsAlert($this->pi_getLL('map.jsalert')); }
/** * Creates the HTML (mixture of a <form> and a JavaScript section) for the JavaScript menu (basically an array of selector boxes with onchange handlers) * * @return string The HTML code for the menu */ function writeMenu() { if ($this->id) { // Making levels: $levels = t3lib_div::intInRange($this->mconf['levels'], 1, 5); $this->levels = $levels; $uniqueParam = t3lib_div::shortMD5(microtime(), 5); $this->JSVarName = 'eid' . $uniqueParam; $this->JSMenuName = $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu' . $uniqueParam; $JScode = "\n var " . $this->JSMenuName . " = new JSmenu(" . $levels . ",'" . $this->JSMenuName . "Form');"; for ($a = 1; $a <= $levels; $a++) { $JScode .= "\n var " . $this->JSVarName . $a . "=0;"; } $JScode .= $this->generate_level($levels, 1, $this->id, $this->menuArr, $this->MP_array) . LF; $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode'] = '<script type="text/javascript" src="' . $GLOBALS['TSFE']->absRefPrefix . 't3lib/jsfunc.menu.js"></script>'; $GLOBALS['TSFE']->JSCode .= $JScode; // Printing: $allFormCode = ""; for ($a = 1; $a <= $this->levels; $a++) { $formCode = ''; $levelConf = $this->mconf[$a . '.']; $length = $levelConf['width'] ? $levelConf['width'] : 14; $lenghtStr = ''; for ($b = 0; $b < $length; $b++) { $lenghtStr .= '_'; } $height = $levelConf['elements'] ? $levelConf['elements'] : 5; $formCode .= '<select name="selector' . $a . '" onchange="' . $this->JSMenuName . '.act(' . $a . ');"' . ($levelConf['additionalParams'] ? ' ' . $levelConf['additionalParams'] : '') . '>'; for ($b = 0; $b < $height; $b++) { $formCode .= '<option value="0">'; if ($b == 0) { $formCode .= $lenghtStr; } $formCode .= '</option>'; } $formCode .= '</select>'; $allFormCode .= $this->tmpl->wrap($formCode, $levelConf['wrap']); } $formCode = $this->tmpl->wrap($allFormCode, $this->mconf['wrap']); $formCode = '<form action="" method="post" style="margin: 0 0 0 0;" name="' . $this->JSMenuName . 'Form">' . $formCode . '</form>'; $formCode .= '<script type="text/javascript"> /*<![CDATA[*/ ' . $this->JSMenuName . '.writeOut(1,' . $this->JSMenuName . '.openID,1); /*]]>*/ </script>'; return $this->tmpl->wrap($formCode, $this->mconf['wrapAfterTags']); } }
/** * Loading extensions configured in $TYPO3_CONF_VARS['EXT']['extList'] * * CACHING ON: ($TYPO3_CONF_VARS['EXT']['extCache'] = 1 or 2) * If caching is enabled (and possible), the output will be $extensions['_CACHEFILE'] set to the cacheFilePrefix. Subsequently the cache files must be included then since those will eventually set up the extensions. * If cachefiles are not found they will be generated * CACHING OFF: ($TYPO3_CONF_VARS['EXT']['extCache'] = 0) * The returned value will be an array where each key is an extension key and the value is an array with filepaths for the extension. * This array will later be set in the global var $TYPO3_LOADED_EXT * * Usages of this function can be seen in config_default.php * Extensions are always detected in the order local - global - system. * Usage: 1 * * @return array Extension Array * @internal */ public static function typo3_loadExtensions() { global $TYPO3_CONF_VARS; // Select mode how to load extensions in order to speed up the FE if (TYPO3_MODE == 'FE') { if (!($extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList_FE'])) { // fall back to standard 'extList' if 'extList_FE' is not (yet) set $extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList']; } $cacheFileSuffix = '_FE'; } else { $extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList']; // Works as before $cacheFileSuffix = ''; } // Full list of extensions includes both required and extList: $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'] . ',' . $extLoadInContext; // Empty array as a start. $extensions = array(); // if ($rawExtList) { // The cached File prefix. $cacheFilePrefix = 'temp_CACHED' . $cacheFileSuffix; // Setting the name for the cache files: if (intval($TYPO3_CONF_VARS['EXT']['extCache']) == 1) { $cacheFilePrefix .= '_ps' . substr(t3lib_div::shortMD5(PATH_site . '|' . $GLOBALS['TYPO_VERSION']), 0, 4); } if (intval($TYPO3_CONF_VARS['EXT']['extCache']) == 2) { $cacheFilePrefix .= '_' . t3lib_div::shortMD5($rawExtList); } // If cache files available, set cache file prefix and return: if ($TYPO3_CONF_VARS['EXT']['extCache'] && self::isCacheFilesAvailable($cacheFilePrefix)) { // Return cache file prefix: $extensions['_CACHEFILE'] = $cacheFilePrefix; } else { // ... but if not, configure... // Prepare reserved filenames: $files = array('ext_localconf.php', 'ext_tables.php', 'ext_tables.sql', 'ext_tables_static+adt.sql', 'ext_typoscript_constants.txt', 'ext_typoscript_editorcfg.txt', 'ext_typoscript_setup.txt'); // Traverse extensions and check their existence: clearstatcache(); // Clear file state cache to make sure we get good results from is_dir() $temp_extensions = array_unique(t3lib_div::trimExplode(',', $rawExtList, 1)); foreach ($temp_extensions as $temp_extKey) { // Check local, global and system locations: if (@is_dir(PATH_typo3conf . 'ext/' . $temp_extKey . '/')) { $extensions[$temp_extKey] = array('type' => 'L', 'siteRelPath' => 'typo3conf/ext/' . $temp_extKey . '/', 'typo3RelPath' => '../typo3conf/ext/' . $temp_extKey . '/'); } elseif (@is_dir(PATH_typo3 . 'ext/' . $temp_extKey . '/')) { $extensions[$temp_extKey] = array('type' => 'G', 'siteRelPath' => TYPO3_mainDir . 'ext/' . $temp_extKey . '/', 'typo3RelPath' => 'ext/' . $temp_extKey . '/'); } elseif (@is_dir(PATH_typo3 . 'sysext/' . $temp_extKey . '/')) { $extensions[$temp_extKey] = array('type' => 'S', 'siteRelPath' => TYPO3_mainDir . 'sysext/' . $temp_extKey . '/', 'typo3RelPath' => 'sysext/' . $temp_extKey . '/'); } // If extension was found, check for reserved filenames: if (isset($extensions[$temp_extKey])) { foreach ($files as $fName) { $temp_filename = PATH_site . $extensions[$temp_extKey]['siteRelPath'] . trim($fName); if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) { $extensions[$temp_extKey][$fName] = $temp_filename; } } } } unset($extensions['_CACHEFILE']); // write cache? if ($TYPO3_CONF_VARS['EXT']['extCache'] && @is_dir(PATH_typo3 . 'sysext/') && @is_dir(PATH_typo3 . 'ext/')) { // Must also find global and system extension directories to exist, otherwise caching cannot be allowed (since it is most likely a temporary server problem). This might fix a rare, unrepeatable bug where global/system extensions are not loaded resulting in fatal errors if that is cached! $wrError = self::cannotCacheFilesWritable($cacheFilePrefix); if ($wrError) { $TYPO3_CONF_VARS['EXT']['extCache'] = 0; } else { // Write cache files: $extensions = self::writeCacheFiles($extensions, $cacheFilePrefix); } } } } return $extensions; }
/** * 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; }
/** * Initialize; reading parameters with GPvar and checking file path * Results in internal var, $this->input, being set to the absolute path of the file for which to make the thumbnail. * * @return void */ function init() { global $TYPO3_CONF_VARS; // Setting GPvars: $file = t3lib_div::_GP('file'); $size = t3lib_div::_GP('size'); $md5sum = t3lib_div::_GP('md5sum'); // Image extension list is set: $this->imageList = $TYPO3_CONF_VARS['GFX']['imagefile_ext']; // valid extensions. OBS: No spaces in the list, all lowercase... // If the filereference $this->file is relative, we correct the path if (substr($file, 0, 3) == '../') { $file = PATH_site . substr($file, 3); } // Now the path is absolute. // Checking for backpath and double slashes + the thumbnail can be made from files which are in the PATH_site OR the lockRootPath only! if (t3lib_div::isAllowedAbsPath($file)) { $mtime = filemtime($file); } // Do an MD5 check to prevent viewing of images without permission $OK = FALSE; if ($mtime) { // Always use the absolute path for this check! $check = basename($file) . ':' . $mtime . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; $md5_real = t3lib_div::shortMD5($check); if (!strcmp($md5_real, $md5sum)) { $OK = TRUE; } } if ($OK) { $this->input = $file; $this->size = $size; $this->mtime = $mtime; } else { throw new RuntimeException('TYPO3 Fatal Error: Image does not exist and/or MD5 checksum did not match.', 1270853950); } }
/** * Creates the id for dynTabMenus. * * @param string $identString: Identification string. This should be unique for every instance of a dynamic menu! * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a" */ function getDynTabMenuId($identString) { $id = 'DTM-' . t3lib_div::shortMD5($identString); return $id; }
/** * 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; }
/** * Creates a new alias<->id relation in database lookup table. * * WARNING! This function is internal to RealURL. It is made public for * backwards compatibility but its behavior and parameters may change as * necessary for RealURL. No guaranties at all! * * @param array Configuration array of lookup table * @param string Preferred new alias (final alias might be different if duplicates were found in the cache) * @param integer ID associated with alias * @param integer sys_language_uid to store with record * @return string Final alias string * @see lookUpTranslation() * @internal */ protected function lookUp_newAlias($cfg, $newAliasValue, $idValue, $lang) { // Clean preferred alias $newAliasValue = $this->lookUp_cleanAlias($cfg, $newAliasValue); // If autoupdate is true we might be here even if an alias exists. Therefore we check if that alias is the $newAliasValue and if so, we return that instead of making a new, unique one. if ($cfg['autoUpdate'] && $this->lookUp_idToUniqAlias($cfg, $idValue, $lang, $newAliasValue)) { return $newAliasValue; } // Now, go create a unique alias: $uniqueAlias = ''; $counter = 0; $maxTry = 100; $test_newAliasValue = $newAliasValue; while ($counter < $maxTry) { // If the test-alias did NOT exist, it must be unique and we break out: $foundId = $this->lookUp_uniqAliasToId($cfg, $test_newAliasValue, true); if (!$foundId || $foundId == $idValue) { $uniqueAlias = $test_newAliasValue; break; } // Otherwise, increment counter and test again... $counter++; $test_newAliasValue = $newAliasValue . '-' . $counter; } // if no unique alias was found in the process above, just suffix a hash string and assume that is unique... if (!$uniqueAlias) { $uniqueAlias = $newAliasValue .= '-' . t3lib_div::shortMD5(microtime()); } // Insert the new id<->alias relation: $insertArray = array('tstamp' => time(), 'tablename' => $cfg['table'], 'field_alias' => $cfg['alias_field'], 'field_id' => $cfg['id_field'], 'value_alias' => $uniqueAlias, 'value_id' => $idValue, 'lang' => $lang); // Checking that this alias hasn't been stored since we looked last time: $returnAlias = $this->lookUp_idToUniqAlias($cfg, $idValue, $lang, $uniqueAlias); if ($returnAlias) { // If we are here it is because another process managed to create this alias in the time between we looked the first time and now when we want to put it in database. $uniqueAlias = $returnAlias; } else { // Expire all other aliases: // Look for an alias based on ID: $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_realurl_uniqalias', 'value_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($idValue, 'tx_realurl_uniqalias') . ' AND field_alias=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($cfg['alias_field'], 'tx_realurl_uniqalias') . ' AND field_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($cfg['id_field'], 'tx_realurl_uniqalias') . ' AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($cfg['table'], 'tx_realurl_uniqalias') . ' AND lang=' . intval($lang) . ' AND expire=0', array('expire' => time() + 24 * 3600 * ($cfg['expireDays'] ? $cfg['expireDays'] : 60))); // Store new alias: $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_realurl_uniqalias', $insertArray); } // Return new unique alias: return $uniqueAlias; }
/** * Converts $imagefile to another file in temp-dir of type $newExt (extension). * * @param string The image filepath * @param string New extension, eg. "gif", "png", "jpg", "tif". If $newExt is NOT set, the new imagefile will be of the original format. If newExt = 'WEB' then one of the web-formats is applied. * @param string Width. $w / $h is optional. If only one is given the image is scaled proportionally. If an 'm' exists in the $w or $h and if both are present the $w and $h is regarded as the Maximum w/h and the proportions will be kept * @param string Height. See $w * @param string Additional ImageMagick parameters. * @param string Refers to which frame-number to select in the image. '' or 0 will select the first frame, 1 will select the next and so on... * @param array An array with options passed to getImageScale (see this function). * @param boolean If set, then another image than the input imagefile MUST be returned. Otherwise you can risk that the input image is good enough regarding messures etc and is of course not rendered to a new, temporary file in typo3temp/. But this option will force it to. * @return array [0]/[1] is w/h, [2] is file extension and [3] is the filename. * @see getImageScale(), typo3/show_item.php, fileList_ext::renderImage(), tslib_cObj::getImgResource(), SC_tslib_showpic::show(), maskImageOntoImage(), copyImageOntoImage(), scale() */ function imageMagickConvert($imagefile, $newExt = '', $w = '', $h = '', $params = '', $frame = '', $options = '', $mustCreate = 0) { if ($this->NO_IMAGE_MAGICK) { // Returning file info right away return $this->getImageDimensions($imagefile); } if ($info = $this->getImageDimensions($imagefile)) { $newExt = strtolower(trim($newExt)); if (!$newExt) { // If no extension is given the original extension is used $newExt = $info[2]; } if ($newExt == 'web') { if (t3lib_div::inList($this->webImageExt, $info[2])) { $newExt = $info[2]; } else { $newExt = $this->gif_or_jpg($info[2], $info[0], $info[1]); if (!$params) { $params = $this->cmds[$newExt]; } } } if (t3lib_div::inList($this->imageFileExt, $newExt)) { if (strstr($w . $h, 'm')) { $max = 1; } else { $max = 0; } $data = $this->getImageScale($info, $w, $h, $options); $w = $data['origW']; $h = $data['origH']; // if no conversion should be performed // this flag is true if the width / height does NOT dictate // the image to be scaled!! (that is if no width / height is // given or if the destination w/h matches the original image // dimensions or if the option to not scale the image is set) $noScale = !$w && !$h || $data[0] == $info[0] && $data[1] == $info[1] || $options['noScale']; if ($noScale && !$data['crs'] && !$params && !$frame && $newExt == $info[2] && !$mustCreate) { // set the new width and height before returning, // if the noScale option is set if ($options['noScale']) { $info[0] = $data[0]; $info[1] = $data[1]; } $info[3] = $imagefile; return $info; } $info[0] = $data[0]; $info[1] = $data[1]; $frame = $this->noFramePrepended ? '' : intval($frame); if (!$params) { $params = $this->cmds[$newExt]; } // Cropscaling: if ($data['crs']) { if (!$data['origW']) { $data['origW'] = $data[0]; } if (!$data['origH']) { $data['origH'] = $data[1]; } $offsetX = intval(($data[0] - $data['origW']) * ($data['cropH'] + 100) / 200); $offsetY = intval(($data[1] - $data['origH']) * ($data['cropV'] + 100) / 200); $params .= ' -crop ' . $data['origW'] . 'x' . $data['origH'] . '+' . $offsetX . '+' . $offsetY . ' '; } $command = $this->scalecmd . ' ' . $info[0] . 'x' . $info[1] . '! ' . $params . ' '; $cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : ''; if ($this->alternativeOutputKey) { $theOutputName = t3lib_div::shortMD5($command . $cropscale . basename($imagefile) . $this->alternativeOutputKey . '[' . $frame . ']'); } else { $theOutputName = t3lib_div::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']'); } if ($this->imageMagickConvert_forceFileNameBody) { $theOutputName = $this->imageMagickConvert_forceFileNameBody; $this->imageMagickConvert_forceFileNameBody = ''; } // Making the temporary filename: $this->createTempSubDir('pics/'); $output = $this->absPrefix . $this->tempPath . 'pics/' . $this->filenamePrefix . $theOutputName . '.' . $newExt; // Register temporary filename: $GLOBALS['TEMP_IMAGES_ON_PAGE'][] = $output; if ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output, $imagefile)) { $this->imageMagickExec($imagefile, $output, $command, $frame); } if (file_exists($output)) { $info[3] = $output; $info[2] = $newExt; if ($params) { // params could realisticly change some imagedata! $info = $this->getImageDimensions($info[3]); } if ($info[2] == $this->gifExtension && !$this->dontCompress) { t3lib_div::gif_compress($info[3], ''); // Compress with IM (lzw) or GD (rle) (Workaround for the absence of lzw-compression in GD) } return $info; } } } }
/** * Creates and returns a TypoScript "imgResource". * The value ($file) can either be a file reference (TypoScript resource) or the string "GIFBUILDER". * In the first case a current image is returned, possibly scaled down or otherwise processed. * In the latter case a GIFBUILDER image is returned; This means an image is made by TYPO3 from layers of elements as GIFBUILDER defines. * In the function IMG_RESOURCE() this function is called like $this->getImgResource($conf['file'],$conf['file.']); * * @param string A "imgResource" TypoScript data type. Either a TypoScript file resource or the string GIFBUILDER. See description above. * @param array TypoScript properties for the imgResource type * @return array Returns info-array. info[origFile] = original file. * @see IMG_RESOURCE(), cImage(), tslib_gifBuilder */ function getImgResource($file, $fileArray) { if (is_array($fileArray)) { switch ($file) { case 'GIFBUILDER': $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); $gifCreator->init(); $theImage = ''; if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) { $gifCreator->start($fileArray, $this->data); $theImage = $gifCreator->gifBuild(); } $imageResource = $gifCreator->getImageDimensions($theImage); break; default: if ($fileArray['import.']) { $ifile = $this->stdWrap('', $fileArray['import.']); if ($ifile) { $file = $fileArray['import'] . $ifile; } } $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file); if ($theImage) { $fileArray['width'] = isset($fileArray['width.']) ? $this->stdWrap($fileArray['width'], $fileArray['width.']) : $fileArray['width']; $fileArray['height'] = isset($fileArray['height.']) ? $this->stdWrap($fileArray['height'], $fileArray['height.']) : $fileArray['height']; $fileArray['ext'] = isset($fileArray['ext.']) ? $this->stdWrap($fileArray['ext'], $fileArray['ext.']) : $fileArray['ext']; $fileArray['maxW'] = isset($fileArray['maxW.']) ? intval($this->stdWrap($fileArray['maxW'], $fileArray['maxW.'])) : intval($fileArray['maxW']); $fileArray['maxH'] = isset($fileArray['maxH.']) ? intval($this->stdWrap($fileArray['maxH'], $fileArray['maxH.'])) : intval($fileArray['maxH']); $fileArray['minW'] = isset($fileArray['minW.']) ? intval($this->stdWrap($fileArray['minW'], $fileArray['minW.'])) : intval($fileArray['minW']); $fileArray['minH'] = isset($fileArray['minH.']) ? intval($this->stdWrap($fileArray['minH'], $fileArray['minH.'])) : intval($fileArray['minH']); $fileArray['noScale'] = isset($fileArray['noScale.']) ? $this->stdWrap($fileArray['noScale'], $fileArray['noScale.']) : $fileArray['noScale']; $maskArray = $fileArray['m.']; $maskImages = array(); if (is_array($fileArray['m.'])) { // Must render mask images and include in hash-calculating - else we cannot be sure the filename is unique for the setup! $maskImages['m_mask'] = $this->getImgResource($maskArray['mask'], $maskArray['mask.']); $maskImages['m_bgImg'] = $this->getImgResource($maskArray['bgImg'], $maskArray['bgImg.']); $maskImages['m_bottomImg'] = $this->getImgResource($maskArray['bottomImg'], $maskArray['bottomImg.']); $maskImages['m_bottomImg_mask'] = $this->getImgResource($maskArray['bottomImg_mask'], $maskArray['bottomImg_mask.']); } $hash = t3lib_div::shortMD5($theImage . serialize($fileArray) . serialize($maskImages)); if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) { $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); $gifCreator->init(); if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']) { $filename = basename($theImage); // remove extension $filename = substr($filename, 0, strrpos($filename, '.')); // strip everything non-ascii $filename = preg_replace('/[^A-Za-z0-9_-]/', '', trim($filename)); $gifCreator->filenamePrefix = substr($filename, 0, intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'])) . '_'; unset($filename); } if ($fileArray['sample']) { $gifCreator->scalecmd = '-sample'; $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.'); } if ($fileArray['alternativeTempPath'] && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'], $fileArray['alternativeTempPath'])) { $gifCreator->tempPath = $fileArray['alternativeTempPath']; $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: ' . $fileArray['alternativeTempPath']); } if (!trim($fileArray['ext'])) { $fileArray['ext'] = 'web'; } $options = array(); if ($fileArray['maxW']) { $options['maxW'] = $fileArray['maxW']; } if ($fileArray['maxH']) { $options['maxH'] = $fileArray['maxH']; } if ($fileArray['minW']) { $options['minW'] = $fileArray['minW']; } if ($fileArray['minH']) { $options['minH'] = $fileArray['minH']; } if ($fileArray['noScale']) { $options['noScale'] = $fileArray['noScale']; } // checks to see if m (the mask array) is defined if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) { // Filename: $fI = t3lib_div::split_fileref($theImage); $imgExt = strtolower($fI['fileext']) == $gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg'; $dest = $gifCreator->tempPath . $hash . '.' . $imgExt; if (!file_exists($dest)) { // Generate! $m_mask = $maskImages['m_mask']; $m_bgImg = $maskImages['m_bgImg']; if ($m_mask && $m_bgImg) { $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : ''; $temp_ext = 'png'; if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) { // If ImageMagick version 5+ $temp_ext = $gifCreator->gifExtension; } $tempFileInfo = $gifCreator->imageMagickConvert($theImage, $temp_ext, $fileArray['width'], $fileArray['height'], $fileArray['params'], $fileArray['frame'], $options); if (is_array($tempFileInfo)) { $m_bottomImg = $maskImages['m_bottomImg']; if ($m_bottomImg) { $m_bottomImg_mask = $maskImages['m_bottomImg_mask']; } // Scaling: **** $tempScale = array(); $command = '-geometry ' . $tempFileInfo[0] . 'x' . $tempFileInfo[1] . '!'; $command = $this->modifyImageMagickStripProfileParameters($command, $fileArray); $tmpStr = $gifCreator->randomName(); // m_mask $tempScale['m_mask'] = $tmpStr . '_mask.' . $temp_ext; $gifCreator->imageMagickExec($m_mask[3], $tempScale['m_mask'], $command . $negate); // m_bgImg $tempScale['m_bgImg'] = $tmpStr . '_bgImg.' . trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']); $gifCreator->imageMagickExec($m_bgImg[3], $tempScale['m_bgImg'], $command); // m_bottomImg / m_bottomImg_mask if ($m_bottomImg && $m_bottomImg_mask) { $tempScale['m_bottomImg'] = $tmpStr . '_bottomImg.' . $temp_ext; $gifCreator->imageMagickExec($m_bottomImg[3], $tempScale['m_bottomImg'], $command); $tempScale['m_bottomImg_mask'] = $tmpStr . '_bottomImg_mask.' . $temp_ext; $gifCreator->imageMagickExec($m_bottomImg_mask[3], $tempScale['m_bottomImg_mask'], $command . $negate); // BEGIN combining: // The image onto the background $gifCreator->combineExec($tempScale['m_bgImg'], $tempScale['m_bottomImg'], $tempScale['m_bottomImg_mask'], $tempScale['m_bgImg']); } // The image onto the background $gifCreator->combineExec($tempScale['m_bgImg'], $tempFileInfo[3], $tempScale['m_mask'], $dest); // Unlink the temp-images... foreach ($tempScale as $file) { if (@is_file($file)) { unlink($file); } } } } } // Finish off if (($fileArray['reduceColors'] || $imgExt == 'png' && !$gifCreator->png_truecolor) && is_file($dest)) { $reduced = $gifCreator->IMreduceColors($dest, t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256)); if (is_file($reduced)) { unlink($dest); rename($reduced, $dest); } } $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->getImageDimensions($dest); } else { // Normal situation: $fileArray['params'] = $this->modifyImageMagickStripProfileParameters($fileArray['params'], $fileArray); $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->imageMagickConvert($theImage, $fileArray['ext'], $fileArray['width'], $fileArray['height'], $fileArray['params'], $fileArray['frame'], $options); if (($fileArray['reduceColors'] || $imgExt == 'png' && !$gifCreator->png_truecolor) && is_file($GLOBALS['TSFE']->tmpl->fileCache[$hash][3])) { $reduced = $gifCreator->IMreduceColors($GLOBALS['TSFE']->tmpl->fileCache[$hash][3], t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256)); if (is_file($reduced)) { unlink($GLOBALS['TSFE']->tmpl->fileCache[$hash][3]); rename($reduced, $GLOBALS['TSFE']->tmpl->fileCache[$hash][3]); } } } $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage; $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile_mtime'] = @filemtime($theImage); // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash. $GLOBALS['TSFE']->tmpl->fileCache[$hash]['fileCacheHash'] = $hash; } $imageResource = $GLOBALS['TSFE']->tmpl->fileCache[$hash]; } break; } } $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file); // If image was processed by GIFBUILDER: // ($imageResource indicates that it was processed the regular way) if (!isset($imageResource) && $theImage) { $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); /* @var $gifCreator tslib_gifbuilder */ $gifCreator->init(); $info = $gifCreator->imageMagickConvert($theImage, 'WEB', '', '', '', '', ''); $info['origFile'] = $theImage; $info['origFile_mtime'] = @filemtime($theImage); // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash. $imageResource = $info; } // Hook 'getImgResource': Post-processing of image resources if (isset($imageResource)) { foreach ($this->getGetImgResourceHookObjects() as $hookObject) { $imageResource = $hookObject->getImgResourcePostProcess($file, (array) $fileArray, $imageResource, $this); } } return $imageResource; }
/** * Includes a locallang-xml file and returns the $LOCAL_LANG array * Works only when the frontend or backend has been initialized with a charset conversion object. See first code lines. * * @param string Absolute reference to locallang-XML file * @param string TYPO3 language key, eg. "dk" or "de" or "default" * @return array LOCAL_LANG array in return. */ function readLLXMLfile($fileRef, $langKey) { if (is_object($GLOBALS['LANG'])) { $csConvObj =& $GLOBALS['LANG']->csConvObj; } elseif (is_object($GLOBALS['TSFE'])) { $csConvObj =& $GLOBALS['TSFE']->csConvObj; } else { $csConvObj = NULL; } if (@is_file($fileRef) && $langKey && is_object($csConvObj)) { // Set charset: $origCharset = $csConvObj->parse_charset($csConvObj->charSetArray[$langKey] ? $csConvObj->charSetArray[$langKey] : 'iso-8859-1'); // Cache file name: $hashSource = substr($fileRef, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($fileRef)); $cacheFileName = PATH_site . 'typo3temp/llxml/' . substr(basename($fileRef), 10, 15) . '_' . t3lib_div::shortMD5($hashSource) . '.' . $langKey . '.' . $origCharset . '.cache'; // Check if cache file exists... if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it: // Read XML, parse it. $xmlString = t3lib_div::getUrl($fileRef); $xmlContent = t3lib_div::xml2array($xmlString); // Set default LOCAL_LANG array content: $LOCAL_LANG = array(); $LOCAL_LANG['default'] = $xmlContent['data']['default']; // Specific language, convert from utf-8 to backend language charset: // NOTICE: Converting from utf-8 back to "native" language may be a temporary solution until we can totally discard "locallang.php" files altogether (and use utf-8 for everything). But doing this conversion is the quickest way to migrate now and the source is in utf-8 anyway which is the main point. if ($langKey != 'default') { $LOCAL_LANG[$langKey] = $xmlContent['data'][$langKey]; // Checking if charset should be converted. if (is_array($LOCAL_LANG[$langKey]) && $origCharset != 'utf-8') { foreach ($LOCAL_LANG[$langKey] as $labelKey => $labelValue) { $LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue, $origCharset); } } } // Cache the content now: $serContent = array('origFile' => $hashSource, 'LOCAL_LANG' => $LOCAL_LANG); $res = t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent)); if ($res) { die('ERROR: ' . $res); } } else { // Get content from cache: $serContent = unserialize(t3lib_div::getUrl($cacheFileName)); $LOCAL_LANG = $serContent['LOCAL_LANG']; } // Checking for EXTERNAL file for non-default language: if ($langKey != 'default' && is_string($LOCAL_LANG[$langKey]) && strlen($LOCAL_LANG[$langKey])) { // Look for localized file: $localized_file = t3lib_div::getFileAbsFileName($LOCAL_LANG[$langKey]); if ($localized_file && @is_file($localized_file)) { // Cache file name: $hashSource = substr($localized_file, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($localized_file)); $cacheFileName = PATH_site . 'typo3temp/llxml/ext_' . substr(basename($localized_file), 10, 15) . '_' . t3lib_div::shortMD5($hashSource) . '.' . $langKey . '.' . $origCharset . '.cache'; // Check if cache file exists... if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it: // Read and parse XML content: $local_xmlString = t3lib_div::getUrl($localized_file); $local_xmlContent = t3lib_div::xml2array($local_xmlString); $LOCAL_LANG[$langKey] = is_array($local_xmlContent['data'][$langKey]) ? $local_xmlContent['data'][$langKey] : array(); // Checking if charset should be converted. if (is_array($LOCAL_LANG[$langKey]) && $origCharset != 'utf-8') { foreach ($LOCAL_LANG[$langKey] as $labelKey => $labelValue) { $LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue, $origCharset); } } // Cache the content now: $serContent = array('extlang' => $langKey, 'origFile' => $LOCAL_LANG[$langKey], 'EXT_DATA' => $LOCAL_LANG[$langKey]); $res = t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent)); if ($res) { die('ERROR: ' . $res); } } else { // Get content from cache: $serContent = unserialize(t3lib_div::getUrl($cacheFileName)); $LOCAL_LANG[$langKey] = $serContent['EXT_DATA']; } } else { $LOCAL_LANG[$langKey] = array(); } } return $LOCAL_LANG; } }
/** * gets categories and subcategories for a news record * * @param integer $uid : uid of the current news record * @param bool $getAll: ... * @return array $categories: array of found categories */ function getCategories($uid, $getAll = false) { $hash = FALSE; $tmpcat = false; if ($this->cache_categories) { $hash = t3lib_div::shortMD5(serialize(array($uid, $this->config['catOrderBy'], $this->enableCatFields, $this->SPaddWhere, $getAll, $this->tsfe->sys_language_content, $this->conf['useSPidFromCategory'], $this->conf['useSPidFromCategoryRecusive'], $this->conf['displaySubCategories'], $this->config['useSubCategories'])), 30); $tmpcat = $this->cache->get($hash); } if ($tmpcat !== false) { if ($this->writeCachingInfoToDevlog > 1) { t3lib_div::devLog('CACHE HIT (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', -1, array()); } $categories = unserialize($tmpcat); } else { if ($this->cache_categories && $this->writeCachingInfoToDevlog) { t3lib_div::devLog('CACHE MISS (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', 2, array()); } if (!$this->config['catOrderBy'] || $this->config['catOrderBy'] == 'sorting') { $mmCatOrderBy = 'mmsorting'; } else { $mmCatOrderBy = $this->config['catOrderBy']; } $addWhere = $this->SPaddWhere . ($getAll ? ' AND tt_news_cat.deleted=0' : $this->enableCatFields); $select_fields = 'tt_news_cat.*,tt_news_cat_mm.sorting AS mmsorting'; $from_table = 'tt_news_cat_mm, tt_news_cat '; $where_clause = 'tt_news_cat_mm.uid_local=' . intval($uid) . ' AND tt_news_cat_mm.uid_foreign=tt_news_cat.uid'; $where_clause .= $addWhere; $groupBy = ''; $orderBy = $mmCatOrderBy; $limit = ''; $res = $this->db->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit); $categories = array(); $maincat = 0; while ($row = $this->db->sql_fetch_assoc($res)) { $maincat .= ',' . $row['uid']; $rows = array($row); if ($this->conf['displaySubCategories'] && $this->config['useSubCategories']) { $subCategories = array(); $subcats = implode(',', array_unique(explode(',', tx_ttnews_div::getSubCategories($rows[0]['uid'], $addWhere)))); $subres = $this->db->exec_SELECTquery('tt_news_cat.*', 'tt_news_cat', 'tt_news_cat.uid IN (' . ($subcats ? $subcats : 0) . ')' . $addWhere, '', 'tt_news_cat.' . $this->config['catOrderBy']); while ($subrow = $this->db->sql_fetch_assoc($subres)) { $subCategories[] = $subrow; } $this->db->sql_free_result($subres); $rows = array_merge($rows, $subCategories); } foreach ($rows as $val) { $parentSP = FALSE; $catTitle = ''; if ($this->tsfe->sys_language_content) { // find translations of category titles $catTitleArr = t3lib_div::trimExplode('|', $val['title_lang_ol']); $catTitle = $catTitleArr[$this->tsfe->sys_language_content - 1]; } $catTitle = $catTitle ? $catTitle : $val['title']; if ($this->conf['useSPidFromCategory'] && $this->conf['useSPidFromCategoryRecusive']) { $parentSP = $this->hObj->getRecursiveCategorySinglePid($val['uid']); } $singlePid = $parentSP ? $parentSP : $val['single_pid']; $categories[$val['uid']] = array('title' => $catTitle, 'image' => $val['image'], 'shortcut' => $val['shortcut'], 'shortcut_target' => $val['shortcut_target'], 'single_pid' => $singlePid, 'catid' => $val['uid'], 'parent_category' => !t3lib_div::inList($maincat, $val['uid']) && $this->conf['displaySubCategories'] ? $val['parent_category'] : '', 'sorting' => $val['sorting'], 'mmsorting' => $val['mmsorting']); } } $this->db->sql_free_result($res); if ($this->cache_categories && is_array($categories)) { $this->cache->set($hash, serialize($categories), __FUNCTION__); } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__); } } return $categories; }
/** * Checks that using t3vars returns correct file * * @return void */ public function testLocalPathWithT3Vars() { $this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-'); $html = 'test <a href="testfile">test</a> test'; $savedValue = $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles']; $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(t3lib_div::shortMD5('testfile') => $this->temporaryFileName); $result = $this->indexer->extractHyperLinks($html); $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = $savedValue; $this->assertEquals(1, count($result), 'Wrong number of parsed links'); $this->assertEquals($result[0]['localPath'], $this->temporaryFileName, 'Local path is incorrect'); }