/**
  * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel.
  * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in.
  *
  * @param	string		The string to wrap in a link, typ. and image used as button in the edit panel.
  * @param	string		The name of the form wrapping the edit panel.
  * @param	string		The command of the link. There is a predefined list available: edit, new, up, down etc.
  * @param	string		The "table:uid" of the record being processed by the panel.
  * @param	string		Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed)
  * @param	integer		"New pid" - for new records
  * @return	string		A <a> tag wrapped string.
  * @see	editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction()
  */
 protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord = '', $confirm = '', $nPid = '')
 {
     // Editing forms on page only supported in Live workspace (because of incomplete implementation)
     $editFormsOnPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] && $GLOBALS['BE_USER']->workspace === 0;
     $nV = t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
     $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
     if ($cmd == 'edit' && !$editFormsOnPage) {
         $rParts = explode(':', $currentRecord);
         $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $rParts[1] . ']=edit&noView=' . $nV, $currentRecord);
     } elseif ($cmd == 'new' && !$editFormsOnPage) {
         $rParts = explode(':', $currentRecord);
         if ($rParts[0] == 'pages') {
             $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'db_new.php?id=' . $rParts[1] . '&pagesOnly=1', $currentRecord);
         } else {
             if (!intval($nPid)) {
                 $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
             }
             $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $nPid . ']=new&noView=' . $nV, $currentRecord);
         }
     } else {
         if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
             // Gets htmlspecialchared later
             $cf1 = 'if (confirm(' . t3lib_div::quoteJSvalue($confirm, true) . ')) {';
             $cf2 = '}';
         } else {
             $cf1 = $cf2 = '';
         }
         $out = '<a href="#" onclick="' . htmlspecialchars($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;') . '">' . $string . '</a>';
     }
     return $out;
 }
    /**
     * Test if default file format works
     *
     * @test
     * @return void
     */
    public function viewHelperReturnsCorrectJs()
    {
        $newsRepository = $this->objectManager->get('Tx_News_Domain_Repository_NewsRepository');
        $newUid = $this->testingFramework->createRecord('tx_news_domain_model_news', array('pid' => 98, 'title' => 'fobar'));
        $newsItem = $newsRepository->findByUid($newUid);
        $language = 'en';
        $viewHelper = new Tx_News_ViewHelpers_Social_DisqusViewHelper();
        $settingsService = $this->getAccessibleMock('Tx_News_Service_SettingsService');
        $settingsService->expects($this->any())->method('getSettings')->will($this->returnValue(array('disqusLang' => $language)));
        $viewHelper->injectSettingsService($settingsService);
        $actualResult = $viewHelper->render($newsItem, 'abcdef', 'http://typo3.org/dummy/fobar.html');
        $expectedCode = '<script type="text/javascript">
					var disqus_shortname = ' . t3lib_div::quoteJSvalue('abcdef', TRUE) . ';
					var disqus_identifier = ' . t3lib_div::quoteJSvalue('news_' . $newUid, TRUE) . ';
					var disqus_url = ' . t3lib_div::quoteJSvalue('http://typo3.org/dummy/fobar.html') . ';
					var disqus_title = ' . t3lib_div::quoteJSvalue('fobar', TRUE) . ';
					var disqus_config = function () {
						this.language = ' . t3lib_div::quoteJSvalue($language) . ';
					};

					(function() {
						var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
						dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
						(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
					})();
				</script>';
        $this->assertEquals($expectedCode, $actualResult);
    }
    /**
     * Render videos from various video portals
     *
     * @param Tx_News_Domain_Model_Media $element
     * @param integer $width
     * @param integer $height
     * @return string
     */
    public function render(Tx_News_Domain_Model_Media $element, $width, $height)
    {
        $content = $finalUrl = '';
        $url = Tx_News_Service_FileService::getCorrectUrl($element->getContent());
        // get the correct rewritten url
        $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($url);
        if ($mediaWizard !== NULL) {
            $finalUrl = $mediaWizard->rewriteUrl($url);
        }
        // override width & height if both are set
        if ($element->getWidth() > 0 && $element->getHeight() > 0) {
            $width = $element->getWidth();
            $height = $element->getHeight();
        }
        if (!empty($finalUrl)) {
            $GLOBALS['TSFE']->getPageRenderer()->addJsFile('typo3conf/ext/news/Resources/Public/JavaScript/Contrib/swfobject-2-2.js');
            $uniqueDivId = 'mediaelement' . Tx_News_Service_FileService::getUniqueId($element);
            $content .= '<div id="' . htmlspecialchars($uniqueDivId) . '"></div>
						<script type="text/javascript">
							var params = { allowScriptAccess: "always" };
							var atts = { id: ' . t3lib_div::quoteJSvalue($uniqueDivId) . ' };
							swfobject.embedSWF(' . t3lib_div::quoteJSvalue($finalUrl) . ',
							' . t3lib_div::quoteJSvalue($uniqueDivId) . ', "' . (int) $width . '", "' . (int) $height . '", "8", null, null, params, atts);
						</script>';
        }
        return $content;
    }
Esempio n. 4
0
    /**
     * Render mp3 files
     *
     * @param Tx_News_Domain_Model_Media $element
     * @param integer $width
     * @param integer $height
     * @param string $template
     * @return string
     */
    public function render(Tx_News_Domain_Model_Media $element, $width, $height, $template = '')
    {
        $url = Tx_News_Service_FileService::getCorrectUrl($element->getMultimedia());
        $uniqueId = Tx_News_Service_FileService::getUniqueId($element);
        $GLOBALS['TSFE']->getPageRenderer()->addJsFile(self::PATH_TO_JS . 'swfobject-2-2.js');
        $GLOBALS['TSFE']->getPageRenderer()->addJsFile(self::PATH_TO_JS . 'audioplayer-noswfobject.js');
        $inlineJs = '
			AudioPlayer.setup("' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . self::PATH_TO_JS . 'audioplayer-player.swf", {
				width: ' . (int) $width . '
			});';
        $GLOBALS['TSFE']->getPageRenderer()->addJsInlineCode('news_audio', $inlineJs);
        $content = '<p id="' . htmlspecialchars($uniqueId) . '">' . htmlspecialchars($element->getCaption()) . '</p>
					<script type="text/javascript">
						AudioPlayer.embed(' . t3lib_div::quoteJSvalue($uniqueId) . ', {soundFile: ' . t3lib_div::quoteJSvalue($url) . '});
					</script> ';
        return $content;
    }
    /**
     * Render disqus thread
     *
     * @param Tx_News_Domain_Model_News $newsItem news item
     * @param string $shortName shortname
     * @param string $link link
     * @return string
     */
    public function render(Tx_News_Domain_Model_News $newsItem, $shortName, $link)
    {
        $tsSettings = $this->pluginSettingsService->getSettings();
        $code = '<script type="text/javascript">
					var disqus_shortname = ' . t3lib_div::quoteJSvalue($shortName, TRUE) . ';
					var disqus_identifier = \'news_' . $newsItem->getUid() . '\';
					var disqus_url = ' . t3lib_div::quoteJSvalue($link, TRUE) . ';
					var disqus_title = ' . t3lib_div::quoteJSvalue($newsItem->getTitle(), TRUE) . ';
					var disqus_config = function () {
						this.language = ' . t3lib_div::quoteJSvalue($tsSettings['disqusLang']) . ';
					};

					(function() {
						var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
						dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
						(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
					})();
				</script>';
        return $code;
    }
 /**
  * Wrapping $title in a-tags.
  *
  * @param	string		Title string
  * @param	string		Item record
  * @param	integer		Bank pointer (which mount point number)
  * @return	string
  * @access private
  */
 function wrapTitle($title, $row)
 {
     if ($row['uid']) {
         #			$aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&bparams='.$GLOBALS['SOBE']->bparams.$this->getJumpToParam($row).'\');';
         #			$title = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
         $aOnClick = "return insertElement('" . $this->table . "', '" . $row['uid'] . "', 'db', " . t3lib_div::quoteJSvalue($title) . ", '', '', '');";
         $ATag = '<a href="#" onclick="' . $aOnClick . '">';
         $ATag_alt = substr($ATag, 0, -4) . ',\'\',1);">';
         #			$title = $ATag_alt.$title.'</a>';
         $icon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />';
         $title = $ATag_alt . $title . '&nbsp;' . $ATag . $icon . '</a>';
     }
     return $title;
 }
 /**
  * Generates a number of lines of JavaScript code for a menu level.
  * Calls itself recursively for additional levels.
  *
  * @param	integer		Number of levels to generate
  * @param	integer		Current level being generated - and if this number is less than $levels it will call itself recursively with $count incremented
  * @param	integer		Page id of the starting point.
  * @param	array		$this->menuArr passed along
  * @param	array		Previous MP vars
  * @return	string		JavaScript code lines.
  * @access private
  */
 function generate_level($levels, $count, $pid, $menuItemArray = '', $MP_array = array())
 {
     $levelConf = $this->mconf[$count . '.'];
     // Translate PID to a mount page, if any:
     $mount_info = $this->sys_page->getMountPointInfo($pid);
     if (is_array($mount_info)) {
         $MP_array[] = $mount_info['MPvar'];
         $pid = $mount_info['mount_pid'];
     }
     // UIDs to ban:
     $banUidArray = $this->getBannedUids();
     // Initializing variables:
     $var = $this->JSVarName;
     $menuName = $this->JSMenuName;
     $parent = $count == 1 ? 0 : $var . ($count - 1);
     $prev = 0;
     $c = 0;
     $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
     foreach ($menuItems as $uid => $data) {
         // $data['_MP_PARAM'] contains MP param for overlay mount points (MPs with "substitute this page" set)
         // if present: add param to copy of MP array (copy used for that submenu branch only)
         $MP_array_sub = $MP_array;
         if (array_key_exists('_MP_PARAM', $data) && $data['_MP_PARAM']) {
             $MP_array_sub[] = $data['_MP_PARAM'];
         }
         // Set "&MP=" var:
         $MP_var = implode(',', $MP_array_sub);
         $MP_params = $MP_var ? '&MP=' . rawurlencode($MP_var) : '';
         $spacer = t3lib_div::inList($this->spacerIDList, $data['doktype']) ? 1 : 0;
         // if item is a spacer, $spacer is set
         if ($this->mconf['SPC'] || !$spacer) {
             // If the spacer-function is not enabled, spacers will not enter the $menuArr
             if (!t3lib_div::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !t3lib_div::inArray($banUidArray, $uid)) {
                 // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
                 if ($count < $levels) {
                     $addLines = $this->generate_level($levels, $count + 1, $data['uid'], '', $MP_array_sub);
                 } else {
                     $addLines = '';
                 }
                 $title = $data['title'];
                 $url = '';
                 $target = '';
                 if (!$addLines && !$levelConf['noLink'] || $levelConf['alwaysLink']) {
                     $LD = $this->menuTypoLink($data, $this->mconf['target'], '', '', array(), $MP_params, $this->mconf['forceTypeValue']);
                     // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
                     $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']);
                     $url = $GLOBALS['TSFE']->baseUrlWrap($LD['totalURL']);
                     $target = $LD['target'];
                 }
                 $codeLines .= LF . $var . $count . "=" . $menuName . ".add(" . $parent . "," . $prev . ",0," . t3lib_div::quoteJSvalue($title, true) . "," . t3lib_div::quoteJSvalue($url, true) . "," . t3lib_div::quoteJSvalue($target, true) . ");";
                 // If the active one should be chosen...
                 $active = $levelConf['showActive'] && $this->isActive($data['uid'], $MP_var);
                 // If the first item should be shown
                 $first = !$c && $levelConf['showFirst'];
                 // do it...
                 if ($active || $first) {
                     if ($count == 1) {
                         $codeLines .= LF . $menuName . ".openID = " . $var . $count . ";";
                     } else {
                         $codeLines .= LF . $menuName . ".entry[" . $parent . "].openID = " . $var . $count . ";";
                     }
                 }
                 // Add submenu...
                 $codeLines .= $addLines;
                 $prev = $var . $count;
                 $c++;
             }
         }
     }
     if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel']) {
         $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
     }
     if ($levelConf['firstLabel'] && $codeLines) {
         $codeLines .= LF . $menuName . '.defTopTitle[' . $count . '] = ' . t3lib_div::quoteJSvalue($levelConf['firstLabel'], true) . ';';
     }
     return $codeLines;
 }
    /**
     * Echo the HTML page and JS that will insert the image
     *
     * @param	string		$url: the url of the image
     * @param	integer		$width: the width of the image
     * @param	integer		$height: the height of the image
     * @param	string		$altText: text for the alt attribute of the image
     * @param	string		$titleText: text for the title attribute of the image
     * @param	string		$additionalParams: text representing more html attributes to be added on the img tag
     * @return	void
     */
    protected function imageInsertJS($url, $width, $height, $altText = '', $titleText = '', $additionalParams = '')
    {
        echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Untitled</title>
</head>
<script type="text/javascript">
/*<![CDATA[*/
	var dialog = window.opener.HTMLArea.Dialog.TYPO3Image;
	var plugin = dialog.plugin;
	function insertImage(file,width,height,alt,title,additionalParams)	{
		plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass ? '+\' class="' . $this->defaultClass . '"\'' : '') . '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
	}
/*]]>*/
</script>
<body>
<script type="text/javascript">
/*<![CDATA[*/
	insertImage(' . t3lib_div::quoteJSvalue($url, 1) . ',' . $width . ',' . $height . ',' . t3lib_div::quoteJSvalue($altText, 1) . ',' . t3lib_div::quoteJSvalue($titleText, 1) . ',' . t3lib_div::quoteJSvalue($additionalParams, 1) . ');
/*]]>*/
</script>
</body>
</html>';
    }
 /**
  * Parse all images into the template
  * 
  * @param string $dir
  * @param boolean $onlyJS
  * @return string
  */
 public function parseTemplate($dir = '', $onlyJS = false)
 {
     $this->pagerenderer = t3lib_div::makeInstance('tx_imagecarousel_pagerenderer');
     $this->pagerenderer->setConf($this->conf);
     // define the directory of images
     if ($dir == '') {
         $dir = $this->imageDir;
     }
     // define the contentKey if not exist
     if ($this->getContentKey() == '') {
         $this->setContentKey($this->extKey . '_key');
     }
     // define the jQuery mode and function
     if ($this->conf['jQueryNoConflict']) {
         $jQueryNoConflict = "jQuery.noConflict();";
     } else {
         $jQueryNoConflict = "";
     }
     preg_match("/^([0-9]*)/i", $this->conf['imagewidth'], $reg_width);
     preg_match("/^([0-9]*)/i", $this->conf['imageheight'], $reg_height);
     $css_width = is_numeric($reg_width[1]) ? $reg_width[1] . "px" : $this->conf['imagewidth'];
     $css_height = is_numeric($reg_height[1]) ? $reg_height[1] . "px" : $this->conf['imageheight'];
     // add CSS file for skin
     $skin_class = null;
     if ($this->conf['skin']) {
         $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['imagecarousel']);
         $this->pagerenderer->addCssFile("{$confArr['skinFolder']}/{$this->conf['skin']}/skin.css");
         $skin_class = "jcarousel-skin-{$this->conf['skin']}";
     }
     // checks if t3jquery is loaded
     if (T3JQUERY === true) {
         tx_t3jquery::addJqJS();
     } else {
         $this->pagerenderer->addJsFile($this->conf['jQueryLibrary'], true);
         $this->pagerenderer->addJsFile($this->conf['jQueryEasing']);
     }
     // define the js files
     $this->pagerenderer->addJsFile($this->conf['jQueryCarousel']);
     $this->pagerenderer->addJsFile($this->conf['jsScript']);
     // get the options from config
     $options = array();
     $options[] = "size: " . count($this->images);
     if ($this->conf['vertical']) {
         // turn off the externalcontrol
         $this->conf['externalcontrol'] = 0;
         $options[] = "vertical: true";
     }
     if ($this->conf['auto'] > 0) {
         $options[] = "auto: " . $this->conf['auto'] / 1000;
     }
     if (in_array($this->conf['transition'], array('linear', 'swing'))) {
         $options[] = "easing: '{$this->conf['transition']}'";
     } elseif ($this->conf['transitiondir'] && $this->conf['transition']) {
         $options[] = "easing: 'ease{$this->conf['transitiondir']}{$this->conf['transition']}'";
     }
     if ($this->conf['transitionduration'] > 0) {
         $options[] = "animation: {$this->conf['transitionduration']}";
     }
     if (in_array($this->conf['movewrap'], array("first", "last", "both", "circular"))) {
         if (!($this->conf['externalcontrol'] && $this->conf['movewrap'] == "circular")) {
             $options[] = "wrap: '{$this->conf['movewrap']}'";
         }
     }
     if ($this->conf['rtl']) {
         $options[] = "rtl: true";
     }
     if ($this->conf['scroll'] > 0) {
         if ($this->conf['scroll'] > count($this->images)) {
             $this->conf['scroll'] = count($this->images);
         }
         $options[] = "scroll: {$this->conf['scroll']}";
     }
     // init Callback
     $initCallback[] = "imagecarousel.initCallback('#{$this->getContentKey()}',carousel,state)";
     if ($this->conf['stoponmouseover'] == 1) {
         $initCallback[] = "imagecarousel.initCallbackMouseover(carousel,state)";
     }
     $options[] = "initCallback: function(carousel,state){" . implode(";", $initCallback) . ";}";
     // hide buttons
     if ($this->conf['hidenextbutton']) {
         $options[] = "buttonNextHTML: null";
     }
     if ($this->conf['hidepreviousbutton']) {
         $options[] = "buttonPrevHTML: null";
     }
     // fallback for childElem
     if (!$this->conf['carousel.'][$this->type . '.']['childElem']) {
         $this->conf['carousel.'][$this->type . '.']['childElem'] = 'li';
     }
     $random_script = null;
     if ($this->conf['random']) {
         $random_script = "\n\timagecarousel.randomize('#{$this->getContentKey()}','{$this->conf['carousel.'][$this->type . '.']['childElem']}');";
     }
     // caption
     $jQueryCaptify = null;
     if ($this->conf['showCaption']) {
         $captions = array();
         if ($this->conf['animation']) {
             $captions[] = "animation: " . t3lib_div::quoteJSvalue($this->conf['animation']);
         }
         if ($this->conf['position']) {
             $captions[] = "position: " . t3lib_div::quoteJSvalue($this->conf['position']);
         }
         if ($this->conf['speedOver']) {
             $captions[] = "speedOver: " . t3lib_div::quoteJSvalue($this->conf['speedOver']);
         }
         if ($this->conf['speedOut']) {
             $captions[] = "speedOut: " . t3lib_div::quoteJSvalue($this->conf['speedOut']);
         }
         if ($this->conf['hideDelay']) {
             $captions[] = "hideDelay: " . t3lib_div::quoteJSvalue($this->conf['hideDelay']);
         }
         if ($this->conf['prefix']) {
             $captions[] = "prefix: " . t3lib_div::quoteJSvalue($this->conf['prefix']);
         }
         if ($this->conf['opacity']) {
             $captions[] = "opacity: " . t3lib_div::quoteJSvalue($this->conf['opacity']);
         }
         if ($this->conf['className']) {
             $captions[] = "className: " . t3lib_div::quoteJSvalue($this->conf['className']);
         }
         if ($this->conf['spanWidth']) {
             $captions[] = "spanWidth: " . t3lib_div::quoteJSvalue($this->conf['spanWidth']);
         }
         $this->pagerenderer->addJsFile($this->conf['jQueryCaptify']);
         $jQueryCaptify = "\n\tjQuery('#{$this->getContentKey()} img.captify').captify(" . (count($captions) ? "{\n\t\t" . implode(",\n\t\t", $captions) . "\n\t}" : "") . ");";
     }
     $this->pagerenderer->addJS($jQueryNoConflict . "\njQuery(document).ready(function() { {$random_script}\n\tjQuery('#{$this->getContentKey()}-outer').css('display', 'block');\n\tjQuery('#{$this->getContentKey()}').jcarousel(" . (count($options) ? "{\n\t\t" . implode(",\n\t\t", $options) . "\n\t}" : "") . ");{$jQueryCaptify}\n});\n");
     if (is_numeric($this->conf['carouselwidth'])) {
         $this->pagerenderer->addCSS("\n#c{$this->cObj->data['uid']} .jcarousel-clip-horizontal,\n#c{$this->cObj->data['uid']} .jcarousel-container-horizontal {\n\twidth: {$this->conf['carouselwidth']}px;" . ($this->conf['carouselheight'] ? "\n\theight: {$this->conf['carouselheight']}px;" : "") . "\n}\n");
     }
     if (is_numeric($this->conf['carouselheight'])) {
         $this->pagerenderer->addCSS("\n#c{$this->cObj->data['uid']} .jcarousel-clip-vertical,\n#c{$this->cObj->data['uid']} .jcarousel-container-vertical {\n\theight: {$this->conf['carouselheight']}px;" . ($this->conf['carouselwidth'] ? "\n\twidth: {$this->conf['carouselwidth']}px;" : "") . "\n}\n");
     }
     $this->pagerenderer->addCSS("\n#{$this->getContentKey()}-outer {\n\tdisplay: none;\n}\n#c{$this->cObj->data['uid']} .jcarousel-item {\n\twidth: {$css_width};\n\theight: {$css_height};\n}");
     // Add the ressources
     $this->pagerenderer->addResources();
     if ($onlyJS === true) {
         return true;
     }
     $return_string = null;
     $images = null;
     $navigation = null;
     $markerArray = array();
     $GLOBALS['TSFE']->register['key'] = $this->getContentKey();
     $GLOBALS['TSFE']->register['class'] = $skin_class;
     $GLOBALS['TSFE']->register['imagewidth'] = $this->conf['imagewidth'];
     $GLOBALS['TSFE']->register['imageheight'] = $this->conf['imageheight'];
     $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = 0;
     if (count($this->images) > 0) {
         foreach ($this->images as $key => $image_name) {
             $image = null;
             $imgConf = $this->conf['carousel.'][$this->type . '.']['image.'];
             $totalImagePath = $this->imageDir . $image_name;
             $GLOBALS['TSFE']->register['file'] = $totalImagePath;
             $GLOBALS['TSFE']->register['href'] = $this->hrefs[$key];
             $GLOBALS['TSFE']->register['caption'] = $this->captions[$key];
             $GLOBALS['TSFE']->register['description'] = $this->description[$key];
             $GLOBALS['TSFE']->register['CURRENT_ID'] = $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] + 1;
             if ($this->hrefs[$key]) {
                 $imgConf['imageLinkWrap.'] = $imgConf['imageHrefWrap.'];
             }
             $image = $this->cObj->IMAGE($imgConf);
             $images .= $this->cObj->typolink($image, $imgConf['imageLinkWrap.']);
             // create the navigation
             if ($this->conf['externalcontrol']) {
                 $navigation .= trim($this->cObj->cObjGetSingle($this->conf['carousel.'][$this->type . '.']['navigation'], $this->conf['carousel.'][$this->type . '.']['navigation.']));
             }
             $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT']++;
         }
         $markerArray['NAVIGATION'] = $this->cObj->stdWrap($navigation, $this->conf['carousel.'][$this->type . '.']['navigationWrap.']);
         // the stdWrap
         $images = $this->cObj->stdWrap($images, $this->conf['carousel.'][$this->type . '.']['stdWrap.']);
         $return_string = $this->cObj->substituteMarkerArray($images, $markerArray, '###|###', 0);
     }
     return $this->pi_wrapInBaseClass($return_string);
 }
    /**
     * Render list of files.
     *
     * @param	array		List of files. See t3lib_div::getFilesInDir
     * @param	string		$mode EB mode: "db", "file", ...
     * @return	string		HTML output
     */
    function renderFileList($files, $mode = 'file', $act = '')
    {
        global $LANG, $BACK_PATH, $TCA, $TYPO3_CONF_VARS;
        $out = '';
        // sorting selector
        // TODO move to scbase (see tx_dam_list_thumbs too)
        $allFields = tx_dam_db::getFieldListForUser('tx_dam');
        if (is_array($allFields) && count($allFields)) {
            $fieldsSelItems = array();
            foreach ($allFields as $field => $title) {
                $fL = is_array($TCA['tx_dam']['columns'][$field]) ? preg_replace('#:$#', '', $GLOBALS['LANG']->sL($TCA['tx_dam']['columns'][$field]['label'])) : '[' . $field . ']';
                $fieldsSelItems[$field] = t3lib_div::fixed_lgd_cs($fL, 15);
            }
            $sortingSelector = '<label>' . $GLOBALS['LANG']->sL('LLL:EXT:dam/lib/locallang.xml:labelSorting', 1) . '</label> ';
            $sortingSelector .= t3lib_befunc::getFuncMenu($this->addParams, 'SET[txdam_sortField]', $this->damSC->MOD_SETTINGS['txdam_sortField'], $fieldsSelItems);
            if ($this->damSC->MOD_SETTINGS['txdam_sortRev']) {
                $params = (array) $this->addParams + array('SET[txdam_sortRev]' => '0');
                $href = t3lib_div::linkThisScript($params);
                $sortingSelector .= '<button name="SET[txdam_sortRev]" type="button" onclick="self.location.href=\'' . htmlspecialchars($href) . '\'">' . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/pil2up.gif', 'width="12" height="7"') . ' alt="" />' . '</button>';
            } else {
                $params = (array) $this->addParams + array('SET[txdam_sortRev]' => '1');
                $href = t3lib_div::linkThisScript($params);
                $sortingSelector .= '<button name="SET[txdam_sortRev]" type="button" onclick="self.location.href=\'' . htmlspecialchars($href) . '\'">' . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/pil2down.gif', 'width="12" height="7"') . ' alt="" />' . '</button>';
            }
            $sortingSelector = $this->getFormTag('', 'sortingSelector') . $sortingSelector . '</form>';
        }
        $out .= '<div id="medialistfunctions">';
        $out .= $this->getSelectionSelector();
        $out .= $this->getFormTag();
        $out .= $this->damSC->getSearchBox('simple', false, '', true);
        $out .= '</form>';
        $out .= $sortingSelector;
        $out .= '</div>';
        $out .= $this->doc->spacer(10);
        $out .= $this->damSC->getResultInfoBar();
        $out .= $this->doc->spacer(10);
        // Listing the files:
        if (is_array($files) and count($files)) {
            $displayThumbs = $this->displayThumbs();
            $dragdropImage = $mode == 'rte' && ($act == 'dragdrop' || $act == 'media_dragdrop');
            $addAllJS = '';
            $displayItems = '';
            if ($mode == 'rte' && $act == 'media') {
                if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'usedamcolumn') && $this->thisConfig['buttons.']['link.'][$act . '.']['properties.']['title.']['useDAMColumn']) {
                    $displayItems = $this->thisConfig['buttons.']['link.'][$act . '.']['properties.']['title.']['useDAMColumn.']['displayItems'] ? $this->thisConfig['buttons.']['link.'][$act . '.']['properties.']['title.']['useDAMColumn.']['displayItems'] : '';
                }
            }
            // Traverse the file list:
            $lines = array();
            foreach ($files as $fI) {
                if (!$fI['__exists']) {
                    tx_dam::meta_updateStatus($fI);
                    continue;
                }
                // Create file icon:
                $iconFile = tx_dam::icon_getFileType($fI);
                $iconTag = tx_dam_guiFunc::icon_getFileTypeImgTag($fI);
                $iconAndFilename = $iconTag . htmlspecialchars(t3lib_div::fixed_lgd_cs($fI['file_title'], max($GLOBALS['BE_USER']->uc['titleLen'], 120)));
                // Create links for adding the file:
                if (strstr($fI['file_name_absolute'], ',') || strstr($fI['file_name_absolute'], '|')) {
                    // In case an invalid character is in the filepath, display error message:
                    $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |'));
                    $ATag_insert = '<a href="#" onclick="alert(' . $eMsg . ');return false;">';
                    // If filename is OK, just add it:
                } else {
                    // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
                    $onClick_params = implode(', ', array("'" . $fI['_ref_table'] . "'", "'" . $fI['_ref_id'] . "'", "'" . $mode . "'", t3lib_div::quoteJSvalue($fI['file_name']), t3lib_div::quoteJSvalue($fI['_ref_file_path']), "'" . $fI['file_type'] . "'", "'" . $iconFile . "'"));
                    $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($fI);
                    if ($mode === 'rte' and $act === 'media') {
                        $onClick = 'return link_folder(\'' . t3lib_div::rawUrlEncodeFP(tx_dam::file_relativeSitePath($fI['_ref_file_path'])) . '\');';
                        if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'txdam')) {
                            $onClick = 'browse_links_setAdditionalValue(\'txdam\', \'' . $fI['uid'] . '\');' . $onClick;
                        }
                        if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'usedamcolumn') && $this->thisConfig['buttons.']['link.'][$act . '.']['properties.']['title.']['useDAMColumn']) {
                            $damTitle = t3lib_div::quoteJSvalue(tx_dam_guiFunc::meta_compileHoverText($fI, $displayItems, ', '));
                            $onClick = 'if (document.getElementById(\'rtehtmlarea-dam-browse-links-useDAMColumn\') && document.getElementById(\'rtehtmlarea-dam-browse-links-useDAMColumn\').checked) { document.getElementById(\'rtehtmlarea-browse-links-anchor_title\').value = ' . $damTitle . '; }' . $onClick;
                        }
                        $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                    } elseif (!$dragdropImage) {
                        $onClick = 'return insertElement(' . $onClick_params . ');';
                        $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                        $addIcon = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" /></a>';
                        $onClick = 'return insertElement(' . $onClick_params . ', \'\', 1);';
                        $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                        $addAllJS .= $mode === 'rte' ? '' : 'insertElement(' . $onClick_params . '); ';
                    }
                }
                // Create link to showing details about the file in a window:
                if ($fI['__exists']) {
                    $infoOnClick = 'launchView(\'' . t3lib_div::rawUrlEncodeFP($fI['file_name_absolute']) . '\', \'\'); return false;';
                    $ATag_info = '<a href="#" onclick="' . htmlspecialchars($infoOnClick) . '">';
                    $info = $ATag_info . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $LANG->getLL('info', 1) . '" alt="" /> ' . $LANG->getLL('info', 1) . '</a>';
                    $info = '<span class="button">' . $info . '</span>';
                } else {
                    $info = '&nbsp;';
                }
                // Thumbnail/size generation:
                $clickThumb = '';
                if ($displayThumbs and is_file($fI['file_name_absolute']) and tx_dam_image::isPreviewPossible($fI)) {
                    $addAttrib = array();
                    $addAttrib['title'] = tx_dam_guiFunc::meta_compileHoverText($fI);
                    $clickThumb = tx_dam_image::previewImgTag($fI, '', $addAttrib);
                    $clickThumb = '<div class="clickThumb">' . $ATag_insert . $clickThumb . '</a>' . '</div>';
                } elseif ($displayThumbs) {
                    $clickThumb = '<div style="width:68px"></div>';
                }
                // Image for drag & drop replaces the thumbnail
                if ($dragdropImage and t3lib_div::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) and is_file($fI['file_name_absolute'])) {
                    if (t3lib_div::_GP('noLimit')) {
                        $maxW = 10000;
                        $maxH = 10000;
                    } else {
                        $maxW = 380;
                        $maxH = 500;
                    }
                    $IW = $fI['hpixels'];
                    $IH = $fI['vpixels'];
                    if ($IW > $maxW) {
                        $IH = ceil($IH / $IW * $maxW);
                        $IW = $maxW;
                    }
                    if ($IH > $maxH) {
                        $IW = ceil($IW / $IH * $maxH);
                        $IH = $maxH;
                    }
                    $clickThumb = '<img src="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . substr($fI['file_name_absolute'], strlen(PATH_site)) . '" width="' . $IW . '" height="' . $IH . '"' . ($this->defaultClass ? ' class="' . $this->defaultClass . '"' : '') . ' alt="' . $fI['alt_text'] . '" title="' . $fI[$this->imgTitleDAMColumn] . '" txdam="' . $fI['uid'] . '" />';
                    $clickThumb = '<div class="clickThumb2">' . $clickThumb . '</div>';
                }
                // Show element:
                $lines[] = '
					<tr>
						<td valign="middle" class="bgColor4" nowrap="nowrap" style="min-width:20em">' . ($dragdropImage ? '' : $ATag_insert) . $iconAndFilename . '</a>' . '&nbsp;</td>
						<td valign="middle" class="bgColor4" width="1%">' . ($mode == 'rte' ? '' : $addIcon) . '</td>
						<td valign="middle" nowrap="nowrap" width="1%">' . $info . '</td>
					</tr>';
                $infoText = '';
                if ($this->getModSettings('extendedInfo')) {
                    $infoText = tx_dam_guiFunc::meta_compileInfoData($fI, 'file_name, file_size:filesize, _dimensions, caption:truncate:50, instructions', 'table');
                    $infoText = str_replace('<table>', '<table border="0" cellpadding="0" cellspacing="1">', $infoText);
                    $infoText = str_replace('<strong>', '<strong style="font-weight:normal;">', $infoText);
                    $infoText = str_replace('</td><td>', '</td><td class="bgColor-10">', $infoText);
                }
                if ($displayThumbs || $dragdropImage and $infoText) {
                    $lines[] = '
						<tr class="bgColor">
							<td valign="top" colspan="3">
							<table border="0" cellpadding="0" cellspacing="0"><tr>
								<td valign="top">' . $clickThumb . '</td>
								<td valign="top" style="padding-left:1em">' . $infoText . '</td></tr>
							</table>
							<div style="height:0.5em;"></div>
							</td>
						</tr>';
                } elseif ($clickThumb or $infoText) {
                    $lines[] = '
						<tr class="bgColor">
							<td valign="top" colspan="3" style="padding-left:22px">
							' . $clickThumb . $infoText . '
							<div style="height:0.5em;"></div>
							</td>
						</tr>';
                }
                $lines[] = '
						<tr>
							<td colspan="3"><div style="height:0.5em;"></div></td>
						</tr>';
            }
            // Wrap all the rows in table tags:
            $out .= '



		<!--
			File listing
		-->
				<table border="0" cellpadding="1" cellspacing="0" id="typo3-fileList">
					' . implode('', $lines) . '
				</table>';
        }
        if ($addAllJS) {
            $label = $LANG->getLL('eb_addAllToList', true);
            $titleAttrib = ' title="' . $label . '"';
            $onClick = $addAllJS . 'return true;';
            $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
            $addIcon = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />';
            $addAllButton = '<div class="addAllButton"><span class="button"' . $titleAttrib . '>' . $ATag_add . $addIcon . $label . '</a></span></div>';
            $out = $out . $addAllButton;
        }
        $out .= $this->doc->spacer(20);
        $out .= $this->damSC->getResultInfoBar();
        // Return accumulated content for filelisting:
        return $out;
    }
    /**
     * Returns a JavaScript <script> section with some function calls to JavaScript functions from "t3lib/jsfunc.updateform.js" (which is also included by setting a reference in $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'])
     * The JavaScript codes simply transfers content into form fields of a form which is probably used for editing information by frontend users. Used by fe_adminLib.inc.
     *
     * @param	array		Data array which values to load into the form fields from $formName (only field names found in $fieldList)
     * @param	string		The form name
     * @param	string		A prefix for the data array
     * @param	string		The list of fields which are loaded
     * @return	string
     * @access private
     * @see user_feAdmin::displayCreateScreen()
     */
    function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
    {
        $JSPart = '';
        $updateValues = t3lib_div::trimExplode(',', $fieldList);
        foreach ($updateValues as $fKey) {
            $value = $dataArray[$fKey];
            if (is_array($value)) {
                foreach ($value as $Nvalue) {
                    $JSPart .= "\n\tupdateForm('" . $formName . "','" . $arrPrefix . "[" . $fKey . "][]'," . t3lib_div::quoteJSvalue($Nvalue, TRUE) . ");";
                }
            } else {
                $JSPart .= "\n\tupdateForm('" . $formName . "','" . $arrPrefix . "[" . $fKey . "]'," . t3lib_div::quoteJSvalue($value, TRUE) . ");";
            }
        }
        $JSPart = '<script type="text/javascript">
	/*<![CDATA[*/ ' . $JSPart . '
	/*]]>*/
</script>
';
        $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'] = '<script type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 't3lib/jsfunc.updateform.js') . '"></script>';
        return $JSPart;
    }
 /**
  * Creates a list of uploaded files
  *
  * @param	array		$log: ...
  * @return	string		HTML content
  */
 function getUploadedFileList($files)
 {
     global $BACK_PATH, $LANG;
     $content = '';
     // init table layout
     $tableLayout = array('table' => array('<table border="0" cellpadding="1" cellspacing="1" id="typo3-filelist">', '</table>'), 'defRow' => array('tr' => array('<tr>', '</tr>'), 'defCol' => array('<td valign="middle" class="bgColor4">', '</td>'), '990' => array('<td valign="middle" class="bgColor4">', '</td>'), '996' => array('<td valign="middle" class="bgColor5">', '</td>')), '0' => array('tr' => array('<tr class="c-headLine">', '</tr>'), 'defCol' => array('<td valign="middle" class="c-headLine">', '</td>'), '2' => array('<td valign="middle" class="c-headLine" style="width:165px;">', '</td>')));
     $table = array();
     $tr = 0;
     // header
     $td = 0;
     $table[$tr][$td++] = '&nbsp;';
     $table[$tr][$td++] = '&nbsp;';
     $table[$tr][$td++] = $LANG->getLL('c_file');
     $table[$tr][$td++] = $LANG->getLL('c_fileext');
     $table[$tr][$td++] = $LANG->getLL('c_tstamp');
     $table[$tr][$td++] = $LANG->getLL('c_size');
     # $table[$tr][$td++] = $LANG->getLL('c_rw');
     $table[$tr][$td++] = '&nbsp;';
     if (is_object($this->ebObj) && !$this->rteMode) {
         $table[$tr][$td++] = '&nbsp;';
     }
     $addAllJS = '';
     foreach ($files as $item) {
         $tr++;
         $row = $item['meta'];
         $fileIcon = tx_dam::icon_getFileTypeImgTag($row, 'title="' . htmlspecialchars($row['file_type']) . '"');
         // Add row to table
         $td = 0;
         if ($row['uid']) {
             #$table[$tr][$td++] = $this->pObj->doc->icons(-1); // Ok;
             $table[$tr][$td++] = $this->enableBatchProcessing ? '<input type="checkbox" name="process_recs[]" value="' . $row['uid'] . '" />' : '';
             $table[$tr][$td++] = $fileIcon;
             // if upload is called from RTE, allow direct linking by a click on file name
             if ($this->rteMode && is_object($this->ebObj)) {
                 $row = $this->ebObj->enhanceItemArray($row, $this->ebObj->mode);
                 $onClick = 'return link_folder(' . t3lib_div::quoteJSvalue(t3lib_div::rawUrlEncodeFP(tx_dam::file_relativeSitePath($row['_ref_file_path']))) . ');';
                 $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                 $table[$tr][$td++] = $ATag_insert . htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30)) . '</a>';
             } else {
                 $table[$tr][$td++] = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30));
             }
             $table[$tr][$td++] = htmlspecialchars(strtoupper($row['file_type']));
             $table[$tr][$td++] = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['file_ctime']);
             $table[$tr][$td++] = htmlspecialchars(t3lib_div::formatSize($row['file_size']));
             $table[$tr][$td++] = $this->pObj->btn_editRec_inNewWindow('tx_dam', $item['uid']);
             if (is_object($this->ebObj)) {
                 if (intval($row['uid']) && !$this->rteMode) {
                     $row = $this->ebObj->enhanceItemArray($row, $this->ebObj->mode);
                     $iconFile = tx_dam::icon_getFileType($row);
                     $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($row);
                     // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
                     $onClick_params = implode(', ', array("'" . $row['_ref_table'] . "'", "'" . $row['_ref_id'] . "'", "'" . $this->ebObj->mode . "'", t3lib_div::quoteJSvalue($row['file_name']), t3lib_div::quoteJSvalue($row['_ref_file_path']), "'" . $row['file_type'] . "'", "'" . $iconFile . "'"));
                     $onClick = 'return insertElement(' . $onClick_params . ');';
                     $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                     $onClick = 'return insertElement(' . $onClick_params . ', \'\', 1);';
                     $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                     $addAllJS .= 'insertElement(' . $onClick_params . '); ';
                     $table[$tr][$td++] = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" /></a>';
                 } elseif ($this->rteMode) {
                     continue;
                 } else {
                     $table[$tr][$td++] = '';
                 }
             }
         } else {
             // failure
             $table[$tr][$td++] = $this->pObj->doc->icons(2);
             // warning
             $table[$tr][$td++] = $fileIcon;
             $table[$tr][$td++] = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30));
             $table[$tr][$td++] = htmlspecialchars(strtoupper($row['file_type']));
             $table[$tr][$td++] = '';
             $table[$tr][$td++] = '';
             $table[$tr][$td++] = htmlspecialchars($this->getErrorMsgFromItem($item));
         }
     }
     // render table
     if ($tr) {
         $code = '';
         // folder_link expects a form named ltargetform to look for link settings, so we need this if it's called from RTE
         if ($this->rteMode) {
             $code .= '<form action="" name="ltargetform" id="ltargetform"></form>';
         }
         $code .= $this->pObj->doc->table($table, $tableLayout);
         if ($addAllJS) {
             $label = $LANG->getLL('eb_addAllToList', true);
             $titleAttrib = ' title="' . $label . '"';
             $onClick = $addAllJS . 'return true;';
             $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
             $addIcon = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />';
             $addAllButton = '<div style="margin:1em 0 1em 1em;"><span class="button"' . $titleAttrib . '>' . $ATag_add . $addIcon . $label . '</a></span></div>';
             $code = $code . $addAllButton;
         }
     } else {
         $code = false;
     }
     return $code;
 }
