ILIAS  release_8 Revision v8.23
class.ilLuceneAdvancedSearchSettings.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /*
5  +-----------------------------------------------------------------------------+
6  | ILIAS open source |
7  +-----------------------------------------------------------------------------+
8  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
9  | |
10  | This program is free software; you can redistribute it and/or |
11  | modify it under the terms of the GNU General Public License |
12  | as published by the Free Software Foundation; either version 2 |
13  | of the License, or (at your option) any later version. |
14  | |
15  | This program is distributed in the hope that it will be useful, |
16  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18  | GNU General Public License for more details. |
19  | |
20  | You should have received a copy of the GNU General Public License |
21  | along with this program; if not, write to the Free Software |
22  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23  +-----------------------------------------------------------------------------+
24 */
25 
26 
34 {
35  private static ?ilLuceneAdvancedSearchSettings $instance = null;
36  private array $fields = [];
37 
38  protected ilSetting $storage;
39 
43  private function __construct()
44  {
45  $this->storage = new ilSetting('lucene_adv_search');
46  $this->read();
47  }
48 
49  public static function getInstance(): ilLuceneAdvancedSearchSettings
50  {
51  if (self::$instance instanceof ilLuceneAdvancedSearchSettings) {
52  return self::$instance;
53  }
54  return self::$instance = new ilLuceneAdvancedSearchSettings();
55  }
56 
60  public function isActive(string $a_field): bool
61  {
62  return $this->fields[$a_field] ?: false;
63  }
64 
65  public function setActive(string $a_field, bool $a_status): void
66  {
67  $this->fields[$a_field] = $a_status;
68  }
69 
70  public function save(): void
71  {
72  foreach ($this->fields as $name => $status) {
73  $this->storage->set($name, $status ? "1" : "0");
74  }
75  }
76 
77  private function read(): void
78  {
79  foreach (ilLuceneAdvancedSearchFields::getFields() as $name => $translation) {
80  $this->fields[$name] = (bool) $this->storage->get($name, 'true');
81  }
82  }
83 }
$errors fields
Definition: imgupload.php:67
En/disable single lom/advanced meta data fields.
if($format !==null) $name
Definition: metadata.php:247
isActive(string $a_field)
check if field is active
static ilLuceneAdvancedSearchSettings $instance
static getFields()
Return an array of all meta data fields.