/**
  * Entry method for use as TCEMain "inline" field filter
  *
  * @param array $parameters
  * @param \TYPO3\CMS\Core\DataHandling\DataHandler $tceMain
  * @return array
  */
 public function filterInlineChildren(array $parameters, \TYPO3\CMS\Core\DataHandling\DataHandler $tceMain)
 {
     $values = $parameters['values'];
     if ($parameters['allowedFileExtensions']) {
         $this->setAllowedFileExtensions($parameters['allowedFileExtensions']);
     }
     if ($parameters['disallowedFileExtensions']) {
         $this->setDisallowedFileExtensions($parameters['disallowedFileExtensions']);
     }
     $cleanValues = array();
     if (is_array($values)) {
         foreach ($values as $value) {
             if (empty($value)) {
                 continue;
             }
             $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $value, 2);
             $fileReferenceUid = $parts[count($parts) - 1];
             $fileReference = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($fileReferenceUid);
             $file = $fileReference->getOriginalFile();
             if ($this->isAllowed($file->getName())) {
                 $cleanValues[] = $value;
             } else {
                 // Remove the erroneously created reference record again
                 $tceMain->deleteAction('sys_file_reference', $fileReferenceUid);
             }
         }
     }
     return $cleanValues;
 }
 /**
  * @param Request $request
  * @param RenderingContext $renderingContext
  * @return array
  */
 protected function resolveRenderingConfiguration(Request $request, RenderingContext $renderingContext)
 {
     $configuration = array();
     if ($request->hasArgument('path')) {
         $renderingPath = $request->getArgument('path');
     }
     if ($request->hasArgument('record')) {
         if (strpos($request->getArgument('record'), '_') !== FALSE) {
             list($table, $id) = GeneralUtility::revExplode('_', $request->getArgument('record'), 2);
         } else {
             $id = $request->getArgument('record');
         }
     }
     if ($request->hasArgument('table')) {
         $table = $request->getArgument('table');
     }
     if (empty($table) && empty($id)) {
         $table = 'pages';
         $id = $renderingContext->getFrontendController()->id;
         if (!empty($id) && $renderingContext->getFrontendController()->page['pid'] === '0') {
             // Allow rendering of a root page which has pid === 0 and will be denied otherwise
             $configuration['dontCheckPid'] = '1';
         }
     }
     if (!empty($id) && empty($table)) {
         $table = 'tt_content';
     }
     $configuration['source'] = $table . '_' . $id;
     $configuration['tables'] = $table;
     if (!empty($renderingPath)) {
         $configuration['conf.'][$table] = '< ' . $renderingPath;
     }
     return $configuration;
 }
示例#3
0
	/**
	 * Calculate and return the current type value of a record
	 *
	 * @param string $table The table name. MUST be in $GLOBALS['TCA']
	 * @param array $row The row from the table, should contain at least the "type" field, if applicable.
	 * @return string Return the "type" value for this record, ready to pick a "types" configuration from the $GLOBALS['TCA'] array.
	 * @throws \RuntimeException
	 */
	protected function getRecordTypeValue($table, array $row) {
		$typeNum = 0;
		$field = $GLOBALS['TCA'][$table]['ctrl']['type'];
		if ($field) {
			if (strpos($field, ':') !== FALSE) {
				list($pointerField, $foreignTypeField) = explode(':', $field);
				$fieldConfig = $GLOBALS['TCA'][$table]['columns'][$pointerField]['config'];
				$relationType = $fieldConfig['type'];
				if ($relationType === 'select') {
					$foreignUid = $row[$pointerField];
					$foreignTable = $fieldConfig['foreign_table'];
				} elseif ($relationType === 'group') {
					$values = FormEngineUtility::extractValuesOnlyFromValueLabelList($row[$pointerField]);
					list(, $foreignUid) = GeneralUtility::revExplode('_', $values[0], 2);
					$allowedTables = explode(',', $fieldConfig['allowed']);
					// Always take the first configured table.
					$foreignTable = $allowedTables[0];
				} else {
					throw new \RuntimeException('TCA Foreign field pointer fields are only allowed to be used with group or select field types.', 1325861239);
				}
				if ($foreignUid) {
					$foreignRow = BackendUtility::getRecord($foreignTable, $foreignUid, $foreignTypeField);
					$this->registerDefaultLanguageData($foreignTable, $foreignRow);
					if ($foreignRow[$foreignTypeField]) {
						$foreignTypeFieldConfig = $GLOBALS['TCA'][$table]['columns'][$field];
						$typeNum = $this->overrideTypeWithValueFromDefaultLanguageRecord($foreignTable, $foreignRow, $foreignTypeField, $foreignTypeFieldConfig);
					}
				}
			} else {
				$typeFieldConfig = $GLOBALS['TCA'][$table]['columns'][$field];
				$typeNum = $this->overrideTypeWithValueFromDefaultLanguageRecord($table, $row, $field, $typeFieldConfig);
			}
		}
		if (empty($typeNum)) {
			// If that value is an empty string, set it to "0" (zero)
			$typeNum = 0;
		}
		// If current typeNum doesn't exist, set it to 0 (or to 1 for historical reasons, if 0 doesn't exist)
		if (!$GLOBALS['TCA'][$table]['types'][$typeNum]) {
			$typeNum = $GLOBALS['TCA'][$table]['types']['0'] ? 0 : 1;
		}
		// Force to string. Necessary for eg '-1' to be recognized as a type value.
		return (string)$typeNum;
	}
 /**
  * @param Request $request
  * @param RenderingContext $renderingContext
  * @return array
  */
 protected function resolveRenderingConfiguration(Request $request, RenderingContext $renderingContext)
 {
     $configuration = array();
     if ($request->hasArgument('path')) {
         $renderingPath = $request->getArgument('path');
     }
     if ($request->hasArgument('record')) {
         if (strpos($request->getArgument('record'), '_') !== FALSE) {
             list($table, $id) = GeneralUtility::revExplode('_', $request->getArgument('record'), 2);
         } else {
             $id = $request->getArgument('record');
         }
     }
     if ($request->hasArgument('table')) {
         $table = $request->getArgument('table');
     }
     if (empty($table) && empty($id)) {
         $table = 'pages';
         $id = $renderingContext->getFrontendController()->id;
     }
     if (!empty($id) && empty($table)) {
         $table = 'tt_content';
     }
     if ($table === 'pages') {
         // Allow rendering of a root page which has pid === 0 and would be denied otherwise
         $rootLine = $renderingContext->getFrontendController()->sys_page->getRootLine($id);
         // $rootLine[0] is the root page. Check if the page we're going to render is a root page.
         // We explicitly ignore the case where the to be rendered id is in another root line (multi domain setup)
         // as this would require an additional record lookup. The use case for this is very limited anyway
         // and should be implemented in a different renderer instead of covering that here.
         if ($rootLine[0]['uid'] === (string) $id) {
             $configuration['dontCheckPid'] = '1';
         }
     }
     $configuration['source'] = $table . '_' . $id;
     $configuration['tables'] = $table;
     if (!empty($renderingPath)) {
         $configuration['conf.'][$table] = '< ' . $renderingPath;
     }
     return $configuration;
 }
示例#5
0
 /**
  * Main function
  * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
  *
  * @return void
  * @todo Define visibility
  */
 public function main()
 {
     if ($this->doClose) {
         $this->closeWindow();
     } else {
         // Initialize:
         $table = $this->P['table'];
         $field = $this->P['field'];
         \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
         $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
         $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
         // Detecting the various allowed field type setups and acting accordingly.
         if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
             // SINGLE value:
             $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit';
             \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);
         } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) {
             // MULTIPLE VALUES:
             // Init settings:
             $allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
             $prependName = 1;
             $params = '';
             // Selecting selected values into an array:
             $dbAnalysis = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
             $dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables);
             $value = $dbAnalysis->getValueArray($prependName);
             // Traverse that array and make parameters for alt_doc.php:
             foreach ($value as $rec) {
                 $recTableUidParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $rec, 2);
                 $params .= '&edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']=edit';
             }
             // Redirect to alt_doc.php:
             \TYPO3\CMS\Core\Utility\HttpUtility::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params);
         } else {
             $this->closeWindow();
         }
     }
 }
 /**
  * @param string $delimiter Delimiter string to explode with
  * @param string $string The string to explode
  * @param int $count Number of array entries
  * @return array Exploded values
  */
 public function revExplode($delimiter, $string, $count = 0)
 {
     return GeneralUtility::revExplode($delimiter, $string, $count);
 }
