当前位置: 首页>>代码示例>>PHP>>正文


PHP GeneralUtility::split_fileref方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::split_fileref方法的具体用法?PHP GeneralUtility::split_fileref怎么用?PHP GeneralUtility::split_fileref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\GeneralUtility的用法示例。


在下文中一共展示了GeneralUtility::split_fileref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 /**
  * Manipulating the input array, $params, adding new selectorbox items.
  *
  * @param	array	$params array of select field options (reference)
  * @param	object	$pObj parent object (reference)
  * @return	void
  */
 function main(&$params, &$pObj)
 {
     // get the current page ID
     $thePageId = $params['row']['pid'];
     /** @var TemplateService $template */
     $template = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
     // do not log time-performance information
     $template->tt_track = 0;
     $template->init();
     /** @var PageRepository $sys_page */
     $sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $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 = GeneralUtility::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 = GeneralUtility::getFilesInDir($readPath, 'tmpl,html,htm', 1, 1);
         /** @var HtmlParser $parseHTML */
         $parseHTML = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser');
         foreach ($template_files as $htmlFilePath) {
             // reset vars
             $selectorBoxItem_title = '';
             $selectorBoxItem_icon = '';
             // read template content
             $content = GeneralUtility::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 = GeneralUtility::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);
         }
     }
 }
开发者ID:scheibome,项目名称:tt_address,代码行数:51,代码来源:AddFilesToSelector.php

示例2: uploadAvatar

 /**
  * Uploads a new avatar to the server.
  * @author  Martin Helmich <m.helmich@mittwald.de>
  * @author  Georg Ringer <typo3@ringerge.org>
  * @version 2007-10-03
  * @param   string $content The plugin content
  * @return  string          The content
  */
 function uploadAvatar($content)
 {
     $avatarFile = $_FILES[$this->prefixId];
     if (isset($this->piVars['del_avatar'])) {
         $this->user->removeAvatar($this->conf['path_avatar']);
         $this->user->updateDatabase();
         return $content;
     }
     $fI = GeneralUtility::split_fileref($avatarFile['name']['file']);
     $fileExt = $fI['fileext'];
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($avatarFile['name']['file']) || !GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExt)) {
         return '';
     }
     if (isset($this->piVars['upload'])) {
         $uploaddir = $this->conf['path_avatar'];
         /*
          * Load the allowed file size for avatar image from the TCA and
          * check against the size of the uploaded image.
          */
         if (filesize($avatarFile['tmp_name']['file']) > $GLOBALS['TCA']['fe_users']['columns']['tx_mmforum_avatar']['config']['max_size'] * 1024) {
             return '';
         }
         $file = $this->user->getUid() . '_' . $GLOBALS['EXEC_TIME'] . '.' . $fileExt;
         $uploadfile = $uploaddir . $file;
         if (GeneralUtility::upload_copy_move($avatarFile['tmp_name']['file'], $uploadfile)) {
             $this->user->setAvatar($file);
             $this->user->updateDatabase();
         }
     }
     return $content;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:39,代码来源:class.tx_mmforum_pi5.php

