Пример #1
0
 /**
  * Generates news site map.
  *
  * @return    void
  */
 protected function generateSitemapContent()
 {
     if (count($this->pidList) > 0) {
         $languageCondition = '';
         $language = GeneralUtility::_GP('L');
         if (MathUtility::canBeInterpretedAsInteger($language)) {
             $languageCondition = ' AND sys_language_uid=' . $language;
         }
         /** @noinspection PhpUndefinedMethodInspection */
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_t3blog_post', 'pid IN (' . implode(',', $this->pidList) . ')' . $languageCondition . $this->cObj->enableFields('tx_t3blog_post'), '', 'date DESC', $this->offset . ',' . $this->limit);
         /** @noinspection PhpUndefinedMethodInspection */
         $rowCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
         /** @noinspection PhpUndefinedMethodInspection */
         while (FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
             if ($url = $this->getPostItemUrl($row)) {
                 echo $this->renderer->renderEntry($url, $row['title'], $row['date'], '', $row['tagClouds']);
             }
         }
         /** @noinspection PhpUndefinedMethodInspection */
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         if ($rowCount === 0) {
             echo '<!-- It appears that there are no tx_t3blog_post entries. If your ' . 'blog storage sysfolder is outside of the rootline, you may ' . 'want to use the dd_googlesitemap.skipRootlineCheck=1 TS ' . 'setup option. Beware: it is insecure and may cause certain ' . 'undesired effects! Better move your news sysfolder ' . 'inside the rootline! -->';
         }
     }
 }
Пример #2
0
 /**
  * @param int $value
  * @param int $bit
  * @return bool
  */
 public function render($value = null, $bit = 0)
 {
     if ($value === null) {
         $value = $this->renderChildren();
     }
     return \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($bit) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($value) ? ((int) $bit & (int) $value) > 0 : false;
 }
 /**
  * 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');
         }
     }
 }
Пример #4
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // we check for existence of our targetDirectory
     if (!is_dir(PATH_site . $this->targetDirectory)) {
         GeneralUtility::mkdir_deep(PATH_site . $this->targetDirectory);
     }
     // if enabled, we check whether we should auto-create the .htaccess file
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
         // check whether .htaccess exists
         $htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
         if (!file_exists($htaccessPath)) {
             GeneralUtility::writeFile($htaccessPath, $this->htaccessTemplate);
         }
     }
     // decide whether we should create gzipped versions or not
     $compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
     // we need zlib for gzencode()
     if (extension_loaded('zlib') && $compressionLevel) {
         $this->createGzipped = true;
         // $compressionLevel can also be TRUE
         if (MathUtility::canBeInterpretedAsInteger($compressionLevel)) {
             $this->gzipCompressionLevel = (int) $compressionLevel;
         }
     }
     $this->setInitialPaths();
 }
Пример #5
0
 /**
  * Get focus point information
  *
  * @param $uid
  *
  * @return array|FALSE|NULL
  */
 protected function getCurrentFocusPoint($uid)
 {
     $row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('focus_point_x, focus_point_y', 'sys_file_metadata', 'uid=' . $uid);
     $row['focus_point_x'] = MathUtility::forceIntegerInRange((int) $row['focus_point_x'], -100, 100, 0);
     $row['focus_point_y'] = MathUtility::forceIntegerInRange((int) $row['focus_point_y'], -100, 100, 0);
     return $row;
 }
