Ejemplo n.º 1
1
 /**
  * Returns information about this extension plugin
  *
  * @param array $params Parameters to the hook
  *
  * @return string Information about pi1 plugin
  * @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar
  */
 public function getExtensionSummary(array $params)
 {
     $relIconPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ExtensionManagementUtility::siteRelPath('calendarize') . 'ext_icon.png';
     $this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService');
     $this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService');
     $this->layoutService->setTitle('<img src="' . $relIconPath . '" /> Calendarize');
     if ($params['row']['list_type'] != 'calendarize_calendar') {
         return '';
     }
     $this->flexFormService->load($params['row']['pi_flexform']);
     if (!$this->flexFormService->isValid()) {
         return '';
     }
     $actions = $this->flexFormService->get('switchableControllerActions', 'main');
     $parts = GeneralUtility::trimExplode(';', $actions, true);
     $parts = array_map(function ($element) {
         $split = explode('->', $element);
         return ucfirst($split[1]);
     }, $parts);
     $actionKey = lcfirst(implode('', $parts));
     $this->layoutService->addRow(LocalizationUtility::translate('mode', 'calendarize'), LocalizationUtility::translate('mode.' . $actionKey, 'calendarize'));
     $this->layoutService->addRow(LocalizationUtility::translate('configuration', 'calendarize'), $this->flexFormService->get('settings.configuration', 'main'));
     if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) {
         $this->layoutService->addRow(LocalizationUtility::translate('hide.pagination.teaser', 'calendarize'), '!!!');
     }
     $this->addPageIdsToTable();
     return $this->layoutService->render();
 }
 /**
  * Echoes an exception for the web.
  *
  * @param \Exception $exception The exception
  * @return void
  */
 public function echoExceptionWeb(\Exception $exception)
 {
     $this->sendStatusHeaders($exception);
     $this->writeLogEntries($exception, self::CONTEXT_WEB);
     $messageObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage', $this->getMessage($exception), $this->getTitle($exception));
     $messageObj->output();
 }
Ejemplo n.º 3
0
    /**
     * This method is called by the Scheduler task that triggers
     * the autopublication process
     * It searches for workspaces whose publication date is in the past
     * and publishes them
     *
     * @return void
     */
    public function autoPublishWorkspaces()
    {
        // Temporarily set admin rights
        // @todo once workspaces are cleaned up a better solution should be implemented
        $currentAdminStatus = $GLOBALS['BE_USER']->user['admin'];
        $GLOBALS['BE_USER']->user['admin'] = 1;
        // Select all workspaces that needs to be published / unpublished:
        $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,swap_modes,publish_time,unpublish_time', 'sys_workspace', 'pid=0
				AND
				((publish_time!=0 AND publish_time<=' . (int) $GLOBALS['EXEC_TIME'] . ')
				OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<=' . (int) $GLOBALS['EXEC_TIME'] . '))' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_workspace'));
        $workspaceService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
        foreach ($workspaces as $rec) {
            // First, clear start/end time so it doesn't get select once again:
            $fieldArray = $rec['publish_time'] != 0 ? array('publish_time' => 0) : array('unpublish_time' => 0);
            $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_workspace', 'uid=' . (int) $rec['uid'], $fieldArray);
            // Get CMD array:
            $cmd = $workspaceService->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes'] == 1);
            // $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace.
            // Execute CMD array:
            $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
            $tce->stripslashes_values = 0;
            $tce->start(array(), $cmd);
            $tce->process_cmdmap();
        }
        // Restore admin status
        $GLOBALS['BE_USER']->user['admin'] = $currentAdminStatus;
    }
Ejemplo n.º 4
0
 /**
  * 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 = file_get_contents($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)) . '";';
 }
Ejemplo n.º 5
0
 /**
  * Prepare a DatabaseConnection subject.
  * Used by driver specific test cases.
  *
  * @param string $driver Driver to use like "mssql", "oci8" and "postgres7"
  * @param array $configuration Dbal configuration array
  * @return \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
  */
 protected function prepareSubject($driver, array $configuration)
 {
     /** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
     $subject = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\DatabaseConnection::class, array('getFieldInfoCache'), array(), '', false);
     $subject->conf = $configuration;
     // Disable caching
     $mockCacheFrontend = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, array(), array(), '', false);
     $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
     // Inject SqlParser - Its logic is tested with the tests, too.
     $sqlParser = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\SqlParser::class, array('dummy'), array(), '', false);
     $sqlParser->_set('databaseConnection', $subject);
     $sqlParser->_set('sqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Adodb::class, $subject));
     $sqlParser->_set('nativeSqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Mysql::class, $subject));
     $subject->SQLparser = $sqlParser;
     // Mock away schema migration service from install tool
     $installerSqlMock = $this->getMock(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService::class, array('getFieldDefinitions_fileContent'), array(), '', false);
     $installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array()));
     $subject->_set('installerSql', $installerSqlMock);
     $subject->initialize();
     // Fake a working connection
     $handlerKey = '_DEFAULT';
     $subject->lastHandlerKey = $handlerKey;
     $adodbDriverClass = '\\ADODB_' . $driver;
     $subject->handlerInstance[$handlerKey] = new $adodbDriverClass();
     $subject->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($subject->handlerInstance[$handlerKey]);
     $subject->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
     return $subject;
 }
Ejemplo n.º 6
0
 /**
  * Returns all interceptors for a given Interception Point.
  *
  * @param int $interceptionPoint one of the \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
  * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface>
  */
 public function getInterceptors($interceptionPoint)
 {
     if (isset($this->interceptors[$interceptionPoint]) && $this->interceptors[$interceptionPoint] instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage) {
         return $this->interceptors[$interceptionPoint];
     }
     return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class);
 }
Ejemplo n.º 7
0
 /**
  * Returns an URL that switches the sorting indicator according to the
  * given sorting direction
  *
  * @param array $arguments Expects 'asc' or 'desc' as sorting direction in key 0
  * @return string
  * @throws \InvalidArgumentException when providing an invalid sorting direction
  */
 public function execute(array $arguments = array())
 {
     $content = '';
     $sortDirection = trim($arguments[0]);
     $configuration = Util::getSolrConfiguration();
     $contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $defaultImagePrefix = 'EXT:solr/Resources/Public/Images/Indicator';
     $sortViewHelperConfiguration = $configuration->getViewHelpersSortIndicatorConfiguration();
     switch ($sortDirection) {
         case 'asc':
             $imageConfiguration = $sortViewHelperConfiguration['up.'];
             if (!isset($imageConfiguration['file'])) {
                 $imageConfiguration['file'] = $defaultImagePrefix . 'Up.png';
             }
             $content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
             break;
         case 'desc':
             $imageConfiguration = $sortViewHelperConfiguration['down.'];
             if (!isset($imageConfiguration['file'])) {
                 $imageConfiguration['file'] = $defaultImagePrefix . 'Down.png';
             }
             $content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
             break;
         case '###SORT.CURRENT_DIRECTION###':
         case '':
             // ignore
             break;
         default:
             throw new \InvalidArgumentException('Invalid sorting direction "' . $arguments[0] . '", must be "asc" or "desc".', 1390868460);
     }
     return $content;
 }
