/**
  * Analyze a given JS script
  * @param $file
  * @param $string
  * @param $config
  * @return void
  */
 public function __construct($inputFile = '', $string = FALSE, $config = array())
 {
     $this->configXML = $config;
     if ($string || ($string = t3lib_div::getURL($inputFile))) {
         // we just look for double quote
         $string = str_replace("'", '"', $string);
         $result = array();
         $components = array();
         if (count($this->configXML) > 0) {
             // build the components array
             foreach ($this->configXML as $group) {
                 if (count($group['files']) > 0) {
                     foreach ($group['files'] as $file) {
                         $components[$file['name']] = $file;
                         $components[$file['name']]['groupname'] = $group['name'];
                     }
                 }
             }
             // search for
             foreach ($this->configXML as $group) {
                 if (count($group['files']) > 0) {
                     foreach ($group['files'] as $file) {
                         if ($this->contains($string, $file['sources']) === TRUE) {
                             $result = array_merge($result, array($components[$file['depends']]['name'] => $components[$file['depends']]['groupname']));
                             $result = array_merge($result, array($file['name'] => $components[$file['name']]['groupname']));
                         }
                     }
                 }
             }
         }
         $this->dependencies = $result;
     }
 }
 /**
  * Creates URL to page using page id and parameters
  *
  * @param int $pageId
  * @param string $parameters
  * @return	string	Path to page or empty string
  */
 public static function getPagePath($pageId, $parameters = '')
 {
     if (is_array($parameters)) {
         $parameters = t3lib_div::implodeArrayForUrl('', $parameters);
     }
     $data = array('id' => intval($pageId));
     if ($parameters != '' && $parameters[0] == '&') {
         $data['parameters'] = $parameters;
     }
     $siteUrl = self::getSiteUrl($pageId);
     if ($siteUrl) {
         $url = $siteUrl . 'index.php?eID=pagepath&data=' . base64_encode(serialize($data));
         // Send TYPO3 cookies as this may affect path generation
         $headers = array('Cookie: fe_typo_user='******'fe_typo_user']);
         $result = t3lib_div::getURL($url, false, $headers);
         $urlParts = parse_url($result);
         if (!is_array($urlParts)) {
             // filter_var is too strict (for example, underscore characters make it fail). So we use parse_url here for a quick check.
             $result = '';
         } elseif ($result) {
             // See if we need to prepend domain part
             if ($urlParts['host'] == '') {
                 $result = rtrim($siteUrl, '/') . '/' . ltrim($result, '/');
             }
         }
     } else {
         $result = '';
     }
     return $result;
 }
示例#3
0
 public function main()
 {
     $out = '';
     $conf = $this->getModule()->getConfigurations();
     $file = t3lib_div::getFileAbsFileName($conf->get($this->getConfId() . 'template'));
     $templateCode = t3lib_div::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;
 }
 /**
  * The constructor for a finisher setting the component manager and the configuration.
  *
  * @param Tx_Formhandler_Component_Manager $componentManager
  * @param Tx_Formhandler_Configuration $configuration
  * @author Reinhard Führicht <*****@*****.**>
  * @return void
  */
 public function __construct(Tx_Formhandler_Component_Manager $componentManager, Tx_Formhandler_Configuration $configuration)
 {
     $this->componentManager = $componentManager;
     $this->configuration = $configuration;
     $this->templatePath = t3lib_extMgm::extPath('formhandler') . 'Resources/HTML/backend/';
     $this->templateFile = $this->templatePath . 'template.html';
     $this->templateCode = t3lib_div::getURL($this->templateFile);
 }
 /**
  * init method to load translation data and set log table.
  *
  * @global $LANG
  * @return void
  */
 protected function init()
 {
     global $LANG;
     $LANG->includeLLFile('EXT:formhandler/Resources/Language/locallang.xml');
     $templatePath = t3lib_extMgm::extPath('formhandler') . 'Resources/HTML/backend/';
     $templateFile = $templatePath . 'template.html';
     $this->templateCode = t3lib_div::getURL($templateFile);
 }
 /**
  * Main function
  *
  * @param	string		Absolute path to the selected PHP file
  * @param	string		Extension dir (local, global, system) relative to PATH_site
  * @return	string		HTML content.
  */
 function main($phpFile, $extensionDir)
 {
     if (@is_file($phpFile)) {
         $fCheck = $this->checkLLfilename($phpFile);
         if (!$fCheck) {
             $fileContent = t3lib_div::xml2array(t3lib_div::getURL($phpFile));
             if (@is_array($fileContent)) {
                 return $this->renderForm($fileContent, $phpFile);
             } else {
                 return 'ERROR: File is not XML: ' . $fileContent;
             }
         } else {
             return 'ERROR: ' . $fCheck;
         }
     }
 }
 function createPdf($abschlussLsf, $spoVersion, $fakultaet, $studiengangLsf, $vertiefungLsf = '')
 {
     $error = FALSE;
     $url = 'http://www3.hs-esslingen.de/qislsf/rds?state=modulBeschrGast&createPDF=Y&create=blobs&modulversion.semester=&modulversion.versionsid=' . '&nodeID=auswahlBaum|abschluss:abschl=' . $abschlussLsf . '|studiengang:stg=' . $studiengangLsf . '|stgSpecials:vert=' . $vertiefungLsf . ',schwp=,kzfa=H,pversion=' . $spoVersion . '&expand=1&asi=#';
     $dateiName = $studiengangLsf;
     if (!empty($vertiefungLsf)) {
         $dateiName .= '_' . $vertiefungLsf;
     }
     $dateiName .= '_' . $spoVersion;
     $dateiNameDe = $dateiName . '_de.pdf';
     $pfad = 'fileadmin/medien/fakultaeten/allgemein/modulbeschreibungen/' . $fakultaet;
     $documentRoot = t3lib_div::getIndpEnv(TYPO3_DOCUMENT_ROOT);
     $pfadKomplett = $documentRoot . '/' . $pfad;
     if (!is_dir($pfadKomplett)) {
         mkdir($pfadKomplett, 0755);
     }
     $dateiPfad = $pfadKomplett . '/' . $dateiNameDe;
     $redirectHeader = t3lib_div::getURL($url, 1, true, $report);
     preg_match('#^(.*)(http://www3.hs-esslingen.de/qislsf/.*&asi=)(.*)#Uis', $redirectHeader, $matches);
     $urlNew = $matches[2];
     $content = t3lib_div::getURL($urlNew, 1, true, $report);
     if ($report['error']) {
         $error = 'Fehler beim Einlesen des PDFs: "' . $dateiPfad . '"';
     } else {
         file_put_contents($dateiPfad, $content);
         /*
         $urlEnStart = 'http://www3.hs-esslingen.de/qislsf/rds?state=user&type=5&language=en';
         preg_match('#^(.*)(http://www3.hs-esslingen.de/qislsf/.*&asi=)(.*)#Uis',$redirectHeader,$matches);
         
         $content = t3lib_div::getURL($urlNew, 1, true, $report);
         $dateiNameEn = $dateiName . '_en.pdf';
         $dateiPfad = $pfadKomplett . '/' . $dateiNameEn;
         $redirectHeader = t3lib_div::getURL($url, 1, true, $report);
         preg_match('#^(.*)(http://www3.hs-esslingen.de/qislsf/.*&asi=)(.*)#Uis',$redirectHeader,$matches);
         $urlNew = $matches[2];
         $content = t3lib_div::getURL($urlNew, 1, true, $report);
         if ($report['error']) {
         	$error = 'Fehler beim Einlesen des PDFs: "' . $dateiPfad . '"';
         } else {
         	file_put_contents($dateiPfad, $content);
         }
         */
     }
     return $error;
 }
    /**
     * List media types, along with options to edit & delete
     *
     * @return	string		HTML table of all the mimetypes
     */
    function listMimeTypes()
    {
        global $LANG, $BACK_PATH, $BE_USER;
        // Load template
        $content = t3lib_parsehtml::getSubpart(t3lib_div::getURL($BACK_PATH . t3lib_extMgm::extRelPath('dam') . 'modfunc_tools_mimetypes/template.html'), '###MOD_TEMPLATE###');
        $rowTemplate[1] = t3lib_parsehtml::getSubpart($content, '###ROW_1###');
        $rowTemplate[2] = t3lib_parsehtml::getSubpart($content, '###ROW_2###');
        // Add some JS
        $this->pObj->doc->JScode .= $this->pObj->doc->wrapScriptTags('
				function deleteRecord(id)	{	//
					if (confirm(' . $LANG->JScharCode($LANG->getLL('deleteWarning')) . '))	{
						window.location.href = "' . $BACK_PATH . 'tce_db.php?cmd[tx_dam_media_types]["+id+"][delete]=1&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&vC=' . $BE_USER->veriCode() . '&prErr=1&uPT=1";
					}
					return false;
				}
		');
        // Get content
        $alternate = 1;
        $rows = '';
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dam_media_types', '', '', 'ext ASC');
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $editURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . ']=edit';
            //$deleteURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode( t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') ) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . '][delete]=1';
            $rowMarkers['EDIT'] = '<a href="#" onclick="window.location.href=\'' . $editURL . '\'; return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="Edit this type" alt="" height="16" width="16"></a>';
            $rowMarkers['DELETE'] = '<a href="#" onclick="deleteRecord(' . $row['uid'] . ')"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/deletedok.gif', 'width="11" height="12"') . ' title="Delete this type" alt="" height="16" width="16"></a>';
            $rowMarkers['EXTENSION'] = $row['ext'];
            $rowMarkers['MIME'] = $row['mime'];
            $rowMarkers['ICON'] = '<img src="' . $BACK_PATH . tx_dam::icon_getFileType(array('file_type' => $row['ext'], 'media_type' => $row['type'])) . '" />';
            $rows .= t3lib_parsehtml::substituteMarkerArray($rowTemplate[$alternate], $rowMarkers, '###|###');
            // Cycle the alternating rows
            if ($alternate == 2) {
                $alternate = 1;
            } else {
                $alternate = 2;
            }
        }
        $content = t3lib_parsehtml::substituteSubpart($content, '###ROWS###', $rows);
        $GLOBALS['TYPO3_DB']->sql_free_result($res);
        return $content;
    }
 /**
  * Main function, rendering the content of the rename form
  *
  * @return	void
  */
 function main()
 {
     global $LANG;
     $content = '';
     if (is_array($this->pObj->data) and isset($this->pObj->data['file_content'])) {
         // process conent update
         $error = tx_dam::process_editFile($this->pObj->media->getInfoArray(), $this->pObj->data['file_content']);
         if ($error) {
             $content .= $this->pObj->errorMessageBox($error);
         } elseif (t3lib_div::_GP('_saveandclosedok_x')) {
             $this->pObj->redirect(true);
             return;
         }
     }
     $content .= $this->renderForm(t3lib_div::getURL($this->pObj->media->getPathAbsolute()));
     return $content;
 }