示例#7
0
 /**
  * Where-clause for free index-uid value.
  *
  * @param int $freeIndexUid Free Index UID value to limit search to.
  * @return string WHERE SQL clause part.
  */
 public function freeIndexUidWhere($freeIndexUid)
 {
     $freeIndexUid = (int) $freeIndexUid;
     if ($freeIndexUid < 0) {
         return '';
     }
     // First, look if the freeIndexUid is a meta configuration:
     $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_config');
     $queryBuilder->getRestrictions()->removeAll();
     $indexCfgRec = $queryBuilder->select('indexcfgs')->from('index_config')->where($queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(5, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($freeIndexUid, \PDO::PARAM_INT)), QueryHelper::stripLogicalOperatorPrefix($this->enableFields('index_config')))->execute()->fetch();
     if (is_array($indexCfgRec)) {
         $refs = GeneralUtility::trimExplode(',', $indexCfgRec['indexcfgs']);
         // Default value to protect against empty array.
         $list = [-99];
         foreach ($refs as $ref) {
             list($table, $uid) = GeneralUtility::revExplode('_', $ref, 2);
             $uid = (int) $uid;
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_config');
             $queryBuilder->getRestrictions()->removeAll();
             $queryBuilder->select('uid')->from('index_config')->where(QueryHelper::stripLogicalOperatorPrefix($this->enableFields('index_config')));
             switch ($table) {
                 case 'index_config':
                     $idxRec = $queryBuilder->andWhere($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))->execute()->fetch();
                     if ($idxRec) {
                         $list[] = $uid;
                     }
                     break;
                 case 'pages':
                     $indexCfgRecordsFromPid = $queryBuilder->andWhere($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))->execute();
                     while ($idxRec = $indexCfgRecordsFromPid->fetch()) {
                         $list[] = $idxRec['uid'];
                     }
                     break;
             }
         }
         $list = array_unique($list);
     } else {
         $list = [$freeIndexUid];
     }
     $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_phash')->expr();
     return ' AND ' . $expressionBuilder->in('IP.freeIndexUid', array_map('intval', $list));
 }
 /**
  * Where-clause for free index-uid value.
  *
  * @param 	integer		Free Index UID value to limit search to.
  * @return 	string		WHERE SQL clause part.
  */
 public function freeIndexUidWhere($freeIndexUid)
 {
     $freeIndexUid = (int) $freeIndexUid;
     if ($freeIndexUid >= 0) {
         // First, look if the freeIndexUid is a meta configuration:
         $indexCfgRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('indexcfgs', 'index_config', 'type=5 AND uid=' . $freeIndexUid . $this->enableFields('index_config'));
         if (is_array($indexCfgRec)) {
             $refs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $indexCfgRec['indexcfgs']);
             // Default value to protect against empty array.
             $list = array(-99);
             foreach ($refs as $ref) {
                 list($table, $uid) = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $ref, 2);
                 $uid = (int) $uid;
                 switch ($table) {
                     case 'index_config':
                         $idxRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'index_config', 'uid=' . $uid . $this->enableFields('index_config'));
                         if ($idxRec) {
                             $list[] = $uid;
                         }
                         break;
                     case 'pages':
                         $indexCfgRecordsFromPid = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'index_config', 'pid=' . $uid . $this->enableFields('index_config'));
                         foreach ($indexCfgRecordsFromPid as $idxRec) {
                             $list[] = $idxRec['uid'];
                         }
                         break;
                 }
             }
             $list = array_unique($list);
         } else {
             $list = array($freeIndexUid);
         }
         return ' AND IP.freeIndexUid IN (' . implode(',', $list) . ')';
     }
 }
示例#9
0
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = \TYPO3\CMS\Core\Database\RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // render using a self-defined user function
     if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = \t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitlePrep($recTitle);
         if (!strcmp(trim($recTitle), '')) {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(\TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => 64, 'height' => 64), $imageSetup);
                 $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup)->getPublicUrl(TRUE);
                 $thumbnail = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($recTitle) . '">';
             } else {
                 $thumbnail = FALSE;
             }
         }
     }
     $altText = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $header = '<table>' . '<tr>' . (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail ? '<td class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</td>' : '<td class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</td>') . '<td class="t3-form-field-header-inline-summary">' . $label . '</td>' . '<td clasS="t3-form-field-header-inline-ctrl">' . $ctrl . '</td>' . '</tr>' . '</table>';
     return $header;
 }
 /**
  * Parse old curl options and set new http ones instead
  *
  * @return void
  */
 protected function transferDeprecatedCurlSettings()
 {
     $changed = false;
     try {
         $curlProxyServer = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlProxyServer');
     } catch (\RuntimeException $e) {
         $curlProxyServer = '';
     }
     try {
         $proxyHost = $this->configurationManager->getLocalConfigurationValueByPath('HTTP/proxy_host');
     } catch (\RuntimeException $e) {
         $proxyHost = '';
     }
     if (!empty($curlProxyServer) && empty($proxyHost)) {
         $curlProxy = rtrim(preg_replace('#^https?://#', '', $curlProxyServer), '/');
         $proxyParts = GeneralUtility::revExplode(':', $curlProxy, 2);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_host', $proxyParts[0]);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_port', $proxyParts[1]);
         $changed = true;
     }
     try {
         $curlProxyUserPass = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlProxyUserPass');
     } catch (\RuntimeException $e) {
         $curlProxyUserPass = '';
     }
     try {
         $proxyUser = $this->configurationManager->getLocalConfigurationValueByPath('HTTP/proxy_user');
     } catch (\RuntimeException $e) {
         $proxyUser = '';
     }
     if (!empty($curlProxyUserPass) && empty($proxyUser)) {
         $userPassParts = explode(':', $curlProxyUserPass, 2);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_user', $userPassParts[0]);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_password', $userPassParts[1]);
         $changed = true;
     }
     try {
         $curlUse = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlUse');
     } catch (\RuntimeException $e) {
         $curlUse = '';
     }
     try {
         $adapter = $this->configurationManager->getConfigurationValueByPath('HTTP/adapter');
     } catch (\RuntimeException $e) {
         $adapter = '';
     }
     if (!empty($curlUse) && $adapter !== 'curl') {
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter'] = 'curl';
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/adapter', 'curl');
         $changed = true;
     }
     if ($changed) {
         $this->throwRedirectException();
     }
 }
