Skip to content

Commit

Permalink
Merge pull request #52 from pastakhov/DisplayParameters
Browse files Browse the repository at this point in the history
Use default dispaly parameters when it is not provided by user
  • Loading branch information
krabina authored May 3, 2024
2 parents bdfccf5 + 2b762bc commit 0d6b625
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/Parameters/DisplayParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DisplayParameters implements IteratorAggregate {
/**
* @param string $displayParameters String of the form "x1=y1;...;xn=yn"
*/
public function __construct( string $displayParameters ) {
public function __construct( string $displayParameters = '' ) {
$displayParameters = array_map( 'trim', explode( self::SEP, $displayParameters ) );

foreach ( $displayParameters as $dp ) {
Expand Down
4 changes: 4 additions & 0 deletions includes/Parameters/DisplayParametersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ public function strings(): Generator {
}
}

public function count(): int {
return count( $this->list );
}

}
8 changes: 6 additions & 2 deletions includes/Specials/BrowseData/QueryPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PageProps;
use RequestContext;
use SD\DbService;
use SD\Parameters\DisplayParameters;
use SD\Parameters\Parameters;
use SD\Sql\PropertyTypeDbInfo;
use SD\Sql\SqlProvider;
Expand Down Expand Up @@ -65,8 +66,9 @@ public function __construct(

$this->headerPage = $parameters->header();
$this->footerPage = $parameters->footer();
if ( $parameters->displayParametersList() ) {
foreach ( $parameters->displayParametersList() as $dps ) {
$displayParametersList = $parameters->displayParametersList();
if ( $displayParametersList && $displayParametersList->count() ) {
foreach ( $displayParametersList as $dps ) {
$format = $dps->format();
if ( !array_key_exists( $format, $resultFormatTypes ) ) {
$this->displayParametersWithUnknownFormat[] = $dps;
Expand All @@ -78,6 +80,8 @@ public function __construct(
$this->displayParametersWithUnsupportedFormat[] = $dps;
}
}
} else {
$this->pagedDisplayParametersList[] = new DisplayParameters();
}

$this->processTemplate = new ProcessTemplate;
Expand Down

0 comments on commit 0d6b625

Please sign in to comment.