本文整理汇总了PHP中t3lib_div::split_fileref方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::split_fileref方法的具体用法?PHP t3lib_div::split_fileref怎么用?PHP t3lib_div::split_fileref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::split_fileref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setModeByFile
public function setModeByFile($file)
{
$fileInfo = t3lib_div::split_fileref($file);
switch ($fileInfo['fileext']) {
case 'html':
case 'htm':
case 'tmpl':
$mode = self::MODE_HTML;
break;
case 'js':
$mode = self::MODE_JAVASCRIPT;
break;
case 'xml':
case 'svg':
$mode = self::MODE_XML;
break;
case 'css':
$mode = self::MODE_CSS;
break;
case 'ts':
$mode = self::MODE_TYPOSCRIPT;
break;
case 'php':
case 'phpsh':
case 'inc':
$mode = self::MODE_PHP;
break;
default:
$mode = self::MODE_MIXED;
}
$this->setMode($mode);
}
示例2: setFileInformations
/**
* collect all fileinformations of given file and
* save them to the global fileinformation array
*
* @param string $file
* @return boolean is valid file?
*/
protected function setFileInformations($file)
{
$this->fileInfo = array();
// reset previously information to have a cleaned object
$this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
if (is_string($file) && !empty($file)) {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
} else {
$this->fileInfo = t3lib_div::split_fileref($file);
}
$this->fileInfo['mtime'] = filemtime($file);
$this->fileInfo['atime'] = fileatime($file);
$this->fileInfo['owner'] = fileowner($file);
$this->fileInfo['group'] = filegroup($file);
$this->fileInfo['size'] = filesize($file);
$this->fileInfo['type'] = filetype($file);
$this->fileInfo['perms'] = fileperms($file);
$this->fileInfo['is_dir'] = is_dir($file);
$this->fileInfo['is_file'] = is_file($file);
$this->fileInfo['is_link'] = is_link($file);
$this->fileInfo['is_readable'] = is_readable($file);
$this->fileInfo['is_uploaded'] = is_uploaded_file($file);
$this->fileInfo['is_writeable'] = is_writeable($file);
}
if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
$pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
$this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
}
return $this->fileInfo !== array();
}
示例3: main
/**
* 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);
}
}
}
示例4: split_fileref
/**
* @param $fileref
* @return array
* @see t3lib_div::split_fileref
*/
public function split_fileref($fileref)
{
/** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */
return t3lib_div::split_fileref($fileref);
}
示例5: getFileMimeType
/**
* get the mime type of a file with full path
*
* @param string $pathname absolute path to file
* @return array file information
*/
function getFileMimeType($pathname)
{
// this will be called from tx_dam therefore $pathname can be a fileInfo array
$pathname = tx_dam::file_absolutePath($pathname);
$TX_DAM = $GLOBALS['T3_VAR']['ext']['dam'];
$mimeType = array();
$mimeType['fulltype'] = '';
$mimeType['file_mime_type'] = '';
$mimeType['file_mime_subtype'] = '';
$mimeType['file_type'] = '';
$path_parts = t3lib_div::split_fileref($pathname);
$mimeType['file_type'] = strtolower($path_parts['realFileext']);
// cleanup bakup files extension
$mimeType['file_type'] = preg_replace('#\\~$#', '', $mimeType['file_type']);
$this->setup['useInternalMimeList'] = tx_dam::config_checkValueEnabled('setup.indexing.useInternalMimeList', true);
$this->setup['useMimeContentType'] = tx_dam::config_checkValueEnabled('setup.indexing.useMimeContentType', true);
$this->setup['useFileCommand'] = tx_dam::config_checkValueEnabled('setup.indexing.useFileCommand', true);
// Get the mimetype info from the DB
$file_type = tx_dam_db::getMediaExtension($mimeType['file_type']);
// try first to get the mime type by extension with own array
// I made the experience that it is a bit safer than with 'file'
if ($this->setup['useInternalMimeList'] and $mimeType['file_type'] and isset($file_type['mime'])) {
$mt = $file_type['mime'];
if ($this->writeDevLog) {
t3lib_div::devLog('getFileMimeType(): used builtin conversion table', 'tx_dam_indexing');
}
// next try
} elseif ($this->setup['useMimeContentType'] and function_exists('mime_content_type')) {
// available in PHP 4.3.0
$mt = mime_content_type($pathname);
if ($this->writeDevLog) {
t3lib_div::devLog('getFileMimeType(): used mime_content_type()', 'tx_dam_indexing');
}
}
// last chance
if ($this->setup['useFileCommand'] and (!$mt or $mt === 'application/octet-stream')) {
$osType = TYPO3_OS;
if (!($osType === 'WIN')) {
if ($cmd = t3lib_exec::getCommand('file')) {
$dummy = array();
$ret = false;
$mimeTypeTxt = trim(exec($cmd . ' --mime ' . escapeshellarg($pathname), $dummy, $ret));
if (!$ret and strstr($mimeTypeTxt, tx_dam::file_basename($pathname) . ':')) {
$a = explode(':', $mimeTypeTxt);
$a = explode(';', trim($a[1]));
//a[1]: text/plain, English; charset=iso-8859-1
$a = explode(',', trim($a[0]));
$a = explode(' ', trim($a[0]));
$mt = trim($a[0]);
}
}
}
if ($this->writeDevLog) {
t3lib_div::devLog('getFileMimeType(): used t3lib_exec::getCommand(\'file\')', 'tx_dam_indexing');
}
}
$mtarr = explode('/', $mt);
if (is_array($mtarr) && count($mtarr) == 2) {
$mimeType['fulltype'] = $mt;
$mimeType['file_mime_type'] = $mtarr[0];
$mimeType['file_mime_subtype'] = $mtarr[1];
}
if ($mimeType['file_type'] == '') {
$file_type = tx_dam_db::getMediaExtension('', $mimeType['fulltype']);
$mimeType['file_type'] = $file_type['mime'];
}
if ($this->writeDevLog) {
t3lib_div::devLog('getFileMimeType()', 'tx_dam_indexing', 0, $mimeType);
}
unset($mimeType['fulltype']);
return $mimeType;
}
示例6: getImgResource
/**
* 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!
//.........这里部分代码省略.........
示例7: folderList
/**
* 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;
}
示例8: decodeSpURL
/**
* Parse speaking URL and translate it to parameters understood by TYPO3
* Function is called from tslib_fe
* The overall format of a speaking URL is these five parts [TYPO3_SITE_URL] / [pre-var] / [page-identification] / [post-vars] / [file.ext]
* - "TYPO3_SITE_URL" is fixed value from the environment,
* - "pre-var" is any number of segments separated by "/" mapping to GETvars AND with a known lenght,
* - "page-identification" identifies the page id in TYPO3 possibly with multiple segments separated by "/" BUT with an UNKNOWN length,
* - "post-vars" is sets of segments offering the same features as "pre-var"
* - "file.ext" is any filename that might apply
*
* @param array Params for hook
* @return void Setting internal variables.
*/
public function decodeSpURL($params) {
$this->devLog('Entering decodeSpURL');
// Setting parent object reference (which is $GLOBALS['TSFE'])
$this->pObj = &$params['pObj'];
// Initializing config / request URL:
$this->setConfig();
$this->adjustConfigurationByHost('decode');
$this->adjustRootPageId();
// If there has been a redirect (basically; we arrived here otherwise than via "index.php" in the URL) this can happend either due to a CGI-script or because of reWrite rule. Earlier we used $GLOBALS['HTTP_SERVER_VARS']['REDIRECT_URL'] to check but...
if ($this->pObj->siteScript && substr($this->pObj->siteScript, 0, 9) != 'index.php' && substr($this->pObj->siteScript, 0, 1) != '?') {
// Getting the path which is above the current site url:
// For instance "first/second/third/index.html?¶m1=value1¶m2=value2"
// should be the result of the URL
// "http://localhost/typo3/dev/dummy_1/first/second/third/index.html?¶m1=value1¶m2=value2"
// Note: sometimes in fcgi installations it is absolute, so we have to make it
// relative to work properly.
$speakingURIpath = $this->pObj->siteScript{0} == '/' ? substr($this->pObj->siteScript, 1) : $this->pObj->siteScript;
// Call hooks
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'] as $userFunc) {
$hookParams = array(
'pObj' => &$this,
'params' => $params,
'URL' => &$speakingURIpath,
);
t3lib_div::callUserFunction($userFunc, $hookParams, $this);
}
}
// Append missing slash if configured for:
if ($this->extConf['init']['appendMissingSlash']) {
$regexp = '~^([^\?]*[^/])(\?.*)?$~';
if (substr($speakingURIpath, -1, 1) == '?') {
$speakingURIpath = substr($speakingURIpath, 0, -1);
}
if (preg_match($regexp, $speakingURIpath)) { // Only process if a slash is missing:
$options = t3lib_div::trimExplode(',', $this->extConf['init']['appendMissingSlash'], true);
if (in_array('ifNotFile', $options)) {
if (!preg_match('/\/[^\/\?]+\.[^\/]+(\?.*)?$/', '/' . $speakingURIpath)) {
$speakingURIpath = preg_replace($regexp, '\1/\2', $speakingURIpath);
$this->appendedSlash = true;
}
}
else {
$speakingURIpath = preg_replace($regexp, '\1/\2', $speakingURIpath);
$this->appendedSlash = true;
}
if ($this->appendedSlash && count($options) > 0) {
foreach ($options as $option) {
$matches = array();
if (preg_match('/^redirect(\[(30[1237])\])?$/', $option, $matches)) {
$code = count($matches) > 1 ? $matches[2] : 301;
$status = 'HTTP/1.0 ' . $code . ' TYPO3 RealURL redirect';
// Check path segment to be relative for the current site.
// parse_url() does not work with relative URLs, so we use it to test
if (!@parse_url($speakingURIpath, PHP_URL_HOST)) {
@ob_end_clean();
header($status);
header('Location: ' . t3lib_div::locationHeaderUrl($speakingURIpath));
exit;
}
}
}
}
}
}
// If the URL is a single script like "123.1.html" it might be an "old" simulateStaticDocument request. If this is the case and support for this is configured, do NOT try and resolve it as a Speaking URL
$fI = t3lib_div::split_fileref($speakingURIpath);
if (!self::testInt($this->pObj->id) && $fI['path'] == '' && $this->extConf['fileName']['defaultToHTMLsuffixOnPrev'] && $this->extConf['init']['respectSimulateStaticURLs']) {
// If page ID does not exist yet and page is on the root level and both
// respectSimulateStaticURLs and defaultToHTMLsuffixOnPrev are set, than
// ignore respectSimulateStaticURLs and attempt to resolve page id.
// See http://bugs.typo3.org/view.php?id=1530
$GLOBALS['TT']->setTSlogMessage('decodeSpURL: ignoring respectSimulateStaticURLs due defaultToHTMLsuffixOnPrev for the root level page!)', 2);
$this->extConf['init']['respectSimulateStaticURLs'] = false;
}
if (!$this->extConf['init']['respectSimulateStaticURLs'] || $fI['path']) {
$this->devLog('RealURL powered decoding (TM) starting!');
//.........这里部分代码省略.........
示例9: _renderReadOnly
function _renderReadOnly()
{
$sPath = $this->_getPath();
if ($sPath !== FALSE || is_array($this->_navConf("/imageconf/")) && $this->defaultFalse("/imageconf/forcegeneration")) {
$sTag = FALSE;
$aSize = FALSE;
$bExternal = FALSE;
$bReprocess = FALSE;
if (is_array($mConf = $this->_navConf("/imageconf/")) && tx_ameosformidable::isRunneable($mConf)) {
$bReprocess = TRUE;
}
if ($this->oForm->isAbsServerPath($sPath)) {
$sAbsServerPath = $sPath;
$sRelWebPath = $this->oForm->_removeStartingSlash($this->oForm->toRelPath($sAbsServerPath));
$sAbsWebPath = $this->oForm->toWebPath($sRelWebPath);
$sFileName = basename($sRelWebPath);
$aSize = @getImageSize($sAbsServerPath);
} else {
if (!$this->oForm->isAbsWebPath($sPath)) {
// relative web path given
// turn it into absolute web path
$sPath = $this->oForm->toWebPath($sPath);
$aSize = @getImageSize($this->oForm->toServerPath($sPath));
}
// absolute web path
$sAbsWebPath = $sPath;
$aInfosPath = parse_url($sAbsWebPath);
$aInfosFile = t3lib_div::split_fileref($sAbsWebPath);
#debug($aInfosPath);
#debug($aInfosFile);
if (strtolower($aInfosPath["host"]) !== strtolower(t3lib_div::getIndpEnv("TYPO3_HOST_ONLY"))) {
// it's an external image
$bExternal = TRUE;
$sAbsServerPath = "";
if ($bReprocess === TRUE) {
// we have to make a local copy of the image to enable TS processing
$aHeaders = $this->oForm->div_getHeadersForUrl($sAbsWebPath);
if (array_key_exists("ETag", $aHeaders)) {
$sSignature = str_replace(array('"', ",", ":", "-", ".", "/", "\\", " "), "", $aHeaders["ETag"]);
} elseif (array_key_exists("Last-Modified", $aHeaders)) {
$sSignature = str_replace(array('"', ",", ":", "-", ".", "/", "\\", " "), "", $aHeaders["Last-Modified"]);
} elseif (array_key_exists("Content-Length", $aHeaders)) {
$sSignature = $aHeaders["Content-Length"];
}
}
$sTempFileName = $aInfosFile["filebody"] . $aInfosFile["fileext"] . "-" . $sSignature . "." . $aInfosFile["fileext"];
$sTempFilePath = PATH_site . "typo3temp/" . $sTempFileName;
if (!file_exists($sTempFilePath)) {
t3lib_div::writeFileToTypo3tempDir($sTempFilePath, t3lib_div::getUrl($sAbsWebPath));
}
$sAbsServerPath = $sTempFilePath;
$sAbsWebPath = $this->oForm->toWebPath($sAbsServerPath);
$sRelWebPath = $this->oForm->toRelPath($sAbsServerPath);
} else {
// it's an local image given as an absolute web url
// trying to convert pathes to handle the image as a local one
$sAbsServerPath = PATH_site . $this->oForm->_removeStartingSlash($aInfosPath["path"]);
$sRelWebPath = $this->oForm->_removeStartingSlash($aInfosPath["path"]);
}
$sFileName = $aInfosFile["file"];
}
$sRelWebPath = $this->oForm->_removeStartingslash($sRelWebPath);
$sContentAlt = '';
if (($mAlt = $this->_navConf("/alt")) !== FALSE) {
if (tx_ameosformidable::isRunneable($mAlt)) {
$mAlt = $this->callRunneable($mAlt);
}
$sContentAlt = $mAlt;
}
$sAlt = trim($sContentAlt) == '' ? '' : 'alt="' . $sContentAlt . '"';
$aHtmlBag = array("filepath" => $sAbsWebPath, "filepath." => array("rel" => $sRelWebPath, "web" => $this->oForm->toWebPath($this->oForm->toServerPath($sRelWebPath)), "original" => $sAbsWebPath, "original." => array("rel" => $sRelWebPath, "web" => $this->oForm->toWebPath($sAbsServerPath), "server" => $sAbsServerPath)), "filename" => $sFileName, "filename." => array("original" => $sFileName), "alt" => $sContentAlt);
if ($aSize !== FALSE) {
$aHtmlBag["filesize."]["width"] = $aSize[0];
$aHtmlBag["filesize."]["width."]["px"] = $aSize[0] . "px";
$aHtmlBag["filesize."]["height"] = $aSize[1];
$aHtmlBag["filesize."]["height."]["px"] = $aSize[1] . "px";
}
if ($bReprocess === TRUE) {
// require_once(PATH_t3lib . "class.t3lib_stdgraphic.php");
// require_once(PATH_tslib . "class.tslib_gifbuilder.php");
// expecting typoscript
$aParams = array("filename" => $sFileName, "abswebpath" => $sAbsWebPath, "relwebpath" => $sRelWebPath);
if ($this->oForm->oDataHandler->aObjectType["TYPE"] == "LISTER") {
$aParams["row"] = $this->oForm->oDataHandler->__aListData;
} elseif ($this->oForm->oDataHandler->aObjectType["TYPE"] == "DB") {
$aParams["row"] = $this->oForm->oDataHandler->_getStoredData();
}
$this->callRunneable($mConf, $aParams);
$aImage = array_pop($this->oForm->aLastTs);
if ($this->defaultFalse("/imageconf/generatetag") === TRUE) {
$sTag = $GLOBALS["TSFE"]->cObj->IMAGE($aImage);
} else {
$sTag = FALSE;
}
$sNewPath = $GLOBALS["TSFE"]->cObj->IMG_RESOURCE($aImage);
// IMG_RESOURCE always returns relative path
$aHtmlBag["filepath"] = $this->oForm->toWebPath($sNewPath);
$aHtmlBag["filepath."]["rel"] = $sNewPath;
$aHtmlBag["filepath."]["web"] = $this->oForm->toWebPath($this->oForm->toServerPath($sNewPath));
$aHtmlBag["filename"] = basename($sNewPath);
//.........这里部分代码省略.........
示例10: checkValue_group_select_file
//.........这里部分代码省略.........
// This array contains the filenames in the uploadfolder that should be deleted:
foreach ($theFileValues as $key => $theFile) {
$theFile = trim($theFile);
if (@is_file($dest . '/' . $theFile)) {
$this->removeFilesStore[] = $dest . '/' . $theFile;
} elseif ($theFile) {
$this->log($table, $id, 5, 0, 1, "Could not delete file '%s' (does not exist). (%s)", 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
}
}
}
}
// Traverse the submitted values:
foreach ($valueArray as $key => $theFile) {
// NEW FILES? If the value contains '/' it indicates, that the file is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
if (strstr(t3lib_div::fixWindowsFilePath($theFile), '/')) {
// Init:
$maxSize = intval($tcaFieldConf['max_size']);
$cmd = '';
$theDestFile = '';
// Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
// Check various things before copying file:
if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
// File and destination must exist
// Finding size. For safe_mode we have to rely on the size in the upload array if the file is uploaded.
if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
$fileSize = $uploadedFileArray['size'];
} else {
$fileSize = filesize($theFile);
}
if (!$maxSize || $fileSize <= $maxSize * 1024) {
// Check file size:
// Prepare filename:
$theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
$fI = t3lib_div::split_fileref($theEndFileName);
// Check for allowed extension:
if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
$theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
// If we have a unique destination filename, then write the file:
if ($theDestFile) {
t3lib_div::upload_copy_move($theFile, $theDestFile);
// Hook for post-processing the upload action
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
$hookObject = t3lib_div::getUserObj($classRef);
if (!$hookObject instanceof t3lib_TCEmain_processUploadHook) {
throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_processUploadHook', 1279962349);
}
$hookObject->processUpload_postProcessAction($theDestFile, $this);
}
}
$this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache();
if (!@is_file($theDestFile)) {
$this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, 'The destination (%s) or the source file (%s) does not exist. (%s)', 14, array($dest, $theFile, $recFID), $propArr['event_pid']);
示例11: renderFileInfo
/**
* 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;
//.........这里部分代码省略.........
示例12: hookCheckAlternativeIDMethods
/**
* Hook for checking to see if the URL is a speaking URL
*
* Here a .htaccess file maps all .html-files to index.php and
* then we extract the id and type from the name of that HTML-file. (AKA "simulateStaticDocuments")
* Support for RewriteRule to generate (simulateStaticDocuments)
* With the mod_rewrite compiled into apache, put these lines into a .htaccess in this directory:
* RewriteEngine On
* RewriteRule ^[^/]*\.html$ index.php
* The url must end with '.html' and the format must comply with either of these:
* 1: '[title].[id].[type].html' - title is just for easy recognition in the
* logfile!; no practical use of the title for TYPO3.
* 2: '[id].[type].html' - above, but title is omitted; no practical use of
* the title for TYPO3.
* 3: '[id].html' - only id, type is set to the default, zero!
* NOTE: In all case 'id' may be the uid-number OR the page alias (if any)
*
* @param array includes a reference to the parent Object (which is the global TSFE)
* @param tslib_fe is a reference to the global TSFE
* @return void
*/
public function hookCheckAlternativeIDMethods(array &$parameters, tslib_fe &$parentObject)
{
// If there has been a redirect (basically; we arrived here otherwise
// than via "index.php" in the URL)
// this can happend either due to a CGI-script or because of reWrite rule.
// Earlier we used $_SERVER['REDIRECT_URL'] to check
if ($parentObject->siteScript && substr($parentObject->siteScript, 0, 9) != 'index.php') {
$uParts = parse_url($parentObject->siteScript);
$fI = t3lib_div::split_fileref($uParts['path']);
if (!$fI['path'] && $fI['file'] && substr($fI['file'], -5) == '.html') {
$parts = explode('.', $fI['file']);
$pCount = count($parts);
if ($pCount > 2) {
$parentObject->type = intval($parts[$pCount - 2]);
$parentObject->id = $parts[$pCount - 3];
} else {
$parentObject->type = 0;
$parentObject->id = $parts[0];
}
}
}
// If PATH_INFO is defined as simulateStaticDocuments mode and has information:
if (t3lib_div::getIndpEnv('PATH_INFO') && strpos(t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT'), 'index.php/') === 0) {
$parts = t3lib_div::trimExplode('/', t3lib_div::getIndpEnv('PATH_INFO'), true);
$pCount = count($parts);
if ($pCount > 1) {
$parentObject->type = intval($parts[$pCount - 1]);
$parentObject->id = $parts[$pCount - 2];
} else {
$parentObject->type = 0;
$parentObject->id = $parts[0];
}
$parentObject->absRefPrefix_force = 1;
}
}
示例13: checkIfSplitFileRefReturnsFileTypeForFilesWithoutPathSite
/**
* @test
* @see t3lib_div::split_fileref()
*/
public function checkIfSplitFileRefReturnsFileTypeForFilesWithoutPathSite()
{
$testFile = 'fileadmin/media/someFile.png';
$fileInfo = t3lib_div::split_fileref($testFile);
$this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $fileInfo);
$this->assertEquals('fileadmin/media/', $fileInfo['path']);
$this->assertEquals('someFile.png', $fileInfo['file']);
$this->assertEquals('someFile', $fileInfo['filebody']);
$this->assertEquals('png', $fileInfo['fileext']);
}
示例14: setAltfiles
/**
* Sets the alternative files
*
* @return void
*/
public function setAltfiles()
{
$fileInfo = t3lib_div::split_fileref($this->getFile());
/* get mime and duration from provided file */
$this->setMime($this->getFileMime($this->getFile()));
$this->setDuration($this->getFileDuration($this->getFile()));
$altfiles = array();
$altfiles[0] = $this->getFile() . ',' . $this->getMime();
$basepath = $fileInfo['path'] . $fileInfo['filebody'] . '.*';
$files = glob($basepath);
/* search for other files */
for ($i = 0; $i < count($files); $i++) {
if ($files[$i] != $this->getFile()) {
$altfiles[$i + 1] = $files[$i] . ',' . $this->getFileMime($files[$i]);
}
}
$this->altfiles = implode('|', $altfiles);
}
示例15: getUniqueName
/**
* Returns the destination path/filename of a unique filename/foldername in that path.
* If $theFile exists in $theDest (directory) the file have numbers appended up to $this->maxNumber. Hereafter a unique string will be appended.
* This function is used by fx. TCEmain when files are attached to records and needs to be uniquely named in the uploads/* folders
*
* @param string The input filename to check
* @param string The directory for which to return a unique filename for $theFile. $theDest MUST be a valid directory. Should be absolute.
* @param boolean If set the filename is returned with the path prepended without checking whether it already existed!
* @return string The destination absolute filepath (not just the name!) of a unique filename/foldername in that path.
* @see t3lib_TCEmain::checkValue()
*/
function getUniqueName($theFile, $theDest, $dontCheckForUnique = 0)
{
$theDest = $this->is_directory($theDest);
// $theDest is cleaned up
$origFileInfo = t3lib_div::split_fileref($theFile);
// Fetches info about path, name, extention of $theFile
if ($theDest) {
if ($this->getUniqueNamePrefix) {
// Adds prefix
$origFileInfo['file'] = $this->getUniqueNamePrefix . $origFileInfo['file'];
$origFileInfo['filebody'] = $this->getUniqueNamePrefix . $origFileInfo['filebody'];
}
// Check if the file exists and if not - return the filename...
$fileInfo = $origFileInfo;
$theDestFile = $theDest . '/' . $fileInfo['file'];
// The destinations file
if (!file_exists($theDestFile) || $dontCheckForUnique) {
// If the file does NOT exist we return this filename
return $theDestFile;
}
// Well the filename in its pure form existed. Now we try to append numbers / unique-strings and see if we can find an available filename...
$theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filebody']);
// This removes _xx if appended to the file
$theOrigExt = $origFileInfo['realFileext'] ? '.' . $origFileInfo['realFileext'] : '';
for ($a = 1; $a <= $this->maxNumber + 1; $a++) {
if ($a <= $this->maxNumber) {
// First we try to append numbers
$insert = '_' . sprintf('%02d', $a);
} else {
// .. then we try unique-strings...
$insert = '_' . substr(md5(uniqId('')), 0, $this->uniquePrecision);
}
$theTestFile = $theTempFileBody . $insert . $theOrigExt;
$theDestFile = $theDest . '/' . $theTestFile;
// The destinations file
if (!file_exists($theDestFile)) {
// If the file does NOT exist we return this filename
return $theDestFile;
}
}
}
}