removes unnecessary site iteration

This commit is contained in:
buttle 2021-05-04 13:07:56 +02:00
parent 9a4d3e2822
commit 3671b05828
1 changed files with 10 additions and 18 deletions

View File

@ -56,26 +56,18 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
} }
public function getCollections($sites){ public function getCollections($sites){
$collections = $this->omekaSettings->get('sitemeta_collections'); $sitemeta_collections = $this->omekaSettings->get('sitemeta_collections');
$collection_options = []; $collections = [];
foreach ( explode("\n", $sitemeta_collections) as $value ) {
foreach ( explode("\n", $collections) as $value ) { if ($value == "") {
continue;
}
$key_value = explode("=", str_replace(array("\r", "\n"), '', $value)); $key_value = explode("=", str_replace(array("\r", "\n"), '', $value));
$collection_options[trim($key_value[1])] = trim($key_value[0]); if ($key_value) {
} $collections[trim($key_value[1])] = trim($key_value[0]);
//return $collections;
//$site = $sites[0]->setting('sitemeta_collections');
//$collections = [];
$result = [];
foreach ($sites as $site) {
$settings = $this->getSiteMetaValues($site);
if ($settings && !in_array($settings['collection'], $result)) {
$name = $collection_options[$settings['collection']];
$result[$settings['collection']] = $name;
//array_push($collections, $settings['collection']);
} }
} }
return $result; return $collections;
} }
public function getPages() public function getPages()