Пример #6
0
 /**
  * Get the Records
  *
  * @param integer                                        $startPage
  * @param array                                          $basePages
  * @param Tx_GoogleServices_Controller_SitemapController $obj
  *
  * @throws Exception
  * @return Tx_GoogleServices_Domain_Model_Node
  */
 public function getRecords($startPage, $basePages, Tx_GoogleServices_Controller_SitemapController $obj)
 {
     $nodes = array();
     if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tt_news')) {
         return $nodes;
     }
     if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.']['singlePid'])) {
         throw new Exception('You have to set tt_news singlePid.');
     }
     $singlePid = intval($GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.']['singlePid']);
     $news = $this->getRecordsByField('tt_news', 'pid', implode(',', $basePages));
     foreach ($news as $record) {
         // Alternative Single PID
         $alternativeSinglePid = $this->alternativeSinglePid($record['uid']);
         $linkPid = $alternativeSinglePid ? $alternativeSinglePid : $singlePid;
         // Build URL
         $url = $obj->getUriBuilder()->setArguments(array('tx_ttnews' => array('tt_news' => $record['uid'])))->setTargetPageUid($linkPid)->build();
         // can't generate a valid url
         if (!strlen($url)) {
             continue;
         }
         // Build Node
         $node = new Tx_GoogleServices_Domain_Model_Node();
         $node->setLoc($url);
         $node->setPriority($this->getPriority($record));
         $node->setChangefreq('monthly');
         $node->setLastmod($this->getModifiedDate($record));
         $nodes[] = $node;
     }
     return $nodes;
 }
Пример #7
0
 /**
  * This method forwards the call to Bootstrap's run() method. This method is invoked by the mod.php
  * function of TYPO3.
  *
  * @param string $moduleSignature
  * @throws \RuntimeException
  * @return boolean TRUE, if the request request could be dispatched
  * @see run()
  */
 public function callModule($moduleSignature)
 {
     if (!isset($GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature])) {
         return FALSE;
     }
     $moduleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
     // Check permissions and exit if the user has no permission for entry
     $GLOBALS['BE_USER']->modAccess($moduleConfiguration, TRUE);
     $id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
     if ($id && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
         // Check page access
         $permClause = $GLOBALS['BE_USER']->getPagePermsClause(TRUE);
         $access = is_array(\TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess((int) $id, $permClause));
         if (!$access) {
             throw new \RuntimeException('You don\'t have access to this page', 1289917924);
         }
     }
     // BACK_PATH is the path from the typo3/ directory from within the
     // directory containing the controller file. We are using mod.php dispatcher
     // and thus we are already within typo3/ because we call typo3/mod.php
     $GLOBALS['BACK_PATH'] = '';
     $configuration = array('extensionName' => $moduleConfiguration['extensionName'], 'pluginName' => $moduleSignature);
     if (isset($moduleConfiguration['vendorName'])) {
         $configuration['vendorName'] = $moduleConfiguration['vendorName'];
     }
     $bootstrap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface');
     $content = $bootstrap->run('', $configuration);
     print $content;
     return TRUE;
 }
 /**
  * Check if a connection to a Solr server could be established with the given credentials.
  *
  * @access	public
  *
  * @param	array		&$params: An array with parameters
  * @param	\TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object
  *
  * @return	string		Message informing the user of success or failure
  */
 public function checkSolrConnection(&$params, &$pObj)
 {
     // Prepend username and password to hostname.
     if (!empty($this->conf['solrUser']) && !empty($this->conf['solrPass'])) {
         $host = $this->conf['solrUser'] . ':' . $this->conf['solrPass'] . '@' . (!empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost');
     } else {
         $host = !empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost';
     }
     // Set port if not set.
     $port = !empty($this->conf['solrPort']) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['solrPort'], 0, 65535, 8180) : 8180;
     // Trim path and append trailing slash.
     $path = !empty($this->conf['solrPath']) ? trim($this->conf['solrPath'], '/') . '/' : '';
     // Build request URI.
     $url = 'http://' . $host . ':' . $port . '/' . $path . 'admin/cores';
     $context = stream_context_create(array('http' => array('method' => 'GET', 'user_agent' => !empty($this->conf['useragent']) ? $this->conf['useragent'] : ini_get('user_agent'))));
     // Try to connect to Solr server.
     $response = @simplexml_load_string(file_get_contents($url, FALSE, $context));
     // Check status code.
     if ($response) {
         $status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]');
         if (is_array($status)) {
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('solr.status'), (string) $status[0]), $GLOBALS['LANG']->getLL('solr.connected'), $status[0] == 0 ? \TYPO3\CMS\Core\Messaging\FlashMessage::OK : \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE);
             $this->content .= $message->render();
             return $this->content;
         }
     }
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('solr.error'), $url), $GLOBALS['LANG']->getLL('solr.notConnected'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE);
     $this->content .= $message->render();
     return $this->content;
 }
 /**
  * This method actually does the processing of files locally
  *
  * takes the original file (on remote storages this will be fetched from the remote server)
  * does the IM magic on the local server by creating a temporary typo3temp/ file
  * copies the typo3temp/ file to the processing folder of the target storage
  * removes the typo3temp/ file
  *
  * @param TaskInterface $task
  * @return array
  */
 public function process(TaskInterface $task)
 {
     $targetFile = $task->getTargetFile();
     // Merge custom configuration with default configuration
     $configuration = array_merge(array('width' => 64, 'height' => 64), $task->getConfiguration());
     $configuration['width'] = Utility\MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
     $configuration['height'] = Utility\MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
     $originalFileName = $targetFile->getOriginalFile()->getForLocalProcessing(FALSE);
     // Create a temporary file in typo3temp/
     if ($targetFile->getOriginalFile()->getExtension() === 'jpg') {
         $targetFileExtension = '.jpg';
     } else {
         $targetFileExtension = '.png';
     }
     // Create the thumb filename in typo3temp/preview_....jpg
     $temporaryFileName = Utility\GeneralUtility::tempnam('preview_') . $targetFileExtension;
     // Check file extension
     if ($targetFile->getOriginalFile()->getType() != Resource\File::FILETYPE_IMAGE && !Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $targetFile->getOriginalFile()->getExtension())) {
         // Create a default image
         $this->processor->getTemporaryImageWithText($temporaryFileName, 'Not imagefile!', 'No ext!', $targetFile->getOriginalFile()->getName());
     } else {
         // Create the temporary file
         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
             $parameters = '-sample ' . $configuration['width'] . 'x' . $configuration['height'] . ' ' . $this->processor->wrapFileName($originalFileName) . '[0] ' . $this->processor->wrapFileName($temporaryFileName);
             $cmd = Utility\GeneralUtility::imageMagickCommand('convert', $parameters) . ' 2>&1';
             Utility\CommandUtility::exec($cmd);
             if (!file_exists($temporaryFileName)) {
                 // Create a error gif
                 $this->processor->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', $targetFile->getOriginalFile()->getName());
             }
         }
     }
     return array('filePath' => $temporaryFileName);
 }
Пример #10
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 $autoLoader
  * @param int $type
  *
  * @return array
  */
 public function prepareLoader(Loader $autoLoader, $type)
 {
     $slots = [];
     $slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/';
     $slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php');
     foreach ($slotClasses as $slot) {
         $slotClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Slots/' . $slot);
         if (!$autoLoader->isInstantiableClass($slotClass)) {
             continue;
         }
         $methods = ReflectionUtility::getPublicMethods($slotClass);
         foreach ($methods as $methodReflection) {
             /** @var MethodReflection $methodReflection */
             $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName', 'signalPriority']);
             foreach ($tagConfiguration['signalClass'] as $key => $signalClass) {
                 if (!isset($tagConfiguration['signalName'][$key])) {
                     continue;
                 }
                 $priority = isset($tagConfiguration['signalPriority'][$key]) ? $tagConfiguration['signalPriority'][$key] : 0;
                 $priority = MathUtility::forceIntegerInRange($priority, 0, 100);
                 $slots[$priority][] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()];
             }
         }
     }
     $slots = $this->flattenSlotsByPriority($slots);
     return $slots;
 }
 /**
  * Verify TS objects
  *
  * @param array $propertyArray
  * @param string $parentType
  * @param string $parentValue
  * @return array
  * @todo Define visibility
  */
 public function verify_TSobjects($propertyArray, $parentType, $parentValue)
 {
     $TSobjTable = array('PAGE' => array('prop' => array('typeNum' => 'int', '1,2,3' => 'COBJ', 'bodyTag' => 'string')), 'TEXT' => array('prop' => array('value' => 'string')), 'HTML' => array('prop' => array('value' => 'stdWrap')), 'stdWrap' => array('prop' => array('field' => 'string', 'current' => 'boolean')));
     $TSobjDataTypes = array('COBJ' => 'TEXT,CONTENT', 'PAGE' => 'PAGE', 'stdWrap' => '');
     if ($parentType) {
         if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || \TYPO3\CMS\Core\Utility\GeneralUtility::inlist($TSobjDataTypes[$parentType], $parentValue))) {
             $ObjectKind = $parentValue;
         } else {
             // Object kind is "" if it should be known.
             $ObjectKind = '';
         }
     } else {
         // If parentType is not given, then it can be anything. Free.
         $ObjectKind = $parentValue;
     }
     if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) {
         $result = array();
         if (is_array($propertyArray)) {
             foreach ($propertyArray as $key => $val) {
                 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($key)) {
                     // If num-arrays
                     $result[$key] = $TSobjTable[$ObjectKind]['prop']['1,2,3'];
                 } else {
                     // standard
                     $result[$key] = $TSobjTable[$ObjectKind]['prop'][$key];
                 }
             }
         }
         return $result;
     }
 }
