diff --git a/action/ajax.php b/action/ajax.php index dbba8859..5778f35a 100644 --- a/action/ajax.php +++ b/action/ajax.php @@ -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(); } diff --git a/action/cache.php b/action/cache.php index 5b27fda9..6d0135d6 100644 --- a/action/cache.php +++ b/action/cache.php @@ -1,8 +1,8 @@ has($key)) { $event->result = false; diff --git a/action/output.php b/action/output.php index 220d005a..332f7982 100644 --- a/action/output.php +++ b/action/output.php @@ -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; /** @@ -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; @@ -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 + ] + ] ); } diff --git a/admin/assignments.php b/admin/assignments.php index 6f6a9a42..52c082a0 100644 --- a/admin/assignments.php +++ b/admin/assignments.php @@ -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 @@ -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 ''; diff --git a/meta/AggregationTable.php b/meta/AggregationTable.php index 7e8e3b8d..32029da3 100644 --- a/meta/AggregationTable.php +++ b/meta/AggregationTable.php @@ -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', @@ -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); @@ -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); diff --git a/meta/ConfigParser.php b/meta/ConfigParser.php index 13f08134..4edb43df 100644 --- a/meta/ConfigParser.php +++ b/meta/ConfigParser.php @@ -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. @@ -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; diff --git a/meta/DateFormatConverter.php b/meta/DateFormatConverter.php index 00717ad6..1a19edcb 100644 --- a/meta/DateFormatConverter.php +++ b/meta/DateFormatConverter.php @@ -20,175 +20,99 @@ class DateFormatConverter { protected static $strftime = [ // Day - '%a' => 'D', - // An abbreviated textual representation of the day Sun through Sat - '%A' => 'l', - // A full textual representation of the day Sunday through Saturday - '%d' => 'd', - // Two-digit day of the month (with leading zeros) 01 to 31 - '%e' => 'j', - // Day of the month, with a space preceding single digits. Not implemented as described on Windows. See below for more information. 1 to 31 - '%j' => '', - // NOT SUPPORTED Day of the year, 3 digits with leading zeros 001 to 366 - '%u' => 'N', - // ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday) - '%w' => 'w', - // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) + '%a' => 'D', // An abbreviated textual representation of the day Sun through Sat + '%A' => 'l', // A full textual representation of the day Sunday through Saturday + '%d' => 'd', // Two-digit day of the month (with leading zeros) 01 to 31 + '%e' => 'j', // Day of the month, with a space preceding single digits. Not implemented as described on Windows. See below for more information. 1 to 31 + '%j' => '', // NOT SUPPORTED Day of the year, 3 digits with leading zeros 001 to 366 + '%u' => 'N', // ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday) + '%w' => 'w', // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) // Week - '%U' => '', - // NOT SUPPORTED Week number of the given year, starting with the first Sunday as the first week 13 (for the 13th full week of the year) - '%V' => 'W', - // ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week 01 through 53 (where 53 accounts for an overlapping week) - '%W' => '', - // NOT SUPPORTED A numeric representation of the week of the year, starting with the first Monday as the first week 46 (for the 46th week of the year beginning with a Monday) + '%U' => '', // NOT SUPPORTED Week number of the given year, starting with the first Sunday as the first week 13 (for the 13th full week of the year) + '%V' => 'W', // ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week 01 through 53 (where 53 accounts for an overlapping week) + '%W' => '', // NOT SUPPORTED A numeric representation of the week of the year, starting with the first Monday as the first week 46 (for the 46th week of the year beginning with a Monday) // Month - '%b' => 'M', - // Abbreviated month name, based on the locale Jan through Dec - '%B' => 'F', - // Full month name, based on the locale January through December - '%h' => 'M', - // Abbreviated month name, based on the locale (an alias of %b) Jan through Dec - '%m' => 'm', - // Two digit representation of the month 01 (for January) through 12 (for December) + '%b' => 'M', // Abbreviated month name, based on the locale Jan through Dec + '%B' => 'F', // Full month name, based on the locale January through December + '%h' => 'M', // Abbreviated month name, based on the locale (an alias of %b) Jan through Dec + '%m' => 'm', // Two digit representation of the month 01 (for January) through 12 (for December) // Year - '%C' => '', - // NOT SUPPORTED Two digit representation of the century (year divided by 100, truncated to an integer) 19 for the 20th Century - '%g' => 'y', - // Two digit representation of the year going by ISO-8601:1988 standards (see %V) Example: 09 for the week of January 6, 2009 - '%G' => 'Y', - // The full four-digit version of %g Example: 2008 for the week of January 3, 2009 - '%y' => 'y', - // Two digit representation of the year Example: 09 for 2009, 79 for 1979 - '%Y' => 'Y', - // Four digit representation for the year Example: 2038 + '%C' => '', // NOT SUPPORTED Two digit representation of the century (year divided by 100, truncated to an integer) 19 for the 20th Century + '%g' => 'y', // Two digit representation of the year going by ISO-8601:1988 standards (see %V) Example: 09 for the week of January 6, 2009 + '%G' => 'Y', // The full four-digit version of %g Example: 2008 for the week of January 3, 2009 + '%y' => 'y', // Two digit representation of the year Example: 09 for 2009, 79 for 1979 + '%Y' => 'Y', // Four digit representation for the year Example: 2038 // Time - '%H' => 'H', - // Two digit representation of the hour in 24-hour format 00 through 23 - '%k' => 'G', - // Two digit representation of the hour in 24-hour format, with a space preceding single digits 0 through 23 - '%I' => 'h', - // Two digit representation of the hour in 12-hour format 01 through 12 - '%l' => 'g', - // (lower-case 'L') Hour in 12-hour format, with a space preceding single digits 1 through 12 - '%M' => 'i', - // Two digit representation of the minute 00 through 59 - '%p' => 'A', - // UPPER-CASE 'AM' or 'PM' based on the given time Example: AM for 00:31, PM for 22:23 - '%P' => 'a', - // lower-case 'am' or 'pm' based on the given time Example: am for 00:31, pm for 22:23 - '%r' => 'h:i:s A', - // Same as %I:%M:%S %p Example: 09:34:17 PM for 21:34:17 - '%R' => 'H:i', - // Same as %H:%M Example: 00:35 for 12:35 AM, 16:44for 4:44 PM - '%S' => 's', - // Two digit representation of the second 00 through 59 - '%T' => 'H:i:s', - // Same as %H:%M:%S Example: 21:34:17 for 09:34:17 PM - '%X' => 'H:i:s', - // Preferred time representation based on locale, without the date Example: 03:59:16 or 15:59:16 - '%z' => 'z', - // The time zone offset. Not implemented as described on Windows. See below for more information. Example: -0500 for US Eastern Time - '%Z' => 'T', - // The time zone abbreviation. Not implemented as described on Windows. See below for more information. Example: EST for Eastern Time + '%H' => 'H', // Two digit representation of the hour in 24-hour format 00 through 23 + '%k' => 'G', // Two digit representation of the hour in 24-hour format, with a space preceding single digits 0 through 23 + '%I' => 'h', // Two digit representation of the hour in 12-hour format 01 through 12 + '%l' => 'g', // (lower-case 'L') Hour in 12-hour format, with a space preceding single digits 1 through 12 + '%M' => 'i', // Two digit representation of the minute 00 through 59 + '%p' => 'A', // UPPER-CASE 'AM' or 'PM' based on the given time Example: AM for 00:31, PM for 22:23 + '%P' => 'a', // lower-case 'am' or 'pm' based on the given time Example: am for 00:31, pm for 22:23 + '%r' => 'h:i:s A', // Same as %I:%M:%S %p Example: 09:34:17 PM for 21:34:17 + '%R' => 'H:i', // Same as %H:%M Example: 00:35 for 12:35 AM, 16:44for 4:44 PM + '%S' => 's', // Two digit representation of the second 00 through 59 + '%T' => 'H:i:s', // Same as %H:%M:%S Example: 21:34:17 for 09:34:17 PM + '%X' => 'H:i:s', // Preferred time representation based on locale, without the date Example: 03:59:16 or 15:59:16 + '%z' => 'z', // The time zone offset. Not implemented as described on Windows. See below for more information. Example: -0500 for US Eastern Time + '%Z' => 'T', // The time zone abbreviation. Not implemented as described on Windows. See below for more information. Example: EST for Eastern Time // Time and Date Stamps - '%c' => 'D M j H:i:s Y', - // Preferred date and time stamp based on locale Example: Tue Feb 5 00:45:10 2009 for February 5, 2009 at 12:45:10 AM - '%D' => 'm/d/y', - // Same as %m/%d/%y Example: 02/05/09 for February 5, 2009 - '%F' => 'Y/m/d', - // Same as %Y-%m-%d (commonly used in database datestamps) Example: 2009-02-05 for February 5, 2009 - '%s' => 'U', - // Unix Epoch Time timestamp (same as the time() function) Example: 305815200 for September 10, 1979 08:40:00 AM - '%x' => 'm/d/y', - // Preferred date representation based on locale, without the time Example: 02/05/09 for February 5, 2009 + '%c' => 'D M j H:i:s Y', // Preferred date and time stamp based on locale Example: Tue Feb 5 00:45:10 2009 for February 5, 2009 at 12:45:10 AM + '%D' => 'm/d/y', // Same as %m/%d/%y Example: 02/05/09 for February 5, 2009 + '%F' => 'Y/m/d', // Same as %Y-%m-%d (commonly used in database datestamps) Example: 2009-02-05 for February 5, 2009 + '%s' => 'U', // Unix Epoch Time timestamp (same as the time() function) Example: 305815200 for September 10, 1979 08:40:00 AM + '%x' => 'm/d/y', // Preferred date representation based on locale, without the time Example: 02/05/09 for February 5, 2009 // Miscellaneous - '%n' => "\n", - // A newline character (\n) --- - '%t' => "\t", - // A Tab character (\t) --- + '%n' => "\n", // A newline character (\n) --- + '%t' => "\t", // A Tab character (\t) --- '%%' => '%', ]; protected static $date = [ // Day - 'd' => '%d', - // Day of the month, 2 digits with leading zeros 01 to 31 - 'D' => '%a', - // A textual representation of a day, three letters Mon through Sun - 'j' => '%e', - // Day of the month without leading zeros 1 to 31 - 'l' => '%A', - // (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday - 'N' => '%u', - // ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday) - 'S' => '', - // NOT SUPPORTED English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j - 'w' => '%w', - // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) - 'z' => '', - // NOT SUPPORTED The day of the year (starting from 0) 0 through 365 + 'd' => '%d', // Day of the month, 2 digits with leading zeros 01 to 31 + 'D' => '%a', // A textual representation of a day, three letters Mon through Sun + 'j' => '%e', // Day of the month without leading zeros 1 to 31 + 'l' => '%A', // (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday + 'N' => '%u', // ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday) + 'S' => '', // NOT SUPPORTED English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j + 'w' => '%w', // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) + 'z' => '', // NOT SUPPORTED The day of the year (starting from 0) 0 through 365 // Week - 'W' => '%V', - // ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year) + 'W' => '%V', // ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year) // Month - 'F' => '%B', - // A full textual representation of a month, such as January or March January through December - 'm' => '%m', - // Numeric representation of a month, with leading zeros 01 through 12 - 'M' => '%b', - // A short textual representation of a month, three letters Jan through Dec - 'n' => '%m', - // Numeric representation of a month, without leading zeros 1 through 12 - 't' => '', - // NOT SUPPORTED Number of days in the given month 28 through 31 + 'F' => '%B', // A full textual representation of a month, such as January or March January through December + 'm' => '%m', // Numeric representation of a month, with leading zeros 01 through 12 + 'M' => '%b', // A short textual representation of a month, three letters Jan through Dec + 'n' => '%m', // Numeric representation of a month, without leading zeros 1 through 12 + 't' => '', // NOT SUPPORTED Number of days in the given month 28 through 31 // Year - 'L' => '', - // NOT SUPPORTED Whether it's a leap year 1 if it is a leap year, 0 otherwise. - 'o' => '%g', - // ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) Examples: 1999or 2003 - 'Y' => '%Y', - // A full numeric representation of a year, 4 digits Examples: 1999or 2003 - 'y' => '%y', - // A two digit representation of a year Examples: 99 or03 + 'L' => '', // NOT SUPPORTED Whether it's a leap year 1 if it is a leap year, 0 otherwise. + 'o' => '%g', // ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) Examples: 1999or 2003 + 'Y' => '%Y', // A full numeric representation of a year, 4 digits Examples: 1999or 2003 + 'y' => '%y', // A two digit representation of a year Examples: 99 or03 // Time - 'a' => '%P', - // Lowercase Ante meridiem and Post meridiem am or pm - 'A' => '%p', - // Uppercase Ante meridiem and Post meridiem AM or PM - 'B' => '', - // NOT SUPPORTED Swatch Internet time 000 through 999 - 'g' => '%l', - // 12-hour format of an hour without leading zeros 1 through 12 - 'G' => '%k', - // 24-hour format of an hour without leading zeros 0 through 23 - 'h' => '%I', - // 12-hour format of an hour with leading zeros 01 through 12 - 'H' => '%H', - // 24-hour format of an hour with leading zeros 00 through 23 - 'i' => '%M', - // Minutes with leading zeros 00 to 59 - 's' => '%S', - // Seconds, with leading zeros 00 through 59 - 'u' => '%s000000', - // Microseconds (added in PHP 5.2.2). Note that date() will always generate000000 since it takes an integer parameter, whereas DateTime::format()does support microseconds if DateTime was created with microseconds. Example: 654321 + 'a' => '%P', // Lowercase Ante meridiem and Post meridiem am or pm + 'A' => '%p', // Uppercase Ante meridiem and Post meridiem AM or PM + 'B' => '', // NOT SUPPORTED Swatch Internet time 000 through 999 + 'g' => '%l', // 12-hour format of an hour without leading zeros 1 through 12 + 'G' => '%k', // 24-hour format of an hour without leading zeros 0 through 23 + 'h' => '%I', // 12-hour format of an hour with leading zeros 01 through 12 + 'H' => '%H', // 24-hour format of an hour with leading zeros 00 through 23 + 'i' => '%M', // Minutes with leading zeros 00 to 59 + 's' => '%S', // Seconds, with leading zeros 00 through 59 + 'u' => '%s000000', // Microseconds (added in PHP 5.2.2). Note that date() will always generate000000 since it takes an integer parameter, whereas DateTime::format()does support microseconds if DateTime was created with microseconds. Example: 654321 // Timezone - 'e' => '%Z', - // Timezone identifier (added in PHP 5.1.0) Examples: UTC,GMT,Atlantic/Azores - 'I' => '', - // NOT SUPPORTED (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0otherwise. - 'O' => '%z', - // Difference to Greenwich time (GMT) in hours Example: +0200 - 'P' => '%z', - // Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00 - 'T' => '%Z', - // Timezone abbreviation Examples: EST,MDT ... - 'Z' => '', - // NOT SUPPORTED Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through50400 + 'e' => '%Z', // Timezone identifier (added in PHP 5.1.0) Examples: UTC,GMT,Atlantic/Azores + 'I' => '', // NOT SUPPORTED (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0otherwise. + 'O' => '%z', // Difference to Greenwich time (GMT) in hours Example: +0200 + 'P' => '%z', // Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00 + 'T' => '%Z', // Timezone abbreviation Examples: EST,MDT ... + 'Z' => '', // NOT SUPPORTED Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through50400 // Full Date/Time - 'c' => '', - // NOT SUPPORTED ISO 8601 date (added in PHP 5) 2004-02-12T15:19:21+00:00 - 'r' => '%a, %e %b %Y %H:%M:%S %s', - // » RFC 2822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200 + 'c' => '', // NOT SUPPORTED ISO 8601 date (added in PHP 5) 2004-02-12T15:19:21+00:00 + 'r' => '%a, %e %b %Y %H:%M:%S %s', // » RFC 2822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200 'U' => '%s', ]; diff --git a/meta/Schema.php b/meta/Schema.php index 18c33aff..680dccc5 100644 --- a/meta/Schema.php +++ b/meta/Schema.php @@ -311,7 +311,7 @@ public function isEditable() */ public function isInternal() { - return (bool) $this->config['internal']; + return (bool)$this->config['internal']; } /** @@ -345,7 +345,7 @@ function (Column $col) { public function findColumn($name) { foreach ($this->columns as $col) { - if ($col->isEnabled() && PhpString::strtolower($col->getLabel()) === PhpString::strtolower($name)) { + if ($col->isEnabled() && PhpString::strtolower($col->getLabel()) === PhpString::strtolower($name)) { return $col; } } @@ -373,10 +373,25 @@ public function getMaxsort() */ public function toJSON() { - $data = ['structversion' => $this->structversion, 'schema' => $this->getTable(), 'id' => $this->getId(), 'user' => $this->getUser(), 'config' => $this->getConfig(), 'columns' => []]; + $data = [ + 'structversion' => $this->structversion, + 'schema' => $this->getTable(), + 'id' => $this->getId(), + 'user' => $this->getUser(), + 'config' => $this->getConfig(), + 'columns' => [] + ]; foreach ($this->columns as $column) { - $data['columns'][] = ['colref' => $column->getColref(), 'ismulti' => $column->isMulti(), 'isenabled' => $column->isEnabled(), 'sort' => $column->getSort(), 'label' => $column->getLabel(), 'class' => $column->getType()->getClass(), 'config' => $column->getType()->getConfig()]; + $data['columns'][] = [ + 'colref' => $column->getColref(), + 'ismulti' => $column->isMulti(), + 'isenabled' => $column->isEnabled(), + 'sort' => $column->getSort(), + 'label' => $column->getLabel(), + 'class' => $column->getType()->getClass(), + 'config' => $column->getType()->getConfig() + ]; } return json_encode($data, JSON_PRETTY_PRINT); diff --git a/meta/SchemaBuilder.php b/meta/SchemaBuilder.php index e994a3e9..cb511c7d 100644 --- a/meta/SchemaBuilder.php +++ b/meta/SchemaBuilder.php @@ -198,7 +198,13 @@ protected function updateColumns() } // add this type to the schema columns - $schemaEntry = ['sid' => $this->newschemaid, 'colref' => $column->getColref(), 'enabled' => $enabled, 'tid' => $newTid, 'sort' => $sort]; + $schemaEntry = [ + 'sid' => $this->newschemaid, + 'colref' => $column->getColref(), + 'enabled' => $enabled, + 'tid' => $newTid, + 'sort' => $sort + ]; $ok = $this->sqlite->saveRecord('schema_cols', $schemaEntry); if (!$ok) return false; } @@ -277,7 +283,13 @@ protected function addColumns() // add this type to the schema columns - $schemaEntry = ['sid' => $this->newschemaid, 'colref' => $colref, 'enabled' => true, 'tid' => $newTid, 'sort' => $sort]; + $schemaEntry = [ + 'sid' => $this->newschemaid, + 'colref' => $colref, + 'enabled' => true, + 'tid' => $newTid, + 'sort' => $sort + ]; $ok = $this->sqlite->saveRecord('schema_cols', $schemaEntry); if (!$ok) return false; $colref++; diff --git a/meta/Search.php b/meta/Search.php index 282c8037..fe679061 100755 --- a/meta/Search.php +++ b/meta/Search.php @@ -594,7 +594,7 @@ protected function resolveColumn($colname) if (!$this->schemas) throw new StructException('noschemas'); // resolve the alias or table name - @[$table, $colname] = array_pad(explode('.', $colname, 2), 2, ''); + [$table, $colname] = sexplode('.', $colname, 2, ''); if (!$colname) { $colname = $table; $table = null; diff --git a/meta/SearchConfig.php b/meta/SearchConfig.php index 207a1f6c..07f8c79f 100644 --- a/meta/SearchConfig.php +++ b/meta/SearchConfig.php @@ -114,13 +114,25 @@ protected function applyFilterVars($filter) global $INPUT; global $INFO; if (!isset($INFO['id'])) { - $INFO['id'] = null; + $INFO['id'] = ''; } // apply inexpensive filters first $filter = str_replace( - ['$ID$', '$NS$', '$PAGE$', '$USER$', '$TODAY$'], - [$INFO['id'], getNS($INFO['id']), noNS($INFO['id']), $INPUT->server->str('REMOTE_USER'), date('Y-m-d')], + [ + '$ID$', + '$NS$', + '$PAGE$', + '$USER$', + '$TODAY$' + ], + [ + $INFO['id'], + getNS($INFO['id']), + noNS($INFO['id']), + $INPUT->server->str('REMOTE_USER'), + date('Y-m-d') + ], $filter ); @@ -164,7 +176,7 @@ protected function applyFilterVarsStruct($match) $label = $column->getLabel(); $table = $column->getTable(); } else { - [$table, $label] = array_pad(explode('.', $key), 2, ''); + [$table, $label] = sexplode('.', $key, 2, ''); } // get the data from the current page diff --git a/remote.php b/remote.php index 32f9fb02..0e475832 100644 --- a/remote.php +++ b/remote.php @@ -111,7 +111,12 @@ public function getSchema($schema = null) foreach ($schemas as $name => $schema) { $result[$name] = []; foreach ($schema->getColumns(false) as $column) { - $result[$name][] = ['name' => $column->getLabel(), 'type' => array_pop(explode('\\', get_class($column->getType()))), 'ismulti' => $column->isMulti()]; + $class = explode('\\', get_class($column->getType())); + $class = array_pop($class); + $result[$name][] = [ + 'name' => $column->getLabel(), + 'type' => $class, + 'ismulti' => $column->isMulti()]; } } return $result; diff --git a/renderer/csv.php b/renderer/csv.php index edbac60b..2927b55b 100644 --- a/renderer/csv.php +++ b/renderer/csv.php @@ -24,7 +24,8 @@ protected function doOutput() global $INPUT; if ( - !isset($this->info['struct_table_hash']) || $this->info['struct_table_hash'] != $INPUT->str('hash') + !isset($this->info['struct_table_hash']) || + $this->info['struct_table_hash'] != $INPUT->str('hash') ) { return false; } @@ -52,8 +53,11 @@ public function getFormat() public function document_start() { global $ID; - $filename = noNS($ID) . '.csv'; - $headers = ['Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="' . $filename . '";']; + $filename = noNS($ID ?? 'data') . '.csv'; + $headers = [ + 'Content-Type' => 'text/csv', + 'Content-Disposition' => 'attachment; filename="' . $filename . '";' + ]; p_set_metadata($ID, ['format' => ['struct_csv' => $headers]]); // don't cache $this->nocache(); diff --git a/syntax/output.php b/syntax/output.php index 5eecc9e5..ddd6c38f 100644 --- a/syntax/output.php +++ b/syntax/output.php @@ -124,7 +124,13 @@ public function render($format, Doku_Renderer $renderer, $data) continue; // no such schema at this revision } - $rendercontext = ['renderer' => $renderer, 'format' => $format, 'meta' => p_get_metadata($ID), 'schemadata' => $schemadata, 'hasdata' => &$hasdata]; + $rendercontext = [ + 'renderer' => $renderer, + 'format' => $format, + 'meta' => p_get_metadata($ID), + 'schemadata' => $schemadata, + 'hasdata' => &$hasdata + ]; $event = new Event( 'PLUGIN_STRUCT_RENDER_SCHEMA_DATA', diff --git a/types/AbstractBaseType.php b/types/AbstractBaseType.php index 59c657b6..c1220b48 100644 --- a/types/AbstractBaseType.php +++ b/types/AbstractBaseType.php @@ -71,7 +71,12 @@ abstract class AbstractBaseType public function __construct($config = null, $label = '', $ismulti = false, $tid = 0) { // general config options - $baseconfig = ['visibility' => ['inpage' => true, 'ineditor' => true]]; + $baseconfig = [ + 'visibility' => [ + 'inpage' => true, + 'ineditor' => true + ] + ]; // use previously saved configuration, ignoring all keys that are not supposed to be here if (!is_null($config)) { @@ -113,7 +118,12 @@ protected function mergeConfig($current, &$config) */ public function getAsEntry() { - return ['config' => json_encode($this->config), 'label' => $this->label, 'ismulti' => $this->ismulti, 'class' => $this->getClass()]; + return [ + 'config' => json_encode($this->config), + 'label' => $this->label, + 'ismulti' => $this->ismulti, + 'class' => $this->getClass() + ]; } /** @@ -286,7 +296,12 @@ public function valueEditor($name, $rawvalue, $htmlID) $class .= ' struct_autocomplete'; } - $params = ['name' => $name, 'value' => $rawvalue, 'class' => $class, 'id' => $htmlID]; + $params = [ + 'name' => $name, + 'value' => $rawvalue, + 'class' => $class, + 'id' => $htmlID + ]; $attributes = buildAttributes($params, true); return ""; } diff --git a/types/Checkbox.php b/types/Checkbox.php index 9d1455e3..acbba7b9 100644 --- a/types/Checkbox.php +++ b/types/Checkbox.php @@ -39,7 +39,14 @@ public function valueEditor($name, $rawvalue, $htmlID) $checked = ''; } $opt = hsc($opt); - $params = ['name' => $name, 'value' => $opt, 'class' => 'struct_' . strtolower($this->getClass()), 'type' => 'checkbox', 'id' => $htmlID, 'checked' => $checked]; + $params = [ + 'name' => $name, + 'value' => $opt, + 'class' => 'struct_' . strtolower($this->getClass()), + 'type' => 'checkbox', + 'id' => $htmlID, + 'checked' => $checked + ]; $attributes = buildAttributes($params, true); return ""; } @@ -65,7 +72,14 @@ public function multiValueEditor($name, $rawvalues, $htmlID) $checked = ''; } - $params = ['name' => $name . '[]', 'value' => $opt, 'class' => $class, 'type' => 'checkbox', 'id' => $htmlID, 'checked' => $checked]; + $params = [ + 'name' => $name . '[]', + 'value' => $opt, + 'class' => $class, + 'type' => 'checkbox', + 'id' => $htmlID, + 'checked' => $checked + ]; $attributes = buildAttributes($params, true); $htmlID = ''; diff --git a/types/Color.php b/types/Color.php index 58385fed..b9a8b0c2 100644 --- a/types/Color.php +++ b/types/Color.php @@ -6,7 +6,9 @@ class Color extends AbstractBaseType { - protected $config = ['default' => '#ffffff']; + protected $config = [ + 'default' => '#ffffff' + ]; /** * @inheritDoc @@ -66,7 +68,13 @@ public function valueEditor($name, $rawvalue, $htmlID) $rawvalue = $this->config['default']; } - $params = ['name' => $name, 'value' => $rawvalue, 'class' => 'struct_color', 'type' => 'color', 'id' => $htmlID]; + $params = [ + 'name' => $name, + 'value' => $rawvalue, + 'class' => 'struct_color', + 'type' => 'color', + 'id' => $htmlID + ]; $attributes = buildAttributes($params, true); return ""; } diff --git a/types/Date.php b/types/Date.php index ea4caccf..16c7e9e0 100644 --- a/types/Date.php +++ b/types/Date.php @@ -6,7 +6,12 @@ class Date extends AbstractBaseType { - protected $config = ['format' => 'Y/m/d', 'prefilltoday' => false, 'pastonly' => false, 'futureonly' => false]; + protected $config = [ + 'format' => 'Y/m/d', + 'prefilltoday' => false, + 'pastonly' => false, + 'futureonly' => false + ]; /** * Output the stored data @@ -48,8 +53,7 @@ public function valueEditor($name, $rawvalue, $htmlID) 'name' => $name, 'value' => $rawvalue, 'class' => 'struct_date', - 'type' => 'date', - // HTML5 date picker + 'type' => 'date', // HTML5 date picker 'id' => $htmlID, ]; $attributes = buildAttributes($params, true); diff --git a/types/DateTime.php b/types/DateTime.php index 2048393c..3c8678b2 100644 --- a/types/DateTime.php +++ b/types/DateTime.php @@ -10,8 +10,7 @@ class DateTime extends Date { protected $config = [ - 'format' => '', - // filled by constructor + 'format' => '', // filled by constructor 'prefilltoday' => false, 'pastonly' => false, 'futureonly' => false, @@ -52,8 +51,7 @@ public function valueEditor($name, $rawvalue, $htmlID) 'name' => $name, 'value' => $rawvalue, 'class' => 'struct_datetime', - 'type' => 'datetime-local', - // HTML5 datetime picker + 'type' => 'datetime-local', // HTML5 datetime picker 'id' => $htmlID, ]; $attributes = buildAttributes($params, true); diff --git a/types/Decimal.php b/types/Decimal.php index 759f9f60..6aa68f58 100644 --- a/types/Decimal.php +++ b/types/Decimal.php @@ -20,8 +20,7 @@ class Decimal extends AbstractMultiBaseType 'max' => '', 'roundto' => '-1', 'decpoint' => '.', - 'thousands' => "\xE2\x80\xAF", - // narrow no-break space + 'thousands' => "\xE2\x80\xAF", // narrow no-break space 'trimzeros' => true, 'prefix' => '', 'postfix' => '', @@ -102,7 +101,7 @@ public function validate($rawvalue) $rawvalue = parent::validate($rawvalue); $rawvalue = str_replace(',', '.', $rawvalue); // we accept both - if ((string)$rawvalue !== (string)(float) $rawvalue) { + if ((string)$rawvalue != (string)(float) $rawvalue) { throw new ValidationException('Decimal needed'); } diff --git a/types/Dropdown.php b/types/Dropdown.php index ebbd9a33..659233bc 100644 --- a/types/Dropdown.php +++ b/types/Dropdown.php @@ -4,7 +4,9 @@ class Dropdown extends AbstractBaseType { - protected $config = ['values' => 'one, two, three']; + protected $config = [ + 'values' => 'one, two, three' + ]; /** * Creates the options array @@ -30,7 +32,11 @@ protected function getOptions() */ public function valueEditor($name, $rawvalue, $htmlID) { - $params = ['name' => $name, 'class' => 'struct_' . strtolower($this->getClass()), 'id' => $htmlID]; + $params = [ + 'name' => $name, + 'class' => 'struct_' . strtolower($this->getClass()), + 'id' => $htmlID + ]; $attributes = buildAttributes($params, true); $html = ""; foreach ($this->getOptions() as $raw => $opt) { diff --git a/types/LongText.php b/types/LongText.php index b59e643a..e7c702b1 100644 --- a/types/LongText.php +++ b/types/LongText.php @@ -6,7 +6,12 @@ class LongText extends AbstractMultiBaseType { use TraitFilterPrefix; - protected $config = ['prefix' => '', 'postfix' => '', 'rows' => '5', 'cols' => '50']; + protected $config = [ + 'prefix' => '', + 'postfix' => '', + 'rows' => '5', + 'cols' => '50' + ]; /** @@ -53,7 +58,13 @@ public function validate($rawvalue) public function valueEditor($name, $rawvalue, $htmlID) { $rawvalue = formText($rawvalue); - $params = ['name' => $name, 'class' => 'struct_' . strtolower($this->getClass()), 'id' => $htmlID, 'rows' => $this->config['rows'], 'cols' => $this->config['cols']]; + $params = [ + 'name' => $name, + 'class' => 'struct_' . strtolower($this->getClass()), + 'id' => $htmlID, + 'rows' => $this->config['rows'], + 'cols' => $this->config['cols'] + ]; $attributes = buildAttributes($params, true); return ""; diff --git a/types/Mail.php b/types/Mail.php index 5b965aab..613f0831 100644 --- a/types/Mail.php +++ b/types/Mail.php @@ -6,7 +6,10 @@ class Mail extends Text { - protected $config = ['prefix' => '', 'postfix' => '']; + protected $config = [ + 'prefix' => '', + 'postfix' => '' + ]; /** * Output the stored data diff --git a/types/Media.php b/types/Media.php index 071f82c9..fb5fab87 100644 --- a/types/Media.php +++ b/types/Media.php @@ -6,7 +6,13 @@ class Media extends AbstractBaseType { - protected $config = ['mime' => 'image/', 'width' => 90, 'height' => 90, 'agg_width' => '', 'agg_height' => '']; + protected $config = [ + 'mime' => 'image/', + 'width' => 90, + 'height' => 90, + 'agg_width' => '', + 'agg_height' => '' + ]; /** * Checks against the allowed mime types @@ -98,7 +104,12 @@ public function valueEditor($name, $rawvalue, $htmlID) $id = $htmlID ?: 'struct__' . md5($name . $count); - $params = ['name' => $name, 'value' => $rawvalue, 'class' => 'struct_media', 'id' => $id]; + $params = [ + 'name' => $name, + 'value' => $rawvalue, + 'class' => 'struct_media', + 'id' => $id + ]; $attributes = buildAttributes($params, true); $html = ""; $html .= "