Skip to content

Commit

Permalink
Remove orderable options field workaround. See pkp/pkp-lib#10529
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Nov 12, 2024
1 parent 1d95c1e commit 33a9b09
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions SlubThemeOptions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public function addOptions(): void
$this->addArticleMetadataOption();
$this->addIssueArchivesOption();
$this->addColorOptions();

// Must be last option
$this->fixOrderedHomepageBlocks();
}

/**
Expand Down Expand Up @@ -353,32 +350,6 @@ protected function addHomepageBlocksOption(): void
]);
}

/**
* Workaround for bug in 3.3.x where the form does not display the options
* in the selected order. This function must be called after all other
* options are defined. All option values are loaded and stored in memory
* once. Any theme options defined after this function is called will not
* have their values loaded.
*/
protected function fixOrderedHomepageBlocks(): void
{
$enabled = $this->theme->getOption('homepageBlocks');
if (!$enabled) {
$enabled = self::HOMEPAGE_BLOCKS_DEFAULT;
}

$options = $this->getHomepageBlockOptions()->values()->toArray();
usort($options, function ($a, $b) use ($enabled) {
$aIndex = array_search($a['value'], $enabled);
$aIndex = $aIndex === false ? PHP_INT_MAX : $aIndex;
$bIndex = array_search($b['value'], $enabled);
$bIndex = $bIndex === false ? PHP_INT_MAX : $bIndex;
return $aIndex < $bIndex ? -1 : 1;
});

$this->theme->options['homepageBlocks']->options = $options;
}

/**
* Add text fields for the how to submit homepage block
*/
Expand Down

0 comments on commit 33a9b09

Please sign in to comment.