From: Roland Haeder Date: Sat, 1 Aug 2015 13:11:24 +0000 (+0200) Subject: Introduced "entities" to bundle lots and sections + added some (not-used) classes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3935e544363c8cad755c75df4d20c46e6bf8d1e6;p=city.git Introduced "entities" to bundle lots and sections + added some (not-used) classes for handling city lots. 'core' updated to latest commit. Signed-off-by: Roland Haeder --- diff --git a/application/city/interfaces/database/frontend/city_entities/.htaccess b/application/city/interfaces/database/frontend/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/database/frontend/city_entities/lots/.htaccess b/application/city/interfaces/database/frontend/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/database/frontend/city_entities/lots/class_CityLotsWrapper.php b/application/city/interfaces/database/frontend/city_entities/lots/class_CityLotsWrapper.php new file mode 100644 index 0000000..7455c38 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_entities/lots/class_CityLotsWrapper.php @@ -0,0 +1,35 @@ + + * @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 . + */ +interface CityLotsWrapper extends DatabaseWrapper { + /** + * Checks if the given city id is found in lots table + * + * @param $cityId City id to check + * @return $isFound Whether the city id is found + */ + function ifCityHasLots ($cityId); +} + +// [EOF] +?> diff --git a/application/city/interfaces/database/frontend/city_entities/sections/.htaccess b/application/city/interfaces/database/frontend/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/database/frontend/city_entities/sections/class_CitySectionsWrapper.php b/application/city/interfaces/database/frontend/city_entities/sections/class_CitySectionsWrapper.php new file mode 100644 index 0000000..e96eacc --- /dev/null +++ b/application/city/interfaces/database/frontend/city_entities/sections/class_CitySectionsWrapper.php @@ -0,0 +1,43 @@ + + * @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 . + */ +interface CitySectionsWrapper extends DatabaseWrapper { + /** + * Checks if the given city id is found in sections table + * + * @param $cityId City id to check + * @return $isFound Whether the city id is found + */ + function ifCityHasSections ($cityId); + + /** + * Expands the sections table with initial data for given city id + * + * @param $cityId City id to check + * @return $ids Sections ids from initial expansion + */ + function doInitialCityExpansion ($cityId); +} + +// [EOF] +?> diff --git a/application/city/interfaces/database/frontend/city_sections/.htaccess b/application/city/interfaces/database/frontend/city_sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/interfaces/database/frontend/city_sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php b/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php deleted file mode 100644 index 6075615..0000000 --- a/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @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 . - */ -interface CitySectionsWrapper extends DatabaseWrapper { - /** - * Checks if the given city id is found in sections table - * - * @param $cityId City id to check - * @return $isFound Whether the city id is found - */ - function ifCityHasSections ($cityId); - - /** - * Expands the sections table with initial data for given city id - * - * @param $cityId City id to check - * @return void - */ - function doInitialCityExpansion ($cityId); -} - -// [EOF] -?> diff --git a/application/city/interfaces/manager/city/class_ManageableCity.php b/application/city/interfaces/manager/city/class_ManageableCity.php index 206e4d4..66d9155 100644 --- a/application/city/interfaces/manager/city/class_ManageableCity.php +++ b/application/city/interfaces/manager/city/class_ManageableCity.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface ManageableCity extends FrameworkInterface { +interface ManageableCity extends Manageable { /** * Checks whether the current user has already founded a city * diff --git a/application/city/interfaces/manager/city_entities/.htaccess b/application/city/interfaces/manager/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city_entities/class_ManageableCityEntities.php b/application/city/interfaces/manager/city_entities/class_ManageableCityEntities.php new file mode 100644 index 0000000..127201a --- /dev/null +++ b/application/city/interfaces/manager/city_entities/class_ManageableCityEntities.php @@ -0,0 +1,41 @@ + + * @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 . + */ +interface ManageableCityEntities extends Manageable { + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + */ + function isMapPendingExpansion (); + + /** + * Expands any map that requires expansion + * + * @return void + */ + function expandMaps (); +} + +// [EOF] +?> diff --git a/application/city/interfaces/manager/city_entities/lots/.htaccess b/application/city/interfaces/manager/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city_entities/lots/class_ManageableCityLots.php b/application/city/interfaces/manager/city_entities/lots/class_ManageableCityLots.php new file mode 100644 index 0000000..696727e --- /dev/null +++ b/application/city/interfaces/manager/city_entities/lots/class_ManageableCityLots.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface ManageableCityLots extends ManageableCityEntities { +} + +// [EOF] +?> diff --git a/application/city/interfaces/manager/city_entities/sections/.htaccess b/application/city/interfaces/manager/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city_entities/sections/class_ManageableCitySections.php b/application/city/interfaces/manager/city_entities/sections/class_ManageableCitySections.php new file mode 100644 index 0000000..ec8c661 --- /dev/null +++ b/application/city/interfaces/manager/city_entities/sections/class_ManageableCitySections.php @@ -0,0 +1,41 @@ + + * @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 . + */ +interface ManageableCitySections extends ManageableCityEntities { + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + */ + function isMapPendingExpansion (); + + /** + * Expands any map that requires expansion + * + * @return void + */ + function expandMaps (); +} + +// [EOF] +?> diff --git a/application/city/interfaces/manager/city_sections/.htaccess b/application/city/interfaces/manager/city_sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/interfaces/manager/city_sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/interfaces/manager/city_sections/class_ManageableCitySections.php b/application/city/interfaces/manager/city_sections/class_ManageableCitySections.php deleted file mode 100644 index e38f337..0000000 --- a/application/city/interfaces/manager/city_sections/class_ManageableCitySections.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @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 . - */ -interface ManageableCitySections extends FrameworkInterface { - /** - * Checks whether at least one map requires expansion - * - * @return $requiresExpansion Whether a map requires expansion - */ - function isMapPendingExpansion (); - - /** - * Expands any map that requires expansion - * - * @return void - */ - function expandMaps (); -} - -// [EOF] -?> diff --git a/application/city/interfaces/manager/class_Manageable.php b/application/city/interfaces/manager/class_Manageable.php new file mode 100644 index 0000000..5daf798 --- /dev/null +++ b/application/city/interfaces/manager/class_Manageable.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface Manageable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/application/city/interfaces/manager/region/class_ManageableRegion.php b/application/city/interfaces/manager/region/class_ManageableRegion.php index 1e5b7a9..9452bb6 100644 --- a/application/city/interfaces/manager/region/class_ManageableRegion.php +++ b/application/city/interfaces/manager/region/class_ManageableRegion.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface ManageableRegion extends FrameworkInterface { +interface ManageableRegion extends Manageable { /** * Checks whether the current user has already founded a region * diff --git a/application/city/interfaces/manager/region/class_ManageableRegionMap.php b/application/city/interfaces/manager/region/class_ManageableRegionMap.php index 41dca2c..e8f596a 100644 --- a/application/city/interfaces/manager/region/class_ManageableRegionMap.php +++ b/application/city/interfaces/manager/region/class_ManageableRegionMap.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface ManageableRegionMap extends FrameworkInterface { +interface ManageableRegionMap extends Manageable { /** * Creates a map, if not found yet, for given result which should contain * data about the region in question diff --git a/application/city/main/database/frontend/city_entities/.htaccess b/application/city/main/database/frontend/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/database/frontend/city_entities/lots/.htaccess b/application/city/main/database/frontend/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php b/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php new file mode 100644 index 0000000..cafd007 --- /dev/null +++ b/application/city/main/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php @@ -0,0 +1,89 @@ + + * @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 . + */ +class CityLotsDatabaseWrapper extends BaseDatabaseWrapper implements CityLotsWrapper, Registerable { + // Constants for database table names + const DB_TABLE_CITY_LOTS = 'city_lots'; + + // Section id, an referenced city id and lot id + const DB_COLUMN_CITY_ID = 'city_id'; + const DB_COLUMN_LOT_ID = 'lot_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 createCityLotsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new CityLotsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_CITY_LOTS); + + // Return the instance + return $wrapperInstance; + } + + /** + * Checks if the given city id is found in lots table + * + * @param $cityId City id to check + * @return $isFound Whether the city id is found + */ + public function ifCityHasLots ($cityId) { + // Get search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for 'city_id' + $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId); + + /* + * Only one entry is enough to find, else this query could run very\ + * long on large maps. + */ + $searchInstance->setLimit(1); + + // Execute it on database instance + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Check if there is one entry + $isFound = ($resultInstance->next() == 1); + + // Return result + return $isFound; + } +} + +// [EOF] +?> diff --git a/application/city/main/database/frontend/city_entities/sections/.htaccess b/application/city/main/database/frontend/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php b/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php new file mode 100644 index 0000000..007129d --- /dev/null +++ b/application/city/main/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php @@ -0,0 +1,125 @@ + + * @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 . + */ +class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySectionsWrapper, Registerable { + // Constants for database table names + const DB_TABLE_CITY_SECTIONS = 'city_sections'; + + // Section id, an referenced city id and lot id + const DB_COLUMN_SECTION_ID = 'city_section_id'; + const DB_COLUMN_CITY_ID = 'city_id'; + const DB_COLUMN_LOT_ID = 'lot_id'; + + // Section and sub type (e.g. residential, hut) + const DB_COLUMN_SECTION_TYPE = 'section_type'; + const DB_COLUMN_SECTION_SUB_TYPE = 'section_sub_type'; + + // X-Y-Z position + const DB_COLUMN_SECTION_POSITION_X = 'section_position_x'; + const DB_COLUMN_SECTION_POSITION_Y = 'section_position_y'; + const DB_COLUMN_SECTION_POSITION_Z = 'section_position_z'; + + // Connected neigbouring sections + const DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID = 'section_neighbour_west_id'; + const DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID = 'section_neighbour_east_id'; + const DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID = 'section_neighbour_north_id'; + const DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID = 'section_neighbour_south_id'; + const DB_COLUMN_SECTION_NEIGHBOUR_UP_ID = 'section_neighbour_up_id'; + const DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID = 'section_neighbour_down_id'; + + // Other settings: + // Reserved section (see documentation) + const DB_COLUMN_SECTION_RESERVED = 'section_reserved'; + + /** + * 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 createCitySectionsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new CitySectionsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_CITY_SECTIONS); + + // Return the instance + return $wrapperInstance; + } + + /** + * Checks if the given city id is found in sections table + * + * @param $cityId City id to check + * @return $isFound Whether the city id is found + */ + public function ifCityHasSections ($cityId) { + // Get search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for 'city_id' + $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId); + + /* + * Only one entry is enough to find, else this query could run very\ + * long on large maps. + */ + $searchInstance->setLimit(1); + + // Execute it on database instance + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Check if there is one entry + $isFound = ($resultInstance->next() == 1); + + // Return result + return $isFound; + } + + /** + * Expands the sections table with initial data for given city id + * + * @param $cityId City id to check + * @return $ids Sections ids from initial expansion + */ + public function doInitialCityExpansion ($cityId) { + // Make sure this city has no sections + assert(!$this->ifCityHasSections($cityId)); + + // @TODO Unfinished + $this->partialStub('cityId=' . $cityId . ' - UNFINISHED!'); + } +} + +// [EOF] +?> diff --git a/application/city/main/database/frontend/city_sections/.htaccess b/application/city/main/database/frontend/city_sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php b/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php deleted file mode 100644 index bb9effe..0000000 --- a/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @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 . - */ -class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySectionsWrapper, Registerable { - // Constants for database table names - const DB_TABLE_CITY_SECTIONS = 'city_sections'; - - // Section id, an referenced city id and lot id - const DB_COLUMN_SECTION_ID = 'city_section_id'; - const DB_COLUMN_CITY_ID = 'city_id'; - const DB_COLUMN_LOT_ID = 'lot_id'; - - // Section and sub type (e.g. residential, hut) - const DB_COLUMN_SECTION_TYPE = 'section_type'; - const DB_COLUMN_SECTION_SUB_TYPE = 'section_sub_type'; - - // X-Y-Z position - const DB_COLUMN_SECTION_POSITION_X = 'section_position_x'; - const DB_COLUMN_SECTION_POSITION_Y = 'section_position_y'; - const DB_COLUMN_SECTION_POSITION_Z = 'section_position_z'; - - // Connected neigbouring sections - const DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID = 'section_neighbour_west_id'; - const DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID = 'section_neighbour_east_id'; - const DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID = 'section_neighbour_north_id'; - const DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID = 'section_neighbour_south_id'; - const DB_COLUMN_SECTION_NEIGHBOUR_UP_ID = 'section_neighbour_up_id'; - const DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID = 'section_neighbour_down_id'; - - // Other settings: - // Reserved section (see documentation) - const DB_COLUMN_SECTION_RESERVED = 'section_reserved'; - - /** - * 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 createCitySectionsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new CitySectionsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_CITY_SECTIONS); - - // Return the instance - return $wrapperInstance; - } - - /** - * Checks if the given city id is found in sections table - * - * @param $cityId City id to check - * @return $isFound Whether the city id is found - */ - public function ifCityHasSections ($cityId) { - // Get search instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for 'city_id' - $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId); - - /* - * Only one entry is enough to find, else this query could run very\ - * long on large maps. - */ - $searchInstance->setLimit(1); - - // Execute it on database instance - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Check if there is one entry - $isFound = ($resultInstance->next() == 1); - - // Return result - return $isFound; - } - - /** - * Expands the sections table with initial data for given city id - * - * @param $cityId City id to check - * @return void - */ - public function doInitialCityExpansion ($cityId) { - // Make sure this city has no sections - assert(!$this->ifCityHasSections($cityId)); - - // @TODO Unfinished - $this->partialStub('cityId=' . $cityId . ' - UNFINISHED!'); - } -} - -// [EOF] -?> diff --git a/application/city/main/manager/city_entities/.htaccess b/application/city/main/manager/city_entities/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/manager/city_entities/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/manager/city_entities/lots/.htaccess b/application/city/main/manager/city_entities/lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/manager/city_entities/lots/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/manager/city_entities/lots/class_CityLotsManager.php b/application/city/main/manager/city_entities/lots/class_CityLotsManager.php new file mode 100644 index 0000000..5e25cc4 --- /dev/null +++ b/application/city/main/manager/city_entities/lots/class_CityLotsManager.php @@ -0,0 +1,101 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City 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 . + */ +class CityLotsManager extends BaseFrameworkSystem implements ManageableCityLots, Registerable { + /** + * 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 ManageableCityLots class + */ + public final static function createCityLotsManager () { + // Get new instance + $managerInstance = new CityLotsManager(); + + // Get database wrapper + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_lots_db_wrapper_class'); + + // And set it here + $managerInstance->setWrapperInstance($wrapperInstance); + + // Return the prepared instance + return $managerInstance; + } + + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + * @todo 0% done + */ + public function isMapPendingExpansion () { + // Default is no expansion is needed + $requireExpansion = FALSE; + + // First, a simple check if the lots table contains any entries at all + if ($this->getWrapperInstance()->countTotalRows() == 0) { + // This definedly requires expansion + $requireExpansion = TRUE; + } // END - if + + // Return status + return $requireExpansion; + } + + /** + * Expands any map that requires expansion + * + * @return void + * @todo 0% done + */ + public function expandMaps () { + // Get a city info wrapper instance + $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class'); + + // Get all city ids from it + $cityIds = $cityWrapperInstance->getAllCityIds(); + + // Now check all ids + foreach ($cityIds as $cityId) { + // Does this id have any lots + if (!$this->getWrapperInstance()->ifCityHasLots($cityId)) { + // Nothing found, so it is a brand-new city that needs first initialization + $sections = $this->getWrapperInstance()->doInitialCityExpansion($cityId); + } else { + // @TODO Maybe some expansion is needed + } + } // END - foreach + } +} + +// [EOF] +?> diff --git a/application/city/main/manager/city_entities/sections/.htaccess b/application/city/main/manager/city_entities/sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/manager/city_entities/sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php b/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php new file mode 100644 index 0000000..fda32de --- /dev/null +++ b/application/city/main/manager/city_entities/sections/class_CitySectionsManager.php @@ -0,0 +1,101 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City 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 . + */ +class CitySectionsManager extends BaseFrameworkSystem implements ManageableCitySections, Registerable { + /** + * 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 ManageableCitySections class + */ + public final static function createCitySectionsManager () { + // Get new instance + $managerInstance = new CitySectionsManager(); + + // Get database wrapper + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_sections_db_wrapper_class'); + + // And set it here + $managerInstance->setWrapperInstance($wrapperInstance); + + // Return the prepared instance + return $managerInstance; + } + + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + * @todo 0% done + */ + public function isMapPendingExpansion () { + // Default is no expansion is needed + $requireExpansion = FALSE; + + // First, a simple check if the sections table contains any entries at all + if ($this->getWrapperInstance()->countTotalRows() == 0) { + // This definedly requires expansion + $requireExpansion = TRUE; + } // END - if + + // Return status + return $requireExpansion; + } + + /** + * Expands any map that requires expansion + * + * @return void + * @todo 0% done + */ + public function expandMaps () { + // Get a city info wrapper instance + $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class'); + + // Get all city ids from it + $cityIds = $cityWrapperInstance->getAllCityIds(); + + // Now check all ids + foreach ($cityIds as $cityId) { + // Does this id have any sections + if (!$this->getWrapperInstance()->ifCityHasSections($cityId)) { + // Nothing found, so it is a brand-new city that needs first initialization + $sections = $this->getWrapperInstance()->doInitialCityExpansion($cityId); + } else { + // @TODO Maybe some expansion is needed + } + } // END - foreach + } +} + +// [EOF] +?> diff --git a/application/city/main/manager/city_sections/.htaccess b/application/city/main/manager/city_sections/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/manager/city_sections/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/manager/city_sections/class_CitySectionsManager.php b/application/city/main/manager/city_sections/class_CitySectionsManager.php deleted file mode 100644 index b05ab91..0000000 --- a/application/city/main/manager/city_sections/class_CitySectionsManager.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2015 City 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 . - */ -class CitySectionsManager extends BaseFrameworkSystem implements ManageableCitySections, Registerable { - /** - * 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 ManageableCitySections class - */ - public final static function createCitySectionsManager () { - // Get new instance - $managerInstance = new CitySectionsManager(); - - // Get database wrapper - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_sections_db_wrapper_class'); - - // And set it here - $managerInstance->setWrapperInstance($wrapperInstance); - - // Return the prepared instance - return $managerInstance; - } - - /** - * Checks whether at least one map requires expansion - * - * @return $requiresExpansion Whether a map requires expansion - * @todo 0% done - */ - public function isMapPendingExpansion () { - // Default is no expansion is needed - $requireExpansion = FALSE; - - // First, a simple check if the sections table contains any entries at all - if ($this->getWrapperInstance()->countTotalRows() == 0) { - // This definedly requires expansion - $requireExpansion = TRUE; - } // END - if - - // Return status - return $requireExpansion; - } - - /** - * Expands any map that requires expansion - * - * @return void - * @todo 0% done - */ - public function expandMaps () { - // Get a city info wrapper instance - $cityWrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class'); - - // Get all city ids from it - $cityIds = $cityWrapperInstance->getAllCityIds(); - - // Now check all ids - foreach ($cityIds as $cityId) { - // Does this id have any sections - if (!$this->getWrapperInstance()->ifCityHasSections($cityId)) { - // Nothing found, so it is a brand-new city that needs first initialization - $this->getWrapperInstance()->doInitialCityExpansion($cityId); - } else { - // @TODO Maybe some expansion is needed - } - } // END - foreach - } -} - -// [EOF] -?> diff --git a/application/city/main/manager/class_BaseManager.php b/application/city/main/manager/class_BaseManager.php index 69de06b..ec3e690 100644 --- a/application/city/main/manager/class_BaseManager.php +++ b/application/city/main/manager/class_BaseManager.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseManager extends BaseCitySystem implements Registerable { +class BaseManager extends BaseCitySystem implements Manageable, Registerable { /** * Protected constructor * diff --git a/core b/core index d939a8d..23aa45d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d939a8df01d12151255dc67950f1336fa215e2ab +Subproject commit 23aa45d4a6205e26184190ca446316d06a9b4648 diff --git a/db/city_lots/.htaccess b/db/city_lots/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/db/city_lots/.htaccess @@ -0,0 +1 @@ +Deny from all