示例3: getImgResource

 /**
  * Renders the actual image
  *
  * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject
  * @param $file
  * @param array $fileConfiguration
  * @return array
  */
 public function getImgResource(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject, $file, array $fileConfiguration)
 {
     if ($fileConfiguration['import.']) {
         $ifile = $contentObject->stdWrap('', $fileConfiguration['import.']);
         if ($ifile) {
             $file = $fileConfiguration['import'] . $ifile;
         }
     }
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($file)) {
         $file = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory')->getFileObject($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
         $theImage = $file->getForLocalProcessing(FALSE);
     } else {
         // clean ../ sections of the path and resolve to proper string.
         // This is necessary for the \TYPO3\CMS\Core\Resource\Service\FrontendContentAdapterService to work.
         $file = \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($file);
         $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
         if (!$theImage) {
             return array();
         }
     }
     $fileConfiguration = $this->processFileConfiguration($fileConfiguration, $contentObject);
     $maskArray = $fileConfiguration['m.'];
     $maskImages = array();
     // Must render mask images and include in hash-calculating - else we
     // cannot be sure the filename is unique for the setup!
     if (is_array($maskArray)) {
         $maskImages['m_mask'] = $this->getImgResource($contentObject, $maskArray['mask'], $maskArray['mask.']);
         $maskImages['m_bgImg'] = $this->getImgResource($contentObject, $maskArray['bgImg'], $maskArray['bgImg.']);
         $maskImages['m_bottomImg'] = $this->getImgResource($contentObject, $maskArray['bottomImg'], $maskArray['bottomImg.']);
         $maskImages['m_bottomImg_mask'] = $this->getImgResource($contentObject, $maskArray['bottomImg_mask'], $maskArray['bottomImg_mask.']);
     }
     // TODO use \TYPO3\CMS\Core\Resource\FileInterface here
     if ($file instanceof \TYPO3\CMS\Core\Resource\FileReference) {
         $hash = $file->getOriginalFile()->calculateChecksum();
     } else {
         $hash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($theImage . serialize($fileConfiguration) . serialize($maskImages));
     }
     if (isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) {
         return $GLOBALS['TSFE']->tmpl->fileCache[$hash];
     }
     /** @var $gifCreator tslib_gifbuilder */
     $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_gifbuilder');
     $gifCreator->init();
     if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']) {
         $filename = basename($theImage);
         // Remove extension
         $filename = substr($filename, 0, strrpos($filename, '.'));
         $tempFilePrefixLength = intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']);
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
             /** @var $t3libCsInstance \TYPO3\CMS\Core\Charset\CharsetConverter */
             $t3libCsInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
             $filenamePrefix = $t3libCsInstance->substr('utf-8', $filename, 0, $tempFilePrefixLength);
         } else {
             // Strip everything non-ascii
             $filename = preg_replace('/[^A-Za-z0-9_-]/', '', trim($filename));
             $filenamePrefix = substr($filename, 0, $tempFilePrefixLength);
         }
         $gifCreator->filenamePrefix = $filenamePrefix . '_';
         unset($filename);
     }
     if ($fileConfiguration['sample']) {
         $gifCreator->scalecmd = '-sample';
         $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.');
     }
     if ($fileConfiguration['alternativeTempPath'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'], $fileConfiguration['alternativeTempPath'])) {
         $gifCreator->tempPath = $fileConfiguration['alternativeTempPath'];
         $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: ' . $fileConfiguration['alternativeTempPath']);
     }
     if (!trim($fileConfiguration['ext'])) {
         $fileConfiguration['ext'] = 'web';
     }
     $options = array();
     if ($fileConfiguration['maxW']) {
         $options['maxW'] = $fileConfiguration['maxW'];
     }
     if ($fileConfiguration['maxH']) {
         $options['maxH'] = $fileConfiguration['maxH'];
     }
     if ($fileConfiguration['minW']) {
         $options['minW'] = $fileConfiguration['minW'];
     }
     if ($fileConfiguration['minH']) {
         $options['minH'] = $fileConfiguration['minH'];
     }
     if ($fileConfiguration['noScale']) {
         $options['noScale'] = $fileConfiguration['noScale'];
     }
     $fileInformation = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($theImage);
     $imgExt = strtolower($fileInformation['fileext']) == $gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg';
     // If no mask  is used or ImageMagick is disabled, processing is quite simple
//.........这里部分代码省略.........
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:101,代码来源:ImageProcessingService.php

示例4: getUniqueName

 protected function getUniqueName(\TYPO3\CMS\Core\Resource\Folder $folder, $theFile, $dontCheckForUnique = FALSE)
 {
     static $maxNumber = 99, $uniqueNamePrefix = '';
     // Fetches info about path, name, extention of $theFile
     $origFileInfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($theFile);
     // Adds prefix
     if ($uniqueNamePrefix) {
         $origFileInfo['file'] = $uniqueNamePrefix . $origFileInfo['file'];
         $origFileInfo['filebody'] = $uniqueNamePrefix . $origFileInfo['filebody'];
     }
     // Check if the file exists and if not - return the fileName...
     $fileInfo = $origFileInfo;
     // The destinations file
     $theDestFile = $fileInfo['file'];
     // If the file does NOT exist we return this fileName
     if (!$this->driver->fileExistsInFolder($theDestFile, $folder) || $dontCheckForUnique) {
         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
     // This removes _xx if appended to the file
     $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filebody']);
     $theOrigExt = $origFileInfo['realFileext'] ? '.' . $origFileInfo['realFileext'] : '';
     for ($a = 1; $a <= $maxNumber + 1; $a++) {
         // First we try to append numbers
         if ($a <= $maxNumber) {
             $insert = '_' . sprintf('%02d', $a);
         } else {
             // TODO remove constant 6
             $insert = '_' . substr(md5(uniqId('')), 0, 6);
         }
         $theTestFile = $theTempFileBody . $insert . $theOrigExt;
         // The destinations file
         $theDestFile = $theTestFile;
         // If the file does NOT exist we return this fileName
         if (!$this->driver->fileExistsInFolder($theDestFile, $folder)) {
             return $theDestFile;
         }
     }
     throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:41,代码来源:ResourceStorage.php

示例5: filelink

 /**
  * Creates a list of links to files.
  * Implements the stdWrap property "filelink"
  *
  * @param string $theValue The filename to link to, possibly prefixed with $conf[path]
  * @param array $conf TypoScript parameters for the TypoScript function ->filelink
  * @return string The link to the file possibly with icons, thumbnails, size in bytes shown etc.
  * @access private
  * @see stdWrap()
  */
 public function filelink($theValue, $conf)
 {
     $conf['path'] = isset($conf['path.']) ? $this->stdWrap($conf['path'], $conf['path.']) : $conf['path'];
     $theFile = trim($conf['path']) . $theValue;
     if (!@is_file($theFile)) {
         return '';
     }
     $theFileEnc = str_replace('%2F', '/', rawurlencode($theFile));
     $title = $conf['title'];
     if (isset($conf['title.'])) {
         $title = $this->stdWrap($title, $conf['title.']);
     }
     $target = $conf['target'];
     if (isset($conf['target.'])) {
         $target = $this->stdWrap($target, $conf['target.']);
     }
     $tsfe = $this->getTypoScriptFrontendController();
     $typoLinkConf = array('parameter' => $theFileEnc, 'fileTarget' => $target, 'title' => $title, 'ATagParams' => $this->getATagParams($conf));
     if (isset($conf['typolinkConfiguration.'])) {
         $additionalTypoLinkConfiguration = $conf['typolinkConfiguration.'];
         // We only allow additional configuration. This is why the generated conf overwrites the additional conf.
         ArrayUtility::mergeRecursiveWithOverrule($additionalTypoLinkConfiguration, $typoLinkConf);
         $typoLinkConf = $additionalTypoLinkConfiguration;
     }
     $theLinkWrap = $this->typoLink('|', $typoLinkConf);
     $theSize = filesize($theFile);
     $fI = GeneralUtility::split_fileref($theFile);
     $icon = '';
     if ($conf['icon']) {
         $conf['icon.']['path'] = isset($conf['icon.']['path.']) ? $this->stdWrap($conf['icon.']['path'], $conf['icon.']['path.']) : $conf['icon.']['path'];
         $iconP = !empty($conf['icon.']['path']) ? $conf['icon.']['path'] : ExtensionManagementUtility::siteRelPath('frontend') . 'Resources/Public/Icons/FileIcons/';
         $conf['icon.']['ext'] = isset($conf['icon.']['ext.']) ? $this->stdWrap($conf['icon.']['ext'], $conf['icon.']['ext.']) : $conf['icon.']['ext'];
         $iconExt = !empty($conf['icon.']['ext']) ? '.' . $conf['icon.']['ext'] : '.gif';
         $icon = @is_file($iconP . $fI['fileext'] . $iconExt) ? $iconP . $fI['fileext'] . $iconExt : $iconP . 'default' . $iconExt;
         // Checking for images: If image, then return link to thumbnail.
         $IEList = isset($conf['icon_image_ext_list.']) ? $this->stdWrap($conf['icon_image_ext_list'], $conf['icon_image_ext_list.']) : $conf['icon_image_ext_list'];
         $image_ext_list = str_replace(' ', '', strtolower($IEList));
         if ($fI['fileext'] && GeneralUtility::inList($image_ext_list, $fI['fileext'])) {
             if ($conf['iconCObject']) {
                 $icon = $this->cObjGetSingle($conf['iconCObject'], $conf['iconCObject.'], 'iconCObject');
             } else {
                 $notFoundThumb = ExtensionManagementUtility::extPath('core') . 'Resources/Public/Images/NotFound.gif';
                 $sizeParts = array(64, 64);
                 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
                     // using the File Abstraction Layer to generate a preview image
                     try {
                         /** @var File $fileObject */
                         $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($theFile);
                         if ($fileObject->isMissing()) {
                             $icon = $notFoundThumb;
                         } else {
                             $fileExtension = $fileObject->getExtension();
                             if ($fileExtension === 'ttf' || GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
                                 if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.']) {
                                     $thumbSize = isset($conf['icon_thumbSize.']) ? $this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']) : $conf['icon_thumbSize'];
                                     $sizeParts = explode('x', $thumbSize);
                                 }
                                 $icon = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => $sizeParts[0], 'height' => $sizeParts[1]))->getPublicUrl(true);
                             }
                         }
                     } catch (ResourceDoesNotExistException $exception) {
                         $icon = $notFoundThumb;
                     }
                 } else {
                     $icon = $notFoundThumb;
                 }
                 $urlPrefix = '';
                 if (parse_url($icon, PHP_URL_HOST) === null) {
                     $urlPrefix = $tsfe->absRefPrefix;
                 }
                 $icon = '<img src="' . htmlspecialchars($urlPrefix . $icon) . '"' . 'width="' . (int) $sizeParts[0] . '" height="' . (int) $sizeParts[1] . '" ' . $this->getBorderAttr(' border="0"') . '' . $this->getAltParam($conf) . ' />';
             }
         } else {
             $conf['icon.']['widthAttribute'] = isset($conf['icon.']['widthAttribute.']) ? $this->stdWrap($conf['icon.']['widthAttribute'], $conf['icon.']['widthAttribute.']) : $conf['icon.']['widthAttribute'];
             $iconWidth = !empty($conf['icon.']['widthAttribute']) ? $conf['icon.']['widthAttribute'] : 18;
             $conf['icon.']['heightAttribute'] = isset($conf['icon.']['heightAttribute.']) ? $this->stdWrap($conf['icon.']['heightAttribute'], $conf['icon.']['heightAttribute.']) : $conf['icon.']['heightAttribute'];
             $iconHeight = !empty($conf['icon.']['heightAttribute']) ? (int) $conf['icon.']['heightAttribute'] : 16;
             $icon = '<img src="' . htmlspecialchars($tsfe->absRefPrefix . $icon) . '" width="' . (int) $iconWidth . '" height="' . (int) $iconHeight . '"' . $this->getBorderAttr(' border="0"') . $this->getAltParam($conf) . ' />';
         }
         if ($conf['icon_link'] && !$conf['combinedLink']) {
             $icon = $this->wrap($icon, $theLinkWrap);
         }
         $icon = isset($conf['icon.']) ? $this->stdWrap($icon, $conf['icon.']) : $icon;
     }
     $size = '';
     if ($conf['size']) {
         $size = isset($conf['size.']) ? $this->stdWrap($theSize, $conf['size.']) : $theSize;
     }
     // Wrapping file label
     if ($conf['removePrependedNumbers']) {
//.........这里部分代码省略.........
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:101,代码来源:ContentObjectRenderer.php

示例6: getFileName

 /**
  * Returns the reference to a 'resource' in TypoScript.
  * This could be from the filesystem if '/' is found in the value $fileFromSetup, else from the resource-list
  *
  * @param string $fileFromSetup TypoScript "resource" data type value.
  * @return string Resulting filename, if any.
  * @todo Define visibility
  */
 public function getFileName($fileFromSetup)
 {
     $file = trim($fileFromSetup);
     if (!$file) {
         return;
     } elseif (strstr($file, '../')) {
         if ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('File path "' . $file . '" contained illegal string "../"!', 3);
         }
         return;
     }
     // Cache
     $hash = md5($file);
     if (isset($this->fileCache[$hash])) {
         return $this->fileCache[$hash];
     }
     if (substr($file, 0, 4) === 'EXT:') {
         $newFile = '';
         list($extKey, $script) = explode('/', substr($file, 4), 2);
         if ($extKey && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
             $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey);
             $newFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($extPath) . $script;
         }
         if (!@file_exists(PATH_site . $newFile)) {
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('Extension media file "' . $newFile . '" was not found!', 3);
             }
             return;
         } else {
             $file = $newFile;
         }
     }
     // if this is an URL, it can be returned directly
     $urlScheme = parse_url($file, PHP_URL_SCHEME);
     if ($urlScheme === 'https' || $urlScheme === 'http' || is_file(PATH_site . $file)) {
         return $file;
     }
     // Find
     if (strpos($file, '/') !== FALSE) {
         // If the file is in the media/ folder but it doesn't exist,
         // it is assumed that it's in the tslib folder
         if (GeneralUtility::isFirstPartOfStr($file, 'media/') && !file_exists($this->getFileName_backPath . $file)) {
             $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('cms') . 'tslib/' . $file;
         }
         if (file_exists($this->getFileName_backPath . $file)) {
             $outFile = $file;
             $fileInfo = GeneralUtility::split_fileref($outFile);
             $OK = 0;
             foreach ($this->allowedPaths as $val) {
                 if (substr($fileInfo['path'], 0, strlen($val)) == $val) {
                     $OK = 1;
                     break;
                 }
             }
             if ($OK) {
                 $this->fileCache[$hash] = $outFile;
                 return $outFile;
             } elseif ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('"' . $file . '" was not located in the allowed paths: (' . implode(',', $this->allowedPaths) . ')', 3);
             }
         } elseif ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('"' . $this->getFileName_backPath . $file . '" is not a file (non-uploads/.. resource, did not exist).', 3);
         }
     }
 }