Esempio n. 13
0
    /**
     * Sets the startup module from either GETvars module and mpdParams or user configuration.
     *
     * @return	void
     */
    protected function setStartupModule()
    {
        $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
        if (!$startModule) {
            if ($GLOBALS['BE_USER']->uc['startModule']) {
                $startModule = $GLOBALS['BE_USER']->uc['startModule'];
            } else {
                if ($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
                    $startModule = 'user_task';
                }
            }
        }
        $moduleParameters = t3lib_div::_GET('modParams');
        if ($startModule) {
            return '
					// start in module:
				top.startInModule = [\'' . $startModule . '\', ' . t3lib_div::quoteJSvalue($moduleParameters) . '];
			';
        } else {
            return '';
        }
    }
 /**
  * Rendering the cObject, FORM
  *
  * Note on $formData:
  * In the optional $formData array each entry represents a line in the ordinary setup.
  * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
  *
  * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
  * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
  *
  * - corresponds to the $conf['data'] value being :
  * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
  *
  * If $formData is an array the value of $conf['data'] is ignored.
  *
  * @param	array		Array of TypoScript properties
  * @param	array		Alternative formdata overriding whatever comes from TypoScript
  * @return	string		Output
  */
 public function render($conf = array(), $formData = '')
 {
     $content = '';
     if (is_array($formData)) {
         $dataArray = $formData;
     } else {
         $data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
         // Clearing dataArr
         $dataArray = array();
         // Getting the original config
         if (trim($data)) {
             $data = str_replace(LF, '||', $data);
             $dataArray = explode('||', $data);
         }
         // Adding the new dataArray config form:
         if (is_array($conf['dataArray.'])) {
             // dataArray is supplied
             $sortedKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
             foreach ($sortedKeyArray as $theKey) {
                 $singleKeyArray = $conf['dataArray.'][$theKey . '.'];
                 if (is_array($singleKeyArray)) {
                     $temp = array();
                     $label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
                     list($temp[0]) = explode('|', $label);
                     $type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
                     list($temp[1]) = explode('|', $type);
                     $required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
                     if ($required) {
                         $temp[1] = '*' . $temp[1];
                     }
                     $singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
                     list($temp[2]) = explode('|', $singleValue);
                     // If value array is set, then implode those values.
                     if (is_array($singleKeyArray['valueArray.'])) {
                         $temp_accumulated = array();
                         foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
                             if (is_array($singleKey_valueArray) && !strcmp(intval($singleKey) . '.', $singleKey)) {
                                 $temp_valueArray = array();
                                 $valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
                                 list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
                                 $selected = isset($singleKeyArray['selected.']) ? $this->cObj->stdWrap($singleKeyArray['selected'], $singleKeyArray['selected.']) : $singleKeyArray['selected'];
                                 if ($selected) {
                                     $temp_valueArray[0] = '*' . $temp_valueArray[0];
                                 }
                                 $singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
                                 list($temp_valueArray[1]) = explode(',', $singleKeyValue);
                             }
                             $temp_accumulated[] = implode('=', $temp_valueArray);
                         }
                         $temp[2] = implode(',', $temp_accumulated);
                     }
                     $specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
                     list($temp[3]) = explode('|', $specialEval);
                     // adding the form entry to the dataArray
                     $dataArray[] = implode('|', $temp);
                 }
             }
         }
     }
     $attachmentCounter = '';
     $hiddenfields = '';
     $fieldlist = array();
     $propertyOverride = array();
     $fieldname_hashArray = array();
     $counter = 0;
     $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
     // Formname
     $formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
     if ($formName) {
         $formName = $this->cObj->cleanFormName($formName);
     } else {
         $formName = 'a' . $GLOBALS['TSFE']->uniqueHash();
         // form name has to start with a letter to reach XHTML compliance
     }
     $fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
     if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
         if ($fieldPrefix) {
             $prefix = $this->cObj->cleanFormName($fieldPrefix);
         } else {
             $prefix = '';
         }
     } else {
         $prefix = $formName;
     }
     foreach ($dataArray as $dataValue) {
         $counter++;
         $confData = array();
         if (is_array($formData)) {
             $parts = $dataValue;
             $dataValue = 1;
             // TRUE...
         } else {
             $dataValue = trim($dataValue);
             $parts = explode('|', $dataValue);
         }
         if ($dataValue && strcspn($dataValue, '#/')) {
             // label:
             $confData['label'] = t3lib_div::removeXSS(trim($parts[0]));
             // field:
             $fParts = explode(',', $parts[1]);
             $fParts[0] = trim($fParts[0]);
             if (substr($fParts[0], 0, 1) == '*') {
                 $confData['required'] = 1;
                 $fParts[0] = substr($fParts[0], 1);
             }
             $typeParts = explode('=', $fParts[0]);
             $confData['type'] = trim(strtolower(end($typeParts)));
             if (count($typeParts) == 1) {
                 $confData['fieldname'] = $this->cObj->cleanFormName($parts[0]);
                 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
                     $confData['fieldname'] = 'email';
                 }
                 // Duplicate fieldnames resolved
                 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
                     $confData['fieldname'] .= '_' . $counter;
                 }
                 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
                 // Attachment names...
                 if ($confData['type'] == 'file') {
                     $confData['fieldname'] = 'attachment' . $attachmentCounter;
                     $attachmentCounter = intval($attachmentCounter) + 1;
                 }
             } else {
                 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
             }
             $confData['fieldname'] = htmlspecialchars($confData['fieldname']);
             $fieldCode = '';
             $wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
             if ($wrapFieldName) {
                 $confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
             }
             // Set field name as current:
             $this->cObj->setCurrentVal($confData['fieldname']);
             // Additional parameters
             if (trim($confData['type'])) {
                 if (isset($conf['params.'][$confData['type']])) {
                     $addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
                 } else {
                     $addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
                 }
                 if (strcmp('', $addParams)) {
                     $addParams = ' ' . $addParams;
                 }
             } else {
                 $addParams = '';
             }
             $dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
             if ($dontMd5FieldNames) {
                 $fName = $confData['fieldname'];
             } else {
                 $fName = md5($confData['fieldname']);
             }
             // Accessibility: Set id = fieldname attribute:
             $accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
             if ($accessibility || $xhtmlStrict) {
                 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
             } else {
                 $elementIdAttribute = '';
             }
             // Create form field based on configuration/type:
             switch ($confData['type']) {
                 case 'textarea':
                     $cols = trim($fParts[1]) ? intval($fParts[1]) : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $cols = t3lib_div::intInRange($cols * $compWidth, 1, 120);
                     $rows = trim($fParts[2]) ? t3lib_div::intInRange($fParts[2], 1, 30) : 5;
                     $wrap = trim($fParts[3]);
                     $noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
                     if ($noWrapAttr || $wrap === 'disabled') {
                         $wrap = '';
                     } else {
                         $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
                     }
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
                     $fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, t3lib_div::formatForTextarea($default));
                     break;
                 case 'input':
                 case 'password':
                     $size = trim($fParts[1]) ? intval($fParts[1]) : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $size = t3lib_div::intInRange($size * $compWidth, 1, 120);
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     if ($confData['type'] == 'password') {
                         $default = '';
                     }
                     $max = trim($fParts[2]) ? ' maxlength="' . t3lib_div::intInRange($fParts[2], 1, 1000) . '"' : "";
                     $theType = $confData['type'] == 'input' ? 'text' : 'password';
                     $fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
                     break;
                 case 'file':
                     $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 60) : 20;
                     $fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
                     break;
                 case 'check':
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     $checked = $default ? ' checked="checked"' : '';
                     $fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
                     break;
                 case 'select':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // size
                     if (strtolower(trim($fParts[1])) == 'auto') {
                         $fParts[1] = count($valueParts);
                     }
                     // Auto size set here. Max 20
                     $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 20) : 1;
                     // multiple
                     $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
                     $items = array();
                     // Where the items will be
                     $defaults = array();
                     //RTF
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if (substr($valueParts[$a], 0, 1) == '*') {
                             // Finding default value
                             $sel = 'selected';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Sets the value
                         $items[] = $subParts;
                         // Adds the value/label pair to the items-array
                         if ($sel) {
                             $defaults[] = $subParts[1];
                         }
                         // Sets the default value if value/label pair is marked as default.
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
                     if (!is_array($default)) {
                         $defaults = array();
                         $defaults[] = $default;
                     } else {
                         $defaults = $default;
                     }
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>';
                         //RTF
                     }
                     if ($multiple) {
                         // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
                         $confData['fieldname'] .= '[]';
                     }
                     $fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
                     //RTF
                     break;
                 case 'radio':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     $items = array();
                     // Where the items will be
                     $default = '';
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if (substr($valueParts[$a], 0, 1) == '*') {
                             $sel = 'checked';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Sets the value
                         $items[] = $subParts;
                         // Adds the value/label pair to the items-array
                         if ($sel) {
                             $default = $subParts[1];
                         }
                         // Sets the default value if value/label pair is marked as default.
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $optionParts = '';
                         $radioId = $prefix . $fName . $this->cObj->cleanFormName($items[$a][0]);
                         if ($accessibility) {
                             $radioLabelIdAttribute = ' id="' . $radioId . '"';
                         } else {
                             $radioLabelIdAttribute = '';
                         }
                         $optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . (!strcmp($items[$a][1], $default) ? ' checked="checked"' : '') . $addParams . ' />';
                         if ($accessibility) {
                             $label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                             $optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
                         } else {
                             $optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                         }
                         $option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
                     }
                     if ($accessibility) {
                         $accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap.'];
                         if ($accessibilityWrap) {
                             $search = array('###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###');
                             $replace = array($elementIdAttribute, $confData['label']);
                             $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
                             $option = $this->cObj->wrap($option, $accessibilityWrap);
                         }
                     }
                     $fieldCode = $option;
                     break;
                 case 'hidden':
                     $value = trim($parts[2]);
                     // If this form includes an auto responder message, include a HMAC checksum field
                     // in order to verify potential abuse of this feature.
                     if (strlen($value) && t3lib_div::inList($confData['fieldname'], 'auto_respond_msg')) {
                         $hmacChecksum = t3lib_div::hmac($value);
                         $hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
                     }
                     if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         break;
                     }
                     if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname'])) {
                         $value = $GLOBALS['TSFE']->codeString($value);
                     }
                     $hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
                     break;
                 case 'property':
                     if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
                         $value = trim($parts[2]);
                         $propertyOverride[$confData['fieldname']] = $value;
                         $conf[$confData['fieldname']] = $value;
                     }
                     break;
                 case 'submit':
                     $value = trim($parts[2]);
                     if ($conf['image.']) {
                         $this->cObj->data[$this->cObj->currentValKey] = $value;
                         $image = $this->cObj->IMG_RESOURCE($conf['image.']);
                         $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
                         $params .= $this->cObj->getAltParam($conf['image.'], FALSE);
                         $params .= $addParams;
                     } else {
                         $image = '';
                     }
                     if ($image) {
                         $fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
                     } else {
                         $fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
                     }
                     break;
                 case 'reset':
                     $value = trim($parts[2]);
                     $fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
                     break;
                 case 'label':
                     $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
                     break;
                 default:
                     $confData['type'] = 'comment';
                     $fieldCode = trim($parts[2]) . '&nbsp;';
                     break;
             }
             if ($fieldCode) {
                 // Checking for special evaluation modes:
                 if (t3lib_div::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
                     $modeParameters = t3lib_div::trimExplode(':', $parts[3]);
                 } else {
                     $modeParameters = array();
                 }
                 // Adding evaluation based on settings:
                 switch ((string) $modeParameters[0]) {
                     case 'EREG':
                         $fieldlist[] = '_EREG';
                         $fieldlist[] = $modeParameters[1];
                         $fieldlist[] = $modeParameters[2];
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         $confData['required'] = 1;
                         // Setting this so "required" layout is used.
                         break;
                     case 'EMAIL':
                         $fieldlist[] = '_EMAIL';
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         $confData['required'] = 1;
                         // Setting this so "required" layout is used.
                         break;
                     default:
                         if ($confData['required']) {
                             $fieldlist[] = $confData['fieldname'];
                             $fieldlist[] = $confData['label'];
                         }
                         break;
                 }
                 // Field:
                 $fieldLabel = $confData['label'];
                 if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
                     $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
                 }
                 // Getting template code:
                 if (isset($conf['fieldWrap.'])) {
                     $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
                 }
                 $labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
                 $commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
                 $result = $conf['layout'];
                 $req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
                 if ($req && $confData['required']) {
                     if (isset($conf['REQ.']['fieldWrap.'])) {
                         $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
                     }
                     if (isset($conf['REQ.']['labelWrap.'])) {
                         $labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
                     }
                     $reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
                     if ($reqLayout) {
                         $result = $reqLayout;
                     }
                 }
                 if ($confData['type'] == 'comment') {
                     $commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
                     if ($commentLayout) {
                         $result = $commentLayout;
                     }
                 }
                 if ($confData['type'] == 'check') {
                     $checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($checkLayout) {
                         $result = $checkLayout;
                     }
                 }
                 if ($confData['type'] == 'radio') {
                     $radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
                     if ($radioLayout) {
                         $result = $radioLayout;
                     }
                 }
                 if ($confData['type'] == 'label') {
                     $labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($labelLayout) {
                         $result = $labelLayout;
                     }
                 }
                 $result = str_replace('###FIELD###', $fieldCode, $result);
                 $result = str_replace('###LABEL###', $labelCode, $result);
                 $result = str_replace('###COMMENT###', $commentCode, $result);
                 //RTF
                 $content .= $result;
             }
         }
     }
     if (isset($conf['stdWrap.'])) {
         $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
     // redirect (external: where to go afterwards. internal: where to submit to)
     $theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $page = $GLOBALS['TSFE']->page;
     if (!$theRedirect) {
         // Internal: Just submit to current page
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } elseif (t3lib_div::testInt($theRedirect)) {
         // Internal: Submit to page with ID $theRedirect
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } else {
         // External URL, redirect-hidden field is rendered!
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $LD['totalURL'] = $theRedirect;
         $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
         // 18-09-00 added
     }
     // Formtype (where to submit to!):
     if ($propertyOverride['type']) {
         $formtype = $propertyOverride['type'];
     } else {
         $formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
     }
     if (t3lib_div::testInt($formtype)) {
         // Submit to a specific page
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     } elseif ($formtype) {
         // Submit to external script
         $LD_A = $LD;
         $action = $formtype;
     } elseif (t3lib_div::testInt($theRedirect)) {
         $LD_A = $LD;
         $action = $LD_A['totalURL'];
     } else {
         // Submit to "nothing" - which is current page
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     }
     // Recipient:
     $theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
     if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
         $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
         $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
     }
     // location data:
     $location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
     if ($location) {
         if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
             $locationData = t3lib_div::_POST('locationData');
         } else {
             // locationData is [hte page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
             $locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
         }
         $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
     }
     // hidden fields:
     if (is_array($conf['hiddenFields.'])) {
         foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
             if (substr($hF_key, -1) != '.') {
                 $hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
                 if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient', $hF_key)) {
                     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         continue;
                     }
                     $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
                 }
                 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
             }
         }
     }
     // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
     $hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
     if ($conf['REQ']) {
         $goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
         $badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
         $emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
         $validateForm = ' onsubmit="return validateForm(\'' . $formName . '\',\'' . implode(',', $fieldlist) . '\',' . t3lib_div::quoteJSvalue($goodMess) . ',' . t3lib_div::quoteJSvalue($badMess) . ',' . t3lib_div::quoteJSvalue($emailMess) . ')"';
         $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 't3lib/jsfunc.validateform.js') . '"></script>';
     } else {
         $validateForm = '';
     }
     // Create form tag:
     $theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
     $method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
     $content = array('<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>', $hiddenfields . $content, '</form>');
     $arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
     if ($arrayReturnMode) {
         $content['validateForm'] = $validateForm;
         $content['formname'] = $formName;
         return $content;
     } else {
         return implode('', $content);
     }
 }
    function imageInsertJS($url, $width, $height, $altText, $titleText, $origFile)
    {
        global $TYPO3_CONF_VARS;
        echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Untitled</title>
</head>
<script type="text/javascript">
/*<![CDATA[*/
	var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Image");
	function insertImage(file,width,height,alt,title)	{
		plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass ? ' class="' . $this->defaultClass . '"' : '') . ' alt="\'+alt+\'" title="\'+title+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
	}