Пример #12
0
 /**
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  *
  * @return string
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $title = $arguments['title'];
     $message = $arguments['message'];
     $state = $arguments['state'];
     $isInRange = MathUtility::isIntegerInRange($state, -2, 2);
     if (!$isInRange) {
         $state = -2;
     }
     $iconName = $arguments['iconName'];
     $disableIcon = $arguments['disableIcon'];
     if ($message === null) {
         $messageTemplate = $renderChildrenClosure();
     } else {
         $messageTemplate = htmlspecialchars($message);
     }
     $classes = [self::STATE_NOTICE => 'notice', self::STATE_INFO => 'info', self::STATE_OK => 'success', self::STATE_WARNING => 'warning', self::STATE_ERROR => 'danger'];
     $icons = [self::STATE_NOTICE => 'lightbulb-o', self::STATE_INFO => 'info', self::STATE_OK => 'check', self::STATE_WARNING => 'exclamation', self::STATE_ERROR => 'times'];
     $stateClass = $classes[$state];
     $icon = $icons[$state];
     if ($iconName !== null) {
         $icon = $iconName;
     }
     $iconTemplate = '';
     if (!$disableIcon) {
         $iconTemplate = '' . '<div class="media-left">' . '<span class="fa-stack fa-lg callout-icon">' . '<i class="fa fa-circle fa-stack-2x"></i>' . '<i class="fa fa-' . htmlspecialchars($icon) . ' fa-stack-1x"></i>' . '</span>' . '</div>';
     }
     $titleTemplate = '';
     if ($title !== null) {
         $titleTemplate = '<h4 class="callout-title">' . htmlspecialchars($title) . '</h4>';
     }
     return '<div class="callout callout-' . htmlspecialchars($stateClass) . '">' . '<div class="media">' . $iconTemplate . '<div class="media-body">' . $titleTemplate . '<div class="callout-body">' . $messageTemplate . '</div>' . '</div>' . '</div>' . '</div>';
 }
 /**
  * The main method of the PlugIn
  *
  * @access	public
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  *
  * @return	string		The content that is displayed on the website
  */
 public function main($content, $conf)
 {
     $this->init($conf);
     // Merge configuration with conf array of toolbox.
     $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf);
     // Load current document.
     $this->loadDocument();
     if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) {
         // Quit without doing anything if required variables are not set.
         return $content;
     } else {
         // Set default values if not set.
         // page may be integer or string (physical page attribute)
         if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) {
             $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
         } else {
             $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages);
         }
         $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
     }
     // Load template file.
     if (!empty($this->conf['templateFile'])) {
         $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
     } else {
         $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###');
     }
     $fullTextFile = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
     if (!empty($fullTextFile)) {
         $markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:' . $this->pi_getLL('fulltext-on', '', TRUE) . ';fulltext-off:' . $this->pi_getLL('fulltext-off', '', TRUE) . '"></a>';
     } else {
         $markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-not-available', '', TRUE);
     }
     $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
     return $this->pi_wrapInBaseClass($content);
 }
