This commit is contained in:
Generated
+2
-2
@@ -12,7 +12,7 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.lutran.fr/franzz/objects",
|
"url": "https://git.lutran.fr/franzz/objects",
|
||||||
"reference": "af7d0f4c86564995f1c8149df98a183d33fab767"
|
"reference": "b8a2220701a43b6695f3010257d5bf62c77d81c2"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Objects",
|
"description": "Objects",
|
||||||
"time": "2026-05-29T23:29:34+00:00"
|
"time": "2026-07-27T13:46:58+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpmailer/phpmailer",
|
"name": "phpmailer/phpmailer",
|
||||||
|
|||||||
@@ -12,5 +12,43 @@
|
|||||||
Options FollowSymLinks
|
Options FollowSymLinks
|
||||||
AllowOverride None
|
AllowOverride None
|
||||||
Require all granted
|
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>
|
</Directory>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|||||||
+1
-4
@@ -20,8 +20,7 @@ class Controller extends PhpObject
|
|||||||
'add_position',
|
'add_position',
|
||||||
'admin_set',
|
'admin_set',
|
||||||
'admin_create',
|
'admin_create',
|
||||||
'admin_delete',
|
'admin_delete'
|
||||||
'build_geojson'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
private Spot $oSpot;
|
private Spot $oSpot;
|
||||||
@@ -130,7 +129,6 @@ class Controller extends PhpObject
|
|||||||
return match($sAction) {
|
return match($sAction) {
|
||||||
'markers' => $this->oSpot->getMarkers(),
|
'markers' => $this->oSpot->getMarkers(),
|
||||||
'last_update' => $this->oSpot->getLastUpdate(),
|
'last_update' => $this->oSpot->getLastUpdate(),
|
||||||
'geojson' => $this->oSpot->getProjectGeoJson(),
|
|
||||||
'next_feed' => $this->oSpot->getNextFeed($this->asReq['id']),
|
'next_feed' => $this->oSpot->getNextFeed($this->asReq['id']),
|
||||||
'new_feed' => $this->oSpot->getNewFeed($this->asReq['id']),
|
'new_feed' => $this->oSpot->getNewFeed($this->asReq['id']),
|
||||||
'add_post' => $this->oSpot->addPost($this->asReq['name'], $this->asReq['content']),
|
'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_create' => $this->oSpot->createAdminSettings($this->asReq['type']),
|
||||||
'admin_delete' => $this->oSpot->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
'admin_delete' => $this->oSpot->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
||||||
'sql' => $this->oSpot->getDbBuildScript(),
|
'sql' => $this->oSpot->getDbBuildScript(),
|
||||||
'build_geojson' => $this->oSpot->buildGeoJSON($this->asReq['name']),
|
|
||||||
default => Spot::getJsonResult(false, Spot::NOT_FOUND)
|
default => Spot::getJsonResult(false, Spot::NOT_FOUND)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ use Franzz\Objects\PhpObject;
|
|||||||
* 1. Add file <file_name>.gpx to geo/ folder
|
* 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>;
|
* 2. Assign file to project: UPDATE projects SET codename = '<file_name>' WHERE id_project = <id_project>;
|
||||||
* 3. Load any page
|
* 3. Load any page
|
||||||
*
|
|
||||||
* To force gpx rebuild:
|
|
||||||
* ?a=build_geojson&name=<file_name>
|
|
||||||
*/
|
*/
|
||||||
class Converter extends PhpObject {
|
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);
|
if($bSpecificProj) $asInfo['constraint'] = array(Db::getId(self::PROJ_TABLE)=>$iProjectId);
|
||||||
|
|
||||||
$asProjects = $this->oDb->selectRows($asInfo, 'codename');
|
$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']) {
|
switch($asProject['mode']) {
|
||||||
case 0: $asProject['mode'] = self::MODE_PREVIZ; break;
|
case 0: $asProject['mode'] = self::MODE_PREVIZ; break;
|
||||||
case 1: $asProject['mode'] = self::MODE_BLOG; break;
|
case 1: $asProject['mode'] = self::MODE_BLOG; break;
|
||||||
@@ -146,21 +154,13 @@ class Project extends PhpObject {
|
|||||||
}
|
}
|
||||||
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
||||||
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
||||||
|
$asProject['geofilepath'] = Spot::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
|
||||||
$asProject['codename'] = $sCodeName;
|
$asProject['codename'] = $sCodeName;
|
||||||
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
|
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
|
||||||
}
|
}
|
||||||
return $bSpecificProj?$asProject:$asProjects;
|
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() {
|
public function getProject() {
|
||||||
return $this->getProjects($this->getProjectId());
|
return $this->getProjects($this->getProjectId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,10 +256,6 @@ class Spot extends Main
|
|||||||
$this->oProject->setProjectId($iProjectId);
|
$this->oProject->setProjectId($iProjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProjectGeoJson() {
|
|
||||||
return self::getJsonResult(true, '', $this->oProject->getGeoJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateProject() {
|
public function updateProject() {
|
||||||
$bNewMsg = false;
|
$bNewMsg = false;
|
||||||
$bSuccess = true;
|
$bSuccess = true;
|
||||||
@@ -859,10 +855,6 @@ class Spot extends Main
|
|||||||
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildGeoJSON($sCodeName) {
|
|
||||||
return Converter::convertToGeoJson($sCodeName)['logs'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function decToDms($dValue, $sType) {
|
public static function decToDms($dValue, $sType) {
|
||||||
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
||||||
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
||||||
|
|||||||
@@ -179,8 +179,6 @@ class User extends PhpObject {
|
|||||||
$sDesc = 'lang:account.logged_in';
|
$sDesc = 'lang:account.logged_in';
|
||||||
}
|
}
|
||||||
else $sDesc = 'lang:account.invalid_credentials';
|
else $sDesc = 'lang:account.invalid_credentials';
|
||||||
|
|
||||||
//die(print_r(['provided_pass'=>$sPassword, 'db_pass'=>$asDBUser['password']], true));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bSuccess = true;
|
$bSuccess = true;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ export default {
|
|||||||
this.track
|
this.track
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.api.get('markers', {id_project: this.project.id}),
|
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();
|
await this.initMap();
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ export default class Api {
|
|||||||
return response.data;
|
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 = {}) {
|
async post(sAction, asParams = {}) {
|
||||||
const response = await this.request(sAction, asParams, 'POST');
|
const response = await this.request(sAction, asParams, 'POST');
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user