示例#10
0
 /**
  * Getting HTTP request headers of URL
  *
  * @param	string		The URL
  * @param	integer		Timeout (seconds?)
  * @return	mixed		If no answer, returns false. Otherwise an array where HTTP headers are keys
  */
 function getUrlHeaders($url)
 {
     $content = t3lib_div::getURL($url, 2);
     // Try to get the headers only
     if (strlen($content)) {
         // Compile headers:
         $headers = t3lib_div::trimExplode(LF, $content, 1);
         $retVal = array();
         foreach ($headers as $line) {
             if (!strlen(trim($line))) {
                 break;
                 // Stop at the first empty line (= end of header)
             }
             list($headKey, $headValue) = explode(':', $line, 2);
             $retVal[$headKey] = $headValue;
         }
         return $retVal;
     }
 }
示例#11
0
文件: index.php 项目: Gerberus/tscobj
 /**
  * Add CSS styles
  *
  * This functions reads the module's stylesheet and replace some
  * colors to add skinning compatibility.
  *
  * @return		CSS styles, ready to be included in a <style> tag
  */
 function addStyles()
 {
     // Get stylesheet path
     $path = t3lib_extMgm::extPath('tscobj') . 'wiz1/stylesheet.css.tmpl';
     // Read stylesheet
     $styles = t3lib_div::getURL($path);
     // Replace color markers
     $styles = str_replace('###COLOR1###', $this->doc->bgColor5, $styles);
     $styles = str_replace('###COLOR2###', $this->doc->bgColor6, $styles);
     $styles = str_replace('###COLOR3###', $this->doc->bgColor3, $styles);
     // Return CSS styles
     return $styles;
 }
 /**
  * This function returns the mime type of the file specified by the url
  *
  * @param	string		$url: the url
  * @return	string		$mimeType: the mime type found in the header
  */
 public function getMimeType($url)
 {
     $mimeType = '';
     $headers = trim(t3lib_div::getURL($url, 2));
     if ($headers) {
         $matches = array();
         if (preg_match('/(Content-Type:[\\s]*)([a-zA-Z_0-9\\/\\-\\.\\+]*)([\\s]|$)/', $headers, $matches)) {
             $mimeType = trim($matches[2]);
         }
     }
     return $mimeType;
 }
 /**
  * Generic error page handler.
  * Exits.
  *
  * @param	mixed		Which type of handling; If a true PHP-boolean or TRUE then a ->printError message is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
  * @param	string		If set, this is passed directly to the PHP function, header()
  * @param	string		If set, error messages will also mention this as the reason for the page-not-found.
  * @return	void		(The function exits!)
  */
 function pageErrorHandler($code, $header = '', $reason = '')
 {
     // Issue header in any case:
     if ($header) {
         $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($headerArr as $header) {
             header($header);
         }
     }
     // Create response:
     if (gettype($code) == 'boolean' || !strcmp($code, 1)) {
         // Simply boolean; Just shows TYPO3 error page with reason:
         $this->printError('The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . htmlspecialchars($reason) : ''));
     } elseif (t3lib_div::isFirstPartOfStr($code, 'USER_FUNCTION:')) {
         $funcRef = trim(substr($code, 14));
         $params = array('currentUrl' => t3lib_div::getIndpEnv('REQUEST_URI'), 'reasonText' => $reason, 'pageAccessFailureReasons' => $this->getPageAccessFailureReasons());
         echo t3lib_div::callUserFunction($funcRef, $params, $this);
     } elseif (t3lib_div::isFirstPartOfStr($code, 'READFILE:')) {
         $readFile = t3lib_div::getFileAbsFileName(trim(substr($code, 9)));
         if (@is_file($readFile)) {
             $fileContent = t3lib_div::getUrl($readFile);
             $fileContent = str_replace('###CURRENT_URL###', t3lib_div::getIndpEnv('REQUEST_URI'), $fileContent);
             $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent);
             echo $fileContent;
         } else {
             $this->printError('Configuration Error: 404 page "' . $readFile . '" could not be found.');
         }
     } elseif (t3lib_div::isFirstPartOfStr($code, 'REDIRECT:')) {
         t3lib_utility_Http::redirect(substr($code, 9));
     } elseif (strlen($code)) {
         // Check if URL is relative
         $url_parts = parse_url($code);
         if ($url_parts['host'] == '') {
             $url_parts['host'] = t3lib_div::getIndpEnv('HTTP_HOST');
             $code = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . $code;
             $checkBaseTag = false;
         } else {
             $checkBaseTag = true;
         }
         // Check recursion
         if ($code == t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) {
             if ($reason == '') {
                 $reason = 'Page cannot be found.';
             }
             $reason .= LF . LF . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
             $this->printError('Reason: ' . nl2br(htmlspecialchars($reason)));
             exit;
         }
         // Prepare headers
         $headerArr = array('User-agent: ' . t3lib_div::getIndpEnv('HTTP_USER_AGENT'), 'Referer: ' . t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
         $res = t3lib_div::getURL($code, 1, $headerArr);
         // Header and content are separated by an empty line
         list($header, $content) = explode(CRLF . CRLF, $res, 2);
         $content .= CRLF;
         if (false === $res) {
             // Last chance -- redirect
             t3lib_utility_Http::redirect($code);
         } else {
             $forwardHeaders = array('Content-Type:');
             $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
             foreach ($headerArr as $header) {
                 foreach ($forwardHeaders as $h) {
                     if (preg_match('/^' . $h . '/', $header)) {
                         header($header);
                     }
                 }
             }
             // Put <base> if necesary
             if ($checkBaseTag) {
                 // If content already has <base> tag, we do not need to do anything
                 if (false === stristr($content, '<base ')) {
                     // Generate href for base tag
                     $base = $url_parts['scheme'] . '://';
                     if ($url_parts['user'] != '') {
                         $base .= $url_parts['user'];
                         if ($url_parts['pass'] != '') {
                             $base .= ':' . $url_parts['pass'];
                         }
                         $base .= '@';
                     }
                     $base .= $url_parts['host'];
                     // Add path portion skipping possible file name
                     $base .= preg_replace('/(.*\\/)[^\\/]*/', '${1}', $url_parts['path']);
                     // Put it into content (generate also <head> if necessary)
                     $replacement = LF . '<base href="' . htmlentities($base) . '" />' . LF;
                     if (stristr($content, '<head>')) {
                         $content = preg_replace('/(<head>)/i', '\\1' . $replacement, $content);
                     } else {
                         $content = preg_replace('/(<html[^>]*>)/i', '\\1<head>' . $replacement . '</head>', $content);
                     }
                 }
             }
             echo $content;
             // Output the content
         }
     } else {
         $this->printError($reason ? 'Reason: ' . htmlspecialchars($reason) : 'Page cannot be found.');
     }
     exit;
 }
示例#14
0
 /**
  * Returns the contents of a specific file within the ZIP
  *
  * @return	string	contents
  */
 function getZIPFileContents($ZIPfile, $filename)
 {
     if (file_exists($ZIPfile)) {
         // Unzipping SXW file, getting filelist:
         $tempPath = PATH_site . 'typo3temp/tx_tsconfighelp_ziptemp/';
         t3lib_div::mkdir($tempPath);
         $this->unzip($ZIPfile, $tempPath);
         $output = t3lib_div::getURL($tempPath . $filename);
         $cmd = 'rm -r "' . $tempPath . '"';
         t3lib_utility_Command::exec($cmd);
         return $output;
     }
 }
 /**
  * @param void
  * @return mixed
  */
 public function getBeLayout()
 {
     $beLayout = FALSE;
     if ($this->row['belayout']) {
         $beLayout = t3lib_div::getURL(t3lib_div::getFileAbsFileName($this->row['belayout']));
     } else {
         $beLayout = $this->getDatastructure()->getBeLayout();
     }
     return $beLayout;
 }
示例#16
0
    /**
     * [Describe function...]
     *
     * @return	[type]		...
     */
    function main()
    {
        $arrayBrowser = t3lib_div::makeInstance('t3lib_arrayBrowser');
        $this->content = $this->doc->header($GLOBALS['LANG']->getLL('configuration', true));
        $this->content .= $this->doc->spacer(5);
        $this->content .= '<div id="lowlevel-config">
						<label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', true) . '</label>
						<input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
						<input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', true) . '" />';
        $this->content .= t3lib_BEfunc::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"') . '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', true) . '</label>';
        $this->content .= t3lib_BEfunc::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') . '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', true) . '</label>
						</div>';
        $this->content .= $this->doc->spacer(5);
        switch ($this->MOD_SETTINGS['function']) {
            case 0:
                $theVar = $GLOBALS['TYPO3_CONF_VARS'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TYPO3_CONF_VARS';
                break;
            case 1:
                foreach ($GLOBALS['TCA'] as $table => $config) {
                    t3lib_div::loadTCA($table);
                }
                $theVar = $GLOBALS['TCA'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TCA';
                break;
            case 2:
                $theVar = $GLOBALS['TCA_DESCR'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TCA_DESCR';
                break;
            case 3:
                $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
                break;
            case 4:
                $theVar = $GLOBALS['T3_SERVICES'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$T3_SERVICES';
                break;
            case 5:
                $theVar = $GLOBALS['TBE_MODULES'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TBE_MODULES';
                break;
            case 6:
                $theVar = $GLOBALS['TBE_MODULES_EXT'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TBE_MODULES_EXT';
                break;
            case 7:
                $theVar = $GLOBALS['TBE_STYLES'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TBE_STYLES';
                break;
            case 8:
                $theVar = $GLOBALS['BE_USER']->uc;
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$BE_USER->uc';
                break;
            case 9:
                $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
                t3lib_div::naturalKeySortRecursive($theVar);
                $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
                break;
            default:
                $theVar = array();
                break;
        }
        // Update node:
        $update = 0;
        $node = t3lib_div::_GET('node');
        if (is_array($node)) {
            // If any plus-signs were clicked, it's registred.
            $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
            $update = 1;
        }
        if ($update) {
            $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'], $this->MOD_SETTINGS);
        }
        $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
        $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
        $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
        $arrayBrowser->searchKeysToo = TRUE;
        $search_field = t3lib_div::_GP('search_field');
        if (t3lib_div::_POST('search') && trim($search_field)) {
            // If any POST-vars are send, update the condition array
            $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
        }
        $tree = $arrayBrowser->tree($theVar, '', '');
        $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
        $this->content .= $this->doc->sectionEnd();
        // Variable name:
        if (t3lib_div::_GP('varname')) {
            $line = t3lib_div::_GP('_') ? t3lib_div::_GP('_') : t3lib_div::_GP('varname');
            if (t3lib_div::_GP('writetoexttables')) {
                // Write the line to extTables.php
                // change value to $GLOBALS
                $length = strpos($line, '[');
                $var = substr($line, 0, $length);
                $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
                // insert line  in extTables.php
                $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
                $extTables = '<?php' . preg_replace('/<\\?php|\\?>/is', '', $extTables) . $changedLine . LF . '?>';
                $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
                if ($success) {
                    // show flash message
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script, '<br />', '<strong>' . $changedLine . '</strong>'), t3lib_FlashMessage::OK);
                } else {
                    // Error: show flash message
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script), t3lib_FlashMessage::ERROR);
                }
                $this->content .= $flashMessage->render();
            }
            $this->content .= '<div id="lowlevel-config-var">
				<strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
				<input type="text" name="_" value="' . trim(htmlspecialchars($line)) . '" size="120" /><br/>';
            if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
                // write only for $TCA and TBE_STYLES if  TYPO3_extTableDef_script is defined
                $this->content .= '<br /><input type="submit" name="writetoexttables" value="' . $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
            } else {
                $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
            }
        }
        $this->content .= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">';
        $this->content .= '<tr>
					<th class="t3-row-header t3-tree-config-header">' . $label . '</th>
				</tr>
				<tr>
					<td>' . $tree . '</td>
				</tr>
			</table>
		';
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => $this->getFuncMenu(), 'CONTENT' => $this->content);
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render('Configuration', $this->content);
    }
 /**
  * Fetches extension l10n status from the given mirror
  *
  * @param string	 $extKey	Extension Key
  * @param string	 $mirrorURL	URL of mirror to use
  * @return mixed	Array containing l10n status data or FALSE if no status could be fetched
  */
 function fetchTranslationStatus($extKey, $mirrorURL)
 {
     $extPath = t3lib_div::strtolower($extKey);
     $mirrorURL .= $extPath[0] . '/' . $extPath[1] . '/' . $extPath . '-l10n/' . $extPath . '-l10n.xml';
     $remote = t3lib_div::getURL($mirrorURL, 0, array(TYPO3_user_agent));
     if ($remote !== false) {
         $parsed = $this->emObj->xmlHandler->parseL10nXML($remote);
         return $parsed['languagePackIndex'];
     }
     return FALSE;
 }
示例#18
0
 function gibModulHandbuch($args)
 {
     $dateiName = strtolower($args['stug']);
     if (!empty($args['vert'])) {
         $dateiName .= '_' . strtolower($args['vert']);
     }
     $dateiName .= '_' . $args['spo'] . '_' . $args['lang'] . '.pdf';
     $pfadKomplett = 'fileadmin/medien/fakultaeten/allgemein/modulbeschreibungen/' . strtolower($args['faku']);
     if (!is_dir($pfadKomplett)) {
         mkdir($pfadKomplett, 0755);
     }
     $pfadKomplett = 'fileadmin/medien/fakultaeten/allgemein/modulbeschreibungen/' . strtolower($args['faku']) . '/' . strtolower($args['stug']);
     if (!is_dir($pfadKomplett)) {
         mkdir($pfadKomplett, 0755);
     }
     $dateiPfad = $pfadKomplett . '/' . $dateiName;
     $documentRoot = t3lib_div::getIndpEnv(TYPO3_DOCUMENT_ROOT);
     $systemPfad = $documentRoot . '/' . $dateiPfad;
     $dateiVorhanden = file_exists($systemPfad);
     if ($dateiVorhanden) {
         $heute = date("Ymd", time());
         $dateiDatum = date("Ymd", filectime($systemPfad));
         if ($heute != $dateiDatum) {
             unlink($systemPfad);
             $dateiVorhanden = FALSE;
         }
     }
     if (!$dateiVorhanden) {
         $url = 'http://www3.hs-esslingen.de/qislsf/rds?state=modulBeschrGast&struct=auswahlBaum&language=' . $args['lang'] . '&createPDF=Y&create=blobs&modulversion.semester=&modulversion.versionsid=' . '&nodeID=auswahlBaum|abschluss:abschl=' . $args['abs'] . '|studiengang:stg=' . $args['stug'] . '|stgSpecials:vert=' . $args['vert'] . ',schwp=,kzfa=H,pversion=' . $args['spo'] . '&expand=1&asi=#';
         $redirectHeader = t3lib_div::getURL($url, 1, true, $report);
         preg_match('#^(.*)(http://www3.hs-esslingen.de/qislsf/.*&asi=)(.*)#Uis', $redirectHeader, $matches);
         $urlNew = $matches[2];
         $content = t3lib_div::getURL($urlNew, 1, true, $report);
         if ($report['error']) {
             $error = 'Fehler beim Einlesen des PDFs: "' . $dateiPfad . '"';
         } else {
             file_put_contents($dateiPfad, $content);
         }
     }
     $datei = fopen($dateiPfad, 'rb');
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: no-cache');
     header("Content-Type : application/pdf");
     header("Content-Disposition: attachment; filename=" . $dateiName);
     while (!feof($datei)) {
         set_time_limit(60);
         echo fread($datei, 8192);
     }
     fclose($datei);
     exit;
 }
示例#19
0
 /**
  * Function to load a HTML template file with markers.
  * When calling from own extension, use  syntax getHtmlTemplate('EXT:extkey/template.html')
  *
  * @param	string		tmpl name, usually in the typo3/template/ directory
  * @return	string		HTML of template
  */
 function getHtmlTemplate($filename)
 {
     if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
         $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
     }
     if (substr($filename, 0, 4) != 'EXT:') {
         $filename = t3lib_div::resolveBackPath($this->backPath . $filename);
     } else {
         $filename = t3lib_div::getFileAbsFileName($filename, true, true);
     }
     return t3lib_div::getURL($filename);
 }
 /**
  * Checks a given URL + /path/filename.ext for validity
  *
  * @param	string		$url: url to check
  * @param	 array	   $softRefEntry: the softref entry which builds the context of that url
  * @param	object		$reference:  parent instance of tx_linkvalidator_Processor
  * @return	string		TRUE on success or FALSE on error
  */
 public function checkLink($url, $softRefEntry, $reference)
 {
     $errorParams = array();
     if (isset($this->urlReports[$url])) {
         if (!$this->urlReports[$url]) {
             if (is_array($this->urlErrorParams[$url])) {
                 $this->setErrorParams($this->urlErrorParams[$url]);
             }
         }
         return $this->urlReports[$url];
     }
     // remove possible anchor from the url
     if (strrpos($url, '#') !== FALSE) {
         $url = substr($url, 0, strrpos($url, '#'));
     }
     // try to fetch the content of the URL (headers only)
     $report = array();
     // try fetching the content of the URL (just fetching the headers does not work correctly)
     $content = '';
     $content = t3lib_div::getURL($url, 1, FALSE, $report);
     $tries = 0;
     while (($report['http_code'] == 301 || $report['http_code'] == 302 || $report['http_code'] == 303 || $report['http_code'] == 307) && $tries < 5) {
         $isCodeRedirect = preg_match('/Location: (.*)/', $content, $location);
         if (isset($location[1])) {
             $content = t3lib_div::getURL($location[1], 2, FALSE, $report);
         }
         $tries++;
     }
     $response = TRUE;
     // analyze the response
     if ($report['error']) {
         // More cURL error codes can be found here:
         // http://curl.haxx.se/libcurl/c/libcurl-errors.html
         if ($report['lib'] === 'cURL' && $report['error'] === 28) {
             $errorParams['errorType'] = 'cURL28';
         } elseif ($report['lib'] === 'cURL' && $report['error'] === 22) {
             if (strstr($report['message'], '404')) {
                 $errorParams['errorType'] = 404;
             } elseif (strstr($report['message'], '403')) {
                 $errorParams['errorType'] = 403;
             } elseif (strstr($report['message'], '500')) {
                 $errorParams['errorType'] = 500;
             }
         } elseif ($report['lib'] === 'cURL' && $report['error'] === 6) {
             $errorParams['errorType'] = 'cURL6';
         } elseif ($report['lib'] === 'cURL' && $report['error'] === 56) {
             $errorParams['errorType'] = 'cURL56';
         }
         $response = FALSE;
     }
     // special handling for more information
     if ($report['http_code'] == 301 || $report['http_code'] == 302 || $report['http_code'] == 303 || $report['http_code'] == 307) {
         $errorParams['errorType'] = $report['http_code'];
         $errorParams['location'] = $location[1];
         $response = FALSE;
     }
     if ($report['http_code'] == 404 || $report['http_code'] == 403) {
         $errorParams['errorType'] = $report['http_code'];
         $response = FALSE;
     }
     if ($report['http_code'] >= 300 && $response) {
         $errorParams['errorType'] = $report['http_code'];
         $response = FALSE;
     }
     if (!$response) {
         $this->setErrorParams($errorParams);
     }
     $this->urlReports[$url] = $response;
     $this->urlErrorParams[$url] = $errorParams;
     return $response;
 }
 protected function replaceMarkersFromMaster()
 {
     $fieldMarkers = array();
     foreach ($this->masterTemplates as $idx => $masterTemplate) {
         $masterTemplateCode = t3lib_div::getURL($masterTemplate);
         $matches = array();
         preg_match_all('/###(field|master)_([^#]*)###/', $masterTemplateCode, $matches);
         if (!empty($matches[0])) {
             $subparts = array_unique($matches[0]);
             $subpartsCodes = array();
             if (is_array($subparts)) {
                 foreach ($subparts as $index => $subpart) {
                     $subpartKey = str_replace('#', '', $subpart);
                     $subpartsCodes[$subpartKey] = $this->cObj->getSubpart($masterTemplateCode, $subpart);
                 }
             }
             foreach ($subpartsCodes as $subpart => $code) {
                 $matchesSlave = array();
                 preg_match_all('/###' . $subpart . '(###|_([^#]*)###)/', $this->template, $matchesSlave);
                 if (!empty($matchesSlave[0])) {
                     foreach ($matchesSlave[0] as $key => $markerName) {
                         $fieldName = $matchesSlave[2][$key];
                         if ($fieldName) {
                             $markers = array('###fieldname###' => $fieldName, '###formValuesPrefix###' => Tx_Formhandler_Globals::$formValuesPrefix);
                             $replacedCode = $this->cObj->substituteMarkerArray($code, $markers);
                         } else {
                             $replacedCode = $code;
                         }
                         $fieldMarkers[$markerName] = $replacedCode;
                     }
                 }
             }
         }
     }
     $this->template = $this->cObj->substituteMarkerArray($this->template, $fieldMarkers);
 }
	/**
	 * @param void
	 * @return mixed
	 */
	public function getBeLayout() {
		$beLayout = FALSE;		
		$file = substr(t3lib_div::getFileAbsFileName($this->filename), 0, -3) . 'html';
		if (file_exists($file)) {
			$beLayout = t3lib_div::getURL($file);
		}
		return $beLayout;
	}
 /**
  * @return mixed
  */
 public function getAllMemberData()
 {
     $agencyData = t3lib_div::getURL($this->baseApiUrl . '&tx_ptassoc_admin%5Baction%5D=getAll');
     $decodedData = $this->decodeMemberData($agencyData);
     return $decodedData;
 }
 /**
  * Function executed from the Scheduler.
  *
  * @return	void
  */
 public function execute()
 {
     $this->setCliArguments();
     $successfullyExecuted = TRUE;
     if (!file_exists($file = t3lib_div::getFileAbsFileName($this->emailTemplateFile)) && !empty($this->email)) {
         throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidEmailTemplateFile'), '1295476972');
     }
     $htmlFile = t3lib_div::getURL($file);
     $this->templateMail = t3lib_parsehtml::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
     // The array to put the content into
     $html = array();
     $pageSections = '';
     $this->dif = FALSE;
     $pageList = t3lib_div::trimExplode(',', $this->page, 1);
     $modTS = $this->loadModTSconfig($this->page);
     if (is_array($pageList)) {
         foreach ($pageList as $page) {
             $pageSections .= $this->checkPageLinks($page);
         }
     }
     if ($this->totalBrokenLink != $this->oldTotalBrokenLink) {
         $this->dif = TRUE;
     }
     if ($this->totalBrokenLink > 0 && (!$this->emailOnBrokenLinkOnly || $this->dif) && !empty($this->email)) {
         $successfullyExecuted = $this->reportEmail($pageSections, $modTS);
     }
     return $successfullyExecuted;
 }
 /**
  * List action for this controller. Displays a list of agencies
  *
  * @var array $filter The filter to filter
  * @return string The rendered view
  * @dontvalidate $filter
  * @dontvalidate $order
  */
 public function listAction(array $filter = null)
 {
     // Process the filter
     $filterObject = $this->createFilterObject($filter);
     // Initialize the order
     $order = t3lib_div::makeInstance('Tx_Typo3Agencies_Domain_Model_Order');
     $order->addOrdering('member', Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING);
     $order->addOrdering('name', Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING);
     // Initialize the pager
     $pager = t3lib_div::makeInstance('Tx_Typo3Agencies_Domain_Model_Pager');
     if ($this->request->hasArgument('page')) {
         $pager->setPage($this->request->getArgument('page'));
         if ($pager->getPage() < 1) {
             $pager->setPage(1);
         }
     }
     $pager->setItemsPerPage($this->settings['pageBrowser']['itemsPerPage']);
     $offset = ($pager->getPage() - 1) * $pager->getItemsPerPage();
     $count = 0;
     if ($filterObject instanceof Tx_Typo3Agencies_Domain_Model_Filter && $filterObject->getLocation() != '') {
         //geocode the location
         $url = 'https://maps.googleapis.com/maps/api/geocode/json?' . $this->buildURL('address', $filterObject->getLocation());
         #$this->buildURL('output', 'csv').
         #$this->buildURL('key', $this->settings['googleMapsKey']);
         $result = json_decode(t3lib_div::getURL($url));
         $latLong = array();
         switch ($result->status) {
             case 'OK':
                 /*
                  * Geocoding worked!
                  * 200:  OK
                  */
                 $latLong['lat'] = $result->results[0]->geometry->location->lat;
                 $latLong['long'] = $result->results[0]->geometry->location->lng;
                 break;
             default:
         }
     }
     // Query the repository
     if (!empty($latLong) || $filterObject->getLocation() === '') {
         $agencies = $this->agencyRepository->findAllByFilter($filterObject, $order, $offset, $pager->getItemsPerPage(), $latLong, $this->settings['nearbyAdditionalWhere']);
         $allAgencies = $this->agencyRepository->findAllByFilter($filterObject, NULL, 0, 0, $latLong, $this->settings['nearbyAdditionalWhere']);
     }
     if ($agencies !== NULL) {
         $agenciesArray = $agencies->toArray();
     }
     if ($filterObject->getLocation() !== '' && (empty($latLong) || empty($agenciesArray))) {
         // search for the name or city
         $agencies = $this->agencyRepository->findByNameOrCity($filterObject, $order);
         $allAgencies = $agencies;
     }
     $count = count($allAgencies->toArray());
     $pager->setCount($count);
     // Assign values
     $this->view->assign('agencies', $agencies);
     $this->view->assign('allAgencies', $allAgencies);
     $this->view->assign('pager', $pager);
     $this->view->assign('filter', $filterObject);
 }
 private function queryDB($updateKey)
 {
     $file = t3lib_extMgm::extPath($this->getExtensionName(), $this->getSqlFileName());
     $fileContent = explode("\n", t3lib_div::getURL($file));
     if (!$fileContent) {
         return $this->getSqlFileName() . ' not found! (' . $file . ')';
     }
     $destEncoding = $this->getDestEncoding();
     $querys = array();
     $keyQuery = 0;
     foreach ($fileContent as $line) {
         $line = trim($line);
         // nach dem ende des update keys suchen
         if ($keyQuery && t3lib_div::isFirstPartOfStr($line, '#' . $updateKey)) {
             $keyQuery = 2;
             break;
             // alle satements gefunden schleife nicht mehr durchlaufen
         }
         // nach dem anfang des update keys suchen
         if (!$keyQuery && t3lib_div::isFirstPartOfStr($line, '#' . $updateKey)) {
             $keyQuery = 1;
             // key gefunden, jetzt folgen die statements
             continue;
         }
         // der update key wurde noch nicht erreicht
         if (!$keyQuery) {
             continue;
         }
         if ($line && t3lib_div::isFirstPartOfStr($line, $this->getSqlMode())) {
             // ggf. das encoding ändern
             $querys[] = $this->getUpdateEncoded($line, $destEncoding);
         }
     }
     switch ($keyQuery) {
         case 0:
             return 'No ' . strtolower($this->getSqlMode()) . ' key not found. (' . $updateKey . ')';
         case 1:
             return 'End key not found. (' . $updateKey . ')';
         case 2:
             // alles ok
     }
     if (count($querys) === 0) {
         return 'No queries found. (' . $updateKey . ')';
     }
     foreach ($querys as $query) {
         $GLOBALS['TYPO3_DB']->admin_query($query);
     }
     return true;
 }
 /**
  * render the section (Header or Footer)
  *
  * @param int $part	section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER
  * @return string	content of rendered section
  */
 public function render($part = self::PART_COMPLETE)
 {
     $jsFiles = '';
     $cssFiles = '';
     $cssInline = '';
     $jsInline = '';
     $jsFooterInline = '';
     $jsFooterLibs = '';
     $jsFooterFiles = '';
     $noJS = FALSE;
     // preRenderHook for possible manuipulation
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) {
         $params = array('jsLibs' => &$this->jsLibs, 'jsFiles' => &$this->jsFiles, 'jsFooterFiles' => &$this->jsFooterFiles, 'cssFiles' => &$this->cssFiles, 'headerData' => &$this->headerData, 'footerData' => &$this->footerData, 'jsInline' => &$this->jsInline, 'cssInline' => &$this->cssInline);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) {
             t3lib_div::callUserFunction($hook, $params, $this);
         }
     }
     $jsLibs = $this->renderJsLibraries();
     if ($this->concatenateFiles) {
         // do the file concatenation
         $this->doConcatenate();
     }
     if ($this->compressCss || $this->compressJavascript) {
         // do the file compression
         $this->doCompress();
     }
     $metaTags = implode(LF, $this->metaTags);
     // remove ending slashes from static header block
     // if the page is beeing rendered as html (not xhtml)
     // and define variable $endingSlash for further use
     if ($this->getRenderXhtml()) {
         $endingSlash = ' /';
     } else {
         $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag);
         $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag);
         $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag);
         $endingSlash = '';
     }
     if (count($this->cssFiles)) {
         foreach ($this->cssFiles as $file => $properties) {
             $file = t3lib_div::resolveBackPath($file);
             $file = t3lib_div::createVersionNumberedFilename($file);
             $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' . htmlspecialchars($file) . '" media="' . $properties['media'] . '"' . ($properties['title'] ? ' title="' . $properties['title'] . '"' : '') . $endingSlash . '>';
             if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
                 $tag = str_replace('|', $tag, $properties['allWrap']);
             }
             if ($properties['forceOnTop']) {
                 $cssFiles = $tag . LF . $cssFiles;
             } else {
                 $cssFiles .= LF . $tag;
             }
         }
     }
     if (count($this->cssInline)) {
         foreach ($this->cssInline as $name => $properties) {
             if ($properties['forceOnTop']) {
                 $cssInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $cssInline;
             } else {
                 $cssInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
             }
         }
         $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];
     }
     if (count($this->jsLibs)) {
         foreach ($this->jsLibs as $name => $properties) {
             $properties['file'] = t3lib_div::resolveBackPath($properties['file']);
             $properties['file'] = t3lib_div::createVersionNumberedFilename($properties['file']);
             $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . $properties['type'] . '"></script>';
             if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
                 $tag = str_replace('|', $tag, $properties['allWrap']);
             }
             if ($properties['forceOnTop']) {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsLibs = $tag . LF . $jsLibs;
                 } else {
                     $jsFooterLibs = $tag . LF . $jsFooterLibs;
                 }
             } else {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsLibs .= LF . $tag;
                 } else {
                     $jsFooterLibs .= LF . $tag;
                 }
             }
         }
     }
     if (count($this->jsFiles)) {
         foreach ($this->jsFiles as $file => $properties) {
             $file = t3lib_div::resolveBackPath($file);
             $file = t3lib_div::createVersionNumberedFilename($file);
             $tag = '<script src="' . htmlspecialchars($file) . '" type="' . $properties['type'] . '"></script>';
             if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
                 $tag = str_replace('|', $tag, $properties['allWrap']);
             }
             if ($properties['forceOnTop']) {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsFiles = $tag . LF . $jsFiles;
                 } else {
                     $jsFooterFiles = $tag . LF . $jsFooterFiles;
                 }
             } else {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsFiles .= LF . $tag;
                 } else {
                     $jsFooterFiles .= LF . $tag;
                 }
             }
         }
     }
     if (count($this->jsInline)) {
         foreach ($this->jsInline as $name => $properties) {
             if ($properties['forceOnTop']) {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsInline;
                 } else {
                     $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsFooterInline;
                 }
             } else {
                 if ($properties['section'] === self::PART_HEADER) {
                     $jsInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
                 } else {
                     $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF;
                 }
             }
         }
     }
     if ($jsInline) {
         $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];
     }
     if ($jsFooterInline) {
         $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];
     }
     // get template
     $templateFile = t3lib_div::getFileAbsFileName($this->templateFile, TRUE);
     $template = t3lib_div::getURL($templateFile);
     if ($this->removeEmptyLinesFromTemplate) {
         $template = strtr($template, array(LF => '', CR => ''));
     }
     if ($part != self::PART_COMPLETE) {
         $templatePart = explode('###BODY###', $template);
         $template = $templatePart[$part - 1];
     }
     if ($this->moveJsFromHeaderToFooter) {
         $jsFooterLibs = $jsLibs . LF . $jsFooterLibs;
         $jsLibs = '';
         $jsFooterFiles = $jsFiles . LF . $jsFooterFiles;
         $jsFiles = '';
         $jsFooterInline = $jsInline . LF . $jsFooterInline;
         $jsInline = '';
     }
     $markerArray = array('XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType, 'HTMLTAG' => $this->htmlTag, 'HEADTAG' => $this->headTag, 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '', 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '', 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '', 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '', 'CSS_INCLUDE' => $cssFiles, 'CSS_INLINE' => $cssInline, 'JS_INLINE' => $jsInline, 'JS_INCLUDE' => $jsFiles, 'JS_LIBS' => $jsLibs, 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '', 'META' => $metaTags, 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '', 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '', 'JS_LIBS_FOOTER' => $jsFooterLibs, 'JS_INCLUDE_FOOTER' => $jsFooterFiles, 'JS_INLINE_FOOTER' => $jsFooterInline, 'BODY' => $this->bodyContent);
     $markerArray = array_map('trim', $markerArray);
     $this->reset();
     return trim(t3lib_parsehtml::substituteMarkerArray($template, $markerArray, '###|###'));
 }
