From 647bd7db586468e1dee49eda6ee14cddc7b4aab5 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 15 Dec 2019 22:27:17 +0100 Subject: [PATCH] - BC Break: _PHP_ namespaces changed (PSR-4 standard). The _root_ namespace for all _PF_ related scripts is `Exodus4D\Pathfinder` - BC Break: Project folder structure changed. Removed `app/main` dir. - BC Break: Core _PHP_ framework + dependencies moved into `composer.json` and are no longer part of this repo --- README.md | 89 +- .../AccessController.php} | 4 +- .../admin.php => Controller/Admin.php} | 14 +- .../access.php => Controller/Api/Access.php} | 6 +- .../github.php => Controller/Api/GitHub.php} | 7 +- .../api/map.php => Controller/Api/Map.php} | 40 +- .../Api/Rest/AbstractRestController.php} | 4 +- .../Api/Rest/Connection.php} | 5 +- .../log.php => Controller/Api/Rest/Log.php} | 5 +- .../Api/Rest/Signature.php} | 4 +- .../Api/Rest/SignatureHistory.php} | 6 +- .../Api/Rest/Structure.php} | 4 +- .../Api/Rest/System.php} | 4 +- .../route.php => Controller/Api/Route.php} | 14 +- .../setup.php => Controller/Api/Setup.php} | 10 +- .../Api/Statistic.php} | 8 +- .../system.php => Controller/Api/System.php} | 8 +- .../Api/Universe.php} | 8 +- .../api/user.php => Controller/Api/User.php} | 22 +- .../AppController.php} | 9 +- .../ccp/sso.php => Controller/Ccp/Sso.php} | 10 +- .../Ccp/Universe.php} | 10 +- app/Controller/Controller.php | 1001 ++++++++++++++ .../LogController.php} | 8 +- .../MapController.php} | 6 +- .../setup.php => Controller/Setup.php} | 60 +- .../controller => Controller}/controller.php | 0 .../AbstractCron.php} | 6 +- app/{main/cron/cache.php => Cron/Cache.php} | 4 +- .../CcpSystemsUpdate.php} | 12 +- .../CharacterUpdate.php} | 4 +- .../maphistory.php => Cron/MapHistory.php} | 8 +- .../cron/mapupdate.php => Cron/MapUpdate.php} | 6 +- .../StatisticsUpdate.php} | 2 +- .../cron/universe.php => Cron/Universe.php} | 5 +- .../File/FileHandler.php} | 2 +- .../File/ReverseSplFileObject.php} | 2 +- .../search.php => Data/Filesystem/Search.php} | 2 +- .../Mapper/AbstractIterator.php} | 15 +- .../Mapper/SortingIterator.php} | 2 +- .../session.php => Db/Sql/Mysql/Session.php} | 11 +- .../mysql => Db/Sql/Mysql}/tablemodifier.php | 15 +- .../ConfigException.php} | 5 +- .../DatabaseException.php} | 10 +- .../DateException.php} | 6 +- .../PathfinderException.php} | 10 +- .../RegistrationException.php} | 10 +- .../ValidationException.php} | 10 +- .../lib/api => Lib/Api}/AbstractClient.php | 14 +- app/{main/lib/api => Lib/Api}/CcpClient.php | 4 +- .../lib/api => Lib/Api}/EveScoutClient.php | 4 +- .../lib/api => Lib/Api}/GitHubClient.php | 4 +- app/{main/lib/api => Lib/Api}/SsoClient.php | 4 +- app/{main/lib/config.php => Lib/Config.php} | 19 +- app/{main/lib => Lib}/Cron.php | 4 +- app/{main/lib => Lib}/DateRange.php | 4 +- app/{main/lib/db => Lib/Db}/Pool.php | 26 +- app/{main/lib/db/SQL.php => Lib/Db/Sql.php} | 4 +- app/{main/lib/format => Lib/Format}/Image.php | 4 +- .../lib/format => Lib/Format}/Number.php | 0 .../Logging}/AbstractChannelLog.php | 2 +- .../Logging}/AbstractCharacterLog.php | 6 +- .../logging => Lib/Logging}/AbstractLog.php | 4 +- .../lib/logging => Lib/Logging}/ApiLog.php | 11 +- .../logging => Lib/Logging}/DefaultLog.php | 2 +- .../Logging/Formatter}/MailFormatter.php | 12 +- .../Handler}/AbstractMapWebhookHandler.php | 4 +- .../Handler}/AbstractRallyWebhookHandler.php | 7 +- .../Handler}/AbstractWebhookHandler.php | 4 +- .../Handler}/DiscordMapWebhookHandler.php | 2 +- .../Handler}/DiscordRallyWebhookHandler.php | 6 +- .../Handler}/SlackMapWebhookHandler.php | 4 +- .../Handler}/SlackRallyWebhookHandler.php | 5 +- .../Logging/Handler}/SocketHandler.php | 9 +- .../logging => Lib/Logging}/LogCollection.php | 6 +- .../logging => Lib/Logging}/LogInterface.php | 2 +- .../lib/logging => Lib/Logging}/MapLog.php | 11 +- .../lib/logging => Lib/Logging}/RallyLog.php | 12 +- .../lib/logging => Lib/Logging}/UserLog.php | 8 +- app/{main/lib => Lib}/Monolog.php | 18 +- app/{main/lib => Lib}/PriorityCacheStore.php | 2 +- .../lib/resource.php => Lib/Resource.php} | 2 +- .../socket => Lib/Socket}/AbstractSocket.php | 6 +- .../lib/socket => Lib/Socket}/NullSocket.php | 2 +- .../socket => Lib/Socket}/SocketInterface.php | 3 +- .../lib/socket => Lib/Socket}/TcpSocket.php | 2 +- app/{main/lib/util.php => Lib/Util.php} | 3 +- app/Model/AbstractModel.php | 1156 +++++++++++++++++ .../Pathfinder/AbstractMapTrackingModel.php} | 9 +- .../Pathfinder/AbstractPathfinderModel.php | 112 ++ .../AbstractSystemApiBasicModel.php} | 2 +- .../Pathfinder/ActivityLogModel.php} | 19 +- .../Pathfinder/AllianceMapModel.php} | 6 +- .../Pathfinder/AllianceModel.php} | 8 +- .../CharacterAuthenticationModel.php} | 12 +- .../Pathfinder/CharacterLogModel.php} | 4 +- .../Pathfinder/CharacterMapModel.php} | 12 +- .../Pathfinder/CharacterModel.php} | 24 +- .../Pathfinder/CharacterStatusModel.php} | 11 +- .../Pathfinder/ConnectionLogModel.php} | 10 +- .../Pathfinder/ConnectionModel.php} | 30 +- .../Pathfinder/ConnectionScopeModel.php} | 12 +- .../Pathfinder/CorporationMapModel.php} | 6 +- .../Pathfinder/CorporationModel.php} | 14 +- .../Pathfinder/CorporationRightModel.php} | 8 +- .../Pathfinder/CorporationStructureModel.php} | 6 +- .../Pathfinder/CronModel.php} | 7 +- .../Pathfinder/LogModelInterface.php} | 2 +- .../Pathfinder/MapModel.php} | 55 +- .../Pathfinder/MapScopeModel.php} | 11 +- .../Pathfinder/MapTypeModel.php} | 11 +- .../Pathfinder/RightModel.php} | 4 +- .../Pathfinder/RoleModel.php} | 13 +- .../Pathfinder/StructureModel.php} | 10 +- .../Pathfinder/StructureStatusModel.php} | 4 +- .../Pathfinder/SystemFactionKillModel.php} | 2 +- .../Pathfinder/SystemJumpModel.php} | 2 +- .../Pathfinder/SystemModel.php} | 34 +- .../Pathfinder/SystemPodKillModel.php} | 2 +- .../Pathfinder/SystemShipKillModel.php} | 2 +- .../Pathfinder/SystemSignatureModel.php} | 15 +- .../Pathfinder/SystemStatusModel.php} | 11 +- .../Pathfinder/SystemTypeModel.php} | 2 +- .../Pathfinder/UserCharacterModel.php} | 12 +- .../Pathfinder/UserModel.php} | 20 +- .../Pathfinder}/abstractpathfindermodel.php | 0 .../Universe/AllianceModel.php} | 8 +- .../Universe/CategoryModel.php} | 10 +- .../Universe/ConstellationModel.php} | 8 +- .../Universe/CorporationModel.php} | 10 +- .../Universe/DogmaAttributeModel.php} | 4 +- .../Universe/FactionModel.php} | 14 +- .../Universe/FactionWarSystemModel.php} | 8 +- .../Universe/GroupModel.php} | 6 +- .../Universe/PlanetModel.php} | 12 +- .../Universe/RaceModel.php} | 6 +- .../Universe/RegionModel.php} | 6 +- .../Universe/SovereigntyMapModel.php} | 10 +- .../Universe/StarModel.php} | 6 +- .../Universe/StargateModel.php} | 14 +- .../Universe/StationModel.php} | 10 +- .../Universe/StructureModel.php} | 6 +- .../Universe/SystemModel.php} | 22 +- .../Universe/SystemNeighbourModel.php} | 8 +- .../Universe/SystemStaticModel.php} | 6 +- .../Universe/TypeAttributeModel.php} | 6 +- .../Universe/TypeModel.php} | 22 +- .../Universe}/abstractuniversemodel.php | 4 +- app/{main/model => Model}/abstractmodel.php | 0 app/config.ini | 8 +- app/routes.ini | 22 +- composer-dev.json | 4 +- composer.json | 6 +- index.php | 8 +- public/templates/ui/jsonld.html | 2 +- 155 files changed, 3085 insertions(+), 610 deletions(-) rename app/{main/controller/accesscontroller.php => Controller/AccessController.php} (97%) rename app/{main/controller/admin.php => Controller/Admin.php} (97%) rename app/{main/controller/api/access.php => Controller/Api/Access.php} (93%) rename app/{main/controller/api/github.php => Controller/Api/GitHub.php} (95%) rename app/{main/controller/api/map.php => Controller/Api/Map.php} (98%) rename app/{main/controller/api/rest/abstractrestcontroller.php => Controller/Api/Rest/AbstractRestController.php} (93%) rename app/{main/controller/api/rest/connection.php => Controller/Api/Rest/Connection.php} (97%) rename app/{main/controller/api/rest/log.php => Controller/Api/Rest/Log.php} (96%) rename app/{main/controller/api/rest/signature.php => Controller/Api/Rest/Signature.php} (98%) rename app/{main/controller/api/rest/signaturehistory.php => Controller/Api/Rest/SignatureHistory.php} (97%) rename app/{main/controller/api/rest/structure.php => Controller/Api/Rest/Structure.php} (97%) rename app/{main/controller/api/rest/system.php => Controller/Api/Rest/System.php} (98%) rename app/{main/controller/api/route.php => Controller/Api/Route.php} (99%) rename app/{main/controller/api/setup.php => Controller/Api/Setup.php} (98%) rename app/{main/controller/api/statistic.php => Controller/Api/Statistic.php} (98%) rename app/{main/controller/api/system.php => Controller/Api/System.php} (97%) rename app/{main/controller/api/universe.php => Controller/Api/Universe.php} (96%) rename app/{main/controller/api/user.php => Controller/Api/User.php} (97%) rename app/{main/controller/appcontroller.php => Controller/AppController.php} (92%) rename app/{main/controller/ccp/sso.php => Controller/Ccp/Sso.php} (99%) rename app/{main/controller/ccp/universe.php => Controller/Ccp/Universe.php} (98%) create mode 100644 app/Controller/Controller.php rename app/{main/controller/logcontroller.php => Controller/LogController.php} (97%) rename app/{main/controller/mapcontroller.php => Controller/MapController.php} (86%) rename app/{main/controller/setup.php => Controller/Setup.php} (98%) rename app/{main/controller => Controller}/controller.php (100%) rename app/{main/cron/abstractcron.php => Cron/AbstractCron.php} (98%) rename app/{main/cron/cache.php => Cron/Cache.php} (96%) rename app/{main/cron/ccpsystemsupdate.php => Cron/CcpSystemsUpdate.php} (97%) rename app/{main/cron/characterupdate.php => Cron/CharacterUpdate.php} (98%) rename app/{main/cron/maphistory.php => Cron/MapHistory.php} (96%) rename app/{main/cron/mapupdate.php => Cron/MapUpdate.php} (98%) rename app/{main/cron/statisticsupdate.php => Cron/StatisticsUpdate.php} (97%) rename app/{main/cron/universe.php => Cron/Universe.php} (99%) rename app/{main/data/file/filehandler.php => Data/File/FileHandler.php} (98%) rename app/{main/data/file/reversesplfileobject.php => Data/File/ReverseSplFileObject.php} (99%) rename app/{main/data/filesystem/search.php => Data/Filesystem/Search.php} (98%) rename app/{main/data/mapper/abstractiterator.php => Data/Mapper/AbstractIterator.php} (92%) rename app/{main/data/mapper/sortingiterator.php => Data/Mapper/SortingIterator.php} (89%) rename app/{main/db/sql/mysql/session.php => Db/Sql/Mysql/Session.php} (84%) rename app/{main/db/sql/mysql => Db/Sql/Mysql}/tablemodifier.php (96%) rename app/{main/exception/configexception.php => Exception/ConfigException.php} (72%) rename app/{main/exception/databaseexception.php => Exception/DatabaseException.php} (65%) rename app/{main/exception/dateexception.php => Exception/DateException.php} (74%) rename app/{main/exception/pathfinderexception.php => Exception/PathfinderException.php} (89%) rename app/{main/exception/registrationexception.php => Exception/RegistrationException.php} (77%) rename app/{main/exception/validationexception.php => Exception/ValidationException.php} (78%) rename app/{main/lib/api => Lib/Api}/AbstractClient.php (97%) rename app/{main/lib/api => Lib/Api}/CcpClient.php (93%) rename app/{main/lib/api => Lib/Api}/EveScoutClient.php (91%) rename app/{main/lib/api => Lib/Api}/GitHubClient.php (93%) rename app/{main/lib/api => Lib/Api}/SsoClient.php (91%) rename app/{main/lib/config.php => Lib/Config.php} (98%) rename app/{main/lib => Lib}/Cron.php (98%) rename app/{main/lib => Lib}/DateRange.php (92%) rename app/{main/lib/db => Lib/Db}/Pool.php (92%) rename app/{main/lib/db/SQL.php => Lib/Db/Sql.php} (97%) rename app/{main/lib/format => Lib/Format}/Image.php (96%) rename app/{main/lib/format => Lib/Format}/Number.php (100%) rename app/{main/lib/logging => Lib/Logging}/AbstractChannelLog.php (98%) rename app/{main/lib/logging => Lib/Logging}/AbstractCharacterLog.php (93%) rename app/{main/lib/logging => Lib/Logging}/AbstractLog.php (99%) rename app/{main/lib/logging => Lib/Logging}/ApiLog.php (81%) rename app/{main/lib/logging => Lib/Logging}/DefaultLog.php (83%) rename app/{main/lib/logging/formatter => Lib/Logging/Formatter}/MailFormatter.php (84%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/AbstractMapWebhookHandler.php (97%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/AbstractRallyWebhookHandler.php (98%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/AbstractWebhookHandler.php (98%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/DiscordMapWebhookHandler.php (76%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/DiscordRallyWebhookHandler.php (78%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/SlackMapWebhookHandler.php (76%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/SlackRallyWebhookHandler.php (76%) rename app/{main/lib/logging/handler => Lib/Logging/Handler}/SocketHandler.php (85%) rename app/{main/lib/logging => Lib/Logging}/LogCollection.php (97%) rename app/{main/lib/logging => Lib/Logging}/LogInterface.php (97%) rename app/{main/lib/logging => Lib/Logging}/MapLog.php (95%) rename app/{main/lib/logging => Lib/Logging}/RallyLog.php (92%) rename app/{main/lib/logging => Lib/Logging}/UserLog.php (78%) rename app/{main/lib => Lib}/Monolog.php (92%) rename app/{main/lib => Lib}/PriorityCacheStore.php (98%) rename app/{main/lib/resource.php => Lib/Resource.php} (99%) rename app/{main/lib/socket => Lib/Socket}/AbstractSocket.php (99%) rename app/{main/lib/socket => Lib/Socket}/NullSocket.php (94%) rename app/{main/lib/socket => Lib/Socket}/SocketInterface.php (93%) rename app/{main/lib/socket => Lib/Socket}/TcpSocket.php (91%) rename app/{main/lib/util.php => Lib/Util.php} (99%) create mode 100644 app/Model/AbstractModel.php rename app/{main/model/pathfinder/abstractmaptrackingmodel.php => Model/Pathfinder/AbstractMapTrackingModel.php} (90%) create mode 100644 app/Model/Pathfinder/AbstractPathfinderModel.php rename app/{main/model/pathfinder/abstractsystemapibasicmodel.php => Model/Pathfinder/AbstractSystemApiBasicModel.php} (98%) rename app/{main/model/pathfinder/activitylogmodel.php => Model/Pathfinder/ActivityLogModel.php} (92%) rename app/{main/model/pathfinder/alliancemapmodel.php => Model/Pathfinder/AllianceMapModel.php} (88%) rename app/{main/model/pathfinder/alliancemodel.php => Model/Pathfinder/AllianceModel.php} (93%) rename app/{main/model/pathfinder/characterauthenticationmodel.php => Model/Pathfinder/CharacterAuthenticationModel.php} (87%) rename app/{main/model/pathfinder/characterlogmodel.php => Model/Pathfinder/CharacterLogModel.php} (98%) rename app/{main/model/pathfinder/charactermapmodel.php => Model/Pathfinder/CharacterMapModel.php} (84%) rename app/{main/model/pathfinder/charactermodel.php => Model/Pathfinder/CharacterModel.php} (98%) rename app/{main/model/pathfinder/characterstatusmodel.php => Model/Pathfinder/CharacterStatusModel.php} (87%) rename app/{main/model/pathfinder/connectionlogmodel.php => Model/Pathfinder/ConnectionLogModel.php} (94%) rename app/{main/model/pathfinder/connectionmodel.php => Model/Pathfinder/ConnectionModel.php} (93%) rename app/{main/model/pathfinder/connectionscopemodel.php => Model/Pathfinder/ConnectionScopeModel.php} (91%) rename app/{main/model/pathfinder/corporationmapmodel.php => Model/Pathfinder/CorporationMapModel.php} (87%) rename app/{main/model/pathfinder/corporationmodel.php => Model/Pathfinder/CorporationModel.php} (94%) rename app/{main/model/pathfinder/corporationrightmodel.php => Model/Pathfinder/CorporationRightModel.php} (89%) rename app/{main/model/pathfinder/corporationstructuremodel.php => Model/Pathfinder/CorporationStructureModel.php} (86%) rename app/{main/model/pathfinder/cronmodel.php => Model/Pathfinder/CronModel.php} (98%) rename app/{main/model/pathfinder/logmodelinterface.php => Model/Pathfinder/LogModelInterface.php} (84%) rename app/{main/model/pathfinder/mapmodel.php => Model/Pathfinder/MapModel.php} (96%) rename app/{main/model/pathfinder/mapscopemodel.php => Model/Pathfinder/MapScopeModel.php} (88%) rename app/{main/model/pathfinder/maptypemodel.php => Model/Pathfinder/MapTypeModel.php} (93%) rename app/{main/model/pathfinder/rightmodel.php => Model/Pathfinder/RightModel.php} (92%) rename app/{main/model/pathfinder/rolemodel.php => Model/Pathfinder/RoleModel.php} (91%) rename app/{main/model/pathfinder/structuremodel.php => Model/Pathfinder/StructureModel.php} (95%) rename app/{main/model/pathfinder/structurestatusmodel.php => Model/Pathfinder/StructureStatusModel.php} (93%) rename app/{main/model/pathfinder/systemfactionkillmodel.php => Model/Pathfinder/SystemFactionKillModel.php} (92%) rename app/{main/model/pathfinder/systemjumpmodel.php => Model/Pathfinder/SystemJumpModel.php} (92%) rename app/{main/model/pathfinder/systemmodel.php => Model/Pathfinder/SystemModel.php} (96%) rename app/{main/model/pathfinder/systempodkillmodel.php => Model/Pathfinder/SystemPodKillModel.php} (92%) rename app/{main/model/pathfinder/systemshipkillmodel.php => Model/Pathfinder/SystemShipKillModel.php} (92%) rename app/{main/model/pathfinder/systemsignaturemodel.php => Model/Pathfinder/SystemSignatureModel.php} (95%) rename app/{main/model/pathfinder/systemstatusmodel.php => Model/Pathfinder/SystemStatusModel.php} (94%) rename app/{main/model/pathfinder/systemtypemodel.php => Model/Pathfinder/SystemTypeModel.php} (96%) rename app/{main/model/pathfinder/usercharactermodel.php => Model/Pathfinder/UserCharacterModel.php} (87%) rename app/{main/model/pathfinder/usermodel.php => Model/Pathfinder/UserModel.php} (96%) rename app/{main/model/pathfinder => Model/Pathfinder}/abstractpathfindermodel.php (100%) rename app/{main/model/universe/alliancemodel.php => Model/Universe/AllianceModel.php} (88%) rename app/{main/model/universe/categorymodel.php => Model/Universe/CategoryModel.php} (96%) rename app/{main/model/universe/constellationmodel.php => Model/Universe/ConstellationModel.php} (89%) rename app/{main/model/universe/corporationmodel.php => Model/Universe/CorporationModel.php} (89%) rename app/{main/model/universe/dogmaattributemodel.php => Model/Universe/DogmaAttributeModel.php} (94%) rename app/{main/model/universe/factionmodel.php => Model/Universe/FactionModel.php} (76%) rename app/{main/model/universe/factionwarsystemmodel.php => Model/Universe/FactionWarSystemModel.php} (90%) rename app/{main/model/universe/groupmodel.php => Model/Universe/GroupModel.php} (95%) rename app/{main/model/universe/planetmodel.php => Model/Universe/PlanetModel.php} (90%) rename app/{main/model/universe/racemodel.php => Model/Universe/RaceModel.php} (89%) rename app/{main/model/universe/regionmodel.php => Model/Universe/RegionModel.php} (89%) rename app/{main/model/universe/sovereigntymapmodel.php => Model/Universe/SovereigntyMapModel.php} (85%) rename app/{main/model/universe/starmodel.php => Model/Universe/StarModel.php} (92%) rename app/{main/model/universe/stargatemodel.php => Model/Universe/StargateModel.php} (92%) rename app/{main/model/universe/stationmodel.php => Model/Universe/StationModel.php} (92%) rename app/{main/model/universe/structuremodel.php => Model/Universe/StructureModel.php} (94%) rename app/{main/model/universe/systemmodel.php => Model/Universe/SystemModel.php} (94%) rename app/{main/model/universe/systemneighbourmodel.php => Model/Universe/SystemNeighbourModel.php} (87%) rename app/{main/model/universe/systemstaticmodel.php => Model/Universe/SystemStaticModel.php} (89%) rename app/{main/model/universe/typeattributemodel.php => Model/Universe/TypeAttributeModel.php} (90%) rename app/{main/model/universe/typemodel.php => Model/Universe/TypeModel.php} (93%) rename app/{main/model/universe => Model/Universe}/abstractuniversemodel.php (98%) rename app/{main/model => Model}/abstractmodel.php (100%) diff --git a/README.md b/README.md index bdf15843..9c75b8a3 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,16 @@ # ![Pathfinder logo](favicon/favicon-32x32.png "Logo") *PATHFINDER* -Mapping tool for [*EVE ONLINE*](https://www.eveonline.com) +#### Mapping tool for [*EVE ONLINE*](https://www.eveonline.com) - Project URL [https://www.pathfinder-w.space](https://www.pathfinder-w.space) -- Official forum post [https://forums.eveonline.com](https://forums.eveonline.com/default.aspx?g=posts&m=6021776#post6021776) - Screenshots [imgur.com](http://imgur.com/a/k2aVa) - Videos [youtube.com](https://www.youtube.com/channel/UC7HU7XEoMbqRwqxDTbMjSPg) - Licence [MIT](http://opensource.org/licenses/MIT) #### Development -- Test server - - URL: http://www.dev.pathfinder-w.space +- Test server: [https://www.dev.pathfinder-w.space](https://www.dev.pathfinder-w.space) - Running current `develop` branch - _SISI_ _ESI_ (make sure to use your test-server client) - - Available for public testing (e.g. new feature,.. ) + - Available for public testing (e.g. new feature,… ) - Database will be cleared from time to time - Installation guide: - [wiki](https://github.com/exodus4d/pathfinder/wiki) @@ -29,49 +27,48 @@ Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/ ### Project structure ``` - |-- [0755] app/ --> backend [*.php] - |-- app/ --> "Fat Free Framework" extensions - |-- lib/ --> "Fat Free Framework" - |-- main/ --> "PATHFINDER" root - |-- config.ini --> config "f3" framework - |-- cron.ini --> config - cronjobs - |-- environment.ini --> config - system environment - |-- pathfinder.ini --> config - pathfinder - |-- requirements.ini --> config - system requirements - |-- routes.ini --> config - routes - |-- [0755] export/ --> static data - |-- csv/ --> *.csv used by /setup page - |-- sql/ --> DB dump for import (eve_universe.sql.zip) - |-- [0755] favicon/ --> Favicons - |-- [0777] history/ --> log files (map history logs) [optional] - |-- [0755] js/ --> JS source files - |-- app/ --> "PASTHFINDER" core files (not used for production) - |-- lib/ --> 3rd partie extension/library (not used for production) - |-- app.js --> require.js config (!required for production!) - |-- [0777] logs/ --> log files - |-- ... - |-- node_modules/ --> node.js modules (not used for production) - |-- ... - |-- [0755] public/ --> frontend source - |-- css/ --> CSS dist/build folder (minified) - |-- fonts/ --> (icon)-Fonts - |-- img/ --> images - |-- js/ --> JS dist/build folder and source maps (minified, uglified) - |-- templates/ --> templates - |-- sass/ --> SCSS source (not used for production) - |-- [0777] tmp/ --> cache folder - |-- [0755] .htaccess --> reroute/caching rules ("Apache" only!) - |-- [0755] index.php + ─╮ + ├─ app/ [0755] → "PATHFINDER" root + │ ├─ config.ini → config "f3" framework + │ ├─ cron.ini → config - cronjobs + │ ├─ environment.ini → config - system environment + │ ├─ pathfinder.ini → config - pathfinder + │ ├─ requirements.ini → config - system requirements + │ └─ routes.ini → config - routes + ├─ export/ [0755] → static data + │ ├─ csv/ → *.csv used by /setup page + │ └─ sql/ → DB dump for import (eve_universe.sql.zip) + ├─ favicon/ [0755] → favicons + ├─ history/ [0777] → log files (map history logs) [optional] + ├─ js/ [0755] → JS source files (not used for production) + │ ├─ app/ → "PATHFINDER" core files + │ ├─ lib/ → 3rd party libs + │ └─ app.js → require.js config + ├─ logs/ [0777] → log files + │ └─ … + ├─ node_modules/ → node.js modules (not used for production) + │ └─ … + ├─ public/ [0755] → static resources + │ ├─ css/ → CSS dist/build folder (minified) + │ ├─ fonts/ → icon-/fonts + │ ├─ img/ → images + │ ├─ js/ → JS dist/build folder and source maps (minified, uglified) + │ └─ templates/ → templates + ├─ sass/ → SCSS sources (not used for production) + ├─ tmp/ [0777] → cache folder (PHP templates) + │ └─ cache/ [0777] → cache folder (PHP cache) + ├─ .htaccess [0755] → reroute/caching rules ("Apache" only!) + └─ index.php [0755] - -------------------------- + ━━━━━━━━━━━━━━━━━━━━━━━━━━ CI/CD config files: - -------------------------- - |-- .jshintrc --> "JSHint" config (not used for production) - |-- composer.json --> Composer package definition - |-- config.rb --> "Compass" config (not used for production) - |-- gulpfile.js --> "Gulp" task config (not used for production ) - |-- package.json --> "Node.js" dependency config (not used for production) - |-- README.md --> This file :) (not used for production) + + ├─ .jshintrc → "JSHint" config (not used for production) + ├─ composer.json → "Composer" package definition + ├─ config.rb → "Compass" config (not used for production) + ├─ gulpfile.js → "Gulp" task config (not used for production) + ├─ package.json → "Node.js" dependency config (not used for production) + └─ README.md → This file :) (not used for production) ``` *** diff --git a/app/main/controller/accesscontroller.php b/app/Controller/AccessController.php similarity index 97% rename from app/main/controller/accesscontroller.php rename to app/Controller/AccessController.php index ab2dca79..7d4d9ce8 100644 --- a/app/main/controller/accesscontroller.php +++ b/app/Controller/AccessController.php @@ -6,10 +6,10 @@ * Time: 23:30 */ -namespace Controller; +namespace Exodus4D\Pathfinder\Controller; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; class AccessController extends Controller { diff --git a/app/main/controller/admin.php b/app/Controller/Admin.php similarity index 97% rename from app/main/controller/admin.php rename to app/Controller/Admin.php index 7c9670df..d1f0b977 100644 --- a/app/main/controller/admin.php +++ b/app/Controller/Admin.php @@ -6,15 +6,15 @@ * Time: 20:30 */ -namespace Controller; +namespace Exodus4D\Pathfinder\Controller; -use Controller\Ccp\Sso; -use lib\Config; -use Model\Pathfinder\CharacterModel; -use Model\Pathfinder\CorporationModel; -use Model\Pathfinder\MapModel; -use Model\Pathfinder\RoleModel; +use Exodus4D\Pathfinder\Controller\Ccp\Sso; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel; +use Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel; +use Exodus4D\Pathfinder\Model\Pathfinder\MapModel; +use Exodus4D\Pathfinder\Model\Pathfinder\RoleModel; class Admin extends Controller{ diff --git a/app/main/controller/api/access.php b/app/Controller/Api/Access.php similarity index 93% rename from app/main/controller/api/access.php rename to app/Controller/Api/Access.php index 01ad9bc2..d1ca15f0 100644 --- a/app/main/controller/api/access.php +++ b/app/Controller/Api/Access.php @@ -6,10 +6,10 @@ * Time: 17:42 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Model\Pathfinder; class Access extends Controller\AccessController { diff --git a/app/main/controller/api/github.php b/app/Controller/Api/GitHub.php similarity index 95% rename from app/main/controller/api/github.php rename to app/Controller/Api/GitHub.php index 2967b9e6..211d1f3c 100644 --- a/app/main/controller/api/github.php +++ b/app/Controller/Api/GitHub.php @@ -7,12 +7,11 @@ * Time: 03:34 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use lib\Config; -use Controller; - +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; /** * Github controller diff --git a/app/main/controller/api/map.php b/app/Controller/Api/Map.php similarity index 98% rename from app/main/controller/api/map.php rename to app/Controller/Api/Map.php index 1fa570a2..2abd9224 100644 --- a/app/main/controller/api/map.php +++ b/app/Controller/Api/Map.php @@ -6,15 +6,15 @@ * Time: 20:23 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use data\file\FileHandler; -use lib\Config; -use Model\AbstractModel; -use Model\Pathfinder; -use Model\Universe; -use Exception; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Data\File\FileHandler; +use Exodus4D\Pathfinder\Model\AbstractModel; +use Exodus4D\Pathfinder\Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Universe; +use Exodus4D\Pathfinder\Exception; /** * Map controller @@ -49,7 +49,7 @@ class Map extends Controller\AccessController { /** * Get all required static config data for program initialization * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function initData(\Base $f3){ $validInitData = true; @@ -272,7 +272,7 @@ class Map extends Controller\AccessController { /** * import new map data * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function import(\Base $f3){ $importData = (array)$f3->get('POST'); @@ -433,7 +433,7 @@ class Map extends Controller\AccessController { /** * save a new map or update an existing map * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function save(\Base $f3){ $formData = (array)$f3->get('POST.formData'); @@ -619,7 +619,7 @@ class Map extends Controller\AccessController { /** * delete a map and all dependencies * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function delete(\Base $f3){ $mapData = (array)$f3->get('POST.mapData'); @@ -653,7 +653,7 @@ class Map extends Controller\AccessController { * broadcast characters with map access rights to WebSocket server * -> if characters with map access found -> broadcast mapData to them * @param Pathfinder\MapModel $map - * @throws Exception + * @throws \Exception */ protected function broadcastMapAccess(Pathfinder\MapModel $map){ $mapAccess = [ @@ -682,7 +682,7 @@ class Map extends Controller\AccessController { * get map access tokens for current character * -> send access tokens via TCP Socket for WebSocket auth * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function getAccessData(\Base $f3){ $return = (object) []; @@ -827,7 +827,7 @@ class Map extends Controller\AccessController { * update map data * -> function is called continuously (trigger) by any active client * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function updateData(\Base $f3){ $postData = (array)$f3->get('POST'); @@ -851,7 +851,7 @@ class Map extends Controller\AccessController { * onUnload map sync * @see https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function updateUnloadData(\Base $f3){ $postData = (array)$f3->get('POST'); @@ -870,7 +870,7 @@ class Map extends Controller\AccessController { * update map data api * -> function is called continuously by any active client * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function updateUserData(\Base $f3){ $postData = (array)$f3->get('POST'); @@ -941,7 +941,7 @@ class Map extends Controller\AccessController { * @param Pathfinder\CharacterModel $character * @param array $newSystemPositions * @return Pathfinder\MapModel - * @throws Exception + * @throws \Exception */ protected function updateMapByCharacter(Pathfinder\MapModel $map, Pathfinder\CharacterModel $character, array $newSystemPositions = []) : Pathfinder\MapModel { // map changed. update cache (system/connection) changed @@ -1207,7 +1207,7 @@ class Map extends Controller\AccessController { /** * get connectionData * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function getConnectionData(\Base $f3){ $postData = (array)$f3->get('POST'); @@ -1258,7 +1258,7 @@ class Map extends Controller\AccessController { /** * get map log data * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function getLogData(\Base $f3){ $postData = (array)$f3->get('POST'); diff --git a/app/main/controller/api/rest/abstractrestcontroller.php b/app/Controller/Api/Rest/AbstractRestController.php similarity index 93% rename from app/main/controller/api/rest/abstractrestcontroller.php rename to app/Controller/Api/Rest/AbstractRestController.php index 1d0debea..5bf26d22 100644 --- a/app/main/controller/api/rest/abstractrestcontroller.php +++ b/app/Controller/Api/Rest/AbstractRestController.php @@ -6,9 +6,9 @@ * Time: 16:14 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Controller; +use Exodus4D\Pathfinder\Controller; abstract class AbstractRestController extends Controller\AccessController { diff --git a/app/main/controller/api/rest/connection.php b/app/Controller/Api/Rest/Connection.php similarity index 97% rename from app/main/controller/api/rest/connection.php rename to app/Controller/Api/Rest/Connection.php index 9c24bfb3..2177e1bd 100644 --- a/app/main/controller/api/rest/connection.php +++ b/app/Controller/Api/Rest/Connection.php @@ -6,9 +6,10 @@ * Time: 12:10 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; + +use Exodus4D\Pathfinder\Model\Pathfinder; class Connection extends AbstractRestController { diff --git a/app/main/controller/api/rest/log.php b/app/Controller/Api/Rest/Log.php similarity index 96% rename from app/main/controller/api/rest/log.php rename to app/Controller/Api/Rest/Log.php index 8b872f0c..9696ce00 100644 --- a/app/main/controller/api/rest/log.php +++ b/app/Controller/Api/Rest/Log.php @@ -6,9 +6,10 @@ * Time: 15:28 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; + +use Exodus4D\Pathfinder\Model\Pathfinder; class Log extends AbstractRestController { diff --git a/app/main/controller/api/rest/signature.php b/app/Controller/Api/Rest/Signature.php similarity index 98% rename from app/main/controller/api/rest/signature.php rename to app/Controller/Api/Rest/Signature.php index 92a0db71..e928d9c0 100644 --- a/app/main/controller/api/rest/signature.php +++ b/app/Controller/Api/Rest/Signature.php @@ -6,10 +6,10 @@ * Time: 16:20 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; class Signature extends AbstractRestController { diff --git a/app/main/controller/api/rest/signaturehistory.php b/app/Controller/Api/Rest/SignatureHistory.php similarity index 97% rename from app/main/controller/api/rest/signaturehistory.php rename to app/Controller/Api/Rest/SignatureHistory.php index f431687b..ffaf2de5 100644 --- a/app/main/controller/api/rest/signaturehistory.php +++ b/app/Controller/Api/Rest/SignatureHistory.php @@ -6,11 +6,11 @@ * Time: 16:44 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; -use lib\Config; +use Exodus4D\Pathfinder\Model\Pathfinder; +use Exodus4D\Pathfinder\Lib\Config; class SignatureHistory extends AbstractRestController { diff --git a/app/main/controller/api/rest/structure.php b/app/Controller/Api/Rest/Structure.php similarity index 97% rename from app/main/controller/api/rest/structure.php rename to app/Controller/Api/Rest/Structure.php index b100d77e..19ea8ecb 100644 --- a/app/main/controller/api/rest/structure.php +++ b/app/Controller/Api/Rest/Structure.php @@ -6,10 +6,10 @@ * Time: 23:29 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; class Structure extends AbstractRestController { diff --git a/app/main/controller/api/rest/system.php b/app/Controller/Api/Rest/System.php similarity index 98% rename from app/main/controller/api/rest/system.php rename to app/Controller/Api/Rest/System.php index 4a5983a8..efceae2d 100644 --- a/app/main/controller/api/rest/system.php +++ b/app/Controller/Api/Rest/System.php @@ -6,10 +6,10 @@ * Time: 12:34 */ -namespace Controller\Api\Rest; +namespace Exodus4D\Pathfinder\Controller\Api\Rest; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; class System extends AbstractRestController { diff --git a/app/main/controller/api/route.php b/app/Controller/Api/Route.php similarity index 99% rename from app/main/controller/api/route.php rename to app/Controller/Api/Route.php index c6496f4a..8360b948 100644 --- a/app/main/controller/api/route.php +++ b/app/Controller/Api/Route.php @@ -6,12 +6,12 @@ * Time: 03:34 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use Controller\Ccp\Universe; -use lib\Config; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Controller\Ccp\Universe; +use Exodus4D\Pathfinder\Model\Pathfinder; /** * Routes controller @@ -731,9 +731,7 @@ class Route extends Controller\AccessController { ]; $keyParts += $filterData; - $key = 'route_' . hash('md5', implode('_', $keyParts)); - - return $key; + return 'route_' . hash('md5', implode('_', $keyParts)); } /** diff --git a/app/main/controller/api/setup.php b/app/Controller/Api/Setup.php similarity index 98% rename from app/main/controller/api/setup.php rename to app/Controller/Api/Setup.php index 8076a9cf..b436ff06 100644 --- a/app/main/controller/api/setup.php +++ b/app/Controller/Api/Setup.php @@ -6,12 +6,12 @@ * Time: 14:17 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use lib\Config; -use lib\Cron; -use Model; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Lib\Cron; +use Exodus4D\Pathfinder\Model; class Setup extends Controller\Controller { diff --git a/app/main/controller/api/statistic.php b/app/Controller/Api/Statistic.php similarity index 98% rename from app/main/controller/api/statistic.php rename to app/Controller/Api/Statistic.php index e8fed3b8..79688023 100644 --- a/app/main/controller/api/statistic.php +++ b/app/Controller/Api/Statistic.php @@ -6,11 +6,11 @@ * Time: 00:29 */ -namespace controller\api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use lib\Config; -use Model\Pathfinder\CharacterModel; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel; class Statistic extends Controller\AccessController { diff --git a/app/main/controller/api/system.php b/app/Controller/Api/System.php similarity index 97% rename from app/main/controller/api/system.php rename to app/Controller/Api/System.php index bf87bfb9..9a6cf039 100644 --- a/app/main/controller/api/system.php +++ b/app/Controller/Api/System.php @@ -6,11 +6,11 @@ * Time: 20:23 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use lib\Config; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Model\Pathfinder; class System extends Controller\AccessController { diff --git a/app/main/controller/api/universe.php b/app/Controller/Api/Universe.php similarity index 96% rename from app/main/controller/api/universe.php rename to app/Controller/Api/Universe.php index 95156955..907cb62d 100644 --- a/app/main/controller/api/universe.php +++ b/app/Controller/Api/Universe.php @@ -6,11 +6,11 @@ * Time: 15:49 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use Controller\Ccp as Ccp; -use Model; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Controller\Ccp as Ccp; +use Exodus4D\Pathfinder\Model; class Universe extends Controller\AccessController { diff --git a/app/main/controller/api/user.php b/app/Controller/Api/User.php similarity index 97% rename from app/main/controller/api/user.php rename to app/Controller/Api/User.php index 1a132dc0..4158f9a2 100644 --- a/app/main/controller/api/user.php +++ b/app/Controller/Api/User.php @@ -6,13 +6,13 @@ * Time: 20:50 */ -namespace Controller\Api; +namespace Exodus4D\Pathfinder\Controller\Api; -use Controller; -use lib\Config; -use Model\Pathfinder; -use Exception; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Model\Pathfinder; +use Exodus4D\Pathfinder\Exception; class User extends Controller\Controller{ @@ -46,7 +46,7 @@ class User extends Controller\Controller{ * login a valid character * @param Pathfinder\CharacterModel $character * @return bool - * @throws Exception + * @throws \Exception */ protected function loginByCharacter(Pathfinder\CharacterModel &$character) : bool { $login = false; @@ -113,7 +113,7 @@ class User extends Controller\Controller{ * validate cookie character information * -> return character data (if valid) * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function getCookieCharacter(\Base $f3){ $data = $f3->get('POST'); @@ -194,7 +194,7 @@ class User extends Controller\Controller{ /** * log the current user out + clear character system log data * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function logout(\Base $f3){ $this->logoutCharacter($f3, false, true, true, true); @@ -204,7 +204,7 @@ class User extends Controller\Controller{ * remote open ingame information window (character, corporation or alliance) Id * -> the type is auto-recognized by CCP * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function openIngameWindow(\Base $f3){ $data = $f3->get('POST'); @@ -235,7 +235,7 @@ class User extends Controller\Controller{ * -> a fresh user automatically generated on first login with a new character * -> see SSO login * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function saveAccount(\Base $f3){ $data = $f3->get('POST'); @@ -348,7 +348,7 @@ class User extends Controller\Controller{ /** * delete current user account from DB * @param \Base $f3 - * @throws Exception + * @throws \Exception */ public function deleteAccount(\Base $f3){ $data = $f3->get('POST.formData'); diff --git a/app/main/controller/appcontroller.php b/app/Controller/AppController.php similarity index 92% rename from app/main/controller/appcontroller.php rename to app/Controller/AppController.php index 529f531b..e8785f36 100644 --- a/app/main/controller/appcontroller.php +++ b/app/Controller/AppController.php @@ -6,11 +6,12 @@ * Time: 21:27 */ -namespace Controller; +namespace Exodus4D\Pathfinder\Controller; -use Controller\Ccp as Ccp; -use lib\Config; -use lib\Resource; + +use Exodus4D\Pathfinder\Controller\Ccp as Ccp; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Resource; class AppController extends Controller { diff --git a/app/main/controller/ccp/sso.php b/app/Controller/Ccp/Sso.php similarity index 99% rename from app/main/controller/ccp/sso.php rename to app/Controller/Ccp/Sso.php index 2b51cdb8..fbb30bea 100644 --- a/app/main/controller/ccp/sso.php +++ b/app/Controller/Ccp/Sso.php @@ -11,12 +11,12 @@ * - Check "PATHFINDER.API" in "pathfinder.ini" for correct API URLs */ -namespace Controller\Ccp; +namespace Exodus4D\Pathfinder\Controller\Ccp; -use Controller; -use Controller\Api as Api; -use Model\Pathfinder; -use Lib; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Controller\Api as Api; +use Exodus4D\Pathfinder\Model\Pathfinder; +use Exodus4D\Pathfinder\Lib; class Sso extends Api\User{ diff --git a/app/main/controller/ccp/universe.php b/app/Controller/Ccp/Universe.php similarity index 98% rename from app/main/controller/ccp/universe.php rename to app/Controller/Ccp/Universe.php index 67f1fc68..471d87d2 100644 --- a/app/main/controller/ccp/universe.php +++ b/app/Controller/Ccp/Universe.php @@ -6,13 +6,13 @@ * Time: 11:31 */ -namespace Controller\Ccp; +namespace Exodus4D\Pathfinder\Controller\Ccp; -use Controller\Controller; -use lib\Util; -use Model; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Lib\Util; +use Exodus4D\Pathfinder\Model; -class Universe extends Controller { +class Universe extends Controller\Controller { const SESSION_KEY_SYSTEM_IDS = 'SESSION.SETUP.SYSTEM_IDS'; diff --git a/app/Controller/Controller.php b/app/Controller/Controller.php new file mode 100644 index 00000000..5e45250e --- /dev/null +++ b/app/Controller/Controller.php @@ -0,0 +1,1001 @@ +template = $template; + } + + /** + * @return string + */ + protected function getTemplate(){ + return $this->template; + } + + /** + * get $f3 base object + * @return \Base + */ + protected function getF3() : \Base { + return \Base::instance(); + } + + /** + * get DB connection + * @param string $alias + * @return SQL|null + */ + protected function getDB(string $alias = 'PF') : ?SQL { + return $this->getF3()->DB->getDB($alias); + } + + /** + * event handler for all "views" + * some global template variables are set in here + * @param \Base $f3 + * @param $params + * @return bool + */ + function beforeroute(\Base $f3, $params) : bool { + // init user session + $this->initSession($f3); + + if($f3->get('AJAX')){ + header('Content-Type: application/json'); + + // send "maintenance" Header -> e.g. before server update + if($modeMaintenance = (int)Config::getPathfinderData('login.mode_maintenance')){ + header('Pf-Maintenance: ' . $modeMaintenance); + } + }else{ + $this->initResource($f3); + + $this->setTemplate(Config::getPathfinderData('view.index')); + + + $f3->set('tplImage', Format\Image::instance()); + } + + return true; + } + + /** + * event handler after routing + * -> render view + * @param \Base $f3 + */ + public function afterroute(\Base $f3){ + // send preload/prefetch headers + $resource = Resource::instance(); + if($resource->getOption('output') === 'header'){ + header($resource->buildHeader(), false); + } + + if($file = $this->getTemplate()){ + // Ajax calls don´t need a page render.. + // this happens on client side + echo \Template::instance()->render($file); + } + } + + /** + * init new Session handler + * @param \Base $f3 + */ + protected function initSession(\Base $f3){ + $session = null; + + if( + $f3->get('SESSION_CACHE') === 'mysql' && + ($db = $f3->DB->getDB('PF')) instanceof SQL + ){ + if(!headers_sent() && session_status() != PHP_SESSION_ACTIVE){ + /** + * callback() for suspect sessions + * @param \DB\SQL\Session $session + * @param string $sid + * @return bool + */ + $onSuspect = function($session, $sid){ + self::getLogger('SESSION_SUSPECT')->write( sprintf( + self::ERROR_SESSION_SUSPECT, + $sid, + $session->ip(), + $session->agent() + )); + // .. continue with default onSuspect() handler + // -> destroy session + return false; + }; + + new Mysql\Session($db, 'sessions', true, $onSuspect); + } + } + } + + /** + * init new Resource handler + * @param \Base $f3 + */ + protected function initResource(\Base $f3){ + $resource = Resource::instance(); + $resource->setOption('filePath', [ + 'style' => $f3->get('BASE') . '/public/css/' . Config::getPathfinderData('version'), + 'script' => $f3->get('BASE') . '/public/js/' . Config::getPathfinderData('version'), + 'font' => $f3->get('BASE') . '/public/fonts', + 'document' => $f3->get('BASE') . '/public/templates', + 'image' => $f3->get('BASE') . '/public/img' + ], true); + + $resource->register('style', 'pathfinder'); + + $resource->register('script', 'lib/require'); + $resource->register('script', 'app'); + + $resource->register('font', 'oxygen-regular-webfont'); + $resource->register('font', 'oxygen-bold-webfont'); + $resource->register('font', 'fa-regular-400'); + $resource->register('font', 'fa-solid-900'); + $resource->register('font', 'fa-brands-400'); + + $resource->register('url', self::getEnvironmentData('CCP_SSO_URL'), 'prerender'); + $resource->register('url', Config::getPathfinderData('api.ccp_image_server'), 'dns-prefetch'); + $resource->register('url', '//i.ytimg.com', 'dns-prefetch'); // YouTube tiny embed domain + + $f3->set('tplResource', $resource); + } + + /** + * get cookies "state" information + * -> whether user accepts cookies + * @return bool + */ + protected function getCookieState() : bool { + return (bool)count( $this->getCookieByName(self::COOKIE_NAME_STATE) ); + } + + /** + * search for existing cookies + * -> either a specific cookie by its name + * -> or get multiple cookies by their name (search by prefix) + * @param $cookieName + * @param bool $prefix + * @return array + */ + protected function getCookieByName($cookieName, $prefix = false) : array { + $data = []; + + if(!empty($cookieName)){ + $cookieData = (array)$this->getF3()->get('COOKIE'); + if($prefix === true){ + // look for multiple cookies with same prefix + foreach($cookieData as $name => $value){ + if(strpos($name, $cookieName) === 0){ + $data[$name] = $value; + } + } + }elseif(isset($cookieData[$cookieName])){ + // look for a single cookie + $data[$cookieName] = $cookieData[$cookieName]; + } + } + + return $data; + } + + /** + * set/update logged in cookie by character model + * -> store validation data in DB + * @param Pathfinder\CharacterModel $character + * @throws \Exception + */ + protected function setLoginCookie(Pathfinder\CharacterModel $character){ + if( $this->getCookieState() ){ + $expireSeconds = (int)Config::getPathfinderData('login.cookie_expire'); + $expireSeconds *= 24 * 60 * 60; + + $timezone = $this->getF3()->get('getTimeZone')(); + $expireTime = new \DateTime('now', $timezone); + + // add cookie expire time + $expireTime->add(new \DateInterval('PT' . $expireSeconds . 'S')); + + // unique "selector" -> to facilitate database look-ups (small size) + // -> This is preferable to simply using the database id field, + // which leaks the number of active users on the application + $selector = bin2hex( openssl_random_pseudo_bytes(12) ); + + // generate unique "validator" (strong encryption) + // -> plaintext set to user (cookie), hashed version of this in DB + $size = openssl_cipher_iv_length('aes-256-cbc'); + $validator = bin2hex(openssl_random_pseudo_bytes($size) ); + + // generate unique cookie token + $token = hash('sha256', $validator); + + // get unique cookie name for this character + $name = $character->getCookieName(); + + $authData = [ + 'characterId' => $character, + 'selector' => $selector, + 'token' => $token, + 'expires' => $expireTime->format('Y-m-d H:i:s') + ]; + + $authenticationModel = $character->rel('characterAuthentications'); + $authenticationModel->copyfrom($authData); + $authenticationModel->save(); + + $cookieValue = implode(':', [$selector, $validator]); + + // get cookie name -> save new one OR update existing cookie + $cookieName = 'COOKIE.' . self::COOKIE_PREFIX_CHARACTER . '_' . $name; + $this->getF3()->set($cookieName, $cookieValue, $expireSeconds); + } + } + + /** + * get characters from given cookie data + * -> validate cookie data + * -> validate characters + * -> cf. Sso->requestAuthorization() ( equivalent DB based login) + * + * @param array $cookieData + * @param bool $checkAuthorization + * @return Pathfinder\CharacterModel[] + * @throws \Exception + */ + protected function getCookieCharacters($cookieData = [], $checkAuthorization = true) : array { + $characters = []; + + if( + $this->getCookieState() && + !empty($cookieData) + ){ + /** + * @var $characterAuth Pathfinder\CharacterAuthenticationModel + */ + $characterAuth = Pathfinder\AbstractPathfinderModel::getNew('CharacterAuthenticationModel'); + + $timezone = $this->getF3()->get('getTimeZone')(); + $currentTime = new \DateTime('now', $timezone); + + foreach($cookieData as $name => $value){ + // remove invalid cookies + $invalidCookie = false; + + $data = explode(':', $value); + if(count($data) === 2){ + // cookie data is well formatted + $characterAuth->getByForeignKey('selector', $data[0], ['limit' => 1]); + + // validate "scope hash" + // -> either "normal" scopes OR "admin" scopes + // "expire data" and "validate token" + if( !$characterAuth->dry() ){ + if( + strtotime($characterAuth->expires) >= $currentTime->getTimestamp() && + hash_equals($characterAuth->token, hash('sha256', $data[1])) + ){ + // cookie information is valid + // -> try to update character information from ESI + // e.g. Corp has changed, this also ensures valid "access_token" + /** + * @var $character Pathfinder\CharacterModel + */ + $updateStatus = $characterAuth->characterId->updateFromESI(); + + if( empty($updateStatus) ){ + // make sure character data is up2date! + // -> this is not the case if e.g. userCharacters was removed "ownerHash" changed... + $character = $characterAuth->rel('characterId'); + $character->getById( $characterAuth->get('characterId', true) ); + + // check ESI scopes + $scopeHash = Util::getHashFromScopes($character->esiScopes); + + if( + $scopeHash === Util::getHashFromScopes(self::getScopesByAuthType()) || + $scopeHash === Util::getHashFromScopes(self::getScopesByAuthType('admin')) + ){ + // check if character still has user (is not the case of "ownerHash" changed + // check if character is still authorized to log in (e.g. corp/ally or config has changed + // -> do NOT remove cookie on failure. This can be a temporary problem (e.g. ESI is down,..) + if( $character->hasUserCharacter() ){ + $authStatus = $character->isAuthorized(); + + if( + $authStatus == 'OK' || + !$checkAuthorization + ){ + $character->virtual( 'authStatus', $authStatus); + } + + $characters[$name] = $character; + } + }else{ + // outdated/invalid ESI scopes + $characterAuth->erase(); + $invalidCookie = true; + } + }else{ + $invalidCookie = true; + } + }else{ + // clear existing authentication data from DB + $characterAuth->erase(); + $invalidCookie = true; + } + }else{ + $invalidCookie = true; + } + $characterAuth->reset(); + }else{ + $invalidCookie = true; + } + + // remove invalid cookie + if($invalidCookie){ + $this->getF3()->clear('COOKIE.' . $name); + } + } + } + + return $characters; + } + + /** + * get current character from session data + * @param int $ttl + * @return Pathfinder\CharacterModel|null + * @throws \Exception + */ + protected function getSessionCharacter(int $ttl = AbstractModel::DEFAULT_SQL_TTL) : ?Pathfinder\CharacterModel { + $character = null; + if($user = $this->getUser($ttl)){ + $header = self::getRequestHeaders(); + $requestedCharacterId = (int)$header['Pf-Character']; + if( !$this->getF3()->get('AJAX') ){ + $requestedCharacterId = (int)$_COOKIE['old_char_id']; + if(!$requestedCharacterId){ + $tempCharacterData = (array)$this->getF3()->get(Api\User::SESSION_KEY_TEMP_CHARACTER_DATA); + if((int)$tempCharacterData['ID'] > 0){ + $requestedCharacterId = (int)$tempCharacterData['ID']; + } + } + } + + $character = $user->getSessionCharacter($requestedCharacterId, $ttl); + } + + return $character; + } + + /** + * get current character + * @param int $ttl + * @return Pathfinder\CharacterModel|null + * @throws \Exception + */ + public function getCharacter(int $ttl = AbstractModel::DEFAULT_SQL_TTL) : ?Pathfinder\CharacterModel { + return $this->getSessionCharacter($ttl); + } + + /** + * get current user + * @param int $ttl + * @return Pathfinder\UserModel|null + * @throws \Exception + */ + public function getUser($ttl = AbstractModel::DEFAULT_SQL_TTL) : ?Pathfinder\UserModel { + $user = null; + + if($this->getF3()->exists(Api\User::SESSION_KEY_USER_ID, $userId)){ + /** + * @var $userModel Pathfinder\UserModel + */ + $userModel = Pathfinder\AbstractPathfinderModel::getNew('UserModel'); + $userModel->getById($userId, $ttl); + + if( + !$userModel->dry() && + $userModel->hasUserCharacters() + ){ + $user = $userModel; + } + } + + return $user; + } + + /** + * set temp login character data (required during HTTP redirects on login) + * @param int $characterId + * @throws \Exception + */ + protected function setTempCharacterData(int $characterId){ + if($characterId > 0){ + $tempCharacterData = [ + 'ID' => $characterId + ]; + $this->getF3()->set(Api\User::SESSION_KEY_TEMP_CHARACTER_DATA, $tempCharacterData); + }else{ + throw new \Exception( sprintf(self::ERROR_TEMP_CHARACTER_ID, $characterId) ); + } + } + + /** + * log out current character or all active characters (multiple browser tabs) + * -> send response data to client + * @param \Base $f3 + * @param bool $all + * @param bool $deleteSession + * @param bool $deleteLog + * @param bool $deleteCookie + * @throws \Exception + */ + protected function logoutCharacter(\Base $f3, bool $all = false, bool $deleteSession = true, bool $deleteLog = true, bool $deleteCookie = false){ + $sessionCharacterData = (array)$f3->get(Api\User::SESSION_KEY_CHARACTERS); + + if($sessionCharacterData){ + $activeCharacterId = ($activeCharacter = $this->getCharacter()) ? $activeCharacter->_id : 0; + /** + * @var $character Pathfinder\CharacterModel + */ + $character = Pathfinder\AbstractPathfinderModel::getNew('CharacterModel'); + $characterIds = []; + foreach($sessionCharacterData as $characterData){ + if($characterData['ID'] === $activeCharacterId){ + $characterIds[] = $activeCharacter->_id; + $activeCharacter->logout($deleteSession, $deleteLog, $deleteCookie); + }elseif($all){ + $character->getById($characterData['ID']); + $characterIds[] = $character->_id; + $character->logout($deleteSession, $deleteLog, $deleteCookie); + } + $character->reset(); + } + + if($characterIds){ + // broadcast logout information to webSocket server + $f3->webSocket()->write('characterLogout', $characterIds); + } + } + + if($f3->get('AJAX')){ + $status = 403; + $f3->status($status); + + $return = (object) []; + $return->reroute = rtrim(self::getEnvironmentData('URL'), '/') . $f3->alias('login'); + $return->error[] = $this->getErrorObject($status, Config::getMessageFromHTTPStatus($status)); + + echo json_encode($return); + }else{ + // redirect to landing page + $f3->reroute(['login']); + } + } + + /** + * get EVE server status from ESI + * @param \Base $f3 + * @throws \Exception + */ + public function getEveServerStatus(\Base $f3){ + $ttl = 60; + $esiStatusVersion = 'latest'; + $cacheKey = 'eve_server_status'; + + if(!$exists = $f3->exists($cacheKey, $return)){ + $return = (object) []; + $return->error = []; + + /** + * @var $client CcpClient + */ + if($client = $f3->ccpClient()){ + $return->server = [ + 'name' => strtoupper(self::getEnvironmentData('CCP_ESI_DATASOURCE')), + 'status' => 'offline', + 'statusColor' => 'red', + ]; + $return->api = [ + 'name' => 'ESI API', + 'status' => 'offline', + 'statusColor' => 'red', + 'url' => $client->getUrl(), + 'timeout' => $client->getTimeout(), + 'connectTimeout' => $client->getConnectTimeout(), + 'readTimeout' => $client->getReadTimeout(), + 'proxy' => ($proxy = $client->getProxy()) ? : 'false', + 'verify' => $client->getVerify(), + 'debug' => $client->getDebugRequests(), + 'dataSource' => $client->getDataSource(), + 'statusVersion' => $esiStatusVersion, + 'routes' => [] + ]; + + $serverStatus = $client->getServerStatus(); + if( !isset($serverStatus['error']) ){ + $statusData = $serverStatus['status']; + // calculate time diff since last server restart + $timezone = $f3->get('getTimeZone')(); + $dateNow = new \DateTime('now', $timezone); + $dateServerStart = new \DateTime($statusData['startTime']); + $interval = $dateNow->diff($dateServerStart); + $startTimestampFormat = $interval->format('%hh %im'); + if($interval->days > 0){ + $startTimestampFormat = $interval->days . 'd ' . $startTimestampFormat; + } + + $statusData['name'] = $return->server['name']; + $statusData['status'] = 'online'; + $statusData['statusColor'] = 'green'; + $statusData['startTime'] = $startTimestampFormat; + $return->server = $statusData; + }else{ + $return->error[] = (new PathfinderException($serverStatus['error'], 500))->getError(); + } + + $apiStatus = $client->getStatusForRoutes('latest'); + if( !isset($apiStatus['error']) ){ + // find top status + $status = 'OK'; + $color = 'green'; + foreach($apiStatus['status'] as &$statusData){ + if('red' == $statusData['status']){ + $status = 'unstable'; + $color = $statusData['status'] = 'orange'; // red is already in use for fatal API errors (e.g. no response at all, or offline) + break; + } + if('yellow' == $statusData['status']){ + $status = 'degraded'; + $color = $statusData['status']; + } + } + + $return->api['status'] = $status; + $return->api['statusColor'] = $color; + $return->api['routes'] = $apiStatus['status']; + }else{ + $return->error[] = (new PathfinderException($apiStatus['error'], 500))->getError(); + } + + if(empty($return->error)){ + $f3->set($cacheKey, $return, $ttl); + } + } + } + + if(empty($return->error)){ + $f3->expire(Config::ttlLeft($exists, $ttl)); + } + + echo json_encode($return); + } + + /** + * @param int $code + * @param string $message + * @param string $status + * @param null $trace + * @return \stdClass + */ + protected function getErrorObject(int $code, string $message = '', string $status = '', $trace = null): \stdClass{ + $object = (object) []; + $object->type = 'error'; + $object->code = $code; + $object->status = empty($status) ? @constant('Base::HTTP_' . $code) : $status; + if(!empty($message)){ + $object->message = $message; + } + if(!empty($trace)){ + $object->trace = $trace; + } + return $object; + } + + /** + * @param string $title + * @param string $message + * @param string $type + * @return \stdClass + */ + protected function getNotificationObject(string $title, $message = '', $type = 'danger') : \stdClass { + $notification = (object) []; + $notification->type = in_array($type, self::NOTIFICATION_TYPES) ? $type : 'danger'; + $notification->title = $title; + $notification->message = $message; + return $notification; + } + + /** + * get a program URL by alias + * -> if no $alias given -> get "default" route (index.php) + * @param null $alias + * @return bool|string + */ + protected function getRouteUrl($alias = null){ + $url = false; + + if(!empty($alias)){ + // check given alias is a valid (registered) route + if(array_key_exists($alias, $this->getF3()->get('ALIASES'))){ + $url = $this->getF3()->alias($alias); + } + }elseif($this->getF3()->get('ALIAS')){ + // get current URL + $url = $this->getF3()->alias( $this->getF3()->get('ALIAS') ); + }else{ + // get main (index.php) URL + $url = $this->getF3()->alias('login'); + } + + return $url; + } + + /** + * get a custom userAgent string for API calls + * @return string + */ + protected function getUserAgent() : string { + $userAgent = ''; + $userAgent .= Config::getPathfinderData('name'); + $userAgent .= ' - ' . Config::getPathfinderData('version'); + $userAgent .= ' | ' . Config::getPathfinderData('contact'); + $userAgent .= ' (' . $_SERVER['SERVER_NAME'] . ')'; + + return $userAgent; + } + + /** + * print error information in CLI mode + * @param \stdClass $error + */ + protected function echoErrorCLI(\stdClass $error){ + echo '[' . date('H:i:s') . '] ───────────────────────────' . PHP_EOL; + foreach(get_object_vars($error) as $key => $value){ + $row = str_pad(' ',2 ) . str_pad($key . ':',10 ); + if($key == 'trace'){ + $value = preg_replace("/\r\n|\r|\n/", "\n" . str_pad(' ',12 ), $value); + $row .= PHP_EOL . str_pad(' ',12 ) . $value; + }else{ + $row .= $value; + } + echo $row . PHP_EOL; + } + } + + /** + * onError() callback function + * -> on AJAX request -> return JSON with error information + * -> on HTTP request -> render error page + * @param \Base $f3 + * @return bool + */ + public function showError(\Base $f3){ + + if(!headers_sent()){ + // collect error info ------------------------------------------------------------------------------------- + $errorData = $f3->get('ERROR'); + $exception = $f3->get('EXCEPTION'); + + if($exception instanceof PathfinderException){ + // ... handle Pathfinder exceptions (e.g. validation Exceptions,..) + $error = $exception->getError(); + }else{ + // ... handle error $f3->error() calls + $error = $this->getErrorObject( + $errorData['code'], + $errorData['status'], + $errorData['text'], + $f3->get('DEBUG') >= 1 ? $errorData['trace'] : null + ); + } + + // check if error is a PDO Exception ---------------------------------------------------------------------- + if(strpos(strtolower( $f3->get('ERROR.text') ), 'duplicate') !== false){ + preg_match_all('/\'([^\']+)\'/', $f3->get('ERROR.text'), $matches, PREG_SET_ORDER); + + if(count($matches) === 2){ + $error->field = $matches[1][1]; + $error->message = 'Value "' . $matches[0][1] . '" already exists'; + } + } + + // set response status ------------------------------------------------------------------------------------ + if(!empty($error->code)){ + $f3->status($error->code); + } + + if($f3->get('CLI')){ + $this->echoErrorCLI($error); + // no further processing (no HTML output) + return false; + }elseif($f3->get('AJAX')){ + $return = (object) []; + $return->error[] = $error; + echo json_encode($return); + }else{ + // non AJAX (e.g. GET/POST) + // recursively clear existing output buffers + while(ob_get_level()){ + ob_end_clean(); + } + + $f3->set('tplPageTitle', 'ERROR - ' . $error->code); + // set error data for template rendering + $error->redirectUrl = $this->getRouteUrl(); + $f3->set('errorData', $error); + + // 4xx/5xx error -> set error page template + if( preg_match('/^4[0-9]{2}$/', $error->code) ){ + $f3->set('tplPageContent', Config::getPathfinderData('STATUS.4XX') ); + }elseif( preg_match('/^5[0-9]{2}$/', $error->code) ){ + $f3->set('tplPageContent', Config::getPathfinderData('STATUS.5XX')); + } + + // stop script - die(); after this fkt is done + // -> unload() fkt is still called + $f3->set('HALT', true); + } + } + + return true; + } + + /** + * Callback for framework "unload" + * -> this function is called on each request! + * -> configured in config.ini + * @param \Base $f3 + * @return bool + */ + public function unload(\Base $f3){ + // store all user activities that are buffered for logging in this request + // this should work even on non HTTP200 responses + $this->logActivities(); + + return true; + } + + /** + * store activity log data to DB + */ + protected function logActivities(){ + LogController::instance()->logActivities(); + Monolog::instance()->log(); + } + + /** + * simple counter with "static" store + * -> called within tpl render + * @return \Closure + */ + protected function counter() : \Closure { + $store = []; + + return function(string $action = 'increment', string $type = 'default', $val = 0) use (&$store){ + $return = null; + switch($action){ + case 'increment': $store[$type]++; break; + case 'add': $store[$type] += (int)$val; break; + case 'get': $return = $store[$type] ? : null; break; + case 'reset': unset($store[$type]); break; + } + return $return; + }; + } + + /** + * get controller by class name + * -> controller class is searched within all controller directories + * @param $className + * @return null|Controller + * @throws \Exception + */ + static function getController($className){ + $controller = null; + // add subNamespaces for controller classes + $subNamespaces = ['Api', 'Ccp']; + + for($i = 0; $i <= count($subNamespaces); $i++){ + $path = [__NAMESPACE__]; + $path[] = ( isset($subNamespaces[$i - 1]) ) ? $subNamespaces[$i - 1] : ''; + $path[] = $className; + $classPath = implode('\\', array_filter($path)); + + if(class_exists($classPath)){ + $controller = new $classPath(); + break; + } + } + + if( is_null($controller) ){ + throw new \Exception( sprintf('Controller class "%s" not found!', $className) ); + } + + return $controller; + } + + + /** + * get scope array by a "role" + * @param string $authType + * @return array + */ + static function getScopesByAuthType(string $authType = '') : array { + $scopes = array_filter((array)self::getEnvironmentData('CCP_ESI_SCOPES')); + switch($authType){ + case 'admin': + $scopesAdmin = array_filter((array)self::getEnvironmentData('CCP_ESI_SCOPES_ADMIN')); + $scopes = array_merge($scopes, $scopesAdmin); + break; + } + sort($scopes); + return $scopes; + } + + /** + * Helper function to return all headers because + * getallheaders() is not available under nginx + * @return array (string $key -> string $value) + */ + static function getRequestHeaders() : array { + $headers = []; + $headerPrefix = 'http_'; + $prefixLength = mb_strlen($headerPrefix); + $serverData = self::getServerData(); + + if( + function_exists('apache_request_headers') && + $serverData->type === 'apache' + ){ + // Apache WebServer + $headers = apache_request_headers(); + }else{ + // Other WebServer, e.g. Nginx + // Unfortunately this "fallback" does not work for me (Apache) + // Therefore we can´t use this for all servers + // https://github.com/exodus4d/pathfinder/issues/58 + foreach($_SERVER as $name => $value){ + $name = mb_strtolower($name); + if(mb_substr($name, 0, $prefixLength) == $headerPrefix){ + $headers[mb_convert_case(str_replace('_', '-', mb_substr($name, $prefixLength)), MB_CASE_TITLE)] = $value; + } + } + } + + return $headers; + } + + /** + * get some server information + * @param int $ttl cache time (default: 1h) + * @return \stdClass + */ + static function getServerData($ttl = 3600){ + $f3 = \Base::instance(); + $cacheKey = 'PF_SERVER_INFO'; + + if( !$f3->exists($cacheKey) ){ + $serverData = (object) []; + $serverData->type = 'unknown'; + $serverData->version = 'unknown'; + $serverData->requiredVersion = 'unknown'; + $serverData->phpInterfaceType = php_sapi_name(); + + if(strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'nginx' ) !== false){ + // Nginx server + $serverSoftwareArgs = explode('/', strtolower( $_SERVER['SERVER_SOFTWARE']) ); + $serverData->type = reset($serverSoftwareArgs); + $serverData->version = end($serverSoftwareArgs); + $serverData->requiredVersion = $f3->get('REQUIREMENTS.SERVER.NGINX.VERSION'); + }elseif(strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache' ) !== false){ + // Apache server + $serverData->type = 'apache'; + $serverData->requiredVersion = $f3->get('REQUIREMENTS.SERVER.APACHE.VERSION'); + + // try to get the apache version... + if(function_exists('apache_get_version')){ + // function does not exists if PHP is running as CGI/FPM module! + $matches = preg_split('/[\s,\/ ]+/', strtolower( apache_get_version() ) ); + if(count($matches) > 1){ + $serverData->version = $matches[1]; + } + } + } + + // cache data for one day + $f3->set($cacheKey, $serverData, $ttl); + } + + return $f3->get($cacheKey); + } + + /** + * get the current registration status + * 0=registration stop |1=new registration allowed + * @return int + */ + static function getRegistrationStatus(){ + return (int)Config::getPathfinderData('registration.status'); + } + + /** + * get a Logger object by Hive key + * -> set in pathfinder.ini + * @param string $type + * @return \Log + */ + static function getLogger($type = 'DEBUG') : \Log { + return LogController::getLogger($type); + } + + /** + * removes illegal characters from a Hive-key that are not allowed + * @param $key + * @return string + */ + static function formatHiveKey($key) : string { + $illegalCharacters = ['-', ' ']; + return strtolower(str_replace($illegalCharacters, '', $key)); + } + + /** + * get environment specific configuration data + * @param string $key + * @return string|array|null + */ + static function getEnvironmentData($key){ + return Config::getEnvironmentData($key); + } + +} \ No newline at end of file diff --git a/app/main/controller/logcontroller.php b/app/Controller/LogController.php similarity index 97% rename from app/main/controller/logcontroller.php rename to app/Controller/LogController.php index 1fc900b3..b17044fa 100644 --- a/app/main/controller/logcontroller.php +++ b/app/Controller/LogController.php @@ -6,12 +6,12 @@ * Time: 15:24 */ -namespace controller; +namespace Exodus4D\Pathfinder\Controller; -use lib\Config; -use lib\logging\MapLog; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Logging\MapLog; +use Exodus4D\Pathfinder\Model\Pathfinder; class LogController extends \Prefab { diff --git a/app/main/controller/mapcontroller.php b/app/Controller/MapController.php similarity index 86% rename from app/main/controller/mapcontroller.php rename to app/Controller/MapController.php index 5e0e2379..fcab21e5 100644 --- a/app/main/controller/mapcontroller.php +++ b/app/Controller/MapController.php @@ -6,11 +6,11 @@ * Time: 21:18 */ -namespace Controller; +namespace Exodus4D\Pathfinder\Controller; -use lib\Config; -use lib\Resource; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Resource; class MapController extends AccessController { diff --git a/app/main/controller/setup.php b/app/Controller/Setup.php similarity index 98% rename from app/main/controller/setup.php rename to app/Controller/Setup.php index 2f61e5f8..faa273af 100644 --- a/app/main/controller/setup.php +++ b/app/Controller/Setup.php @@ -6,17 +6,19 @@ * Time: 10:59 */ -namespace Controller; +namespace Exodus4D\Pathfinder\Controller; + -use Controller\Ccp\Universe as UniverseController; -use data\filesystem\Search; use DB\SQL\Schema; -use DB\SQL\MySQL as MySQL; -use lib\Config; -use lib\Cron; -use lib\Util; -use Model\Pathfinder; -use Model\Universe; +use Exodus4D\Pathfinder\Db\Sql\Mysql; +use Exodus4D\Pathfinder\Lib\Db\Sql; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Cron; +use Exodus4D\Pathfinder\Lib\Util; +use Exodus4D\Pathfinder\Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Universe; +use Exodus4D\Pathfinder\Controller\Ccp\Universe as UniverseController; +use Exodus4D\Pathfinder\Data\Filesystem\Search; class Setup extends Controller { @@ -275,7 +277,7 @@ class Setup extends Controller { * @return array */ protected function getNavigationConfig() : array { - $config = [ + return [ 'server' => [ 'icon' => 'fa-home' ], @@ -301,8 +303,6 @@ class Setup extends Controller { 'icon' => 'fa-wrench' ] ]; - - return $config; } /** @@ -351,7 +351,7 @@ class Setup extends Controller { * @return array */ protected function getServerInformation(\Base $f3) : array { - $serverInfo = [ + return [ 'time' => [ 'label' => 'Time', 'value' => date('Y/m/d H:i:s') . ' - (' . $f3->get('TZ') . ')' @@ -389,8 +389,6 @@ class Setup extends Controller { 'value' => $f3->get('SERVER.SERVER_PROTOCOL') . ' - ' . $f3->get('SCHEME') ] ]; - - return $serverInfo; } /** @@ -399,7 +397,7 @@ class Setup extends Controller { * @return array */ protected function getDirectoryConfig(\Base $f3) : array { - $directoryData = [ + return [ 'TEMP' => [ 'label' => 'TEMP', 'value' => $f3->get('TEMP'), @@ -465,8 +463,6 @@ class Setup extends Controller { 'tooltip' => 'Folder for custom *.ini files. (e.g. when overwriting of default values in app/*.ini)' ] ]; - - return $directoryData; } /** @@ -639,7 +635,7 @@ class Setup extends Controller { $maxExecutionTime = (int)ini_get('max_execution_time'); // 0 == infinite $htmlErrors = (int)ini_get('html_errors'); - $phpConfig = [ + return [ 'exec' => [ 'label' => 'exec()', 'required' => $f3->get('REQUIREMENTS.PHP.EXEC'), @@ -697,8 +693,6 @@ class Setup extends Controller { 'tooltip' => 'PHP Session name.' ] ]; - - return $phpConfig; } /** @@ -724,7 +718,7 @@ class Setup extends Controller { * @return array */ $getClientInfo = function(\Redis $client, array $conf) : array { - $redisInfo = [ + return [ 'dsn' => [ 'label' => 'DSN', 'value' => $conf['host'] . ':' . $conf['port'] @@ -734,8 +728,6 @@ class Setup extends Controller { 'value' => $client->isConnected() ] ]; - - return $redisInfo; }; /** @@ -1110,7 +1102,7 @@ class Setup extends Controller { // collection for errors $dbErrors = []; /** - * @var $db \lib\db\SQL + * @var $db Sql */ $db = $f3->DB->getDB($dbAlias); @@ -1172,7 +1164,7 @@ class Setup extends Controller { // Table exists $tableExists = true; // get existing table columns and column related constraints (if exists) - $tableModifierTemp = new MySQL\TableModifier($requiredTableName, $schema); + $tableModifierTemp = new Mysql\TableModifier($requiredTableName, $schema); $currentColumns = $tableModifierTemp->getCols(true); // get row count $tableRows = $db->getRowCount($requiredTableName); @@ -1220,10 +1212,10 @@ class Setup extends Controller { // column exists // get tableModifier -> possible column update - $tableModifier = new MySQL\TableModifier($requiredTableName, $schema); + $tableModifier = new Mysql\TableModifier($requiredTableName, $schema); // get new column and copy Schema from existing column - $col = new MySQL\Column($columnName, $tableModifier); + $col = new Mysql\Column($columnName, $tableModifier); $col->copyfrom($currentColumns[$columnName]); $currentColType = $currentColumns[$columnName]['type']; @@ -1441,10 +1433,10 @@ class Setup extends Controller { /** * check MySQL params * @param \Base $f3 - * @param \lib\db\SQL $db + * @param Sql $db * @return array */ - protected function checkDBConfig(\Base $f3, \lib\db\SQL $db) : array { + protected function checkDBConfig(\Base $f3, Sql $db) : array { $checkAll = true; // some db like "Maria DB" have some strange version strings.... $dbVersionString = $db->version(); @@ -1624,7 +1616,7 @@ class Setup extends Controller { $setStats((array)$payload['stats']); }); - $socketInformation = [ + return [ 'tcpSocket' => [ 'label' => 'TCP-Socket (intern)', 'icon' => 'fa-exchange-alt', @@ -1669,8 +1661,6 @@ class Setup extends Controller { ] ] ]; - - return $socketInformation; } /** @@ -1710,13 +1700,11 @@ class Setup extends Controller { ] ]; - $config = [ + return [ 'checkCronConfig' => $cronConf, 'settings' => $f3->constants($cron, 'DEFAULT_'), 'jobs' => $cron->getJobsConfig() ]; - - return $config; } /** diff --git a/app/main/controller/controller.php b/app/Controller/controller.php similarity index 100% rename from app/main/controller/controller.php rename to app/Controller/controller.php diff --git a/app/main/cron/abstractcron.php b/app/Cron/AbstractCron.php similarity index 98% rename from app/main/cron/abstractcron.php rename to app/Cron/AbstractCron.php index 5e98b942..c14bcad6 100644 --- a/app/main/cron/abstractcron.php +++ b/app/Cron/AbstractCron.php @@ -6,9 +6,9 @@ * Time: 12:13 */ -namespace cron; +namespace Exodus4D\Pathfinder\Cron; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; abstract class AbstractCron { @@ -90,7 +90,7 @@ abstract class AbstractCron { protected function logStart(string $job, bool $logging = true){ $this->setMaxExecutionTime(); - $cron = \lib\Cron::instance(); + $cron = \Exodus4D\Pathfinder\Lib\Cron::instance(); if(isset($cron->jobs[$job])){ // set "start" date for current cronjob $jobConf = $cron->getJobDataFromConf($cron->jobs[$job]); diff --git a/app/main/cron/cache.php b/app/Cron/Cache.php similarity index 96% rename from app/main/cron/cache.php rename to app/Cron/Cache.php index 6bafd0f7..9cc0caf4 100644 --- a/app/main/cron/cache.php +++ b/app/Cron/Cache.php @@ -6,9 +6,9 @@ * Time: 14:59 */ -namespace cron; +namespace Exodus4D\Pathfinder\Cron; -use data\filesystem\Search; +use Exodus4D\Pathfinder\Data\Filesystem\Search; class Cache extends AbstractCron { diff --git a/app/main/cron/ccpsystemsupdate.php b/app/Cron/CcpSystemsUpdate.php similarity index 97% rename from app/main/cron/ccpsystemsupdate.php rename to app/Cron/CcpSystemsUpdate.php index 20d92246..a88757b6 100644 --- a/app/main/cron/ccpsystemsupdate.php +++ b/app/Cron/CcpSystemsUpdate.php @@ -6,8 +6,10 @@ * Time: 21:31 */ -namespace Cron; -use lib\db\SQL; +namespace Exodus4D\Pathfinder\Cron; + + +use Exodus4D\Pathfinder\Lib\Db\Sql; class CcpSystemsUpdate extends AbstractCron { @@ -29,11 +31,11 @@ class CcpSystemsUpdate extends AbstractCron { /** * checks if a table exists in DB or not - * @param SQL$db + * @param Sql $db * @param string $table * @return bool */ - protected function tableExists (SQL $db, string $table) : bool { + protected function tableExists (Sql $db, string $table) : bool { return !empty($db->exec('SHOW TABLES LIKE :table', [':table' => $table])); } @@ -111,7 +113,7 @@ class CcpSystemsUpdate extends AbstractCron { // switch DB for data import.. /** - * @var $pfDB SQL + * @var $pfDB Sql */ $pfDB = $f3->DB->getDB('PF'); diff --git a/app/main/cron/characterupdate.php b/app/Cron/CharacterUpdate.php similarity index 98% rename from app/main/cron/characterupdate.php rename to app/Cron/CharacterUpdate.php index e99781cb..53eb5921 100644 --- a/app/main/cron/characterupdate.php +++ b/app/Cron/CharacterUpdate.php @@ -6,10 +6,10 @@ * Time: 19:35 */ -namespace Cron; +namespace Exodus4D\Pathfinder\Cron; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Model\Pathfinder; class CharacterUpdate extends AbstractCron { diff --git a/app/main/cron/maphistory.php b/app/Cron/MapHistory.php similarity index 96% rename from app/main/cron/maphistory.php rename to app/Cron/MapHistory.php index 46e24086..70da7d97 100644 --- a/app/main/cron/maphistory.php +++ b/app/Cron/MapHistory.php @@ -6,11 +6,11 @@ * Time: 15:48 */ -namespace Cron; +namespace Exodus4D\Pathfinder\Cron; -use data\mapper\SortingIterator; -use data\file\FileHandler; -use data\filesystem\Search; +use Exodus4D\Pathfinder\Data\Mapper\SortingIterator; +use Exodus4D\Pathfinder\Data\File\FileHandler; +use Exodus4D\Pathfinder\Data\Filesystem\Search; class MapHistory extends AbstractCron { diff --git a/app/main/cron/mapupdate.php b/app/Cron/MapUpdate.php similarity index 98% rename from app/main/cron/mapupdate.php rename to app/Cron/MapUpdate.php index 1535e3ba..1d619636 100644 --- a/app/main/cron/mapupdate.php +++ b/app/Cron/MapUpdate.php @@ -6,11 +6,11 @@ * Time: 17:54 */ -namespace cron; +namespace Exodus4D\Pathfinder\Cron; -use lib\Config; -use Model\Pathfinder; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Model\Pathfinder; class MapUpdate extends AbstractCron { diff --git a/app/main/cron/statisticsupdate.php b/app/Cron/StatisticsUpdate.php similarity index 97% rename from app/main/cron/statisticsupdate.php rename to app/Cron/StatisticsUpdate.php index b23e8349..b2dc743e 100644 --- a/app/main/cron/statisticsupdate.php +++ b/app/Cron/StatisticsUpdate.php @@ -6,7 +6,7 @@ * Time: 21:31 */ -namespace cron; +namespace Exodus4D\Pathfinder\Cron; class StatisticsUpdate extends AbstractCron { diff --git a/app/main/cron/universe.php b/app/Cron/Universe.php similarity index 99% rename from app/main/cron/universe.php rename to app/Cron/Universe.php index bfe88568..e3c71992 100644 --- a/app/main/cron/universe.php +++ b/app/Cron/Universe.php @@ -6,9 +6,10 @@ * Time: 03:46 */ -namespace Cron; +namespace Exodus4D\Pathfinder\Cron; -use Model; + +use Exodus4D\Pathfinder\Model; class Universe extends AbstractCron { diff --git a/app/main/data/file/filehandler.php b/app/Data/File/FileHandler.php similarity index 98% rename from app/main/data/file/filehandler.php rename to app/Data/File/FileHandler.php index f1c6e75d..e6ff1ddf 100644 --- a/app/main/data/file/filehandler.php +++ b/app/Data/File/FileHandler.php @@ -6,7 +6,7 @@ * Time: 18:47 */ -namespace data\file; +namespace Exodus4D\Pathfinder\Data\File; class FileHandler extends \Prefab { diff --git a/app/main/data/file/reversesplfileobject.php b/app/Data/File/ReverseSplFileObject.php similarity index 99% rename from app/main/data/file/reversesplfileobject.php rename to app/Data/File/ReverseSplFileObject.php index 13b71988..829ae027 100644 --- a/app/main/data/file/reversesplfileobject.php +++ b/app/Data/File/ReverseSplFileObject.php @@ -6,7 +6,7 @@ * Time: 18:42 */ -namespace data\file; +namespace Exodus4D\Pathfinder\Data\File; class ReverseSplFileObject extends \SplFileObject{ diff --git a/app/main/data/filesystem/search.php b/app/Data/Filesystem/Search.php similarity index 98% rename from app/main/data/filesystem/search.php rename to app/Data/Filesystem/Search.php index 8037b1f5..2872faa6 100644 --- a/app/main/data/filesystem/search.php +++ b/app/Data/Filesystem/Search.php @@ -6,7 +6,7 @@ * Time: 16:58 */ -namespace data\filesystem; +namespace Exodus4D\Pathfinder\Data\Filesystem; class Search { diff --git a/app/main/data/mapper/abstractiterator.php b/app/Data/Mapper/AbstractIterator.php similarity index 92% rename from app/main/data/mapper/abstractiterator.php rename to app/Data/Mapper/AbstractIterator.php index 01141172..f81b02e4 100644 --- a/app/main/data/mapper/abstractiterator.php +++ b/app/Data/Mapper/AbstractIterator.php @@ -6,9 +6,9 @@ * Time: 04:06 */ -namespace data\mapper; +namespace Exodus4D\Pathfinder\Data\Mapper; -use lib\Util; +use Exodus4D\Pathfinder\Lib\Util; class AbstractIterator extends \RecursiveArrayIterator { @@ -26,7 +26,10 @@ class AbstractIterator extends \RecursiveArrayIterator { */ protected static $removeUnmapped = true; - + /** + * AbstractIterator constructor. + * @param $data + */ function __construct($data){ parent::__construct($data, \RecursiveIteratorIterator::SELF_FIRST); } @@ -52,10 +55,10 @@ class AbstractIterator extends \RecursiveArrayIterator { /** * recursive iterator function called on every node - * @param $iterator - * @return mixed + * @param AbstractIterator $iterator + * @return AbstractIterator */ - static function recursiveIterator($iterator){ + static function recursiveIterator(AbstractIterator $iterator){ $keyWhitelist = array_keys(static::$map); diff --git a/app/main/data/mapper/sortingiterator.php b/app/Data/Mapper/SortingIterator.php similarity index 89% rename from app/main/data/mapper/sortingiterator.php rename to app/Data/Mapper/SortingIterator.php index 875bc4dc..ceb4b7f3 100644 --- a/app/main/data/mapper/sortingiterator.php +++ b/app/Data/Mapper/SortingIterator.php @@ -6,7 +6,7 @@ * Time: 00:55 */ -namespace data\mapper; +namespace Exodus4D\Pathfinder\Data\Mapper; class SortingIterator extends \ArrayIterator { diff --git a/app/main/db/sql/mysql/session.php b/app/Db/Sql/Mysql/Session.php similarity index 84% rename from app/main/db/sql/mysql/session.php rename to app/Db/Sql/Mysql/Session.php index 1de0eeb8..cce602ec 100644 --- a/app/main/db/sql/mysql/session.php +++ b/app/Db/Sql/Mysql/Session.php @@ -6,12 +6,19 @@ * Time: 15:40 */ -namespace DB\SQL\MySQL; +namespace Exodus4D\Pathfinder\Db\Sql\Mysql; class Session extends \DB\SQL\Session { - + /** + * Session constructor. + * @param \DB\SQL $db + * @param string $table + * @param bool $force + * @param callback $onsuspect + * @param string $key + */ function __construct(\DB\SQL $db, string $table = 'sessions', bool $force = true, $onsuspect = null, $key = null){ if($force){ // create sessions table diff --git a/app/main/db/sql/mysql/tablemodifier.php b/app/Db/Sql/Mysql/tablemodifier.php similarity index 96% rename from app/main/db/sql/mysql/tablemodifier.php rename to app/Db/Sql/Mysql/tablemodifier.php index b28b62f4..7e3312ef 100644 --- a/app/main/db/sql/mysql/tablemodifier.php +++ b/app/Db/Sql/Mysql/tablemodifier.php @@ -12,7 +12,9 @@ * - FOREIGN KEY CONSTRAINTS (single column key) */ -namespace DB\SQL\MySQL; +namespace Exodus4D\Pathfinder\Db\Sql\Mysql; + + use DB\SQL; class TableModifier extends SQL\TableModifier { @@ -23,7 +25,7 @@ class TableModifier extends SQL\TableModifier { /** * return table foreign key constraints as assoc array * -> if §constraint is passed, constraints are limited to that column - * @param null| SQL\MySQL\Constraint $constraint + * @param null| Constraint $constraint * @return Constraint[] */ public function listConstraint($constraint = null){ @@ -65,7 +67,7 @@ class TableModifier extends SQL\TableModifier { /** * checks whether a constraint name exists or not * -> does not check constraint params - * @param SQL\MySQL\Constraint $constraint + * @param Constraint $constraint * @return bool */ public function constraintExists($constraint){ @@ -75,7 +77,7 @@ class TableModifier extends SQL\TableModifier { /** * drop foreign key constraint - * @param SQL\MySQL\Constraint $constraint + * @param Constraint $constraint */ public function dropConstraint($constraint){ if($constraint->isValid()){ @@ -88,7 +90,7 @@ class TableModifier extends SQL\TableModifier { /** * Add/Update foreign key constraint - * @param SQL\MySQL\Constraint $constraint + * @param Constraint $constraint */ public function addConstraint($constraint){ @@ -131,7 +133,6 @@ class Column extends SQL\Column { } /** - * @see \DB\SQL\MySQL\TableModifier->constraintExists(); * @param Constraint $constraint * @return mixed */ @@ -147,7 +148,7 @@ class Column extends SQL\Column { * $constraintData['on-update'] => ON UPDATE action (optional) default: see \DB\SQL\MySQL\Constraint const * * @param array $constraintData - * @return SQL\MySQL\Constraint + * @return Constraint */ public function newConstraint($constraintData){ diff --git a/app/main/exception/configexception.php b/app/Exception/ConfigException.php similarity index 72% rename from app/main/exception/configexception.php rename to app/Exception/ConfigException.php index 9f2bb033..d61d89e4 100644 --- a/app/main/exception/configexception.php +++ b/app/Exception/ConfigException.php @@ -6,11 +6,14 @@ * Time: 18:53 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; class ConfigException extends PathfinderException { + /** + * @var array + */ protected $codes = [ 1000 => 500 ]; diff --git a/app/main/exception/databaseexception.php b/app/Exception/DatabaseException.php similarity index 65% rename from app/main/exception/databaseexception.php rename to app/Exception/DatabaseException.php index 187beeed..79ac3fe3 100644 --- a/app/main/exception/databaseexception.php +++ b/app/Exception/DatabaseException.php @@ -6,14 +6,22 @@ * Time: 20:31 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; + class DatabaseException extends PathfinderException { + /** + * @var array + */ protected $codes = [ 1500 => 500 ]; + /** + * DatabaseException constructor. + * @param string $message + */ public function __construct(string $message){ parent::__construct($message, 1500); } diff --git a/app/main/exception/dateexception.php b/app/Exception/DateException.php similarity index 74% rename from app/main/exception/dateexception.php rename to app/Exception/DateException.php index 4b578fa7..823c49a4 100644 --- a/app/main/exception/dateexception.php +++ b/app/Exception/DateException.php @@ -6,10 +6,14 @@ * Time: 18:12 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; class DateException extends PathfinderException { + + /** + * @var array + */ protected $codes = [ 3000 => 500 // invalid DateRange ]; diff --git a/app/main/exception/pathfinderexception.php b/app/Exception/PathfinderException.php similarity index 89% rename from app/main/exception/pathfinderexception.php rename to app/Exception/PathfinderException.php index 2636e1d4..19d08b83 100644 --- a/app/main/exception/pathfinderexception.php +++ b/app/Exception/PathfinderException.php @@ -6,9 +6,10 @@ * Time: 00:41 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; -use lib\Config; + +use Exodus4D\Pathfinder\Lib\Config; class PathfinderException extends \Exception { @@ -26,6 +27,11 @@ class PathfinderException extends \Exception { 0 => self::DEFAULT_RESPONSECODE ]; + /** + * PathfinderException constructor. + * @param string $message + * @param int $code + */ public function __construct(string $message, int $code = 0){ if( !array_key_exists($code, $this->codes) ){ // exception code not specified by child class diff --git a/app/main/exception/registrationexception.php b/app/Exception/RegistrationException.php similarity index 77% rename from app/main/exception/registrationexception.php rename to app/Exception/RegistrationException.php index b98e107b..bd0057b2 100644 --- a/app/main/exception/registrationexception.php +++ b/app/Exception/RegistrationException.php @@ -6,11 +6,14 @@ * Time: 21:21 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; class RegistrationException extends PathfinderException{ + /** + * @var array + */ protected $codes = [ 2000 => 403 ]; @@ -21,6 +24,11 @@ class RegistrationException extends PathfinderException{ */ private $field; + /** + * RegistrationException constructor. + * @param string $message + * @param string $field + */ public function __construct(string $message, string $field = ''){ parent::__construct($message, 2000); $this->field = $field; diff --git a/app/main/exception/validationexception.php b/app/Exception/ValidationException.php similarity index 78% rename from app/main/exception/validationexception.php rename to app/Exception/ValidationException.php index abfbf668..b28e1b80 100644 --- a/app/main/exception/validationexception.php +++ b/app/Exception/ValidationException.php @@ -6,11 +6,14 @@ * Time: 00:12 */ -namespace Exception; +namespace Exodus4D\Pathfinder\Exception; class ValidationException extends PathfinderException { + /** + * @var array + */ protected $codes = [ 2000 => 422 ]; @@ -21,6 +24,11 @@ class ValidationException extends PathfinderException { */ private $field; + /** + * ValidationException constructor. + * @param string $message + * @param string $field + */ public function __construct(string $message, string $field = ''){ parent::__construct($message, 2000); $this->field = $field; diff --git a/app/main/lib/api/AbstractClient.php b/app/Lib/Api/AbstractClient.php similarity index 97% rename from app/main/lib/api/AbstractClient.php rename to app/Lib/Api/AbstractClient.php index 4b8d9756..2d9157d2 100644 --- a/app/main/lib/api/AbstractClient.php +++ b/app/Lib/Api/AbstractClient.php @@ -6,7 +6,7 @@ * Time: 17:41 */ -namespace lib\api; +namespace Exodus4D\Pathfinder\Lib\Api; use Cache\Adapter\Filesystem\FilesystemCachePool; use Cache\Adapter\PHPArray\ArrayCachePool; @@ -14,10 +14,10 @@ use Cache\Adapter\Redis\RedisCachePool; use Cache\Namespaced\NamespacedCachePool; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; -use lib\Config; -use lib\Util; -use lib\logging; -use controller\LogController; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Util; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Controller\LogController; use Exodus4D\ESI\Client\ApiInterface; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\RequestInterface; @@ -89,8 +89,8 @@ abstract class AbstractClient extends \Prefab { * @return \Closure */ protected function newLog() : \Closure { - return function(string $action, string $level = 'warning') : logging\LogInterface { - $log = new logging\ApiLog($action, $level); + return function(string $action, string $level = 'warning') : Logging\LogInterface { + $log = new Logging\ApiLog($action, $level); $log->addHandler('stream', 'json', $this->getStreamConfig($action)); return $log; }; diff --git a/app/main/lib/api/CcpClient.php b/app/Lib/Api/CcpClient.php similarity index 93% rename from app/main/lib/api/CcpClient.php rename to app/Lib/Api/CcpClient.php index bce06a3c..d056c87f 100644 --- a/app/main/lib/api/CcpClient.php +++ b/app/Lib/Api/CcpClient.php @@ -6,9 +6,9 @@ * Time: 17:43 */ -namespace lib\api; +namespace Exodus4D\Pathfinder\Lib\Api; -use lib\Config; +use Exodus4D\Pathfinder\Lib\Config; use Exodus4D\ESI\Client\ApiInterface; use Exodus4D\ESI\Client\Ccp\Esi\Esi as Client; use Exodus4D\ESI\Client\Ccp\Esi\EsiInterface as ClientInterface; diff --git a/app/main/lib/api/EveScoutClient.php b/app/Lib/Api/EveScoutClient.php similarity index 91% rename from app/main/lib/api/EveScoutClient.php rename to app/Lib/Api/EveScoutClient.php index 5e682a37..0a869f3f 100644 --- a/app/main/lib/api/EveScoutClient.php +++ b/app/Lib/Api/EveScoutClient.php @@ -1,9 +1,9 @@ NO database is used * -> can be used to check if a certain DB exists without connecting to it directly * @param string $alias - * @return SQL|null + * @return Sql|null */ - public function connectToServer(string $alias) : ?SQL { + public function connectToServer(string $alias) : ?Sql { $config = ($this->getConfig)($alias); $config['NAME'] = ''; return $this->newDB($config); @@ -95,9 +95,9 @@ class Pool extends \Prefab { * tries to create a database if not exists * -> DB user needs rights to create a DB * @param string $alias - * @return SQL|null + * @return Sql|null */ - public function createDB(string $alias) : ?SQL { + public function createDB(string $alias) : ?Sql { $db = null; $config = ($this->getConfig)($alias); // remove database from $dsn (we want to crate it) @@ -135,9 +135,9 @@ class Pool extends \Prefab { /** * get active connection from store or init new connection * @param string $alias - * @return SQL|null + * @return Sql|null */ - public function getDB(string $alias) : ?SQL { + public function getDB(string $alias) : ?Sql { if(!isset($this->connectionStore[$alias])){ $db = $this->newDB(($this->getConfig)($alias)); if(!is_null($db)){ @@ -175,14 +175,14 @@ class Pool extends \Prefab { /** * @param array $config - * @return SQL|null + * @return Sql|null */ - protected function newDB(array $config) : ?SQL { + protected function newDB(array $config) : ?Sql { $db = null; if($config['SCHEME'] == 'mysql'){ try{ - $db = new SQL($this->buildDnsFromConfig($config), $config['USER'], $config['PASS'], $config['OPTIONS']); + $db = new Sql($this->buildDnsFromConfig($config), $config['USER'], $config['PASS'], $config['OPTIONS']); }catch(\PDOException $e){ $this->pushError($config['ALIAS'], $e); diff --git a/app/main/lib/db/SQL.php b/app/Lib/Db/Sql.php similarity index 97% rename from app/main/lib/db/SQL.php rename to app/Lib/Db/Sql.php index 6ffc629f..3153e4ac 100644 --- a/app/main/lib/db/SQL.php +++ b/app/Lib/Db/Sql.php @@ -1,12 +1,12 @@ 'json' ]; + /** + * @var string + */ protected $channelType = 'api'; + /** + * ApiLog constructor. + * @param string $action + * @param string $level + * @throws \Exception + */ public function __construct(string $action, string $level){ parent::__construct($action); diff --git a/app/main/lib/logging/DefaultLog.php b/app/Lib/Logging/DefaultLog.php similarity index 83% rename from app/main/lib/logging/DefaultLog.php rename to app/Lib/Logging/DefaultLog.php index 885917d5..6a23a2ae 100644 --- a/app/main/lib/logging/DefaultLog.php +++ b/app/Lib/Logging/DefaultLog.php @@ -6,7 +6,7 @@ * Time: 22:08 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; class DefaultLog extends AbstractLog { diff --git a/app/main/lib/logging/formatter/MailFormatter.php b/app/Lib/Logging/Formatter/MailFormatter.php similarity index 84% rename from app/main/lib/logging/formatter/MailFormatter.php rename to app/Lib/Logging/Formatter/MailFormatter.php index 042872d4..dc990bd3 100644 --- a/app/main/lib/logging/formatter/MailFormatter.php +++ b/app/Lib/Logging/Formatter/MailFormatter.php @@ -6,13 +6,17 @@ * Time: 14:49 */ -namespace lib\logging\formatter; +namespace Exodus4D\Pathfinder\Lib\Logging\Formatter; -use lib\Config; +use Exodus4D\Pathfinder\Lib\Config; use Monolog\Formatter; class MailFormatter implements Formatter\FormatterInterface { + /** + * @param array $record + * @return mixed|string + */ public function format(array $record){ $tplDefaultData = [ @@ -34,6 +38,10 @@ class MailFormatter implements Formatter\FormatterInterface { return \Template::instance()->render('templates/mail/basic_inline.html', 'text/html', $tplData); } + /** + * @param array $records + * @return mixed|string + */ public function formatBatch(array $records){ $message = ''; foreach ($records as $key => $record) { diff --git a/app/main/lib/logging/handler/AbstractMapWebhookHandler.php b/app/Lib/Logging/Handler/AbstractMapWebhookHandler.php similarity index 97% rename from app/main/lib/logging/handler/AbstractMapWebhookHandler.php rename to app/Lib/Logging/Handler/AbstractMapWebhookHandler.php index 0a01ff32..2e34095d 100644 --- a/app/main/lib/logging/handler/AbstractMapWebhookHandler.php +++ b/app/Lib/Logging/Handler/AbstractMapWebhookHandler.php @@ -6,9 +6,9 @@ * Time: 10:18 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; -use lib\Util; +use Exodus4D\Pathfinder\Lib\Util; abstract class AbstractMapWebhookHandler extends AbstractWebhookHandler { diff --git a/app/main/lib/logging/handler/AbstractRallyWebhookHandler.php b/app/Lib/Logging/Handler/AbstractRallyWebhookHandler.php similarity index 98% rename from app/main/lib/logging/handler/AbstractRallyWebhookHandler.php rename to app/Lib/Logging/Handler/AbstractRallyWebhookHandler.php index f77d4dd2..c8ca5ddf 100644 --- a/app/main/lib/logging/handler/AbstractRallyWebhookHandler.php +++ b/app/Lib/Logging/Handler/AbstractRallyWebhookHandler.php @@ -6,10 +6,10 @@ * Time: 10:09 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; use League\HTMLToMarkdown\HtmlConverter; -use lib\Util; +use Exodus4D\Pathfinder\Lib\Util; abstract class AbstractRallyWebhookHandler extends AbstractWebhookHandler { @@ -150,7 +150,6 @@ abstract class AbstractRallyWebhookHandler extends AbstractWebhookHandler { protected function htmlToMarkdown($html){ $converter = new HtmlConverter(); $converter->getConfig()->setOption('strip_tags', true); - $markdown = $converter->convert($html); - return $markdown; + return $converter->convert($html); } } \ No newline at end of file diff --git a/app/main/lib/logging/handler/AbstractWebhookHandler.php b/app/Lib/Logging/Handler/AbstractWebhookHandler.php similarity index 98% rename from app/main/lib/logging/handler/AbstractWebhookHandler.php rename to app/Lib/Logging/Handler/AbstractWebhookHandler.php index 7dd2cb09..50869218 100644 --- a/app/main/lib/logging/handler/AbstractWebhookHandler.php +++ b/app/Lib/Logging/Handler/AbstractWebhookHandler.php @@ -6,9 +6,9 @@ * Time: 20:08 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; -use lib\Config; +use Exodus4D\Pathfinder\Lib\Config; use Monolog\Handler; use Monolog\Logger; diff --git a/app/main/lib/logging/handler/DiscordMapWebhookHandler.php b/app/Lib/Logging/Handler/DiscordMapWebhookHandler.php similarity index 76% rename from app/main/lib/logging/handler/DiscordMapWebhookHandler.php rename to app/Lib/Logging/Handler/DiscordMapWebhookHandler.php index 1c6b34c0..41f8c1a9 100644 --- a/app/main/lib/logging/handler/DiscordMapWebhookHandler.php +++ b/app/Lib/Logging/Handler/DiscordMapWebhookHandler.php @@ -6,7 +6,7 @@ * Time: 10:23 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; class DiscordMapWebhookHandler extends AbstractMapWebhookHandler { diff --git a/app/main/lib/logging/handler/DiscordRallyWebhookHandler.php b/app/Lib/Logging/Handler/DiscordRallyWebhookHandler.php similarity index 78% rename from app/main/lib/logging/handler/DiscordRallyWebhookHandler.php rename to app/Lib/Logging/Handler/DiscordRallyWebhookHandler.php index 1078d65e..8ed8d986 100644 --- a/app/main/lib/logging/handler/DiscordRallyWebhookHandler.php +++ b/app/Lib/Logging/Handler/DiscordRallyWebhookHandler.php @@ -6,11 +6,15 @@ * Time: 10:13 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; class DiscordRallyWebhookHandler extends AbstractRallyWebhookHandler { + /** + * @param $html + * @return string + */ protected function htmlToMarkdown($html){ $markdown = parent::htmlToMarkdown($html); // Discord supports syntax highlighting for MarkDown diff --git a/app/main/lib/logging/handler/SlackMapWebhookHandler.php b/app/Lib/Logging/Handler/SlackMapWebhookHandler.php similarity index 76% rename from app/main/lib/logging/handler/SlackMapWebhookHandler.php rename to app/Lib/Logging/Handler/SlackMapWebhookHandler.php index 72406c81..bff2a7f8 100644 --- a/app/main/lib/logging/handler/SlackMapWebhookHandler.php +++ b/app/Lib/Logging/Handler/SlackMapWebhookHandler.php @@ -6,9 +6,9 @@ * Time: 20:52 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; + class SlackMapWebhookHandler extends AbstractMapWebhookHandler { - } \ No newline at end of file diff --git a/app/main/lib/logging/handler/SlackRallyWebhookHandler.php b/app/Lib/Logging/Handler/SlackRallyWebhookHandler.php similarity index 76% rename from app/main/lib/logging/handler/SlackRallyWebhookHandler.php rename to app/Lib/Logging/Handler/SlackRallyWebhookHandler.php index 319a7091..e90e2d31 100644 --- a/app/main/lib/logging/handler/SlackRallyWebhookHandler.php +++ b/app/Lib/Logging/Handler/SlackRallyWebhookHandler.php @@ -6,12 +6,9 @@ * Time: 17:32 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; class SlackRallyWebhookHandler extends AbstractRallyWebhookHandler { - - - } \ No newline at end of file diff --git a/app/main/lib/logging/handler/SocketHandler.php b/app/Lib/Logging/Handler/SocketHandler.php similarity index 85% rename from app/main/lib/logging/handler/SocketHandler.php rename to app/Lib/Logging/Handler/SocketHandler.php index 4687e0c4..071d87e9 100644 --- a/app/main/lib/logging/handler/SocketHandler.php +++ b/app/Lib/Logging/Handler/SocketHandler.php @@ -6,7 +6,7 @@ * Time: 19:11 */ -namespace lib\logging\handler; +namespace Exodus4D\Pathfinder\Lib\Logging\Handler; use Monolog\Logger; @@ -19,6 +19,13 @@ class SocketHandler extends \Monolog\Handler\SocketHandler { */ protected $metaData = []; + /** + * SocketHandler constructor. + * @param $connectionString + * @param int $level + * @param bool $bubble + * @param array $metaData + */ public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true, $metaData = []){ $this->metaData = $metaData; diff --git a/app/main/lib/logging/LogCollection.php b/app/Lib/Logging/LogCollection.php similarity index 97% rename from app/main/lib/logging/LogCollection.php rename to app/Lib/Logging/LogCollection.php index 5e8ea48b..721a3972 100644 --- a/app/main/lib/logging/LogCollection.php +++ b/app/Lib/Logging/LogCollection.php @@ -6,7 +6,7 @@ * Time: 11:23 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; class LogCollection extends AbstractLog { @@ -32,6 +32,10 @@ class LogCollection extends AbstractLog { */ private $collection = null; + /** + * LogCollection constructor. + * @param string $action + */ public function __construct(string $action){ parent::__construct($action); diff --git a/app/main/lib/logging/LogInterface.php b/app/Lib/Logging/LogInterface.php similarity index 97% rename from app/main/lib/logging/LogInterface.php rename to app/Lib/Logging/LogInterface.php index ef26c261..e5346dd6 100644 --- a/app/main/lib/logging/LogInterface.php +++ b/app/Lib/Logging/LogInterface.php @@ -6,7 +6,7 @@ * Time: 14:10 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; interface LogInterface { diff --git a/app/main/lib/logging/MapLog.php b/app/Lib/Logging/MapLog.php similarity index 95% rename from app/main/lib/logging/MapLog.php rename to app/Lib/Logging/MapLog.php index bb527da1..447340dd 100644 --- a/app/main/lib/logging/MapLog.php +++ b/app/Lib/Logging/MapLog.php @@ -6,10 +6,10 @@ * Time: 22:08 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; -use controller\LogController; +use Exodus4D\Pathfinder\Controller\LogController; class MapLog extends AbstractCharacterLog { @@ -34,7 +34,12 @@ class MapLog extends AbstractCharacterLog { */ protected $logActivity = false; - + /** + * MapLog constructor. + * @param string $action + * @param array $objectData + * @throws \Exception + */ public function __construct(string $action, array $objectData){ parent::__construct($action, $objectData); diff --git a/app/main/lib/logging/RallyLog.php b/app/Lib/Logging/RallyLog.php similarity index 92% rename from app/main/lib/logging/RallyLog.php rename to app/Lib/Logging/RallyLog.php index 986b359a..ebfc3efb 100644 --- a/app/main/lib/logging/RallyLog.php +++ b/app/Lib/Logging/RallyLog.php @@ -6,9 +6,10 @@ * Time: 16:50 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; -use lib\Config; + +use Exodus4D\Pathfinder\Lib\Config; class RallyLog extends AbstractCharacterLog { @@ -27,7 +28,12 @@ class RallyLog extends AbstractCharacterLog { */ protected $channelType = 'rally'; - + /** + * RallyLog constructor. + * @param string $action + * @param array $objectData + * @throws \Exception + */ public function __construct(string $action, array $objectData){ parent::__construct($action, $objectData); diff --git a/app/main/lib/logging/UserLog.php b/app/Lib/Logging/UserLog.php similarity index 78% rename from app/main/lib/logging/UserLog.php rename to app/Lib/Logging/UserLog.php index 5beb2c78..d4e3813d 100644 --- a/app/main/lib/logging/UserLog.php +++ b/app/Lib/Logging/UserLog.php @@ -6,7 +6,7 @@ * Time: 14:15 */ -namespace lib\logging; +namespace Exodus4D\Pathfinder\Lib\Logging; class UserLog extends AbstractChannelLog { @@ -25,6 +25,12 @@ class UserLog extends AbstractChannelLog { */ protected $channelType = 'user'; + /** + * UserLog constructor. + * @param string $action + * @param array $objectData + * @throws \Exception + */ public function __construct(string $action, array $objectData){ parent::__construct($action, $objectData); diff --git a/app/main/lib/Monolog.php b/app/Lib/Monolog.php similarity index 92% rename from app/main/lib/Monolog.php rename to app/Lib/Monolog.php index ab44103e..ff6d2220 100644 --- a/app/main/lib/Monolog.php +++ b/app/Lib/Monolog.php @@ -6,11 +6,11 @@ * Time: 20:17 */ -namespace lib; +namespace Exodus4D\Pathfinder\Lib; -use controller\LogController; -use lib\logging; +use Exodus4D\Pathfinder\Controller\LogController; +use Exodus4D\Pathfinder\Lib\Logging; use Monolog\Registry; use Monolog\Processor\ProcessorInterface; use Monolog\Formatter\FormatterInterface; @@ -43,7 +43,7 @@ class Monolog extends \Prefab { 'line' => 'Monolog\Formatter\LineFormatter', 'json' => 'Monolog\Formatter\JsonFormatter', 'html' => 'Monolog\Formatter\HtmlFormatter', - 'mail' => 'lib\logging\formatter\MailFormatter' + 'mail' => 'Exodus4D\Pathfinder\Lib\Logging\Formatter\MailFormatter' ]; /** @@ -52,11 +52,11 @@ class Monolog extends \Prefab { const HANDLER = [ 'stream' => 'Monolog\Handler\StreamHandler', 'mail' => 'Monolog\Handler\SwiftMailerHandler', - 'socket' => 'lib\logging\handler\SocketHandler', - 'slackMap' => 'lib\logging\handler\SlackMapWebhookHandler', - 'slackRally' => 'lib\logging\handler\SlackRallyWebhookHandler', - 'discordMap' => 'lib\logging\handler\DiscordMapWebhookHandler', - 'discordRally' => 'lib\logging\handler\DiscordRallyWebhookHandler' + 'socket' => 'Exodus4D\Pathfinder\Lib\Logging\Handler\SocketHandler', + 'slackMap' => 'Exodus4D\Pathfinder\Lib\Logging\Handler\SlackMapWebhookHandler', + 'slackRally' => 'Exodus4D\Pathfinder\Lib\Logging\Handler\SlackRallyWebhookHandler', + 'discordMap' => 'Exodus4D\Pathfinder\Lib\Logging\Handler\DiscordMapWebhookHandler', + 'discordRally' => 'Exodus4D\Pathfinder\Lib\Logging\Handler\DiscordRallyWebhookHandler' ]; /** diff --git a/app/main/lib/PriorityCacheStore.php b/app/Lib/PriorityCacheStore.php similarity index 98% rename from app/main/lib/PriorityCacheStore.php rename to app/Lib/PriorityCacheStore.php index 740d0a32..85add008 100644 --- a/app/main/lib/PriorityCacheStore.php +++ b/app/Lib/PriorityCacheStore.php @@ -1,7 +1,7 @@ $task, 'load' => $load ]; - - return $payload; } /** diff --git a/app/main/lib/socket/NullSocket.php b/app/Lib/Socket/NullSocket.php similarity index 94% rename from app/main/lib/socket/NullSocket.php rename to app/Lib/Socket/NullSocket.php index 9b60e3cb..7702f642 100644 --- a/app/main/lib/socket/NullSocket.php +++ b/app/Lib/Socket/NullSocket.php @@ -6,7 +6,7 @@ * Time: 23:22 */ -namespace lib\socket; +namespace Exodus4D\Pathfinder\Lib\Socket; use React\Socket; diff --git a/app/main/lib/socket/SocketInterface.php b/app/Lib/Socket/SocketInterface.php similarity index 93% rename from app/main/lib/socket/SocketInterface.php rename to app/Lib/Socket/SocketInterface.php index e56bf33d..238c97a9 100644 --- a/app/main/lib/socket/SocketInterface.php +++ b/app/Lib/Socket/SocketInterface.php @@ -6,10 +6,9 @@ * Time: 11:26 */ -namespace lib\socket; +namespace Exodus4D\Pathfinder\Lib\Socket; -use React\EventLoop; use React\Promise; interface SocketInterface { diff --git a/app/main/lib/socket/TcpSocket.php b/app/Lib/Socket/TcpSocket.php similarity index 91% rename from app/main/lib/socket/TcpSocket.php rename to app/Lib/Socket/TcpSocket.php index 68dbb875..651a79db 100644 --- a/app/main/lib/socket/TcpSocket.php +++ b/app/Lib/Socket/TcpSocket.php @@ -6,7 +6,7 @@ * Time: 10:04 */ -namespace lib\socket; +namespace Exodus4D\Pathfinder\Lib\Socket; use React\Socket; diff --git a/app/main/lib/util.php b/app/Lib/Util.php similarity index 99% rename from app/main/lib/util.php rename to app/Lib/Util.php index 8d031de6..ec9d3324 100644 --- a/app/main/lib/util.php +++ b/app/Lib/Util.php @@ -6,7 +6,8 @@ * Time: 17:32 */ -namespace lib; +namespace Exodus4D\Pathfinder\Lib; + class Util { diff --git a/app/Model/AbstractModel.php b/app/Model/AbstractModel.php new file mode 100644 index 00000000..f87e8ad5 --- /dev/null +++ b/app/Model/AbstractModel.php @@ -0,0 +1,1156 @@ + leave this at a higher value + * @var int + */ + protected $ttl = 60; + + /** + * caching for relational data + * @var int + */ + protected $rel_ttl = 0; + + /** + * ass static columns for this table + * -> can be overwritten in child models + * @var bool + */ + protected $addStaticFields = true; + + /** + * enables table truncate + * -> see truncate(); + * -> CAUTION! if set to true truncate() will clear ALL rows! + * @var bool + */ + protected $allowTruncate = false; + + /** + * enables change for "active" column + * -> see setActive(); + * -> $this->active = false; will NOT work (prevent abuse)! + * @var bool + */ + private $allowActiveChange = false; + + /** + * getData() cache key prefix + * -> do not change, otherwise cached data is lost + * @var string + */ + private $dataCacheKeyPrefix = 'DATACACHE'; + + /** + * enables data export for this table + * -> can be overwritten in child models + * @var bool + */ + public static $enableDataExport = false; + + /** + * enables data import for this table + * -> can be overwritten in child models + * @var bool + */ + public static $enableDataImport = false; + + /** + * collection for validation errors + * @var array + */ + protected $validationError = []; + + + /** + * default charset for table + */ + const DEFAULT_CHARSET = 'utf8mb4'; + + /** + * default caching time of field schema - seconds + */ + const DEFAULT_TTL = 86400; + + /** + * default TTL for getData(); cache - seconds + */ + const DEFAULT_CACHE_TTL = 120; + + /** + * default TTL or temp table data read from *.csv file + * -> used during data import + */ + const DEFAULT_CACHE_CSV_TTL = 120; + + /** + * cache key prefix name for "full table" indexing + * -> used e.g. for a "search" index; or "import" index for *.csv imports + */ + const CACHE_KEY_PREFIX = 'INDEX'; + + /** + * cache key name for temp data import from *.csv files per table + */ + const CACHE_KEY_CSV_PREFIX = 'CSV'; + + /** + * default TTL for SQL query cache + */ + const DEFAULT_SQL_TTL = 3; + + /** + * data from Universe tables is static and does not change frequently + * -> refresh static data after X days + */ + const CACHE_MAX_DAYS = 60; + + /** + * class not exists error + */ + const ERROR_INVALID_MODEL_CLASS = 'Model class (%s) not found'; + + /** + * AbstractModel constructor. + * @param null $db + * @param null $table + * @param null $fluid + * @param int $ttl + * @param string $charset + */ + public function __construct($db = null, $table = null, $fluid = null, $ttl = self::DEFAULT_TTL, $charset = self::DEFAULT_CHARSET){ + + if(!is_object($db)){ + $db = self::getF3()->DB->getDB(static::DB_ALIAS); + } + + if(is_null($db)){ + // no valid DB connection found -> break on error + self::getF3()->set('HALT', true); + } + + // set charset -> used during table setup() + $this->charset = $charset; + + $this->addStaticFieldConfig(); + + parent::__construct($db, $table, $fluid, $ttl); + + // insert events ------------------------------------------------------------------------------------ + $this->beforeinsert(function($self, $pkeys){ + return $self->beforeInsertEvent($self, $pkeys); + }); + + $this->afterinsert(function($self, $pkeys){ + $self->afterInsertEvent($self, $pkeys); + }); + + // update events ------------------------------------------------------------------------------------ + $this->beforeupdate(function($self, $pkeys){ + return $self->beforeUpdateEvent($self, $pkeys); + }); + + $this->afterupdate(function($self, $pkeys){ + $self->afterUpdateEvent($self, $pkeys); + }); + + // erase events ------------------------------------------------------------------------------------- + $this->beforeerase(function($self, $pkeys){ + return $self->beforeEraseEvent($self, $pkeys); + }); + + $this->aftererase(function($self, $pkeys){ + $self->afterEraseEvent($self, $pkeys); + }); + } + + /** + * checks whether table exists on DB + * @return bool + */ + public function tableExists() : bool { + return is_object($this->db) ? $this->db->tableExists($this->table) : false; + } + + /** + * clear existing table Schema cache + * @return bool + */ + public function clearSchemaCache() : bool { + $f3 = self::getF3(); + $cache=\Cache::instance(); + if( + $f3->CACHE && is_object($this->db) && + $cache->exists($hash = $f3->hash($this->db->getDSN() . $this->table) . '.schema') + ){ + return (bool)$cache->clear($hash); + } + return false; + } + + /** + * @param string $key + * @param mixed $val + * @return mixed + * @throws ValidationException + */ + public function set($key, $val){ + if(is_string($val)){ + $val = trim($val); + } + + if( + !$this->dry() && + $key != 'updated' + ){ + if($this->exists($key)){ + // get raw column data (no objects) + $currentVal = $this->get($key, true); + + if(is_object($val)){ + if( + is_subclass_of($val, 'Model\AbstractModel') && + $val->_id != $currentVal + ){ + // relational object changed + $this->touch('updated'); + } + }elseif($val != $currentVal){ + // non object value + $this->touch('updated'); + } + } + } + + if(!$this->validateField($key, $val)){ + $this->throwValidationException($key); + } + + return parent::set($key, $val); + } + + /** + * setter for "active" status + * -> default: keep current "active" status + * -> can be overwritten + * @param bool $active + * @return mixed + */ + public function set_active($active){ + if($this->allowActiveChange){ + // allowed to set/change -> reset "allowed" property + $this->allowActiveChange = false; + }else{ + // not allowed to set/change -> keep current status + $active = $this->active; + } + return $active; + } + + /** + * get static fields for this model instance + * @return array + */ + protected function getStaticFieldConf() : array { + $staticFieldConfig = []; + + // static tables (fixed data) do not require them... + if($this->addStaticFields){ + $staticFieldConfig = [ + 'created' => [ + 'type' => Schema::DT_TIMESTAMP, + 'default' => Schema::DF_CURRENT_TIMESTAMP, + 'index' => true + ], + 'updated' => [ + 'type' => Schema::DT_TIMESTAMP, + 'default' => Schema::DF_CURRENT_TIMESTAMP, + 'index' => true + ] + ]; + } + + return $staticFieldConfig; + } + + /** + * extent the fieldConf Array with static fields for each table + */ + private function addStaticFieldConfig(){ + $this->fieldConf = array_merge($this->getStaticFieldConf(), $this->fieldConf); + } + + /** + * validates a table column based on validation settings + * @param string $key + * @param $val + * @return bool + */ + protected function validateField(string $key, $val) : bool { + $valid = true; + if($fieldConf = $this->fieldConf[$key]){ + if($method = $this->fieldConf[$key]['validate']){ + if( !is_string($method)){ + $method = $key; + } + $method = 'validate_' . $method; + if(method_exists($this, $method)){ + // validate $key (column) with this method... + $valid = $this->$method($key, $val); + }else{ + self::getF3()->error(501, 'Method ' . get_class($this) . '->' . $method . '() is not implemented'); + } + } + } + + return $valid; + } + + /** + * validates a model field to be a valid relational model + * @param $key + * @param $val + * @return bool + * @throws ValidationException + */ + protected function validate_notDry($key, $val) : bool { + $valid = true; + if($colConf = $this->fieldConf[$key]){ + if(isset($colConf['belongs-to-one'])){ + if( (is_int($val) || ctype_digit($val)) && (int)$val > 0){ + $valid = true; + }elseif( is_a($val, $colConf['belongs-to-one']) && !$val->dry() ){ + $valid = true; + }else{ + $valid = false; + $msg = 'Validation failed: "' . get_class($this) . '->' . $key . '" must be a valid instance of ' . $colConf['belongs-to-one']; + $this->throwValidationException($key, $msg); + } + } + } + + return $valid; + } + + /** + * validates a model field to be not empty + * @param $key + * @param $val + * @return bool + */ + protected function validate_notEmpty($key, $val) : bool { + $valid = false; + if($colConf = $this->fieldConf[$key]){ + switch($colConf['type']){ + case Schema::DT_INT: + case Schema::DT_FLOAT: + if( (is_int($val) || ctype_digit($val)) && (int)$val > 0){ + $valid = true; + } + break; + case Schema::DT_VARCHAR128: + case Schema::DT_VARCHAR256: + case Schema::DT_VARCHAR512: + if(!empty($val)){ + $valid = true; + } + break; + default: + } + } + + return $valid; + } + + /** + * get key for for all objects in this table + * @return string + */ + private function getTableCacheKey() : string { + return $this->dataCacheKeyPrefix .'.' . strtoupper($this->table); + } + + /** + * get the cache key for this model + * ->do not set a key if the model is not saved! + * @param string $dataCacheTableKeyPrefix + * @return null|string + */ + protected function getCacheKey(string $dataCacheTableKeyPrefix = '') : ?string { + $cacheKey = null; + + // set a model unique cache key if the model is saved + if($this->_id > 0){ + $cacheKey = $this->getTableCacheKey(); + + // check if there is a given key prefix + // -> if not, use the standard key. + // this is useful for caching multiple data sets according to one row entry + if(!empty($dataCacheTableKeyPrefix)){ + $cacheKey .= '.' . $dataCacheTableKeyPrefix . '_'; + }else{ + $cacheKey .= '.ID_'; + } + $cacheKey .= (string)$this->_id; + } + + return $cacheKey; + } + + /** + * get cached data from this model + * @param string $dataCacheKeyPrefix - optional key prefix + * @return mixed|null + */ + protected function getCacheData($dataCacheKeyPrefix = ''){ + $cacheData = null; + // table cache exists + // -> check cache for this row data + if(!is_null($cacheKey = $this->getCacheKey($dataCacheKeyPrefix))){ + self::getF3()->exists($cacheKey, $cacheData); + } + return $cacheData; + } + + /** + * update/set the getData() cache for this object + * @param $cacheData + * @param string $dataCacheKeyPrefix + * @param int $data_ttl + */ + public function updateCacheData($cacheData, string $dataCacheKeyPrefix = '', int $data_ttl = self::DEFAULT_CACHE_TTL){ + $cacheDataTmp = (array)$cacheData; + + // check if data should be cached + // and cacheData is not empty + if( + $data_ttl > 0 && + !empty($cacheDataTmp) + ){ + $cacheKey = $this->getCacheKey($dataCacheKeyPrefix); + if(!is_null($cacheKey)){ + self::getF3()->set($cacheKey, $cacheData, $data_ttl); + } + } + } + + /** + * unset the getData() cache for this object + * -> see also clearCacheDataWithPrefix(), for more information + */ + public function clearCacheData(){ + $this->clearCache($this->getCacheKey()); + } + + /** + * unset object cached data by prefix + * -> primarily used by object cache with multiple data caches + * @param string $dataCacheKeyPrefix + */ + public function clearCacheDataWithPrefix(string $dataCacheKeyPrefix = ''){ + $this->clearCache($this->getCacheKey($dataCacheKeyPrefix)); + } + + /** + * unset object cached data (if exists) + * @param $cacheKey + */ + private function clearCache($cacheKey){ + if(!empty($cacheKey)){ + $f3 = self::getF3(); + if($f3->exists($cacheKey)){ + $f3->clear($cacheKey); + } + } + } + + /** + * throw validation exception for a model property + * @param string $col + * @param string $msg + * @throws ValidationException + */ + protected function throwValidationException(string $col, string $msg = ''){ + $msg = empty($msg) ? 'Validation failed: "' . $col . '".' : $msg; + throw new ValidationException($msg, $col); + } + + /** + * @param string $msg + * @throws DatabaseException + */ + protected function throwDbException(string $msg){ + throw new DatabaseException($msg); + } + + /** + * checks whether this model is active or not + * each model should have an "active" column + * @return bool + */ + public function isActive() : bool { + return (bool)$this->active; + } + + /** + * set active state for a model + * -> do NOT use $this->active for status change! + * -> this will not work (prevent abuse) + * @param bool $active + */ + public function setActive(bool $active){ + // enables "active" change for this model + $this->allowActiveChange = true; + $this->active = $active; + } + + /** + * get single dataSet by id + * @param int $id + * @param int $ttl + * @param bool $isActive + * @return bool + */ + public function getById(int $id, int $ttl = self::DEFAULT_SQL_TTL, bool $isActive = true) : bool { + return $this->getByForeignKey($this->primary, $id, ['limit' => 1], $ttl, $isActive); + } + + /** + * get dataSet by foreign column (single result) + * @param string $key + * @param $value + * @param array $options + * @param int $ttl + * @param bool $isActive + * @return bool + */ + public function getByForeignKey(string $key, $value, array $options = [], int $ttl = 0, bool $isActive = true) : bool { + $filters = [self::getFilter($key, $value)]; + + if($isActive && $this->exists('active')){ + $filters[] = self::getFilter('active', true); + } + + $this->filterRel(); + + return $this->load($this->mergeFilter($filters), $options, $ttl); + } + + /** + * apply filter() for relations + * -> overwrite in child classes + * @see https://github.com/ikkez/f3-cortex#filter + */ + protected function filterRel() : void {} + + /** + * get first model from a relation that matches $filter + * @param string $key + * @param array $filter + * @return mixed|null + */ + protected function relFindOne(string $key, array $filter){ + $relModel = null; + $relFilter = []; + if($this->exists($key, true)){ + $fieldConf = $this->getFieldConfiguration(); + if(array_key_exists($key, $fieldConf)){ + if(array_key_exists($type = 'has-many', $fieldConf[$key])){ + $fromConf = $fieldConf[$key][$type]; + $relFilter = self::getFilter($fromConf[1], $this->getRaw($fromConf['relField'])); + } + } + + /** + * @var $relModel self|bool + */ + $relModel = $this->rel($key)->findone($this->mergeFilter([$relFilter, $this->mergeWithRelFilter($key, $filter)])); + } + + return $relModel ? : null; + } + + /** + * get all models from a relation that match $filter + * @param string $key + * @param array $filter + * @return CortexCollection|null + */ + protected function relFind(string $key, array $filter) : ?CortexCollection { + $relModel = null; + $relFilter = []; + if($this->exists($key, true)){ + $fieldConf = $this->getFieldConfiguration(); + if(array_key_exists($key, $fieldConf)){ + if(array_key_exists($type = 'has-many', $fieldConf[$key])){ + $fromConf = $fieldConf[$key][$type]; + $relFilter = self::getFilter($fromConf[1], $this->getRaw($fromConf['relField'])); + } + } + + /** + * @var $relModel CortexCollection|bool + */ + $relModel = $this->rel($key)->find($this->mergeFilter([$relFilter, $this->mergeWithRelFilter($key, $filter)])); + } + + return $relModel ? : null; + } + + /** + * Event "Hook" function + * can be overwritten + * return false will stop any further action + * @param self $self + * @param $pkeys + * @return bool + */ + public function beforeInsertEvent($self, $pkeys) : bool { + if($this->exists('updated')){ + $this->touch('updated'); + } + return true; + } + + /** + * Event "Hook" function + * can be overwritten + * return false will stop any further action + * @param self $self + * @param $pkeys + */ + public function afterInsertEvent($self, $pkeys){ + } + + /** + * Event "Hook" function + * can be overwritten + * return false will stop any further action + * @param self $self + * @param $pkeys + * @return bool + */ + public function beforeUpdateEvent($self, $pkeys) : bool { + return true; + } + + /** + * Event "Hook" function + * can be overwritten + * return false will stop any further action + * @param self $self + * @param $pkeys + */ + public function afterUpdateEvent($self, $pkeys){ + } + + /** + * Event "Hook" function + * can be overwritten + * @param self $self + * @param $pkeys + * @return bool + */ + public function beforeEraseEvent($self, $pkeys) : bool { + return true; + } + + /** + * Event "Hook" function + * can be overwritten + * @param self $self + * @param $pkeys + */ + public function afterEraseEvent($self, $pkeys){ + } + + /** + * function should be overwritten in parent classes + * @return bool + */ + public function isValid() : bool { + return true; + } + + /** + * get row count in this table + * @return int + */ + public function getRowCount() : int { + return is_object($this->db) ? $this->db->getRowCount($this->getTable()) : 0; + } + + /** + * truncate all table rows + * -> Use with Caution!!! + */ + public function truncate(){ + if($this->allowTruncate && is_object($this->db)){ + $this->db->exec("TRUNCATE " . $this->getTable()); + } + } + + /** + * format dateTime column + * @param $column + * @param string $format + * @return false|null|string + */ + public function getFormattedColumn($column, $format = 'Y-m-d H:i'){ + return $this->get($column) ? date($format, strtotime( $this->get($column) )) : null; + } + + /** + * export and download table data as *.csv + * this is primarily used for static tables + * @param array $fields + * @return bool + */ + public function exportData(array $fields = []) : bool { + $status = false; + + if(static::$enableDataExport){ + $tableModifier = static::getTableModifier(); + $headers = $tableModifier->getCols(); + + if($fields){ + // columns to export -> reIndex keys + $headers = array_values(array_intersect($headers, $fields)); + } + + // just get the records with existing columns + // -> no "virtual" fields or "new" columns + $this->fields($headers); + $allRecords = $this->find(); + + if($allRecords){ + $tableData = $allRecords->castAll(0); + + // format data -> "id" must be first key + foreach($tableData as &$rowData){ + $rowData = [$this->primary => $rowData['_id']] + $rowData; + unset($rowData['_id']); + } + + $sheet = \Sheet::instance(); + $data = $sheet->dumpCSV($tableData, $headers); + + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Content-Type: text/csv;charset=UTF-8'); + header('Content-Disposition: attachment;filename=' . $this->getTable() . '.csv'); + echo $data; + exit(); + } + } + + return $status; + } + + /** + * read *.csv file for a $table name + * -> 'group' by $getByKey column name and return array + * @param string $table + * @param string $getByKey + * @return array + */ + public static function getCSVData(string $table, string $getByKey = 'id') : array { + $hashKeyTableCSV = static::generateHashKeyTable($table, static::CACHE_KEY_PREFIX . '_' . self::CACHE_KEY_CSV_PREFIX); + + if( + !self::getF3()->exists($hashKeyTableCSV, $tableData) && + !empty($tableData = Util::arrayGetBy(self::loadCSV($table), $getByKey, false)) + ){ + self::getF3()->set($hashKeyTableCSV, $tableData, self::DEFAULT_CACHE_CSV_TTL); + } + + return $tableData; + } + + /** + * load data from *.csv file + * @param string $fileName + * @return array + */ + protected static function loadCSV(string $fileName) : array { + $tableData = []; + + // rtrim(); for arrays (removes empty values) from the end + $rtrim = function($array = [], $lengthMin = false) : array { + $length = key(array_reverse(array_diff($array, ['']), 1))+1; + $length = $length < $lengthMin ? $lengthMin : $length; + return array_slice($array, 0, $length); + }; + + if($fileName){ + $filePath = self::getF3()->get('EXPORT') . 'csv/' . $fileName . '.csv'; + if(is_file($filePath)){ + $handle = @fopen($filePath, 'r'); + $keys = array_map('lcfirst', fgetcsv($handle, 0, ';')); + $keys = $rtrim($keys); + + if(count($keys) > 0){ + while (!feof($handle)) { + $tableData[] = array_combine($keys, $rtrim(fgetcsv($handle, 0, ';'), count($keys))); + } + }else{ + self::getF3()->error(500, 'File could not be read'); + } + }else{ + self::getF3()->error(404, 'File not found: ' . $filePath); + } + } + + return $tableData; + } + + /** + * import table data from a *.csv file + * @return array|bool + */ + public function importData(){ + $status = false; + + if( + static::$enableDataImport && + !empty($tableData = self::loadCSV($this->getTable())) + ){ + // import row data + $status = $this->importStaticData($tableData); + $this->getF3()->status(202); + } + + return $status; + } + + /** + * insert/update static data into this table + * WARNING: rows will be deleted if not part of $tableData ! + * @param array $tableData + * @return array + */ + protected function importStaticData(array $tableData = []) : array { + $rowIDs = []; + $addedCount = 0; + $updatedCount = 0; + $deletedCount = 0; + + $tableModifier = static::getTableModifier(); + $fields = $tableModifier->getCols(); + + foreach($tableData as $rowData){ + // search for existing record and update columns + $this->getById($rowData['id'], 0); + if($this->dry()){ + $addedCount++; + }else{ + $updatedCount++; + } + $this->copyfrom($rowData, $fields); + $this->save(); + $rowIDs[] = $this->_id; + $this->reset(); + } + + // remove old data + $oldRows = $this->find('id NOT IN (' . implode(',', $rowIDs) . ')'); + if($oldRows){ + foreach($oldRows as $oldRow){ + $oldRow->erase(); + $deletedCount++; + } + } + return ['added' => $addedCount, 'updated' => $updatedCount, 'deleted' => $deletedCount]; + } + + /** + * get "default" logging object for this kind of model + * -> can be overwritten + * @param string $action + * @return Logging\LogInterface + */ + protected function newLog(string $action = '') : Logging\LogInterface{ + return new Logging\DefaultLog($action); + } + + /** + * get formatter callback function for parsed logs + * @return null + */ + protected function getLogFormatter(){ + return null; + } + + /** + * add new validation error + * @param ValidationException $e + */ + protected function setValidationError(ValidationException $e){ + $this->validationError[] = $e->getError(); + } + + /** + * get all validation errors + * @return array + */ + public function getErrors() : array { + return $this->validationError; + } + + /** + * checks whether data is outdated and should be refreshed + * @return bool + */ + protected function isOutdated() : bool { + $outdated = true; + if($this->valid()){ + try{ + $timezone = $this->getF3()->get('getTimeZone')(); + $currentTime = new \DateTime('now', $timezone); + $updateTime = \DateTime::createFromFormat( + 'Y-m-d H:i:s', + $this->updated, + $timezone + ); + $interval = $updateTime->diff($currentTime); + if($interval->days < self::CACHE_MAX_DAYS){ + $outdated = false; + } + }catch(\Exception $e){ + self::getF3()->error($e->getCode(), $e->getMessage(), $e->getTrace()); + } + } + return $outdated; + } + + /** + * @return mixed + */ + public function save(){ + $return = false; + try{ + $return = parent::save(); + }catch(ValidationException $e){ + $this->setValidationError($e); + }catch(DatabaseException $e){ + self::getF3()->error($e->getResponseCode(), $e->getMessage(), $e->getTrace()); + } + + return $return; + } + + /** + * @return string + */ + public function __toString() : string { + return $this->getTable(); + } + + /** + * @param string $argument + * @return \ReflectionClass + * @throws \ReflectionException + */ + protected static function refClass($argument = self::class) : \ReflectionClass { + return new \ReflectionClass($argument); + } + + /** + * get the framework instance + * @return \Base + */ + public static function getF3() : \Base { + return \Base::instance(); + } + + /** + * get model data as array + * @param $data + * @return array + */ + public static function toArray($data) : array { + return json_decode(json_encode($data), true); + } + + /** + * get new filter array representation + * -> $suffix can be used fore unique placeholder, + * in case the same $key is used with different $values in the same query + * @param string $key + * @param mixed $value + * @param string $operator + * @param string $suffix + * @return array + */ + public static function getFilter(string $key, $value, string $operator = '=', string $suffix = '') : array { + $placeholder = ':' . implode('_', array_filter([$key, $suffix])); + return [$key . ' ' . $operator . ' ' . $placeholder, $placeholder => $value]; + } + + /** + * stores data direct into the Cache backend (e.g. Redis) + * $f3->set() used the same code. The difference is, that $f3->set() + * also loads data into the Hive. + * This can result in high RAM usage if a great number of key->values should be stored in Cache + * (like the search index for system data) + * @param string $key + * @param $data + * @param int $ttl + */ + public static function setCacheValue(string $key, $data, int $ttl = 0){ + $cache = \Cache::instance(); + $cache->set(self::getF3()->hash($key).'.var', $data, $ttl); + } + + /** + * check whether a cache $key exists + * -> §val (reference) get updated with the cache data + * -> equivalent to $f3->exists() + * @param string $key + * @param null $val + * @return bool + */ + public static function existsCacheValue(string $key, &$val = null){ + $cache = \Cache::instance(); + return $cache->exists(self::getF3()->hash($key).'.var',$val); + } + + /** + * debug log function + * @param string $text + * @param string $type + */ + public static function log($text, $type = 'DEBUG'){ + Controller\LogController::getLogger($type)->write($text); + } + + /** + * get tableModifier class for this table + * @return bool|Mysql\TableModifier + */ + public static function getTableModifier(){ + $df = parent::resolveConfiguration(); + $schema = new Schema($df['db']); + return $schema->alterTable($df['table']); + } + + /** + * Check whether a (multi)-column index exists or not on a table + * related to this model + * @param array $columns + * @return bool|array + */ + public static function indexExists(array $columns = []){ + $tableModifier = self::getTableModifier(); + $df = parent::resolveConfiguration(); + + $check = false; + $indexKey = $df['table'] . '___' . implode('__', $columns); + $indexList = $tableModifier->listIndex(); + if(array_key_exists( $indexKey, $indexList)){ + $check = $indexList[$indexKey]; + } + + return $check; + } + + /** + * set a multi-column index for this table + * @param array $columns Column(s) to be indexed + * @param bool $unique Unique index + * @param int $length index length for text fields in mysql + * @return bool + */ + public static function setMultiColumnIndex(array $columns = [], $unique = false, $length = 20) : bool { + $status = false; + $tableModifier = self::getTableModifier(); + + if( self::indexExists($columns) === false ){ + $tableModifier->addIndex($columns, $unique, $length); + $buildStatus = $tableModifier->build(); + if($buildStatus === 0){ + $status = true; + } + } + + return $status; + } + + /** + * factory for all Models + * @param string $className + * @param int $ttl + * @return AbstractModel|null + * @throws \Exception + */ + public static function getNew(string $className, int $ttl = self::DEFAULT_TTL) : ?self { + $model = null; + $className = self::refClass(static::class)->getNamespaceName() . '\\' . $className; + if(class_exists($className)){ + $model = new $className(null, null, null, $ttl); + }else{ + throw new \Exception(sprintf(self::ERROR_INVALID_MODEL_CLASS, $className)); + } + return $model; + } + + /** + * generate hashKey for a complete table + * -> should hold hashKeys for multiple rows + * @param string $table + * @param string $prefix + * @return string + */ + public static function generateHashKeyTable(string $table, string $prefix = self::CACHE_KEY_PREFIX ) : string { + return $prefix . '_' . strtolower($table); + } + + /** + * overwrites parent + * @param null $db + * @param null $table + * @param null $fields + * @return bool + * @throws \Exception + */ + public static function setup($db = null, $table = null, $fields = null){ + $status = parent::setup($db, $table, $fields); + + // set static default data + if($status === true && property_exists(static::class, 'tableData')){ + $model = self::getNew(self::refClass(static::class)->getShortName(), 0); + $model->importStaticData(static::$tableData); + } + + return $status; + } + +} \ No newline at end of file diff --git a/app/main/model/pathfinder/abstractmaptrackingmodel.php b/app/Model/Pathfinder/AbstractMapTrackingModel.php similarity index 90% rename from app/main/model/pathfinder/abstractmaptrackingmodel.php rename to app/Model/Pathfinder/AbstractMapTrackingModel.php index 8f4b65cf..510a86a8 100644 --- a/app/main/model/pathfinder/abstractmaptrackingmodel.php +++ b/app/Model/Pathfinder/AbstractMapTrackingModel.php @@ -6,9 +6,10 @@ * Time: 18:45 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; +use Exodus4D\Pathfinder\Exception; abstract class AbstractMapTrackingModel extends AbstractPathfinderModel implements LogModelInterface { @@ -19,7 +20,7 @@ abstract class AbstractMapTrackingModel extends AbstractPathfinderModel implemen 'createdCharacterId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', @@ -31,7 +32,7 @@ abstract class AbstractMapTrackingModel extends AbstractPathfinderModel implemen 'updatedCharacterId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', @@ -70,7 +71,7 @@ abstract class AbstractMapTrackingModel extends AbstractPathfinderModel implemen /** * validates all required columns of this class * @return bool - * @throws \Exception\DatabaseException + * @throws Exception\DatabaseException */ public function isValid(): bool { if($valid = parent::isValid()){ diff --git a/app/Model/Pathfinder/AbstractPathfinderModel.php b/app/Model/Pathfinder/AbstractPathfinderModel.php new file mode 100644 index 00000000..d31ebb09 --- /dev/null +++ b/app/Model/Pathfinder/AbstractPathfinderModel.php @@ -0,0 +1,112 @@ + fields that should be checked need an "activity-log" flag + * in $fieldConf config + * @var bool + */ + protected $enableActivityLogging = true; + + /** + * changed fields (columns) on update/insert + * -> e.g. for character "activity logging" + * @var array + */ + protected $fieldChanges = []; + + /** + * change default "activity logging" status + * -> enable/disable + * @param $status + */ + public function setActivityLogging(bool $status){ + $this->enableActivityLogging = $status; + } + + /** + * @param bool $mapper + * @return NULL|void + */ + public function reset($mapper = true){ + $this->fieldChanges = []; + parent::reset($mapper); + } + + /** + * function should be overwritten in child classes with access restriction + * @param CharacterModel $characterModel + * @return bool + */ + public function hasAccess(CharacterModel $characterModel) : bool { + return true; + } + + /** + * set "updated" field to current timestamp + * this is useful to mark a row as "changed" + */ + protected function setUpdated(){ + if($this->_id > 0){ + $this->db->exec( + ["UPDATE " . $this->table . " SET updated=NOW() WHERE id=:id"], + [ + [':id' => $this->_id] + ] + ); + } + } + + /** + * get old and new value from field, in case field is configured with 'activity-log' + * @return array + */ + protected function getFieldChanges() : array { + $changes = []; + + if($this->enableActivityLogging){ + // filter fields, where "activity" (changes) should be logged + $fieldConf = array_filter($this->fieldConf, function($fieldConf, $key){ + return isset($fieldConf['activity-log']) ? (bool)$fieldConf['activity-log'] : false; + }, ARRAY_FILTER_USE_BOTH); + + if($fieldKeys = array_keys($fieldConf)){ + // model has fields where changes should be logged + $schema = $this->getMapper()->schema(); + foreach($fieldKeys as $key){ + if($this->changed($key)){ + $changes[$key] = [ + 'old' => $schema[$key]['initial'], + 'new' => $schema[$key]['value'] + ]; + } + } + } + } + + return $changes; + } + + /** + * @return mixed|void + */ + public function save(){ + // save changed field value BEFORE ->save() it called! + // parent::save() resets the schema and old values get replaced with new values + $this->fieldChanges = $this->getFieldChanges(); + + return parent::save(); + } +} \ No newline at end of file diff --git a/app/main/model/pathfinder/abstractsystemapibasicmodel.php b/app/Model/Pathfinder/AbstractSystemApiBasicModel.php similarity index 98% rename from app/main/model/pathfinder/abstractsystemapibasicmodel.php rename to app/Model/Pathfinder/AbstractSystemApiBasicModel.php index b603dd13..89728c64 100644 --- a/app/main/model/pathfinder/abstractsystemapibasicmodel.php +++ b/app/Model/Pathfinder/AbstractSystemApiBasicModel.php @@ -6,7 +6,7 @@ * Time: 22:11 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/activitylogmodel.php b/app/Model/Pathfinder/ActivityLogModel.php similarity index 92% rename from app/main/model/pathfinder/activitylogmodel.php rename to app/Model/Pathfinder/ActivityLogModel.php index efb8631b..bfe47e39 100644 --- a/app/main/model/pathfinder/activitylogmodel.php +++ b/app/Model/Pathfinder/ActivityLogModel.php @@ -6,14 +6,20 @@ * Time: 15:11 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class ActivityLogModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'activity_log'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -24,7 +30,7 @@ class ActivityLogModel extends AbstractPathfinderModel { 'characterId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', @@ -35,7 +41,7 @@ class ActivityLogModel extends AbstractPathfinderModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', @@ -129,6 +135,13 @@ class ActivityLogModel extends AbstractPathfinderModel { ], ]; + /** + * ActivityLogModel constructor. + * @param null $db + * @param null $table + * @param null $fluid + * @param int $ttl + */ public function __construct($db = NULL, $table = NULL, $fluid = NULL, $ttl = 0){ $this->addStaticDateFieldConfig(); diff --git a/app/main/model/pathfinder/alliancemapmodel.php b/app/Model/Pathfinder/AllianceMapModel.php similarity index 88% rename from app/main/model/pathfinder/alliancemapmodel.php rename to app/Model/Pathfinder/AllianceMapModel.php index 0152b5ff..e13a39de 100644 --- a/app/main/model/pathfinder/alliancemapmodel.php +++ b/app/Model/Pathfinder/AllianceMapModel.php @@ -6,7 +6,7 @@ * Time: 20:14 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -30,7 +30,7 @@ class AllianceMapModel extends AbstractPathfinderModel { 'allianceId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\AllianceModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\AllianceModel', 'constraint' => [ [ 'table' => 'alliance', @@ -41,7 +41,7 @@ class AllianceMapModel extends AbstractPathfinderModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', diff --git a/app/main/model/pathfinder/alliancemodel.php b/app/Model/Pathfinder/AllianceModel.php similarity index 93% rename from app/main/model/pathfinder/alliancemodel.php rename to app/Model/Pathfinder/AllianceModel.php index 10ad8d06..66f7736a 100644 --- a/app/main/model/pathfinder/alliancemodel.php +++ b/app/Model/Pathfinder/AllianceModel.php @@ -6,10 +6,10 @@ * Time: 20:43 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use lib\Config; +use Exodus4D\Pathfinder\Lib\Config; class AllianceModel extends AbstractPathfinderModel { @@ -44,10 +44,10 @@ class AllianceModel extends AbstractPathfinderModel { 'default' => 0 ], 'allianceCharacters' => [ - 'has-many' => ['Model\Pathfinder\CharacterModel', 'allianceId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'allianceId'] ], 'mapAlliances' => [ - 'has-many' => ['Model\Pathfinder\AllianceMapModel', 'allianceId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\AllianceMapModel', 'allianceId'] ] ]; diff --git a/app/main/model/pathfinder/characterauthenticationmodel.php b/app/Model/Pathfinder/CharacterAuthenticationModel.php similarity index 87% rename from app/main/model/pathfinder/characterauthenticationmodel.php rename to app/Model/Pathfinder/CharacterAuthenticationModel.php index b80e773b..f73101c5 100644 --- a/app/main/model/pathfinder/characterauthenticationmodel.php +++ b/app/Model/Pathfinder/CharacterAuthenticationModel.php @@ -6,15 +6,21 @@ * Time: 19:33 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use Controller; +use Exodus4D\Pathfinder\Controller; class CharacterAuthenticationModel extends AbstractPathfinderModel{ + /** + * @var string + */ protected $table = 'character_authentication'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -25,7 +31,7 @@ class CharacterAuthenticationModel extends AbstractPathfinderModel{ 'characterId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', diff --git a/app/main/model/pathfinder/characterlogmodel.php b/app/Model/Pathfinder/CharacterLogModel.php similarity index 98% rename from app/main/model/pathfinder/characterlogmodel.php rename to app/Model/Pathfinder/CharacterLogModel.php index 1e4a6b10..82afa5d0 100644 --- a/app/main/model/pathfinder/characterlogmodel.php +++ b/app/Model/Pathfinder/CharacterLogModel.php @@ -6,7 +6,7 @@ * Time: 00:04 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -37,7 +37,7 @@ class CharacterLogModel extends AbstractPathfinderModel { 'type' => Schema::DT_INT, 'index' => true, 'unique' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', diff --git a/app/main/model/pathfinder/charactermapmodel.php b/app/Model/Pathfinder/CharacterMapModel.php similarity index 84% rename from app/main/model/pathfinder/charactermapmodel.php rename to app/Model/Pathfinder/CharacterMapModel.php index 688ce91e..83428264 100644 --- a/app/main/model/pathfinder/charactermapmodel.php +++ b/app/Model/Pathfinder/CharacterMapModel.php @@ -6,14 +6,20 @@ * Time: 12:31 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class CharacterMapModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'character_map'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -24,7 +30,7 @@ class CharacterMapModel extends AbstractPathfinderModel { 'characterId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', @@ -35,7 +41,7 @@ class CharacterMapModel extends AbstractPathfinderModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', diff --git a/app/main/model/pathfinder/charactermodel.php b/app/Model/Pathfinder/CharacterModel.php similarity index 98% rename from app/main/model/pathfinder/charactermodel.php rename to app/Model/Pathfinder/CharacterModel.php index 49082bf6..3a13fa0e 100644 --- a/app/main/model/pathfinder/charactermodel.php +++ b/app/Model/Pathfinder/CharacterModel.php @@ -6,13 +6,13 @@ * Time: 15:20 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; -use Controller\Ccp\Sso as Sso; -use Controller\Api\User as User; +use Exodus4D\Pathfinder\Controller\Ccp\Sso as Sso; +use Exodus4D\Pathfinder\Controller\Api\User as User; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; -use lib\Config; -use Model\Universe; class CharacterModel extends AbstractPathfinderModel { @@ -116,7 +116,7 @@ class CharacterModel extends AbstractPathfinderModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -127,7 +127,7 @@ class CharacterModel extends AbstractPathfinderModel { 'allianceId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\AllianceModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\AllianceModel', 'constraint' => [ [ 'table' => 'alliance', @@ -140,7 +140,7 @@ class CharacterModel extends AbstractPathfinderModel { 'nullable' => false, 'default' => 1, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\RoleModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\RoleModel', 'constraint' => [ [ 'table' => 'role', @@ -187,16 +187,16 @@ class CharacterModel extends AbstractPathfinderModel { 'default' => 0 ], 'userCharacter' => [ - 'has-one' => ['Model\Pathfinder\UserCharacterModel', 'characterId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Pathfinder\UserCharacterModel', 'characterId'] ], 'characterLog' => [ - 'has-one' => ['Model\Pathfinder\CharacterLogModel', 'characterId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterLogModel', 'characterId'] ], 'characterMaps' => [ - 'has-many' => ['Model\Pathfinder\CharacterMapModel', 'characterId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterMapModel', 'characterId'] ], 'characterAuthentications' => [ - 'has-many' => ['Model\Pathfinder\CharacterAuthenticationModel', 'characterId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterAuthenticationModel', 'characterId'] ] ]; diff --git a/app/main/model/pathfinder/characterstatusmodel.php b/app/Model/Pathfinder/CharacterStatusModel.php similarity index 87% rename from app/main/model/pathfinder/characterstatusmodel.php rename to app/Model/Pathfinder/CharacterStatusModel.php index 1d5eab8f..ba98c2e3 100644 --- a/app/main/model/pathfinder/characterstatusmodel.php +++ b/app/Model/Pathfinder/CharacterStatusModel.php @@ -6,14 +6,20 @@ * Time: 21:12 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class CharacterStatusModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'character_status'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -33,6 +39,9 @@ class CharacterStatusModel extends AbstractPathfinderModel { ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, diff --git a/app/main/model/pathfinder/connectionlogmodel.php b/app/Model/Pathfinder/ConnectionLogModel.php similarity index 94% rename from app/main/model/pathfinder/connectionlogmodel.php rename to app/Model/Pathfinder/ConnectionLogModel.php index 8f3aab9c..96ffa6cf 100644 --- a/app/main/model/pathfinder/connectionlogmodel.php +++ b/app/Model/Pathfinder/ConnectionLogModel.php @@ -6,14 +6,20 @@ * Time: 17:51 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class ConnectionLogModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'connection_log'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -24,7 +30,7 @@ class ConnectionLogModel extends AbstractPathfinderModel { 'connectionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\ConnectionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\ConnectionModel', 'constraint' => [ [ 'table' => 'connection', diff --git a/app/main/model/pathfinder/connectionmodel.php b/app/Model/Pathfinder/ConnectionModel.php similarity index 93% rename from app/main/model/pathfinder/connectionmodel.php rename to app/Model/Pathfinder/ConnectionModel.php index 4b2e5ab2..33eff594 100644 --- a/app/main/model/pathfinder/connectionmodel.php +++ b/app/Model/Pathfinder/ConnectionModel.php @@ -6,11 +6,12 @@ * Time: 21:12 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use Controller\Api\Route; -use lib\logging; +use Exodus4D\Pathfinder\Controller\Api\Route; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Exception; class ConnectionModel extends AbstractMapTrackingModel { @@ -32,7 +33,7 @@ class ConnectionModel extends AbstractMapTrackingModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', @@ -43,7 +44,7 @@ class ConnectionModel extends AbstractMapTrackingModel { 'source' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -55,7 +56,7 @@ class ConnectionModel extends AbstractMapTrackingModel { 'target' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -87,10 +88,10 @@ class ConnectionModel extends AbstractMapTrackingModel { 'default' => null ], 'signatures' => [ - 'has-many' => ['Model\Pathfinder\SystemSignatureModel', 'connectionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\SystemSignatureModel', 'connectionId'] ], 'connectionLog' => [ - 'has-many' => ['Model\Pathfinder\ConnectionLogModel', 'connectionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\ConnectionLogModel', 'connectionId'] ] ]; @@ -258,7 +259,7 @@ class ConnectionModel extends AbstractMapTrackingModel { /** * check whether this model is valid or not * @return bool - * @throws \Exception\DatabaseException + * @throws Exception\DatabaseException */ public function isValid() : bool { if($valid = parent::isValid()){ @@ -278,13 +279,14 @@ class ConnectionModel extends AbstractMapTrackingModel { } /** - * Event "Hook" function + * Event "Hook" function * can be overwritten * return false will stop any further action - * @param self $self + * @param \Exodus4D\Pathfinder\Model\AbstractModel $self * @param $pkeys * @return bool - * @throws \Exception\DatabaseException + * @throws Exception\DatabaseException + * @throws \Exception */ public function beforeInsertEvent($self, $pkeys) : bool { // check for "default" connection type and add them if missing @@ -335,8 +337,8 @@ class ConnectionModel extends AbstractMapTrackingModel { /** * @param string $action - * @return logging\LogInterface - * @throws \Exception\ConfigException + * @return Logging\LogInterface + * @throws Exception\ConfigException */ public function newLog(string $action = '') : Logging\LogInterface { return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData()); diff --git a/app/main/model/pathfinder/connectionscopemodel.php b/app/Model/Pathfinder/ConnectionScopeModel.php similarity index 91% rename from app/main/model/pathfinder/connectionscopemodel.php rename to app/Model/Pathfinder/ConnectionScopeModel.php index fd9c3021..5d07fea9 100644 --- a/app/main/model/pathfinder/connectionscopemodel.php +++ b/app/Model/Pathfinder/ConnectionScopeModel.php @@ -6,14 +6,20 @@ * Time: 20:01 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class ConnectionScopeModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'connection_scope'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -38,6 +44,9 @@ class ConnectionScopeModel extends AbstractPathfinderModel { ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, @@ -63,7 +72,6 @@ class ConnectionScopeModel extends AbstractPathfinderModel { 'label' => 'abyssal', 'connectorDefinition' => '[ "Straight", { "stub": [5, 5], "gap": 0 } ]' ] - ]; } \ No newline at end of file diff --git a/app/main/model/pathfinder/corporationmapmodel.php b/app/Model/Pathfinder/CorporationMapModel.php similarity index 87% rename from app/main/model/pathfinder/corporationmapmodel.php rename to app/Model/Pathfinder/CorporationMapModel.php index 8fe73e1c..24ada8c9 100644 --- a/app/main/model/pathfinder/corporationmapmodel.php +++ b/app/Model/Pathfinder/CorporationMapModel.php @@ -6,7 +6,7 @@ * Time: 20:01 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -30,7 +30,7 @@ class CorporationMapModel extends AbstractPathfinderModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -41,7 +41,7 @@ class CorporationMapModel extends AbstractPathfinderModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', diff --git a/app/main/model/pathfinder/corporationmodel.php b/app/Model/Pathfinder/CorporationModel.php similarity index 94% rename from app/main/model/pathfinder/corporationmodel.php rename to app/Model/Pathfinder/CorporationModel.php index b2a5cb71..12482080 100644 --- a/app/main/model/pathfinder/corporationmodel.php +++ b/app/Model/Pathfinder/CorporationModel.php @@ -6,10 +6,10 @@ * Time: 20:43 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use lib\Config; +use Exodus4D\Pathfinder\Lib\Config; class CorporationModel extends AbstractPathfinderModel { @@ -130,19 +130,19 @@ class CorporationModel extends AbstractPathfinderModel { 'default' => 0 ], 'corporationCharacters' => [ - 'has-many' => ['Model\Pathfinder\CharacterModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'corporationId'] ], 'mapCorporations' => [ - 'has-many' => ['Model\Pathfinder\CorporationMapModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationMapModel', 'corporationId'] ], 'corporationRights' => [ - 'has-many' => ['Model\Pathfinder\CorporationRightModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationRightModel', 'corporationId'] ], 'corporationStructures' => [ - 'has-many' => ['Model\Pathfinder\CorporationStructureModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationStructureModel', 'corporationId'] ], 'structures' => [ - 'has-many' => ['Model\Pathfinder\StructureModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\StructureModel', 'corporationId'] ] ]; diff --git a/app/main/model/pathfinder/corporationrightmodel.php b/app/Model/Pathfinder/CorporationRightModel.php similarity index 89% rename from app/main/model/pathfinder/corporationrightmodel.php rename to app/Model/Pathfinder/CorporationRightModel.php index 1587968c..b42b8c45 100644 --- a/app/main/model/pathfinder/corporationrightmodel.php +++ b/app/Model/Pathfinder/CorporationRightModel.php @@ -6,7 +6,7 @@ * Time: 15:37 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -30,7 +30,7 @@ class CorporationRightModel extends AbstractPathfinderModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -41,7 +41,7 @@ class CorporationRightModel extends AbstractPathfinderModel { 'rightId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\RightModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\RightModel', 'constraint' => [ [ 'table' => 'right', @@ -52,7 +52,7 @@ class CorporationRightModel extends AbstractPathfinderModel { 'roleId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\RoleModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\RoleModel', 'constraint' => [ [ 'table' => 'role', diff --git a/app/main/model/pathfinder/corporationstructuremodel.php b/app/Model/Pathfinder/CorporationStructureModel.php similarity index 86% rename from app/main/model/pathfinder/corporationstructuremodel.php rename to app/Model/Pathfinder/CorporationStructureModel.php index a9aab364..5ee8f4a7 100644 --- a/app/main/model/pathfinder/corporationstructuremodel.php +++ b/app/Model/Pathfinder/CorporationStructureModel.php @@ -6,7 +6,7 @@ * Time: 19:23 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -30,7 +30,7 @@ class CorporationStructureModel extends AbstractPathfinderModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -41,7 +41,7 @@ class CorporationStructureModel extends AbstractPathfinderModel { 'structureId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\StructureModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\StructureModel', 'constraint' => [ [ 'table' => 'structure', diff --git a/app/main/model/pathfinder/cronmodel.php b/app/Model/Pathfinder/CronModel.php similarity index 98% rename from app/main/model/pathfinder/cronmodel.php rename to app/Model/Pathfinder/CronModel.php index 3708f6ca..973f9c11 100644 --- a/app/main/model/pathfinder/cronmodel.php +++ b/app/Model/Pathfinder/CronModel.php @@ -1,7 +1,7 @@ [ 'type' => 'warning', @@ -160,6 +163,7 @@ class CronModel extends AbstractPathfinderModel { /** * @param bool $addLastIfFinished * @return array + * @throws \Exception */ protected function getHistory(bool $addLastIfFinished = false) : array { $history = $this->history ? : []; @@ -183,6 +187,7 @@ class CronModel extends AbstractPathfinderModel { /** * get current job status based on its current data * @return array + * @throws \Exception */ protected function getStatus() : array { $status = []; diff --git a/app/main/model/pathfinder/logmodelinterface.php b/app/Model/Pathfinder/LogModelInterface.php similarity index 84% rename from app/main/model/pathfinder/logmodelinterface.php rename to app/Model/Pathfinder/LogModelInterface.php index aa145a57..b2e7245e 100644 --- a/app/main/model/pathfinder/logmodelinterface.php +++ b/app/Model/Pathfinder/LogModelInterface.php @@ -6,7 +6,7 @@ * Time: 04:10 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; interface LogModelInterface { diff --git a/app/main/model/pathfinder/mapmodel.php b/app/Model/Pathfinder/MapModel.php similarity index 96% rename from app/main/model/pathfinder/mapmodel.php rename to app/Model/Pathfinder/MapModel.php index 2be5ad10..28d097aa 100644 --- a/app/main/model/pathfinder/mapmodel.php +++ b/app/Model/Pathfinder/MapModel.php @@ -6,14 +6,14 @@ * Time: 22:10 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\CortexCollection; use DB\SQL\Schema; -use data\file\FileHandler; -use Exception\ConfigException; -use lib\Config; -use lib\logging; +use Exodus4D\Pathfinder\Data\File\FileHandler; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Exception; class MapModel extends AbstractMapTrackingModel { @@ -44,7 +44,7 @@ class MapModel extends AbstractMapTrackingModel { 'scopeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapScopeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapScopeModel', 'constraint' => [ [ 'table' => 'map_scope', @@ -57,7 +57,7 @@ class MapModel extends AbstractMapTrackingModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapTypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapTypeModel', 'constraint' => [ [ 'table' => 'map_type', @@ -171,19 +171,19 @@ class MapModel extends AbstractMapTrackingModel { 'validate' => true ], 'systems' => [ - 'has-many' => ['Model\Pathfinder\SystemModel', 'mapId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\SystemModel', 'mapId'] ], 'connections' => [ - 'has-many' => ['Model\Pathfinder\ConnectionModel', 'mapId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\ConnectionModel', 'mapId'] ], 'mapCharacters' => [ - 'has-many' => ['Model\Pathfinder\CharacterMapModel', 'mapId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CharacterMapModel', 'mapId'] ], 'mapCorporations' => [ - 'has-many' => ['Model\Pathfinder\CorporationMapModel', 'mapId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationMapModel', 'mapId'] ], 'mapAlliances' => [ - 'has-many' => ['Model\Pathfinder\AllianceMapModel', 'mapId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\AllianceMapModel', 'mapId'] ] ]; @@ -340,7 +340,7 @@ class MapModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_name(string $key, string $val) : bool { $valid = true; @@ -356,7 +356,7 @@ class MapModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_slackWebHookURL(string $key, string $val) : bool { return $this->validate_WebHookURL($key, $val, 'slack'); @@ -367,7 +367,7 @@ class MapModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_discordWebHookURLHistory(string $key, string $val) : bool { return $this->validate_WebHookURL($key, $val, 'discord'); @@ -378,7 +378,7 @@ class MapModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_discordWebHookURLRally(string $key, string $val) : bool { return $this->validate_WebHookURL($key, $val, 'discord'); @@ -390,7 +390,7 @@ class MapModel extends AbstractMapTrackingModel { * @param string $val * @param string $type * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_WebHookURL(string $key, string $val, string $type) : bool { $valid = true; @@ -775,7 +775,7 @@ class MapModel extends AbstractMapTrackingModel { * @var CharacterMapModel $characterMapModel */ $characterMapModel->erase(); - }; + } break; case 'corporation': foreach((array)$this->mapCorporations as $corporationMapModel){ @@ -783,7 +783,7 @@ class MapModel extends AbstractMapTrackingModel { * @var CorporationMapModel $corporationMapModel */ $corporationMapModel->erase(); - }; + } break; case 'alliance': foreach((array)$this->mapAlliances as $allianceMapModel){ @@ -791,7 +791,7 @@ class MapModel extends AbstractMapTrackingModel { * @var AllianceMapModel $allianceMapModel */ $allianceMapModel->erase(); - }; + } break; } } @@ -975,13 +975,14 @@ class MapModel extends AbstractMapTrackingModel { /** * @param string $action - * @return logging\LogInterface - * @throws ConfigException + * @return Logging\LogInterface + * @throws Exception\ConfigException + * @throws \Exception */ public function newLog(string $action = '') : Logging\LogInterface{ $logChannelData = $this->getLogChannelData(); $logObjectData = $this->getLogObjectData(); - $log = (new logging\MapLog($action, $logChannelData))->setTempData($logObjectData); + $log = (new Logging\MapLog($action, $logChannelData))->setTempData($logObjectData); // update map history *.log files ----------------------------------------------------------------------------- if($this->isHistoryLogEnabled()){ @@ -1072,7 +1073,7 @@ class MapModel extends AbstractMapTrackingModel { * check if "Slack WebHook" is enabled for this map type * @param string $channel * @return bool - * @throws ConfigException + * @throws Exception\ConfigException */ public function isSlackChannelEnabled(string $channel) : bool { $enabled = false; @@ -1082,7 +1083,7 @@ class MapModel extends AbstractMapTrackingModel { switch($channel){ case 'slackChannelHistory': $defaultMapConfigKey = 'send_history_slack_enabled'; break; case 'slackChannelRally': $defaultMapConfigKey = 'send_rally_slack_enabled'; break; - default: throw new ConfigException(sprintf(self::ERROR_SLACK_CHANNEL, $channel)); + default: throw new Exception\ConfigException(sprintf(self::ERROR_SLACK_CHANNEL, $channel)); } if((bool) Config::getMapsDefaultConfig($this->typeId->name)[$defaultMapConfigKey]){ @@ -1100,7 +1101,7 @@ class MapModel extends AbstractMapTrackingModel { * check if "Discord WebHook" is enabled for this map type * @param string $channel * @return bool - * @throws ConfigException + * @throws Exception\ConfigException */ public function isDiscordChannelEnabled(string $channel) : bool { $enabled = false; @@ -1110,7 +1111,7 @@ class MapModel extends AbstractMapTrackingModel { switch($channel){ case 'discordWebHookURLHistory': $defaultMapConfigKey = 'send_history_discord_enabled'; break; case 'discordWebHookURLRally': $defaultMapConfigKey = 'send_rally_discord_enabled'; break; - default: throw new ConfigException(sprintf(self::ERROR_DISCORD_CHANNEL, $channel)); + default: throw new Exception\ConfigException(sprintf(self::ERROR_DISCORD_CHANNEL, $channel)); } if((bool) Config::getMapsDefaultConfig($this->typeId->name)[$defaultMapConfigKey]){ diff --git a/app/main/model/pathfinder/mapscopemodel.php b/app/Model/Pathfinder/MapScopeModel.php similarity index 88% rename from app/main/model/pathfinder/mapscopemodel.php rename to app/Model/Pathfinder/MapScopeModel.php index 9ae22291..e3d3d9c3 100644 --- a/app/main/model/pathfinder/mapscopemodel.php +++ b/app/Model/Pathfinder/MapScopeModel.php @@ -6,14 +6,20 @@ * Time: 20:01 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class MapScopeModel extends AbstractPathfinderModel{ + /** + * @var string + */ protected $table = 'map_scope'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -33,6 +39,9 @@ class MapScopeModel extends AbstractPathfinderModel{ ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, diff --git a/app/main/model/pathfinder/maptypemodel.php b/app/Model/Pathfinder/MapTypeModel.php similarity index 93% rename from app/main/model/pathfinder/maptypemodel.php rename to app/Model/Pathfinder/MapTypeModel.php index c25f2d6a..35fee514 100644 --- a/app/main/model/pathfinder/maptypemodel.php +++ b/app/Model/Pathfinder/MapTypeModel.php @@ -6,14 +6,20 @@ * Time: 20:01 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class MapTypeModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'map_type'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -43,6 +49,9 @@ class MapTypeModel extends AbstractPathfinderModel { ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, diff --git a/app/main/model/pathfinder/rightmodel.php b/app/Model/Pathfinder/RightModel.php similarity index 92% rename from app/main/model/pathfinder/rightmodel.php rename to app/Model/Pathfinder/RightModel.php index 2c13b877..9a3e022d 100644 --- a/app/main/model/pathfinder/rightmodel.php +++ b/app/Model/Pathfinder/RightModel.php @@ -6,7 +6,7 @@ * Time: 14:38 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -45,7 +45,7 @@ class RightModel extends AbstractPathfinderModel { 'default' => '' ], 'corporationRights' => [ - 'has-many' => ['Model\Pathfinder\CorporationRightModel', 'rightId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationRightModel', 'rightId'] ] ]; diff --git a/app/main/model/pathfinder/rolemodel.php b/app/Model/Pathfinder/RoleModel.php similarity index 91% rename from app/main/model/pathfinder/rolemodel.php rename to app/Model/Pathfinder/RoleModel.php index 75763924..e0d1463c 100644 --- a/app/main/model/pathfinder/rolemodel.php +++ b/app/Model/Pathfinder/RoleModel.php @@ -6,14 +6,20 @@ * Time: 12:42 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class RoleModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'role'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -41,10 +47,13 @@ class RoleModel extends AbstractPathfinderModel { 'default' => '' ], 'corporationRights' => [ - 'has-many' => ['Model\Pathfinder\CorporationRightModel', 'roleId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationRightModel', 'roleId'] ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, diff --git a/app/main/model/pathfinder/structuremodel.php b/app/Model/Pathfinder/StructureModel.php similarity index 95% rename from app/main/model/pathfinder/structuremodel.php rename to app/Model/Pathfinder/StructureModel.php index ef0fcd89..25533f68 100644 --- a/app/main/model/pathfinder/structuremodel.php +++ b/app/Model/Pathfinder/StructureModel.php @@ -6,10 +6,10 @@ * Time: 19:41 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use Model\Universe; +use Exodus4D\Pathfinder\Model\Universe; class StructureModel extends AbstractPathfinderModel { @@ -36,7 +36,7 @@ class StructureModel extends AbstractPathfinderModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -53,7 +53,7 @@ class StructureModel extends AbstractPathfinderModel { 'type' => Schema::DT_INT, 'default' => 1, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\StructureStatusModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\StructureStatusModel', 'constraint' => [ [ 'table' => 'structure_status', @@ -72,7 +72,7 @@ class StructureModel extends AbstractPathfinderModel { 'default' => '' ], 'structureCorporations' => [ - 'has-many' => ['Model\Pathfinder\CorporationStructureModel', 'structureId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\CorporationStructureModel', 'structureId'] ] ]; diff --git a/app/main/model/pathfinder/structurestatusmodel.php b/app/Model/Pathfinder/StructureStatusModel.php similarity index 93% rename from app/main/model/pathfinder/structurestatusmodel.php rename to app/Model/Pathfinder/StructureStatusModel.php index 5d7aca0c..cb814b68 100644 --- a/app/main/model/pathfinder/structurestatusmodel.php +++ b/app/Model/Pathfinder/StructureStatusModel.php @@ -6,7 +6,7 @@ * Time: 20:13 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; @@ -44,7 +44,7 @@ class StructureStatusModel extends AbstractPathfinderModel { 'default' => '' ], 'structures' => [ - 'has-many' => ['Model\Pathfinder\StructureModel', 'statusId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\StructureModel', 'statusId'] ] ]; diff --git a/app/main/model/pathfinder/systemfactionkillmodel.php b/app/Model/Pathfinder/SystemFactionKillModel.php similarity index 92% rename from app/main/model/pathfinder/systemfactionkillmodel.php rename to app/Model/Pathfinder/SystemFactionKillModel.php index 90c654b0..8bd773fb 100644 --- a/app/main/model/pathfinder/systemfactionkillmodel.php +++ b/app/Model/Pathfinder/SystemFactionKillModel.php @@ -6,7 +6,7 @@ * Time: 21:04 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/systemjumpmodel.php b/app/Model/Pathfinder/SystemJumpModel.php similarity index 92% rename from app/main/model/pathfinder/systemjumpmodel.php rename to app/Model/Pathfinder/SystemJumpModel.php index 03d62b8c..9fd6e2e5 100644 --- a/app/main/model/pathfinder/systemjumpmodel.php +++ b/app/Model/Pathfinder/SystemJumpModel.php @@ -6,7 +6,7 @@ * Time: 21:04 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/systemmodel.php b/app/Model/Pathfinder/SystemModel.php similarity index 96% rename from app/main/model/pathfinder/systemmodel.php rename to app/Model/Pathfinder/SystemModel.php index 29ec2de9..a038b2b8 100644 --- a/app/main/model/pathfinder/systemmodel.php +++ b/app/Model/Pathfinder/SystemModel.php @@ -6,12 +6,13 @@ * Time: 23:56 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use lib\logging; -use lib\PriorityCacheStore; -use Controller\Ccp\Universe; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Lib\PriorityCacheStore; +use Exodus4D\Pathfinder\Controller\Ccp\Universe; +use Exodus4D\Pathfinder\Exception; class SystemModel extends AbstractMapTrackingModel { @@ -64,7 +65,7 @@ class SystemModel extends AbstractMapTrackingModel { 'mapId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\MapModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\MapModel', 'constraint' => [ [ 'table' => 'map', @@ -86,7 +87,7 @@ class SystemModel extends AbstractMapTrackingModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\SystemTypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\SystemTypeModel', 'constraint' => [ [ 'table' => 'system_type', @@ -99,7 +100,7 @@ class SystemModel extends AbstractMapTrackingModel { 'nullable' => false, 'default' => 1, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\SystemStatusModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\SystemStatusModel', 'constraint' => [ [ 'table' => 'system_status', @@ -141,13 +142,13 @@ class SystemModel extends AbstractMapTrackingModel { 'default' => 0 ], 'signatures' => [ - 'has-many' => ['Model\Pathfinder\SystemSignatureModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\SystemSignatureModel', 'systemId'] ], 'connectionsSource' => [ - 'has-many' => ['Model\Pathfinder\ConnectionModel', 'source'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\ConnectionModel', 'source'] ], 'connectionsTarget' => [ - 'has-many' => ['Model\Pathfinder\ConnectionModel', 'target'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\ConnectionModel', 'target'] ] ]; @@ -297,7 +298,7 @@ class SystemModel extends AbstractMapTrackingModel { * @param string $key * @param int $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_statusId(string $key, int $val) : bool { $valid = true; @@ -313,7 +314,7 @@ class SystemModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_description(string $key, string $val) : bool { $valid = true; @@ -554,8 +555,8 @@ class SystemModel extends AbstractMapTrackingModel { /** * @param string $action - * @return logging\LogInterface - * @throws \Exception\ConfigException + * @return Logging\LogInterface + * @throws Exception\ConfigException */ public function newLog(string $action = '') : Logging\LogInterface{ return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData()); @@ -715,12 +716,13 @@ class SystemModel extends AbstractMapTrackingModel { * -> send to an Email * @param array $rallyData * @param CharacterModel $characterModel - * @throws \Exception\ConfigException + * @throws Exception\ConfigException + * @throws \Exception */ public function sendRallyPoke(array $rallyData, CharacterModel $characterModel){ // rally log needs at least one handler to be valid $isValidLog = false; - $log = new logging\RallyLog('rallySet', $this->getMap()->getLogChannelData()); + $log = new Logging\RallyLog('rallySet', $this->getMap()->getLogChannelData()); // Slack poke ----------------------------------------------------------------------------- $slackChannelKey = 'slackChannelRally'; diff --git a/app/main/model/pathfinder/systempodkillmodel.php b/app/Model/Pathfinder/SystemPodKillModel.php similarity index 92% rename from app/main/model/pathfinder/systempodkillmodel.php rename to app/Model/Pathfinder/SystemPodKillModel.php index 7eb847f7..99b5d51d 100644 --- a/app/main/model/pathfinder/systempodkillmodel.php +++ b/app/Model/Pathfinder/SystemPodKillModel.php @@ -6,7 +6,7 @@ * Time: 21:04 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/systemshipkillmodel.php b/app/Model/Pathfinder/SystemShipKillModel.php similarity index 92% rename from app/main/model/pathfinder/systemshipkillmodel.php rename to app/Model/Pathfinder/SystemShipKillModel.php index 15af811a..9c859d0b 100644 --- a/app/main/model/pathfinder/systemshipkillmodel.php +++ b/app/Model/Pathfinder/SystemShipKillModel.php @@ -6,7 +6,7 @@ * Time: 21:04 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/systemsignaturemodel.php b/app/Model/Pathfinder/SystemSignatureModel.php similarity index 95% rename from app/main/model/pathfinder/systemsignaturemodel.php rename to app/Model/Pathfinder/SystemSignatureModel.php index 06be9f3a..8a95f78a 100644 --- a/app/main/model/pathfinder/systemsignaturemodel.php +++ b/app/Model/Pathfinder/SystemSignatureModel.php @@ -6,10 +6,11 @@ * Time: 14:34 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use lib\logging; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Exception; class SystemSignatureModel extends AbstractMapTrackingModel { @@ -31,7 +32,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -56,7 +57,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel { 'connectionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\ConnectionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\ConnectionModel', 'constraint' => [ [ 'table' => 'connection', @@ -163,7 +164,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel { * @param string $key * @param string $val * @return bool - * @throws \Exception\ValidationException + * @throws Exception\ValidationException */ protected function validate_name(string $key, string $val): bool { $valid = true; @@ -176,8 +177,8 @@ class SystemSignatureModel extends AbstractMapTrackingModel { /** * @param string $action - * @return logging\LogInterface - * @throws \Exception\ConfigException + * @return Logging\LogInterface + * @throws Exception\ConfigException */ public function newLog(string $action = ''): Logging\LogInterface{ return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData()); diff --git a/app/main/model/pathfinder/systemstatusmodel.php b/app/Model/Pathfinder/SystemStatusModel.php similarity index 94% rename from app/main/model/pathfinder/systemstatusmodel.php rename to app/Model/Pathfinder/SystemStatusModel.php index 65a236b4..74e0d71d 100644 --- a/app/main/model/pathfinder/systemstatusmodel.php +++ b/app/Model/Pathfinder/SystemStatusModel.php @@ -6,14 +6,20 @@ * Time: 21:53 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class SystemStatusModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'system_status'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -38,6 +44,9 @@ class SystemStatusModel extends AbstractPathfinderModel { ] ]; + /** + * @var array + */ protected static $tableData = [ [ 'id' => 1, diff --git a/app/main/model/pathfinder/systemtypemodel.php b/app/Model/Pathfinder/SystemTypeModel.php similarity index 96% rename from app/main/model/pathfinder/systemtypemodel.php rename to app/Model/Pathfinder/SystemTypeModel.php index b4c18db5..8e026e36 100644 --- a/app/main/model/pathfinder/systemtypemodel.php +++ b/app/Model/Pathfinder/SystemTypeModel.php @@ -6,7 +6,7 @@ * Time: 21:59 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; diff --git a/app/main/model/pathfinder/usercharactermodel.php b/app/Model/Pathfinder/UserCharacterModel.php similarity index 87% rename from app/main/model/pathfinder/usercharactermodel.php rename to app/Model/Pathfinder/UserCharacterModel.php index e96cb7ed..492d7993 100644 --- a/app/main/model/pathfinder/usercharactermodel.php +++ b/app/Model/Pathfinder/UserCharacterModel.php @@ -6,14 +6,20 @@ * Time: 21:49 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; class UserCharacterModel extends AbstractPathfinderModel { + /** + * @var string + */ protected $table = 'user_character'; + /** + * @var array + */ protected $fieldConf = [ 'active' => [ 'type' => Schema::DT_BOOL, @@ -24,7 +30,7 @@ class UserCharacterModel extends AbstractPathfinderModel { 'userId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Pathfinder\UserModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\UserModel', 'constraint' => [ [ 'table' => 'user', @@ -36,7 +42,7 @@ class UserCharacterModel extends AbstractPathfinderModel { 'type' => Schema::DT_INT, 'index' => true, 'unique' => true, - 'belongs-to-one' => 'Model\Pathfinder\CharacterModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Pathfinder\CharacterModel', 'constraint' => [ [ 'table' => 'character', diff --git a/app/main/model/pathfinder/usermodel.php b/app/Model/Pathfinder/UserModel.php similarity index 96% rename from app/main/model/pathfinder/usermodel.php rename to app/Model/Pathfinder/UserModel.php index 6a01c6fa..51bce730 100644 --- a/app/main/model/pathfinder/usermodel.php +++ b/app/Model/Pathfinder/UserModel.php @@ -6,14 +6,14 @@ * Time: 20:43 */ -namespace Model\Pathfinder; +namespace Exodus4D\Pathfinder\Model\Pathfinder; use DB\SQL\Schema; -use Controller; -use Controller\Api\User as User; -use Exception; -use lib\Config; -use lib\logging; +use Exodus4D\Pathfinder\Controller; +use Exodus4D\Pathfinder\Controller\Api\User as User; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Logging; +use Exodus4D\Pathfinder\Exception; class UserModel extends AbstractPathfinderModel { @@ -46,7 +46,7 @@ class UserModel extends AbstractPathfinderModel { 'validate' => true ], 'userCharacters' => [ - 'has-many' => ['Model\Pathfinder\UserCharacterModel', 'userId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\UserCharacterModel', 'userId'] ] ]; @@ -55,7 +55,7 @@ class UserModel extends AbstractPathfinderModel { * -> ! caution ! this function returns sensitive data! (e.g. email,..) * -> user getSimpleData() for faster performance and public user data * @return \stdClass - * @throws Exception + * @throws \Exception */ public function getData() : \stdClass { @@ -207,7 +207,7 @@ class UserModel extends AbstractPathfinderModel { * @param int $characterId * @param int $ttl * @return CharacterModel|null - * @throws Exception + * @throws \Exception */ public function getSessionCharacter(int $characterId = 0, int $ttl = self::DEFAULT_SQL_TTL) : ?CharacterModel { $data = []; @@ -285,7 +285,7 @@ class UserModel extends AbstractPathfinderModel { * -> EITHER - the current active one for the current user * -> OR - get the first active one * @return null|CharacterModel - * @throws Exception + * @throws \Exception */ public function getActiveCharacter() : ?CharacterModel { $activeCharacter = null; diff --git a/app/main/model/pathfinder/abstractpathfindermodel.php b/app/Model/Pathfinder/abstractpathfindermodel.php similarity index 100% rename from app/main/model/pathfinder/abstractpathfindermodel.php rename to app/Model/Pathfinder/abstractpathfindermodel.php diff --git a/app/main/model/universe/alliancemodel.php b/app/Model/Universe/AllianceModel.php similarity index 88% rename from app/main/model/universe/alliancemodel.php rename to app/Model/Universe/AllianceModel.php index 7a1b3f49..d72ded47 100644 --- a/app/main/model/universe/alliancemodel.php +++ b/app/Model/Universe/AllianceModel.php @@ -1,7 +1,7 @@ [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', @@ -42,10 +42,10 @@ class AllianceModel extends AbstractUniverseModel { ] ], 'corporations' => [ - 'has-many' => ['Model\Universe\CorporationModel', 'allianceId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\CorporationModel', 'allianceId'] ], 'sovereigntySystems' => [ - 'has-many' => ['Model\Universe\SovereigntyMapModel', 'allianceId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SovereigntyMapModel', 'allianceId'] ] ]; diff --git a/app/main/model/universe/categorymodel.php b/app/Model/Universe/CategoryModel.php similarity index 96% rename from app/main/model/universe/categorymodel.php rename to app/Model/Universe/CategoryModel.php index 3d533143..cf32f1e0 100644 --- a/app/main/model/universe/categorymodel.php +++ b/app/Model/Universe/CategoryModel.php @@ -6,14 +6,20 @@ * Time: 23:49 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; class CategoryModel extends AbstractUniverseModel { + /** + * @var string + */ protected $table = 'category'; + /** + * @var array + */ protected $fieldConf = [ 'name' => [ 'type' => Schema::DT_VARCHAR128, @@ -27,7 +33,7 @@ class CategoryModel extends AbstractUniverseModel { 'index' => true ], 'groups' => [ - 'has-many' => ['Model\Universe\GroupModel', 'categoryId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\GroupModel', 'categoryId'] ] ]; diff --git a/app/main/model/universe/constellationmodel.php b/app/Model/Universe/ConstellationModel.php similarity index 89% rename from app/main/model/universe/constellationmodel.php rename to app/Model/Universe/ConstellationModel.php index 1f061ecf..4fff75b6 100644 --- a/app/main/model/universe/constellationmodel.php +++ b/app/Model/Universe/ConstellationModel.php @@ -6,7 +6,7 @@ * Time: 16:49 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -29,7 +29,7 @@ class ConstellationModel extends AbstractUniverseModel { 'regionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\RegionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\RegionModel', 'constraint' => [ [ 'table' => 'region', @@ -54,10 +54,10 @@ class ConstellationModel extends AbstractUniverseModel { 'default' => 0 ], 'systems' => [ - 'has-many' => ['Model\Universe\SystemModel', 'constellationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constellationId'] ], 'systemNeighbours' => [ - 'has-many' => ['Model\Universe\SystemNeighbourModel', 'constellationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemNeighbourModel', 'constellationId'] ] ]; diff --git a/app/main/model/universe/corporationmodel.php b/app/Model/Universe/CorporationModel.php similarity index 89% rename from app/main/model/universe/corporationmodel.php rename to app/Model/Universe/CorporationModel.php index d672bc13..3c6faf9e 100644 --- a/app/main/model/universe/corporationmodel.php +++ b/app/Model/Universe/CorporationModel.php @@ -1,7 +1,7 @@ [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', @@ -54,7 +54,7 @@ class CorporationModel extends AbstractUniverseModel { 'allianceId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\AllianceModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\AllianceModel', 'constraint' => [ [ 'table' => 'alliance', @@ -63,10 +63,10 @@ class CorporationModel extends AbstractUniverseModel { ] ], 'sovereigntySystems' => [ - 'has-many' => ['Model\Universe\SovereigntyMapModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SovereigntyMapModel', 'corporationId'] ], 'stations' => [ - 'has-many' => ['Model\Universe\StationModel', 'corporationId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StationModel', 'corporationId'] ] ]; diff --git a/app/main/model/universe/dogmaattributemodel.php b/app/Model/Universe/DogmaAttributeModel.php similarity index 94% rename from app/main/model/universe/dogmaattributemodel.php rename to app/Model/Universe/DogmaAttributeModel.php index 7936c2a8..75575126 100644 --- a/app/main/model/universe/dogmaattributemodel.php +++ b/app/Model/Universe/DogmaAttributeModel.php @@ -6,7 +6,7 @@ * Time: 22:00 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -65,7 +65,7 @@ class DogmaAttributeModel extends AbstractUniverseModel { 'default' => null ], 'attributeTypes' => [ - 'has-many' => ['Model\Universe\TypeAttributeModel', 'attributeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\TypeAttributeModel', 'attributeId'] ] ]; diff --git a/app/main/model/universe/factionmodel.php b/app/Model/Universe/FactionModel.php similarity index 76% rename from app/main/model/universe/factionmodel.php rename to app/Model/Universe/FactionModel.php index bc4623ac..6469bbdf 100644 --- a/app/main/model/universe/factionmodel.php +++ b/app/Model/Universe/FactionModel.php @@ -6,7 +6,7 @@ * Time: 09:51 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -47,22 +47,22 @@ class FactionModel extends AbstractUniverseModel { 'default' => 0 ], 'race' => [ // faction API endpoint dont have "raceId" data, but race API endpoint has - 'has-one' => ['Model\Universe\RaceModel', 'factionId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Universe\RaceModel', 'factionId'] ], 'alliances' => [ - 'has-many' => ['Model\Universe\AllianceModel', 'factionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\AllianceModel', 'factionId'] ], 'corporations' => [ - 'has-many' => ['Model\Universe\CorporationModel', 'factionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\CorporationModel', 'factionId'] ], 'sovereigntySystems' => [ - 'has-many' => ['Model\Universe\SovereigntyMapModel', 'factionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SovereigntyMapModel', 'factionId'] ], 'factionWarSystemOwners' => [ - 'has-many' => ['Model\Universe\FactionWarSystemModel', 'ownerFactionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\FactionWarSystemModel', 'ownerFactionId'] ], 'factionWarSystemOccupiers' => [ - 'has-many' => ['Model\Universe\FactionWarSystemModel', 'occupierFactionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\FactionWarSystemModel', 'occupierFactionId'] ] ]; diff --git a/app/main/model/universe/factionwarsystemmodel.php b/app/Model/Universe/FactionWarSystemModel.php similarity index 90% rename from app/main/model/universe/factionwarsystemmodel.php rename to app/Model/Universe/FactionWarSystemModel.php index 943cd09b..807010a3 100644 --- a/app/main/model/universe/factionwarsystemmodel.php +++ b/app/Model/Universe/FactionWarSystemModel.php @@ -1,7 +1,7 @@ Schema::DT_INT, 'index' => true, 'unique' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -32,7 +32,7 @@ class FactionWarSystemModel extends AbstractUniverseModel { 'ownerFactionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', @@ -43,7 +43,7 @@ class FactionWarSystemModel extends AbstractUniverseModel { 'occupierFactionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', diff --git a/app/main/model/universe/groupmodel.php b/app/Model/Universe/GroupModel.php similarity index 95% rename from app/main/model/universe/groupmodel.php rename to app/Model/Universe/GroupModel.php index 1bbf5076..1b73be6b 100644 --- a/app/main/model/universe/groupmodel.php +++ b/app/Model/Universe/GroupModel.php @@ -6,7 +6,7 @@ * Time: 23:58 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -40,7 +40,7 @@ class GroupModel extends AbstractUniverseModel { 'categoryId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\CategoryModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\CategoryModel', 'constraint' => [ [ 'table' => 'category', @@ -50,7 +50,7 @@ class GroupModel extends AbstractUniverseModel { 'validate' => 'notDry' ], 'types' => [ - 'has-many' => ['Model\Universe\TypeModel', 'groupId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\TypeModel', 'groupId'] ] ]; diff --git a/app/main/model/universe/planetmodel.php b/app/Model/Universe/PlanetModel.php similarity index 90% rename from app/main/model/universe/planetmodel.php rename to app/Model/Universe/PlanetModel.php index 6b7eefb4..cdc9a944 100644 --- a/app/main/model/universe/planetmodel.php +++ b/app/Model/Universe/PlanetModel.php @@ -6,14 +6,20 @@ * Time: 01:12 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; class PlanetModel extends AbstractUniverseModel { + /** + * @var string + */ protected $table = 'planet'; + /** + * @var array + */ protected $fieldConf = [ 'name' => [ 'type' => Schema::DT_VARCHAR128, @@ -23,7 +29,7 @@ class PlanetModel extends AbstractUniverseModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -35,7 +41,7 @@ class PlanetModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', diff --git a/app/main/model/universe/racemodel.php b/app/Model/Universe/RaceModel.php similarity index 89% rename from app/main/model/universe/racemodel.php rename to app/Model/Universe/RaceModel.php index deea0ed0..680875d5 100644 --- a/app/main/model/universe/racemodel.php +++ b/app/Model/Universe/RaceModel.php @@ -6,7 +6,7 @@ * Time: 03:21 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -32,7 +32,7 @@ class RaceModel extends AbstractUniverseModel { 'factionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', @@ -42,7 +42,7 @@ class RaceModel extends AbstractUniverseModel { 'validate' => 'notDry' ], 'stations' => [ - 'has-many' => ['Model\Universe\StationModel', 'raceId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StationModel', 'raceId'] ] ]; diff --git a/app/main/model/universe/regionmodel.php b/app/Model/Universe/RegionModel.php similarity index 89% rename from app/main/model/universe/regionmodel.php rename to app/Model/Universe/RegionModel.php index 77b84fc7..ae238adf 100644 --- a/app/main/model/universe/regionmodel.php +++ b/app/Model/Universe/RegionModel.php @@ -6,7 +6,7 @@ * Time: 15:20 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -31,10 +31,10 @@ class RegionModel extends AbstractUniverseModel { 'type' => Schema::DT_TEXT ], 'constellations' => [ - 'has-many' => ['Model\Universe\ConstellationModel', 'regionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\ConstellationModel', 'regionId'] ], 'systemNeighbours' => [ - 'has-many' => ['Model\Universe\SystemNeighbourModel', 'regionId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemNeighbourModel', 'regionId'] ] ]; diff --git a/app/main/model/universe/sovereigntymapmodel.php b/app/Model/Universe/SovereigntyMapModel.php similarity index 85% rename from app/main/model/universe/sovereigntymapmodel.php rename to app/Model/Universe/SovereigntyMapModel.php index 59b18b2c..6ac02c29 100644 --- a/app/main/model/universe/sovereigntymapmodel.php +++ b/app/Model/Universe/SovereigntyMapModel.php @@ -1,7 +1,7 @@ Schema::DT_INT, 'index' => true, 'unique' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -32,7 +32,7 @@ class SovereigntyMapModel extends AbstractUniverseModel { 'factionId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\FactionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\FactionModel', 'constraint' => [ [ 'table' => 'faction', @@ -43,7 +43,7 @@ class SovereigntyMapModel extends AbstractUniverseModel { 'allianceId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\AllianceModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\AllianceModel', 'constraint' => [ [ 'table' => 'alliance', @@ -54,7 +54,7 @@ class SovereigntyMapModel extends AbstractUniverseModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', diff --git a/app/main/model/universe/starmodel.php b/app/Model/Universe/StarModel.php similarity index 92% rename from app/main/model/universe/starmodel.php rename to app/Model/Universe/StarModel.php index 94d21876..5a12d9f5 100644 --- a/app/main/model/universe/starmodel.php +++ b/app/Model/Universe/StarModel.php @@ -6,7 +6,7 @@ * Time: 23:52 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -29,7 +29,7 @@ class StarModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', @@ -64,7 +64,7 @@ class StarModel extends AbstractUniverseModel { 'default' => null ], 'system' => [ - 'has-one' => ['Model\Universe\SystemModel', 'starId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Universe\SystemModel', 'starId'] ] ]; diff --git a/app/main/model/universe/stargatemodel.php b/app/Model/Universe/StargateModel.php similarity index 92% rename from app/main/model/universe/stargatemodel.php rename to app/Model/Universe/StargateModel.php index cbc32a58..03e8c2f2 100644 --- a/app/main/model/universe/stargatemodel.php +++ b/app/Model/Universe/StargateModel.php @@ -6,14 +6,20 @@ * Time: 04:30 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; class StargateModel extends AbstractUniverseModel { + /** + * @var string + */ protected $table = 'stargate'; + /** + * @var array + */ protected $fieldConf = [ 'name' => [ 'type' => Schema::DT_VARCHAR128, @@ -23,7 +29,7 @@ class StargateModel extends AbstractUniverseModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -35,7 +41,7 @@ class StargateModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', @@ -47,7 +53,7 @@ class StargateModel extends AbstractUniverseModel { 'destinationSystemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', diff --git a/app/main/model/universe/stationmodel.php b/app/Model/Universe/StationModel.php similarity index 92% rename from app/main/model/universe/stationmodel.php rename to app/Model/Universe/StationModel.php index d890ea59..daae2bc6 100644 --- a/app/main/model/universe/stationmodel.php +++ b/app/Model/Universe/StationModel.php @@ -6,7 +6,7 @@ * Time: 03:00 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -29,7 +29,7 @@ class StationModel extends AbstractUniverseModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -41,7 +41,7 @@ class StationModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', @@ -53,7 +53,7 @@ class StationModel extends AbstractUniverseModel { 'corporationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\CorporationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\CorporationModel', 'constraint' => [ [ 'table' => 'corporation', @@ -64,7 +64,7 @@ class StationModel extends AbstractUniverseModel { 'raceId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\RaceModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\RaceModel', 'constraint' => [ [ 'table' => 'race', diff --git a/app/main/model/universe/structuremodel.php b/app/Model/Universe/StructureModel.php similarity index 94% rename from app/main/model/universe/structuremodel.php rename to app/Model/Universe/StructureModel.php index a1fc0ae4..17b48b21 100644 --- a/app/main/model/universe/structuremodel.php +++ b/app/Model/Universe/StructureModel.php @@ -6,7 +6,7 @@ * Time: 15:56 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL; use DB\SQL\Schema; @@ -30,7 +30,7 @@ class StructureModel extends AbstractUniverseModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -42,7 +42,7 @@ class StructureModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', diff --git a/app/main/model/universe/systemmodel.php b/app/Model/Universe/SystemModel.php similarity index 94% rename from app/main/model/universe/systemmodel.php rename to app/Model/Universe/SystemModel.php index c59ca342..7b035676 100644 --- a/app/main/model/universe/systemmodel.php +++ b/app/Model/Universe/SystemModel.php @@ -6,7 +6,7 @@ * Time: 19:29 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -29,7 +29,7 @@ class SystemModel extends AbstractUniverseModel { 'constellationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\ConstellationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\ConstellationModel', 'constraint' => [ [ 'table' => 'constellation', @@ -41,7 +41,7 @@ class SystemModel extends AbstractUniverseModel { 'starId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\StarModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\StarModel', 'constraint' => [ [ 'table' => 'star', @@ -85,28 +85,28 @@ class SystemModel extends AbstractUniverseModel { 'default' => 0 ], 'planets' => [ - 'has-many' => ['Model\Universe\PlanetModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\PlanetModel', 'systemId'] ], 'statics' => [ - 'has-many' => ['Model\Universe\SystemStaticModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemStaticModel', 'systemId'] ], 'stargates' => [ - 'has-many' => ['Model\Universe\StargateModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StargateModel', 'systemId'] ], 'stations' => [ - 'has-many' => ['Model\Universe\StationModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StationModel', 'systemId'] ], 'structures' => [ - 'has-many' => ['Model\Universe\StructureModel', 'systemId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StructureModel', 'systemId'] ], 'neighbour' => [ - 'has-one' => ['Model\Universe\SystemNeighbourModel', 'systemId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Universe\SystemNeighbourModel', 'systemId'] ], 'sovereignty' => [ - 'has-one' => ['Model\Universe\SovereigntyMapModel', 'systemId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Universe\SovereigntyMapModel', 'systemId'] ], 'factionWar' => [ - 'has-one' => ['Model\Universe\FactionWarSystemModel', 'systemId'] + 'has-one' => ['Exodus4D\Pathfinder\Model\Universe\FactionWarSystemModel', 'systemId'] ] ]; diff --git a/app/main/model/universe/systemneighbourmodel.php b/app/Model/Universe/SystemNeighbourModel.php similarity index 87% rename from app/main/model/universe/systemneighbourmodel.php rename to app/Model/Universe/SystemNeighbourModel.php index f598565c..0ef5a20c 100644 --- a/app/main/model/universe/systemneighbourmodel.php +++ b/app/Model/Universe/SystemNeighbourModel.php @@ -1,7 +1,7 @@ [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\RegionModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\RegionModel', 'constraint' => [ [ 'table' => 'region', @@ -38,7 +38,7 @@ class SystemNeighbourModel extends AbstractUniverseModel { 'constellationId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\ConstellationModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\ConstellationModel', 'constraint' => [ [ 'table' => 'constellation', @@ -51,7 +51,7 @@ class SystemNeighbourModel extends AbstractUniverseModel { 'type' => Schema::DT_INT, 'index' => true, 'unique' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', diff --git a/app/main/model/universe/systemstaticmodel.php b/app/Model/Universe/SystemStaticModel.php similarity index 89% rename from app/main/model/universe/systemstaticmodel.php rename to app/Model/Universe/SystemStaticModel.php index a072b123..c62b7b52 100644 --- a/app/main/model/universe/systemstaticmodel.php +++ b/app/Model/Universe/SystemStaticModel.php @@ -6,7 +6,7 @@ * Time: 17:50 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -24,7 +24,7 @@ class SystemStaticModel extends AbstractUniverseModel { 'systemId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\SystemModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constraint' => [ [ 'table' => 'system', @@ -36,7 +36,7 @@ class SystemStaticModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', diff --git a/app/main/model/universe/typeattributemodel.php b/app/Model/Universe/TypeAttributeModel.php similarity index 90% rename from app/main/model/universe/typeattributemodel.php rename to app/Model/Universe/TypeAttributeModel.php index eec9d4bf..41011af6 100644 --- a/app/main/model/universe/typeattributemodel.php +++ b/app/Model/Universe/TypeAttributeModel.php @@ -6,7 +6,7 @@ * Time: 22:00 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; @@ -24,7 +24,7 @@ class TypeAttributeModel extends AbstractUniverseModel { 'typeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\TypeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel', 'constraint' => [ [ 'table' => 'type', @@ -36,7 +36,7 @@ class TypeAttributeModel extends AbstractUniverseModel { 'attributeId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\DogmaAttributeModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\DogmaAttributeModel', 'constraint' => [ [ 'table' => 'dogma_attribute', diff --git a/app/main/model/universe/typemodel.php b/app/Model/Universe/TypeModel.php similarity index 93% rename from app/main/model/universe/typemodel.php rename to app/Model/Universe/TypeModel.php index 4402d741..e9d9045c 100644 --- a/app/main/model/universe/typemodel.php +++ b/app/Model/Universe/TypeModel.php @@ -6,11 +6,11 @@ * Time: 15:56 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; use DB\SQL\Schema; -use lib\Config; -use lib\Util; +use Exodus4D\Pathfinder\Lib\Config; +use Exodus4D\Pathfinder\Lib\Util; class TypeModel extends AbstractUniverseModel { @@ -72,7 +72,7 @@ class TypeModel extends AbstractUniverseModel { 'groupId' => [ 'type' => Schema::DT_INT, 'index' => true, - 'belongs-to-one' => 'Model\Universe\GroupModel', + 'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\GroupModel', 'constraint' => [ [ 'table' => 'group', @@ -104,25 +104,25 @@ class TypeModel extends AbstractUniverseModel { 'index' => true ], 'stations' => [ - 'has-many' => ['Model\Universe\StationModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StationModel', 'typeId'] ], 'structures' => [ - 'has-many' => ['Model\Universe\StructureModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StructureModel', 'typeId'] ], 'planets' => [ - 'has-many' => ['Model\Universe\PlanetModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\PlanetModel', 'typeId'] ], 'stars' => [ - 'has-many' => ['Model\Universe\StarModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StarModel', 'typeId'] ], 'attributes' => [ - 'has-many' => ['Model\Universe\TypeAttributeModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\TypeAttributeModel', 'typeId'] ], 'stargates' => [ - 'has-many' => ['Model\Universe\StargateModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\StargateModel', 'typeId'] ], 'statics' => [ - 'has-many' => ['Model\Universe\SystemStaticModel', 'typeId'] + 'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemStaticModel', 'typeId'] ] ]; diff --git a/app/main/model/universe/abstractuniversemodel.php b/app/Model/Universe/abstractuniversemodel.php similarity index 98% rename from app/main/model/universe/abstractuniversemodel.php rename to app/Model/Universe/abstractuniversemodel.php index f2b85df8..cc5c3a9a 100644 --- a/app/main/model/universe/abstractuniversemodel.php +++ b/app/Model/Universe/abstractuniversemodel.php @@ -6,9 +6,9 @@ * Time: 14:18 */ -namespace Model\Universe; +namespace Exodus4D\Pathfinder\Model\Universe; -use Model\AbstractModel; +use Exodus4D\Pathfinder\Model\AbstractModel; abstract class AbstractUniverseModel extends AbstractModel { diff --git a/app/main/model/abstractmodel.php b/app/Model/abstractmodel.php similarity index 100% rename from app/main/model/abstractmodel.php rename to app/Model/abstractmodel.php diff --git a/app/config.ini b/app/config.ini index 8eb9ab6c..3e2bfc23 100644 --- a/app/config.ini +++ b/app/config.ini @@ -85,8 +85,8 @@ API_CACHE = {{@CACHE}} SESSION_CACHE = mysql ; Callback functions ============================================================================== -ONERROR = Controller\Controller->showError -UNLOAD = Controller\Controller->unload +ONERROR = Exodus4D\Pathfinder\Controller\Controller->showError +UNLOAD = Exodus4D\Pathfinder\Controller\Controller->unload ; Path configurations ============================================================================= ; All path configurations are relative to BASE dir and should NOT be changed @@ -111,8 +111,8 @@ UI = public/ ; Autoload folder ; Where PHP attempts to autoload PHP classes at runtime. ; Syntax: [DIR] -; Default: app/main/ -AUTOLOAD = app/main/ +; Default: app/ +;AUTOLOAD = app/ ; Favicon folder ; Syntax: [DIR] diff --git a/app/routes.ini b/app/routes.ini index d411c0ec..5b4ce3cf 100644 --- a/app/routes.ini +++ b/app/routes.ini @@ -3,25 +3,25 @@ [routes] ; DB setup setup ; IMPORTANT: remove/comment this line after setup/update is finished! -GET @setup: /setup [sync] = Controller\Setup->init +GET @setup: /setup [sync] = Exodus4D\Pathfinder\Controller\Setup->init ; login (index) page -GET @login: / [sync] = Controller\AppController->init +GET @login: / [sync] = Exodus4D\Pathfinder\Controller\AppController->init ; CCP SSO redirect -GET @sso: /sso/@action [sync] = Controller\Ccp\Sso->@action +GET @sso: /sso/@action [sync] = Exodus4D\Pathfinder\Controller\Ccp\Sso->@action ; map page -GET @map: /map* [sync] = Controller\MapController->init +GET @map: /map* [sync] = Exodus4D\Pathfinder\Controller\MapController->init ; admin panel -GET @admin: /admin* [sync] = Controller\Admin->dispatch +GET @admin: /admin* [sync] = Exodus4D\Pathfinder\Controller\Admin->dispatch ; AJAX API wildcard endpoints (not cached, throttled) -GET|POST /api/@controller/@action [ajax] = Controller\Api\@controller->@action, 0, 512 -GET|POST /api/@controller/@action/@arg1 [ajax] = Controller\Api\@controller->@action, 0, 512 -GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = Controller\Api\@controller->@action, 0, 512 +GET|POST /api/@controller/@action [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512 +GET|POST /api/@controller/@action/@arg1 [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512 +GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512 ; onUnload route or final map sync (@see https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) -POST /api/map/updateUnloadData = Controller\Api\map->updateUnloadData, 0, 512 +POST /api/map/updateUnloadData = Exodus4D\Pathfinder\Controller\Api\map->updateUnloadData, 0, 512 [maps] ; REST API wildcard endpoints (not cached, throttled) -/api/rest/@controller* [ajax] = Controller\Api\Rest\@controller, 0, 512 -/api/rest/@controller/@id [ajax] = Controller\Api\Rest\@controller, 0, 512 \ No newline at end of file +/api/rest/@controller* [ajax] = Exodus4D\Pathfinder\Controller\Api\Rest\@controller, 0, 512 +/api/rest/@controller/@id [ajax] = Exodus4D\Pathfinder\Controller\Api\Rest\@controller, 0, 512 \ No newline at end of file diff --git a/composer-dev.json b/composer-dev.json index 1536b4c4..e38cfe9b 100644 --- a/composer-dev.json +++ b/composer-dev.json @@ -17,7 +17,7 @@ }, "autoload": { "psr-4": { - "Exodus4D\\Pathfinder\\": "app/main" + "Exodus4D\\Pathfinder\\": "app/" } }, "repositories": [ @@ -34,8 +34,10 @@ "ext-json": "*", "ext-mbstring": "*", "ext-ctype": "*", + "ext-gd": "*", "bcosca/fatfree-core": "3.7.*", "ikkez/f3-cortex": "dev-master#0d7754a5897a639e563add6b8d6db53fc0fae677", + "ikkez/f3-sheet": "0.4.*", "xfra35/f3-cron": "1.2.*", "monolog/monolog": "2.*", "swiftmailer/swiftmailer": "6.2.*", diff --git a/composer.json b/composer.json index b7395b40..7a5b403d 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "autoload": { "psr-4": { - "Exodus4D\\Pathfinder\\": "app/main" + "Exodus4D\\Pathfinder\\": "app/" } }, "repositories": [ @@ -34,8 +34,10 @@ "ext-json": "*", "ext-mbstring": "*", "ext-ctype": "*", + "ext-gd": "*", "bcosca/fatfree-core": "3.7.*", - "ikkez/f3-cortex": "1.6.*", + "ikkez/f3-cortex": "dev-master#0d7754a5897a639e563add6b8d6db53fc0fae677", + "ikkez/f3-sheet": "0.4.*", "xfra35/f3-cron": "1.2.*", "monolog/monolog": "2.*", "swiftmailer/swiftmailer": "6.2.x", diff --git a/index.php b/index.php index 98b54884..1bfbc12a 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,8 @@ config('app/config.ini', true); // load environment dependent config -lib\Config::instance($f3); +Lib\Config::instance($f3); // initiate cron-jobs -lib\Cron::instance(); +Lib\Cron::instance(); $f3->run(); \ No newline at end of file diff --git a/public/templates/ui/jsonld.html b/public/templates/ui/jsonld.html index c47cd846..ef2db48a 100644 --- a/public/templates/ui/jsonld.html +++ b/public/templates/ui/jsonld.html @@ -6,7 +6,7 @@ "@type": "Organization", "name": "{{ @PATHFINDER.NAME }}", "legalName": "Pathfinder - OpenSource", - "url": "{{ Controller\Controller::getEnvironmentData('URL') }}", + "url": "{{ Exodus4D\Pathfinder\Controller\Controller::getEnvironmentData('URL') }}", "logo": "{{@SCHEME.'://'.@HOST.'/'.@BASE.@FAVICON}}favicon-192x192.png", "foundingDate": "2014", "founders": [{