示例#1
0
 /**
  * Initialize all required repository and factory objects.
  *
  * @throws \RuntimeException
  */
 protected function init()
 {
     $fileadminDirectory = rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/';
     /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
     $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
     $storages = $storageRepository->findAll();
     foreach ($storages as $storage) {
         $storageRecord = $storage->getStorageRecord();
         $configuration = $storage->getConfiguration();
         $isLocalDriver = $storageRecord['driver'] === 'Local';
         $isOnFileadmin = !empty($configuration['basePath']) && \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($configuration['basePath'], $fileadminDirectory);
         if ($isLocalDriver && $isOnFileadmin) {
             $this->storage = $storage;
             break;
         }
     }
     if (!isset($this->storage)) {
         throw new \RuntimeException('Local default storage could not be initialized - might be due to missing sys_file* tables.');
     }
     $this->fileFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
     //TYPO3 >= 6.2.0
     if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 6002000) {
         $this->fileIndexRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
     } else {
         //TYPO3 = 6.1
         $this->fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     }
     $this->targetDirectory = PATH_site . $fileadminDirectory . self::FOLDER_ContentUploads . '/';
 }
示例#2
0
 /**
  * Prepend current url if url is relative
  *
  * @param string $url given url
  * @return string
  */
 public static function prependDomain($url)
 {
     if (!GeneralUtility::isFirstPartOfStr($url, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
         $url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url;
     }
     return $url;
 }
示例#3
0
 /**
  * Post-processing to define which control items to show. Possibly own icons can be added here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreignTable The table (foreign_table) we create control-icons for
  * @param array $childRecord The current record of that foreign_table
  * @param array $childConfig TCA configuration of the current field of the child record
  * @param boolean $isVirtual Defines whether the current records is only virtually shown and not physically part of the parent record
  * @param array $controlItems (reference) Associative array with the currently available control items
  *
  * @return void
  */
 public function renderForeignRecordHeaderControl_postProcess($parentUid, $foreignTable, array $childRecord, array $childConfig, $isVirtual, array &$controlItems)
 {
     if ($foreignTable != 'sys_file_reference') {
         return;
     }
     if (!GeneralUtility::isFirstPartOfStr($childRecord['uid_local'], 'sys_file_')) {
         return;
     }
     $parts = BackendUtility::splitTable_Uid($childRecord['uid_local']);
     if (!isset($parts[1])) {
         return;
     }
     $table = $childRecord['tablenames'];
     $uid = $parentUid;
     $arguments = GeneralUtility::_GET();
     if ($this->isValidRecord($table, $uid) && isset($arguments['edit'])) {
         $returnUrl = ['edit' => $arguments['edit'], 'returnUrl' => $arguments['returnUrl']];
         if (GeneralUtility::compat_version('7.0')) {
             $returnUrlGenerated = BackendUtility::getModuleUrl('record_edit', $returnUrl);
         } else {
             $returnUrlGenerated = 'alt_doc.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $returnUrl, '', true, true), '&') . BackendUtility::getUrlToken('editRecord');
         }
         $wizardArguments = ['P' => ['referenceUid' => $childRecord['uid'], 'returnUrl' => $returnUrlGenerated]];
         $wizardUri = BackendUtility::getModuleUrl('focuspoint', $wizardArguments);
     } else {
         $wizardUri = 'javascript:alert(\'Please save the base record first, because open this wizard will not save the changes in the current form!\');';
     }
     /** @var WizardService $wizardService */
     $wizardService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\WizardService');
     $this->arrayUnshiftAssoc($controlItems, 'focuspoint', $wizardService->getWizardButton($wizardUri));
 }
示例#4
0
 /**
  * Type fetching method, based on the type that softRefParserObj returns
  *
  * @param array $value Reference properties
  * @param string $type Current type
  * @param string $key Validator hook name
  * @return string fetched type
  */
 public function fetchType($value, $type, $key)
 {
     if ($value['type'] === 'string' && GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'record:')) {
         $type = 'linkhandler';
     }
     return $type;
 }