Ejemplo n.º 8
0
 /**
  * Return the mime type of a file.
  *
  * @return string|bool Returns the mime type or FALSE if the mime type could not be discovered
  */
 public function getMimeType()
 {
     $mimeType = FALSE;
     if ($this->isFile()) {
         $fileExtensionToMimeTypeMapping = $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'];
         $lowercaseFileExtension = strtolower($this->getExtension());
         if (!empty($fileExtensionToMimeTypeMapping[$lowercaseFileExtension])) {
             $mimeType = $fileExtensionToMimeTypeMapping[$lowercaseFileExtension];
         } else {
             if (function_exists('finfo_file')) {
                 $fileInfo = new \finfo();
                 $mimeType = $fileInfo->file($this->getPathname(), FILEINFO_MIME_TYPE);
             } elseif (function_exists('mime_content_type')) {
                 $mimeType = mime_content_type($this->getPathname());
             }
         }
     }
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'] as $mimeTypeGuesser) {
             $hookParameters = array('mimeType' => &$mimeType);
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($mimeTypeGuesser, $hookParameters, $this);
         }
     }
     return $mimeType;
 }
 /**
  * test process datamap post process field array
  *
  * @test
  */
 public function processDatamapPostProcessFieldArray()
 {
     $hook = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('GridElementsTeam\\Gridelements\\Hooks\\DataHandler');
     $status = '';
     $table = 'tt_content';
     $id = 12;
     $fieldArray = array();
     $map = array(array('tt_content', 0, NULL, 'noPid'), array('tt_content', 0, 23, 123));
     $parentObj = $this->getMock('TYPO3\\CMS\\Core\\DataHandling\\DataHandler', array('getSortNumber'));
     $parentObj->isImporting = FALSE;
     $parentObj->expects($this->any())->method('getSortNumber')->will($this->returnValueMap($map));
     $hook->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $parentObj);
     $this->assertEquals(array(), $fieldArray);
     $_GET['cmd'] = array('tt_content' => array(12 => array('copy' => '23x24')));
     $status = 'new';
     $expectedFieldArray['sorting'] = 123;
     $hook->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $parentObj);
     $this->assertEquals($expectedFieldArray, $fieldArray);
     $_GET['cmd'] = array('tt_content' => array(12 => array('copy' => '-2x24')));
     $t3lib_db = $this->getMock('t3lib_db', array('exec_SELECTgetSingleRow'));
     $t3lib_db->expects($this->once())->method('exec_SELECTgetSingleRow')->will($this->returnValue(array('pid' => 0)));
     $GLOBALS['TYPO3_DB'] = $t3lib_db;
     $expectedFieldArray['sorting'] = null;
     $hook->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $parentObj);
     $this->assertEquals($expectedFieldArray, $fieldArray);
     $t3lib_db = $this->getMock('t3lib_db', array('exec_SELECTgetSingleRow'));
     $t3lib_db->expects($this->once())->method('exec_SELECTgetSingleRow')->will($this->returnValue(array('pid' => 23)));
     $GLOBALS['TYPO3_DB'] = $t3lib_db;
     $expectedFieldArray['sorting'] = '123';
     $hook->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $parentObj);
     $this->assertEquals($expectedFieldArray, $fieldArray);
 }
Ejemplo n.º 10
0
 /**
  * Constructor
  */
 public function __construct(\TYPO3\CMS\Core\Mail\MailMessage $mailMessage, array $typoScript)
 {
     $this->localCobj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
     $this->localizationHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Form\Localization::class);
     $this->mailMessage = $mailMessage;
     $this->typoScript = $typoScript;
 }
 protected function renderTypoLink($linkData)
 {
     $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
     $configuration = array('parameter' => $linkData, 'returnLast' => true);
     return $cObj->typolink('', $configuration);
 }