示例#11
0
 /**
  * Gets the values from the Expand/Collapse Parameter (&PM)
  * previously known as "PM" (plus/minus)
  * PM action:
  * (If an plus/minus icon has been clicked,
  * the PM GET var is sent and we must update the stored positions in the tree):
  * 0: mount key, 1: set/clear boolean, 2: item ID (cannot contain "_"), 3: treeName
  *
  * @param string $PM The "plus/minus" command
  * @return array
  */
 protected function evaluateExpandCollapseParameter($PM = NULL)
 {
     if ($PM === NULL) {
         $PM = GeneralUtility::_GP('PM');
         // IE takes anchor as parameter
         if (($PMpos = strpos($PM, '#')) !== FALSE) {
             $PM = substr($PM, 0, $PMpos);
         }
     }
     // Take the first three parameters
     list($mountKey, $doExpand, $folderIdentifier) = explode('_', $PM, 3);
     // In case the folder identifier contains "_", we just need to get the fourth/last parameter
     list($folderIdentifier, $treeName) = GeneralUtility::revExplode('_', $folderIdentifier, 2);
     return array($mountKey, $doExpand, $folderIdentifier, $treeName);
 }
示例#12
0
文件: index.php 项目: xf-/l10nmgr-1
 function explodeElement($elementList)
 {
     $elements = GeneralUtility::trimExplode(',', $elementList);
     foreach ($elements as $k => $element) {
         $elements[$k] = GeneralUtility::revExplode('_', $element, 2);
     }
     return $elements;
 }
示例#13
0
 /**
  * Parse old curl options and set new http ones instead
  *
  * @TODO: This code segment must still be finished
  * @return Bootstrap
  */
 protected function transferDeprecatedCurlSettings()
 {
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
         $proxyParts = Utility\GeneralUtility::revExplode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
     }
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
         $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
     }
     return $this;
 }
示例#14
0
 /**
  * Post-processes the URL. If necessary prepends another domain to the URL.
  *
  * @param array $parameters
  * @param ContentObjectRenderer $pObj
  * @return void
  */
 public function postProcessEncodedUrl(array &$parameters, ContentObjectRenderer $pObj)
 {
     if (isset($parameters['finalTagParts']['url'])) {
         // We must check for absolute URLs here because typolink can force
         // absolute URLs for pages with restricted access. It prepends
         // current host always. See http://bugs.typo3.org/view.php?id=18200
         $testUrl = $parameters['finalTagParts']['url'];
         if (preg_match('/^https?:\\/\\/[^\\/]+\\//', $testUrl)) {
             $testUrl = preg_replace('/https?:\\/\\/[^\\/]+\\/(.*)$/', $this->tsfe->absRefPrefix . '\\1', $testUrl);
         }
         list($testUrl, $section) = GeneralUtility::revExplode('#', $testUrl, 2);
         if (isset(self::$urlPrependRegister[$testUrl])) {
             $urlKey = $url = $testUrl;
             $url = self::$urlPrependRegister[$urlKey] . ($url[0] != '/' ? '/' : '') . $url;
             if ($section) {
                 $url .= '#' . $section;
             }
             unset(self::$urlPrependRegister[$testUrl]);
             // Adjust the URL
             $parameters['finalTag'] = str_replace('"' . htmlspecialchars($parameters['finalTagParts']['url']) . '"', '"' . htmlspecialchars($url) . '"', $parameters['finalTag']);
             $parameters['finalTagParts']['url'] = $url;
             $pObj->lastTypoLinkUrl = $url;
         }
     }
 }
 function splitGroup($group)
 {
     $groups = explode(',', $group);
     foreach ($groups as $group) {
         $item = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $group, 2);
         $ret[$item[0]][] = $item[1];
     }
     return $ret;
 }
示例#16
0
 /**
  * Decodes the file name and adjusts file parts accordingly
  *
  * @param array $pathParts Path parts of the URLs (can be modified)
  * @return array GET varaibles from the file name or empty array
  */
 protected function decodeSpURL_decodeFileName(array &$pathParts)
 {
     $getVars = array();
     $fileName = array_pop($pathParts);
     $fileParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('.', $fileName, 2);
     if (count($fileParts) == 2 && !$fileParts[1]) {
         $this->decodeSpURL_throw404('File "' . $fileName . '" was not found (2)!');
     }
     list($segment, $extension) = $fileParts;
     if ($extension) {
         $getVars = array();
         if (!$this->decodeSpURL_decodeFileName_lookupInIndex($fileName, $segment, $extension, $pathParts, $getVars)) {
             if (!$this->decodeSpURL_decodeFileName_checkHtmlSuffix($fileName, $segment, $extension, $pathParts)) {
                 $this->decodeSpURL_throw404('File "' . $fileName . '" was not found (1)!');
             }
         }
     } elseif ($fileName != '') {
         $pathParts[] = $fileName;
     }
     return $getVars;
 }
