'
+ if(substr($type, 0, 3) == 'img') {
+ $width = (int) substr($type, 3);
+ if(!$width) {
+ $width = $this->getConf('image_width');
+ }
+
+ list($mediaid, $title) = explode('|', $val, 2);
+ if($title === null) {
+ $title = $column['key'] . ': ' . basename(str_replace(':', '/', $mediaid));
+ } else {
+ $title = trim($title);
+ }
+
+ if(media_isexternal($val)) {
+ $html = $R->externalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true);
+ } else {
+ $html = $R->internalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true);
+ }
+ if(strpos($html, 'mediafile') === false) {
+ $html = str_replace('href', 'rel="lightbox" href', $html);
+ }
+
+ $outs[] = $html;
+ } else {
+ $outs[] = hsc($val);
+ }
+ }
+ }
+ return join(', ', $outs);
+ }
+
/**
* Split a column name into its parts
*
diff --git a/syntax/list.php b/syntax/list.php
index c13d0b3..37fc6c3 100644
--- a/syntax/list.php
+++ b/syntax/list.php
@@ -20,50 +20,121 @@ function connectTo($mode) {
$this->Lexer->addSpecialPattern('----+ *datalist(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', $mode, 'plugin_data_list');
}
- protected $before_item = '';
- protected $after_item = '
';
- protected $before_val = '';
- protected $after_val = ' ';
+ /**
+ * Before item in list
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function before_item(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '';
+ break;
+ case 'odt':
+ $R->listitem_open();
+ $R->listcontent_open();
+ break;
+ }
+ }
+
+ /**
+ * After item in list
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function after_item(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '
';
+ break;
+ case 'odt':
+ $R->listcontent_close();
+ $R->listitem_close();
+ break;
+ }
+ }
/**
* Before value in listitem
*
- * @param array $data instructions by handler
- * @param int $colno column number
- * @return string
+ * @param string $class The CSS class
+ * @param Doku_Renderer $R
*/
- protected function beforeVal(&$data, $colno) {
+ protected function before_val($class, Doku_Renderer $R)
+ {
+ return;
+ }
+
+ /**
+ * After value in listitem
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function after_val(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= ' ';
+ break;
+ case 'odt':
+ $R->doc .= ' ';
+ break;
+ }
+ }
+
+ /**
+ * Before value in listitem
+ *
+ * @param array $data instructions by handler
+ * @param int $colno column number
+ * @param string $class the xhtml class
+ * @param Doku_Renderer $R the current DokuWiki renderer
+ */
+ protected function beforeVal(&$data, $colno, $class, Doku_Renderer $R) {
if($data['sepbyheaders'] AND $colno === 0) {
- return $data['headers'][$colno];
+ $R->doc .= $data['headers'][$colno];
} else {
- return $this->before_val;
+ $this->before_val($class, $R);
}
}
/**
* After value in listitem
*
- * @param array $data
- * @param int $colno
- * @return string
+ * @param array $data
+ * @param int $colno
+ * @param Doku_Renderer $R
*/
- protected function afterVal(&$data, $colno) {
+ protected function afterVal(&$data, $colno, Doku_Renderer $R) {
if($data['sepbyheaders']) {
- return $data['headers'][$colno + 1];
+ $R->doc .= $data['headers'][$colno + 1];
} else {
- return $this->after_val;
+ $this->after_val($R);
}
}
/**
* Create list header
*
- * @param array $clist keys of the columns
- * @param array $data instruction by handler
- * @return string html of table header
+ * @param array $clist keys of the columns
+ * @param array $data instruction by handler
+ * @param Doku_Renderer $R the current DokuWiki renderer
*/
- function preList($clist, $data) {
- return '';
+ function preList($clist, $data, Doku_Renderer $R) {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '';
+ function postList($data, $rowcnt, Doku_Renderer $R) {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '
';
+ break;
+ case 'odt':
+ $R->listu_close();
+ break;
+ }
}
}
diff --git a/syntax/table.php b/syntax/table.php
index ef98106..9c79779 100644
--- a/syntax/table.php
+++ b/syntax/table.php
@@ -223,10 +223,80 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
return $data;
}
- protected $before_item = '';
- protected $after_item = '
';
- protected $before_val = '';
- protected $after_val = ' | ';
+ /**
+ * Before item in list
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function before_item(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '';
+ break;
+ case 'odt':
+ $R->tablerow_open();
+ break;
+ }
+ }
+
+ /**
+ * After item in list
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function after_item(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= '
';
+ break;
+ case 'odt':
+ $R->tablerow_close();
+ break;
+ }
+ }
+
+ /**
+ * Before value in listitem
+ *
+ * @param string $class The CSS class
+ * @param Doku_Renderer $R
+ */
+ protected function before_val($class, Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= sprintf("", $class);
+ break;
+ case 'odt':
+ $R->tablecell_open();
+ $R->p_open();
+ break;
+ }
+ }
+
+ /**
+ * After value in listitem
+ *
+ * @param Doku_Renderer $R
+ */
+ protected function after_val(Doku_Renderer $R)
+ {
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= ' | ';
+ break;
+ case 'odt':
+ $R->p_close();
+ $R->tablecell_close();
+ break;
+ }
+ }
/**
* Handles the actual output creation.
@@ -237,7 +307,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
* @return boolean rendered correctly? (however, returned value is not used at the moment)
*/
function render($format, Doku_Renderer $R, $data) {
- if($format != 'xhtml') return false;
+ if(($format != 'xhtml') && ($format != 'odt')) return false;
/** @var Doku_Renderer_xhtml $R */
if(is_null($data)) return false;
@@ -286,28 +356,27 @@ function render($format, Doku_Renderer $R, $data) {
}
//start table/list
- $R->doc .= $this->preList($clist, $data);
+ $this->preList($clist, $data, $R);
foreach($rows as $rownum => $row) {
// build data rows
- $R->doc .= $this->before_item;
+ $this->before_item($R);
if($data['rownumbers']) {
- $R->doc .= sprintf($this->before_val, 'class="' . $classes[0] . '"');
+ $this->before_val('class="' . $classes[0] . '"', $R);
$R->doc .= $rownum + 1;
- $R->doc .= $this->after_val;
+ $this->after_val($R);
}
foreach(array_values($row) as $num => $cval) {
$num_rn = $num + $offset;
- $R->doc .= sprintf($this->beforeVal($data, $num_rn), 'class="' . $classes[$num_rn] . '"');
+ $this->beforeVal($data, $num_rn, 'class="' . $classes[$num_rn] . '"', $R);
$R->doc .= $this->dthlp->_formatData(
$data['cols'][$clist[$num]],
$cval, $R
);
- $R->doc .= $this->afterVal($data, $num_rn);
-
+ $this->afterVal($data, $num_rn, $R);
// clean currency symbols
$nval = str_replace('$€₤', '', $cval);
$nval = str_replace('/ [A-Z]{0,3}$/', '', $nval);
@@ -323,9 +392,9 @@ function render($format, Doku_Renderer $R, $data) {
}
}
- $R->doc .= $this->after_item;
+ $this->after_item($R);
}
- $R->doc .= $this->postList($data, $cnt);
+ $this->postList($data, $cnt, $R);
return true;
}
@@ -333,33 +402,34 @@ function render($format, Doku_Renderer $R, $data) {
/**
* Before value in table cell
*
- * @param array $data instructions by handler
- * @param int $colno column number
- * @return string
+ * @param array $data instructions by handler
+ * @param int $colno column number
+ * @param string $class the xhtml class
+ * @param Doku_Renderer $R the current DokuWiki renderer
*/
- protected function beforeVal(&$data, $colno) {
- return $this->before_val;
+ protected function beforeVal(&$data, $colno, $class, Doku_Renderer $R) {
+ $this->before_val($class, $R);
}
/**
* After value in table cell
*
- * @param array $data
- * @param int $colno
- * @return string
+ * @param array $data
+ * @param int $colno
+ * @param Doku_Renderer $R
*/
- protected function afterVal(&$data, $colno) {
- return $this->after_val;
+ protected function afterVal(&$data, $colno, Doku_Renderer $R) {
+ $this->after_val($R);
}
/**
* Create table header
*
- * @param array $clist keys of the columns
- * @param array $data instruction by handler
- * @return string html of table header
+ * @param array $clist keys of the columns
+ * @param array $data instruction by handler
+ * @param Doku_Renderer $R the current DokuWiki renderer
*/
- function preList($clist, $data) {
+ function preList($clist, $data, Doku_Renderer $R) {
global $ID;
global $conf;
@@ -459,7 +529,32 @@ function preList($clist, $data) {
$text .= '';
}
- return $text;
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= $text;
+ break;
+ case 'odt':
+ $R->p_close();
+ $ncols = count($data['headers']);
+ if($data['rownumbers'])
+ $ncols += 1;
+ $R->table_open($ncols);
+ $R->tablerow_open();
+ if($data['rownumbers'])
+ {
+ $R->tableheader_open();
+ $R->tableheader_close();
+ }
+ foreach($data['headers'] as $num => $head)
+ {
+ $R->tableheader_open();
+ $R->doc .= $head;
+ $R->tableheader_close();
+ }
+ $R->tablerow_close();
+ break;
+ }
}
/**
@@ -469,24 +564,24 @@ function preList($clist, $data) {
* @param array $clist keys of the columns
* @param Doku_Renderer $R
*/
- function nullList($data, $clist, $R) {
- $R->doc .= $this->preList($clist, $data);
+ function nullList($data, $clist, Doku_Renderer $R) {
+ $this->preList($clist, $data, $R);
$R->tablerow_open();
$R->tablecell_open(count($clist), 'center');
$R->cdata($this->getLang('none'));
$R->tablecell_close();
$R->tablerow_close();
- $R->doc .= '';
+ $this->postList($data, 0, $R);
}
/**
* Create table footer
*
- * @param array $data instruction by handler()
- * @param int $rowcnt number of rows
- * @return string html of table footer
+ * @param array $data instruction by handler()
+ * @param int $rowcnt number of rows
+ * @param Doku_Renderer $R the current DokuWiki renderer
*/
- function postList($data, $rowcnt) {
+ function postList($data, $rowcnt, Doku_Renderer $R) {
global $ID;
$text = '';
// if summarize was set, add sums
@@ -550,7 +645,16 @@ function postList($data, $rowcnt) {
}
$text .= '';
- return $text;
+
+ switch($R->getFormat())
+ {
+ case 'xhtml':
+ $R->doc .= $text;
+ break;
+ case 'odt':
+ $R->table_close();
+ break;
+ }
}
/**