/** * Constructor. * * @param Tx_Solr_Query $query Solr query */ public function __construct(Tx_Solr_Query $query) { $this->solrConfiguration = Tx_Solr_Util::getSolrConfiguration(); $this->contentObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $this->query = $query; $targetPageUid = $this->contentObject->stdWrap($this->solrConfiguration['search.']['targetPage'], $this->solrConfiguration['search.']['targetPage.']); $this->linkTargetPageId = $targetPageUid; if (empty($this->linkTargetPageId)) { $this->linkTargetPageId = $GLOBALS['TSFE']->id; } }
/** * Converts a given unix timestamp to a human readable date * * @param array $arguments * @return string */ public function execute(array $arguments = array()) { $content = ''; if (count($arguments) > 1) { $this->dateFormat['date'] = $arguments[1]; } if (is_numeric($arguments[0])) { $content = $this->contentObject->stdWrap($arguments[0], $this->dateFormat); } return $content; }
/** * Converts a given unix timestamp to a human readable date * * @param array $arguments * @return string */ public function execute(array $arguments = array()) { $content = ''; if (count($arguments) > 1) { $this->dateFormat = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['general.']['dateFormat.']; $this->dateFormat['date'] = $arguments[1]; } if (is_numeric($arguments[0])) { $content = $this->contentObject->stdWrap($arguments[0], $this->dateFormat); } return $content; }
/** * Recursively looks for stdWrap and executes it * * @param array $conf Current section of configuration to work on * @param int $level Current level being processed (currently just for tracking; no limit enforced) * @return array Current section of configuration after stdWrap applied */ protected function applyStdWrapRecursive(array $conf, $level = 0) { foreach ($conf as $key => $confNextLevel) { if (strpos($key, '.') !== FALSE) { $key = substr($key, 0, -1); // descend into all non-stdWrap-subelements first foreach ($confNextLevel as $subKey => $subConfNextLevel) { if (is_array($subConfNextLevel) && strpos($subKey, '.') !== FALSE && $subKey !== 'stdWrap.') { $conf[$key . '.'] = $this->applyStdWrapRecursive($confNextLevel, $level + 1); } } // now for stdWrap foreach ($confNextLevel as $subKey => $subConfNextLevel) { if (is_array($subConfNextLevel) && $subKey === 'stdWrap.') { $conf[$key] = $this->cObj->stdWrap($conf[$key], $conf[$key . '.']['stdWrap.']); unset($conf[$key . '.']['stdWrap.']); if (empty($conf[$key . '.'])) { unset($conf[$key . '.']); } } } } } return $conf; }
/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * Convert FORM to COA_INT - COA_INT.10 = FORM_INT * If FORM_INT is also dedected by the ContentObjectRenderer, and now * the Extbaseplugin "Form" is initalized. At this time the * controller "Frontend" action "execute" do the rest. * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject) { $content = ''; if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { $mergedTypoScript = null; if ($contentObject->data['CType'] === 'mailform') { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser TypoScriptParser */ $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); // Disables content elements since TypoScript is handled that could contain insecure settings: $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true; } $newTypoScript = array('10' => 'FORM_INT', '10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript); $content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } elseif ($typoScriptObjectName === 'FORM_INT') { $extbase = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class); $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $typoScript), 'persistence' => array(), 'view' => array())); } return $content; }
/** * Merge all TypoScript for the typoLink from the global and local defined settings. * * @param array $linkConfigurationArray Global defined TypoScript cofiguration for the linkHandler * @param array $typoLinkConfigurationArray Local typolink TypoScript configuration for current link * @param string $recordTableName The name of database table * @access protected * @return array */ protected function mergeTypoScript(array $linkConfigurationArray, array $typoLinkConfigurationArray, $recordTableName) { // pre-compile the "additionalParams" $linkConfigurationArray[$recordTableName . '.']['additionalParams'] = $this->localContentObject->stdWrap($linkConfigurationArray[$recordTableName . '.']['additionalParams'], $linkConfigurationArray[$recordTableName . '.']['additionalParams.']); unset($linkConfigurationArray[$recordTableName . '.']['additionalParams.']); if (version_compare(TYPO3_version, '6.2.0', '<')) { $mergeLinkConfigurationArray = \TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($linkConfigurationArray[$recordTableName . '.']['additionalParams']); \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergeLinkConfigurationArray, \TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($typoLinkConfigurationArray['additionalParams'])); } else { $mergeLinkConfigurationArray = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($linkConfigurationArray[$recordTableName . '.']['additionalParams']), \TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($typoLinkConfigurationArray['additionalParams'])); } // merge recursive the "additionalParams" from "$typoScriptConfiguration" with the "$typoLinkConfigurationArray" if (array_key_exists('additionalParams', $typoLinkConfigurationArray)) { $typoLinkConfigurationArray['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $mergeLinkConfigurationArray); } /** * @internal Merge the linkhandler configuration from $typoScriptConfiguration with the current $typoLinkConfiguration. */ if (is_array($typoLinkConfigurationArray) && !empty($typoLinkConfigurationArray)) { if (array_key_exists('parameter.', $typoLinkConfigurationArray)) { unset($typoLinkConfigurationArray['parameter.']); } $linkConfigurationArray[$recordTableName . '.'] = array_merge($linkConfigurationArray[$recordTableName . '.'], $typoLinkConfigurationArray); } return $linkConfigurationArray[$recordTableName . '.']; }
/** * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context. * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * * @param string $content The content to which the edit icons should be appended * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController * @param array $conf TypoScript properties for configuring the edit icons. * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param array $dataArr Alternative data array to use. Default is $this->data * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController * @param string $table * @param int $editUid * @param string $fieldList * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. */ public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList) { // Special content is about to be shown, so the cache must be disabled. $this->frontendController->set_no_cache('Display frontend edit icons', TRUE); $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $optionsArray = array('title' => htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', FALSE), 'class' => 'frontEndEditIcons', 'style' => $conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : ''); $iconImg = $conf['iconImg'] ? $conf['iconImg'] : IconUtility::getSpriteIcon('actions-document-open', $optionsArray); $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; $url = BackendUtility::getModuleUrl('record_edit', array('edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV)) . $addUrlParamStr; $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url); if ($conf['beforeLastTag'] < 0) { $content = $icon . $content; } elseif ($conf['beforeLastTag'] > 0) { $cBuf = rtrim($content); $secureCount = 30; while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $secureCount--; } $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); } else { $content .= $icon; } return $content; }
/** * @test */ public function recursiveStdWrapIsOnlyCalledOnce() { $stdWrapConfiguration = array( 'append' => 'TEXT', 'append.' => array( 'data' => 'register:Counter' ), 'stdWrap.' => array( 'append' => 'LOAD_REGISTER', 'append.' => array( 'Counter.' => array( 'prioriCalc' => 'intval', 'cObject' => 'TEXT', 'cObject.' => array( 'data' => 'register:Counter', 'wrap' => '|+1', ) ) ) ) ); $this->assertSame( 'Counter:1', $this->subject->stdWrap('Counter:', $stdWrapConfiguration) ); }
/** * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context. * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * * @param string $content The content to which the edit icons should be appended * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php * @param array $conf TypoScript properties for configuring the edit icons. * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param array $dataArr Alternative data array to use. Default is $this->data * @param string $addUrlParamStr Additional URL parameters for the link pointing to alt_doc.php * @param string $table * @param integer $editUid * @param string $fieldList * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. */ public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList) { // Special content is about to be shown, so the cache must be disabled. $GLOBALS['TSFE']->set_no_cache(); $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : ''; $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit_fe.gif', 'width="11" height="12" border="0" align="top" ') . ' title="' . \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($iconTitle)) . '"' . $style . ' class="frontEndEditIcons" alt="" />'; $nV = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; $adminURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir; $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL . 'alt_doc.php?edit[' . $table . '][' . $editUid . ']=edit&columnsOnly=' . rawurlencode($fieldList) . '&noView=' . $nV . $addUrlParamStr, $currentRecord); if ($conf['beforeLastTag'] < 0) { $content = $icon . $content; } elseif ($conf['beforeLastTag'] > 0) { $cBuf = rtrim($content); $securCount = 30; while ($securCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $securCount--; } $content = strlen($cBuf) && $securCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); } else { $content .= $icon; } return $content; }
/** * Constructor. * * @param Query $query Solr query */ public function __construct(Query $query) { $this->solrConfiguration = Util::getSolrConfiguration(); $this->contentObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $this->query = $query; $targetPageUid = $this->contentObject->stdWrap($this->solrConfiguration->getSearchTargetPage(), $this->solrConfiguration->getSearchTargetPageConfiguration()); $this->linkTargetPageId = $targetPageUid; }
/** * Returns an array of banned UIDs (from excludeUidList) * * @return array Array of banned UIDs * @internal */ public function getBannedUids() { $excludeUidList = isset($this->conf['excludeUidList.']) ? $this->parent_cObj->stdWrap($this->conf['excludeUidList'], $this->conf['excludeUidList.']) : $this->conf['excludeUidList']; if (!trim($excludeUidList)) { return []; } $banUidList = str_replace('current', $this->getTypoScriptFrontendController()->page['uid'], $excludeUidList); return GeneralUtility::intExplode(',', $banUidList); }
/** * Returns an array of banned UIDs (from excludeUidList) * * @return array Array of banned UIDs * @access private * @todo Define visibility */ public function getBannedUids() { $excludeUidList = isset($this->conf['excludeUidList.']) ? $this->parent_cObj->stdWrap($this->conf['excludeUidList'], $this->conf['excludeUidList.']) : $this->conf['excludeUidList']; if (!trim($excludeUidList)) { return array(); } $banUidList = str_replace('current', $GLOBALS['TSFE']->page['uid'], $excludeUidList); return GeneralUtility::intExplode(',', $banUidList); }
/** * Renders a content element header, observing the layout type giving different header formattings * * @param string $str The header string * @param integer $type The layout type of the header (in the content element) * * @return string Content */ public function renderHeader($str, $type = 0) { if ($str) { $hConf = $this->conf['header.']; $defaultType = DirectMailUtility::intInRangeWrapper($hConf['defaultType'], 1, 5); $type = DirectMailUtility::intInRangeWrapper($type, 0, 6); if (!$type) { $type = $defaultType; } if ($type != 6) { // not hidden $tConf = $hConf[$type . '.']; if ($tConf['removeSplitChar']) { $str = preg_replace('/' . preg_quote($tConf['removeSplitChar'], '/') . '/', '', $str); } $lines = array(); $blanks = DirectMailUtility::intInRangeWrapper($tConf['preBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } $lines = $this->pad($lines, $tConf['preLineChar'], $tConf['preLineLen']); $blanks = DirectMailUtility::intInRangeWrapper($tConf['preLineBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } if ($this->cObj->data['date']) { $lines[] = $this->getString($hConf['datePrefix']) . date($hConf['date'] ? $hConf['date'] : 'd-m-Y', $this->cObj->data['date']); } $prefix = ''; $str = $this->getString($tConf['prefix']) . $str; if ($tConf['autonumber']) { $str = $this->cObj->parentRecordNumber . $str; } if ($this->cObj->data['header_position'] == 'right') { $prefix = str_pad(' ', $this->charWidth - strlen($str)); } if ($this->cObj->data['header_position'] == 'center') { $prefix = str_pad(' ', floor(($this->charWidth - strlen($str)) / 2)); } $lines[] = $this->cObj->stdWrap($prefix . $str, $tConf['stdWrap.']); if ($this->cObj->data['header_link']) { $lines[] = $this->getString($hConf['linkPrefix']) . $this->getLink($this->cObj->data['header_link']); } $blanks = DirectMailUtility::intInRangeWrapper($tConf['postLineBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } $lines = $this->pad($lines, $tConf['postLineChar'], $tConf['postLineLen']); $blanks = DirectMailUtility::intInRangeWrapper($tConf['postBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } return implode(LF, $lines); } } return ""; }
/** * Build reCAPTCHA Frontend HTML-Code * * @return string reCAPTCHA HTML-Code */ public function getReCaptcha() { if (!$this->developMode || $this->enforceCaptcha) { $captcha = $this->contentObject->stdWrap($this->configuration['public_key'], $this->configuration['public_key.']); } else { $captcha = '<div class="recaptcha-development-mode"> Development mode active. Do not expect the captcha to appear </div>'; } return $captcha; }
/** * Rendering the "data-htmlarea-clickenlarge" custom attribute, called from TypoScript * * @param string Content input. Not used, ignore. * @param array TypoScript configuration * @return string HTML output. * @access private * @todo Define visibility */ public function render_clickenlarge($content, $conf) { $clickenlarge = isset($this->cObj->parameters['data-htmlarea-clickenlarge']) ? $this->cObj->parameters['data-htmlarea-clickenlarge'] : 0; if (!$clickenlarge) { // Backward compatibility $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0; } $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance(); $fileTable = $this->cObj->parameters['data-htmlarea-file-table']; $fileUid = $this->cObj->parameters['data-htmlarea-file-uid']; if ($fileUid) { $fileObject = $fileFactory->getFileObject($fileUid); $filePath = $fileObject->getForLocalProcessing(FALSE); $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath); } else { // Pre-FAL backward compatibility $path = $this->cObj->parameters['src']; $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']); if ($magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) { $magicFolderPath = $magicFolder->getPublicUrl(); $pathPre = $magicFolderPath . 'RTEmagicC_'; if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, $pathPre)) { // Find original file: $pI = pathinfo(substr($path, strlen($pathPre))); $filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension'])); $file = $magicFolderPath . 'RTEmagicP_' . $filename; } else { $file = $this->cObj->parameters['src']; } } } // Unset clickenlarge custom attribute unset($this->cObj->parameters['data-htmlarea-clickenlarge']); // Backward compatibility unset($this->cObj->parameters['clickenlarge']); unset($this->cObj->parameters['allParams']); $content = '<img ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />'; if ($clickenlarge && is_array($conf['imageLinkWrap.'])) { $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : ''; if ($theImage) { $this->cObj->parameters['origFile'] = $theImage; if ($this->cObj->parameters['title']) { $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title']; } if ($this->cObj->parameters['alt']) { $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt']; } $content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']); $content = $this->cObj->stdWrap($content, $conf['stdWrap.']); } } return $content; }
/** * Parsing the bodytext field content, removing typical entities and <br /> tags. * * @param string $str : Field content from "bodytext" or other text field * @param string $altConf : Altername conf name (especially when bodyext field in other table then tt_content) * * @return string Processed content */ function parseBody($str, $altConf = 'bodytext') { if ($this->configuration[$altConf . '.']['doubleLF']) { $str = preg_replace("/\n/", "\n\n", $str); } // Regular parsing: $str = preg_replace('/<br\\s*\\/?>/i', chr(10), $str); $str = $this->contentObject->stdWrap($str, $this->configuration[$altConf . '.']['stdWrap.']); // Then all a-tags: $aConf = array(); $aConf['parseFunc.']['tags.']['a'] = 'USER'; // check direct mail usage @todo $aConf['parseFunc.']['tags.']['a.']['userFunc'] = 'FRUIT\\Ink\\PlainRenderer->atag_to_http'; $aConf['parseFunc.']['tags.']['a.']['siteUrl'] = 'http://www.google.de'; $str = $this->contentObject->stdWrap($str, $aConf); $str = str_replace(' ', ' ', htmlspecialchars_decode($str)); if ($this->configuration[$altConf . '.']['header']) { $str = $this->configuration[$altConf . '.']['header'] . LF . $str; } return chr(10) . $str; }
/** * Renders the image and puts Information to the picture * * @param array $image * @return mixed */ protected function formatBigPicture($image) { $lconf['image.']['params'] = ''; $lconf['image.']['file.']['treatIdAsReference'] = 1; $lconf['image.']['file'] = $image['reference']['uid']; $lconf['image.']['altText'] = ""; $lconf['image.']['file.']['height'] = 228; $lconf['image.']['file.']['width'] = 1000; $theImgCode = $this->local_cObj->cObjGetSingle('IMAGE', $lconf["image."]); $image = $this->local_cObj->stdWrap($theImgCode, $this->conf['image.']); return $image; }
/** * * Displays a form for editing or creating a single forum. * * @access private * @return String HTML content */ function editAction() { $forumUid = $this->v['newForum'] ? -1 : intval($this->v['editForum']); if ($this->v['forum']['save']) { $result = $this->saveEditAction(); if ($result['success'] === TRUE) { $this->redirectToAction(array('flashmessage' => base64_encode(sprintf($this->l('edit-success'), $this->v['forum']['name'])))); } else { $errors = $result['errors']; } } elseif ($this->v['forum']['cancel']) { $this->redirectToAction(array()); } else { $errors = array(); } $template = $this->cObj->fileResource($this->conf['templates.']['edit']); # Select the forum to be edited. The "hidden" flag is not queried on purpose! if ($forumUid > 0) { $res = $this->databaseHandle->exec_SELECTquery('uid, forum_name AS name, forum_desc AS description, parentID AS parent', 'tx_mmforum_forums', 'uid=' . $forumUid . ' AND deleted=0 ' . $this->p->getStoragePIDQuery()); if ($this->databaseHandle->sql_num_rows($res) == 0) { return $this->p->errorMessage($this->p->conf, $this->l('error-forumnotfound')); } $forumArray = $this->databaseHandle->sql_fetch_assoc($res); } else { $forumArray = array(); } if (is_array($this->v['forum'])) { $forumArray = array_merge($forumArray, $this->v['forum']); } if (!$forumArray['name']) { $forumArray['name'] = $this->l('new-dummytitle'); } if (!$this->checkActionAllowance($forumArray['parent'] == 0 ? 'category' : 'forum', $forumUid == -1 ? 'create' : 'edit')) { return $this->displayNoAccessError(); } $forumMarkers = array('###FORUM_NAME###' => $this->validator->specialChars($forumArray['name']), '###FORUM_DESCRIPTION###' => $this->validator->specialChars($forumArray['description']), '###FORUM_PARENT_OPTIONS###' => $this->getForumSelectOptionList($forumArray['parent']), '###FORUM_HIDDEN_CHECKED###' => $forumArray['hidden'] ? 'checked="checked"' : '', '###FORUM_UID###' => $forumUid, '###FORM_ACTION###' => $this->p->pi_getPageLink($GLOBALS['TSFE']->id)); foreach (array('name', 'description', 'parent') as $field) { if ($errors[$field]) { $messages = array(); foreach ($errors[$field] as $error) { $messages[] = vsprintf($this->l('error-' . $field . '-' . $error['type']), $error['args']); } $forumMarkers['###ERRORS_' . strtoupper($field) . '###'] = $this->cObj->stdWrap(implode(' ', $messages), $this->conf['format.']['errorMessage.']); } else { $forumMarkers['###ERRORS_' . strtoupper($field) . '###'] = ''; } } $template = $this->cObj->substituteMarkerArray($template, $forumMarkers); $template = preg_replace_callback('/###L:([A-Z_-]+)###/i', array($this, 'replaceLL'), $template); return $template; }
/** * @return void */ public function prepareConfiguration() { // Filter configuration foreach ($this->processorConfiguration as $key => $value) { if (in_array($key, $this->allowedConfigurationKeys)) { $this->menuConfig[$key] = $value; } } // Process special value if (isset($this->menuConfig['special.']['value.'])) { $this->menuConfig['special.']['value'] = $this->cObj->stdWrap($this->menuConfig['special.']['value'], $this->menuConfig['special.']['value.']); unset($this->menuConfig['special.']['value.']); } return $this->menuConfig; }
/** * Prepare Configuration */ public function prepareConfiguration() { $this->menuConfig += $this->processorConfiguration; // Filter configuration foreach ($this->menuConfig as $key => $value) { if (in_array($key, $this->removeConfigurationKeysForHmenu)) { unset($this->menuConfig[$key]); } } // Process special value if (isset($this->menuConfig['special.']['value.'])) { $this->menuConfig['special.']['value'] = $this->cObj->stdWrap($this->menuConfig['special.']['value'], $this->menuConfig['special.']['value.']); unset($this->menuConfig['special.']['value.']); } }
/** * Userfunc called per TS to create categories check boxes * * @param string $content * @param array $conf TS conf * * @return string */ public function makeCheckboxes($content, $conf) { $content = ''; $databaseConnection = $this->getDatabaseConnection(); $pid = $this->cObj->stdWrap($conf['pid'], $conf['pid.']); if ($address_uid = GeneralUtility::_GP('rU')) { $res = $databaseConnection->exec_SELECTquery('*', 'sys_dmail_ttaddress_category_mm', 'uid_local=' . intval($address_uid)); $subscribed_to = []; while ($row = $databaseConnection->sql_fetch_assoc($res)) { $subscribed_to[] = $row['uid_foreign']; } $subscribed_to_list = implode(',', $subscribed_to); } $res = $databaseConnection->exec_SELECTquery('*', 'sys_dmail_category', 'l18n_parent=0 AND pid=' . intval($pid) . $this->cObj->enableFields('sys_dmail_category')); $i = 1; while ($row = $databaseConnection->sql_fetch_assoc($res)) { $checked = GeneralUtility::inList($subscribed_to_list, $row['uid']); if ($theRow = $this->getTypoScriptFrontendController()->sys_page->getRecordOverlay('sys_dmail_category', $row, $this->getTypoScriptFrontendController()->sys_language_uid, $conf['hideNonTranslatedCategories'] ? 'hideNonTranslated' : '')) { $content .= '<label for="option-' . $i . '">' . htmlspecialchars($theRow['category']) . '</label><input id="option-' . $i . '" type="checkbox" ' . ($checked ? 'checked' : '') . ' name="FE[tt_address][module_sys_dmail_category][' . $row['uid'] . ']" value="1" /><div class="clearall"></div>'; } $i++; } return $content; }
/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * If FORM is dedected by the ContentObjectRenderer, * the Extbase plugin "Form" is initialized. At this time, the * controller "Frontend" action "execute" does the rest. * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject) { $content = ''; // render the FORM CE from TYPO3 < 4.6 if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { $mergedTypoScript = null; // If the FORM configuration comes from the database // all TypoScript interpretation will be disabled for security. if ($contentObject->data['CType'] === 'mailform') { // If the FORM configuration comes from the database // and a predefined form is selected than the TypoScript // interpretation is allowed. $renderPredefinedForm = false; if (isset($contentObject->data['tx_form_predefinedform']) && !empty($contentObject->data['tx_form_predefinedform'])) { $predefinedFormIdentifier = $contentObject->data['tx_form_predefinedform']; if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_form.']['predefinedForms.'][$predefinedFormIdentifier . '.'])) { $renderPredefinedForm = true; } else { throw new \InvalidArgumentException('No FORM configuration for identifier "' . $predefinedFormIdentifier . '" available.', 1457097250); } } if ($renderPredefinedForm) { $mergedTypoScript = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_form.']['predefinedForms.'][$predefinedFormIdentifier . '.']; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); } else { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser TypoScriptParser */ $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); // Disables TypoScript interpretation since TypoScript is handled that could contain insecure settings: $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true; } } $newTypoScript = is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript; $extbase = GeneralUtility::makeInstance(Bootstrap::class); $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $newTypoScript), 'persistence' => array(), 'view' => array())); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } return $content; }
/** * Highlights the searchword * * @param $content * @param array $searchWords * * @return mixed * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception */ protected function highlight($content, array $searchWords) { $rawSearchPattern = '/%s/i'; $replacePatternStdWrapConfiguration = $this->settingsService->getByPath('highlightTag'); if (empty($replacePatternStdWrapConfiguration) === TRUE) { throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('The TypoScript setting "highlightTag" is not set or empty in your configuration.', 1438950217); } $rawReplacePattern = $this->contentObject->stdWrap('%s', $replacePatternStdWrapConfiguration); foreach ($searchWords as $searchWord) { $found = stripos($content, $searchWord); if ($found !== FALSE) { $searchWord = substr($content, $found, strlen($searchWord)); $searchPattern = sprintf($rawSearchPattern, $searchWord); $content = preg_replace($searchPattern, sprintf($rawReplacePattern, $searchWord), $content); } } return $content; }
/** * renders the columns of the grid container and returns the actual content * * @param array $setup : The adjusted setup of the grid container * * @return array $content: The raw HTML output of the grid container before stdWrap functions will be applied to it */ public function renderColumnsIntoParentGrid($setup = array()) { $content = ''; if (!empty($this->cObj->data['tx_gridelements_view_columns'])) { foreach ($this->cObj->data['tx_gridelements_view_columns'] as $column => $columnContent) { // if there are any columns available, we have to determine the corresponding TS setup // and if there is none we are going to use the default setup $tempSetup = isset($setup['columns.'][$column . '.']) ? $setup['columns.'][$column . '.'] : $setup['columns.']['default.']; // now we just have to unset the renderObj // before applying the rest of the keys via the usual stdWrap operations unset($tempSetup['renderObj']); unset($tempSetup['renderObj.']); // we render each column into the column key to provide them prerendered for usage with your own templating $this->cObj->data['tx_gridelements_view_column_' . $column] = !empty($tempSetup) ? $this->cObj->stdWrap($columnContent, $tempSetup) : $columnContent; $content .= $this->cObj->data['tx_gridelements_view_column_' . $column]; } } return $content; }
/** * Renders the author and date columns of the tt_news record * * @param string $row: The tt_news record * @param int $type: * @return string Content */ public function renderAuthor($row, $type = 0) { if ($row['author']) { $hConf = $this->renderPlainText->conf['tt_news_author.']; $str = $this->renderPlainText->getString($hConf['prefix']) . $row['author'] . $this->renderPlainText->getString($hConf['emailPrefix']) . '<' . $row['author_email'] . '>'; $defaultType = DirectMailUtility::intInRangeWrapper($hConf['defaultType'], 1, 5); $type = DirectMailUtility::intInRangeWrapper($type, 0, 6); if (!$type) { $type = $defaultType; } if ($type != 6) { // not hidden $tConf = $hConf[$type . '.']; $lines = array(); $blanks = DirectMailUtility::intInRangeWrapper($tConf['preBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } $lines = $this->renderPlainText->pad($lines, $tConf['preLineChar'], $tConf['preLineLen']); $blanks = DirectMailUtility::intInRangeWrapper($tConf['preLineBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } if ($row['datetime']) { $lConf = $this->conf['displaySingle.']; $lines[] = $this->renderPlainText->getString($hConf['datePrefix']) . $this->cObj->stdWrap($row['datetime'], $lConf['date_stdWrap.']) . ' ' . $this->cObj->stdWrap($row['datetime'], $lConf['time_stdWrap.']); } $lines[] = $this->cObj->stdWrap($str, $tConf['stdWrap.']); $blanks = DirectMailUtility::intInRangeWrapper($tConf['postLineBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } $lines = $this->renderPlainText->pad($lines, $tConf['postLineChar'], $tConf['postLineLen']); $blanks = DirectMailUtility::intInRangeWrapper($tConf['postBlanks'], 0, 1000); if ($blanks) { $lines[] = str_pad('', $blanks - 1, LF); } return implode(LF, $lines); } } return ""; }
/** * Outputs information about a specific user for the post listing. * @param int $uid The UID of the user whose information are to be displayed * @param array $conf The configuration vars of the plugin * @param bool $threadauthor TRUE, if the user is the author of the thread displayed. In * this case, a special string telling that this user is the author * of the thread is displayed. * @return string The user information */ function ident_user($uid, $conf, $threadauthor = FALSE) { $userData = !is_array($uid) ? tx_mmforum_tools::get_userdata($uid) : $uid; $template = $this->cObj->fileResource($this->conf['template.']['list_post']); $template = $this->cObj->getSubpart($template, '###USERINFO###'); if ($template) { $avatar = $this->getUserAvatar($userData); $marker = array('###LLL_DELETED###' => $this->pi_getLL('user-deleted'), '###USERNAME###' => $this->cObj->stdWrap($userData[$this->getUserNameField()], $this->conf['list_posts.']['userinfo.']['username_stdWrap.']), '###USERREALNAME###' => $this->cObj->stdWrap($userData['name'], $this->conf['list_posts.']['userinfo.']['realname_stdWrap.']), '###USERRANKS###' => $this->get_userranking($uid, $conf), '###TOPICCREATOR###' => $uid == $threadauthor ? $this->cObj->stdWrap($this->pi_getLL('topic-topicauthor'), $this->conf['list_posts.']['userinfo.']['creator_stdWrap.']) : '', '###AVATAR###' => $avatar, '###LLL_REGSINCE###' => $this->pi_getLL('user-regSince'), '###LLL_POSTCOUNT###' => $this->pi_getLL('user-posts'), '###REGSINCE###' => $this->cObj->stdWrap($userData['crdate'], $this->conf['list_posts.']['userinfo.']['crdate_stdWrap.']), '###POSTCOUNT###' => intval($userData['tx_mmforum_posts']), '###USER_RATING###' => $this->isUserRating() ? $this->getRatingDisplay('fe_users', $userData['uid']) : ''); if ($userData === false) { $template = $this->cObj->substituteSubpart($template, '###USERINFO_REGULAR###', ''); } else { $template = $this->cObj->substituteSubpart($template, '###USERINFO_DELETED###', ''); } // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $marker = $_procObj->userInformation_marker($marker, $userData, $this); } } $content = $this->cObj->substituteMarkerArray($template, $marker); } else { if ($userData === false) { return '<strong>' . $this->pi_getLL('user.deleted') . '</strong>'; } $content = '<strong>' . $userData[$this->getUserNameField()] . '</strong><br />'; if ($this->conf['list_posts.']['userinfo_realName'] && $userData['name']) { $content .= $this->cObj->wrap($userData['name'], $this->conf['list_posts.']['userinfo_realName_wrap']); } $userranking = $this->get_userranking($uid, $conf) . '<br />'; if ($uid == $threadauthor) { $userranking .= $this->cObj->wrap($this->pi_getLL('topic.topicauthor'), $this->conf['list_posts.']['userinfo_topicauthor_wrap']); } $content .= $userranking; if ($userData['tx_mmforum_avatar']) { $content .= $this->tools->res_img($conf['path_avatar'] . $userData['tx_mmforum_avatar'], $conf['avatar_height'], $conf['avatar_width']); } $content .= $this->cObj->wrap($this->pi_getLL('user.regSince') . ': ' . date('d.m.Y', $userData['crdate']) . '<br />' . $this->pi_getLL('user.posts') . ': ' . $userData['tx_mmforum_posts'], $this->conf['list_posts.']['userinfo_content_wrap']); } return $content; }
/** * Executes the SOLR_MULTIVALUE content object. * * Turns a list of values into an array that can then be used to fill * multivalued fields in a Solr document. The array is returned in * serialized form as content objects are expected to return strings. * * @param string $name content object name 'SOLR_MULTIVALUE' * @param array $configuration for the content object, expects keys 'separator' and 'field' * @param string $TyposcriptKey not used * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject parent cObj * @return string serialized array representation of the given list */ public function cObjGetSingleExt($name, array $configuration, $TyposcriptKey, $contentObject) { $data = ''; if (isset($configuration['value'])) { $data = $configuration['value']; unset($configuration['value']); } if (!empty($configuration)) { $data = $contentObject->stdWrap($data, $configuration); } if (!array_key_exists('separator', $configuration)) { $configuration['separator'] = ','; } $removeEmptyValues = true; if (isset($configuration['removeEmptyValues']) && $configuration['removeEmptyValues'] == 0) { $removeEmptyValues = false; } $listAsArray = GeneralUtility::trimExplode($configuration['separator'], $data, $removeEmptyValues); if (!empty($configuration['removeDuplicateValues'])) { $listAsArray = array_unique($listAsArray); } return serialize($listAsArray); }
/** * Display a poll. * This function displays a poll. Depending on whether the user that is * currently logged in is allowed to vote on this poll (this will be the * case if the user has not already voted in this poll and if the poll is * not yet expired), the user will see a set of radio buttons allowing him/her * to choose an answering possibility, or the poll results. * * @return string The poll content * @version 2007-05-22 */ function objDisplay() { if ($this->piVars['poll']['vote'] == '1') { $this->objVote(); } $template = $this->cObj->fileResource($this->conf['template.']['polls']); $template = $this->cObj->getSubpart($template, '###POLL_DISPLAY###'); $vote = $this->getMayVote(); if (!$vote) { $template = $this->cObj->substituteSubpart($template, '###POLL_SUBMIT###', ''); $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_2###'); } else { $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_1###'); } $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_polls_answers', 'poll_id=' . intval($this->data['uid']) . ' AND deleted=0'); $i = 1; $aContent = ''; while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) { $pAnswers = $arr['votes'] > 0 ? round($arr['votes'] / $this->data['votes'] * 100) : 0; if ($this->conf['polls.']['pollBar_colorMap.'][$i]) { $color = $this->conf['polls.']['pollBar_colorMap.'][$i]; } else { $color = $this->conf['polls.']['pollBar_colorMap.']['default']; } $aMarker = array('###ANSWER_UID###' => $arr['uid'], '###ANSWER_TEXT###' => $this->p->escape($arr['answer']), '###ANSWER_COUNT###' => sprintf($this->p->pi_getLL('poll.replies'), $arr['votes'], $this->data['votes'], $pAnswers . '%'), '###ANSWER_ANSWERS###' => '<div style="width: ' . $pAnswers . '%; height:10px; background-color: ' . $color . ';"> </div>', '###ENABLE###' => ''); $aContent .= $this->cObj->substituteMarkerArray($row_template, $aMarker); $i++; } $actionParams[$this->p->prefixId] = array('tid' => $this->p->piVars['tid'], 'fid' => $this->p->piVars['fid'], 'action' => 'list_post'); $actionLink = $this->p->pi_getPageLink($GLOBALS['TSFE']->id, '', $actionParams); $marker = array('###LABEL_POLL###' => $this->p->pi_getLL('poll.title'), '###LABEL_VOTE###' => $this->p->pi_getLL('poll.vote'), '###LABEL_QUESTION###' => $this->p->pi_getLL('poll.question'), '###QUESTION###' => $this->p->escape($this->data['question']), '###EXPIRES###' => $this->data['endtime'] ? $this->p->pi_getLL('poll.expires') . ' ' . date('d. m. Y, H:i', $this->data['endtime']) : '', '###ACTION###' => $this->p->escapeURL($actionLink), '###ICON###' => $this->cObj->cObjGetSingle($this->conf['polls.']['poll_icon'], $this->conf['polls.']['poll_icon.'])); $marker['###EXPIRES###'] = $this->cObj->stdWrap($marker['###EXPIRES###'], $this->conf['polls.']['expired_stdWrap.']); $template = $this->cObj->substituteMarkerArray($template, $marker); $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_1###', $aContent); $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_2###', ''); return $template; }
/** * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context. * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * * @param string $content The content to which the edit icons should be appended * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController * @param array $conf TypoScript properties for configuring the edit icons. * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param array $dataArr Alternative data array to use. Default is $this->data * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController * @param string $table * @param int $editUid * @param string $fieldList * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. */ public function editIcons($content, $params, array $conf = [], $currentRecord = '', array $dataArr = [], $addUrlParamStr = '', $table, $editUid, $fieldList) { // Special content is about to be shown, so the cache must be disabled. $this->frontendController->set_no_cache('Display frontend edit icons', true); $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $iconImg = '<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', false) . '" class="frontEndEditIcons" style="' . ($conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</span>'; $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; $url = BackendUtility::getModuleUrl('record_edit', ['edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV, 'feEdit' => 1]) . $addUrlParamStr; $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url, 'content-link'); if ($conf['beforeLastTag'] < 0) { $content = $icon . $content; } elseif ($conf['beforeLastTag'] > 0) { $cBuf = rtrim($content); $secureCount = 30; while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $secureCount--; } $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); } else { $content .= $icon; } return $content; }
/** * 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 if (!is_array($maskArray) || !$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) { $fileConfiguration['params'] = $this->modifyImageMagickStripProfileParameters($fileConfiguration['params'], $fileConfiguration); $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->imageMagickConvert($theImage, $fileConfiguration['ext'], $fileConfiguration['width'], $fileConfiguration['height'], $fileConfiguration['params'], $fileConfiguration['frame'], $options); if (($fileConfiguration['reduceColors'] || $imgExt === 'png' && !$gifCreator->png_truecolor) && is_file($GLOBALS['TSFE']->tmpl->fileCache[$hash][3])) { $reduced = $gifCreator->IMreduceColors($GLOBALS['TSFE']->tmpl->fileCache[$hash][3], \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fileConfiguration['reduceColors'], 256, $gifCreator->truecolorColors, 256)); if (is_file($reduced)) { unlink($GLOBALS['TSFE']->tmpl->fileCache[$hash][3]); rename($reduced, $GLOBALS['TSFE']->tmpl->fileCache[$hash][3]); } } } else { // Filename: $fileDestination = $gifCreator->tempPath . $hash . '.' . $imgExt; // Generate! if (!file_exists($fileDestination)) { $this->processMask($maskImages, $gifCreator, $theImage, $fileConfiguration, $options, $fileDestination); } // Finish off if (($fileConfiguration['reduceColors'] || $imgExt === 'png' && !$gifCreator->png_truecolor) && is_file($fileDestination)) { $reduced = $gifCreator->IMreduceColors($fileDestination, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fileConfiguration['reduceColors'], 256, $gifCreator->truecolorColors, 256)); if (is_file($reduced)) { unlink($fileDestination); rename($reduced, $fileDestination); } } $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->getImageDimensions($fileDestination); } $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage; // This is needed by tslib_gifbuilder, in order for the setup-array to create a unique filename hash. $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile_mtime'] = @filemtime($theImage); $GLOBALS['TSFE']->tmpl->fileCache[$hash]['fileCacheHash'] = $hash; if ($file instanceof \TYPO3\CMS\Core\Resource\FileInterface && \TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($GLOBALS['TSFE']->tmpl->fileCache[$hash][3])) { $GLOBALS['TSFE']->tmpl->fileCache[$hash][3] = $file->getPublicUrl(); } $imageResource = $GLOBALS['TSFE']->tmpl->fileCache[$hash]; return $imageResource; }