开发者ID:rob-ot-dot-be,项目名称:ggallkeysecurity,代码行数:73,代码来源:TemplateService.php

示例7: IMreduceColors

 /**
  * Reduce colors in image using IM and create a palette based image if possible (<=256 colors)
  *
  * @param string $file Image file to reduce
  * @param int $cols Number of colors to reduce the image to.
  * @return string Reduced file
  */
 public function IMreduceColors($file, $cols)
 {
     $fI = GeneralUtility::split_fileref($file);
     $ext = strtolower($fI['fileext']);
     $result = $this->randomName() . '.' . $ext;
     $reduce = MathUtility::forceIntegerInRange($cols, 0, $ext == 'gif' ? 256 : $this->truecolorColors, 0);
     if ($reduce > 0) {
         $params = ' -colors ' . $reduce;
         if ($reduce <= 256) {
             $params .= ' -type Palette';
         }
         $prefix = $ext === 'png' && $reduce <= 256 ? 'png8:' : '';
         $this->imageMagickExec($file, $prefix . $result, $params);
         if ($result) {
             return $result;
         }
     }
     return '';
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:26,代码来源:GraphicalFunctions.php

示例8: checkValue_group_select_file


//.........这里部分代码省略.........
                             $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) {
                 // Init:
                 $maxSize = (int) $tcaFieldConf['max_size'];
                 // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                 $theDestFile = '';
                 // a FAL file was added, now resolve the file object and get the absolute path
                 // @todo in future versions this needs to be modified to handle FAL objects natively
                 if (!empty($theFile) && MathUtility::canBeInterpretedAsInteger($theFile)) {
                     $fileObject = ResourceFactory::getInstance()->getFileObject($theFile);
                     $theFile = $fileObject->getForLocalProcessing(false);
                 }
                 // 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(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
                     // Check various things before copying file:
                     // File and destination must exist
                     if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
                         // Finding size.
                         if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
                             $fileSize = $uploadedFileArray['size'];
                         } else {
                             $fileSize = filesize($theFile);
                         }
                         // Check file size:
                         if (!$maxSize || $fileSize <= $maxSize * 1024) {
                             // Prepare filename:
                             $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                             $fI = GeneralUtility::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) {
                                     GeneralUtility::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 = GeneralUtility::getUserObj($classRef);
                                             if (!$hookObject instanceof DataHandlerProcessUploadHookInterface) {
                                                 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\DataHandling\\DataHandlerProcessUploadHookInterface', 1279962349);
                                             }
                                             $hookObject->processUpload_postProcessAction($theDestFile, $this);
                                         }
                                     }
                                     $this->copiedFileMap[$theFile] = $theDestFile;
                                     clearstatcache();
                                     if ($this->enableLogging && !@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']);
                                     }
                                 } elseif ($this->enableLogging) {
                                     $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']);
                                 }
                             } elseif ($this->enableLogging) {
                                 $this->log($table, $id, 5, 0, 1, 'File extension \'%s\' not allowed. (%s)', 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                             }
                         } elseif ($this->enableLogging) {
                             $this->log($table, $id, 5, 0, 1, 'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(GeneralUtility::formatSize($fileSize), $theFile, GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                         }
                     } elseif ($this->enableLogging) {
                         $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']);
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:67,代码来源:DataHandler.php

示例9: main

 /**
  * The main processing method if this class
  *
  * @return string Information of the template status or the taken actions as HTML string
  * @todo Define visibility
  */
 public function main()
 {
     global $BACK_PATH;
     global $tmpl, $tplRow, $theConstants;
     $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE;
     $edit = $this->pObj->edit;
     $e = $this->pObj->e;
     \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_template');
     // Checking for more than one template an if, set a menu...
     $manyTemplatesMenu = $this->pObj->templateMenu();
     $template_uid = 0;
     if ($manyTemplatesMenu) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     // Initialize
     $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
     if ($existTemplate) {
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
     }
     // Create extension template
     $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
     if ($newId) {
         // Switch to new template
         $urlParameters = array('id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId);
         $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
         \TYPO3\CMS\Core\Utility\HttpUtility::redirect($aHref);
     }
     if ($existTemplate) {
         // Update template ?
         $POST = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();
         if ($POST['submit'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_y']) || $POST['saveclose'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) {
             // Set the data to be saved
             $recData = array();
             $alternativeFileName = array();
             $tmp_upload_name = '';
             // Set this to blank
             $tmp_newresource_name = '';
             if (is_array($POST['data'])) {
                 foreach ($POST['data'] as $field => $val) {
                     switch ($field) {
                         case 'constants':
                         case 'config':
                         case 'title':
                         case 'sitetitle':
                         case 'description':
                             $recData['sys_template'][$saveId][$field] = $val;
                             break;
                     }
                 }
             }
             if (count($recData)) {
                 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
                 // Create new  tce-object
                 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                 $tce->stripslashes_values = 0;
                 $tce->alternativeFileName = $alternativeFileName;
                 // Initialize
                 $tce->start($recData, array());
                 // Saved the stuff
                 $tce->process_datamap();
                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                 $tce->clear_cacheCmd('all');
                 // tce were processed successfully
                 $this->tce_processed = TRUE;
                 // re-read the template ...
                 $this->initialize_editor($this->pObj->id, $template_uid);
             }
             // If files has been edited:
             if (is_array($edit)) {
                 if ($edit['filename'] && $tplRow['resources'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($tplRow['resources'], $edit['filename'])) {
                     // Check if there are resources, and that the file is in the resourcelist.
                     $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                     $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($edit['filename']);
                     if (@is_file($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, $fI['fileext'])) {
                         // checks that have already been done.. Just to make sure
                         // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                         // Checks that have already been done.. Just to make sure
                         if (filesize($path) < 30720) {
                             \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($path, $edit['file']);
                             $theOutput .= $this->pObj->doc->spacer(10);
                             $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                             // Clear cache - the file has probably affected the template setup
                             // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                             /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
                             $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                             $tce->stripslashes_values = 0;
                             $tce->start(array(), array());
                             $tce->clear_cacheCmd('all');
                         }
                     }
                 }
             }
         }
         // Hook	post updating template/TCE processing
//.........这里部分代码省略.........
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:101,代码来源:TypoScriptTemplateInformationModuleFunctionController.php

示例10: getUniqueName

 /**
  * Get unique/non-existing filename out of a relative path
  *        func. replace \TYPO3\CMS\Core\Utility\File\BasicFileUtility::getUniqueName()
  *        with endless limit for appending numbers
  *
  * @param string $filename
  * @param string $destinationPath Relative Path to destination
  * @param bool $addPath
  * @param bool $randomized
  * @return string new filename or filenameAndPath
  */
 public static function getUniqueName($filename, $destinationPath, $addPath = true, $randomized = false)
 {
     self::cleanFileName($filename);
     self::getAndSetRandomizedFileName($filename, $randomized);
     $absoluteDestination = self::getAbsoluteFolder($destinationPath);
     $fileInfo = GeneralUtility::split_fileref($filename);
     $newFileName = $filename;
     $newPathAndFileName = $absoluteDestination . $fileInfo['file'];
     if (file_exists($newPathAndFileName)) {
         $theTempFileBody = self::removeAppendingNumbersInString($fileInfo['filebody']);
         $extension = $fileInfo['realFileext'] ? '.' . $fileInfo['realFileext'] : '';
         for ($a = 1; true; $a++) {
             $appendix = '_' . sprintf('%02d', $a);
             $newFileName = $theTempFileBody . $appendix . $extension;
             $newPathAndFileName = $absoluteDestination . $newFileName;
             if (!file_exists($newPathAndFileName)) {
                 break;
             }
         }
     }
     if ($addPath) {
         return $newPathAndFileName;
     }
     return $newFileName;
 }
开发者ID:VladStawizki,项目名称:ipl-logistik.de,代码行数:36,代码来源:BasicFileUtility.php

示例11: convertFrom

 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\CMS\Extbase\Error\Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  *
  * @return mixed|\TYPO3\CMS\Extbase\Error\Error the target type, or an error object if a user-error occurred
  *
  * @throws \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException thrown in case a developer error occurred
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     /** @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $alreadyPersistedImage */
     $alreadyPersistedImage = $configuration->getConfigurationValue('JWeiland\\Clubdirectory\\Property\\TypeConverter\\UploadOneFileConverter', 'IMAGE');
     // if no file was uploaded use the already persisted one
     if (!isset($source['error']) || !isset($source['name']) || !isset($source['size']) || !isset($source['tmp_name']) || !isset($source['type']) || $source['error'] === 4) {
         return $alreadyPersistedImage;
     }
     // check if uploaded file returns an error
     if ($source['error'] !== 0) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.upload', 'clubdirectory') . $source['error'], 1396957314);
     }
     // now we have a valid uploaded file. Check if user has rights to upload this file
     if (!isset($source['rights']) || empty($source['rights'])) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.uploadRights', 'clubdirectory'), 1397464390);
     }
     // check if file extension is allowed
     $fileParts = GeneralUtility::split_fileref($source['name']);
     if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileParts['fileext'])) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.fileExtension', 'clubdirectory', array($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])), 1402981282);
     }
     // before uploading the new file we should remove the old one
     if ($alreadyPersistedImage instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
         $alreadyPersistedImage->getOriginalResource()->delete();
     }
     return $this->getExtbaseFileReference($source);
 }
开发者ID:jweiland-net,项目名称:clubdirectory,代码行数:47,代码来源:UploadOneFileConverter.php

示例12: 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 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?&param1=value1&param2=value2"
         // should be the result of the URL
         // "http://localhost/typo3/dev/dummy_1/first/second/third/index.html?&param1=value1&param2=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);
                 \TYPO3\CMS\Core\Utility\GeneralUtility::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 = \TYPO3\CMS\Core\Utility\GeneralUtility::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.1 ' . $code . ' TYPO3 RealURL redirect M' . __LINE__;
                             // 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: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::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 = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($speakingURIpath);
         if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($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
             /** @noinspection PhpUndefinedMethodInspection */
             $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!');
             // Parse path
             $uParts = @parse_url($speakingURIpath);
             if (!is_array($uParts)) {
                 $this->decodeSpURL_throw404('Current URL is invalid');
             }
             $speakingURIpath = $this->speakingURIpath_procValue = $uParts['path'];
             // Redirecting if needed (exits if so).
             $this->decodeSpURL_checkRedirects($speakingURIpath);
             // Looking for cached information
             $cachedInfo = $this->decodeSpURL_decodeCache($speakingURIpath);
             // If no cached info was found, create it
             if (!is_array($cachedInfo)) {
//.........这里部分代码省略.........
开发者ID:smichaelsen,项目名称:realurl,代码行数:101,代码来源:UrlRewritingHook.php

示例13: getFileMarker

 protected function getFileMarker($marker, &$template, &$sims, &$rems)
 {
     if (!$this->isAllowed($marker)) {
         return;
     }
     $max = $GLOBALS['TCA']['tx_cal_' . $this->objectString]['columns'][$marker]['config']['maxitems'];
     $sims['###' . strtoupper($marker) . '###'] = '';
     $sims['###' . strtoupper($marker) . '_VALUE###'] = '';
     $sims['###' . strtoupper($marker) . '_CAPTION###'] = '';
     $sims['###' . strtoupper($marker) . '_CAPTION_VALUE###'] = '';
     if ($this->isConfirm) {
         $sims['###' . strtoupper($marker) . '###'] = '';
         $fileFunc = new \TYPO3\CMS\Core\Utility\File\BasicFileUtility();
         $all_files = array();
         $all_files['webspace']['allow'] = '*';
         $all_files['webspace']['deny'] = '';
         $fileFunc->init('', $all_files);
         $allowedExt = array();
         $denyExt = array();
         if ($marker == 'image') {
             $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']);
         } else {
             if ($marker == 'attachment') {
                 $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow']);
                 $denyExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny']);
             }
         }
         $i = 0;
         // new files
         if (is_array($_FILES[$this->prefixId]['name'])) {
             foreach ($_FILES[$this->prefixId]['name'][$marker] as $id => $filename) {
                 $theDestFile = '';
                 $iConf = $this->conf['view.'][$this->conf['view'] . '.'][strtolower($marker) . '_stdWrap.'];
                 if ($_FILES[$this->prefixId]['error'][$marker][$id]) {
                     continue;
                 } else {
                     $theFile = GeneralUtility::upload_to_tempfile($_FILES[$this->prefixId]['tmp_name'][$marker][$id]);
                     $fI = GeneralUtility::split_fileref($filename);
                     if (in_array($fI['fileext'], $denyExt)) {
                         continue;
                     } else {
                         if ($marker == 'image' && !in_array($fI['fileext'], $allowedExt)) {
                             continue;
                         }
                     }
                     $theDestFile = $fileFunc->getUniqueName($fileFunc->cleanFileName($fI['file']), 'typo3temp');
                     GeneralUtility::upload_copy_move($theFile, $theDestFile);
                     $iConf['file'] = $theDestFile;
                     $return = '__NEW__' . basename($theDestFile);
                 }
                 $temp_sims = array();
                 $temp_sims['###INDEX###'] = $id;
                 $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $return;
                 $temp = '';
                 if ($marker == 'image') {
                     $temp = $this->renderImage($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true);
                 } else {
                     if ($marker == 'attachment' || $marker == 'ics_file') {
                         $temp = $this->renderFile($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true);
                     }
                 }
                 if ($this->isAllowed($marker . '_caption')) {
                     $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_caption'][$id], $marker . '_caption_stdWrap');
                 }
                 if ($this->isAllowed($marker . '_title')) {
                     $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_title'][$id], $marker . '_title_stdWrap');
                 }
                 $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
                 $i++;
             }
         }
         $removeFiles = $this->controller->piVars['remove_' . $marker] ? $this->controller->piVars['remove_' . $marker] : array();
         $where = 'uid_foreign = ' . $this->conf['uid'] . ' AND  tablenames=\'tx_cal_' . $this->objectString . '\' AND fieldname=\'' . $marker . '\' AND deleted=0';
         if (!empty($removeFiles)) {
             $where .= ' AND uid not in (' . implode(',', array_values($removeFiles)) . ')';
         }
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_file_reference', $where);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             if ($marker == 'image') {
                 $temp = $this->renderImage($row, $row['description'], $row['title'], $marker, false);
             } else {
                 if ($marker == 'attachment' || $marker == 'ics_file') {
                     $temp = $this->renderFile($row, $row['description'], $row['title'], $marker, false);
                 }
             }
             $temp_sims = array();
             $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $row['uid'];
             foreach ($this->controller->piVars[$marker] as $index => $image) {
                 if ($image == $row['uid']) {
                     if (isset($this->controller->piVars[$marker . '_caption'][$index])) {
                         $row['description'] = $this->controller->piVars[$marker . '_caption'][$index];
                     }
                     if (isset($this->controller->piVars[$marker . '_title'][$index])) {
                         $row['title'] = $this->controller->piVars[$marker . '_title'][$index];
                     }
                     $temp_sims['###INDEX###'] = $index;
                     break;
                 }
             }
             if ($this->isAllowed($marker . '_caption')) {
//.........这里部分代码省略.........
开发者ID:ulrikkold,项目名称:cal,代码行数:101,代码来源:FeEditingBaseView.php

示例14: convertFrom

 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\CMS\Extbase\Error\Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  *
  * @return mixed|\TYPO3\CMS\Extbase\Error\Error the target type, or an error object if a user-error occurred
  *
  * @throws \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException thrown in case a developer error occurred
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     $alreadyPersistedImages = $configuration->getConfigurationValue('JWeiland\\Clubdirectory\\Property\\TypeConverter\\UploadMultipleFilesConverter', 'IMAGES');
     $originalSource = $source;
     foreach ($originalSource as $key => $uploadedFile) {
         // check if $source contains an uploaded file. 4 = no file uploaded
         if (!isset($uploadedFile['error']) || !isset($uploadedFile['name']) || !isset($uploadedFile['size']) || !isset($uploadedFile['tmp_name']) || !isset($uploadedFile['type']) || $uploadedFile['error'] === 4) {
             if ($alreadyPersistedImages[$key] !== null) {
                 $source[$key] = $alreadyPersistedImages[$key];
             } else {
                 unset($source[$key]);
             }
             continue;
         }
         // check if uploaded file returns an error
         if (!$uploadedFile['error'] === 0) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.upload', 'clubdirectory') . $uploadedFile['error'], 1396957314);
         }
         // now we have a valid uploaded file. Check if user has rights to upload this file
         if (!isset($uploadedFile['rights']) || empty($uploadedFile['rights'])) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.uploadRights', 'clubdirectory'), 1397464390);
         }
         // check if file extension is allowed
         $fileParts = GeneralUtility::split_fileref($uploadedFile['name']);
         if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileParts['fileext'])) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.fileExtension', 'clubdirectory', array($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])), 1402981282);
         }
         // OK...we have a valid file and the user has the rights. It's time to check, if an old file can be deleted
         if ($alreadyPersistedImages[$key] instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
             /** @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $oldFile */
             $oldFile = $alreadyPersistedImages[$key];
             $oldFile->getOriginalResource()->getOriginalFile()->delete();
         }
     }
     // I will do two foreach here. First: everything must be OK, before files will be uploaded
     // upload file and add it to ObjectStorage
     /** @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage $references */
     $references = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
     foreach ($source as $uploadedFile) {
         if ($uploadedFile instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
             $references->attach($uploadedFile);
         } else {
             $references->attach($this->getExtbaseFileReference($uploadedFile));
         }
     }
     return $references;
 }