示例#5
0
 /**
  * Create a tag
  *
  * @param array $params
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj
  * @return void
  * @throws \Exception
  */
 public function createTag(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
 {
     $request = GeneralUtility::_POST();
     try {
         // Check if a tag is submitted
         if (!isset($request['item']) || empty($request['item'])) {
             throw new \Exception('error_no-tag');
         }
         $itemUid = $request['uid'];
         if ((int) $itemUid === 0 && (strlen($itemUid) == 16 && !GeneralUtility::isFirstPartOfStr($itemUid, 'NEW'))) {
             throw new \Exception('error_no-uid');
         }
         $table = $request['table'];
         if (empty($table)) {
             throw new \Exception('error_no-table');
         }
         // Get tag uid
         $newTagId = $this->getTagUid($request);
         $ajaxObj->setContentFormat('javascript');
         $ajaxObj->setContent('');
         $response = array($newTagId, $request['item'], self::TAG, $table, 'tags', 'data[' . htmlspecialchars($table) . '][' . $itemUid . '][tags]', $itemUid);
         $ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
     } catch (\Exception $e) {
         $errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage());
         $ajaxObj->setError($errorMsg);
     }
 }
示例#6
0
 /**
  * Type fetching method, based on the type that softRefParserObj returns
  *
  * @param array $value Reference properties
  * @param string $type Current type
  * @param string $key Validator hook name
  * @return string fetched type
  */
 public function fetchType($value, $type, $key)
 {
     if (GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'file:')) {
         $type = 'file';
     }
     return $type;
 }
示例#7
0
 /**
  * Creates a valid email address for the sender of mail messages.
  *
  * Uses a fallback chain:
  * $TYPO3_CONF_VARS['MAIL']['defaultMailFromAddress'] ->
  * no-reply@FirstDomainRecordFound ->
  * no-reply@php_uname('n') ->
  * no-reply@example.com
  *
  * Ready to be passed to $mail->setFrom()
  *
  * @return string An email address
  */
 public static function getSystemFromAddress()
 {
     // default, first check the localconf setting
     $address = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
     if (!GeneralUtility::validEmail($address)) {
         // just get us a domain record we can use as the host
         $host = '';
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_domain');
         $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(HiddenRestriction::class));
         $domainRecord = $queryBuilder->select('domainName')->from('sys_domain')->orderBy('pid', 'ASC')->orderBy('sorting', 'ASC')->execute()->fetch();
         if (!empty($domainRecord['domainName'])) {
             $tempUrl = $domainRecord['domainName'];
             if (!GeneralUtility::isFirstPartOfStr($tempUrl, 'http')) {
                 // shouldn't be the case anyways, but you never know
                 // ... there're crazy people out there
                 $tempUrl = 'http://' . $tempUrl;
             }
             $host = parse_url($tempUrl, PHP_URL_HOST);
         }
         $address = 'no-reply@' . $host;
         if (!GeneralUtility::validEmail($address)) {
             // still nothing, get host name from server
             $address = 'no-reply@' . php_uname('n');
             if (!GeneralUtility::validEmail($address)) {
                 // if everything fails use a dummy address
                 $address = '*****@*****.**';
             }
         }
     }
     return $address;
 }
示例#8
0
 /**
  * Add the label to a XML file
  *
  * @param string $extensionKey
  * @param string $key
  * @param string $default
  *
  * @return NULL
  */
 public function addLabel($extensionKey, $key, $default)
 {
     // Excelude
     if (!strlen($default)) {
         return;
     }
     if (!strlen($key)) {
         return;
     }
     if (!strlen($extensionKey)) {
         return;
     }
     if (GeneralUtility::isFirstPartOfStr($key, 'LLL:')) {
         return;
     }
     $absolutePath = $this->getAbsoluteFilename($extensionKey);
     $content = GeneralUtility::getUrl($absolutePath);
     if (strpos($content, ' index="' . $key . '"') !== false || trim($content) === '') {
         return;
     }
     $replace = '<languageKey index="default" type="array">' . LF . TAB . TAB . TAB . '<label index="' . $key . '">' . $this->wrapCdata($default) . '</label>';
     $content = str_replace('<languageKey index="default" type="array">', $replace, $content);
     FileUtility::writeFileAndCreateFolder($absolutePath, $content);
     $this->clearCache();
 }
