Skip to content

Commit a6fc2b5

Browse files
committed
Fix handling of single title fields w/o title
1 parent e6df749 commit a6fc2b5

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

_test/syntax_plugin_data_entry.test.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,38 @@ function testHandle() {
6565
$this->assertEquals($cols, $result['cols'], 'Cols array corrupted');
6666
}
6767

68+
function test_titleEntry_noTitle() {
69+
$test_entry = '---- dataentry ----
70+
test_title: bar
71+
----';
72+
$plugin = new syntax_plugin_data_entry();
73+
74+
$handler = new Doku_Handler();
75+
$data = $plugin->handle($test_entry, 0, 10, $handler);
76+
$renderer = new Doku_Renderer_xhtml();
77+
$plugin->render('xhtml',$renderer,$data);
78+
$result = $renderer->doc;
79+
$result = substr($result,0,strpos($result,'</a>')+4);
80+
$result = substr($result,strpos($result,'<a'));
81+
$this->assertSame('<a href="/./doku.php?id=bar" class="wikilink2" title="bar" rel="nofollow">bar</a>',$result);
82+
}
83+
84+
function test_titleEntry_withTitle() {
85+
$test_entry = '---- dataentry ----
86+
test_title: link:to:page|TitleOfPage
87+
----';
88+
$plugin = new syntax_plugin_data_entry();
89+
90+
$handler = new Doku_Handler();
91+
$data = $plugin->handle($test_entry, 0, 10, $handler);
92+
$renderer = new Doku_Renderer_xhtml();
93+
$plugin->render('xhtml',$renderer,$data);
94+
$result = $renderer->doc;
95+
$result = substr($result,0,strpos($result,'</a>')+4);
96+
$result = substr($result,strpos($result,'<a'));
97+
$this->assertSame('<a href="/./doku.php?id=link:to:page" class="wikilink2" title="link:to:page" rel="nofollow">TitleOfPage</a>',$result);
98+
}
99+
68100
function test_editToWiki() {
69101
$data = array(
70102
'classes' => 'projects',

helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ function _formatData($column, $value, Doku_Renderer_xhtml $R) {
241241
//use ID from first value of the multivalued line
242242
if($title == null) {
243243
$title = $id;
244-
$id = $storedID;
244+
if(!empty($storedID)) {
245+
$id = $storedID;
246+
}
245247
} else {
246248
$storedID = $id;
247249
}

0 commit comments

Comments
 (0)