Ejemplo n.º 12
0
    /**
     * Test if default file format works
     *
     * @test
     * @return void
     */
    public function viewHelperReturnsCorrectJs()
    {
        $newsItem = new Tx_News_Domain_Model_News();
        $newsItem->setTitle('fobar');
        $language = 'en';
        $viewHelper = new Tx_News_ViewHelpers_Social_DisqusViewHelper();
        $settingsService = $this->getAccessibleMock('Tx_News_Service_SettingsService');
        $settingsService->expects($this->any())->method('getSettings')->will($this->returnValue(array('disqusLocale' => $language)));
        $viewHelper->injectSettingsService($settingsService);
        $actualResult = $viewHelper->render($newsItem, 'abcdef', 'http://typo3.org/dummy/fobar.html');
        $expectedCode = '<script type="text/javascript">
					var disqus_shortname = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue('abcdef', TRUE) . ';
					var disqus_identifier = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue('news_' . $newUid, TRUE) . ';
					var disqus_url = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue('http://typo3.org/dummy/fobar.html') . ';
					var disqus_title = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue('fobar', TRUE) . ';
					var disqus_config = function () {
						this.language = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($language) . ';
					};

					(function() {
						var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
						dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
						(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
					})();
				</script>';
        $this->assertEquals($expectedCode, $actualResult);
    }
Ejemplo n.º 13
0
 /**
  * Initialize the live search
  */
 public function __construct()
 {
     // @todo Use the autoloader for this. Not sure why its not working.
     require_once PATH_t3lib . 'search/class.t3lib_search_livesearch_queryParser.php';
     $this->liveSearch = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Search\\LiveSearch\\LiveSearch');
     $this->queryParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Search\\LiveSearch\\QueryParser');
 }
 /**
  * Reads the [extDir]/locallang.xml and returns the \$LOCAL_LANG array found in that file.
  *
  * @return	The array with language labels
  */
 function includeLocalLang()
 {
     $llFile = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ke_search') . 'pi2/locallang.xml';
     $xmlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Parser\\LocallangXmlParser');
     $LOCAL_LANG = $xmlParser->getParsedData($llFile, $GLOBALS['LANG']->lang);
     return $LOCAL_LANG;
 }
Ejemplo n.º 15
0
 /**
  * Return filtered value
  * Removes potential XSS code from the input string.
  *
  * Using an external class by Travis Puderbaugh <*****@*****.**>
  *
  * @param string $value Unfiltered value
  * @return string The filtered value
  */
 public function filter($value)
 {
     $value = stripslashes($value);
     $value = html_entity_decode($value, ENT_QUOTES);
     $filteredValue = \TYPO3\CMS\Core\Utility\GeneralUtility::removeXSS($value);
     return $filteredValue;
 }
Ejemplo n.º 16
0
 /**
  * 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)
 {
     $pluginInformation = [];
     $controllerPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Controller/';
     $controllers = FileUtility::getBaseFilesRecursivelyInDir($controllerPath, 'php');
     foreach ($controllers as $controller) {
         $controllerName = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Controller/' . $controller);
         if (!$loader->isInstantiableClass($controllerName)) {
             continue;
         }
         $controllerKey = str_replace('/', '\\', $controller);
         $controllerKey = str_replace('Controller', '', $controllerKey);
         $methods = ReflectionUtility::getPublicMethods($controllerName);
         foreach ($methods as $method) {
             /** @var $method \TYPO3\CMS\Extbase\Reflection\MethodReflection */
             if ($method->isTaggedWith('plugin')) {
                 $pluginKeys = GeneralUtility::trimExplode(' ', implode(' ', $method->getTagValues('plugin')), true);
                 $actionName = str_replace('Action', '', $method->getName());
                 foreach ($pluginKeys as $pluginKey) {
                     $pluginInformation = $this->addPluginInformation($pluginInformation, $pluginKey, $controllerKey, $actionName, $method->isTaggedWith('noCache'));
                 }
             }
         }
     }
     return $pluginInformation;
 }
Ejemplo n.º 17
0
 public function flash($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK)
 {
     $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, '', $severity, true);
     $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
     $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
     $defaultFlashMessageQueue->enqueue($flashMessage);
 }
Ejemplo n.º 18
0
 /**
  * Constructor.
  *
  * @param \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper The view helper
  * @param array $arguments Arguments of view helper - each value is a RootNode.
  */
 public function __construct(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper, array $arguments)
 {
     $this->uninitializedViewHelper = $viewHelper;
     $this->viewHelpersByContext = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class);
     $this->arguments = $arguments;
     $this->viewHelperClassName = get_class($this->uninitializedViewHelper);
 }
 /**
  * Saves the edited stop word list to Solr
  *
  * @return void
  */
 public function saveStopWordsAction()
 {
     $solrConnection = $this->getSelectedCoreSolrConnection();
     $postParameters = GeneralUtility::_POST('tx_solr_tools_solradministration');
     // lowercase stopword before saving because terms get lowercased before stopword filtering
     $newStopWords = $this->stringUtility->toLower($postParameters['stopWords']);
     $newStopWords = GeneralUtility::trimExplode("\n", $newStopWords, true);
     $oldStopWords = $solrConnection->getStopWords();
     $wordsRemoved = true;
     $removedStopWords = array_diff($oldStopWords, $newStopWords);
     foreach ($removedStopWords as $word) {
         $response = $solrConnection->deleteStopWord($word);
         if ($response->getHttpStatus() != 200) {
             $wordsRemoved = false;
             $this->addFlashMessage('Failed to remove stop word "' . $word . '".', 'An error occurred', FlashMessage::ERROR);
             break;
         }
     }
     $wordsAdded = true;
     $addedStopWords = array_diff($newStopWords, $oldStopWords);
     if (!empty($addedStopWords)) {
         $wordsAddedResponse = $solrConnection->addStopWords($addedStopWords);
         $wordsAdded = $wordsAddedResponse->getHttpStatus() == 200;
     }
     $reloadResponse = $solrConnection->reloadCore();
     if ($wordsRemoved && $wordsAdded && $reloadResponse->getHttpStatus() == 200) {
         $this->addFlashMessage('Stop Words Updated.');
     }
     $this->forwardToIndex();
 }
