/** * * @param TYPO3\CMS\Core\Resource\FileReference $media */ private function initFalReference($media) { $this->record = $media->getProperties(); // Wir verwenden hier die UID der Referenz $this->uid = $media->getUid(); $this->record['uid'] = $media->getUid(); $this->record['file_path'] = $media->getPublicUrl(); $this->record['file_abs_url'] = tx_rnbase_util_Misc::getIndpEnv('TYPO3_SITE_URL') . $this->record['file_path']; }
/** * Return file info for all references for the given reference data * * @param string $refTable * @param string $refField * @return array */ public static function getReferencesFileInfo($refTable, $refUid, $refField) { $refs = self::getReferences($refTable, $refUid, $refField); $res = array(); if (isset($refs['rows']) && count($refs['rows'])) { foreach ($refs['rows'] as $uid => $record) { $fileInfo = self::getFileInfo($record); if (isset($refs['files'][$uid])) { $fileInfo['file_path_name'] = $refs['files'][$uid]; } $fileInfo['file_abs_url'] = tx_rnbase_util_Misc::getIndpEnv('TYPO3_SITE_URL') . $fileInfo['file_path_name']; $res[$uid] = $fileInfo; } } return $res; }
/** * Liefert einen Sortierungslink für das gegebene Feld * @param string $sSortField * @return string */ public function createSortLink($sSortField, $sLabel) { //das ist aktuell gesetzt $sCurrentSortField = tx_rnbase_parameters::getPostOrGetParameter('sortField'); $sCurrentSortRev = tx_rnbase_parameters::getPostOrGetParameter('sortRev'); //wir verweisen immer auf die aktuelle Seite //es kann aber schon ein sort parameter gesetzt sein //weshalb wir alte entfernen $sUrl = preg_replace('/&sortField=.*&sortRev=[^&]*/', '', tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_URL')); //sort richtung rausfinden //beim initialen Aufruf (spalte noch nicht geklickt) wird immer aufsteigend sortiert if ($sCurrentSortField != $sSortField) { $sSortRev = 'asc'; } else { //sonst das gegenteil vom aktuellen $sSortRev = $sCurrentSortRev == 'desc' ? 'asc' : 'desc'; } //prüfen ob Parameter mit ? oder & angehängt werden müssen $sAddParamsWith = strstr($sUrl, '?') ? '&' : '?'; //jetzt setzen wir den aktuellen Sort parameter zusammen $sSortUrl = $sUrl . $sAddParamsWith . 'sortField=' . $sSortField . '&sortRev=' . $sSortRev; //noch den Pfeil für die aktuelle Sortierungsrichtung ggf. einblenden $sSortArrow = $sCurrentSortField == $sSortField ? '<img' . Tx_Rnbase_Backend_Utility_Icons::skinImg($GLOBALS['BACK_PATH'], 'gfx/red' . ($sSortRev == 'asc' ? 'up' : 'down') . '.gif', 'width="7" height="4"') . ' alt="" />' : ''; return '<a href="' . htmlspecialchars($sSortUrl) . '">' . $sLabel . $sSortArrow . '</a>'; }
protected static function getErrorMailHtml($e, $actionName) { $htmlPart = '<strong>This is an automatic email from TYPO3. Don\'t answer!</strong>'; $htmlPart .= '<div><strong>UNCAUGHT EXCEPTION FOR VIEW: ' . $actionName . '</strong></div>'; $htmlPart .= '<p><strong>Message:</strong><br />' . $e->getMessage() . '</p>'; $htmlPart .= '<p><strong>Stacktrace:</strong><pre>' . $e->__toString() . '</pre></p>'; $htmlPart .= '<p><strong>SITE_URL</strong><br />' . tx_rnbase_util_Misc::getIndpEnv('TYPO3_SITE_URL') . '</p>'; $get = self::removePasswordParams($_GET); if (count($get)) { $htmlPart .= '<p><strong>_GET</strong><br />' . var_export($get, TRUE) . '</p>'; } $post = self::removePasswordParams($_POST); if (count($post)) { $htmlPart .= '<p><strong>_POST</strong><br />' . var_export($post, TRUE) . '</p>'; } $cookie = self::removePasswordParams($_COOKIE); if (count($cookie)) { $htmlPart .= '<p><strong>_COOKIE</strong><br />' . var_export($cookie, TRUE) . '</p>'; } $htmlPart .= '<p><strong>_SERVER</strong><br />' . var_export(self::removePasswordParams($_SERVER), TRUE) . '</p>'; if ($e instanceof tx_rnbase_util_Exception) { $additional = $e->getAdditional(); if ($additional) { $htmlPart .= '<p><strong>Additional Data:</strong><br />' . strval($additional) . '</p>'; } } tx_rnbase::load('tx_rnbase_util_TYPO3'); $htmlPart .= '<p><strong>BE_USER:</strong> ' . tx_rnbase_util_TYPO3::getBEUserUID() . '</p>'; $htmlPart .= '<p><strong>FE_USER:</strong> ' . tx_rnbase_util_TYPO3::getFEUserUID() . '</p>'; return $htmlPart; }
/** * Create the panel of buttons for submitting the form or otherwise perform operations. * * @return array all available buttons as an assoc. array */ function getButtons() { global $BACK_PATH, $BE_USER; $buttons = array('csh' => '', 'view' => '', 'record_list' => '', 'shortcut' => ''); // TODO: CSH $buttons['csh'] = Tx_Rnbase_Backend_Utility::cshItem('_MOD_' . $this->MCONF['name'], '', $GLOBALS['BACK_PATH'], '', TRUE); if ($this->id && is_array($this->pageinfo)) { // View page $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(Tx_Rnbase_Backend_Utility::viewOnClick($this->pageinfo['uid'], $BACK_PATH, Tx_Rnbase_Backend_Utility::BEgetRootLine($this->pageinfo['uid']))) . '">' . '<img' . Tx_Rnbase_Backend_Utility_Icons::skinImg($BACK_PATH, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" hspace="3" alt="" />' . '</a>'; // Shortcut if ($BE_USER->mayMakeShortcut()) { $buttons['shortcut'] = $this->getDoc()->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']); } // If access to Web>List for user, then link to that module. if ($BE_USER->check('modules', 'web_list')) { $href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(tx_rnbase_util_Misc::getIndpEnv('REQUEST_URI')); $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' . '<img' . Tx_Rnbase_Backend_Utility_Icons::skinImg($BACK_PATH, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' . '</a>'; } } return $buttons; }
protected static function getReferenceFileInfo(\TYPO3\CMS\Core\Resource\FileReference $reference) { // getProperties gets merged values from reference and the orig file $info = $reference->getProperties(); // add some fileinfo $info['file_path_name'] = $reference->getOriginalFile()->getPublicUrl(); $info['file_abs_url'] = tx_rnbase_util_Misc::getIndpEnv('TYPO3_SITE_URL') . $info['file_path_name']; $info['file_name'] = $info['name']; return $info; }
/** * Liefert die Daten für den testMakeUrlOrTag testcase. * * @return array */ public function getMakeUrlOrTagData() { return array(__LINE__ => array('typolink' => 'service/faq.html', 'absUrl' => FALSE, 'schema' => 'http://www.system25.de/', 'expected' => 'service/faq.html'), __LINE__ => array('typolink' => 'service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => 'http://www.system25.de/service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => '//www.system25.de/service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => '/service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => 'http://www.digedag.de/service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => '//www.digedag.de/service/faq.html', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'http://www.system25.de/service/faq.html'), __LINE__ => array('typolink' => '//www.digedag.de/service/faq.html', 'absUrl' => TRUE, 'schema' => '', 'expected' => tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_DIR') . 'service/faq.html'), __LINE__ => array('typolink' => '//www.digedag.de/service/faq.html', 'absUrl' => TRUE, 'schema' => FALSE, 'expected' => tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_DIR') . 'service/faq.html'), __LINE__ => array('typolink' => '<img src="service/faq.jpg" />', 'absUrl' => FALSE, 'schema' => 'http://www.system25.de/', 'expected' => '<img src="service/faq.jpg" />', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<img src="service/faq.jpg" />', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<img src="http://www.system25.de/service/faq.jpg" />', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="//www.system25.de/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="http://www.digedag.de/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => '<a href="http://www.system25.de/service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="http://www.digedag.de/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => '', 'expected' => '<a href="' . tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_DIR') . 'service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => '<a href="http://www.digedag.de/service/faq.html">FAQ</a>', 'absUrl' => TRUE, 'schema' => FALSE, 'expected' => '<a href="' . tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_DIR') . 'service/faq.html">FAQ</a>', 'method' => 'makeTag'), __LINE__ => array('typolink' => 'a href="service/faq.html">FAQ</a', 'absUrl' => TRUE, 'schema' => 'http://www.system25.de/', 'expected' => 'a href="service/faq.html">FAQ</a', 'method' => 'makeTag')); }
/** * @param string $remoteAddress * @param string $devIPmask * @return boolean */ public static function isDevelopmentIp($remoteAddress = '', $devIPmask = '') { $devIPmask = trim(strcmp($devIPmask, '') ? $devIPmask : $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']); $remoteAddress = trim(strcmp($remoteAddress, '') ? $remoteAddress : tx_rnbase_util_Misc::getIndpEnv('REMOTE_ADDR')); return self::cmpIP($remoteAddress, $devIPmask); }
/** * forces a schema for a url. * if there is already a schema in the url, the schema will be replaced. * * @param string $url * @param string $schema * @return string */ public static function parseAbsUrl($url, $schema = FALSE) { if (!$schema) { $schema = tx_rnbase_util_Misc::getIndpEnv('TYPO3_REQUEST_DIR'); } // check if we have a A-Tag with href attribute or a IMG-Tag with src attribute if (@simplexml_load_string($url)) { return preg_replace_callback('/(href="|src=")(.+)"/', function ($match) use($schema) { // $match[1] contains 'href="' or 'src="' // $match[2] contains the url '/service/contact.html' return $match[1] . tx_rnbase_util_Link::parseAbsUrl($match[2], $schema) . '"'; }, ltrim($url, '/')); } // else, we have only a url to rebuild // rebuild the url without schema $urlParts = parse_url(self::addDefaultSchemaIfRequired($url)); $urlPath = isset($urlParts['path']) ? $urlParts['path'] : ''; $urlPath .= isset($urlParts['query']) ? '?' . $urlParts['query'] : ''; $urlPath .= isset($urlParts['fragment']) ? '#' . $urlParts['fragment'] : ''; return rtrim($schema, '/') . '/' . ltrim($urlPath, '/'); }