示例#17
0
 /**
  * Handles mapping of file names to GET vars (like 'print.html' => 'type=98')
  *
  * @param string $fileNameSegment
  * @param array $getVars
  * @param bool $putBack
  * @return bool
  */
 protected function handleFileNameMappingToGetVar(&$fileNameSegment, array &$getVars, &$putBack)
 {
     $result = false;
     if ($fileNameSegment) {
         $fileNameConfiguration = $this->configuration->get('fileName/index/' . $fileNameSegment);
         if (is_array($fileNameConfiguration)) {
             $result = true;
             $putBack = false;
             if (isset($fileNameConfiguration['keyValues'])) {
                 $getVars = $fileNameConfiguration['keyValues'];
             }
         } else {
             list($fileName, $extension) = GeneralUtility::revExplode('.', $fileNameSegment, 2);
             $fileNameConfiguration = $this->configuration->get('fileName/index/.' . $extension);
             if (is_array($fileNameConfiguration)) {
                 $result = true;
                 $putBack = true;
                 $fileNameSegment = $fileName;
                 if (isset($fileNameConfiguration['keyValues'])) {
                     $getVars = $fileNameConfiguration['keyValues'];
                 }
             }
         }
     }
     return $result;
 }
示例#18
0
 /**
  * @test
  */
 public function revExplodeRespectsLimitThreeWhenExploding()
 {
     $testString = 'even:more:of:my:words:here';
     $expectedArray = array('even:more:of:my', 'words', 'here');
     $actualArray = GeneralUtility::revExplode(':', $testString, 3);
     $this->assertEquals($expectedArray, $actualArray);
 }
 /**
  * Extracts a given zip file and installs the extension
  * As there is no information about the extension key in the zip
  * we have to use the file name to get that information
  * filename format is expected to be extensionkey_version.zip
  *
  * @param string $file path to uploaded file
  * @param string $fileName filename (basename) of uploaded file
  * @return array
  */
 protected function getExtensionFromZipFile($file, $fileName)
 {
     $fileNameParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $fileName, 2);
     $this->fileHandlingUtility->unzipExtensionFromFile($file, $fileNameParts[0]);
     $this->installUtility->install($fileNameParts[0]);
     return array('extKey' => $fileNameParts[0]);
 }
示例#20
0
 /**
  * Main function
  * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
  *
  * @return void
  */
 public function main()
 {
     if ($this->doClose) {
         $this->closeWindow();
     }
     // Initialize:
     $table = $this->P['table'];
     $field = $this->P['field'];
     $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
     $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
     $urlParameters = array('returnUrl' => BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1)));
     // Detecting the various allowed field type setups and acting accordingly.
     if (is_array($config) && $config['type'] === 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
         // SINGLE value
         $urlParameters['edit[' . $fTable . '][' . $this->P['currentValue'] . ']'] = 'edit';
         // Redirect to FormEngine
         $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
         HttpUtility::redirect($url);
     } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] === 'select' && $config['foreign_table'] || $config['type'] === 'group' && $config['internal_type'] === 'db')) {
         // MULTIPLE VALUES:
         // Init settings:
         $allowedTables = $config['type'] === 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
         $prependName = 1;
         // Selecting selected values into an array:
         /** @var RelationHandler $relationHandler */
         $relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
         $relationHandler->start($this->P['currentSelectedValues'], $allowedTables);
         $value = $relationHandler->getValueArray($prependName);
         // Traverse that array and make parameters for FormEngine
         foreach ($value as $rec) {
             $recTableUidParts = GeneralUtility::revExplode('_', $rec, 2);
             $urlParameters['edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']'] = 'edit';
         }
         // Redirect to FormEngine
         $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
         HttpUtility::redirect($url);
     } else {
         $this->closeWindow();
     }
 }
示例#21
0
 /**
  * Return be_users that should be notified on stage change from input list.
  * previously called notifyStageChange_getEmails() in tcemain
  *
  * @param string $listOfUsers List of backend users, on the form "be_users_10,be_users_2" or "10,2" in case noTablePrefix is set.
  * @param bool $noTablePrefix If set, the input list are integers and not strings.
  * @return array Array of emails
  */
 protected function getEmailsForStageChangeNotification($listOfUsers, $noTablePrefix = FALSE)
 {
     $users = GeneralUtility::trimExplode(',', $listOfUsers, TRUE);
     $emails = array();
     foreach ($users as $userIdent) {
         if ($noTablePrefix) {
             $id = (int) $userIdent;
         } else {
             list($table, $id) = GeneralUtility::revExplode('_', $userIdent, 2);
         }
         if ($table === 'be_users' || $noTablePrefix) {
             if ($userRecord = BackendUtility::getRecord('be_users', $id, 'uid,email,lang,realName', BackendUtility::BEenableFields('be_users'))) {
                 if (trim($userRecord['email']) !== '') {
                     $emails[$id] = $userRecord;
                 }
             }
         }
     }
     return $emails;
 }