Пример #14
0
 /**
  * Clears URL cache for records.
  *
  * Currently only clears URL cache for pages but should also clear alias
  * cache for records later.
  *
  * @param array $parameters
  * @return void
  */
 public function clearUrlCacheForRecords(array $parameters)
 {
     if ($parameters['table'] == 'pages' && MathUtility::canBeInterpretedAsInteger($parameters['uid'])) {
         $cacheInstance = CacheFactory::getCache();
         $cacheInstance->clearUrlCacheForPage($parameters['uid']);
     }
 }
Пример #15
0
 /**
  * Construct a status
  *
  * All values must be given as constructor arguments.
  * All strings should be localized.
  *
  * @param string $title Status title, eg. "Deprecation log"
  * @param string $value Status value, eg. "Disabled"
  * @param string $message Optional message further describing the title/value combination
  * 			Example:, eg "The deprecation log is important and does foo, to disable it do bar"
  * @param integer $severity A severity level. Use one of the constants above!
  */
 public function __construct($title, $value, $message = '', $severity = self::OK)
 {
     $this->title = (string) $title;
     $this->value = (string) $value;
     $this->message = (string) $message;
     $this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
 }
Пример #16
0
 /**
  * Clears path and URL caches if the page was deleted.
  *
  * @param string $table
  * @param string|int $id
  */
 public function processCmdmap_deleteAction($table, $id)
 {
     if (($table === 'pages' || $table === 'pages_language_overlay') && MathUtility::canBeInterpretedAsInteger($id)) {
         $this->cache->clearPathCacheForPage((int) $id);
         $this->cache->clearUrlCacheForPage((int) $id);
     }
 }
Пример #17
0
 /**
  * Breaks content lines into a bullet list
  *
  * @param ContentObjectRenderer $contentObject
  * @param string                $str Content string to make into a bullet list
  *
  * @return string Processed value
  */
 function breakBulletList($contentObject, $str)
 {
     $type = $contentObject->data['layout'];
     $type = MathUtility::forceIntegerInRange($type, 0, 3);
     $tConf = $this->configuration['bulletlist.'][$type . '.'];
     $cParts = explode(chr(10), $str);
     $lines = array();
     $c = 0;
     foreach ($cParts as $substrs) {
         if (!strlen($substrs)) {
             continue;
         }
         $c++;
         $bullet = $tConf['bullet'] ? $tConf['bullet'] : ' - ';
         $bLen = strlen($bullet);
         $bullet = substr(str_replace('#', $c, $bullet), 0, $bLen);
         $secondRow = substr($tConf['secondRow'] ? $tConf['secondRow'] : str_pad('', strlen($bullet), ' '), 0, $bLen);
         $lines[] = $bullet . $this->breakLines($substrs, chr(10) . $secondRow, Configuration::getPlainTextWith() - $bLen);
         $blanks = MathUtility::forceIntegerInRange($tConf['blanks'], 0, 1000);
         if ($blanks) {
             $lines[] = str_pad('', $blanks - 1, chr(10));
         }
     }
     return implode(chr(10), $lines);
 }
 /**
  * The main method of the PlugIn
  *
  * @access	public
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  *
  * @return	string		The content that is displayed on the website
  */
 public function main($content, $conf)
 {
     $this->init($conf);
     // Merge configuration with conf array of toolbox.
     $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf);
     // Load current document.
     $this->loadDocument();
     if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpDownload'])) {
         // Quit without doing anything if required variables are not set.
         return $content;
     } else {
         // Set default values if not set.
         // page may be integer or string (physical page attribute)
         if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) {
             $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
         } else {
             $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages);
         }
         $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
     }
     // Load template file.
     if (!empty($this->conf['templateFile'])) {
         $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
     } else {
         $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/pdf/template.tmpl'), '###TEMPLATE###');
     }
     // Get single page downloads.
     $markerArray['###PAGE###'] = $this->getPageLink();
     // Get work download.
     $markerArray['###WORK###'] = $this->getWorkLink();
     $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
     return $this->pi_wrapInBaseClass($content);
 }
