Feature #17822 » tabbedmenupatch.patch
typo3/template.php (working copy) | ||
---|---|---|
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* Contains class with layout/output function for TYPO3 Backend Scripts
|
||
*
|
||
* $Id$
|
||
* $Id: template.php 2592 2007-10-20 18:26:12Z ingmars $
|
||
* Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
|
||
* XHTML-trans compliant
|
||
*
|
||
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
|
||
*/
|
||
/**
|
||
... | ... | |
* 894: function docStyle()
|
||
* 936: function insertStylesAndJS($content)
|
||
* 956: function initCharset()
|
||
* 968: function generator()
|
||
*
|
||
* SECTION: OTHER ELEMENTS
|
||
* 1001: function icons($type, $styleAttribValue='')
|
||
* 1030: function t3Button($onClick,$label)
|
||
* 1041: function dfw($string)
|
||
* 1051: function rfw($string)
|
||
* 1061: function wrapInCData($string)
|
||
* 1078: function wrapScriptTags($string, $linebreak=TRUE)
|
||
* 1117: function table($arr, $layout='')
|
||
... | ... | |
* 1472: function getDragDropCode($table)
|
||
* 1483: function cancelDragEvent(event)
|
||
* 1496: function mouseMoveEvent (event)
|
||
* 1509: function dragElement(id,elementID)
|
||
* 1528: function dropElement(id)
|
||
* 1577: function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
|
||
* 1607: function getTabMenuRaw($menuItems)
|
||
* 1676: function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)
|
||
* 1801: function getDynTabMenuJScode()
|
||
* 1892: function getVersionSelector($id,$noAction=FALSE)
|
||
*
|
||
*
|
||
* 2060: class bigDoc extends template
|
||
... | ... | |
*
|
||
* 2078: class smallDoc extends template
|
||
*
|
||
*
|
||
* 2087: class mediumDoc extends template
|
||
*
|
||
* TOTAL FUNCTIONS: 57
|
||
* TOTAL FUNCTIONS: 55
|
||
* (This index is automatically created/updated by the extension "extdeveval")
|
||
*
|
||
*/
|
||
|
||
|
||
|
||
if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
|
||
|
||
require_once(PATH_t3lib.'class.t3lib_ajax.php');
|
||
require_once(PATH_t3lib.'class.t3lib_iconworks.php');
|
||
require_once(PATH_t3lib.'class.t3lib_tabmenus.php');
|
||
|
||
|
||
|
||
|
||
|
||
|
||
... | ... | |
* @subpackage core
|
||
*/
|
||
class template {
|
||
|
||
// Vars you typically might want to/should set from outside after making instance of this class:
|
||
var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
|
||
var $form=''; // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
|
||
var $form=''; // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
|
||
var $JScodeLibArray = array(); // Similar to $JScode (see below) but used as an associative array to prevent double inclusion of JS code. This is used to include certain external Javascript libraries before the inline JS code. <script>-Tags are not wrapped around automatically
|
||
var $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
|
||
var $JScodeArray = array(); // Similar to $JScode but for use as array with associative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
|
||
var $postCode=''; // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
|
||
var $docType = ''; // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
|
||
|
||
... | ... | |
*/
|
||
function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
|
||
$backPath=$this->backPath;
|
||
$storeUrl=$this->makeShortcutUrl($gvList,$setList);
|
||
$pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
|
||
|
||
// Add the module identifier automatically if typo3/mod.php is used:
|
||
if (ereg('typo3/mod\.php$', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
|
||
$storeUrl = '&M='.$modName.$storeUrl;
|
||
}
|
||
|
||
// Add the module identifier automatically if typo3/mod.php is used:
|
||
if (ereg('typo3/mod\.php$', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
|
||
$storeUrl = '&M='.$modName.$storeUrl;
|
||
}
|
||
|
||
if (!strcmp($motherModName,'1')) {
|
||
$mMN="&motherModName='+top.currentModuleLoaded+'";
|
||
} elseif ($motherModName) {
|
||
$mMN='&motherModName='.rawurlencode($motherModName);
|
||
} else $mMN='';
|
||
|
||
... | ... | |
function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
|
||
$str='';
|
||
|
||
// Setting header
|
||
if ($label) {
|
||
if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
|
||
$str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
|
||
$str.=$this->sectionHeader(t3lib_iconworks::icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"',$this->backPath);
|
||
}
|
||
// Setting content
|
||
$str.='
|
||
|
||
<!-- Section content -->
|
||
'.$text;
|
||
... | ... | |
* OTHER ELEMENTS
|
||
* Tables, buttons, formatting dimmed/red strings
|
||
*
|
||
******************************************/
|
||
|
||
|
||
/**
|
||
* Returns an image-tag with an 18x16 icon of the following types:
|
||
*
|
||
* $type:
|
||
* -1: OK icon (Check-mark)
|
||
* 1: Notice (Speach-bubble)
|
||
* 2: Warning (Yellow triangle)
|
||
* 3: Fatal error (Red stop sign)
|
||
*
|
||
* @param integer See description
|
||
* @param string Value for style attribute
|
||
* @return string HTML image tag (if applicable)
|
||
*/
|
||
function icons($type, $styleAttribValue='') {
|
||
switch($type) {
|
||
case '3':
|
||
$icon = 'gfx/icon_fatalerror.gif';
|
||
break;
|
||
case '2':
|
||
$icon = 'gfx/icon_warning.gif';
|
||
break;
|
||
case '1':
|
||
$icon = 'gfx/icon_note.gif';
|
||
break;
|
||
case '-1':
|
||
$icon = 'gfx/icon_ok.gif';
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if ($icon) {
|
||
return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Returns an <input> button with the $onClick action and $label
|
||
*
|
||
* @param string The value of the onclick attribute of the input tag (submit type)
|
||
* @param string The label for the button (which will be htmlspecialchar'ed)
|
||
... | ... | |
* @param string $script is the script to send the &id to, if empty it's automatically found
|
||
* @param string $addParams is additional parameters to pass to the script.
|
||
* @return string HTML code for tab menu
|
||
* @author Rene Fritz <r.fritz@colorcube.de>
|
||
*/
|
||
function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
|
||
$content='';
|
||
t3lib_tabMenus::getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script,$addparams);
|
||
|
||
if (is_array($menuItems)) {
|
||
if (!is_array($mainParams)) {
|
||
$mainParams = array('id' => $mainParams);
|
||
}
|
||
$mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
|
||
|
||
if (!$script) {$script=basename(PATH_thisScript);}
|
||
|
||
$menuDef = array();
|
||
foreach($menuItems as $value => $label) {
|
||
$menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
|
||
$menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
|
||
$menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
|
||
}
|
||
$content = $this->getTabMenuRaw($menuDef);
|
||
|
||
}
|
||
return $content;
|
||
}
|
||
|
||
/**
|
||
* Creates the HTML content for the tab menu
|
||
*
|
||
* @param array Menu items for tabs
|
||
* @return string Table HTML
|
||
* @access private
|
||
*/
|
||
function getTabMenuRaw($menuItems) {
|
||
$content='';
|
||
|
||
if (is_array($menuItems)) {
|
||
$options='';
|
||
|
||
$count = count($menuItems);
|
||
$widthLeft = 1;
|
||
$addToAct = 5;
|
||
|
||
$widthRight = max (1,floor(30-pow($count,1.72)));
|
||
$widthTabs = 100 - $widthRight - $widthLeft;
|
||
$widthNo = floor(($widthTabs - $addToAct)/$count);
|
||
$addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
|
||
$widthAct = $widthNo + $addToAct;
|
||
$widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
|
||
|
||
$first=true;
|
||
foreach($menuItems as $id => $def) {
|
||
$isActive = $def['isActive'];
|
||
$class = $isActive ? 'tabact' : 'tab';
|
||
$width = $isActive ? $widthAct : $widthNo;
|
||
|
||
// @rene: Here you should probably wrap $label and $url in htmlspecialchars() in order to make sure its XHTML compatible! I did it for $url already since that is VERY likely to break.
|
||
$label = $def['label'];
|
||
$url = htmlspecialchars($def['url']);
|
||
$params = $def['addParams'];
|
||
|
||
if($first) {
|
||
$options.= '
|
||
<td width="'.$width.'%" class="'.$class.'" style="border-left: solid #000 1px;"><a href="'.$url.'" style="padding-left:5px;padding-right:2px;" '.$params.'>'.$label.'</a></td>';
|
||
} else {
|
||
$options.='
|
||
<td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
|
||
}
|
||
$first=false;
|
||
}
|
||
|
||
if ($options) {
|
||
$content .= '
|
||
<!-- Tab menu -->
|
||
<table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
|
||
<tr>
|
||
<td width="'.$widthLeft.'%"> </td>
|
||
'.$options.'
|
||
<td width="'.$widthRight.'%"> </td>
|
||
</tr>
|
||
</table>
|
||
<div class="hr" style="margin:0px"></div>';
|
||
}
|
||
|
||
}
|
||
return $content;
|
||
}
|
||
|
||
/**
|
||
* Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
|
||
* Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: <textarea> fields loose their content when you switch tabs!
|
||
*
|
||
... | ... | |
* @param boolean If set, the tabs will span the full width of their position
|
||
* @param integer Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
|
||
* @param boolean If set to '1' empty tabs will be remove, If set to '2' empty tabs will be disabled
|
||
* @return string JavaScript section for the HTML header.
|
||
*/
|
||
function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1,$dividers2tabs=1) {
|
||
$content = '';
|
||
t3lib_tabMenus::getDynTabMenu($menuItems,$identString,$toggle,$foldout,$newRowCharLimit,$noWrap,$fullWidth,$defaultTabIndex,$dividers2tabs);
|
||
|
||
if (is_array($menuItems)) {
|
||
|
||
// Init:
|
||
$options = array(array());
|
||
$divs = array();
|
||
$JSinit = array();
|
||
$id = $this->getDynTabMenuId($identString);
|
||
$noWrap = $noWrap ? ' nowrap="nowrap"' : '';
|
||
|
||
// Traverse menu items
|
||
$c=0;
|
||
$tabRows=0;
|
||
$titleLenCount = 0;
|
||
foreach($menuItems as $index => $def) {
|
||
$index+=1; // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
|
||
|
||
// Switch to next tab row if needed
|
||
if (!$foldout && ($titleLenCount>$newRowCharLimit | ($def['newline'] === true && $titleLenCount > 0))) {
|
||
$titleLenCount=0;
|
||
$tabRows++;
|
||
$options[$tabRows] = array();
|
||
}
|
||
|
||
if ($toggle==1) {
|
||
$onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
|
||
} else {
|
||
$onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
|
||
}
|
||
|
||
$isNotEmpty = strcmp(trim($def['content']),'');
|
||
|
||
// "Removes" empty tabs
|
||
if (!$isNotEmpty && $dividers2tabs == 1) {
|
||
continue;
|
||
}
|
||
|
||
$mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
|
||
|
||
if (!$foldout) {
|
||
// Create TAB cell:
|
||
$options[$tabRows][] = '
|
||
<td class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
|
||
($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
|
||
$def['icon'].
|
||
($def['label'] ? htmlspecialchars($def['label']) : ' ').
|
||
$this->icons($def['stateIcon'],'margin-left: 10px;').
|
||
($isNotEmpty ? '</a>' :'').
|
||
'</td>';
|
||
$titleLenCount+= strlen($def['label']);
|
||
} else {
|
||
// Create DIV layer for content:
|
||
$divs[] = '
|
||
<div class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
|
||
($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
|
||
$def['icon'].
|
||
($def['label'] ? htmlspecialchars($def['label']) : ' ').
|
||
($isNotEmpty ? '</a>' : '').
|
||
'</div>';
|
||
}
|
||
|
||
// Create DIV layer for content:
|
||
$divs[] = '
|
||
<div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
|
||
($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
|
||
$def['content'].
|
||
'</div>';
|
||
// Create initialization string:
|
||
$JSinit[] = '
|
||
DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
|
||
';
|
||
if ($toggle==1) {
|
||
$JSinit[] = '
|
||
if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
|
||
';
|
||
}
|
||
|
||
$c++;
|
||
}
|
||
|
||
// Render menu:
|
||
if (count($options)) {
|
||
|
||
// Tab menu is compiled:
|
||
if (!$foldout) {
|
||
$tabContent = '';
|
||
for($a=0;$a<=$tabRows;$a++) {
|
||
$tabContent.= '
|
||
|
||
<!-- Tab menu -->
|
||
<table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
|
||
<tr>
|
||
'.implode('',$options[$a]).'
|
||
</tr>
|
||
</table>';
|
||
}
|
||
$content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
|
||
}
|
||
|
||
// Div layers are added:
|
||
$content.= '
|
||
<!-- Div layers for tab menu: -->
|
||
<div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
|
||
'.implode('',$divs).'</div>';
|
||
|
||
// Java Script section added:
|
||
$content.= '
|
||
<!-- Initialization JavaScript for the menu -->
|
||
<script type="text/javascript">
|
||
DTM_array["'.$id.'"] = new Array();
|
||
'.implode('',$JSinit).'
|
||
'.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
|
||
</script>
|
||
|
||
';
|
||
}
|
||
|
||
}
|
||
return $content;
|
||
}
|
||
|
||
/**
|
||
* Creates the id for dynTabMenus.
|
||
*
|
||
* @param string $identString: Identification string. This should be unique for every instance of a dynamic menu!
|
||
* @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a"
|
||
*/
|
||
function getDynTabMenuId($identString) {
|
||
$id = 'DTM-'.t3lib_div::shortMD5($identString);
|
||
return $id;
|
||
}
|
||
|
||
/**
|
||
* Returns dynamic tab menu header JS code.
|
||
*
|
||
* @return string JavaScript section for the HTML header.
|
||
*/
|
||
function getDynTabMenuJScode() {
|
||
return '
|
||
<script type="text/javascript">
|
||
/*<![CDATA[*/
|
||
var DTM_array = new Array();
|
||
var DTM_origClass = new String();
|
||
return '<script type="text/javascript" src="'.t3lib_div::getIndpEnv('TYPO3_SITE_URL').PATH_t3lib.'js/dyntabmenu.js"></script>';
|
||
|
||
// if tabs are used in a popup window the array might not exists
|
||
if(!top.DTM_currentTabs) {
|
||
top.DTM_currentTabs = new Array();
|
||
}
|
||
|
||
function DTM_activate(idBase,index,doToogle) { //
|
||
// Hiding all:
|
||
if (DTM_array[idBase]) {
|
||
for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
|
||
if (DTM_array[idBase][cnt] != idBase+"-"+index) {
|
||
document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
|
||
// Only Overriding when Tab not disabled
|
||
if (document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue != "disabled") {
|
||
document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Showing one:
|
||
if (document.getElementById(idBase+"-"+index+"-DIV")) {
|
||
if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
|
||
document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
|
||
if(DTM_origClass=="") {
|
||
document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
|
||
} else {
|
||
DTM_origClass = "tab";
|
||
}
|
||
top.DTM_currentTabs[idBase] = -1;
|
||
} else {
|
||
document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
|
||
if(DTM_origClass=="") {
|
||
document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
|
||
} else {
|
||
DTM_origClass = "tabact";
|
||
}
|
||
top.DTM_currentTabs[idBase] = index;
|
||
}
|
||
}
|
||
}
|
||
function DTM_toggle(idBase,index,isInit) { //
|
||
// Showing one:
|
||
if (document.getElementById(idBase+"-"+index+"-DIV")) {
|
||
if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
|
||
document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
|
||
if(isInit) {
|
||
document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
|
||
} else {
|
||
DTM_origClass = "tab";
|
||
}
|
||
top.DTM_currentTabs[idBase+"-"+index] = 0;
|
||
} else {
|
||
document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
|
||
if(isInit) {
|
||
document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
|
||
} else {
|
||
DTM_origClass = "tabact";
|
||
}
|
||
top.DTM_currentTabs[idBase+"-"+index] = 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
function DTM_mouseOver(obj) { //
|
||
DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
|
||
obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
|
||
}
|
||
|
||
function DTM_mouseOut(obj) { //
|
||
obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
|
||
DTM_origClass = "";
|
||
}
|
||
|
||
|
||
/*]]>*/
|
||
</script>
|
||
';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Creates the version selector for the page id inputted.
|
||
* Requires the core version management extension, "version" to be loaded.
|
||
*
|
||
* @param integer Page id to create selector for.
|
||
|
||
--- t3lib/class.t3lib_iconworks.php (revision 2741)
|
||
++ t3lib/class.t3lib_iconworks.php (working copy)
|
||
... | ... | |
*
|
||
* SECTION: Other functions
|
||
* 353: function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged)
|
||
* 475: function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h)
|
||
* 505: function imagecreatefrom($file)
|
||
* 522: function imagemake($im, $path)
|
||
function icons($type, $styleAttribValue='',$backPath='',$skinImage=true)
|
||
*
|
||
* TOTAL FUNCTIONS: 7
|
||
* (This index is automatically created/updated by the extension "extdeveval")
|
||
*
|
||
*/
|
||
|
||
... | ... | |
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
|
||
@ImagePng($im, $path);
|
||
} else {
|
||
@ImageGif($im, $path);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Returns an image-tag with an 18x16 icon of the following types:
|
||
*
|
||
* $type:
|
||
* -1: OK icon (Check-mark)
|
||
* 1: Notice (Speach-bubble)
|
||
* 2: Warning (Yellow triangle)
|
||
* 3: Fatal error (Red stop sign)
|
||
*
|
||
* @param integer See description
|
||
* @param string Value for style attribute
|
||
* @return string HTML image tag (if applicable)
|
||
*/
|
||
function icons($type, $styleAttribValue='',$backPath='',$skinImage=true) {
|
||
switch($type) {
|
||
case '3':
|
||
$icon = 'gfx/icon_fatalerror.gif';
|
||
break;
|
||
case '2':
|
||
$icon = 'gfx/icon_warning.gif';
|
||
break;
|
||
case '1':
|
||
$icon = 'gfx/icon_note.gif';
|
||
break;
|
||
case '-1':
|
||
$icon = 'gfx/icon_ok.gif';
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if ($icon) {
|
||
if($skinImage) // backend modules can use skinimages but they are not available for frontend
|
||
return '<img'.t3lib_iconWorks::skinImg($backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
|
||
else return '<img src="'.$backPath.$icon.'" class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
|
||
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
--- t3lib/class.t3lib_tceforms.php (revision 2741)
|
||
++ t3lib/class.t3lib_tceforms.php (working copy)
|
||
... | ... | |
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* Contains TYPO3 Core Form generator - AKA "TCEforms"
|
||
*
|
||
* $Id$
|
||
* $Id: class.t3lib_tceforms.php 2607 2007-10-22 19:33:53Z ingmars $
|
||
* Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj
|
||
* XHTML compliant
|
||
*
|
||
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
|
||
*/
|
||
/**
|
||
... | ... | |
* 3549: function formWidth($size=48,$textarea=0)
|
||
* 3576: function formWidthText($size=48,$wrap='')
|
||
* 3592: function formElStyle($type)
|
||
* 3603: function formElClass($type)
|
||
* 3614: function formElStyleClassValue($type, $class=FALSE)
|
||
* 3638: function insertDefStyle($type)
|
||
* 3657: function getDynTabMenu($parts, $idString)
|
||
*
|
||
* SECTION: Item-array manipulation functions (check/select/radio)
|
||
* 3696: function initItemArray($fieldValue)
|
||
* 3714: function addItems($items,$iArray)
|
||
* 3736: function procItems($items,$iArray,$config,$table,$row,$field)
|
||
* 3760: function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field)
|
||
... | ... | |
|
||
|
||
|
||
|
||
require_once(PATH_t3lib.'class.t3lib_diff.php');
|
||
require_once(PATH_t3lib.'class.t3lib_tceforms_inline.php');
|
||
require_once(PATH_t3lib.'class.t3lib_tabmenus.php');
|
||
|
||
|
||
|
||
/**
|
||
* 'TCEforms' - Class for creating the backend editing forms.
|
||
*
|
||
... | ... | |
var $backPath=''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed.
|
||
var $returnUrl=''; // Alternative return URL path (default is t3lib_div::linkThisScript())
|
||
var $doSaveFieldName=''; // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example.
|
||
var $palettesCollapsed=0; // Can be set true/false to whether palettes (secondary options) are in the topframe or in form. True means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page.
|
||
var $disableRTE=0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!)
|
||
var $globalShowHelp=1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp
|
||
var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records.
|
||
var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records.
|
||
var $fieldOrder=''; // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
|
||
var $doPrintPalette=1; // If set to false, palettes will NEVER be rendered.
|
||
var $dividers2tabs=0; // Will be set to TCA[ctrl][dividers2tabs]
|
||
|
||
/**
|
||
* Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
|
||
... | ... | |
|
||
// Internal, registers for user defined functions etc.
|
||
var $additionalCode_pre = array(); // Additional HTML code, printed before the form.
|
||
var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
|
||
var $additionalJS_post = array(); // Additional JavaScript printed after the form
|
||
var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
|
||
|
||
|
||
/**
|
||
* Instance of t3lib_tceforms_inline
|
||
*
|
||
* @var t3lib_TCEforms_inline
|
||
*/
|
||
var $inline;
|
||
... | ... | |
}
|
||
|
||
if ($TCA[$table]) {
|
||
|
||
// Load the full TCA for the table.
|
||
t3lib_div::loadTCA($table);
|
||
|
||
|
||
// Loads the dividers2tabs from the $TCA
|
||
$this->dividers2tabs = $TCA[$table]['ctrl']['dividers2tabs'];
|
||
|
||
|
||
// Load the description content for the table.
|
||
if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
|
||
$GLOBALS['LANG']->loadSingleTableDescription($table);
|
||
}
|
||
// Get the current "type" value for the record.
|
||
$typeNum = $this->getRTypeNum($table,$row);
|
||
... | ... | |
|
||
// If TCEforms will render a tab menu in the next step, push the name to the tab stack:
|
||
$tabIdentString = '';
|
||
$tabIdentStringMD5 = '';
|
||
if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $this->dividers2tabs) {
|
||
$tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
|
||
$tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
|
||
$tabIdentStringMD5 = t3lib_tabMenus::getDynTabMenuId($tabIdentString);
|
||
// Remember that were currently working on the general tab:
|
||
if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) {
|
||
$this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1');
|
||
}
|
||
}
|
||
|
||
... | ... | |
|
||
$out_array[$out_sheet][$out_pointer].= $sField;
|
||
} elseif ($theField=='--div--') {
|
||
if ($cc>0) {
|
||
$out_array[$out_sheet][$out_pointer].=$this->getDivider();
|
||
|
||
if ($this->enableTabMenu && $this->dividers2tabs) {
|
||
$this->wrapBorder($out_array[$out_sheet],$out_pointer);
|
||
if ($this->enableTabMenu && $this->dividers2tabs) {
|
||
$this->wrapBorder($out_array[$out_sheet],$out_pointer);
|
||
// Remove last tab entry from the dynNestedStack:
|
||
$out_sheet++;
|
||
// Remove the previous sheet from stack (if any):
|
||
$this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet));
|
||
// Remember on which sheet we're currently working:
|
||
$this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
|
||
... | ... | |
|
||
// Return the imploded $out_array:
|
||
if ($out_sheet>0) { // There were --div-- dividers around...
|
||
|
||
// Create parts array for the tab menu:
|
||
$parts = array();
|
||
foreach ($out_array as $idx => $sheetContent) {
|
||
foreach ($out_array as $idx => $sheetContent) {
|
||
$content = implode('', $sheetContent);
|
||
if ($content) {
|
||
// Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
|
||
$content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.$content.'</table>';
|
||
}
|
||
$parts[$idx] = array(
|
||
... | ... | |
}
|
||
|
||
if (count($parts) > 1) {
|
||
// Unset the current level of tab menus:
|
||
$this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
|
||
|
||
$output = $this->getDynTabMenu($parts, $tabIdentString);
|
||
$output = t3lib_tabMenus::getDynTabMenu($parts, $tabIdentString);
|
||
|
||
} else {
|
||
// If there is only one tab/part there is no need to wrap it into the dynTab code
|
||
$output = isset($parts[0]) ? trim($parts[0]['content']) : '';
|
||
}
|
||
|
||
$output = '
|
||
<tr>
|
||
<td colspan="2">
|
||
'.$output.'
|
||
</td>
|
||
</tr>';
|
||
|
||
|
||
} else {
|
||
// Only one, so just implode:
|
||
$output = implode('',$out_array[$out_sheet]);
|
||
}
|
||
|
||
return $output;
|
||
... | ... | |
|
||
// Find item
|
||
$item='';
|
||
$PA['label'] = ($PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label']);
|
||
$PA['label'] = ($PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label']);
|
||
$PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label']);
|
||
$PA['label'] = $this->sL($PA['label']);
|
||
$PA['label'] = $this->sL($PA['label']);
|
||
|
||
// JavaScript code for event handlers:
|
||
$PA['fieldChangeFunc']=array();
|
||
$PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
|
||
$PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
|
||
// if this is the child of an inline type and it is the field creating the label
|
||
... | ... | |
}
|
||
if (in_array('password',$evalList)) {
|
||
$itemFormElValue = $itemFormElValue ? '*********' : '';
|
||
}
|
||
return $this->getSingleField_typeNone_render($config, $itemFormElValue);
|
||
}
|
||
|
||
|
||
foreach ($evalList as $func) {
|
||
switch ($func) {
|
||
case 'required':
|
||
$this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
|
||
break;
|
||
default:
|
||
... | ... | |
}
|
||
|
||
// Getting style attribute value (for icons):
|
||
if ($config['iconsInOptionTags']) {
|
||
$styleAttrValue = $this->optionTagStyle($p[2]);
|
||
}
|
||
|
||
|
||
// Compiling the <option> tag:
|
||
if (!($p[1] != $PA['itemFormElValue'] && is_array($uniqueIds) && in_array($p[1], $uniqueIds))) {
|
||
if(!strcmp($p[1],'--div--')) {
|
||
if($optGroupOpen) { // Closing last optgroup before next one starts
|
||
$opt[]='</optgroup>';
|
||
}
|
||
... | ... | |
'<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" title="'.htmlspecialchars($p[0]).'" alt="'.htmlspecialchars($p[0]).'" />'.
|
||
(!$onlySelectedIconShown ? '</a>' : ''),
|
||
$c,$sM);
|
||
}
|
||
$c++;
|
||
}
|
||
|
||
|
||
if($optGroupOpen) { // Closing optgroup if open
|
||
$opt[]='</optgroup>';
|
||
$optGroupOpen = false;
|
||
}
|
||
|
||
|
||
// No-matching-value:
|
||
if ($PA['itemFormElValue'] && $noMatchingValue && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
|
||
$nMV_label = @sprintf($nMV_label, $PA['itemFormElValue']);
|
||
$opt[]= '<option value="'.htmlspecialchars($PA['itemFormElValue']).'" selected="selected">'.htmlspecialchars($nMV_label).'</option>';
|
||
}
|
||
|
||
... | ... | |
'linkTitle' => ($dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : ''),
|
||
'content' => $sheetContent
|
||
);
|
||
}
|
||
|
||
if (is_array($dataStructArray['sheets'])) {
|
||
$item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
|
||
$item.= t3lib_tabMenus::getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']);
|
||
} else {
|
||
$item.= $sheetContent;
|
||
}
|
||
}
|
||
} else $item='Data Structure ERROR: '.$dataStructArray;
|
||
|
||
... | ... | |
'</td>';
|
||
}
|
||
|
||
return '<table border="0" cellpadding="0" cellspacing="2" class="typo3-TCEforms-flexForm-sheetMenu"><tr>'.implode('',$tCells).'</tr></table>';
|
||
}
|
||
|
||
/**
|
||
/**
|
||
* Recursive rendering of flexforms
|
||
*
|
||
* @param array (part of) Data Structure for which to render. Keys on first level is flex-form fields
|
||
* @param array (part of) Data array of flexform corresponding to the input DS. Keys on first level is flex-form field names
|
||
* @param string Table name, eg. tt_content
|
||
* @param string Field name, eg. tx_templavoila_flex
|
||
... | ... | |
return $this->cachedTSconfig[$mainKey];
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Overrides the TCA field configuration by TSconfig settings.
|
||
*
|
||
*
|
||
* Example TSconfig: TCEform.<table>.<field>.config.appearance.useSortable = 1
|
||
* This overrides the setting in $TCA[<table>]['columns'][<field>]['config']['appearance']['useSortable'].
|
||
*
|
||
* @param array $fieldConfig: TCA field configuration
|
||
* @param array $TSconfig: TSconfig
|
||
* @return array Changed TCA field configuration
|
||
*/
|
||
function overrideFieldConf($fieldConfig, $TSconfig) {
|
||
if (is_array($TSconfig)) {
|
||
$TSconfig = t3lib_div::removeDotsFromTS($TSconfig);
|
||
$type = $fieldConfig['type'];
|
||
if (is_array($TSconfig['config']) && is_array($this->allowOverrideMatrix[$type])) {
|
||
// Check if the keys in TSconfig['config'] are allowed to override TCA field config:
|
||
// Check if the keys in TSconfig['config'] are allowed to override TCA field config:
|
||
foreach (array_keys($TSconfig['config']) as $key) {
|
||
if (!in_array($key, $this->allowOverrideMatrix[$type], true)) {
|
||
unset($TSconfig['config'][$key]);
|
||
}
|
||
}
|
||
// Override TCA field config by remaining TSconfig['config']:
|
||
... | ... | |
$dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
|
||
$fCfg = $GLOBALS['TCA'][$table]['columns'][$field];
|
||
|
||
if (strcmp($dLVal,'')) {
|
||
$item.='<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($dLVal,$fCfg).' </div>';
|
||
}
|
||
|
||
|
||
$prLang = $this->getAdditionalPreviewLanguages();
|
||
foreach($prLang as $prL) {
|
||
$dlVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->additionalPreviewLanguageData[$table.':'.$row['uid']][$prL['uid']][$field],0,1);
|
||
$item.= '<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($dlVal, $fCfg).' </div>';
|
||
}
|
||
|
||
|
||
}
|
||
|
||
return $item;
|
||
}
|
||
|
||
/**
|
||
... | ... | |
$class = $this->formElClass($type);
|
||
$out.= $class?' class="'.htmlspecialchars($class).'"':'';
|
||
|
||
return $out;
|
||
}
|
||
|
||
/**
|
||
* Create dynamic tab menu
|
||
*
|
||
* @param array Parts for the tab menu, fed to template::getDynTabMenu()
|
||
* @param string ID string for the tab menu
|
||
* @return string HTML for the menu
|
||
*/
|
||
function getDynTabMenu($parts, $idString) {
|
||
if (is_object($GLOBALS['TBE_TEMPLATE'])) {
|
||
return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString, 0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs);
|
||
} else {
|
||
$output = '';
|
||
foreach($parts as $singlePad) {
|
||
$output.='
|
||
<h3>'.htmlspecialchars($singlePad['label']).'</h3>
|
||
'.($singlePad['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($singlePad['description'])).'</p>' : '').'
|
||
'.$singlePad['content'];
|
||
}
|
||
|
||
return '<div class="typo3-dyntabmenu-divs">'.$output.'</div>';
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
... | ... | |
* ... and then include the result of this function after the form
|
||
*
|
||
* @param string $formname: The identification of the form on the page.
|
||
* @param boolean $update: Just extend/update existing settings, e.g. for AJAX call
|
||
* @return string A section with JavaScript - if $update is false, embedded in <script></script>
|
||
*/
|
||
function JSbottom($formname='forms[0]', $update = false) {
|
||
function JSbottom($formname='forms[0]', $update = false) {
|
||
$jsFile = array();
|
||
$elements = array();
|
||
|
||
// required:
|
||
foreach ($this->requiredFields as $itemImgName => $itemName) {
|
||
$match = array();
|
||
... | ... | |
}
|
||
|
||
if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode']) unset($output[$row['uid']]);
|
||
}
|
||
return $output;
|
||
}
|
||
|
||
|
||
/**
|
||
* Initializes language icons etc.
|
||
*
|
||
* param string Table name
|
||
* param array Record
|
||
* param string Sys language uid OR ISO language code prefixed with "v", eg. "vDA"
|
||
* param string Sys language uid OR ISO language code prefixed with "v", eg. "vDA"
|
||
* @return void
|
||
*/
|
||
function getLanguageIcon($table,$row,$sys_language_uid) {
|
||
global $TCA,$LANG;
|
||
|
||
$mainKey = $table.':'.$row['uid'];
|
||
... | ... | |
// None:
|
||
$this->cachedAdditionalPreviewLanguages = array();
|
||
}
|
||
}
|
||
return $this->cachedAdditionalPreviewLanguages;
|
||
}
|
||
|
||
|
||
/**
|
||
* Push a new element to the dynNestedStack. Thus, every object know, if it's
|
||
* nested in a tab or IRRE level and in which order this was processed.
|
||
*
|
||
* @param string $type: Type of the level, e.g. "tab" or "inline"
|
||
* @param string $ident: Identifier of the level
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Remove an element from the dynNestedStack. If $type and $ident
|
||
* are set, the last element will only be removed, if it matches
|
||
* what is expected to be removed.
|
||
*
|
||
*
|
||
* @param string $type: Type of the level, e.g. "tab" or "inline"
|
||
* @param string $ident: Identifier of the level
|
||
* @return void
|
||
*/
|
||
function popFromDynNestedStack($type=null, $ident=null) {
|
||
if ($type!=null && $ident!=null) {
|
||
|