+ /**
+ * Setup settings-frontend.php in the build/website directory
+ *
+ * @return null
+ */
+ public function setupWebsite()
+ {
+ $rOutputFile = fopen(CONST_InstallDir.'/settings/settings-frontend.php', 'w');
+
+ fwrite($rOutputFile, "<?php
+@define('CONST_Database_DSN', '".getSetting('DATABASE_DSN')."');
+@define('CONST_Default_Language', ".getSetting('DEFAULT_LANGUAGE', 'false').");
+@define('CONST_Log_DB', ".(getSettingBool('LOG_DB') ? 'true' : 'false').");
+@define('CONST_Log_File', ".getSetting('LOG_FILE', 'false').");
+@define('CONST_Max_Word_Frequency', '".getSetting('MAX_WORD_FREQUENCY')."');
+@define('CONST_NoAccessControl', ".(getSettingBool('CORS_NOACCESSCONTROL') ? 'true' : 'false').");
+@define('CONST_Places_Max_ID_count', ".getSetting('LOOKUP_MAX_COUNT').");
+@define('CONST_PolygonOutput_MaximumTypes', ".getSetting('POLYGON_OUTPUT_MAX_TYPES').");
+@define('CONST_Search_BatchMode', ".(getSettingBool('SEARCH_BATCH_MODE') ? 'true' : 'false').");
+@define('CONST_Search_NameOnlySearchFrequencyThreshold', ".getSetting('SEARCH_NAME_ONLY_THRESHOLD').");
+@define('CONST_Term_Normalization_Rules', \"".getSetting('TERM_NORMALIZATION')."\");
+@define('CONST_Use_Aux_Location_data', ".(getSettingBool('USE_AUX_LOCATION_DATA') ? 'true' : 'false').");
+@define('CONST_Use_US_Tiger_Data', ".(getSettingBool('USE_US_TIGER_DATA') ? 'true' : 'false').");
+@define('CONST_MapIcon_URL', ".getSetting('MAPICON_URL', 'false').');
+');
+ info(CONST_InstallDir.'/settings/settings-frontend.php has been set up successfully');
+ }
+
+ /**
+ * Return the connection to the database.
+ *
+ * @return Database object.
+ *
+ * Creates a new connection if none exists yet. Otherwise reuses the
+ * already established connection.
+ */
+ private function db()
+ {
+ if (is_null($this->oDB)) {
+ $this->oDB = new \Nominatim\DB();
+ $this->oDB->connect();
+ }
+
+ return $this->oDB;
+ }
+