开发者ID:jweiland-net,项目名称:clubdirectory,代码行数:67,代码来源:UploadMultipleFilesConverter.php

示例15: getLinkLabel

 /**
  * This method returns the label for a specified URL.
  * If the page is local and contains a fragment it returns the label of the content element linked to.
  * In any other case it simply fetches the page and extracts the <title> tag content as label
  *
  * @param string $url The statistics click-URL for which to return a label
  * @param string $urlStr  A processed variant of the url string. This could get appended to the label???
  * @param bool $forceFetch When this parameter is set to true the "fetch and extract <title> tag" method will get used
  * @param string $linkedWord The word to be linked
  *
  * @return string The label for the passed $url parameter
  */
 function getLinkLabel($url, $urlStr, $forceFetch = false, $linkedWord = '')
 {
     $pathSite = $this->getBaseURL();
     $label = $linkedWord;
     $contentTitle = '';
     $urlParts = parse_url($url);
     if (!$forceFetch && substr($url, 0, strlen($pathSite)) === $pathSite) {
         if ($urlParts['fragment'] && substr($urlParts['fragment'], 0, 1) == 'c') {
             // linking directly to a content
             $elementUid = intval(substr($urlParts['fragment'], 1));
             $row = BackendUtility::getRecord('tt_content', $elementUid);
             if ($row) {
                 $contentTitle = BackendUtility::getRecordTitle('tt_content', $row, false, true);
             }
         } else {
             $contentTitle = $this->getLinkLabel($url, $urlStr, true);
         }
     } else {
         if (empty($urlParts['host']) && substr($url, 0, strlen($pathSite)) !== $pathSite) {
             // it's internal
             $url = $pathSite . $url;
         }
         $content = GeneralUtility::getURL($url);
         if (preg_match('/\\<\\s*title\\s*\\>(.*)\\<\\s*\\/\\s*title\\s*\\>/i', $content, $matches)) {
             // get the page title
             $contentTitle = GeneralUtility::fixed_lgd_cs(trim($matches[1]), 50);
         } else {
             // file?
             $file = GeneralUtility::split_fileref($url);
             $contentTitle = $file['file'];
         }
     }
     if ($this->params['showContentTitle'] == 1) {
         $label = $contentTitle;
     }
     if ($this->params['prependContentTitle'] == 1) {
         $label = $contentTitle . ' (' . $linkedWord . ')';
     }
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['directmail']['getLinkLabel'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['directmail']['getLinkLabel'] as $funcRef) {
             $params = array('pObj' => &$this, 'url' => $url, 'urlStr' => $urlStr, 'label' => $label);
             $label = GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     if (isset($this->params['maxLabelLength']) && $this->params['maxLabelLength'] > 0) {
         $label = GeneralUtility::fixed_lgd_cs($label, $this->params['maxLabelLength']);
     }
     return $label;
 }
开发者ID:Teddytrombone,项目名称:direct_mail,代码行数:61,代码来源:Statistics.php


注:本文中的TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。