/*]]>*/
</script>
<body>
<script type="text/javascript">
/*<![CDATA[*/
	insertImage(' . t3lib_div::quoteJSvalue($url, 1) . ',' . $width . ',' . $height . ',' . t3lib_div::quoteJSvalue($altText, 1) . ',' . t3lib_div::quoteJSvalue($titleText, 1) . ');
/*]]>*/
</script>
</body>
</html>';
    }
 /**
  * For TYPO3 Element Browser: This lists all content elements from the given list of tables
  *
  * @param	string		Commalist of tables. Set to "*" if you want all tables.
  * @return	string		HTML output.
  */
 function TBE_expandPage($tables)
 {
     global $TCA, $BE_USER, $BACK_PATH;
     $out = '';
     if ($this->expandPage >= 0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
         // Set array with table names to list:
         if (!strcmp(trim($tables), '*')) {
             $tablesArr = array_keys($TCA);
         } else {
             $tablesArr = t3lib_div::trimExplode(',', $tables, 1);
         }
         reset($tablesArr);
         // Headline for selecting records:
         $out .= $this->barheader($GLOBALS['LANG']->getLL('selectRecords') . ':');
         // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
         $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages', $this->expandPage);
         $ATag = '';
         $ATag_e = '';
         $ATag2 = '';
         if (in_array('pages', $tablesArr)) {
             $ficon = t3lib_iconWorks::getIcon('pages', $mainPageRec);
             $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] . "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '" . $ficon . "','',1);\">";
             $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] . "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '" . $ficon . "','',0);\">";
             $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
             $ATag_e = '</a>';
         }
         $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
         $pBicon = $ATag2 ? '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '';
         $pText = htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'], $titleLen));
         $out .= $picon . $ATag2 . $pBicon . $ATag_e . $ATag . $pText . $ATag_e . '<br />';
         // Initialize the record listing:
         $id = $this->expandPage;
         $pointer = t3lib_div::intInRange($this->pointer, 0, 100000);
         $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
         $pageinfo = t3lib_BEfunc::readPageAccess($id, $perms_clause);
         $table = '';
         // Generate the record list:
         $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
         $dblist->thisScript = $this->thisScript;
         $dblist->backPath = $GLOBALS['BACK_PATH'];
         $dblist->thumbs = 0;
         $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
         $dblist->noControlPanels = 1;
         $dblist->clickMenuEnabled = 0;
         $dblist->tableList = implode(',', $tablesArr);
         $dblist->start($id, t3lib_div::_GP('table'), $pointer, t3lib_div::_GP('search_field'), t3lib_div::_GP('search_levels'), t3lib_div::_GP('showLimit'));
         $dblist->setDispFields();
         $dblist->generateList();
         $dblist->writeBottom();
         //	Add the HTML for the record list to output variable:
         $out .= $dblist->HTMLcode;
         // Add support for fieldselectbox in singleTableMode
         if ($dblist->table) {
             $out .= $dblist->fieldSelectBox($dblist->table);
         }
         $out .= $dblist->getSearchBox();
     }
     // Return accumulated content:
     return $out;
 }
 /**
  * Return a errormessage if needed
  * @param string $msg
  * @param boolean $js
  * @return string
  */
 public function outputError($msg = '', $js = FALSE)
 {
     t3lib_div::devLog($msg, $this->extKey, 3);
     if ($this->confArr['frontendErrorMsg'] || !isset($this->confArr['frontendErrorMsg'])) {
         return $js ? "alert(" . t3lib_div::quoteJSvalue($msg) . ")" : "<p>{$msg}</p>";
     } else {
         return NULL;
     }
 }
 /**
  * @test
  */
 public function quoteJSvalueEscapesBackslah()
 {
     $this->assertEquals("'\\\\'", t3lib_div::quoteJSvalue('\\'));
 }
Esempio n. 19
0
    /**
     * Sets the startup module from either GETvars module and mpdParams or user configuration.
     *
     * @return	void
     */
    protected function setStartupModule()
    {
        $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
        if (!$startModule) {
            if ($GLOBALS['BE_USER']->uc['startModule']) {
                $startModule = $GLOBALS['BE_USER']->uc['startModule'];
            } else {
                if ($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
                    $startModule = 'user_task';
                }
            }
        }
        $moduleParameters = t3lib_div::_GET('modParams');
        if ($startModule) {
            $this->pageRenderer->addExtOnReadyCode('
			// start in module:
		function startInModule(modName, cMR_flag, addGetVars)	{
			Ext.onReady(function() {
				top.goToModule(modName, cMR_flag, addGetVars);
			});
		}

		startInModule(\'' . $startModule . '\', false, ' . t3lib_div::quoteJSvalue($moduleParameters) . ');
			');
        }
    }