示例#9
0
 /**
  * Returns the localized label of the LOCAL_LANG key, $key.
  *
  * @param string $key The key from the LOCAL_LANG array for which to return the value.
  * @param string $extensionName The name of the extension
  * @param array $arguments the arguments of the extension, being passed over to vsprintf
  * @return string|NULL The value from LOCAL_LANG or NULL if no translation was found.
  * @api
  * @todo : If vsprintf gets a malformed string, it returns FALSE! Should we throw an exception there?
  */
 public static function translate($key, $extensionName, $arguments = null)
 {
     $value = null;
     if (GeneralUtility::isFirstPartOfStr($key, 'LLL:')) {
         $value = self::translateFileReference($key);
     } else {
         self::initializeLocalization($extensionName);
         // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG
         if (!empty(self::$LOCAL_LANG[$extensionName][self::$languageKey][$key][0]['target']) || isset(self::$LOCAL_LANG_UNSET[$extensionName][self::$languageKey][$key])) {
             // Local language translation for key exists
             $value = self::$LOCAL_LANG[$extensionName][self::$languageKey][$key][0]['target'];
         } elseif (!empty(self::$alternativeLanguageKeys)) {
             $languages = array_reverse(self::$alternativeLanguageKeys);
             foreach ($languages as $language) {
                 if (!empty(self::$LOCAL_LANG[$extensionName][$language][$key][0]['target']) || isset(self::$LOCAL_LANG_UNSET[$extensionName][$language][$key])) {
                     // Alternative language translation for key exists
                     $value = self::$LOCAL_LANG[$extensionName][$language][$key][0]['target'];
                     break;
                 }
             }
         }
         if ($value === null && (!empty(self::$LOCAL_LANG[$extensionName]['default'][$key][0]['target']) || isset(self::$LOCAL_LANG_UNSET[$extensionName]['default'][$key]))) {
             // Default language translation for key exists
             // No charset conversion because default is English and thereby ASCII
             $value = self::$LOCAL_LANG[$extensionName]['default'][$key][0]['target'];
         }
     }
     if (is_array($arguments) && $value !== null) {
         return vsprintf($value, $arguments);
     } else {
         return $value;
     }
 }
示例#10
0
 /**
  * Remove the file if it is located within its album path.
  * That means, it does not remove files located in an other directory (like files imported by the directory importer)
  *
  * @param Tx_Yag_Domain_Model_Item $item
  */
 public function removeImageFileFromAlbumDirectory(Tx_Yag_Domain_Model_Item $item)
 {
     $albumPath = $this->getOrigFileDirectoryPathForAlbum($item->getAlbum());
     $imageFilePath = Tx_Yag_Domain_FileSystem_Div::makePathAbsolute($item->getSourceuri());
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($imageFilePath, $albumPath) && file_exists($imageFilePath)) {
         unlink($imageFilePath);
     }
 }
示例#11
0
 /**
  * @param Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn
  * @return string
  */
 public function renderColumnLabel(Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn)
 {
     $label = $headerColumn->getLabel();
     $label = Tx_PtExtlist_Utility_RenderValue::stdWrapIfPlainArray($label);
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($label, 'LLL:')) {
         $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label, '');
     }
     return $label;
 }
示例#12
0
 /**
  * @test
  */
 public function md5HashIsUpdatedToTemporarySaltedString()
 {
     $isSet = null;
     $originalPassword = '******';
     $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
     $this->assertTrue($isSet);
     $this->assertNotEquals($originalPassword, $saltedPassword);
     $this->assertTrue(GeneralUtility::isFirstPartOfStr($saltedPassword, 'M$'));
 }