Пример #19
0
 /**
  * Get the cropped image by File Object
  *
  * @param FileInterface $file
  * @param string        $ratio
  *
  * @return string The new filename
  */
 public function getCroppedImageSrcByFile(FileInterface $file, $ratio)
 {
     $absoluteImageName = GeneralUtility::getFileAbsFileName($file->getPublicUrl());
     $focusPointX = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_x'), -100, 100, 0);
     $focusPointY = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_y'), -100, 100, 0);
     $tempImageFolder = 'typo3temp/focuscrop/';
     $tempImageName = $tempImageFolder . $file->getSha1() . '-' . str_replace(':', '-', $ratio) . '-' . $focusPointX . '-' . $focusPointY . '.' . $file->getExtension();
     $absoluteTempImageName = GeneralUtility::getFileAbsFileName($tempImageName);
     if (is_file($absoluteTempImageName)) {
         return $tempImageName;
     }
     $absoluteTempImageFolder = GeneralUtility::getFileAbsFileName($tempImageFolder);
     if (!is_dir($absoluteTempImageFolder)) {
         GeneralUtility::mkdir_deep($absoluteTempImageFolder);
     }
     $this->graphicalFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
     $imageSizeInformation = getimagesize($absoluteImageName);
     $width = $imageSizeInformation[0];
     $height = $imageSizeInformation[1];
     // dimensions
     /** @var \HDNET\Focuspoint\Service\DimensionService $service */
     $dimensionService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\DimensionService');
     list($focusWidth, $focusHeight) = $dimensionService->getFocusWidthAndHeight($width, $height, $ratio);
     $cropMode = $dimensionService->getCropMode($width, $height, $ratio);
     list($sourceX, $sourceY) = $dimensionService->calculateSourcePosition($cropMode, $width, $height, $focusWidth, $focusHeight, $focusPointX, $focusPointY);
     // generate image
     $sourceImage = $this->graphicalFunctions->imageCreateFromFile($absoluteImageName);
     $destinationImage = imagecreatetruecolor($focusWidth, $focusHeight);
     $this->graphicalFunctions->imagecopyresized($destinationImage, $sourceImage, 0, 0, $sourceX, $sourceY, $focusWidth, $focusHeight, $focusWidth, $focusHeight);
     $this->graphicalFunctions->ImageWrite($destinationImage, $absoluteTempImageName, $GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality']);
     return $tempImageName;
 }
Пример #20
0
 /**
  * @param mixed $value
  * @return bool
  */
 public function render($value = '')
 {
     if ($value === null) {
         $value = $this->renderChildren();
     }
     return \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($value);
 }
 /**
  * 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);
     }
 }
Пример #22
0
 /**
  * Adds a key to the storage or removes existing key
  *
  * @param string $key The key
  * @return void
  * @see \TYPO3\CMS\Rsaauth\Storage\AbstractStorage::put()
  */
 public function put($key)
 {
     if ($key == null) {
         // Remove existing key
         list($keyId) = $_SESSION['tx_rsaauth_key'];
         if (MathUtility::canBeInterpretedAsInteger($keyId)) {
             $this->databaseConnection->exec_DELETEquery('tx_rsaauth_keys', 'uid=' . $keyId);
             unset($_SESSION['tx_rsaauth_key']);
         }
     } else {
         // Add key
         // Get split point. First part is always smaller than the second
         // because it goes to the file system
         $keyLength = strlen($key);
         $splitPoint = rand((int) ($keyLength / 10), (int) ($keyLength / 2));
         // Get key parts
         $keyPart1 = substr($key, 0, $splitPoint);
         $keyPart2 = substr($key, $splitPoint);
         // Store part of the key in the database
         //
         // Notice: we may not use TCEmain below to insert key part into the
         // table because TCEmain requires a valid BE user!
         $time = $GLOBALS['EXEC_TIME'];
         $this->databaseConnection->exec_INSERTquery('tx_rsaauth_keys', array('pid' => 0, 'crdate' => $time, 'key_value' => $keyPart2));
         $keyId = $this->databaseConnection->sql_insert_id();
         // Store another part in session
         $_SESSION['tx_rsaauth_key'] = array($keyId, $keyPart1);
     }
     // Remove expired keys (more than 30 minutes old)
     $this->databaseConnection->exec_DELETEquery('tx_rsaauth_keys', 'crdate<' . ($GLOBALS['EXEC_TIME'] - 30 * 60));
 }
Пример #23
0
 /**
  * @param array $tsConfig
  * @param array $userArguments
  *
  * @return string
  */
 public function main(array $tsConfig, $userArguments = [])
 {
     $url = $tsConfig['url'];
     $regExpCurlyBraceOpen = preg_quote(rawurlencode('{'), '@');
     $regExpCurlyBraceClose = preg_quote(rawurlencode('}'), '@');
     $pattern = "@{$regExpCurlyBraceOpen}product{$regExpCurlyBraceClose}@i";
     // Return if argument to be replaced is not set!
     if (!preg_match($pattern, $url)) {
         return $tsConfig['TAG'];
     }
     /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
     $db = $GLOBALS['TYPO3_DB'];
     /**
      * <a href="' . $finalTagParts['url'] . '"' . $finalTagParts['targetParams'] . $finalTagParts['aTagParams'] . '>
      *
      * @see http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
      */
     $return = '<a href="%1$s"%2$s>';
     $product = false;
     // get necessary params to apply; replace in url
     if ($page = $db->exec_SELECTgetSingleRow('tx_product', 'pages', 'uid=' . $GLOBALS['TSFE']->id)) {
         if (MathUtility::canBeInterpretedAsInteger($page['tx_product']) && MathUtility::convertToPositiveInteger($page['tx_product'])) {
             $product = MathUtility::convertToPositiveInteger($page['tx_product']);
         }
     }
     /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject */
     $contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $url = str_ireplace($GLOBALS['TSFE']->baseUrl, '', $contentObject->getTypoLink_URL($userArguments['targetPid'], $product ? ['product' => $product] : []));
     return sprintf($return, $url, $tsConfig['targetParams'] . $tsConfig['aTagParams']);
 }
 /**
  * Check if current TYPO3 version is suitable for the extension
  *
  * @param string $lowestVersion
  * @param string $highestVersion
  * @return bool
  */
 protected static function isVersionSuitable($lowestVersion, $highestVersion)
 {
     $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
     $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($lowestVersion);
     $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($highestVersion);
     return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion);
 }
