/** * Rendering the "Table" type content element, called from TypoScript (tt_content.table.20) * * @param string Content input. Not used, ignore. * @param array TypoScript configuration * @return string HTML output. * @access private */ function render_table($content,$conf) { // Look for hook before running default code for function if ($hookObj = &$this->hookRequest('render_table')) { return $hookObj->render_table($content,$conf); } else { // Init FlexForm configuration $this->pi_initPIflexForm(); // Get bodytext field content $content = trim($this->cObj->data['bodytext']); if (!strcmp($content,'')) return ''; // get flexform values $caption = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_caption'))); $summary = trim(htmlspecialchars($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_summary'))); $useTfoot = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_tfoot')); $headerPos = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_headerpos'); $noStyles = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_nostyles'); $tableClass = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'acctables_tableclass'); $delimiter = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'tableparsing_delimiter','s_parsing')); if ($delimiter) { $delimiter = chr(intval($delimiter)); } else { $delimiter = '|'; } $quotedInput = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'tableparsing_quote','s_parsing')); if ($quotedInput) { $quotedInput = chr(intval($quotedInput)); } else { $quotedInput = ''; } // generate id prefix for header if($headerPos == 'top' || $headerPos == 'bottom') $headerScope = 'col'; else $headerScope = 'row'; $headerId = $headerScope.$this->cObj->data['uid'].'-'; // Split into single lines (will become table-rows): $rows = t3lib_div::trimExplode(chr(10),$content); // Find number of columns to render: $cols = t3lib_div::intInRange($this->cObj->data['cols']?$this->cObj->data['cols']:count(explode($delimiter,current($rows))),0,100); // Traverse rows (rendering the table here) $rCount = count($rows); $rLast = $rCount-1; $cLast = $cols-1; foreach($rows as $k => $v) { $cells = explode($delimiter,$v); $newCells=array(); for($a=0;$a<$cols;$a++) { // remove quotes if needed if ($quotedInput && substr($cells[$a],0,1) == $quotedInput && substr($cells[$a],-1,1) == $quotedInput) { $cells[$a] = substr($cells[$a],1,-1); } if (!strcmp(trim($cells[$a]),'')) $cells[$a]=' '; $cellAttribs = ($noStyles?'':(($a>0 && $a==$cLast) ? ' class="td-last"' : ' class="td-'.$a.'"')); if ((!$k && $headerPos == 'top') || (!$a && $headerPos == 'left') || ($a == $cLast && $headerPos == 'right') || ($k == $rLast && $headerPos == 'bottom')) { $scope = ' scope="'.$headerScope.'" id="'.$headerId.(($headerScope=='col')?$a:$k).'"'; $newCells[$a] = '