示例#13
0
 /**
  * Tear down
  */
 public function tearDown()
 {
     foreach ($this->testNodesToDelete as $node) {
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
         }
     }
     parent::tearDown();
 }
示例#14
0
 /**
  * Find lost files in uploads/ folder
  * FIX METHOD: Simply delete the file...
  *
  * TODO: Add parameter to exclude filepath
  * TODO: Add parameter to list more file names/patterns to ignore
  * TODO: Add parameter to include RTEmagic images
  *
  * @return array
  * @todo Define visibility
  */
 public function main()
 {
     global $TYPO3_DB;
     // Initialize result array:
     $resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0), 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0), 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0), 'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3), 'warnings' => array('Warnings picked up', '', 2)), 'managedFiles' => array(), 'ignoredFiles' => array(), 'RTEmagicFiles' => array(), 'lostFiles' => array(), 'warnings' => array());
     // Get all files:
     $fileArr = array();
     $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/');
     $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($fileArr, PATH_site);
     $excludePaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->cli_argValue('--excludePath', 0), TRUE);
     // Traverse files and for each, look up if its found in the reference index.
     foreach ($fileArr as $key => $value) {
         $include = TRUE;
         foreach ($excludePaths as $exclPath) {
             if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($value, $exclPath)) {
                 $include = FALSE;
             }
         }
         $shortKey = \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($value);
         if ($include) {
             // First, allow "index.html", ".htaccess" files since they are often used for good reasons
             if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') {
                 unset($fileArr[$key]);
                 $resultArray['ignoredFiles'][$shortKey] = $value;
             } else {
                 // Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration)
                 $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $TYPO3_DB->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
                 // If found, unset entry:
                 if (count($recs)) {
                     unset($fileArr[$key]);
                     $resultArray['managedFiles'][$shortKey] = $value;
                     if (count($recs) > 1) {
                         $resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!';
                     }
                 } else {
                     // When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it:
                     if (preg_match('/^RTEmagic[P|C]_/', basename($value))) {
                         unset($fileArr[$key]);
                         $resultArray['RTEmagicFiles'][$shortKey] = $value;
                     } else {
                         // We conclude that the file is lost...:
                         unset($fileArr[$key]);
                         $resultArray['lostFiles'][$shortKey] = $value;
                     }
                 }
             }
         }
     }
     asort($resultArray['ignoredFiles']);
     asort($resultArray['managedFiles']);
     asort($resultArray['RTEmagicFiles']);
     asort($resultArray['lostFiles']);
     asort($resultArray['warnings']);
     // $fileArr variable should now be empty with all contents transferred to the result array keys.
     return $resultArray;
 }
