become really large and should not be created or expanded by the HTML client.
Better is to let the daemon do the work.
Signed-off-by: Roland Haeder <roland@mxchange.org>
// CFG: REGION-INFO-DB-WRAPPER-CLASS
$cfg->setConfigEntry('region_info_db_wrapper_class', 'RegionInformationDatabaseWrapper');
+// CFG: REGION-MAP-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('region_map_db_wrapper_class', 'RegionMapDatabaseWrapper');
+
// CFG: CITY-INIT-STATE-CLASS
$cfg->setConfigEntry('city_init_state_class', 'CityInitState');
// CFG: CITY-MANAGER-CLASS
$cfg->setConfigEntry('city_manager_class', 'CityManager');
+// CFG: CITY-MAP-MANAGER-CLASS
+$cfg->setConfigEntry('city_map_manager_class', 'CityMapManager');
+
// CFG: REGION-MANAGER-CLASS
$cfg->setConfigEntry('region_manager_class', 'RegionManager');
+// CFG: REGION-MAP-MANAGER-CLASS
+$cfg->setConfigEntry('region_map_manager_class', 'RegionMapManager');
+
/******************************************************************************
* Console client *
******************************************************************************/
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for city-information (database) wrapper
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface CityInformationWrapper extends DatabaseWrapper {
+ /**
+ * 'Registers' a new city id along with data provided in the city instance.
+ * This may sound confusing but avoids double code very nicely...
+ *
+ * @param $cityInstance A city instance
+ * @param $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ function registerCityId (BaseCity $cityInstance, Requestable $requestInstance);
+
+ /**
+ * Checks whether there is an entry for given city instance
+ *
+ * @param $cityInstance An instance of a CityHelper class
+ * @return $isFound Whether a city id has been found for this city
+ */
+ function ifCityDataIsFound (CityHelper $cityInstance);
+
+ /**
+ * Removes non-data from given array.
+ *
+ * @param $data An array with possible non-data that needs to be removed.
+ * @return $data A cleaned up array with only data.
+ */
+ function removeNonPublicDataFromArray(array $data);
+
+ /**
+ * Checks whether the user has already founded a city
+ *
+ * @return $hasFounded Whether the user has already founded a city
+ */
+ function ifUserHasFoundedCity ();
+
+ /**
+ * Checks whether the given city name is taken
+ *
+ * @para $cityName Name of city
+ * @return $isTaken Whether the given city name is taken
+ */
+ function ifCityExists ($cityName);
+
+ /**
+ * Creates a city from given request
+ *
+ * @para $requestInstance An instance of a Requestable class
+ * @return void
+ */
+ function createCityByRequest (Requestable $requestInstance);
+}
+
+// [EOF]
+?>
+++ /dev/null
-<?php
-/**
- * An interface for city-information (database) wrapper
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface CityInformationWrapper extends DatabaseWrapper {
- /**
- * 'Registers' a new city id along with data provided in the city instance.
- * This may sound confusing but avoids double code very nicely...
- *
- * @param $cityInstance A city instance
- * @param $requestInstance An instance of a Requestable class
- * @return void
- */
- function registerCityId (BaseCity $cityInstance, Requestable $requestInstance);
-
- /**
- * Checks whether there is an entry for given city instance
- *
- * @param $cityInstance An instance of a CityHelper class
- * @return $isFound Whether a city id has been found for this city
- */
- function ifCityDataIsFound (CityHelper $cityInstance);
-
- /**
- * Removes non-data from given array.
- *
- * @param $data An array with possible non-data that needs to be removed.
- * @return $data A cleaned up array with only data.
- */
- function removeNonPublicDataFromArray(array $data);
-
- /**
- * Checks whether the user has already founded a city
- *
- * @return $hasFounded Whether the user has already founded a city
- */
- function ifUserHasFoundedCity ();
-
- /**
- * Checks whether the given city name is taken
- *
- * @para $cityName Name of city
- * @return $isTaken Whether the given city name is taken
- */
- function ifCityExists ($cityName);
-
- /**
- * Creates a city from given request
- *
- * @para $requestInstance An instance of a Requestable class
- * @return void
- */
- function createCityByRequest (Requestable $requestInstance);
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * An interface for region-information (database) wrapper
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015 City Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface RegionInformationWrapper extends DatabaseWrapper {
- /**
- * Removes non-data from given array.
- *
- * @param $data An array with possible non-data that needs to be removed.
- * @return $data A cleaned up array with only data.
- */
- function removeNonPublicDataFromArray(array $data);
-
- /**
- * Checks whether the user has already founded a region
- *
- * @return $hasFounded Whether the user has already founded a region
- */
- function ifUserHasCreatedRegion ();
-
- /**
- * Checks whether the given region name is taken
- *
- * @param $regionName Name of region
- * @return $isTaken Whether the given region name is taken
- */
- function ifRegionExists ($regionName);
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for region-information (database) wrapper
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface RegionInformationWrapper extends DatabaseWrapper {
+ /**
+ * Removes non-data from given array.
+ *
+ * @param $data An array with possible non-data that needs to be removed.
+ * @return $data A cleaned up array with only data.
+ */
+ function removeNonPublicDataFromArray(array $data);
+
+ /**
+ * Checks whether the user has already founded a region
+ *
+ * @return $hasFounded Whether the user has already founded a region
+ */
+ function ifUserHasCreatedRegion ();
+
+ /**
+ * Checks whether the given region name is taken
+ *
+ * @param $regionName Name of region
+ * @return $isTaken Whether the given region name is taken
+ */
+ function ifRegionExists ($regionName);
+
+ /**
+ * Creates a region by given name
+ *
+ * @param $regionName Name of region
+ * @return void
+ */
+ function createRegionByName ($regionName);
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An interface for region-map (database) wrapper
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface RegionMapWrapper extends DatabaseWrapper {
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An interface region map manager
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface ManageableRegionMap extends FrameworkInterface {
+ /**
+ * Creates a map, if not found yet, for given result which should contain
+ * data about the region in question
+ *
+ * @param $resultInstance Region result instance
+ * @return void
+ */
+ function createRegionMapByResult (SearchableResult $resultInstance);
+}
+
+// [EOF]
+?>
* @return $isFound Whether a city id has been found for this city
*/
public function ifCityDataIsFound (CityHelper $cityInstance) {
- // Is there cache?
- if (!isset($GLOBALS[__METHOD__])) {
- // Now get a search criteria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
- // Search for the city number one which is hard-coded the default
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
- $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $cityInstance->getRequestInstance()->getRequestElement('mode'));
- $searchInstance->setLimit(1);
+ // Search for the city number one which is hard-coded the default
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1);
+ $searchInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $cityInstance->getRequestInstance()->getRequestElement('mode'));
+ $searchInstance->setLimit(1);
- // Get a result back
- $resultInstance = $this->doSelectByCriteria($searchInstance);
+ // Get a result back
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
- // Set result instance in city instance
- $cityInstance->setResultInstance($resultInstance);
+ // Set result instance in city instance
+ $cityInstance->setResultInstance($resultInstance);
- // Is it valid?
- $GLOBALS[__METHOD__] = $resultInstance->next();
- } // END - if
+ // Is it valid?
+ $isFound = $resultInstance->next();
// Return it
- return $GLOBALS[__METHOD__];
+ return $isFound;
}
/**
--- /dev/null
+<?php
+/**
+ * A database wrapper for region maps
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class RegionMapDatabaseWrapper extends BaseDatabaseWrapper implements RegionMapWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_REGION_MAP = 'region_map';
+
+ // Constants for database column names
+ const DB_COLUMN_REGION_ID = 'region_id';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createRegionMapDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new RegionMapDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_REGION_MAP);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public function removeNonPublicDataFromArray(array $data) {
+ // Currently call only inner method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...');
+ $data = parent::removeNonPublicDataFromArray($data);
+
+ // Return cleaned data
+ return $data;
+ }
+
+ /**
+ * Creates a region by given name
+ *
+ * @return void
+ */
+ public function createRegionByName () {
+ // Pre-check
+ die(__METHOD__ . ': Unfinshed!');
+ assert(!$this->ifRegionExists($regionName));
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a dataset instance
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_MAP));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID);
+
+ // Add region name and assign user id
+ $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1));
+
+ // "Insert" this dataset instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+
+ // Post-check name
+ assert($this->ifRegionExists($regionName));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A region map manager
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 Region Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class RegionMapManager extends BaseManager implements ManageableRegionMap {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $managerInstance An instance of a ManageableRegion class
+ */
+ public final static function createRegionMapManager () {
+ // Get new instance
+ $managerInstance = new RegionMapManager();
+
+ // Get database wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('region_map_db_wrapper_class');
+
+ // And set it here
+ $managerInstance->setWrapperInstance($wrapperInstance);
+
+ // Return the prepared instance
+ return $managerInstance;
+ }
+
+ /**
+ * Creates a map, if not found yet, for given result which should contain
+ * data about the region in question
+ *
+ * @param $resultInstance Region result instance
+ * @return void
+ */
+ public function createRegionMapByResult (SearchableResult $resultInstance) {
+ die('!ok');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all