/** * @param string $text * @param boolean $trim * @param boolean $htmlentities * @throws Exception * @return string */ public function render($text = null, $trim = true, $htmlentities = false) { if (null === $text) { $text = $this->renderChildren(); } if (null === $text) { return null; } $cacheIdentifier = sha1($text); if (true === $this->cache->has($cacheIdentifier)) { return $this->cache->get($cacheIdentifier); } $this->markdownExecutablePath = CommandUtility::getCommand('markdown'); if (false === is_executable($this->markdownExecutablePath)) { throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed and accessible; this binary ' . 'could not be found in any of your configured paths available to this script', 1350511561); } if (true === (bool) $trim) { $text = trim($text); } if (true === (bool) $htmlentities) { $text = htmlentities($text); } $transformed = $this->transform($text); $this->cache->set($cacheIdentifier, $transformed); return $transformed; }
/** * Creates an instance of this class. It obtains a path to the OpenSSL * binary. */ public function __construct() { $this->opensslPath = CommandUtility::getCommand('openssl'); $this->temporaryDirectory = PATH_site . 'typo3temp'; // Get temporary directory from the configuration $extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']); if ($extconf['temporaryDirectory'] !== '' && $extconf['temporaryDirectory'][0] === '/' && @is_dir($extconf['temporaryDirectory']) && is_writable($extconf['temporaryDirectory'])) { $this->temporaryDirectory = $extconf['temporaryDirectory']; } }
/** * Starts the Tika server * * @return void */ public function startServerAction() { $command = CommandUtility::getCommand('java') . ' -jar ' . escapeshellarg(GeneralUtility::getFileAbsFileName($this->tikaConfiguration['tikaServerPath'], FALSE)) . ' -p ' . escapeshellarg($this->tikaConfiguration['tikaServerPort']); $command = escapeshellcmd($command); $process = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Tika\\Process', $command); $pid = $process->getPid(); $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); $registry->set('tx_tika', 'server.pid', $pid); // wait for Tika to start so that when we return to indexAction // it shows Tika running sleep(2); $this->forwardToIndex(); }
/** * The actual language detection * * @param string $localFilePath Path to a local file * @return string The file content's language */ protected function detectLanguageFromLocalFile($localFilePath) { $tikaCommand = CommandUtility::getCommand('java') . ' -Dfile.encoding=UTF8' . ' -jar ' . escapeshellarg(GeneralUtility::getFileAbsFileName($this->configuration['tikaPath'], FALSE)) . ' -l' . ' ' . escapeshellarg($localFilePath); $language = trim(shell_exec($tikaCommand)); $this->log('Language Detection using local Tika', array('file' => $localFilePath, 'tika command' => $tikaCommand, 'shell output' => $language)); return $language; }
/** * Initializes a Tika server process. * * @param string $arguments * @return \ApacheSolrForTypo3\Tika\Process */ protected function getProcess($arguments = '') { $process = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Tika\\Process', CommandUtility::getCommand('java'), $arguments); return $process; }
/** * @param string $text * @param boolean $trim * @param boolean $htmlentities * @throws Exception * @return string */ public function render($text = NULL, $trim = TRUE, $htmlentities = FALSE) { if (NULL === $text) { $text = $this->renderChildren(); } if (NULL === $text) { return NULL; } $cacheIdentifier = sha1($text); if (TRUE === $this->cache->has($cacheIdentifier)) { return $this->cache->get($cacheIdentifier); } $this->markdownExecutablePath = \TYPO3\CMS\Core\Utility\CommandUtility::getCommand('markdown'); if (FALSE === is_executable($this->markdownExecutablePath)) { throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed ' . 'and accessible; this binary could not be found in any of your configured paths available to this script', 1350511561); } if (TRUE === (bool) $trim) { $text = trim($text); } if (TRUE === (bool) $htmlentities) { $text = htmlentities($text); } $transformed = $this->transform($text); $this->cache->set($cacheIdentifier, $transformed); return $transformed; }