Skip to content

Commit

Permalink
apply #670 and manually cleanup afterwards
Browse files Browse the repository at this point in the history
fixes some failing tests
uses sexplode over array_pad
reformats multiline arrays
  • Loading branch information
splitbrain committed Sep 13, 2023
1 parent 7234bfb commit 7fe2cdf
Show file tree
Hide file tree
Showing 29 changed files with 360 additions and 214 deletions.
4 changes: 3 additions & 1 deletion action/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function handleAjax(Event $event)
try {
$result = $this->executeTypeAjax();
} catch (StructException $e) {
$result = ['error' => $e->getMessage() . ' ' . basename($e->getFile()) . ':' . $e->getLine()];
$result = [
'error' => $e->getMessage() . ' ' . basename($e->getFile()) . ':' . $e->getLine()
];
if ($conf['allowdebug']) {
$result['stacktrace'] = $e->getTraceAsString();
}
Expand Down
8 changes: 6 additions & 2 deletions action/cache.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\EventHandler;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
use dokuwiki\plugin\sqlite\SQLiteDB;
use dokuwiki\plugin\struct\meta\Assignments;
use dokuwiki\plugin\struct\meta\SearchConfig;
Expand Down Expand Up @@ -134,7 +134,11 @@ public function handleCacheDynamic(Event $event, $param)

// disable cache use when one of these parameters is present
foreach (
[SearchConfigParameters::$PARAM_FILTER, SearchConfigParameters::$PARAM_OFFSET, SearchConfigParameters::$PARAM_SORT] as $key
[
SearchConfigParameters::$PARAM_FILTER,
SearchConfigParameters::$PARAM_OFFSET,
SearchConfigParameters::$PARAM_SORT
] as $key
) {
if ($INPUT->has($key)) {
$event->result = false;
Expand Down
13 changes: 11 additions & 2 deletions action/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\EventHandler;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
use dokuwiki\plugin\struct\meta\Schema;

/**
Expand Down Expand Up @@ -48,6 +48,7 @@ public function register(EventHandler $controller)
public function handleOutput(Event $event, $param)
{
global $ID;
if (!$ID) return;
if (!page_exists($ID)) return;

$pos = 0;
Expand Down Expand Up @@ -77,7 +78,15 @@ public function handleOutput(Event $event, $param)
$event->data->calls,
$ins + 1,
0,
[['plugin', ['struct_output', ['pos' => $pos], DOKU_LEXER_SPECIAL, ''], $pos]]
[
[
'plugin',
[
'struct_output', ['pos' => $pos], DOKU_LEXER_SPECIAL, ''
],
$pos
]
]
);
}

Expand Down
10 changes: 8 additions & 2 deletions admin/assignments.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// must be run within Dokuwiki
use dokuwiki\Extension\AdminPlugin;
use dokuwiki\plugin\struct\meta\Assignments;
use dokuwiki\plugin\struct\meta\Schema;
use dokuwiki\plugin\struct\meta\StructException;

class admin_plugin_struct_assignments extends AdminPlugin
Expand Down Expand Up @@ -120,7 +119,14 @@ public function html()

$link = wl(
$ID,
['do' => 'admin', 'page' => 'struct_assignments', 'action' => 'delete', 'sectok' => getSecurityToken(), 'assignment[tbl]' => $schema, 'assignment[assign]' => $assignee]
[
'do' => 'admin',
'page' => 'struct_assignments',
'action' => 'delete',
'sectok' => getSecurityToken(),
'assignment[tbl]' => $schema,
'assignment[assign]' => $assignee
]
);

echo '<tr>';
Expand Down
21 changes: 18 additions & 3 deletions meta/AggregationTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ public function render($showNotFound = false)

$this->renderActiveFilters();

$rendercontext = ['table' => $this, 'renderer' => $this->renderer, 'format' => $this->mode, 'search' => $this->searchConfig, 'columns' => $this->columns, 'data' => $this->result];
$rendercontext = [
'table' => $this,
'renderer' => $this->renderer,
'format' => $this->mode,
'search' => $this->searchConfig,
'columns' => $this->columns,
'data' => $this->result
];

$event = new Event(
'PLUGIN_STRUCT_RENDER_AGGREGATION_TABLE',
Expand Down Expand Up @@ -211,7 +218,7 @@ protected function renderColumnHeaders()
$dynamic = $this->searchConfig->getDynamicParameters();
$dynamic->setSort($column, true);
if (isset($sorts[$column->getFullQualifiedLabel()])) {
[, $currentSort] = $sorts[$column->getFullQualifiedLabel()];
[/*colname*/, $currentSort] = $sorts[$column->getFullQualifiedLabel()];
if ($currentSort) {
$sortclass = 'sort-down';
$dynamic->setSort($column, false);
Expand Down Expand Up @@ -307,7 +314,15 @@ protected function renderDynamicFilters()
protected function renderResult()
{
foreach ($this->result as $rownum => $row) {
$data = ['id' => $this->id, 'mode' => $this->mode, 'renderer' => $this->renderer, 'searchConfig' => $this->searchConfig, 'data' => $this->data, 'rownum' => &$rownum, 'row' => &$row];
$data = [
'id' => $this->id,
'mode' => $this->mode,
'renderer' => $this->renderer,
'searchConfig' => $this->searchConfig,
'data' => $this->data,
'rownum' => &$rownum,
'row' => &$row
];
$evt = new Event('PLUGIN_STRUCT_AGGREGATIONTABLE_RENDERRESULTROW', $data);
if ($evt->advise_before()) {
$this->renderResultRow($rownum, $row);
Expand Down
22 changes: 20 additions & 2 deletions meta/ConfigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@
*/
class ConfigParser
{
protected $config = ['limit' => 0, 'dynfilters' => false, 'summarize' => false, 'rownumbers' => false, 'sepbyheaders' => false, 'target' => '', 'align' => [], 'headers' => [], 'cols' => [], 'widths' => [], 'filter' => [], 'schemas' => [], 'sort' => [], 'csv' => true, 'nesting' => 0, 'index' => 0, 'classes' => []];
protected $config = [
'limit' => 0,
'dynfilters' => false,
'summarize' => false,
'rownumbers' => false,
'sepbyheaders' => false,
'target' => '',
'align' => [],
'headers' => [],
'cols' => [],
'widths' => [],
'filter' => [],
'schemas' => [],
'sort' => [],
'csv' => true,
'nesting' => 0,
'index' => 0,
'classes' => []
];

/**
* Parser constructor.
Expand Down Expand Up @@ -179,7 +197,7 @@ protected function parseSchema($val)
$schemas = [];
$parts = explode(',', $val);
foreach ($parts as $part) {
@[$table, $alias] = array_pad(explode(' ', trim($part)), 2, '');
[$table, $alias] = sexplode(' ', trim($part), 2, '');
$table = trim($table);
$alias = trim($alias);
if (!$table) continue;
Expand Down
Loading

0 comments on commit 7fe2cdf

Please sign in to comment.