Commit ab89d208 authored by Kasper Skårhøj's avatar Kasper Skårhøj
Browse files

* Added new rendering modes for the "select" type in TCA: You can now render multiple-select lists as either a SINGLE selector box with multiple value selection OR as a list of checkboxes. For mozilla even the icons are rendered nicely in the option tags. Check out the backend user group configurations. Work is still in progress.


git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@426 709f56b5-9817-0410-a4d7-c38de5d9e867
parent 5f994bb3
2004-08-04 Kasper Skårhøj,,, <kasper@typo3.com>
* Added new rendering modes for the "select" type in TCA: You can now render multiple-select lists as either a SINGLE selector box with multiple value selection OR as a list of checkboxes. For mozilla even the icons are rendered nicely in the option tags. Check out the backend user group configurations. Work is still in progress.
2004-08-04 Kasper Skårhøj,,, <kasper@typo3.com>
* Added TYPo3_CONF_VARS[FE][lockHashKeyWords] so it is optional to lock FE user sessions to HTTP_USER_AGENT
......
......@@ -1137,8 +1137,18 @@ class t3lib_TCEforms {
$sI=$c;
$noMatchingValue=0;
}
$opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.$sM.'>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
// If there is an icon for the selector box...:
// Getting style attribute value (for icons):
if ($config['iconsInOptionTags']) list($styleAttrValue) = $this->optionTagStyle($p[2]);
// Compiling the <option> tag:
$opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
$sM.
($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
(!strcmp($p[1],'--div--') ? ' class="c-divider"' : '').
'>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
// If there is an icon for the selector box (rendered in table under)...:
if ($p[2] && !$suppressIcons && (!$onlySelectedIconShown || $sM)) {
list($selIconFile,$selIconInfo)=$this->getIcon($p[2]);
$iOnClick = $this->elName($PA['itemFormElName']).'.selectedIndex='.$c.'; '.implode('',$PA['fieldChangeFunc']).$this->blur().'return false;';
......@@ -1178,7 +1188,144 @@ class t3lib_TCEforms {
}
$item.='</table>';
}
} else {
} elseif (!strcmp($config['renderMode'],'checkbox')) { // Checkbox renderMode
// Selected items:
$itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
foreach($itemArray as $tk => $tv) {
$tvP = explode('|',$tv,2);
$tvP[0] = rawurldecode($tvP[0]);
$itemArray[$tk] = $tvP[0];
}
// Traverse the Array of selector box items:
$tRows = array();
$sOnChange = implode('',$PA['fieldChangeFunc']);
$c=0;
foreach($selItems as $p) {
// Non-selectable element:
if (!strcmp($p[1],'--div--')) {
$tRows[] = '
<tr class="c-header">
<td colspan="2">'.htmlspecialchars($p[0]).'</td>
</tr>';
} else {
// Selected or not by default:
if (in_array($p[1], $itemArray)) {
$sM = ' checked="checked"';
} else {
$sM = '';
}
// Icon:
if ($p[2]) {
list($selIconFile,$selIconInfo) = $this->getIcon($p[2]);
} else {
$selIconFile = '';
}
// Compile row:
$onClickCell = $this->elName($PA['itemFormElName'].'['.$c.']').'.checked=!'.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked;';
$onClick= 'this.attributes.getNamedItem("class").nodeValue = '.$this->elName($PA['itemFormElName'].'['.$c.']').'.checked ? "c-selectedItem" : "";';
$tRows[] = '
<tr class="'.($sM ? 'c-selectedItem' : '').'" onclick="'.htmlspecialchars($onClick).'" style="cursor: pointer;">
<td><input type="checkbox" name="'.htmlspecialchars($PA['itemFormElName'].'['.$c.']').'" value="'.htmlspecialchars($p[1]).'"'.$sM.' onclick="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].' /></td>
<td class="c-labelCell" onclick="'.htmlspecialchars($onClickCell).'">'.
($selIconFile ? '<img src="'.$selIconFile.'" '.$selIconInfo[3].' vspace="2" border="0" class="absmiddle" style="margin-right: 4px;" alt="" />' : '').
t3lib_div::deHSCentities(htmlspecialchars($p[0])).
(strcmp($p[3],'') ? '<br/><p class="c-descr">'.htmlspecialchars($p[3]).'</p>' : '').
'</td>
</tr>';
$c++;
}
}
// Implode rows in table:
$item.= '
<table border="0" cellpadding="0" cellspacing="0" class="typo3-TCEforms-select-checkbox">'.
implode('',$tRows).'
</table>';
} elseif (!strcmp($config['renderMode'],'singlebox')) { // Single selector box renderMode
// Selected items:
$itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
foreach($itemArray as $tk => $tv) {
$tvP = explode('|',$tv,2);
$tvP[0] = rawurldecode($tvP[0]);
$itemArray[$tk] = $tvP[0];
}
// Traverse the Array of selector box items:
$opt = array();
$restoreCmd = array();
$c=0;
foreach($selItems as $p) {
// Selected or not by default:
if (in_array($p[1], $itemArray)) {
$sM = ' selected="selected"';
$restoreCmd[] = $this->elName($PA['itemFormElName'].'[]').'.options['.$c.'].selected=1;';
} else {
$sM = '';
}
// Non-selectable element:
if (!strcmp($p[1],'--div--')) {
$nonSel = ' onclick="this.selected=0;" class="c-divider"';
} else {
$nonSel = '';
}
// Icon style for option tag:
if ($config['iconsInOptionTags']) list($styleAttrValue) = $this->optionTagStyle($p[2]);
// Compile <option> tag:
$opt[] = '<option value="'.htmlspecialchars($p[1]).'"'.
$sM.
$nonSel.
($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
'>'.t3lib_div::deHSCentities(htmlspecialchars($p[0])).'</option>';
$c++;
}
// Compile selector box:
$sOnChange = implode('',$PA['fieldChangeFunc']);
$selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
$size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
$selectBox = '<select name="'.$PA['itemFormElName'].'[]"'.
$this->insertDefStyle('select').
($size ? ' size="'.$size.'"' : '').
' multiple="multiple" onchange="'.htmlspecialchars($sOnChange).'"'.
$PA['onFocus'].
$selector_itemListStyle.'>
'.
implode('
',$opt).'
</select>';
// Put it all into a table:
$item.= '
<table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
<tr>
<td>
'.$selectBox.'
<br/>
<em>'.
htmlspecialchars($this->getLL('l_holdDownCTRL')).
'</em>
</td>
<td valign="top">
<a href="#" onclick="'.htmlspecialchars($this->elName($PA['itemFormElName'].'[]').'.selectedIndex=-1;'.implode('',$restoreCmd).' return false;').'">'.
'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history.gif','width="13" height="12"').' title="'.htmlspecialchars($this->getLL('l_revertSelection')).'" alt="" />'.
'</a>
</td>
</tr>
</table>
';
} else { // Traditional multiple selector box:
$item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'" />';
// Set max and min items:
......@@ -1202,19 +1349,27 @@ class t3lib_TCEforms {
} else {
$tvP[1] = rawurlencode($this->sL(rawurldecode($tvP[1])));
}
$itemArray[$tk]=implode('|',$tvP);
$itemArray[$tk] = implode('|',$tvP);
}
// Put together the select form with selected elements:
$selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"';
$size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config['autoSizeMax']) : $size;
$thumbnails = '<select name="'.$PA['itemFormElName'].'_sel"'.$this->insertDefStyle('select').($size?' size="'.$size.'"':'').' onchange="'.htmlspecialchars($sOnChange).'"'.$PA['onFocus'].$selector_itemListStyle.'>';
$thumbnails = '<select name="'.$PA['itemFormElName'].'_sel"'.
$this->insertDefStyle('select').
($size ? ' size="'.$size.'"' : '').
' onchange="'.htmlspecialchars($sOnChange).'"'.
$PA['onFocus'].
$selector_itemListStyle.'>';
foreach($selItems as $p) {
$thumbnails.= '<option value="'.htmlspecialchars($p[1]).'">'.htmlspecialchars($p[0]).'</option>';
if ($config['iconsInOptionTags']) list($styleAttrValue) = $this->optionTagStyle($p[2]);
$thumbnails.= '<option value="'.htmlspecialchars($p[1]).'"'.
($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue).'"' : '').
'>'.htmlspecialchars($p[0]).'</option>';
}
$thumbnails.= '</select>';
$params=array(
$params = array(
'size' => $size,
'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'],0),
'style' => isset($config['selectedListStyle']) ? ' style="'.htmlspecialchars($config['selectedListStyle']).'"' : ' style="'.$this->defaultMultipleSelectorStyle.'"',
......@@ -2160,6 +2315,7 @@ class t3lib_TCEforms {
<td>'.$this->wrapLabels($params['headers']['selector']).'</td>
<td></td>
<td></td>
<td></td>
<td>'.$this->wrapLabels($params['headers']['items']).'</td>
</tr>':'').
'
......@@ -2453,7 +2609,7 @@ class t3lib_TCEforms {
* Get icon (for example for selector boxes)
*
* @param string Icon reference
* @return array Array with two values; the icon file reference, the icon file information array (getimagesize())
* @return array Array with two values; the icon file reference (relative to PATH_typo3 minus backPath), the icon file information array (getimagesize())
*/
function getIcon($icon) {
if (substr($icon,0,4)=='EXT:') {
......@@ -2467,15 +2623,28 @@ class t3lib_TCEforms {
$selIconFile = $this->backPath.$icon;
$selIconInfo = @getimagesize(PATH_site.substr($icon,3));
} elseif (substr($icon,0,4)=='ext/' || substr($icon,0,7)=='sysext/') {
$selIconFile = $icon;
$selIconFile = $this->backPath.$icon;
$selIconInfo = @getimagesize(PATH_typo3.$icon);
} else {
$selIconFile = 't3lib/gfx/'.$icon;
$selIconFile = $this->backPath.'t3lib/gfx/'.$icon;
$selIconInfo = @getimagesize(PATH_t3lib.'gfx/'.$icon);
}
return array($selIconFile,$selIconInfo);
}
/**
*
*/
function optionTagStyle($iconString) {
if ($iconString) {
list($selIconFile,$selIconInfo) = $this->getIcon($iconString);
$padTop = t3lib_div::intInRange(($selIconInfo[1]-12)/2,0);
$styleAttr = 'background-image: url('.$selIconFile.'); background-repeat: no-repeat; height: '.t3lib_div::intInRange(($selIconInfo[1]+2)-$padTop,0).'px; padding-top: '.$padTop.'px; padding-left: '.($selIconInfo[0]+4).'px;';
} else $styleAttr = '';
return array($styleAttr, intval($selIconInfo[1]));
}
/**
* Wraps a string with a link to the palette.
*
......@@ -2854,13 +3023,18 @@ class t3lib_TCEforms {
$loadModules = t3lib_div::makeInstance('t3lib_loadModules');
$loadModules->load($GLOBALS['TBE_MODULES']);
}
$modList = $fieldValue['config']['special']=='modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
if (is_array($modList)) {
reset($modList);
while (list(,$theMod)=each($modList)) {
foreach($modList as $theMod) {
$icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod.'_tab'];
if ($icon) {
$icon = '../'.substr($icon,strlen(PATH_site));
}
$items[] = array(
$this->addSelectOptionsToItemArray_makeModuleData($theMod),
$theMod
$theMod,
$icon
);
}
}
......@@ -3732,7 +3906,7 @@ class t3lib_TCEforms {
}
function setFormValueFromBrowseWin(fName,value,label) { //
var formObj = setFormValue_getFObj(fName)
if (formObj) {
if (formObj && value!="--div--") {
fObj = formObj[fName+"_list"];
// Inserting element
var l=fObj.length;
......
......@@ -1404,6 +1404,11 @@ class t3lib_TCEmain {
function checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles) {
list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
// Detecting if value send is an array and if so, implode it around a comma:
if (is_array($value)) {
$value = implode(',',$value);
}
// This converts all occurencies of '&#123;' to the byte 123 in the string - this is needed in very rare cases where filenames with special characters (like , umlaud etc) gets sent to the server as HTML entities instead of bytes. The error is done only by MSIE, not Mozilla and Opera.
// Anyways, this should NOT disturb anything else:
$value = $this->convNumEntityToByteValue($value);
......
......@@ -141,7 +141,8 @@ $TYPO3_CONF_VARS = Array(
'loginNews' => array(), // In this array you can define news-items for the login screen. To this array, add arrays with assoc keys 'date', 'header', 'content' (HTML content) and for those appropriate value pairs
'XCLASS' => Array(), // See 'Inside TYPO3' document for more information.
'XLLfile' => Array(), // For extension/overriding of the arrays in 'locallang' files in the backend. See 'Inside TYPO3' for more information.
'notificationPrefix' => '[TYPO3 Note]'
'notificationPrefix' => '[TYPO3 Note]',
'accessListRenderMode' => 'checkbox',
),
'FE' => Array( // Configuration for the TypoScript frontend (FE). Nothing here relates to the administration backend!
'png_to_gif' => 0, // Boolean. Enables conversion back to gif of all png-files generated in the frontend libraries. Notice that this leaves an increased number of temporary files in typo3temp/
......
......@@ -315,7 +315,9 @@ $TCA['be_users'] = Array (
'special' => 'modListUser',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '15'
'maxitems' => '15',
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
),
'TSconfig' => Array (
......@@ -388,6 +390,8 @@ $TCA['be_groups'] = Array (
'size' => '3',
'maxitems' => '10',
'autoSizeMax' => 10,
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
'wizards' => Array(
'_PADDING' => 1,
'_VERTICAL' => 1,
......@@ -430,7 +434,9 @@ $TCA['be_groups'] = Array (
'special' => 'pagetypes',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '20'
'maxitems' => 20,
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
),
'tables_modify' => Array (
......@@ -440,7 +446,9 @@ $TCA['be_groups'] = Array (
'special' => 'tables',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '20'
'maxitems' => 20,
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
),
'tables_select' => Array (
......@@ -450,7 +458,9 @@ $TCA['be_groups'] = Array (
'special' => 'tables',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '20'
'maxitems' => 20,
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
),
'non_exclude_fields' => Array (
......@@ -461,6 +471,9 @@ $TCA['be_groups'] = Array (
'size' => '25',
'maxitems' => '300',
'autoSizeMax' => 50,
'renderMode' => 'checkbox',
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
)
),
'hidden' => Array (
......@@ -487,7 +500,9 @@ $TCA['be_groups'] = Array (
'special' => 'modListGroup',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '15'
'maxitems' => '15',
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
),
'inc_access_lists' => Array (
......@@ -538,7 +553,9 @@ $TCA['be_groups'] = Array (
'foreign_table_where' => 'ORDER BY be_groups.title',
'size' => '5',
'autoSizeMax' => 50,
'maxitems' => '20'
'maxitems' => 20,
'renderMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['accessListRenderMode'],
'iconsInOptionTags' => 1,
)
)
),
......
......@@ -228,6 +228,14 @@ BODY#typo3-alt-db-navframe-php DIV.c-notice { border: 1px solid black; padding:
TABLE.typo3-TCEforms SPAN.typo3-TCEforms-recHeader { font-weight: bold; color: #333366; }
TABLE.typo3-TCEforms SPAN.typo3-TCEforms-newToken { font-weight: bold; color: #990000; }
TABLE.typo3-TCEforms SPAN.typo3-TCEforms-helpText { color: #666666; }
TABLE.typo3-TCEforms OPTION.c-divider { font-style: italic; color: #666666; background-color: #eeeeee; text-transform : uppercase; margin-top: 10px; border-bottom: 1px solid #666666; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox TR.c-selectedItem {background-color: #c5c1b5; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox TR TD {border-bottom: 1px #999999 dashed; padding: 1px 3px 1px 3px; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox TR TD.c-labelCell { padding-right: 30px; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox TR TD.c-labelCell P.c-descr {margin-left: 30px; font-style: italic;}
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox TR.c-header TD { font-weight: bold; padding-top: 10px; border-bottom: none; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-checkbox { margin-top: 4px; margin-bottom: 10px; }
TABLE.typo3-TCEforms TABLE.typo3-TCEforms-select-singlebox { margin-top: 4px; margin-bottom: 10px; }
/* Element Browser / RTE link selection: */
TABLE#typo3-curUrl { font-weight: bold; width: 100%; margin-bottom: 2px;}
......
......@@ -439,7 +439,8 @@ $TCA['tt_content'] = Array (
Array('LLL:EXT:cms/locallang_ttc.php:imageorient.I.10', 26, 'selicons/intext_left_nowrap.gif')
),
'selicon_cols' => 6,
'default' => '8'
'default' => '8',
'iconsInOptionTags' => 1,
)
),
'imageborder' => Array (
......
......@@ -75,6 +75,8 @@ Do you want to continue WITHOUT saving?</label>
<label index="labels.clipNoEl">No elements</label>
<label index="labels.cliptabs">Clipboard #</label>
<label index="labels.removeItem">Remove item</label>
<label index="labels.holdDownCTRL">Important: Hold down the CTRL key while toggling elements in this list!</label>
<label index="labels.revertSelection">Revert selection</label>
<label index="TYPO3_Element_Browser">TYPO3 Element Browser</label>
<label index="show_item.php.viewItem">View Item</label>
<label index="show_item.php.file">File</label>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment