From f30a49c9dd980a65ef0c8cc20060f47d107349be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 5 May 2015 17:12:29 +0200 Subject: [PATCH 1/2] Restructure page and title types The types page and pageid are now handled similar, but pageid is not cleaned. If page and pageid are provided without title then the id is shown as title. If they are provided with a title, then this title is shown. If a title field is not provided with a title, then the shown title depends on the useheadings setting. If it has a title, then the title is shown. --- helper.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helper.php b/helper.php index 5d6c4e4..d6ed9e4 100644 --- a/helper.php +++ b/helper.php @@ -143,6 +143,9 @@ function _cleanData($value, $type) { return trim($email . ' ' . $name); case 'page': + list($id, $title) = explode('|', $value, 2); + $id = cleanID($id); + return $id . " | " . $title; case 'nspage': return cleanID($value); default: @@ -230,11 +233,12 @@ function _formatData($column, $value, Doku_Renderer_xhtml $R) { $type = $type['type']; } switch($type) { - case 'page': - $val = $this->_addPrePostFixes($column['type'], $val); - $outs[] = $R->internallink($val, null, null, true); - break; case 'title': + list($id, $title) = explode('|', $val, 2); + $val = $this->_addPrePostFixes($column['type'], $id); + $outs[] = $R->internallink($val, $title, null, true); + break; + case 'page': case 'pageid': list($id, $title) = explode('|', $val, 2); From 0ff38daa06cd4d74ba8f733521eabf1c0a556f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 5 May 2015 17:45:49 +0200 Subject: [PATCH 2/2] Only add pipe if there was a title, adjust test. --- _test/helper.test.php | 5 ++++- helper.php | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/_test/helper.test.php b/_test/helper.test.php index 939b652..b5bb87e 100644 --- a/_test/helper.test.php +++ b/_test/helper.test.php @@ -136,9 +136,12 @@ function testFormatData() { $this->assertEquals('value1, value2, val', $helper->_formatData(array('type' => ''), "value1\n value2\n val", $renderer)); - $this->assertEquals('link: page ', + $this->assertEquals('link: page page', $helper->_formatData(array('type' => 'page'), "page", $renderer)); + $this->assertEquals('link: page ', + $helper->_formatData(array('type' => 'title'), "page", $renderer)); + $this->assertEquals('link: page title', $helper->_formatData(array('type' => 'title'), "page|title", $renderer)); diff --git a/helper.php b/helper.php index d6ed9e4..f2c48b1 100644 --- a/helper.php +++ b/helper.php @@ -145,7 +145,12 @@ function _cleanData($value, $type) { case 'page': list($id, $title) = explode('|', $value, 2); $id = cleanID($id); - return $id . " | " . $title; + if ($title !== null) { + $value = $id . "|" . $title; + } else { + $value = $id; + } + return $value; case 'nspage': return cleanID($value); default: