summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Spring <pierre.spring@liip.ch>2008-02-23 18:58:08 +0100
committerPierre Spring <pierre.spring@liip.ch>2008-02-23 18:58:08 +0100
commitb5742ced86ad0a0e0448556d81e6c97c12ae9d9f (patch)
tree85ed9f1547e15325b447d6b0118cca8c060fdbd1
parentace46cb1e1b6ef39341c73d331fcc1294c2c7e77 (diff)
downloadrpg-b5742ced86ad0a0e0448556d81e6c97c12ae9d9f.tar.gz
rpg-b5742ced86ad0a0e0448556d81e6c97c12ae9d9f.tar.bz2
Table Row And Col Classes
This patch adds classes to the table rows and cells (td and th). This can be of usage when templating and within syntax plugins. darcs-hash:20080223175808-c3d3e-73384884597c56deac774a8a52cd20b639b3039b.gz
-rw-r--r--inc/parser/xhtml.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 5f25d167a..d1e484fb4 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -36,6 +36,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
var $lastsec = 0;
var $store = '';
+ var $_counter = array(); // used as global counter, introduced for table classes
+
function getFormat(){
return 'xhtml';
}
@@ -793,6 +795,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// $numrows not yet implemented
function table_open($maxcols = NULL, $numrows = NULL){
+ // initialize the row counter used for classes
+ $this->_counter['row_counter'] = 0;
$this->doc .= '<table class="inline">'.DOKU_LF;
}
@@ -801,7 +805,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
function tablerow_open(){
- $this->doc .= DOKU_TAB . '<tr>' . DOKU_LF . DOKU_TAB . DOKU_TAB;
+ // initialize the cell counter used for classes
+ $this->_counter['cell_counter'] = 0;
+ $class = 'row' . $this->_counter['row_counter']++;
+ $this->doc .= DOKU_TAB . '<tr class="'.$class.'">' . DOKU_LF . DOKU_TAB . DOKU_TAB;
}
function tablerow_close(){
@@ -809,11 +816,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
function tableheader_open($colspan = 1, $align = NULL){
- $this->doc .= '<th';
+ $class = 'class="col' . $this->_counter['cell_counter']++;
if ( !is_null($align) ) {
- $this->doc .= ' class="'.$align.'align"';
+ $class .= ' '.$align.'align';
}
+ $class .= '"';
+ $this->doc .= '<th ' . $class;
if ( $colspan > 1 ) {
+ $this->_counter['cell_counter'] += $colspan;
$this->doc .= ' colspan="'.$colspan.'"';
}
$this->doc .= '>';
@@ -824,11 +834,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
function tablecell_open($colspan = 1, $align = NULL){
- $this->doc .= '<td';
+ $class = 'class="col' . $this->_counter['cell_counter']++;
if ( !is_null($align) ) {
- $this->doc .= ' class="'.$align.'align"';
+ $class .= ' '.$align.'align';
}
+ $class .= '"';
+ $this->doc .= '<td '.$class;
if ( $colspan > 1 ) {
+ $this->_counter['cell_counter'] += $colspan;
$this->doc .= ' colspan="'.$colspan.'"';
}
$this->doc .= '>';