示例#28
0
	/**
	 * Renders the display of DS/TO creation directly from a file
	 *
	 * @return	void
	 */
	function renderFile()	{
		global $TYPO3_DB;

		if (@is_file($this->displayFile) && t3lib_div::getFileAbsFileName($this->displayFile))		{

				// Converting GPvars into a "cmd" value:
			$cmd = '';
			$msg = array();
			if (t3lib_div::_GP('_load_ds_xml'))	{	// Loading DS from XML or TO uid
				$cmd = 'load_ds_xml';
			} elseif (t3lib_div::_GP('_clear'))	{	// Resetting mapping/DS
				$cmd = 'clear';
			} elseif (t3lib_div::_GP('_saveDSandTO'))	{	// Saving DS and TO to records.
				if (!strlen(trim($this->_saveDSandTO_title))) {
					$cmd = 'saveScreen';
					$flashMessage = t3lib_div::makeInstance(
						't3lib_FlashMessage',
						$GLOBALS['LANG']->getLL('errorNoToTitleDefined'),
						'',
						t3lib_FlashMessage::ERROR
					);
					$msg[] = $flashMessage->render();
				} else {
					$cmd = 'saveDSandTO';
				}
			} elseif (t3lib_div::_GP('_updateDSandTO'))	{	// Updating DS and TO
				$cmd = 'updateDSandTO';
			} elseif (t3lib_div::_GP('_showXMLDS'))	{	// Showing current DS as XML
				$cmd = 'showXMLDS';
			} elseif (t3lib_div::_GP('_preview'))	{	// Previewing mappings
				$cmd = 'preview';
			} elseif (t3lib_div::_GP('_save_data_mapping'))	{	// Saving mapping to Session
				$cmd = 'save_data_mapping';
			} elseif (t3lib_div::_GP('_updateDS')) {
				$cmd = 'updateDS';
			} elseif (t3lib_div::_GP('DS_element_DELETE'))	{
				$cmd = 'DS_element_DELETE';
			} elseif (t3lib_div::_GP('_saveScreen'))	{
				$cmd = 'saveScreen';
			} elseif (t3lib_div::_GP('_loadScreen'))	{
				$cmd = 'loadScreen';
			} elseif (t3lib_div::_GP('_save'))	{
				$cmd = 'saveUpdatedDSandTO';
			} elseif (t3lib_div::_GP('_saveExit'))	{
				$cmd = 'saveUpdatedDSandTOandExit';
			}

				// Init settings:
			$this->editDataStruct=1;	// Edit DS...
			$content='';

				// Checking Storage Folder PID:
			if (!count($this->storageFolders))	{
				$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-error') . '<strong>'.$GLOBALS['LANG']->getLL('error').'</strong> '.$GLOBALS['LANG']->getLL('errorNoStorageFolder');
			}

				// Session data
			$this->sessionKey = $this->MCONF['name'] . '_mappingInfo:' . $this->_load_ds_xml_to;
			if ($cmd=='clear')	{	// Reset session data:
				$sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid);
				$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
			} else {	// Get session data:
				$sesDat = $GLOBALS['BE_USER']->getSessionData($this->sessionKey);
			}
			if ($this->_load_ds_xml_to) {
				$toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $this->_load_ds_xml_to);
				if ($this->staticDS) {
					$dsREC['dataprot'] = t3lib_div::getURL(t3lib_div::getFileAbsFileName($toREC['datastructure']));
				} else {
					$dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure', $toREC['datastructure']);
				}
			}

				// Loading DS from either XML or a Template Object (containing reference to DS)
			if ($cmd=='load_ds_xml' && ($this->_load_ds_xml_content || $this->_load_ds_xml_to))	{
				$to_uid = $this->_load_ds_xml_to;
				if ($to_uid)	{
					$tM = unserialize($toREC['templatemapping']);
					$sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid);
					$sesDat['currentMappingInfo'] = $tM['MappingInfo'];
					$sesDat['currentMappingInfo_head'] = $tM['MappingInfo_head'];
					$ds = t3lib_div::xml2array($dsREC['dataprot']);
					$sesDat['dataStruct'] = $sesDat['autoDS'] = $ds; // Just set $ds, not only its ROOT! Otherwise <meta> will be lost.
					$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
				} else {
					$ds = t3lib_div::xml2array($this->_load_ds_xml_content);
					$sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid);
					$sesDat['dataStruct'] = $sesDat['autoDS'] = $ds;
					$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
				}
			}


				// Setting Data Structure to value from session data - unless it does not exist in which case a default structure is created.
			$dataStruct = is_array($sesDat['autoDS']) ? $sesDat['autoDS'] : array(
				'meta' => array(
					'langDisable' => '1',
				),
				'ROOT' => array (
					'tx_templavoila' => array (
						'title' => 'ROOT',
						'description' => $GLOBALS['LANG']->getLL('rootDescription'),
					),
					'type' => 'array',
					'el' => array()
				)
			);

				// Setting Current Mapping information to session variable content OR blank if none exists.
			$currentMappingInfo = is_array($sesDat['currentMappingInfo']) ? $sesDat['currentMappingInfo'] : array();
			$this->cleanUpMappingInfoAccordingToDS($currentMappingInfo,$dataStruct);	// This will clean up the Current Mapping info to match the Data Structure.

				// CMD switch:
			switch($cmd)	{
					// Saving incoming Mapping Data to session data:
				case 'save_data_mapping':
					$inputData = t3lib_div::_GP('dataMappingForm',1);
					if (is_array($inputData))	{
						$sesDat['currentMappingInfo'] = $currentMappingInfo = $this->array_merge_recursive_overrule($currentMappingInfo,$inputData);
						$sesDat['dataStruct'] = $dataStruct;
						$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
					}
				break;
					// Saving incoming Data Structure settings to session data:
				case 'updateDS':
					$inDS = t3lib_div::_GP('autoDS',1);
					if (is_array($inDS))	{
						$sesDat['dataStruct'] = $sesDat['autoDS'] = $dataStruct = $this->array_merge_recursive_overrule($dataStruct,$inDS);
						$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
					}
				break;
					// If DS element is requested for deletion, remove it and update session data:
				case 'DS_element_DELETE':
					$ref = explode('][',substr($this->DS_element_DELETE,1,-1));
					$this->unsetArrayPath($dataStruct,$ref);
					$sesDat['dataStruct'] = $sesDat['autoDS'] = $dataStruct;
					$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
				break;
			}

				// Creating $templatemapping array with cached mapping content:
			if (t3lib_div::inList('showXMLDS,saveDSandTO,updateDSandTO,saveUpdatedDSandTO,saveUpdatedDSandTOandExit', $cmd)) {

					// Template mapping prepared:
				$templatemapping=array();
				$templatemapping['MappingInfo'] = $currentMappingInfo;
				if (isset($sesDat['currentMappingInfo_head'])) {
					$templatemapping['MappingInfo_head'] = $sesDat['currentMappingInfo_head'];
				}

					// Getting cached data:
				reset($dataStruct);
				$fileContent = t3lib_div::getUrl($this->displayFile);
				$htmlParse = t3lib_div::makeInstance('t3lib_parsehtml');
				$relPathFix = dirname(substr($this->displayFile,strlen(PATH_site))).'/';
				$fileContent = $htmlParse->prefixResourcePath($relPathFix,$fileContent);
				$this->markupObj = t3lib_div::makeInstance('tx_templavoila_htmlmarkup');
				$contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($fileContent,$currentMappingInfo);
				$templatemapping['MappingData_cached'] = $contentSplittedByMapping['sub']['ROOT'];

				list($html_header) =  $this->markupObj->htmlParse->getAllParts($htmlParse->splitIntoBlock('head',$fileContent),1,0);
				$this->markupObj->tags = $this->head_markUpTags;	// Set up the markupObject to process only header-section tags:

				if (isset($templatemapping['MappingInfo_head'])) {
					$h_currentMappingInfo=array();
					$currentMappingInfo_head = $templatemapping['MappingInfo_head'];
					if (is_array($currentMappingInfo_head['headElementPaths']))	{
						foreach($currentMappingInfo_head['headElementPaths'] as $kk => $vv)	{
							$h_currentMappingInfo['el_'.$kk]['MAP_EL'] = $vv;
						}
					}

					$contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($html_header,$h_currentMappingInfo);
					$templatemapping['MappingData_head_cached'] = $contentSplittedByMapping;

						// Get <body> tag:
					$reg='';
					preg_match('/<body[^>]*>/i',$fileContent,$reg);
					$templatemapping['BodyTag_cached'] = $currentMappingInfo_head['addBodyTag'] ? $reg[0] : '';
				}

				if ($cmd != 'showXMLDS') {
					// Set default flags to <meta> tag
					if (!isset($dataStruct['meta'])) {
						// Make sure <meta> goes at the beginning of data structure.
						// This is not critical for typo3 but simply convinient to
						// people who used to see it at the beginning.
						$dataStruct = array_merge(array('meta'=>array()), $dataStruct);
					}
					if ($this->_saveDSandTO_type == 1) {
						// If we save a page template, set langDisable to 1 as per localization guide
						if (!isset($dataStruct['meta']['langDisable'])) {
							$dataStruct['meta']['langDisable'] = '1';
						}
					}
					else {
						// FCE defaults to inheritance
						if (!isset($dataStruct['meta']['langDisable'])) {
							$dataStruct['meta']['langDisable'] = '0';
							$dataStruct['meta']['langChildren'] = '1';
						}
					}
				}
			}

				// CMD switch:
			switch($cmd)	{
					// If it is requested to save the current DS and mapping information to a DS and TO record, then...:
				case 'saveDSandTO':
					$newID = '';
						// Init TCEmain object and store:
					$tce = t3lib_div::makeInstance("t3lib_TCEmain");
					$tce->stripslashes_values=0;


					// DS:

						// Modifying data structure with conversion of preset values for field types to actual settings:
					$storeDataStruct = $dataStruct;
					if (is_array($storeDataStruct['ROOT']['el'])) {
						$this->eTypes->substEtypeWithRealStuff($storeDataStruct['ROOT']['el'],$contentSplittedByMapping['sub']['ROOT'],$dataArr['tx_templavoila_datastructure']['NEW']['scope']);
					}
					$dataProtXML = t3lib_div::array2xml_cs($storeDataStruct,'T3DataStructure', array('useCDATA' => 1));

					if ($this->staticDS) {
						$title = preg_replace('|[/,\."\']+|', '_', $this->_saveDSandTO_title) . ' (' . ($this->_saveDSandTO_type == 1 ? 'page' : 'fce') . ').xml';
						$path = t3lib_div::getFileAbsFileName($this->_saveDSandTO_type == 2 ? $this->extConf['staticDS.']['path_fce'] : $this->extConf['staticDS.']['path_page']) . $title;
						t3lib_div::writeFile($path, $dataProtXML);
						$newID = substr($path, strlen(PATH_site));
					} else {
						$dataArr=array();
						$dataArr['tx_templavoila_datastructure']['NEW']['pid'] = intval($this->_saveDSandTO_pid);
						$dataArr['tx_templavoila_datastructure']['NEW']['title'] = $this->_saveDSandTO_title;
						$dataArr['tx_templavoila_datastructure']['NEW']['scope'] = $this->_saveDSandTO_type;
						$dataArr['tx_templavoila_datastructure']['NEW']['dataprot'] = $dataProtXML;

							// start data processing
						$tce->start($dataArr,array());
						$tce->process_datamap();
						$newID = intval($tce->substNEWwithIDs['NEW']);
					}

						// If that succeeded, create the TO as well:
					if ($newID)	{
						$dataArr=array();
						$dataArr['tx_templavoila_tmplobj']['NEW']['pid'] = intval($this->_saveDSandTO_pid);
						$dataArr['tx_templavoila_tmplobj']['NEW']['title'] = $this->_saveDSandTO_title . ' [Template]';
						$dataArr['tx_templavoila_tmplobj']['NEW']['datastructure'] = $newID;
						$dataArr['tx_templavoila_tmplobj']['NEW']['fileref'] = substr($this->displayFile, strlen(PATH_site));
						$dataArr['tx_templavoila_tmplobj']['NEW']['templatemapping'] = serialize($templatemapping);
						$dataArr['tx_templavoila_tmplobj']['NEW']['fileref_mtime'] = @filemtime($this->displayFile);
						$dataArr['tx_templavoila_tmplobj']['NEW']['fileref_md5'] = @md5_file($this->displayFile);

							// Init TCEmain object and store:
						$tce->start($dataArr,array());
						$tce->process_datamap();
						$newToID = intval($tce->substNEWwithIDs['NEW']);
						if ($newToID) {
							$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-ok') .
								sprintf($GLOBALS['LANG']->getLL('msgDSTOSaved'),
								$dataArr['tx_templavoila_tmplobj']['NEW']['datastructure'],
								$tce->substNEWwithIDs['NEW'], $this->_saveDSandTO_pid);
						} else {
							$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-warning') . '<strong>'.$GLOBALS['LANG']->getLL('error').':</strong> '.sprintf($GLOBALS['LANG']->getLL('errorTONotSaved'), $dataArr['tx_templavoila_tmplobj']['NEW']['datastructure']);
						}
					} else {
						$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-warning') . ' border="0" align="top" class="absmiddle" alt="" /><strong>'.$GLOBALS['LANG']->getLL('error').':</strong> '.$GLOBALS['LANG']->getLL('errorTONotCreated');
					}

					unset($tce);
					if ($newID && $newToID) {
							//redirect to edit view
						$redirectUrl = 'index.php?file=' . rawurlencode($this->displayFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $newToID . '&uid=' . rawurlencode($newID) . '&returnUrl=' . rawurlencode('../mod2/index.php?id=' . intval($this->_saveDSandTO_pid));
						header('Location:' . t3lib_div::locationHeaderUrl($redirectUrl));
						exit;
					} else {
							// Clear cached header info because saveDSandTO always resets headers
						$sesDat['currentMappingInfo_head'] = '';
						$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
					}
				break;
					// Updating DS and TO records:
				case 'updateDSandTO':
				case 'saveUpdatedDSandTO':
				case 'saveUpdatedDSandTOandExit':

					if ($cmd == 'updateDSandTO') {
							// Looking up the records by their uids:
						$toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->_saveDSandTO_TOuid);
					} else {
						$toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->_load_ds_xml_to);
					}
					if ($this->staticDS) {
						$dsREC['uid'] = $toREC['datastructure'];
					} else {
						$dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure', $toREC['datastructure']);
					}

						// If they are found, continue:
					if ($toREC['uid'] && $dsREC['uid'])	{
							// Init TCEmain object and store:
						$tce = t3lib_div::makeInstance('t3lib_TCEmain');
						$tce->stripslashes_values=0;

							// Modifying data structure with conversion of preset values for field types to actual settings:
						$storeDataStruct=$dataStruct;
						if (is_array($storeDataStruct['ROOT']['el'])) {
							$this->eTypes->substEtypeWithRealStuff($storeDataStruct['ROOT']['el'],$contentSplittedByMapping['sub']['ROOT'],$dsREC['scope']);
						}
						$dataProtXML = t3lib_div::array2xml_cs($storeDataStruct,'T3DataStructure', array('useCDATA' => 1));

							// DS:
						if ($this->staticDS) {
							$path = PATH_site . $dsREC['uid'];
							t3lib_div::writeFile($path, $dataProtXML);
						} else {
							$dataArr=array();
							$dataArr['tx_templavoila_datastructure'][$dsREC['uid']]['dataprot'] = $dataProtXML;

								// process data
							$tce->start($dataArr,array());
							$tce->process_datamap();
						}

							// TO:
						$TOuid = t3lib_BEfunc::wsMapId('tx_templavoila_tmplobj',$toREC['uid']);
						$dataArr=array();
						$dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref']=substr($this->displayFile,strlen(PATH_site));
						$dataArr['tx_templavoila_tmplobj'][$TOuid]['templatemapping']=serialize($templatemapping);
						$dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_mtime'] = @filemtime($this->displayFile);
						$dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_md5'] = @md5_file($this->displayFile);


						$tce->start($dataArr,array());
						$tce->process_datamap();

						unset($tce);

						$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-notification') . sprintf($GLOBALS['LANG']->getLL('msgDSTOUpdated'), $dsREC['uid'], $toREC['uid']);

						if ($cmd == 'updateDSandTO') {
							if (!$this->_load_ds_xml_to) {
									//new created was saved to existing DS/TO, redirect to edit view
								$redirectUrl = 'index.php?file=' . rawurlencode($this->displayFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $toREC['uid'] . '&uid=' . rawurlencode($dsREC['uid']) . '&returnUrl=' . rawurlencode('../mod2/index.php?id=' . intval($this->_saveDSandTO_pid));
								header('Location:' . t3lib_div::locationHeaderUrl($redirectUrl));
								exit;
							} else {
									// Clear cached header info because updateDSandTO always resets headers
								$sesDat['currentMappingInfo_head'] = '';
								$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
							}
						} elseif ($cmd == 'saveUpdatedDSandTOandExit') {
							header ('Location:' . t3lib_div::locationHeaderUrl($this->returnUrl));
						}
					}
				break;
			}


				// Header:
			$tRows = array();
			$relFilePath = substr($this->displayFile, strlen(PATH_site));
			$onCl = 'return top.openUrlInWindow(\'' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $relFilePath . '\',\'FileView\');';
			$tRows[]='
				<tr>
					<td class="bgColor5" rowspan="2">' . $this->cshItem('xMOD_tx_templavoila', 'mapping_file', $this->doc->backPath, '|') . '</td>
					<td class="bgColor5" rowspan="2"><strong>' . $GLOBALS['LANG']->getLL('templateFile') . ':</strong></td>
					<td class="bgColor4"><a href="#" onclick="' . htmlspecialchars($onCl) . '">' . htmlspecialchars($relFilePath) . '</a></td>
				</tr>
 				<tr>
					<td class="bgColor4">
						<a href="#" onclick ="openValidator(\'' .  $this->sessionKey . '\');return false;">
						' . t3lib_iconWorks::getSpriteIcon('extensions-templavoila-htmlvalidate') . '
							' . $GLOBALS['LANG']->getLL('validateTpl') . '
						</a>
					</td>
				</tr>
				<tr>
					<td class="bgColor5">&nbsp;</td>
					<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('templateObject') . ':</strong></td>
					<td class="bgColor4">' . ($toREC ? htmlspecialchars($GLOBALS['LANG']->sL($toREC['title'])) : $GLOBALS['LANG']->getLL('mappingNEW')) . '</td>
				</tr>';
			if ($this->staticDS) {
				$onClick = 'return top.openUrlInWindow(\'' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $toREC['datastructure'] . '\',\'FileView\');';
				$tRows[]='
				<tr>
					<td class="bgColor5">&nbsp;</td>
					<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('renderDSO_XML') . ':</strong></td>
					<td class="bgColor4"><a href="#" onclick="' . htmlspecialchars($onClick) . '">'.htmlspecialchars($toREC['datastructure']).'</a></td>
				</tr>';
			} else {
				$tRows[]='
				<tr>
					<td class="bgColor5">&nbsp;</td>
					<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('renderTO_dsRecord') . ':</strong></td>
					<td class="bgColor4">' . ($dsREC ? htmlspecialchars($GLOBALS['LANG']->sL($dsREC['title'])) : $GLOBALS['LANG']->getLL('mappingNEW')) . '</td>
				</tr>';
			}

				// Write header of page:
			$content.='

				<!--
					Create Data Structure Header:
				-->
				<table border="0" cellpadding="2" cellspacing="1" id="c-toHeader">
					'.implode('',$tRows).'
				</table><br />
			';


				// Messages:
			if (is_array($msg))	{
				$content.='

					<!--
						Messages:
					-->
					'.implode('<br />',$msg).'
				';
			}


				// Generate selector box options:
				// Storage Folders for elements:
			$sf_opt=array();
			$res = $TYPO3_DB->exec_SELECTquery (
				'*',
				'pages',
				'uid IN ('.$this->storageFolders_pidList.')'.t3lib_BEfunc::deleteClause('pages'),
				'',
				'title'
			);
			while(false !== ($row = $TYPO3_DB->sql_fetch_assoc($res)))	{
				$sf_opt[]='<option value="'.htmlspecialchars($row['uid']).'">'.htmlspecialchars($row['title'].' (UID:'.$row['uid'].')').'</option>';
			}

				// Template Object records:
			$opt=array();
			$opt[]='<option value="0"></option>';
			if ($this->staticDS) {
				$res = $TYPO3_DB->exec_SELECTquery (
					'*, CASE WHEN LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure)>0 THEN 2 ELSE 1 END AS scope',
					'tx_templavoila_tmplobj',
					'pid IN ('.$this->storageFolders_pidList.') AND datastructure!=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('', 'tx_templavoila_tmplobj') .
						t3lib_BEfunc::deleteClause('tx_templavoila_tmplobj').
						t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_tmplobj'),
					'',
					'scope,title'
				);

			} else {
				$res = $TYPO3_DB->exec_SELECTquery (
					'tx_templavoila_tmplobj.*,tx_templavoila_datastructure.scope',
					'tx_templavoila_tmplobj LEFT JOIN tx_templavoila_datastructure ON tx_templavoila_datastructure.uid=tx_templavoila_tmplobj.datastructure',
					'tx_templavoila_tmplobj.pid IN ('.$this->storageFolders_pidList.') AND tx_templavoila_tmplobj.datastructure>0 '.
						t3lib_BEfunc::deleteClause('tx_templavoila_tmplobj').
						t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_tmplobj'),
					'',
					'tx_templavoila_datastructure.scope, tx_templavoila_tmplobj.pid, tx_templavoila_tmplobj.title'
				);

			}
			$storageFolderPid = 0;
			$optGroupOpen = false;
			while(false !== ($row = $TYPO3_DB->sql_fetch_assoc($res)))	{
				$scope = $row['scope'];
				unset($row['scope']);
				t3lib_BEfunc::workspaceOL('tx_templavoila_tmplobj',$row);
				if ($storageFolderPid != $row['pid']) {
					 $storageFolderPid = $row['pid'];
					 if ($optGroupOpen) {
						$opt[] = '</optgroup>';
					 }
					 $opt[] = '<optgroup label="' . htmlspecialchars($this->storageFolders[$storageFolderPid] . ' (PID: ' . $storageFolderPid . ')') . '">';
					 $optGroupOpen = true;
				}
				$opt[]= '<option value="' .htmlspecialchars($row['uid']).'" ' .
					($scope == 1 ? 'class="pagetemplate"">' : 'class="fce">') .
					 htmlspecialchars($GLOBALS['LANG']->sL($row['title']) . ' (UID:' . $row['uid'] . ')').'</option>';
			}
			if ($optGroupOpen) {
				$opt[] = '</optgroup>';
			}

				// Module Interface output begin:
			switch($cmd)	{
					// Show XML DS
				case 'showXMLDS':
					require_once(PATH_t3lib.'class.t3lib_syntaxhl.php');

						// Make instance of syntax highlight class:
					$hlObj = t3lib_div::makeInstance('t3lib_syntaxhl');

					$storeDataStruct=$dataStruct;
					if (is_array($storeDataStruct['ROOT']['el']))
						$this->eTypes->substEtypeWithRealStuff($storeDataStruct['ROOT']['el'],$contentSplittedByMapping['sub']['ROOT']);
					$dataStructureXML = t3lib_div::array2xml_cs($storeDataStruct,'T3DataStructure', array('useCDATA' => 1));

					$content.='
						<input type="submit" name="_DO_NOTHING" value="Go back" title="' . $GLOBALS['LANG']->getLL('buttonGoBack') . '" />
						<h3>'.$GLOBALS['LANG']->getLL('titleXmlConfiguration').':</h3>
						'.$this->cshItem('xMOD_tx_templavoila','mapping_file_showXMLDS',$this->doc->backPath,'|<br/>').'
						<pre>'.$hlObj->highLight_DS($dataStructureXML).'</pre>';
				break;
				case 'loadScreen':

					$content.='
						<h3>'.$GLOBALS['LANG']->getLL('titleLoadDSXml').'</h3>
						'.$this->cshItem('xMOD_tx_templavoila','mapping_file_loadDSXML',$this->doc->backPath,'|<br/>').'
						<p>'.$GLOBALS['LANG']->getLL('selectTOrecrdToLoadDSFrom').':</p>
						<select name="_load_ds_xml_to">'.implode('',$opt).'</select>
						<br />
						<p>'.$GLOBALS['LANG']->getLL('pasteDSXml').':</p>
						<textarea rows="15" name="_load_ds_xml_content" wrap="off"'.$GLOBALS['TBE_TEMPLATE']->formWidthText(48,'width:98%;','off').'></textarea>
						<br />
						<input type="submit" name="_load_ds_xml" value="'.$GLOBALS['LANG']->getLL('loadDSXml').'" />
						<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('buttonCancel') . '" />
						';
				break;
				case 'saveScreen':

					$content.='
						<h3>' . $GLOBALS['LANG']->getLL('createDSTO') . ':</h3>
						'.$this->cshItem('xMOD_tx_templavoila','mapping_file_createDSTO',$this->doc->backPath,'|<br/>').'
						<table border="0" cellpadding="2" cellspacing="2" class="dso_table">
							<tr>
								<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('titleDSTO') . ':</strong></td>
								<td class="bgColor4"><input type="text" name="_saveDSandTO_title" /></td>
							</tr>
							<tr>
								<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('templateType') . ':</strong></td>
								<td class="bgColor4">
									<select name="_saveDSandTO_type">
										<option value="1">' . $GLOBALS['LANG']->getLL('pageTemplate') . '</option>
										<option value="2">' . $GLOBALS['LANG']->getLL('contentElement') . '</option>
										<option value="0">' . $GLOBALS['LANG']->getLL('undefined') . '</option>
									</select>
								</td>
							</tr>
							<tr>
								<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('storeInPID') . ':</strong></td>
								<td class="bgColor4">
									<select name="_saveDSandTO_pid">
										'.implode('
										',$sf_opt).'
									</select>
								</td>
							</tr>
						</table>

						<input type="submit" name="_saveDSandTO" value="' . $GLOBALS['LANG']->getLL('createDSTOshort') . '" />
						<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('buttonCancel') . '" />



						<h3>' . $GLOBALS['LANG']->getLL('updateDSTO') . ':</h3>
						<table border="0" cellpadding="2" cellspacing="2">
							<tr>
								<td class="bgColor5"><strong>' . $GLOBALS['LANG']->getLL('selectTO') . ':</strong></td>
								<td class="bgColor4">
									<select name="_saveDSandTO_TOuid">
										'.implode('
										',$opt).'
									</select>
								</td>
							</tr>
						</table>

						<input type="submit" name="_updateDSandTO" value="UPDATE TO (and DS)" onclick="return confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('saveDSTOconfirm')) . ');" />
						<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('buttonCancel') . '" />
						';
				break;
				default:
						// Creating menu:
					$menuItems = array();
					$menuItems[]='<input type="submit" name="_showXMLDS" value="' . $GLOBALS['LANG']->getLL('buttonShowXML') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_showXML') . '" />';
					$menuItems[]='<input type="submit" name="_clear" value="' . $GLOBALS['LANG']->getLL('buttonClearAll') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_clearAll') . '" /> ';
					$menuItems[]='<input type="submit" name="_preview" value="' . $GLOBALS['LANG']->getLL('buttonPreview') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_preview') . '" />';
					if (is_array($toREC) && is_array($dsREC)) {
						$menuItems[]='<input type="submit" name="_save" value="' . $GLOBALS['LANG']->getLL('buttonSave') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_save') . '" />';
						$menuItems[]='<input type="submit" name="_saveExit" value="' . $GLOBALS['LANG']->getLL('buttonSaveExit') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_saveExit') . '" />';
					}
					$menuItems[]='<input type="submit" name="_saveScreen" value="' . $GLOBALS['LANG']->getLL('buttonSaveAs') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_saveAs') . '" />';
					$menuItems[]='<input type="submit" name="_loadScreen" value="' . $GLOBALS['LANG']->getLL('buttonLoad') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_load') . '" />';
					$menuItems[]='<input type="submit" name="_DO_NOTHING" value="' . $GLOBALS['LANG']->getLL('buttonRefresh') . '" title="' . $GLOBALS['LANG']->getLL('buttonTitle_refresh') . '" />';

					$menuContent = '

						<!--
							Menu for creation Data Structures / Template Objects
						-->
						<table border="0" cellpadding="2" cellspacing="2" id="c-toMenu">
							<tr class="bgColor5">
								<td>'.implode('</td>
								<td>',$menuItems).'</td>
							</tr>
						</table>
					';

					$content.='

					<!--
						Data Structure creation table:
					-->
					<h3>' . $this->cshItem('xMOD_tx_templavoila','mapping_file',$this->doc->backPath,'|') . $GLOBALS['LANG']->getLL('buildingDS') . ':</h3>' .
						$this->renderTemplateMapper($this->displayFile,$this->displayPath,$dataStruct,$currentMappingInfo,$menuContent);
				break;
			}
		}

		$this->content.=$this->doc->section('',$content,0,1);
	}
 /**
  * get the template code, prepared for javascript (no line breaks, quoted in slinge quotes)
  *
  * @return	string	the template code, prepared to use in javascript
  */
 protected function getPreparedTemplate()
 {
     $T3Editor_template = t3lib_div::getURL(t3lib_div::getFileAbsFileName('EXT:t3editor/res/templates/t3editor.html'));
     $T3Editor_template = addslashes($T3Editor_template);
     $T3Editor_template = str_replace(LF, "' + '", $T3Editor_template);
     return '\'' . $T3Editor_template . '\'';
 }
示例#30
0
文件: Google.php 项目: Konafets/oelib
 /**
  * Sends a geocoding request to the Google Maps server.
  *
  * @param string $address the address to look up, must not be empty
  *
  * @return mixed a string with the CSV result from the Google Maps server,
  *               or FALSE if an error has occurred
  */
 protected function sendRequest($address)
 {
     $baseUrlWithAddress = self::BASE_URL . '&address=';
     return t3lib_div::getURL($baseUrlWithAddress . urlencode($address));
 }