示例#15
0
 /**
  * Modifies the select box of orderBy-options as a category menu
  * needs different ones then a news action
  *
  * @param array &$config configuration array
  * @return void
  */
 public function user_orderBy(array &$config)
 {
     $newItems = '';
     // check if the record has been saved once
     if (is_array($config['row']) && !empty($config['row']['pi_flexform'])) {
         $flexformConfig = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($config['row']['pi_flexform']);
         // check if there is a flexform configuration
         if (isset($flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'])) {
             $selectedActionList = $flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'];
             // check for selected action
             if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Category')) {
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByCategory'];
             } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Tag')) {
                 $this->removeNonValidOrderFields($config, 'tx_mooxnews_domain_model_tag');
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByTag'];
             } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Target')) {
                 $this->removeNonValidOrderFields($config, 'tx_mooxnews_domain_model_target');
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByTarget'];
             } else {
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByNews'];
                 $orderByNews = true;
             }
         }
     }
     // if a override configuration is found
     if (!empty($newItems)) {
         // remove default configuration
         $config['items'] = array();
         // empty default line
         array_push($config['items'], array('', ''));
         $newItemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $newItems, TRUE);
         $languageKey = 'LLL:EXT:moox_news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.';
         foreach ($newItemArray as $item) {
             // label: if empty, key (=field) is used
             $label = $GLOBALS['LANG']->sL($languageKey . $item, TRUE);
             if (empty($label)) {
                 $label = htmlspecialchars($item);
             }
             array_push($config['items'], array($label, $item));
         }
     }
     if ($orderByNews) {
         foreach ($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'] as $fieldname => $field) {
             $ll = 'LLL:EXT:' . $field['extkey'] . '/Resources/Private/Language/locallang_db.xml:';
             if ($field['addToMooxNewsFrontendSorting']) {
                 $prefix = $ll . 'tx_' . str_replace("_", "", $field['extkey']) . '_domain_model_news';
                 $prefix = $GLOBALS['LANG']->sL($prefix, TRUE) . ": ";
                 $label = $GLOBALS['LANG']->sL($field['label'], TRUE);
                 array_push($config['items'], array($prefix . $label, \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase($fieldname)));
             }
         }
     }
 }
 /**
  * Add options to FlexForm Selection - Options can be defined in TSConfig
  *
  * @param array $params
  * @return void
  */
 public function addOptions(&$params)
 {
     $this->initialize();
     $tSconfig = BackendUtility::getPagesTSconfig($this->getPid());
     $this->addCaptchaOption($params);
     if (!empty($tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'])) {
         $options = $tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'];
         foreach ((array) $options as $value => $label) {
             $params['items'][] = array(GeneralUtility::isFirstPartOfStr($label, 'LLL:') ? $this->languageService->sL($label) : $label, $value);
         }
     }
 }
 /**
  * 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;
 }
 public static function getFilePath($file, $absolutePath = true)
 {
     $path = $file;
     if (GeneralUtility::isFirstPartOfStr($file, 'file:')) {
         $fileReference = substr($file, 5);
         $resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
         $fileOrFolder = $resourceFactory->retrieveFileOrFolderObject($fileReference);
         $path = $fileOrFolder->getPublicUrl();
     }
     if ($absolutePath === true) {
         return GeneralUtility::getFileAbsFileName($path);
     }
     return $path;
 }
 /**
  * Add options to FlexForm Selection - Options can be defined in TSConfig
  *
  * @param $params
  * @param $pObj
  * @return void
  */
 public function addOptions(&$params, &$pObj)
 {
     $tSconfig = BackendUtility::getPagesTSconfig($this->getPid());
     // add Captcha field
     if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sr_freecap')) {
         $params['items'][] = array($GLOBALS['LANG']->sL('LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_user.captcha'), 'captcha');
     }
     // add fields from TSconfig
     if (!empty($tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'])) {
         $options = $tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'];
         foreach ((array) $options as $value => $label) {
             $params['items'][] = array(GeneralUtility::isFirstPartOfStr($label, 'LLL:') ? $GLOBALS['LANG']->sL($label) : $label, $value);
         }
     }
 }
示例#20
0
 /**
  * returns a label for the given key
  *
  * @param array $arguments
  * @return	string
  */
 public function execute(array $arguments = array())
 {
     $label = '';
     $isFullPath = FALSE;
     if (GeneralUtility::isFirstPartOfStr($arguments[0], 'FILE')) {
         $arguments[0] = substr($arguments[0], 5);
         $isFullPath = TRUE;
     }
     if ($isFullPath || GeneralUtility::isFirstPartOfStr($arguments[0], 'EXT')) {
         // a full path reference...
         $label = $this->resolveFullPathLabel($arguments[0]);
     } else {
         $label = $this->getLabel($this->languageFile, $arguments[0]);
     }
     return $label;
 }
示例#21
0
 /**
  * Post-processing to define which control items to show. Possibly own icons can be added here.
  *
  * @param string  $parentUid    The uid of the parent (embedding) record (uid or NEW...)
  * @param string  $foreignTable The table (foreign_table) we create control-icons for
  * @param array   $childRecord  The current record of that foreign_table
  * @param array   $childConfig  TCA configuration of the current field of the child record
  * @param boolean $isVirtual    Defines whether the current records is only virtually shown and not physically part of the parent record
  * @param array   $controlItems (reference) Associative array with the currently available control items
  *
  * @return void
  */
 public function renderForeignRecordHeaderControl_postProcess($parentUid, $foreignTable, array $childRecord, array $childConfig, $isVirtual, array &$controlItems)
 {
     if ($foreignTable != 'sys_file_reference') {
         return;
     }
     if (!GeneralUtility::isFirstPartOfStr($childRecord['uid_local'], 'sys_file_')) {
         return;
     }
     $parts = BackendUtility::splitTable_Uid($childRecord['uid_local']);
     if (!isset($parts[1])) {
         return;
     }
     $wizardArguments = array('P' => array('uid' => $this->getMetaDataUidByFileUid($parts[1]), 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
     $wizardUri = BackendUtility::getModuleUrl('focuspoint', $wizardArguments);
     $configuration = '<a href="' . $wizardUri . '" class="btn btn-default">' . IconUtility::getSpriteIcon('extensions-focuspoint-focuspoint') . '</a>';
     $this->arrayUnshiftAssoc($controlItems, 'focuspoint', $configuration);
 }
示例#22
0
 /**
  * Renders a meta tag
  *
  * @param boolean $useCurrentDomain If set, current domain is used
  * @param boolean $forceAbsoluteUrl If set, absolute url is forced
  * @return void
  */
 public function render($useCurrentDomain = FALSE, $forceAbsoluteUrl = FALSE)
 {
     // set current domain
     if ($useCurrentDomain) {
         $this->tag->addAttribute('content', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     }
     // prepend current domain
     if ($forceAbsoluteUrl) {
         $path = $this->arguments['content'];
         if (!GeneralUtility::isFirstPartOfStr($path, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
             $this->tag->addAttribute('content', rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/') . '/' . ltrim($this->arguments['content']), '/');
         }
     }
     if ($useCurrentDomain || isset($this->arguments['content']) && !empty($this->arguments['content'])) {
         \TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->getPageRenderer()->addMetaTag($this->tag->render());
     }
 }
 /**
  * Renders a script tag
  *
  * @param boolean $useCurrentDomain If set, current domain is used
  * @param boolean $forceAbsoluteUrl If set, absolute url is forced
  * @return void
  */
 public function render($useCurrentDomain = false, $forceAbsoluteUrl = false)
 {
     // set current domain
     if ($useCurrentDomain) {
         $this->tag->addAttribute('href', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     }
     // prepend current domain
     if ($forceAbsoluteUrl) {
         $path = $this->arguments['href'];
         if (!GeneralUtility::isFirstPartOfStr($path, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
             $this->tag->addAttribute('href', GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->arguments['href']);
         }
     }
     if ($useCurrentDomain || isset($this->arguments['href']) && !empty($this->arguments['href'])) {
         $this->getPageRenderer()->addHeaderData($this->tag->render());
     }
 }
 /**
  * Renders a meta tag
  *
  * @param boolean $useCurrentDomain If set, current domain is used
  * @param boolean $forceAbsoluteUrl If set, absolute url is forced
  * @return void
  */
 public function render($useCurrentDomain = FALSE, $forceAbsoluteUrl = FALSE)
 {
     // set current domain
     if ($useCurrentDomain) {
         $this->tag->addAttribute('content', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     }
     // prepend current domain
     if ($forceAbsoluteUrl) {
         $path = $this->arguments['content'];
         if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
             $this->tag->addAttribute('content', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->arguments['content']);
         }
     }
     if ($useCurrentDomain || isset($this->arguments['content']) && !empty($this->arguments['content'])) {
         $GLOBALS['TSFE']->getPageRenderer()->addMetaTag($this->tag->render());
     }
 }
示例#25
0
 /**
  * Renders a meta tag
  *
  * @param bool $useCurrentDomain If set, current domain is used
  * @param bool $forceAbsoluteUrl If set, absolute url is forced
  * @return void
  */
 public function render($useCurrentDomain = false, $forceAbsoluteUrl = false)
 {
     // set current domain
     if ($useCurrentDomain) {
         $this->tag->addAttribute('content', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
     }
     // prepend current domain
     if ($forceAbsoluteUrl) {
         $path = $this->arguments['content'];
         if (!GeneralUtility::isFirstPartOfStr($path, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
             $this->tag->addAttribute('content', rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/') . '/' . ltrim($this->arguments['content'], '/'));
         }
     }
     if ($useCurrentDomain || isset($this->arguments['content']) && !empty($this->arguments['content'])) {
         $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
         $pageRenderer->addMetaTag($this->tag->render());
     }
 }
示例#26
0
 /**
  * Get available template layouts for a certain page
  *
  * @param int $pageUid
  * @return array
  */
 public function getAvailableTemplateLayouts($pageUid)
 {
     $templateLayouts = array();
     // Check if the layouts are extended by ext_tables
     if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts'])) {
         $templateLayouts = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['templateLayouts'];
     }
     // Add TsConfig values
     foreach ($this->getTemplateLayoutsFromTsConfig($pageUid) as $templateKey => $title) {
         if (GeneralUtility::isFirstPartOfStr($title, '--div--')) {
             $optGroupParts = GeneralUtility::trimExplode(',', $title, true, 2);
             $title = $optGroupParts[1];
             $templateKey = $optGroupParts[0];
         }
         $templateLayouts[] = array($title, $templateKey);
     }
     return $templateLayouts;
 }
 /**
  * Updates the group assignment to corresponding user records.
  *
  * @param array $incomingFieldArray
  * @param string $table
  * @param int|string $id
  * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj
  * @return void
  */
 public function processDatamap_preProcessFieldArray(array &$incomingFieldArray, $table, $id, \TYPO3\CMS\Core\DataHandling\DataHandler $pObj)
 {
     if (GeneralUtility::inList('be_groups,fe_groups', $table)) {
         $userTable = $table === 'be_groups' ? 'be_users' : 'fe_users';
         $users = $this->getAssignedUsers($table, $id);
         $oldList = array();
         foreach ($users as $user) {
             $oldList[] = $user['uid'];
         }
         $newList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $incomingFieldArray['tx_mrusrgrpmgmt_users']);
         $removedUids = array_diff($oldList, $newList);
         $addedUids = array_diff($newList, $oldList);
         // Remove users that are not member anymore of the group
         foreach ($removedUids as $userUid) {
             if (!$userUid) {
                 continue;
             }
             $user = BackendUtility::getRecord($userTable, $userUid);
             $usergroups = GeneralUtility::trimExplode(',', $user['usergroup']);
             $key = array_search($id, $usergroups);
             unset($usergroups[$key]);
             $this->getDatabaseConnection()->exec_UPDATEquery($userTable, 'uid=' . $userUid, array('usergroup' => implode(',', $usergroups)));
         }
         // Add users that are now member of the group
         foreach ($addedUids as $userUid) {
             if (!$userUid) {
                 continue;
             }
             if (GeneralUtility::isFirstPartOfStr($userUid, $userTable . '_')) {
                 // New member is coming from suggest field
                 $userUid = substr($userUid, strlen($userTable . '_'));
             }
             $user = BackendUtility::getRecord($userTable, $userUid);
             $usergroups = GeneralUtility::trimExplode(',', $user['usergroup']);
             $usergroups[] = $id;
             $this->getDatabaseConnection()->exec_UPDATEquery($userTable, 'uid=' . $userUid, array('usergroup' => implode(',', $usergroups)));
         }
         // Remove virtual user column to prevent TYPO3 from
         // trying to save content to this non-existing column
         unset($incomingFieldArray['tx_mrusrgrpmgmt_users']);
     }
 }
示例#28
0
 /**
  * Recursively builds a sub menu structure for the current menu.
  *
  * @param array $facetOptions Array of facet options
  * @param string $menuName Name of the top level menu to build the sub menu structure for
  * @param integer $level The sub level depth
  * @return array Returns an array sub menu structure if a sub menu exists, an empty array otherwise
  */
 protected function getSubMenu(array $facetOptions, $menuName, $level)
 {
     $menu = array();
     $subMenuEntryPrefix = $level . '-' . $menuName;
     foreach ($facetOptions as $facetOptionKey => $facetOption) {
         // find the sub menu items for the current menu
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($facetOptionKey, $subMenuEntryPrefix)) {
             $currentMenu = array('title' => $this->getFacetOptionLabel($facetOptionKey, $facetOption['numberOfResults']), 'facetKey' => Tx_Solr_Facet_HierarchicalFacetRenderer::getLastPathSegmentFromHierarchicalFacetOption($facetOptionKey), 'numberOfResults' => $facetOption['numberOfResults'], '_OVERRIDE_HREF' => $facetOption['url'], 'ITEM_STATE' => $facetOption['selected'] ? 'ACT' : 'NO');
             $lastPathSegment = Tx_Solr_Facet_HierarchicalFacetRenderer::getLastPathSegmentFromHierarchicalFacetOption($facetOptionKey);
             // move one level down (recursion)
             $subMenu = $this->getSubMenu($facetOptions, $menuName . '/' . $lastPathSegment, $level + 1);
             if (!empty($subMenu)) {
                 $currentMenu['_SUB_MENU'] = $subMenu;
             }
             $menu[] = $currentMenu;
         }
     }
     // return one level up
     return $menu;
 }
示例#29
0
 /**
  * Returns the icon associated to a given document key.
  *
  * @param string $documentKey
  * @return string
  */
 public static function getIcon($documentKey)
 {
     $basePath = 'typo3conf/Documentation/';
     $documentPath = $basePath . $documentKey . '/';
     // Fallback icon
     $icon = ExtensionManagementUtility::siteRelPath('documentation') . 'ext_icon.png';
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
         // Standard extension icon
         $extensionKey = substr($documentKey, 20);
         if (ExtensionManagementUtility::isLoaded($extensionKey)) {
             $extensionPath = ExtensionManagementUtility::extPath($extensionKey);
             $siteRelativePath = ExtensionManagementUtility::siteRelPath($extensionKey);
             $icon = $siteRelativePath . ExtensionManagementUtility::getExtensionIcon($extensionPath);
         }
     } elseif (is_file(PATH_site . $documentPath . 'icon.png')) {
         $icon = $documentPath . 'icon.png';
     } elseif (is_file(PATH_site . $documentPath . 'icon.gif')) {
         $icon = $documentPath . 'icon.gif';
     }
     return $icon;
 }
示例#30
0
 /**
  * Modifies the select box of orderBy-options as a category menu
  * needs different ones then a news action
  *
  * @param array &$config configuration array
  * @return void
  */
 public function user_orderBy(array &$config)
 {
     $newItems = '';
     // check if the record has been saved once
     if (is_array($config['row']) && !empty($config['row']['pi_flexform'])) {
         $flexformConfig = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($config['row']['pi_flexform']);
         // check if there is a flexform configuration
         if (isset($flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'])) {
             $selectedActionList = $flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'];
             // check for selected action
             if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Category')) {
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByCategory'];
             } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Tag')) {
                 $this->removeNonValidOrderFields($config, 'tx_news_domain_model_tag');
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByTag'];
             } else {
                 $newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByNews'];
             }
         }
     }
     // if a override configuration is found
     if (!empty($newItems)) {
         // remove default configuration
         $config['items'] = array();
         // empty default line
         array_push($config['items'], array('', ''));
         $newItemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $newItems, TRUE);
         $languageKey = 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.';
         foreach ($newItemArray as $item) {
             // label: if empty, key (=field) is used
             $label = $GLOBALS['LANG']->sL($languageKey . $item, TRUE);
             if (empty($label)) {
                 $label = htmlspecialchars($item);
             }
             array_push($config['items'], array($label, $item));
         }
     }
 }