示例#22
0
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // Try using a self-defined user function only for formatted labels
     if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
         $recTitle = $params['title'];
         // Try using a normal self-defined user function
     } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = BackendUtility::getRecordTitlePrep($recTitle);
         if (trim($recTitle) === '') {
             $recTitle = BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $thumbnail = FALSE;
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject && $fileObject->isMissing()) {
                 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                 $thumbnail = $flashMessage->render();
             } elseif ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup);
                 $processedImage = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                 // Only use a thumbnail if the processing was successful.
                 if (!$processedImage->usesOriginalFile()) {
                     $imageUrl = $processedImage->getPublicUrl(TRUE);
                     $thumbnail = '<img class="t3-form-field-header-inline-thumbnail-image" src="' . $imageUrl . '" alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '">';
                 }
             }
         }
     }
     if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) {
         $headerClasses = ' t3-form-field-header-inline-has-thumbnail';
         $mediaContainer = '<div class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
     } else {
         $headerClasses = ' t3-form-field-header-inline-has-icon';
         $mediaContainer = '<div class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
     }
     $header = '<div class="t3-form-field-header-inline-wrap' . $headerClasses . '">' . '<div class="t3-form-field-header-inline-ctrl">' . $ctrl . '</div>' . '<div class="t3-form-field-header-inline-body">' . $mediaContainer . '<div class="t3-form-field-header-inline-summary">' . $label . '</div>' . '</div>' . '</div>';
     return $header;
 }
 /**
  * Calculate the document root part to the instance from PATH_thisScript.
  * This is based on the amount of subdirectories "under" PATH_site where PATH_thisScript is located.
  *
  * The following main scenarios for entry points exist by default in the TYPO3 core:
  * - Directly called documentRoot/index.php (-> FE call or eiD include): index.php is located in the same directory
  * as the main project. The document root is identical to the directory the script is located at.
  * - The install tool, located under typo3/sysext/install/Start/Install.php.
  * - A Backend script: This is the case for the typo3/index.php dispatcher and other entry scripts like 'cli_dispatch.phpsh'
  * or 'typo3/index.php' that are located inside typo3/ directly.
  *
  * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
  * @return string Absolute path to document root of installation
  */
 protected static function getPathSite($entryPointLevel)
 {
     $entryScriptDirectory = self::getUnifiedDirectoryName(PATH_thisScript);
     if ($entryPointLevel > 0) {
         list($pathSite) = GeneralUtility::revExplode('/', $entryScriptDirectory, $entryPointLevel + 1);
     } else {
         $pathSite = $entryScriptDirectory;
     }
     return $pathSite . '/';
 }
