/** * 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] = ' '.$this->cObj->stdWrap($cells[$a],$conf['innerStdWrap.']).''; } else { $headers = ' headers="'.$headerId.(($headerScope=='col')?$a:$k).'"'; $newCells[$a] = ' '.$this->cObj->stdWrap($cells[$a],$conf['innerStdWrap.']).''; } } if (!$noStyles) { $oddEven = $k%2 ? 'tr-odd' : 'tr-even'; $rowAttribs = ($k>0 && $k==$rLast) ? ' class="'.$oddEven.' tr-last"' : ' class="'.$oddEven.' tr-'.$k.'"'; } $rows[$k]=' '.implode('',$newCells).' '; } $addTbody = 0; $tableContents = ''; if ($caption) { $tableContents .= ' '.$caption.''; } if ($headerPos == 'top' && $rows[0]) { $tableContents .= ''. $rows[0] .' '; unset($rows[0]); $addTbody = 1; } if ($useTfoot) { $tableContents .= ' '.$rows[$rLast].''; unset($rows[$rLast]); $addTbody = 1; } $tmpTable = implode('',$rows); if ($addTbody) { $tmpTable = ''.$tmpTable.''; } $tableContents .= $tmpTable; // Set header type: $type = intval($this->cObj->data['layout']); // Table tag params. $tableTagParams = $this->getTableAttributes($conf,$type); if (!$noStyles) { $tableTagParams['class'] = 'contenttable contenttable-'.$type; } elseif ($tableClass) { $tableTagParams['class'] = $tableClass; } // Compile table output: $out = ' '. // Omitted xhtmlSafe argument TRUE - none of the values will be needed to be converted anyways, no need to spend processing time on that. $tableContents.'
'; // Calling stdWrap: if ($conf['stdWrap.']) { $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); } // Return value return $out; } }