Ejemplo n.º 20
0
 /**
  * return true if the element is valide
  *
  * @param	string $value value to test
  * @return	bool true if the element is valide
  */
 public function isValid($value)
 {
     if ($value == '') {
         return true;
     }
     return GeneralUtility::validEmail($value);
 }
Ejemplo n.º 21
0
 /**
  * @param $uidList
  *
  * @return array|NULL
  */
 protected function loadSlides($uidList)
 {
     /** @var \WMDB\WmdbBaseEwh\DatabaseLayer\Tables\tx_wmdbbaseewh_slide $table */
     $table = DatabaseFactory::getTable('tx_wmdbbaseewh_slide', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $items = $table->findByUidList($uidList);
     foreach ($items as &$item) {
         $item['image'] = $this->pObj->loadFalData($item, 'image', 'tx_wmdbbaseewh_slide');
         if ($item['style'] == 2) {
             $descriptionParts = GeneralUtility::trimExplode(LF, $item['description'], 1);
             $tmp = array();
             $leftCnt = $rightCnt = 190;
             $itemOffset = 800;
             foreach ($descriptionParts as $key => $part) {
                 $tmp[$key % 2 == 0 ? 'left' : 'right'][] = array('text' => $part, 'offset' => $key % 2 == 0 ? $leftCnt : $rightCnt, 'timeOffset' => $itemOffset);
                 if ($key % 2 == 0) {
                     $leftCnt += 55;
                 } else {
                     $rightCnt += 55;
                 }
                 $itemOffset += 150;
             }
             $item['split'] = $tmp;
         }
     }
     return $items;
 }
Ejemplo n.º 22
0
 /**
  * Public Key Encryption Used by Encrypted Website Payments
  *
  * Encrypted Website Payments uses public key encryption, or asymmetric cryptography, which provides security and convenience
  * by allowing senders and receivers of encrypted communication to exchange public keys to unlock each others messages.
  * The fundamental aspects of public key encryption are:
  *
  * Public keys
  * They are created by receivers and are given to senders before they encrypt and send information. Public certificates
  * comprise a public key and identity information, such as the originator of the key and an expiry date.
  * Public certificates can be signed by certificate authorities, who guarantee that public certificates and their
  * public keys belong to the named entities. You and PayPal exchange each others' public certificates.
  *
  * Private keys
  * They are created by receivers are kept to themselves. You create a private key and keep it in your system.
  * PayPal keeps its private key on its system.
  *
  * The encryption process
  * Senders use their private keys and receivers' public keys to encrypt information before sending it.
  * Receivers use their private keys and senders' public keys to decrypt information after receiving it.
  * This encryption process also uses digital signatures in public certificates to verify the sender of the information.
  * You use your private key and PayPal's public key to encrypt your HTML button code.
  * PayPal uses its private key and your public key to decrypt button code after people click your payment buttons.
  *
  * @param array $data
  * @return string
  * @throws \Exception
  */
 public function encrypt(array $data)
 {
     $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['paypal']);
     $openSSL = $extensionConfiguration['opensslPath'];
     $certificationDir = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->settings['certification']['dir']);
     if ($this->settings['context']['sandbox']) {
         $certificationDir .= 'Sandbox/';
     }
     $files = array();
     foreach ($this->settings['certification']['file'] as $type => $file) {
         $files[$type] = $certificationDir . $file;
         if (!file_exists($files[$type])) {
             throw new \Exception('Certification "' . $files[$type] . '" does not exist!', 1392135405);
         }
     }
     $data['cert_id'] = $this->settings['seller']['cert_id'];
     $data['bn'] = 'ShoppingCart_WPS';
     $hash = '';
     foreach ($data as $key => $value) {
         if ($value != '') {
             $hash .= $key . '=' . $value . "\n";
         }
     }
     $openssl_cmd = "({$openSSL} smime -sign -signer " . $files['public'] . " -inkey " . $files['private'] . " " . "-outform der -nodetach -binary <<_EOF_\n{$hash}\n_EOF_\n) | " . "{$openSSL} smime -encrypt -des3 -binary -outform pem " . $files['public_paypal'] . "";
     exec($openssl_cmd, $output, $error);
     if (!$error) {
         return implode("\n", $output);
     } else {
         throw new \Exception('Paypal Request Encryption failed!', 1392135967);
     }
 }
Ejemplo n.º 23
0
 /**
  * Creates a new public/private key pair using PHP OpenSSL extension.
  *
  * @return \TYPO3\CMS\Rsaauth\Keypair A new key pair or NULL in case of error
  * @see tx_rsaauth_abstract_backend::createNewKeyPair()
  */
 public function createNewKeyPair()
 {
     $result = NULL;
     $privateKey = @openssl_pkey_new();
     if ($privateKey) {
         // Create private key as string
         $privateKeyStr = '';
         openssl_pkey_export($privateKey, $privateKeyStr);
         // Prepare public key information
         $exportedData = '';
         $csr = openssl_csr_new(array(), $privateKey);
         openssl_csr_export($csr, $exportedData, FALSE);
         // Get public key (in fact modulus) and exponent
         $publicKey = $this->extractPublicKeyModulus($exportedData);
         $exponent = $this->extractExponent($exportedData);
         // Create result object
         $result = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Rsaauth\\Keypair');
         /** @var $result \TYPO3\CMS\Rsaauth\Keypair */
         $result->setExponent($exponent);
         $result->setPrivateKey($privateKeyStr);
         $result->setPublicKey($publicKey);
         // Clean up all resources
         openssl_free_key($privateKey);
     }
     return $result;
 }
 /**
  * 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');
         }
     }
 }
 /**
  * Initialize new row with default values from various sources
  *
  * @param array $result
  * @return array
  */
 public function addData(array $result)
 {
     $databaseRow = $result['databaseRow'];
     $newRow = $databaseRow;
     foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
         // Keep current value if it can be resolved to "the is something" directly
         if (isset($databaseRow[$fieldName])) {
             $newRow[$fieldName] = $databaseRow[$fieldName];
             continue;
         }
         // Special handling for eval null
         if (!empty($fieldConfig['config']['eval']) && GeneralUtility::inList($fieldConfig['config']['eval'], 'null')) {
             if (array_key_exists($fieldName, $databaseRow) || array_key_exists('default', $fieldConfig['config']) && $fieldConfig['config']['default'] === null) {
                 $newRow[$fieldName] = null;
             } else {
                 $newRow[$fieldName] = (string) $fieldConfig['config']['default'];
             }
         } else {
             // Fun part: This forces empty string for any field even if no default is set. Unsure if that is a good idea.
             $newRow[$fieldName] = (string) $fieldConfig['config']['default'];
         }
     }
     $result['databaseRow'] = $newRow;
     return $result;
 }
Ejemplo n.º 26
0
 /**
  * Returns the given amount as a formatted string according to the
  * given currency.
  * IMPORTANT NOTE:
  * The amount must always be the smallest unit passed as a string
  * or int! It is a very bad idea to use float for monetary
  * calculations if you need exact values, therefore
  * this method won't accept float values.
  * Examples:
  *      format (500, 'EUR');      --> '5,00 EUR'
  *      format (4.23, 'EUR');     --> FALSE
  *      format ('872331', 'EUR'); --> '8.723,31 EUR'.
  *
  * @param int|string $amount Amount to be formatted. Must be the smalles unit
  * @param string $currencyKey ISO 3 letter code of the currency
  * @param bool $withSymbol If set the currency symbol will be rendered
  *
  * @return string|bool String representation of the amount including currency
  *      symbol(s) or FALSE if $amount was of the type float
  */
 public static function format($amount, $currencyKey, $withSymbol = true)
 {
     if (is_float($amount)) {
         return false;
     }
     /**
      * Currency repository.
      *
      * @var CurrencyRepository
      */
     $currencyRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\CurrencyRepository');
     $currency = $currencyRepository->findByIso3($currencyKey);
     if (empty($currency)) {
         return false;
     }
     $formattedAmount = number_format($amount / $currency['cu_sub_divisor'], $currency['cu_decimal_digits'], $currency['cu_decimal_point'], $currency['cu_thousands_point']);
     if ($withSymbol) {
         $wholeString = $formattedAmount;
         if (!empty($currency['cu_symbol_left'])) {
             $wholeString = $currency['cu_symbol_left'] . ' ' . $wholeString;
         }
         if (!empty($currency['cu_symbol_right'])) {
             $wholeString .= ' ' . $currency['cu_symbol_right'];
         }
     } else {
         $wholeString = $formattedAmount;
     }
     return $wholeString;
 }
 public function check()
 {
     $checkFailed = '';
     $formValue = trim($this->gp[$this->formFieldName]);
     if (strlen($formValue) > 0) {
         $checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words');
         if (!is_array($checkValue)) {
             $checkValue = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $checkValue);
         }
         $error = FALSE;
         $array = preg_split('//', $formValue, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($array as $idx => $char) {
             if (!in_array($char, $checkValue)) {
                 $error = TRUE;
             }
         }
         if ($error) {
             //remove userfunc settings and only store comma seperated words
             $this->settings['params']['words'] = implode(',', $checkValue);
             unset($this->settings['params']['words.']);
             $checkFailed = $this->getCheckFailed();
         }
     }
     return $checkFailed;
 }