示例#24
0
 /**
  * Lets you split the content by LF and proces each line independently. Used to format content made with the RTE.
  *
  * @param string $theValue The input value
  * @param array $conf TypoScript options
  * @return string The processed input value being returned; Splitted lines imploded by LF again.
  * @access private
  */
 public function encaps_lineSplit($theValue, $conf)
 {
     $lParts = explode(LF, $theValue);
     $encapTags = GeneralUtility::trimExplode(',', strtolower($conf['encapsTagList']), true);
     $nonWrappedTag = $conf['nonWrappedTag'];
     $defaultAlign = isset($conf['defaultAlign.']) ? trim($this->stdWrap($conf['defaultAlign'], $conf['defaultAlign.'])) : trim($conf['defaultAlign']);
     if ((string) $theValue === '') {
         return '';
     }
     $str_content = '';
     foreach ($lParts as $k => $l) {
         $sameBeginEnd = 0;
         $emptyTag = 0;
         $l = trim($l);
         $attrib = array();
         $nWrapped = 0;
         $tagName = '';
         if ($l[0] === '<' && substr($l, -1) === '>') {
             $fwParts = explode('>', substr($l, 1), 2);
             list($tagName) = explode(' ', $fwParts[0], 2);
             if (!$fwParts[1]) {
                 if (substr($tagName, -1) === '/') {
                     $tagName = substr($tagName, 0, -1);
                 }
                 if (substr($fwParts[0], -1) === '/') {
                     $sameBeginEnd = 1;
                     $emptyTag = 1;
                     $attrib = GeneralUtility::get_tag_attributes('<' . substr($fwParts[0], 0, -1) . '>');
                 }
             } else {
                 $backParts = GeneralUtility::revExplode('<', substr($fwParts[1], 0, -1), 2);
                 $attrib = GeneralUtility::get_tag_attributes('<' . $fwParts[0] . '>');
                 $str_content = $backParts[0];
                 $sameBeginEnd = substr(strtolower($backParts[1]), 1, strlen($tagName)) === strtolower($tagName);
             }
         }
         if ($sameBeginEnd && in_array(strtolower($tagName), $encapTags)) {
             $uTagName = strtoupper($tagName);
             $uTagName = strtoupper($conf['remapTag.'][$uTagName] ? $conf['remapTag.'][$uTagName] : $uTagName);
         } else {
             $uTagName = strtoupper($nonWrappedTag);
             // The line will be wrapped: $uTagName should not be an empty tag
             $emptyTag = 0;
             $str_content = $lParts[$k];
             $nWrapped = 1;
             $attrib = array();
         }
         // Wrapping all inner-content:
         if (is_array($conf['innerStdWrap_all.'])) {
             $str_content = $this->stdWrap($str_content, $conf['innerStdWrap_all.']);
         }
         if ($uTagName) {
             // Setting common attributes
             if (is_array($conf['addAttributes.'][$uTagName . '.'])) {
                 foreach ($conf['addAttributes.'][$uTagName . '.'] as $kk => $vv) {
                     if (!is_array($vv)) {
                         if ((string) $conf['addAttributes.'][$uTagName . '.'][$kk . '.']['setOnly'] === 'blank') {
                             if ((string) $attrib[$kk] === '') {
                                 $attrib[$kk] = $vv;
                             }
                         } elseif ((string) $conf['addAttributes.'][$uTagName . '.'][$kk . '.']['setOnly'] === 'exists') {
                             if (!isset($attrib[$kk])) {
                                 $attrib[$kk] = $vv;
                             }
                         } else {
                             $attrib[$kk] = $vv;
                         }
                     }
                 }
             }
             // Wrapping all inner-content:
             if (is_array($conf['encapsLinesStdWrap.'][$uTagName . '.'])) {
                 $str_content = $this->stdWrap($str_content, $conf['encapsLinesStdWrap.'][$uTagName . '.']);
             }
             // Default align
             if (!$attrib['align'] && $defaultAlign) {
                 $attrib['align'] = $defaultAlign;
             }
             $params = GeneralUtility::implodeAttributes($attrib, 1);
             if (!($conf['removeWrapping'] && !($emptyTag && $conf['removeWrapping.']['keepSingleTag']))) {
                 if ($emptyTag) {
                     $str_content = '<' . strtolower($uTagName) . (trim($params) ? ' ' . trim($params) : '') . ' />';
                 } else {
                     $str_content = '<' . strtolower($uTagName) . (trim($params) ? ' ' . trim($params) : '') . '>' . $str_content . '</' . strtolower($uTagName) . '>';
                 }
             }
         }
         if ($nWrapped && $conf['wrapNonWrappedLines']) {
             $str_content = $this->wrap($str_content, $conf['wrapNonWrappedLines']);
         }
         $lParts[$k] = $str_content;
     }
     return implode(LF, $lParts);
 }
示例#25
0
 /**
  * Parse old curl options and set new http ones instead
  *
  * @TODO: Move this functionality to the silent updater in the Install Tool
  * @return Bootstrap
  */
 protected function transferDeprecatedCurlSettings()
 {
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'])) {
         $curlProxy = rtrim(preg_replace('#^https?://#', '', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']), '/');
         $proxyParts = Utility\GeneralUtility::revExplode(':', $curlProxy, 2);
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
     }
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'])) {
         $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
     }
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']) {
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter'] = 'curl';
     }
     return $this;
 }
