Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for odt export in datatable and datalist #169

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
21 changes: 10 additions & 11 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function ensureAbsoluteId($id) {
* @param Doku_Renderer_xhtml $R
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the type in the PHPDocs.
Can you add also PHPDocs for the functions where your add new arguments to the function?

(and just a suggestion: some IDEs can generate the PHPDocs for you (and perform many other inspections as well). For example you could have a look at https://www.dokuwiki.org/devel:intellij_idea )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'll update that. You mean the functions in #1239? I tried to comment every changed function signature, did I miss some?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean in the files helper.php, syntax/list.php etc.
For example: Doku_Renderer_xhtml at line 220, can now be updated to Doku_Renderer
Further the before_val, before_item,after_...(), etc doesn't have PHPDocs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note: this are inline comments, maybe in the Github view two discussions are mixed)

* @return string
*/
function _formatData($column, $value, Doku_Renderer_xhtml $R) {
function _formatData($column, $value, Doku_Renderer $R) {
global $conf;
$vals = explode("\n", $value);
$outs = array();
Expand Down Expand Up @@ -274,20 +274,16 @@ function _formatData($column, $value, Doku_Renderer_xhtml $R) {
case 'mail':
list($id, $title) = explode(' ', $val, 2);
$id = $this->_addPrePostFixes($column['type'], $id);
$id = obfuscate(hsc($id));
if(!$title) {
$title = $id;
} else {
$title = hsc($title);
}
if($conf['mailguard'] == 'visible') {
$id = rawurlencode($id);
}
$outs[] = '<a href="mailto:' . $id . '" class="mail" title="' . $id . '">' . $title . '</a>';
$outs[] = $R->emaillink($id, $title, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _formatDataOld() has some rawurlencoding applied, which is applied to the content of the title attribute as well. For the title attribute this encoding is not required.
My proposal is to improve the unittest and to modify the behavior in the _formatDataOld() such that it matches the new behavior.

The old code reuses the encoded $id:

if($conf['mailguard'] == 'visible') {
    $id = rawurlencode($id);
}
$outs[] = '<a href="mailto:' . $id . '" class="mail" title="' . $id . '">' . $title . '</a>';

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich kehre zur�ck am 10.08.2015.

Ich werde Ihre Nachricht nach meiner R�ckkehr beantworten. Herzlichen Dank
f�r ihr Verst�ndnis.

I will answer your message after returning.

Hinweis: Dies ist eine automatische Antwort auf Ihre Nachricht "Re:
[dokuwiki-plugin-data] Support for odt export in datatable and datalist
(#169)" gesendet am 30.07.2015 22:50:48.

Diese ist die einzige Benachrichtigung, die Sie empfangen werden, w�hrend
diese Person abwesend ist.

break;
case 'url':
$val = $this->_addPrePostFixes($column['type'], $val);
$outs[] = $this->external_link($val, false, 'urlextern');
$outs[] = $R->externallink($val, null, true);
break;
case 'tag':
// per default use keyname as target page, but prefix on aliases
Expand All @@ -297,9 +293,12 @@ function _formatData($column, $value, Doku_Renderer_xhtml $R) {
$target = $this->_addPrePostFixes($column['type'], '');
}

$outs[] = '<a href="' . wl(str_replace('/', ':', cleanID($target)), $this->_getTagUrlparam($column, $val))
. '" title="' . sprintf($this->getLang('tagfilter'), hsc($val))
. '" class="wikilink1">' . hsc($val) . '</a>';
$params = buildURLparams($this->_getTagUrlparam($column, $val));
$url = str_replace('/', ':', cleanID($target)) . '?' . $params;
// FIXME: The title is lost when moving to $R->internallink,
// but this syntax is required to support different renderers.
// $title = sprintf($this->getLang('tagfilter'), hsc($val));
$outs[] = $R->internallink($url, hsc($val), true);
break;
case 'timestamp':
$outs[] = dformat($val);
Expand All @@ -326,7 +325,7 @@ function _formatData($column, $value, Doku_Renderer_xhtml $R) {
}
$instructions = array_slice($allinstructions, $wraps, -$wraps);

$outs[] = p_render('xhtml', $instructions, $byref_ignore);
$outs[] = p_render($R->getFormat(), $instructions, $byref_ignore);
$ID = $oldid;
break;
default:
Expand Down
108 changes: 90 additions & 18 deletions syntax/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,54 @@ function connectTo($mode) {
$this->Lexer->addSpecialPattern('----+ *datalist(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', $mode, 'plugin_data_list');
}

protected $before_item = '<li><div class="li">';
protected $after_item = '</div></li>';
protected $before_val = '';
protected $after_val = ' ';
protected function before_item(Doku_Renderer $R)
{
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= '<li><div class="li">';
break;
case 'odt':
$R->listitem_open();
$R->listcontent_open();
break;
}
return true;
}

protected function after_item(Doku_Renderer $R)
{
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= '</div></li>';
break;
case 'odt':
$R->listcontent_close();
$R->listitem_close();
break;
}
return true;
}

protected function before_val($class, Doku_Renderer $R)
{
return true;
}

protected function after_val(Doku_Renderer $R)
{
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= ' ';
break;
case 'odt':
$R->doc .= ' ';
break;
}
return true;
}

/**
* Before value in listitem
Expand All @@ -32,11 +76,11 @@ function connectTo($mode) {
* @param int $colno column number
* @return string
*/
protected function beforeVal(&$data, $colno) {
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);
}
}

Expand All @@ -47,11 +91,11 @@ protected function beforeVal(&$data, $colno) {
* @param int $colno
* @return string
*/
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);
}
}

Expand All @@ -62,8 +106,17 @@ protected function afterVal(&$data, $colno) {
* @param array $data instruction by handler
* @return string html of table header
*/
function preList($clist, $data) {
return '<div class="dataaggregation"><ul class="dataplugin_list ' . $data['classes'] . '">';
function preList($clist, $data, Doku_Renderer $R) {
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= '<div class="dataaggregation"><ul class="dataplugin_list ' . $data['classes'] . '">';
break;
case 'odt':
$R->listu_open();
break;
}
return true;
}

/**
Expand All @@ -73,10 +126,20 @@ function preList($clist, $data) {
* @param array $clist keys of the columns
* @param Doku_Renderer $R
*/
function nullList($data, $clist, $R) {
$R->doc .= '<div class="dataaggregation"><p class="dataplugin_list ' . $data['classes'] . '">';
$R->cdata($this->getLang('none'));
$R->doc .= '</p></div>';
function nullList($data, $clist, Doku_Renderer $R) {
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= '<div class="dataaggregation"><p class="dataplugin_list ' . $data['classes'] . '">';
$R->cdata($this->getLang('none'));
$R->doc .= '</p></div>';
break;
case 'odt':
$R->p_open();
$R->cdata($this->getLang('none'));
$R->p_close();
break;
}
}

/**
Expand All @@ -86,8 +149,17 @@ function nullList($data, $clist, $R) {
* @param int $rowcnt number of rows
* @return string html of table footer
*/
function postList($data, $rowcnt) {
return '</ul></div>';
function postList($data, $rowcnt, Doku_Renderer $R) {
switch($R->getFormat())
{
case 'xhtml':
$R->doc .= '</ul></div>';
break;
case 'odt':
$R->listu_close();
break;
}
return true;
}

}
Loading