Пример #25
0
    /**
     * Check needed framework configuration
     *
     * @param array $settings
     * @return void
     * @throws InvalidConfigurationException
     */
    public static function validateFrameworkConfiguration(array $settings)
    {
        if (empty($settings['persistence']['storagePid']) || !MathUtility::canBeInterpretedAsInteger($settings['persistence']['storagePid'])) {
            throw new InvalidConfigurationException('No valid persistence storage pid setting detected.
				Make sure plugin.tx_t3extblog.persistence.storagePid is a valid page uid.', 1344375015);
        }
    }
Пример #26
0
 /**
  * This method is called by a hook in the TYPO3 core when a record is saved.
  *
  * We use the tx_linkhandler for backend "save & show" button to display records on the configured detail view page.
  *
  * @param  string  $status                                  Type of database operation i.e. new/update.
  * @param  string  $table                                   The table currently being processed.
  * @param  integer $id                                      The records id (if any).
  * @param  array   $fieldArray                              The field names and their values to be processed (passed by reference).
  * @param  \TYPO3\CMS\Core\DataHandling\DataHandler $pObj   Reference to the parent object.
  */
 public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $pObj)
 {
     if (isset($GLOBALS['_POST']['_savedokview_x'])) {
         $settingFound = FALSE;
         $currentPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['_POST']['popViewId']);
         $rootPageData = $this->getRootPage($currentPageId);
         $defaultPageId = isset($rootPageData) && array_key_exists('uid', $rootPageData) ? $rootPageData['uid'] : $currentPageId;
         $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($currentPageId);
         $handlerConfigurationStruct = $pagesTsConfig['mod.']['tx_linkhandler.'];
         // search for the current setting for given table
         foreach ($pagesTsConfig['mod.']['tx_linkhandler.'] as $key => $handler) {
             if (is_array($handler) && $handler['listTables'] === $table) {
                 $settingFound = TRUE;
                 $selectedConfiguration = $key;
                 break;
             }
         }
         if ($settingFound) {
             $l18nPointer = array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : '';
             if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
                 $id = $pObj->substNEWwithIDs[$id];
             }
             if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
                 $recordArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id);
             } else {
                 $recordArray = $fieldArray;
             }
             if (array_key_exists('previewPageId', $handlerConfigurationStruct[$selectedConfiguration]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']) > 0) {
                 $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']);
             } else {
                 $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($defaultPageId);
             }
             if ($GLOBALS['BE_USER']->workspace != 0) {
                 $timeToLiveHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) ? intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) : 24 * 2;
                 $wsPreviewValue = ';' . $GLOBALS['BE_USER']->workspace . ':' . $GLOBALS['BE_USER']->user['uid'] . ':' . 60 * 60 * $timeToLiveHours;
                 // get record UID for
                 if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
                     $id = $recordArray[$l18nPointer];
                 } elseif (array_key_exists('t3ver_oid', $recordArray) && intval($recordArray['t3ver_oid']) > 0) {
                     // this makes no sense because we already receive the UID of the WS-Placeholder which will be the real record in the LIVE-WS
                     $id = $recordArray['t3ver_oid'];
                 }
             } else {
                 $wsPreviewValue = '';
                 if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
                     $id = $recordArray[$l18nPointer];
                 }
             }
             $previewDomainRootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($previewPageId);
             $previewDomain = \TYPO3\CMS\Backend\Utility\BackendUtility::getViewDomain($previewPageId, $previewDomainRootline);
             $linkParamValue = 'record:' . $table . ':' . $id;
             $queryString = '&eID=linkhandlerPreview&linkParams=' . urlencode($linkParamValue . $wsPreviewValue);
             $languageParam = '&L=' . $recordArray['sys_language_uid'];
             $queryString .= $languageParam . '&authCode=' . \TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode($linkParamValue . $wsPreviewValue . intval($recordArray['sys_language_uid']), '', 32);
             $GLOBALS['_POST']['viewUrl'] = $previewDomain . '/index.php?id=' . $previewPageId . $queryString . '&y=';
             $GLOBALS['_POST']['popViewId_addParams'] = $queryString;
         }
     }
 }