示例#26
0
 /**
  * returns a array of names available tx_linkhandler_tabHandler
  */
 protected function getAllRegisteredTabHandlerClassnames()
 {
     $default = array('AOE\\Linkhandler\\RecordTab');
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['linkhandler/class.tx_linkhandler_browselinkshooks.php'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['linkhandler/class.tx_linkhandler_browselinkshooks.php'] as $tabHandler) {
             list($file, $class) = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode(':', $tabHandler, 2);
             $default[] = $class;
         }
     }
     return $default;
 }
    /**
     * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
     * Later on the command-icons are inserted here.
     *
     * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
     * @param string $foreign_table The foreign_table we create a header for
     * @param array $data Current data
     * @param array $config content of $PA['fieldConf']['config']
     * @param bool $isVirtualRecord
     * @return string The HTML code of the header
     */
    protected function renderForeignRecordHeader($parentUid, $foreign_table, $data, $config, $isVirtualRecord = false)
    {
        $rec = $data['databaseRow'];
        // Init:
        $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']);
        $objectId = $domObjectId . '-' . $foreign_table . '-' . $rec['uid'];
        // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
        // Pre-Processing:
        $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
        $hasForeignLabel = (bool) (!$isOnSymmetricSide && $config['foreign_label']);
        $hasSymmetricLabel = (bool) $isOnSymmetricSide && $config['symmetric_label'];
        // Get the record title/label for a record:
        // Try using a self-defined user function only for formatted labels
        if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
            $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config));
            // callUserFunction requires a third parameter, but we don't want to give $this as reference!
            $null = null;
            GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
            $recTitle = $params['title'];
            // Try using a normal self-defined user function
        } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
            $recTitle = $data['recordTitle'];
        } elseif ($hasForeignLabel || $hasSymmetricLabel) {
            $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
            // Render title for everything else than group/db:
            if (isset($this->data['processedTca']['columns'][$titleCol]['config']['type']) && $this->data['processedTca']['columns'][$titleCol]['config']['type'] === 'group' && isset($this->data['processedTca']['columns'][$titleCol]['config']['internal_type']) && $this->data['processedTca']['columns'][$titleCol]['config']['internal_type'] === 'db') {
                $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, false);
            } else {
                // $recTitle could be something like: "tx_table_123|...",
                $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]);
                $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2);
                $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]);
                $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, false);
            }
            $recTitle = BackendUtility::getRecordTitlePrep($recTitle);
            if (trim($recTitle) === '') {
                $recTitle = BackendUtility::getNoRecordTitle(true);
            }
        } else {
            $recTitle = BackendUtility::getRecordTitle($foreign_table, FormEngineUtility::databaseRowCompatibility($rec), true);
        }
        $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table);
        $iconImg = '<span title="' . $altText . '" id="' . htmlspecialchars($objectId) . '_icon' . '">' . $this->iconFactory->getIconForRecord($foreign_table, $rec, Icon::SIZE_SMALL)->render() . '</span>';
        $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
        $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $data, $config, $isVirtualRecord);
        $thumbnail = false;
        // Renders a thumbnail for the header
        if (!empty($config['appearance']['headerThumbnail']['field'])) {
            $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
            $firstElement = array_shift(GeneralUtility::trimExplode('|', array_shift(GeneralUtility::trimExplode(',', $fieldValue))));
            $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
            if (!empty($fileUid)) {
                $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
                if ($fileObject && $fileObject->isMissing()) {
                    $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                    $thumbnail = $flashMessage->render();
                } elseif ($fileObject) {
                    $imageSetup = $config['appearance']['headerThumbnail'];
                    unset($imageSetup['field']);
                    if (!empty($rec['crop'])) {
                        $imageSetup['crop'] = $rec['crop'];
                    }
                    $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup);
                    $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                    // Only use a thumbnail if the processing process was successful by checking if image width is set
                    if ($processedImage->getProperty('width')) {
                        $imageUrl = $processedImage->getPublicUrl(true);
                        $thumbnail = '<img src="' . $imageUrl . '" ' . 'width="' . $processedImage->getProperty('width') . '" ' . 'height="' . $processedImage->getProperty('height') . '" ' . 'alt="' . htmlspecialchars($altText) . '" ' . 'title="' . htmlspecialchars($altText) . '">';
                    }
                }
            }
        }
        if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) {
            $mediaContainer = '<div class="form-irre-header-cell form-irre-header-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
        } else {
            $mediaContainer = '<div class="form-irre-header-cell form-irre-header-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
        }
        $header = $mediaContainer . '
				<div class="form-irre-header-cell form-irre-header-body">' . $label . '</div>
				<div class="form-irre-header-cell form-irre-header-control t3js-formengine-irre-control">' . $ctrl . '</div>';
        return $header;
    }
 /**
  * @test
  */
 public function revExplodeExplodesString()
 {
     $testString = 'my:words:here';
     $expectedArray = array('my:words', 'here');
     $actualArray = Utility\GeneralUtility::revExplode(':', $testString, 2);
     $this->assertEquals($expectedArray, $actualArray);
 }
示例#29
0
 /**
  * Where-clause for free index-uid value.
  *
  * @param int $freeIndexUid Free Index UID value to limit search to.
  * @return string WHERE SQL clause part.
  */
 public function freeIndexUidWhere($freeIndexUid)
 {
     if ($freeIndexUid < 0) {
         return '';
     }
     // First, look if the freeIndexUid is a meta configuration:
     $indexCfgRec = $this->databaseConnection->exec_SELECTgetSingleRow('indexcfgs', 'index_config', 'type=5 AND uid=' . (int) $freeIndexUid . $this->cObj->enableFields('index_config'));
     if (is_array($indexCfgRec)) {
         $refs = GeneralUtility::trimExplode(',', $indexCfgRec['indexcfgs']);
         $list = [-99];
         // Default value to protect against empty array.
         foreach ($refs as $ref) {
             list($table, $uid) = GeneralUtility::revExplode('_', $ref, 2);
             switch ($table) {
                 case 'index_config':
                     $idxRec = $this->databaseConnection->exec_SELECTgetSingleRow('uid', 'index_config', 'uid=' . (int) $uid . $this->cObj->enableFields('index_config'));
                     if ($idxRec) {
                         $list[] = $uid;
                     }
                     break;
                 case 'pages':
                     $indexCfgRecordsFromPid = $this->databaseConnection->exec_SELECTgetRows('uid', 'index_config', 'pid=' . (int) $uid . $this->cObj->enableFields('index_config'));
                     foreach ($indexCfgRecordsFromPid as $idxRec) {
                         $list[] = $idxRec['uid'];
                     }
                     break;
             }
         }
         $list = array_unique($list);
     } else {
         $list = [(int) $freeIndexUid];
     }
     return ' AND IP.freeIndexUid IN (' . implode(',', $list) . ')';
 }