This commit is contained in:
Generated
+2
-2
@@ -12,7 +12,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.lutran.fr/franzz/objects",
|
||||
"reference": "af7d0f4c86564995f1c8149df98a183d33fab767"
|
||||
"reference": "b8a2220701a43b6695f3010257d5bf62c77d81c2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"description": "Objects",
|
||||
"time": "2026-05-29T23:29:34+00:00"
|
||||
"time": "2026-07-27T13:46:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
|
||||
@@ -12,5 +12,43 @@
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
|
||||
AddType application/geo+json .geojson
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
<FilesMatch "\.geojson$">
|
||||
Header set Cache-Control "public, max-age=31536000, immutable"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_brotli.c>
|
||||
AddOutputFilterByType BROTLI_COMPRESS \
|
||||
text/html \
|
||||
text/plain \
|
||||
text/css \
|
||||
text/javascript \
|
||||
text/xml \
|
||||
application/javascript \
|
||||
application/json \
|
||||
application/geo+json \
|
||||
application/manifest+json \
|
||||
application/xml \
|
||||
image/svg+xml
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_deflate.c>
|
||||
AddOutputFilterByType DEFLATE \
|
||||
text/html \
|
||||
text/plain \
|
||||
text/css \
|
||||
text/javascript \
|
||||
text/xml \
|
||||
application/javascript \
|
||||
application/json \
|
||||
application/geo+json \
|
||||
application/manifest+json \
|
||||
application/xml \
|
||||
image/svg+xml
|
||||
</IfModule>
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
|
||||
+1
-4
@@ -20,8 +20,7 @@ class Controller extends PhpObject
|
||||
'add_position',
|
||||
'admin_set',
|
||||
'admin_create',
|
||||
'admin_delete',
|
||||
'build_geojson'
|
||||
'admin_delete'
|
||||
);
|
||||
|
||||
private Spot $oSpot;
|
||||
@@ -130,7 +129,6 @@ class Controller extends PhpObject
|
||||
return match($sAction) {
|
||||
'markers' => $this->oSpot->getMarkers(),
|
||||
'last_update' => $this->oSpot->getLastUpdate(),
|
||||
'geojson' => $this->oSpot->getProjectGeoJson(),
|
||||
'next_feed' => $this->oSpot->getNextFeed($this->asReq['id']),
|
||||
'new_feed' => $this->oSpot->getNewFeed($this->asReq['id']),
|
||||
'add_post' => $this->oSpot->addPost($this->asReq['name'], $this->asReq['content']),
|
||||
@@ -158,7 +156,6 @@ class Controller extends PhpObject
|
||||
'admin_create' => $this->oSpot->createAdminSettings($this->asReq['type']),
|
||||
'admin_delete' => $this->oSpot->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
||||
'sql' => $this->oSpot->getDbBuildScript(),
|
||||
'build_geojson' => $this->oSpot->buildGeoJSON($this->asReq['name']),
|
||||
default => Spot::getJsonResult(false, Spot::NOT_FOUND)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ use Franzz\Objects\PhpObject;
|
||||
* 1. Add file <file_name>.gpx to geo/ folder
|
||||
* 2. Assign file to project: UPDATE projects SET codename = '<file_name>' WHERE id_project = <id_project>;
|
||||
* 3. Load any page
|
||||
*
|
||||
* To force gpx rebuild:
|
||||
* ?a=build_geojson&name=<file_name>
|
||||
*/
|
||||
class Converter extends PhpObject {
|
||||
|
||||
|
||||
+10
-10
@@ -138,7 +138,15 @@ class Project extends PhpObject {
|
||||
if($bSpecificProj) $asInfo['constraint'] = array(Db::getId(self::PROJ_TABLE)=>$iProjectId);
|
||||
|
||||
$asProjects = $this->oDb->selectRows($asInfo, 'codename');
|
||||
foreach($asProjects as $sCodeName=>&$asProject) {
|
||||
foreach($asProjects as $sCodeName => &$asProject) {
|
||||
//Update Geo JSON
|
||||
if($sCodeName != '' && (!Converter::isGeoJsonValid($sCodeName) || !$asProject['latitude'] && !$asProject['longitude'])) {
|
||||
$aiCenter = Converter::convertToGeoJson($sCodeName)['center'];
|
||||
$this->oDb->updateRow(self::PROJ_TABLE, $asProject['id'], ['latitude' => $aiCenter[1], 'longitude' => $aiCenter[0]]);
|
||||
$asProject['latitude'] = $aiCenter[1];
|
||||
$asProject['longitude'] = $aiCenter[0];
|
||||
}
|
||||
|
||||
switch($asProject['mode']) {
|
||||
case 0: $asProject['mode'] = self::MODE_PREVIZ; break;
|
||||
case 1: $asProject['mode'] = self::MODE_BLOG; break;
|
||||
@@ -146,21 +154,13 @@ class Project extends PhpObject {
|
||||
}
|
||||
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
||||
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
||||
$asProject['geofilepath'] = Spot::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
|
||||
$asProject['codename'] = $sCodeName;
|
||||
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
|
||||
}
|
||||
return $bSpecificProj?$asProject:$asProjects;
|
||||
}
|
||||
|
||||
public function getGeoJson() {
|
||||
if($this->sCodeName != '' && !Converter::isGeoJsonValid($this->sCodeName)){
|
||||
$aiCenter = Converter::convertToGeoJson($this->sCodeName)['center'];
|
||||
$this->oDb->updateRow(self::PROJ_TABLE, $this->iProjectId, ['latitude' => $aiCenter[1], 'longitude' => $aiCenter[0]]);
|
||||
}
|
||||
|
||||
return json_decode(file_get_contents(GeoJson::getBackendFilePath($this->sCodeName)), true);
|
||||
}
|
||||
|
||||
public function getProject() {
|
||||
return $this->getProjects($this->getProjectId());
|
||||
}
|
||||
|
||||
@@ -256,10 +256,6 @@ class Spot extends Main
|
||||
$this->oProject->setProjectId($iProjectId);
|
||||
}
|
||||
|
||||
public function getProjectGeoJson() {
|
||||
return self::getJsonResult(true, '', $this->oProject->getGeoJson());
|
||||
}
|
||||
|
||||
public function updateProject() {
|
||||
$bNewMsg = false;
|
||||
$bSuccess = true;
|
||||
@@ -859,10 +855,6 @@ class Spot extends Main
|
||||
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
||||
}
|
||||
|
||||
public function buildGeoJSON($sCodeName) {
|
||||
return Converter::convertToGeoJson($sCodeName)['logs'];
|
||||
}
|
||||
|
||||
public static function decToDms($dValue, $sType) {
|
||||
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
||||
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
||||
|
||||
@@ -179,8 +179,6 @@ class User extends PhpObject {
|
||||
$sDesc = 'lang:account.logged_in';
|
||||
}
|
||||
else $sDesc = 'lang:account.invalid_credentials';
|
||||
|
||||
//die(print_r(['provided_pass'=>$sPassword, 'db_pass'=>$asDBUser['password']], true));
|
||||
}
|
||||
else {
|
||||
$bSuccess = true;
|
||||
|
||||
@@ -204,7 +204,7 @@ export default {
|
||||
this.track
|
||||
] = await Promise.all([
|
||||
this.api.get('markers', {id_project: this.project.id}),
|
||||
this.api.get('geojson', {id_project: this.project.id})
|
||||
this.api.getAsset(this.project.geofilepath)
|
||||
]);
|
||||
|
||||
await this.initMap();
|
||||
|
||||
@@ -14,6 +14,16 @@ export default class Api {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getAsset(sAssetPath) {
|
||||
const oRequest = await fetch(sAssetPath, {headers: {'Accept': 'application/geo+json'}});
|
||||
|
||||
if(!oRequest.ok) {
|
||||
throw new Error('Error HTTP ' + oRequest.status + ': ' + oRequest.statusText);
|
||||
}
|
||||
|
||||
return oRequest.json();
|
||||
}
|
||||
|
||||
async post(sAction, asParams = {}) {
|
||||
const response = await this.request(sAction, asParams, 'POST');
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user