Пример #27
0
 /**
  * Render method
  *
  * @return string
  */
 public function render()
 {
     if (MathUtility::canBeInterpretedAsInteger($this->arguments['value']) === true) {
         return $this->renderThenChild();
     } else {
         return $this->renderElseChild();
     }
 }
Пример #28
0
 /**
  * Validates whether the submitted language parameter can be
  * interpreted as integer value.
  *
  * @param stdClass $parameters
  * @return integer|NULL
  */
 protected function validateLanguageParameter(\stdClass $parameters)
 {
     $language = NULL;
     if (isset($parameters->language) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($parameters->language)) {
         $language = $parameters->language;
     }
     return $language;
 }
 /**
  * Enrich the processed record information with the resolved title
  *
  * @param array $result Incoming result array
  * @return array Modified array
  */
 public function addData(array $result)
 {
     if (!$result['isInlineChild']) {
         return $result;
     }
     $result['isOnSymmetricSide'] = MathUtility::canBeInterpretedAsInteger($result['databaseRow']['uid']) && $result['inlineParentConfig']['symmetric_field'] && $result['inlineParentUid'] == $result['databaseRow'][$result['inlineParentConfig']['symmetric_field']][0];
     return $result;
 }
 private function _get($key)
 {
     $value = is_array($this->configuration) && array_key_exists($key, $this->configuration) ? $this->configuration[$key] : null;
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($value)) {
         return (int) $value;
     }
     return $value;
 }