/** * Initialisation of the ImageGraph object. Checks if the file is already generated, * otherwise generation of the file is not necessary. * * @param array TS Configuration of the image * @param tx_rnbase_plot_IDataProvider $dp * @return string The img tag */ public function make($arrConf, $dp) { $this->setDataProvider($dp); if ($arrConf) { $strFileName = $this->getFileName('ImageGraph/', $arrConf, $arrConf['factory']); $arrConf['factory'] = $arrConf['factory'] ? $arrConf['factory'] : 'png'; $arrConf['width'] = $arrConf['width'] ? $arrConf['width'] : '400'; $arrConf['height'] = $arrConf['height'] ? $arrConf['height'] : '300'; if (!@file_exists(PATH_site . $strFileName) || TRUE) { // TODO: remove me!!! $objGraph = $this->makeCanvas($arrConf, $dp); $objGraph->done(array('filename' => PATH_site . $strFileName)); } $strAltParam = $this->getAltParam($arrConf); switch (strtolower($arrConf['factory'])) { case 'svg': $strOutput = '<object width="' . $arrConf['width'] . '" height="' . $arrConf['height'] . '" type="image/svg+xml" data="' . $strFileName . '">Browser does not support SVG files!</object>'; break; case 'pdf': header('Location: ' . tx_rnbase_util_Network::locationHeaderUrl($strFileName)); exit; default: $strOutput = '<img width="' . $arrConf['width'] . '" height="' . $arrConf['height'] . '" src="/' . $strFileName . '" ' . $strAltParam . ' />'; } } return $strOutput; }
public function main() { $out = ''; $conf = $this->getModule()->getConfigurations(); $file = tx_rnbase_util_Files::getFileAbsFileName($conf->get($this->getConfId() . 'template')); $templateCode = tx_rnbase_util_Network::getURL($file); if (!$templateCode) { return $conf->getLL('msg_template_not_found') . '<br />File: \'' . $file . '\'<br />ConfId: \'' . $this->getConfId() . 'template\''; } $subpart = '###' . strtoupper($this->getFuncId()) . '###'; $template = tx_rnbase_util_Templates::getSubpart($templateCode, $subpart); if (!$template) { return $conf->getLL('msg_subpart_not_found') . ': ' . $subpart; } $start = microtime(TRUE); $memStart = memory_get_usage(); $out .= $this->getContent($template, $conf, $conf->getFormatter(), $this->getModule()->getFormTool()); if (tx_rnbase_util_BaseMarker::containsMarker($out, 'MOD_')) { $markerArr = array(); $memEnd = memory_get_usage(); $markerArr['###MOD_PARSETIME###'] = microtime(TRUE) - $start; $markerArr['###MOD_MEMUSED###'] = $memEnd - $memStart; $markerArr['###MOD_MEMSTART###'] = $memStart; $markerArr['###MOD_MEMEND###'] = $memEnd; $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($out, $markerArr); } return $out; }
/** * Returns a subpart from file * @param string $fileName filepath or url * @param string $subpart * @return string * @throws Exception if file or subpart not found */ public static function getSubpartFromFile($fileName, $subpart) { $file = self::getTSTemplate()->getFileName($fileName); if (TYPO3_MODE == 'BE' && strpos($file, PATH_site) === FALSE) { $file = PATH_site . $file; } // Im BE auf absoluten Pfad setzen $templateCode = tx_rnbase_util_Network::getURL($file); if (!$templateCode) { throw new Exception('File not found: ' . htmlspecialchars($fileName)); } $template = self::getSubpart($templateCode, $subpart); if (!$template) { throw new Exception('Subpart not found! File: ' . htmlspecialchars($file) . ' Subpart: ' . htmlspecialchars($subpart)); } return $template; }
/** * Returns the flexform data of this plugin as array * * @return array by reference */ function &getFlexFormArray() { static $flex; if (!is_array($flex)) { $flex = tx_rnbase_util_Network::getURL(tx_rnbase_util_Extensions::extPath($this->getExtensionKey()) . $this->get('flexform')); $flex = tx_rnbase_util_Arrays::xml2array($flex); } return $flex; }
public function test_includeSubTemplates() { $fixture = tx_rnbase_util_Network::getURL(tx_rnbase_util_Extensions::extPath('rn_base', 'tests/fixtures/html/includeSubTemplates.html')); $raw = tx_rnbase_util_Templates::getSubpart($fixture, '###TEMPLATE###'); $expected = tx_rnbase_util_Templates::getSubpart($fixture, '###EXPECTED###'); $included = tx_rnbase_util_Templates::includeSubTemplates($raw); // remove empty lines $included = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", $included); $expected = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", $expected); $this->assertEquals($expected, $included); }
/** * @param string $globalDevIpMask * @param string $devIpMask * @param string $remoteIp * @param boolean $expectedReturn * @group unit * @dataProvider dataProviderIsDevelopmentIp */ public function testIsDevelopmentIp($globalDevIpMask, $devIpMask, $remoteIp, $expectedReturn) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $globalDevIpMask; self::assertSame($expectedReturn, tx_rnbase_util_Network::isDevelopmentIp($remoteIp, $devIpMask)); }
/** * Redirect the page to the url * * @return void */ function redirect() { session_write_close(); $target = $this->makeUrl(FALSE); $target = tx_rnbase_util_Network::locationHeaderUrl($target); header('Location: ' . $target); exit; }
/** * Reads the file or url $url and returns the content * If you are having trouble with proxys when reading URLs * you can configure your way out of that * with settings like $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] etc. * * @param string $url File/URL to read * @param int $includeHeader Whether the HTTP header should be fetched or not. * @param array|vool $requestHeaders HTTP headers to be used in the request * @param array|bool $report Error code/message and response meta data * * @return mixed The content from the resource or FALSE */ public static function getUrl($url, $includeHeader = 0, $requestHeaders = FALSE, &$report = NULL) { tx_rnbase::load('tx_rnbase_util_Network'); return tx_rnbase_util_Network::getUrl($url, $includeHeader, $requestHeaders, $report); }