Ejemplo n.º 28
0
 /**
  * Render method
  *
  * @throws Exception
  * @return string
  */
 public function render()
 {
     $sources = $this->getSourcesFromArgument();
     if (0 === count($sources)) {
         throw new Exception('No audio sources provided.', 1359382189);
     }
     foreach ($sources as $source) {
         if (TRUE === is_string($source)) {
             if (FALSE !== strpos($source, '//')) {
                 $src = $source;
                 $type = substr($source, strrpos($source, '.') + 1);
             } else {
                 $src = substr(GeneralUtility::getFileAbsFileName($source), strlen(PATH_site));
                 $type = pathinfo($src, PATHINFO_EXTENSION);
             }
         } elseif (TRUE === is_array($source)) {
             if (FALSE === isset($source['src'])) {
                 throw new Exception('Missing value for "src" in sources array.', 1359381250);
             }
             $src = $source['src'];
             if (FALSE === isset($source['type'])) {
                 throw new Exception('Missing value for "type" in sources array.', 1359381255);
             }
             $type = $source['type'];
         } else {
             // skip invalid source
             continue;
         }
         if (FALSE === in_array(strtolower($type), $this->validTypes)) {
             throw new Exception('Invalid audio type "' . $type . '".', 1359381260);
         }
         $type = $this->mimeTypesMap[$type];
         $src = $this->preprocessSourceUri($src);
         $this->renderChildTag('source', array('src' => $src, 'type' => $type), FALSE, 'append');
     }
     $tagAttributes = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'preload' => 'auto');
     if (TRUE === (bool) $this->arguments['autoplay']) {
         $tagAttributes['autoplay'] = 'autoplay';
     }
     if (TRUE === (bool) $this->arguments['controls']) {
         $tagAttributes['controls'] = 'controls';
     }
     if (TRUE === (bool) $this->arguments['loop']) {
         $tagAttributes['loop'] = 'loop';
     }
     if (TRUE === (bool) $this->arguments['muted']) {
         $tagAttributes['muted'] = 'muted';
     }
     if (TRUE === in_array($this->validPreloadModes, $this->arguments['preload'])) {
         $tagAttributes['preload'] = 'preload';
     }
     if (NULL !== $this->arguments['poster']) {
         $tagAttributes['poster'] = $this->arguments['poster'];
     }
     $this->tag->addAttributes($tagAttributes);
     if (NULL !== $this->arguments['unsupported']) {
         $this->tag->setContent($this->tag->getContent() . LF . $this->arguments['unsupported']);
     }
     return $this->tag->render();
 }
 /**
  * Returns TRUE if the associated action in _GET is allowed.
  *
  * @return boolean
  */
 public function actionIsAllowed()
 {
     if (!in_array(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action'), array('route', 'getAPI'))) {
         return FALSE;
     }
     return TRUE;
 }
 public function setUp()
 {
     $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], 0);
     $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $this->view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_gridelements_view');
     $this->view->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
 }