/** * 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(); }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration() { $registerRTEinJavascriptString = ''; if (!file_exists(PATH_site . $this->jsonFileName)) { $schema = array('types' => array(), 'properties' => array()); $fileName = 'EXT:rte_schema/Resources/Public/RDF/schema.rdfa'; $fileName = GeneralUtility::getFileAbsFileName($fileName); $rdf = GeneralUtility::getUrl($fileName); if ($rdf) { $this->parseSchema($rdf, $schema); } uasort($schema['types'], array($this, 'compareLabels')); uasort($schema['properties'], array($this, 'compareLabels')); // Insert no type and no property entries if ($this->isFrontend()) { $noSchema = $GLOBALS['TSFE']->getLLL('No type', $this->LOCAL_LANG); $noProperty = $GLOBALS['TSFE']->getLLL('No property', $this->LOCAL_LANG); } else { $noSchema = $GLOBALS['LANG']->getLL('No type'); $noProperty = $GLOBALS['LANG']->getLL('No property'); } array_unshift($schema['types'], array('name' => 'none', 'domain' => $noSchema, 'comment' => '')); array_unshift($schema['properties'], array('name' => 'none', 'domain' => $noProperty, 'comment' => '')); GeneralUtility::writeFileToTypo3tempDir(PATH_site . $this->jsonFileName, json_encode($schema)); } $output = ($this->isFrontend() && $GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '../') . $this->jsonFileName; $registerRTEinJavascriptString = 'RTEarea[editornumber].schemaUrl = "' . ($this->isFrontend() && $GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . $output . '";'; return $registerRTEinJavascriptString; }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration() { $schema = array('types' => array(), 'properties' => array()); // Parse configured schemas if (is_array($this->configuration['thisConfig']['schema.']) && is_array($this->configuration['thisConfig']['schema.']['sources.'])) { foreach ($this->configuration['thisConfig']['schema.']['sources.'] as $source) { $fileName = trim($source); $absolutePath = GeneralUtility::getFileAbsFileName($fileName); // Fallback to default schema file if configured file does not exists or is of zero size if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) { $fileName = 'EXT:' . $this->extensionKey . '/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf'; } $fileName = $this->getFullFileName($fileName); $rdf = GeneralUtility::getUrl($fileName); if ($rdf) { $this->parseSchema($rdf, $schema); } } } uasort($schema['types'], array($this, 'compareLabels')); uasort($schema['properties'], array($this, 'compareLabels')); // Insert no type and no property entries $languageService = $this->getLanguageService(); $noSchema = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type'); $noProperty = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property'); array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema)); array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty)); // Store json encoded array in temporary file return 'RTEarea[editornumber].schemaUrl = "' . $this->writeTemporaryFile('schema_' . $this->configuration['language'], 'js', json_encode($schema)) . '";'; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $grids = []; if (!ExtensionManagementUtility::isLoaded('gridelements')) { return $grids; } $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Grids/'; $files = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($files as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/Grids/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'grid.' . $pathInfo['filename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $path = 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Grids/' . $file; $icon = $extension ? $iconPath . $extension : false; $label = TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()); $content = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path)); $flexForm = 'EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Grids/' . $pathInfo['filename'] . '.xml'; $flexFormFile = GeneralUtility::getFileAbsFileName($flexForm); $flexFormContent = is_file($flexFormFile) ? GeneralUtility::getUrl($flexFormFile) : false; $grids[] = $this->getPageTsConfig($pathInfo['filename'], $label, $content, $icon, $flexFormContent); } return $grids; }
/** * Import command * * @param string $icsCalendarUri * @param int $pid */ public function importCommand($icsCalendarUri = NULL, $pid = NULL) { if ($icsCalendarUri === NULL || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) { $this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR); } if (!MathUtility::canBeInterpretedAsInteger($pid)) { $this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR); } // fetch external URI and write to file $this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO); $relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical'; $absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile); $content = GeneralUtility::getUrl($icsCalendarUri); GeneralUtility::writeFile($absoluteIcalFile, $content); // get Events from file $icalEvents = $this->getIcalEvents($absoluteIcalFile); $this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO); $events = $this->prepareEvents($icalEvents); $this->enqueueMessage('This is just a first draft. There are same missing fields. Will be part of the next release', 'Items', FlashMessage::ERROR); return; foreach ($events as $event) { $eventObject = $this->eventRepository->findOneByImportId($event['uid']); if ($eventObject instanceof Event) { // update $eventObject->setTitle($event['title']); $eventObject->setDescription($this->nl2br($event['description'])); $this->eventRepository->update($eventObject); $this->enqueueMessage('Update Event Meta data: ' . $eventObject->getTitle(), 'Update'); } else { // create $eventObject = new Event(); $eventObject->setPid($pid); $eventObject->setImportId($event['uid']); $eventObject->setTitle($event['title']); $eventObject->setDescription($this->nl2br($event['description'])); $configuration = new Configuration(); $configuration->setType(Configuration::TYPE_TIME); $configuration->setFrequency(Configuration::FREQUENCY_NONE); /** @var \DateTime $startDate */ $startDate = clone $event['start']; $startDate->setTime(0, 0, 0); $configuration->setStartDate($startDate); /** @var \DateTime $endDate */ $endDate = clone $event['end']; $endDate->setTime(0, 0, 0); $configuration->setEndDate($endDate); $startTime = $this->dateTimeToDaySeconds($event['start']); if ($startTime > 0) { $configuration->setStartTime($startTime); $configuration->setEndTime($this->dateTimeToDaySeconds($event['end'])); $configuration->setAllDay(FALSE); } else { $configuration->setAllDay(TRUE); } $eventObject->addCalendarize($configuration); $this->eventRepository->add($eventObject); $this->enqueueMessage('Add Event: ' . $eventObject->getTitle(), 'Add'); } } }
/** * @param $status * @param $table * @param $id * @param $fieldArray * @param $self */ function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$self) { if ($table == 'tx_html5videoplayer_domain_model_video') { $data = $fieldArray; if ($status == 'update') { $data = array_merge($GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_html5videoplayer_domain_model_video', 'uid=' . (int) $id), $data); } $vimeoUrl = $data['vimeo']; if (($status == 'update' || $status == 'new') && $vimeoUrl != '' && GeneralUtility::isValidUrl($vimeoUrl)) { if (preg_match('/https?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)/i', $vimeoUrl, $matches)) { $videoId = $matches[3]; $videoData = unserialize(GeneralUtility::getUrl('http://vimeo.com/api/v2/video/' . $videoId . '.php')); if (is_array($videoData)) { // We're only interested in index zero. $videoData = $videoData[0]; if (!isset($data['title']) || trim($data['title']) == '') { $fieldArray['title'] = $videoData['title']; } if (!isset($data['description']) || trim($data['description']) == '') { $fieldArray['description'] = $videoData['description']; } if (!isset($data['posterimage']) || trim($data['posterimage']) == '') { $resourceFactory = ResourceFactory::getInstance(); $folder = $resourceFactory->retrieveFileOrFolderObject($this->getUploadFolder()); $thumbnailData = GeneralUtility::getUrl($videoData['thumbnail_large']); $file = $folder->createFile(basename($videoData['thumbnail_large']) . '.jpg'); $file->setContents($thumbnailData); $fieldArray['posterimage'] = 'file:' . $file->getUid(); } } } } } }
/** * Parse a single file and does some magic * - Remove the <?php tags * - Remove the class definition (if set) * * @param string $filePath path of the file * @param boolean $baseClass If class definition should be removed * @return string path of the saved file * @throws \Exception * @throws \InvalidArgumentException */ protected function parseSingleFile($filePath, $baseClass = false) { if (!is_file($filePath)) { throw new \InvalidArgumentException(sprintf('File "%s" could not be found', $filePath)); } $code = GeneralUtility::getUrl($filePath); if ($baseClass) { $closingBracket = strrpos($code, '}'); $content = substr($code, 0, $closingBracket); $content = str_replace('<?php', '', $content); return $content; } else { /** @var ClassParser $classParser */ $classParser = GeneralUtility::makeInstance(ClassParser::class); $classParser->parse($filePath); $classParserInformation = $classParser->getFirstClass(); $codeInLines = explode(LF, $code); if (isset($classParserInformation['eol'])) { $innerPart = array_slice($codeInLines, $classParserInformation['start'], $classParserInformation['eol'] - $classParserInformation['start'] - 1); } else { $innerPart = array_slice($codeInLines, $classParserInformation['start']); } if (trim($innerPart[0] === '{')) { unset($innerPart[0]); } $codePart = implode(LF, $innerPart); $closingBracket = strrpos($codePart, '}'); $content = $this->getPartialInfo($filePath) . substr($codePart, 0, $closingBracket); return $content; } }
/** * @param array|NULL $backendUser * @param int $size * @param bool $showIcon * @return string */ public function render(array $backendUser = NULL, $size = 32, $showIcon = FALSE) { $size = (int) $size; if (!is_array($backendUser)) { $backendUser = $this->getBackendUser()->user; } $image = parent::render($backendUser, $size, $showIcon); if (!StringUtility::beginsWith($image, '<span class="avatar"><span class="avatar-image"></span>') || empty($backendUser['email'])) { return $image; } $cachedFilePath = PATH_site . 'typo3temp/t3gravatar/'; $cachedFileName = sha1($backendUser['email'] . $size) . '.jpg'; if (!file_exists($cachedFilePath . $cachedFileName)) { $gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower($backendUser['email'])) . '?s=' . $size . '&d=404'; $gravatarImage = GeneralUtility::getUrl($gravatar); if (empty($gravatarImage)) { return $image; } GeneralUtility::writeFileToTypo3tempDir($cachedFileName, $gravatarImage); } // Icon $icon = ''; if ($showIcon) { $icon = '<span class="avatar-icon">' . IconUtility::getSpriteIconForRecord('be_users', $backendUser) . '</span>'; } $relativeFilePath = PathUtility::getRelativePath(PATH_typo3, $cachedFilePath); return '<span class="avatar"><span class="avatar-image">' . '<img src="' . $relativeFilePath . $cachedFileName . '" width="' . $size . '" height="' . $size . '" /></span>' . $icon . '</span>'; }
function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) { if ($table == 'tx_mia3location_domain_model_location') { $where = 'uid = ' . $id; $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, $where); if (!is_array($rows)) { return; } $row = current($rows); $address = implode(',', array($row['street'], $row['zip'], $row['city'], 'Deutschland')); // if there is a longitude and latitude present // do not update these fields and just return if (isset($row['longitude']) && !empty($row['longitude']) && (isset($row['latitude']) && !empty($row['latitude']))) { return; } $apiURL = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false&language=de'; $addressData = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($apiURL); $adr = json_decode($addressData); $coordinates = $adr->results[0]->geometry->location; if ($coordinates !== null) { if (!empty($fieldArray['latitude']) && $fieldArray['latitude'] !== $row['latitude']) { } else { $fieldArray['latitude'] = $coordinates->lat; } if (!empty($fieldArray['longitude']) && $fieldArray['longitude'] !== $row['longitude']) { } else { $fieldArray['longitude'] = $coordinates->lng; } } } }
/** * Import command * * @param string $icsCalendarUri * @param int $pid */ public function importCommand($icsCalendarUri = null, $pid = null) { if ($icsCalendarUri === null || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) { $this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR); return; } if (!MathUtility::canBeInterpretedAsInteger($pid)) { $this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR); return; } // fetch external URI and write to file $this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO); $relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical'; $absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile); $content = GeneralUtility::getUrl($icsCalendarUri); GeneralUtility::writeFile($absoluteIcalFile, $content); // get Events from file $icalEvents = $this->getIcalEvents($absoluteIcalFile); $this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO); $events = $this->prepareEvents($icalEvents); $this->enqueueMessage('Found ' . sizeof($events) . ' events in ' . $icsCalendarUri, 'Items', FlashMessage::INFO); /** @var Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); $this->enqueueMessage('Send the ' . __CLASS__ . '::importCommand signal for each event.', 'Signal', FlashMessage::INFO); foreach ($events as $event) { $arguments = ['event' => $event, 'commandController' => $this, 'pid' => $pid, 'handled' => false]; $signalSlotDispatcher->dispatch(__CLASS__, 'importCommand', $arguments); } }
/** * Load the xclass template and cache it in a local property * * @return null */ protected function loadXclassTemplate() { if (!self::$xclassTemplate) { $xclassTemplatePath = ExtensionManagementUtility::extPath('autoloader') . 'Resources/Private/Templates/Xclass/Aspect.tmpl'; self::$xclassTemplate = GeneralUtility::getUrl($xclassTemplatePath); } }
/** * Creates a new backend layout using the given record data. * * @param string $file * @return BackendLayout */ protected function createBackendLayout($file) { $fileInformation = pathinfo($file); $backendLayout = BackendLayout::create($fileInformation['filename'], $this->getTitle($fileInformation), GeneralUtility::getUrl($file)); $this->addIcon($fileInformation, $backendLayout); return $backendLayout; }
/** * Do the language pack update * * @param string $extensionKey: extension key of the language pack * @return void */ public function doUpdate($extensionKey) { $extPath = ExtensionManagementUtility::extPath($extensionKey); $fileContent = explode(LF, GeneralUtility::getUrl($extPath . 'ext_tables_static+adt.sql')); // SQL parser was moved from core to dbal in TYPO3 CMS 7.5 if (is_object($GLOBALS['TYPO3_DB']->SQLparser)) { $sqlParser = $GLOBALS['TYPO3_DB']->SQLparser; } else { $sqlParser = $this->objectManager->get('SJBR\\StaticInfoTables\\Database\\SqlParser'); } foreach ($fileContent as $line) { $line = trim($line); if ($line && preg_match('#^UPDATE#i', $line)) { $parsedResult = $sqlParser->parseSQL($line); // WHERE clause $whereClause = $sqlParser->compileWhereClause($parsedResult['WHERE']); // Fields $fields = array(); foreach ($parsedResult['FIELDS'] as $fN => $fV) { $fields[$fN] = $fV[0]; } $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($parsedResult['TABLE'], $whereClause, $fields, TRUE); } } }
/** * Check and create the TCA information * disable this for better performance */ public static function checkAndCreateTcaInformation() { $register = SmartObjectRegister::getRegister(); $baseTemplatePath = ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/TcaFiles/'); $defaultTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Default.tmpl'); $overrideTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Override.tmpl'); $search = ['__modelName__', '__tableName__', '__extensionKey__']; foreach ($register as $model) { $extensionKey = ClassNamingUtility::getExtensionKeyByModel($model); $basePath = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/TCA/'; $tableName = ModelUtility::getTableNameByModelReflectionAnnotation($model); if ($tableName !== '') { $tcaFileName = $basePath . 'Overrides/' . $tableName . '.php'; $template = $overrideTemplate; } else { $tableName = ModelUtility::getTableNameByModelName($model); $tcaFileName = $basePath . $tableName . '.php'; $template = $defaultTemplate; } if (!is_file($tcaFileName)) { $replace = [str_replace('\\', '\\\\', $model), $tableName, $extensionKey]; $content = str_replace($search, $replace, $template); FileUtility::writeFileAndCreateFolder($tcaFileName, $content); } } }
/** * This is the main method that is called when a task is executed * It MUST be implemented by all classes inheriting from this one * Note that there is no error handling, errors and failures are expected * to be handled and logged by the client implementations. * Should return true on successful execution, false on error. * * @return boolean Returns true on successful execution, false on error */ public function execute() { $success = false; $this->init(); /** @var \TYPO3\CMS\Core\Registry $registry */ $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); $syncLock = $registry->get(static::$package, 'synchronisationLock'); $content = GeneralUtility::getUrl($this->config['masterUrl']); if ($content && ($syncLock === 0 || $syncLock < time())) { $lockUntil = time() - $this->config['updateInterval'] + self::LOCK_INTERVAL; $registry->set(static::$package, 'synchronisationLock', $lockUntil); $response = json_decode($content, true); if ($response['success']) { $key = $this->config['preSharedKey']; $encrypted = $response['data']; $data = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), ""); $records = json_decode($data, true); if (count($records)) { $this->synchronizeUsers($records); $success = true; } else { GeneralUtility::sysLog('No users to be synchronized', self::$extKey, 3); } } else { GeneralUtility::sysLog($response['errors'][0], self::$extKey, 3); } $registry->set(static::$package, 'synchronisationLock', 0); } return $success; }
/** * try to find a similar poiCollection. If found connect it with current record. * * @param string $status "new" od something else to update the record * @param string $table The table name * @param int $uid The UID of the new or updated record. Can be prepended with NEW if record is new. Use: $this->substNEWwithIDs to convert * @param array $fieldArray The fields of the current record * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj */ public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler $pObj) { // process this hook only on expected table if ($table !== 'tx_clubdirectory_domain_model_address') { return; } $this->init(); if ($status === 'new') { $uid = current($pObj->substNEWwithIDs); } $this->currentRecord = $this->getFullRecord($table, $uid); if ($this->currentRecord['tx_maps2_uid']) { // sync categories $this->updateMmEntries(); } else { // create new map-record and set them in relation $jSon = GeneralUtility::getUrl('http://maps.googleapis.com/maps/api/geocode/json?address=' . $this->getAddress() . '&sensor=false'); $response = json_decode($jSon, true); if (is_array($response) && $response['status'] === 'OK') { $location = $response['results'][0]['geometry']['location']; $address = $response['results'][0]['formatted_address']; $poiUid = $this->createNewPoiCollection($location, $address); $this->updateCurrentRecord($poiUid); // sync categories $this->updateMmEntries(); } } }
/** * Get OEmbed data * * @param string $mediaId * @return array|NULL */ protected function getOEmbedData($mediaId) { $oEmbed = GeneralUtility::getUrl($this->getOEmbedUrl($mediaId)); if ($oEmbed) { $oEmbed = json_decode($oEmbed, true); } return $oEmbed; }
public function __construct() { $this->logger = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogManager')->getLogger(__CLASS__); $this->flexFormService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\FlexFormService'); $url = ExtensionManagementUtility::extPath('news_ttnewsimport') . 'Resources/Private/Template/flexform.txt'; $this->newsFlexConfig = json_decode(GeneralUtility::getUrl($url), TRUE); $this->categories = $this->getDatabaseConnection()->exec_SELECTgetRows('uid,import_id,title', 'sys_category', 'import_source="TT_NEWS_CATEGORY_IMPORT"', '', '', '', 'import_id'); }
/** * Creates a new backend layout (object) using the given record data. * * @param array $data * @return BackendLayout */ protected function createBackendLayout(array $data) { $configurationData = GeneralUtility::getUrl($data['configFilePath']); $configurationData = str_replace('###PACKAGE_KEY###', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['Staempfli/TemplateBootstrap']['PackageKey'], $configurationData); $backendLayout = BackendLayout::create($data['layoutKey'], $data['title'], $configurationData); $backendLayout->setIconPath($this->getIconPath($data['icon'])); $backendLayout->setData($data); return $backendLayout; }
/** * Create a backend layout with the given information * * @param $info * * @return mixed */ protected function createBackendLayout($info) { $fileName = GeneralUtility::getFileAbsFileName($info['path']); $backendLayout = BackendLayout::create($this->getIdentifier($info), $info['label'], GeneralUtility::getUrl($fileName)); if ($info['icon']) { $backendLayout->setIconPath(str_replace(PATH_site, '', $info['icon'])); } return $backendLayout; }
/** * Find configuration options by extension * * @param array $extension array with extension information * @return null|SplObjectStorage */ public function findByExtension(array $extension) { $configRaw = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_site . $extension['siteRelPath'] . '/ext_conf_template.txt'); $configurationObjectStorage = NULL; if ($configRaw) { $configurationObjectStorage = $this->convertRawConfigurationToObject($configRaw, $extension); } return $configurationObjectStorage; }
public function execute() { $urls = GeneralUtility::trimExplode(LF, $this->urlsToCrawl, TRUE); if (is_array($urls)) { foreach ($urls as $key => $url) { GeneralUtility::getUrl($url); } } return TRUE; }
/** * Create .htaccess file. */ public function createHtaccessFile() { $htAccessFile = GeneralUtility::getFileAbsFileName(".htaccess"); if (file_exists($htAccessFile)) { $this->addMessage(FlashMessage::NOTICE, '.htaccess not created', ' File .htaccess exists already in the root directory.'); return; } $htAccessContent = GeneralUtility::getUrl(PATH_site . 'typo3_src/_.htaccess'); GeneralUtility::writeFile($htAccessFile, $htAccessContent, TRUE); $this->addMessage(FlashMessage::OK, '.htaccess file created', 'File .htaccess was created in the root directory.'); }
/** * Get Address from geo coordinates * * @param float $lat * @param float $lng * @return array all location infos * ['street_number'] = 12; * ['route'] = 'Kunstmuehlstr.'; * ['locality'] = 'Rosenheim'; * ['country'] = 'Germany'; * ['postal_code'] = '83026'; */ protected function getAddressFromGeo($lat, $lng) { $result = array(); $json = GeneralUtility::getUrl('https://maps.googleapis.com/maps/api/geocode/json?sensor=false®ion=de&latlng=' . urlencode($lat . ',' . $lng)); $jsonDecoded = json_decode($json, TRUE); if (!empty($jsonDecoded['results'])) { foreach ((array) $jsonDecoded['results'][0]['address_components'] as $values) { $result[$values['types'][0]] = $values['long_name']; } } return $result; }
/** * Fetch URL content * Wrapper function so we can mock this for testing * * @param string $source * @param string $postVars * @return string */ public function fetchRawContent($source, $postVars = NULL) { if (is_file($source)) { return file_get_contents($source); } elseif ($postVars !== NULL) { $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => $postVars)); $context = stream_context_create($options); return file_get_contents($source, false, $context); } else { return GeneralUtility::getUrl($source); } }
/** * Include CSS Content * * @param boolean $compress Define if file should be compressed * @param string $path Path to the CSS file which should be included * @return void */ public function render($compress = true, $path = null) { $content = trim($this->renderChildren()); if (!is_null($path) && strtolower(substr($path, -4)) === '.css') { $content .= GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path)); } $name = md5($content); if (!empty($content)) { /** @var PageRenderer $pageRenderer */ $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->addCssInlineBlock($name, $content, $compress); } }
/** * Get local absolute file path to preview image * * @param File $file * @return string */ public function getPreviewImage(File $file) { $videoId = $this->getOnlineMediaId($file); $temporaryFileName = $this->getTempFolderPath() . 'youtube_' . md5($videoId) . '.jpg'; if (!file_exists($temporaryFileName)) { $previewImage = GeneralUtility::getUrl(sprintf('https://img.youtube.com/vi/%s/0.jpg', $videoId)); if ($previewImage !== false) { file_put_contents($temporaryFileName, $previewImage); GeneralUtility::fixPermissions($temporaryFileName); } } return $temporaryFileName; }
/** * Do the language pack update * * @return void */ public function doUpdate() { $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ods_osm'); $fileContent = explode(LF, \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extPath . 'ext_tables_static+adt.sql')); $GLOBALS['TYPO3_DB']->sql_query('TRUNCATE tx_odsosm_layer'); foreach ($fileContent as $line) { $line = trim($line); if ($line && preg_match('#^INSERT#i', $line)) { $GLOBALS['TYPO3_DB']->sql_query($line); } } return true; }
/** * Get the ICS events in an array * * @param string $paramUrl * * @return array */ function toArray($paramUrl) { $tempFileName = $this->getCheckedCacheFolder() . GeneralUtility::shortMD5($paramUrl); if (!is_file($tempFileName) || filemtime($tempFileName) < time() - DateTimeUtility::SECONDS_HOUR) { $icsFile = GeneralUtility::getUrl($paramUrl); GeneralUtility::writeFile($tempFileName, $icsFile); } $backend = new ICalParser(); if ($backend->parseFromFile($tempFileName)) { return $backend->getEvents(); } return []; }
/** * Get the ICS events in an array * * @param string $paramUrl * * @return array */ function toArray($paramUrl) { $tempFileName = GeneralUtility::getFileAbsFileName('typo3temp/calendarize_temp_' . GeneralUtility::shortMD5($paramUrl)); if (filemtime($tempFileName) < time() - 60 * 60) { $icsFile = GeneralUtility::getUrl($paramUrl); GeneralUtility::writeFile($tempFileName, $icsFile); } $backend = new ICalParser(); if ($backend->parseFromFile($tempFileName)) { return $backend->getEvents(); } return array(); }