]> git.mxchange.org Git - city.git/commitdiff
Added a lot new stuff for region maps (and prepared city maps). These maps can
authorRoland Haeder <roland@mxchange.org>
Fri, 29 May 2015 06:09:26 +0000 (08:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 29 May 2015 06:09:26 +0000 (08:09 +0200)
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>
13 files changed:
application/city/config.php
application/city/interfaces/database/frontend/city/.htaccess [new file with mode: 0644]
application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php [new file with mode: 0644]
application/city/interfaces/database/frontend/class_CityInformationWrapper.php [deleted file]
application/city/interfaces/database/frontend/class_RegionInformationWrapper.php [deleted file]
application/city/interfaces/database/frontend/region/.htaccess [new file with mode: 0644]
application/city/interfaces/database/frontend/region/class_RegionInformationWrapper.php [new file with mode: 0644]
application/city/interfaces/database/frontend/region/class_RegionMapWrapper.php [new file with mode: 0644]
application/city/interfaces/manager/region/class_ManageableRegionMap.php [new file with mode: 0644]
application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php
application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php [new file with mode: 0644]
application/city/main/manager/region/class_RegionMapManager.php [new file with mode: 0644]
db/region_map/.htaccess [new file with mode: 0644]

index fba30467b393b954ce2653de31144781488060f2..6487ec087b614942b4f716d4d720967242eb1b91 100644 (file)
@@ -46,6 +46,9 @@ $cfg->setConfigEntry('city_info_db_wrapper_class', 'CityInformationDatabaseWrapp
 // 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');
 
@@ -470,9 +473,15 @@ $cfg->setConfigEntry('login_type', 'username');
 // 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                                *
  ******************************************************************************/
diff --git a/application/city/interfaces/database/frontend/city/.htaccess b/application/city/interfaces/database/frontend/city/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php b/application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php
new file mode 100644 (file)
index 0000000..9484065
--- /dev/null
@@ -0,0 +1,76 @@
+<?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]
+?>
diff --git a/application/city/interfaces/database/frontend/class_CityInformationWrapper.php b/application/city/interfaces/database/frontend/class_CityInformationWrapper.php
deleted file mode 100644 (file)
index 9484065..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?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]
-?>
diff --git a/application/city/interfaces/database/frontend/class_RegionInformationWrapper.php b/application/city/interfaces/database/frontend/class_RegionInformationWrapper.php
deleted file mode 100644 (file)
index 45d9f9f..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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]
-?>
diff --git a/application/city/interfaces/database/frontend/region/.htaccess b/application/city/interfaces/database/frontend/region/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/interfaces/database/frontend/region/class_RegionInformationWrapper.php b/application/city/interfaces/database/frontend/region/class_RegionInformationWrapper.php
new file mode 100644 (file)
index 0000000..2aa07c5
--- /dev/null
@@ -0,0 +1,58 @@
+<?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]
+?>
diff --git a/application/city/interfaces/database/frontend/region/class_RegionMapWrapper.php b/application/city/interfaces/database/frontend/region/class_RegionMapWrapper.php
new file mode 100644 (file)
index 0000000..b83e897
--- /dev/null
@@ -0,0 +1,28 @@
+<?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]
+?>
diff --git a/application/city/interfaces/manager/region/class_ManageableRegionMap.php b/application/city/interfaces/manager/region/class_ManageableRegionMap.php
new file mode 100644 (file)
index 0000000..41dca2c
--- /dev/null
@@ -0,0 +1,36 @@
+<?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]
+?>
index e5cc911d51e5b3523aca03c7aef10251b02e465f..932228052356ec01de3f5478313e9396f942603a 100644 (file)
@@ -65,28 +65,25 @@ class CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements City
         * @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;
        }
 
        /**
diff --git a/application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php b/application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..a2d215b
--- /dev/null
@@ -0,0 +1,103 @@
+<?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]
+?>
diff --git a/application/city/main/manager/region/class_RegionMapManager.php b/application/city/main/manager/region/class_RegionMapManager.php
new file mode 100644 (file)
index 0000000..516b1ba
--- /dev/null
@@ -0,0 +1,67 @@
+<?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]
+?>
diff --git a/db/region_map/.htaccess b/db/region_map/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all