Skip to content

Commit f12df58

Browse files
Merge branch 'cosmocode:master' into metadata-fix
2 parents 19cd51a + 5349948 commit f12df58

28 files changed

+575
-91
lines changed

_test/ConfigParserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function test_simple()
8787
'nesting' => 0,
8888
'index' => 0,
8989
'classes' => ['struct-custom-foo', 'struct-custom-bar'],
90+
'actcol' => -1,
9091
];
9192

9293
$this->assertEquals($expected_config, $actual_config);

_test/InlineConfigParserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function test_simple()
5454
'nesting' => 0,
5555
'index' => 0,
5656
'classes' => [],
57+
'actcol' => -1,
5758
];
5859

5960
$this->assertEquals($expected_config, $actual_config);

_test/SearchConfigTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,40 @@ public function test_filtervars_simple()
3333
$this->assertEquals(date('Y-m-d'), $searchConfig->applyFilterVars('$DATE(now)$'));
3434
}
3535

36+
public function test_filtervars_nsorid()
37+
{
38+
global $INFO;
39+
40+
41+
$searchConfig = new SearchConfig([]);
42+
43+
// normal page
44+
$INFO['id'] = 'foo:bar:baz';
45+
$this->assertEquals('foo:bar:baz', $searchConfig->applyFilterVars('$NSORID$'));
46+
47+
// start page: start in namespace
48+
$INFO['id'] = 'foo:bar:start';
49+
saveWikiText($INFO['id'], 'start page', 'start created');
50+
$this->assertEquals('foo:bar', $searchConfig->applyFilterVars('$NSORID$'));
51+
saveWikiText($INFO['id'], '', 'start page deleted');
52+
clearstatcache();
53+
54+
// start page: same as namespace in namespace
55+
$INFO['id'] = 'foo:bar:bar';
56+
saveWikiText($INFO['id'], 'start page', 'start created');
57+
$this->assertEquals('foo:bar', $searchConfig->applyFilterVars('$NSORID$'));
58+
saveWikiText($INFO['id'], '', 'start page deleted');
59+
clearstatcache();
60+
61+
// start page: same as namespace in above namespace
62+
// incidally this is the same as a normal page
63+
$INFO['id'] = 'foo:bar';
64+
saveWikiText($INFO['id'], 'start page', 'start created');
65+
$this->assertEquals('foo:bar', $searchConfig->applyFilterVars('$NSORID$'));
66+
saveWikiText($INFO['id'], '', 'start page deleted');
67+
clearstatcache();
68+
}
69+
3670
public function test_filtervars_struct()
3771
{
3872
global $INFO;

action/migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ protected function getFixedValues($row)
413413
}
414414
}
415415

416-
if (!empty($fixes)) {
416+
if ($fixes !== []) {
417417
$fixes = array_map(static fn($set, $key) => "$key = '$set'", $fixes, array_keys($fixes));
418418
}
419419

helper/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class helper_plugin_struct_config extends Plugin
2020
*/
2121
public function parseSort($val)
2222
{
23-
if (substr($val, 0, 1) == '^') {
23+
if (str_starts_with($val, '^')) {
2424
return [substr($val, 1), false];
2525
}
2626
return [$val, true];

jsoneditor/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jQuery(function () {
2828
this.updateEditor = function () {
2929
editor.setText($config.val());
3030
};
31+
// collapse all nodes except for the new element
32+
if(!$config.parents('.new').length) {
33+
editor.collapseAll();
34+
}
3135
});
3236

3337
/**

lang/en/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
$lang['Exception no sqlite'] = 'The struct plugin requires the sqlite plugin. Please install and enable it.';
8282
$lang['Exception column not in table'] = 'There is no column %s in schema %s.';
8383
$lang['Exception datefilter'] = 'The filter: \'<code>$Date(%s)$</code>\' contains an unsupported value.';
84-
$lang['Warning: no filters for cloud'] = 'Filters are not supported for struct clouds.';
8584
$lang['sort'] = 'Sort by this column';
8685
$lang['next'] = 'Next page';
8786
$lang['prev'] = 'Previous page';

meta/Assignments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,12 @@ protected function matchPagePattern($pattern, $page, $pns = null)
291291
}
292292

293293
$ans = ':' . cleanID($pattern) . ':';
294-
if (substr($pattern, -2) == '**') {
294+
if (str_ends_with($pattern, '**')) {
295295
// upper namespaces match
296-
if (strpos($pns, $ans) === 0) {
296+
if (str_starts_with($pns, $ans)) {
297297
return true;
298298
}
299-
} elseif (substr($pattern, -1) == '*') {
299+
} elseif (str_ends_with($pattern, '*')) {
300300
// namespaces match exact
301301
if ($ans == $pns) {
302302
return true;

meta/Column.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ public static function allTypes($reload = false)
193193
$files = glob(DOKU_PLUGIN . 'struct/types/*.php');
194194
foreach ($files as $file) {
195195
$file = basename($file, '.php');
196-
if (substr($file, 0, 8) == 'Abstract') continue;
197-
if (substr($file, 0, 5) == 'Trait') continue;
198-
if (substr($file, 0, 4) == 'Auto') continue;
196+
if (str_starts_with($file, 'Abstract')) continue;
197+
if (str_starts_with($file, 'Trait')) continue;
198+
if (str_starts_with($file, 'Auto')) continue;
199199
$map[$file] = 'dokuwiki\\plugin\\struct\\types\\' . $file;
200200
}
201201

meta/ConfigParser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class ConfigParser
3030
'csv' => true,
3131
'nesting' => 0,
3232
'index' => 0,
33-
'classes' => []
33+
'classes' => [],
34+
'actcol' => -1,
3435
];
3536

3637
/**
@@ -131,6 +132,11 @@ public function __construct($lines)
131132
case 'classes':
132133
$this->config['classes'] = $this->parseClasses($val);
133134
break;
135+
case 'actcol':
136+
case 'actioncol':
137+
case 'actioncolumn':
138+
$this->config['actcol'] = (int) $val;
139+
break;
134140
default:
135141
$data = ['config' => &$this->config, 'key' => $key, 'val' => $val];
136142
$ev = new Event('PLUGIN_STRUCT_CONFIGPARSER_UNKNOWNKEY', $data);

0 commit comments

Comments
 (0)