Compare commits
240
Commits
7853c6e285
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56d8f46434 | ||
|
|
a70f6fe64c | ||
|
|
dc4480c4e2 | ||
|
|
e2a694ba03 | ||
|
|
8efd74406f | ||
|
|
51837ef1ac | ||
|
|
842bb56fcc | ||
|
|
0acec1f37e | ||
|
|
8ebfb2d830 | ||
|
|
aa8f80451d | ||
|
|
f4e2781172 | ||
|
|
506c8bd946 | ||
|
|
4ae0e46a7d | ||
|
|
d29403d9c5 | ||
|
|
da5a75a9de | ||
|
|
17009b641f | ||
|
|
171db88400 | ||
|
|
2b32b8a683 | ||
|
|
bf8bfa1de2 | ||
|
|
f1b90a4d83 | ||
|
|
0d4b159ab3 | ||
|
|
46d4702471 | ||
|
|
73c5e45164 | ||
|
|
9242172a12 | ||
|
|
2aac7ad5c4 | ||
|
|
ced5e87542 | ||
|
|
a09fb9792f | ||
|
|
d6c897beeb | ||
|
|
dcd3e7339b | ||
|
|
cb14d2a7c1 | ||
|
|
462502cf9f | ||
|
|
3e3c3ee821 | ||
|
|
0ad238b508 | ||
|
|
7da504ca6b | ||
|
|
fb500f3c34 | ||
|
|
9a8b95d237 | ||
|
|
9acdd3cb13 | ||
|
|
dfb92a4d96 | ||
|
|
085cfd8ba2 | ||
|
|
14d827ab66 | ||
|
|
aa30431df8 | ||
|
|
a127535b36 | ||
|
|
aa17ea99a2 | ||
|
|
ae24be2c22 | ||
|
|
0b9f886905 | ||
|
|
7ecd8094e2 | ||
|
|
9718713eb4 | ||
|
|
36a5900118 | ||
|
|
1eebfc90fa | ||
|
|
7b2962be15 | ||
|
|
c738fe8d50 | ||
|
|
76fdc4be43 | ||
|
|
ff3fac2ab9 | ||
|
|
62f976b6f3 | ||
|
|
00a06a1ca9 | ||
|
|
6800256f09 | ||
|
|
17b998ee60 | ||
|
|
87a991eaea | ||
|
|
9ce25e73f0 | ||
|
|
6cad199431 | ||
|
|
36f9057a30 | ||
|
|
05c77f30bd | ||
|
|
739c593d2a | ||
|
|
034d02f042 | ||
|
|
c2685a2731 | ||
|
|
28c6f79fdb | ||
|
|
77a1c51692 | ||
|
|
319c288586 | ||
|
|
980035e3d1 | ||
|
|
520df5b570 | ||
|
|
fdd0ada815 | ||
|
|
8092846d6f | ||
|
|
7b58b65db3 | ||
|
|
d0c33c31a8 | ||
|
|
313dab26a2 | ||
|
|
7ead18601c | ||
|
|
c80e8d1c67 | ||
|
|
d4bc73e32c | ||
|
|
6ee4c8efc7 | ||
|
|
badae8a3a0 | ||
|
|
c783cbe543 | ||
|
|
cf5ae33ba4 | ||
|
|
a3d217bbdd | ||
|
|
7cad5fbdf9 | ||
|
|
fe8a8034ca | ||
|
|
138ce6ec8b | ||
|
|
690fd6d831 | ||
|
|
24fd224ec6 | ||
|
|
c9ce785f12 | ||
|
|
e0fc62df84 | ||
|
|
8a590aa2fc | ||
|
|
3fd68fa938 | ||
|
|
3ba7b2bfab | ||
|
|
b44d2960f7 | ||
|
|
c5529d5f94 | ||
|
|
f63f5c240e | ||
|
|
0bb7ae2361 | ||
|
|
7f74263ba2 | ||
|
|
c43539b640 | ||
|
|
93a72c628e | ||
|
|
39ddd1cf95 | ||
|
|
6f11c827c6 | ||
|
|
b5de606a3e | ||
|
|
837c4a327b | ||
|
|
5b365f1eab | ||
|
|
dfa4f3239c | ||
|
|
1c69ae56ac | ||
|
|
9adfa18e9b | ||
|
|
a2e7b235fe | ||
|
|
49f37465bd | ||
|
|
c3835f45c5 | ||
|
|
17fe2330c6 | ||
|
|
b88fb4ca9d | ||
|
|
daca0a8294 | ||
|
|
e80e3ff3f3 | ||
|
|
8e17db7a2e | ||
|
|
238001ae93 | ||
|
|
b7956766e8 | ||
|
|
ca1183d88a | ||
|
|
4c34994ac7 | ||
|
|
8385c85820 | ||
|
|
71e9c1a45a | ||
|
|
880bbc3d9a | ||
|
|
e293193dd7 | ||
|
|
821b6b47f3 | ||
|
|
1852f6640e | ||
|
|
3c8cdbaad6 | ||
|
|
415bd9d0cf | ||
|
|
aa1856acb7 | ||
|
|
321e79c230 | ||
|
|
614a69103b | ||
|
|
213bd359fc | ||
|
|
1cb82838b2 | ||
|
|
3f1f98f98c | ||
|
|
e6d11f424d | ||
|
|
7aaaff7dda | ||
|
|
07a5c3baf9 | ||
|
|
5e690e5576 | ||
|
|
12ae225773 | ||
|
|
54bae3e9c9 | ||
|
|
141618f2cd | ||
|
|
b759508779 | ||
|
|
a4e0a345d6 | ||
|
|
86082c513e | ||
|
|
36aa480205 | ||
|
|
87286dc8fd | ||
|
|
da46106779 | ||
|
|
0cc7fc336a | ||
|
|
95ebc96484 | ||
|
|
560b22c039 | ||
|
|
3567f521f8 | ||
|
|
fe2a3d91c0 | ||
|
|
15c044ac52 | ||
|
|
e5e34676e2 | ||
|
|
c4dd938a56 | ||
|
|
dcb916d442 | ||
|
|
37bfb42834 | ||
|
|
13c48a559f | ||
|
|
c39b7705be | ||
|
|
844c9c0a53 | ||
|
|
f2af936e60 | ||
|
|
dc411cc532 | ||
|
|
b339d6d068 | ||
|
|
7dc2b28c44 | ||
|
|
ff4bc26381 | ||
|
|
40565849c5 | ||
|
|
dea14acd29 | ||
|
|
c32998650f | ||
|
|
b2b06180e6 | ||
|
|
90349365f9 | ||
|
|
24021bf60f | ||
|
|
64cacaf16e | ||
|
|
eb0ded0d26 | ||
|
|
635b3781e3 | ||
|
|
9e4fbe7ad4 | ||
|
|
ef88e600e3 | ||
|
|
bcc5e9e0cd | ||
|
|
fcbb3d9d14 | ||
|
|
3416ace4ee | ||
|
|
932f950ed8 | ||
|
|
c4d05c297c | ||
|
|
52316d9abb | ||
|
|
cb505d9092 | ||
|
|
f81fbd454e | ||
|
|
295ff0538a | ||
|
|
fb26000122 | ||
|
|
824718fad0 | ||
|
|
77216e6c2f | ||
|
|
28f95162aa | ||
|
|
4f3be3342c | ||
|
|
e70d3ddbd3 | ||
|
|
051503cbed | ||
|
|
b86d5d2cb1 | ||
|
|
e7d4c840c2 | ||
|
|
da39ca6589 | ||
|
|
14bf9e2fc8 | ||
|
|
853a9cc36f | ||
|
|
8ca5fa2d53 | ||
|
|
975a8039b3 | ||
|
|
325373b5d7 | ||
|
|
ac9fcbe0ba | ||
|
|
d9bc89b7f6 | ||
|
|
760f38374f | ||
|
|
789838dd07 | ||
|
|
a5fe6ebf75 | ||
|
|
b9a4bd6d2d | ||
|
|
ea14a1ef3e | ||
|
|
d0dbb85e28 | ||
|
|
457bab2c18 | ||
|
|
3571f93e41 | ||
|
|
e878b159bf | ||
|
|
db70593852 | ||
|
|
73b8e6b04f | ||
|
|
a49f73236b | ||
|
|
c0b7ad8000 | ||
|
|
83bf47287c | ||
|
|
6a42494099 | ||
|
|
1d90b11aef | ||
|
|
bc75cbc17d | ||
|
|
2e8372d923 | ||
|
|
383890a9be | ||
|
|
4ce96e7192 | ||
|
|
3169b8e83e | ||
|
|
205855acd8 | ||
|
|
356d8ccd7e | ||
|
|
25ff80ad7a | ||
|
|
0cd509a99d | ||
|
|
3063f8b904 | ||
|
|
59dea2917d | ||
|
|
6e614042d1 | ||
|
|
8c812f6b0a | ||
|
|
abacab8206 | ||
|
|
869b084d70 | ||
|
|
cab899e544 | ||
|
|
b6fc305111 | ||
|
|
30a81b5341 | ||
|
|
683670f77a | ||
|
|
c2956ac373 | ||
|
|
ae8a27fa64 | ||
|
|
af05650443 |
@@ -0,0 +1,60 @@
|
|||||||
|
name: Deploy Livetrail
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: livetrail
|
||||||
|
|
||||||
|
env:
|
||||||
|
COMPOSER_NO_INTERACTION: "1"
|
||||||
|
COMPOSER_HOME: .composer
|
||||||
|
DEPLOY_PATH: /var/www/livetrail
|
||||||
|
npm_config_cache: .npm-cache
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check runner tools
|
||||||
|
run: |
|
||||||
|
command -v composer
|
||||||
|
command -v npm
|
||||||
|
command -v rsync
|
||||||
|
|
||||||
|
- name: Check deploy path
|
||||||
|
run: |
|
||||||
|
test -d "$DEPLOY_PATH"
|
||||||
|
test -w "$DEPLOY_PATH"
|
||||||
|
|
||||||
|
- name: Validate Composer configuration
|
||||||
|
run: composer validate --no-check-publish
|
||||||
|
|
||||||
|
- name: Install PHP dependencies
|
||||||
|
run: composer install --no-dev --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Prepare runtime missing mount points
|
||||||
|
run: mkdir -p files resources/geo
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
run: npm run prod
|
||||||
|
|
||||||
|
- name: Deploy to production
|
||||||
|
run: |
|
||||||
|
rsync -azc --no-times --delete \
|
||||||
|
--exclude "/.git/" \
|
||||||
|
--exclude "/.gitea/" \
|
||||||
|
--exclude "/.composer/" \
|
||||||
|
--exclude "/.npm-cache/" \
|
||||||
|
--exclude "/node_modules/" \
|
||||||
|
--exclude "/config/settings.php" \
|
||||||
|
--exclude "/log.html" \
|
||||||
|
--exclude "/files/" \
|
||||||
|
--exclude "/resources/geo/*.geojson" \
|
||||||
|
./ "$DEPLOY_PATH/"
|
||||||
+17
-5
@@ -1,7 +1,19 @@
|
|||||||
/vendor/
|
# App config files
|
||||||
/config/settings.php
|
/config/settings.php
|
||||||
/files/
|
|
||||||
/geo/
|
|
||||||
/node_modules/
|
|
||||||
/log.html
|
/log.html
|
||||||
/dist/
|
|
||||||
|
# Upload folders
|
||||||
|
/files/
|
||||||
|
/resources/geo/*.geojson
|
||||||
|
|
||||||
|
# Build folder
|
||||||
|
/public/*
|
||||||
|
!/public/index.php
|
||||||
|
|
||||||
|
# Dependencies files
|
||||||
|
/vendor/
|
||||||
|
/node_modules/
|
||||||
|
/composer.dev.lock
|
||||||
|
|
||||||
|
# Lint caches
|
||||||
|
/.php-cs-fixer.cache
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PHP-CS-Fixer config codifying the style already in use under lib/ and
|
||||||
|
* public/. Deliberately NOT based on @PSR2/@PSR12 - this codebase diverges
|
||||||
|
* from those on purpose (tabs, no space before control-structure parens),
|
||||||
|
* so pulling in a preset would rewrite most of the codebase to match a
|
||||||
|
* style nobody uses here. Rules below were derived by sampling lib/*.php,
|
||||||
|
* not from a style guide.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$finder = (new PhpCsFixer\Finder())
|
||||||
|
->in([__DIR__.'/lib', __DIR__.'/public'])
|
||||||
|
->append([__DIR__.'/config/settings-sample.php'])
|
||||||
|
->name('*.php');
|
||||||
|
|
||||||
|
return (new PhpCsFixer\Config())
|
||||||
|
->setIndent("\t")
|
||||||
|
->setLineEnding("\n")
|
||||||
|
->setRules([
|
||||||
|
//Strings: single quotes except where interpolation needs double
|
||||||
|
'single_quote' => true,
|
||||||
|
|
||||||
|
//Arrays: short [] syntax, not long-form array()
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
|
||||||
|
//Braces: same line as class/function signature (dominant in lib/,
|
||||||
|
//not the PSR-2 next-line-for-class convention)
|
||||||
|
'braces_position' => [
|
||||||
|
'classes_opening_brace' => 'same_line',
|
||||||
|
'functions_opening_brace' => 'same_line',
|
||||||
|
'anonymous_functions_opening_brace' => 'same_line'
|
||||||
|
],
|
||||||
|
|
||||||
|
//Concatenation: no padding around `.`
|
||||||
|
'concat_space' => ['spacing' => 'none'],
|
||||||
|
|
||||||
|
//true/false/null: lowercase (100% consistent already)
|
||||||
|
'constant_case' => ['case' => 'lower'],
|
||||||
|
'lowercase_keywords' => true,
|
||||||
|
|
||||||
|
'visibility_required' => ['elements' => ['method', 'property', 'const']],
|
||||||
|
|
||||||
|
//Housekeeping - safe regardless of style
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
'no_trailing_whitespace' => true,
|
||||||
|
'no_trailing_whitespace_in_comment' => true,
|
||||||
|
'single_blank_line_at_eof' => true,
|
||||||
|
'no_empty_statement' => true,
|
||||||
|
'trim_array_spaces' => true,
|
||||||
|
'new_with_parentheses' => true
|
||||||
|
])
|
||||||
|
->setFinder($finder);
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
const path = require('path')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
SRC: path.resolve(__dirname, '..', 'src'),
|
|
||||||
DIST: path.resolve(__dirname, '..', 'dist'),
|
|
||||||
ASSETS: path.resolve(__dirname, '..', 'assets'),
|
|
||||||
IMAGES: path.resolve(__dirname, '..', 'src/images'),
|
|
||||||
STYLES: path.resolve(__dirname, '..', 'src/styles'),
|
|
||||||
LIB: path.resolve(__dirname, '..', 'lib'),
|
|
||||||
MASKS: path.resolve(__dirname, '..', 'src/masks'),
|
|
||||||
ROOT: path.resolve(__dirname, '..')
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const { SRC, DIST, ASSETS, LIB } = require('./paths');
|
|
||||||
var webpack = require("webpack");
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
||||||
const SymlinkWebpackPlugin = require('symlink-webpack-plugin');
|
|
||||||
const { VueLoaderPlugin } = require('vue-loader')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: {
|
|
||||||
app: path.resolve(SRC, 'scripts', 'app.js')
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: DIST,
|
|
||||||
filename: '[name].js',
|
|
||||||
publicPath: './' //meaning dist/
|
|
||||||
},
|
|
||||||
devtool: "inline-source-map",
|
|
||||||
module: {
|
|
||||||
rules: [{
|
|
||||||
test: /\.vue$/,
|
|
||||||
loader: 'vue-loader'
|
|
||||||
}, {
|
|
||||||
test: /\.js$/,
|
|
||||||
exclude: file => (/node_modules/.test(file) && !/\.vue\.js/.test(file)),
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['@babel/preset-env'],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
test: /\.html$/i,
|
|
||||||
loader: "html-loader",
|
|
||||||
}, {
|
|
||||||
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
||||||
type: 'asset/resource'
|
|
||||||
}, {
|
|
||||||
test: /\.s[ac]ss$/i,
|
|
||||||
use: [
|
|
||||||
'vue-style-loader',
|
|
||||||
'css-loader',
|
|
||||||
'resolve-url-loader',
|
|
||||||
{
|
|
||||||
loader: 'sass-loader',
|
|
||||||
options: {
|
|
||||||
implementation: require.resolve('sass'),
|
|
||||||
sourceMap: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}, {
|
|
||||||
test: /\.css$/i,
|
|
||||||
use: ["vue-style-loader", "css-loader"],
|
|
||||||
}, {
|
|
||||||
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
||||||
use: {
|
|
||||||
loader: "url-loader",
|
|
||||||
options: {
|
|
||||||
limit: 1 * 1024,
|
|
||||||
//name: "images/[name].[hash:7].[ext]"
|
|
||||||
name: "images/[name].[ext]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*type: 'asset',
|
|
||||||
parser: {
|
|
||||||
dataUrlCondition: {
|
|
||||||
maxSize: 8*1024
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.ProvidePlugin({
|
|
||||||
$: require.resolve('jquery'),
|
|
||||||
jQuery: require.resolve('jquery'),
|
|
||||||
//L: require.resolve('leaflet')
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [{
|
|
||||||
from: 'geo/',
|
|
||||||
to: path.resolve(DIST, 'geo')
|
|
||||||
}, {
|
|
||||||
from: path.resolve(LIB, 'index.php'),
|
|
||||||
to: 'index.php'
|
|
||||||
}, {
|
|
||||||
from: path.resolve(SRC, 'images/icons'),
|
|
||||||
to: 'images/icons'
|
|
||||||
}]
|
|
||||||
}),
|
|
||||||
new SymlinkWebpackPlugin({ origin: '../files/', symlink: 'files' }),
|
|
||||||
new CleanWebpackPlugin(),
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
__VUE_OPTIONS_API__: 'true',
|
|
||||||
__VUE_PROD_DEVTOOLS__: 'false'
|
|
||||||
}),
|
|
||||||
new VueLoaderPlugin()
|
|
||||||
],
|
|
||||||
resolve: {
|
|
||||||
extensions: ['', '.js'],
|
|
||||||
alias: {
|
|
||||||
"@scripts": path.resolve(SRC, "scripts"),
|
|
||||||
'load-image': 'blueimp-load-image/js/load-image.js',
|
|
||||||
'load-image-meta': 'blueimp-load-image/js/load-image-meta.js',
|
|
||||||
'load-image-exif': 'blueimp-load-image/js/load-image-exif.js',
|
|
||||||
'canvas-to-blob': 'blueimp-canvas-to-blob/js/canvas-to-blob.js',
|
|
||||||
'jquery-ui/ui/widget': 'blueimp-file-upload/js/vendor/jquery.ui.widget.js'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
const { merge } = require('webpack-merge')
|
|
||||||
|
|
||||||
module.exports = merge(require('./webpack.common.js'), {
|
|
||||||
mode: 'development',
|
|
||||||
watch: true
|
|
||||||
})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
const { merge } = require('webpack-merge')
|
|
||||||
|
|
||||||
module.exports = merge(require('./webpack.common.js'), {
|
|
||||||
mode: 'production'
|
|
||||||
})
|
|
||||||
Regular → Executable
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
wget -qO- https://spot.lutran.fr/index.php?a=update_project > /dev/null
|
cd "$(dirname "$0")/../public" || exit 1 #Execute from public folder
|
||||||
|
php -f index.php a=update_project > /dev/null
|
||||||
|
|
||||||
#Crontab job: 0 * * * * . /var/www/spot/spot_cron.sh > /dev/null
|
#Crontab job: 0 * * * * /path/to/livetrail/cli/cron.sh > /dev/null
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "franzz/livetrail",
|
||||||
|
"description": "LiveTrail",
|
||||||
|
"type": "project",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"url": "../objects",
|
||||||
|
"options": {
|
||||||
|
"symlink": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.5",
|
||||||
|
"franzz/objects": "dev-vue",
|
||||||
|
"phpmailer/phpmailer": "^7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.75"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Franzz\\Livetrail\\": "lib/",
|
||||||
|
"Franzz\\Objects\\": "../objects/inc/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/settings.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "php-cs-fixer fix --dry-run --diff",
|
||||||
|
"lint-fix": "php-cs-fixer fix"
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-6
@@ -1,23 +1,32 @@
|
|||||||
{
|
{
|
||||||
"name": "franzz/spot",
|
"name": "franzz/livetrail",
|
||||||
"description": "Spotty",
|
"description": "LiveTrail",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "git",
|
||||||
"url": "../objects"
|
"url": "https://git.lutran.fr/franzz/objects"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": ">=8.5",
|
||||||
"franzz/objects": "dev-vue",
|
"franzz/objects": "dev-vue",
|
||||||
"phpmailer/phpmailer": "^6.5"
|
"phpmailer/phpmailer": "^7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.75"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Franzz\\Spot\\": "lib/"
|
"Franzz\\Livetrail\\": "lib/"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"config/settings.php"
|
"config/settings.php"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "php-cs-fixer fix --dry-run --diff",
|
||||||
|
"lint-fix": "php-cs-fixer fix"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2860
-21
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName localhost
|
||||||
|
ServerAlias maui.local
|
||||||
|
DocumentRoot /var/www/html/
|
||||||
|
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteCond %{HTTPS} off
|
||||||
|
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [END,NE,R=permanent]
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
<IfModule mod_ssl.c>
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName localhost
|
||||||
|
ServerAlias maui.local
|
||||||
|
DocumentRoot /var/www/html/
|
||||||
|
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/mushu.nest.lutran.ch/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/mushu.nest.lutran.ch/privkey.pem
|
||||||
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
|
|
||||||
|
DirectoryIndex index.php
|
||||||
|
|
||||||
|
# Serve https://localhost/livetrail/ from the public web root.
|
||||||
|
Alias /livetrail /var/www/html/livetrail/public
|
||||||
|
|
||||||
|
<Directory /var/www/html/livetrail/public>
|
||||||
|
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>
|
||||||
|
</IfModule>
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
CREATE TABLE `maps` (
|
|
||||||
`id_map` int(10) UNSIGNED auto_increment,
|
|
||||||
`codename` VARCHAR(100),
|
|
||||||
`geo_name` VARCHAR(100),
|
|
||||||
`min_zoom` TINYINT UNSIGNED,
|
|
||||||
`max_zoom` TINYINT UNSIGNED,
|
|
||||||
`attribution` VARCHAR(100),
|
|
||||||
`led` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id_map`));
|
|
||||||
|
|
||||||
CREATE TABLE `mappings` (
|
|
||||||
`id_mapping` int(10) UNSIGNED auto_increment,
|
|
||||||
`id_map` int(10) UNSIGNED,
|
|
||||||
`id_project` int(10) UNSIGNED,
|
|
||||||
`led` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id_mapping`));
|
|
||||||
|
|
||||||
ALTER TABLE mappings ADD INDEX(`id_map`);
|
|
||||||
ALTER TABLE mappings ADD FOREIGN KEY (`id_map`) REFERENCES maps(`id_map`);
|
|
||||||
ALTER TABLE mappings ADD INDEX(`id_project`);
|
|
||||||
ALTER TABLE mappings ADD FOREIGN KEY (`id_project`) REFERENCES projects(`id_project`);
|
|
||||||
|
|
||||||
INSERT INTO maps(codename, geo_name, min_zoom, max_zoom, attribution) VALUES
|
|
||||||
/*1*/('satellite', 'mapbox.satellite-streets', 0, 19, ''),
|
|
||||||
/*2*/('otm', 'opentopomap', 2, 19, ''),
|
|
||||||
/*3*/('ign_france', 'ign.fr', 2, 19, ''),
|
|
||||||
/*4*/('ign_spain', 'ign.es', 1, 20, ''),
|
|
||||||
/*5*/('linz', 'linz', 0, 17, 'Sourced from LINZ. CC BY 4.0'),
|
|
||||||
/*6*/('usgs', 'usgs', 1, 16, ''),
|
|
||||||
/*7*/('natgeo', 'natgeo.pct', 5, 14, '');
|
|
||||||
|
|
||||||
INSERT INTO mappings(id_map, id_project) VALUES
|
|
||||||
(1, NULL),
|
|
||||||
(2, NULL),
|
|
||||||
(3, 2),
|
|
||||||
(4, 2),
|
|
||||||
(5, 1),
|
|
||||||
(6, 3);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ALTER TABLE users ADD gravatar LONGTEXT AFTER email;
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
ALTER TABLE medias ADD timezone CHAR(64) AFTER posted_on;
|
|
||||||
ALTER TABLE messages ADD timezone CHAR(64) AFTER site_time;
|
|
||||||
ALTER TABLE posts ADD timezone CHAR(64) AFTER site_time;
|
|
||||||
|
|
||||||
UPDATE messages
|
|
||||||
SET iso_time = DATE_FORMAT(CONVERT_TZ(LEFT(iso_time, 19),'+00:00','+02:00'), '%Y-%m-%dT%T+0200'),
|
|
||||||
led = led
|
|
||||||
WHERE id_feed = 2;
|
|
||||||
|
|
||||||
UPDATE messages
|
|
||||||
INNER JOIN feeds ON feeds.id_feed = messages.id_feed
|
|
||||||
INNER JOIN projects ON projects.id_project = feeds.id_project
|
|
||||||
SET messages.timezone = projects.timezone,
|
|
||||||
messages.led = messages.led;
|
|
||||||
|
|
||||||
UPDATE posts
|
|
||||||
SET timezone = 'Europe/Paris',
|
|
||||||
led = led;
|
|
||||||
|
|
||||||
UPDATE posts
|
|
||||||
INNER JOIN projects ON projects.id_project = posts.id_project
|
|
||||||
SET posts.id_user = 1,
|
|
||||||
posts.timezone = projects.timezone,
|
|
||||||
posts.led = posts.led
|
|
||||||
WHERE posts.name IN ('francois', 'françois','Francois', 'François', 'franzz');
|
|
||||||
|
|
||||||
UPDATE posts
|
|
||||||
SET timezone = 'Pacific/Auckland',
|
|
||||||
led = led
|
|
||||||
WHERE name = 'nz';
|
|
||||||
|
|
||||||
UPDATE posts
|
|
||||||
SET timezone = 'Atlantic/Madeira',
|
|
||||||
led = led
|
|
||||||
WHERE id_post IN (141, 142);
|
|
||||||
|
|
||||||
UPDATE medias
|
|
||||||
INNER JOIN projects ON projects.id_project = medias.id_project
|
|
||||||
SET medias.timezone = projects.timezone,
|
|
||||||
medias.led = medias.led;
|
|
||||||
|
|
||||||
UPDATE medias
|
|
||||||
SET timezone = 'Atlantic/Madeira',
|
|
||||||
taken_on = posted_on,
|
|
||||||
led = led
|
|
||||||
WHERE id_media IN (64, 65);
|
|
||||||
|
|
||||||
ALTER TABLE projects DROP COLUMN timezone;
|
|
||||||
|
|
||||||
UPDATE maps SET attribution = 'OpenTopoMap (CC-BY-SA)' WHERE id_map = 2;
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
ALTER TABLE users ADD clearance TINYINT(1) DEFAULT 0 AFTER active;
|
|
||||||
UPDATE users SET clearance = 9 WHERE email = 'francois.lutran@gmail.com';
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
ALTER TABLE messages ADD posted_on TIMESTAMP DEFAULT 0 AFTER battery_state;
|
|
||||||
UPDATE messages SET posted_on = led, led = led;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
ALTER TABLE messages ADD weather_icon VARCHAR(30) AFTER posted_on;
|
|
||||||
ALTER TABLE messages ADD weather_cond VARCHAR(30) AFTER weather_icon;
|
|
||||||
ALTER TABLE messages ADD weather_temp DECIMAL(3,1) AFTER weather_cond;
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
INSERT INTO maps (codename, geo_name, min_zoom, max_zoom, attribution) VALUES ('outdoors', 'mapbox.outdoors', 0, 19, '');
|
|
||||||
ALTER TABLE maps ADD COLUMN tile_size SMALLINT UNSIGNED DEFAULT 256 AFTER geo_name;
|
|
||||||
UPDATE maps SET tile_size = 512 WHERE geo_name = 'mapbox.outdoors';
|
|
||||||
UPDATE maps SET tile_size = 512 WHERE geo_name = 'mapbox.satellite-streets';
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
ALTER TABLE maps ADD pattern VARCHAR(200) NOT NULL AFTER geo_name;
|
|
||||||
UPDATE maps SET pattern = CONCAT('http://localhost/geo/?a=tile&id=', geo_name, '&z={z}&x={x}&y={y}') WHERE geo_name <> '';
|
|
||||||
|
|
||||||
ALTER TABLE maps ADD token VARCHAR(4096) AFTER pattern;
|
|
||||||
UPDATE maps SET token = '';
|
|
||||||
|
|
||||||
ALTER TABLE maps DROP geo_name;
|
|
||||||
|
|
||||||
INSERT INTO maps (codename, pattern, token, tile_size, min_zoom, max_zoom, attribution)
|
|
||||||
VALUES ('static', 'http://localhost/geo/?a=tile&id=static&z=13&x={x}&y={y}', '', 400, 13, 13, '');
|
|
||||||
|
|
||||||
INSERT INTO maps (codename, pattern, token, tile_size, min_zoom, max_zoom, attribution)
|
|
||||||
VALUES ('static_marker', 'http://localhost/geo/?a=tile&id=static.marker&z=13&x={x}&y={y}&marker=http://localhost/spot/images/footprint_mapbox.png', '', 400, 13, 13, '');
|
|
||||||
|
|
||||||
UPDATE maps SET max_zoom = 17 WHERE codename = 'otm';
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
ALTER TABLE medias ADD width INT AFTER timezone;
|
|
||||||
ALTER TABLE medias ADD height INT AFTER width;
|
|
||||||
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (1).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (10).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (11).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (12).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (13).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (14).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (15).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (16).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (17).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (18).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (19).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (2).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (20).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (21).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (22).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (23).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (24).jpg';
|
|
||||||
UPDATE medias SET width = 640, height = 1136 WHERE filename = 'image (25).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (26).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (27).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (28).jpg';
|
|
||||||
UPDATE medias SET width = 960, height = 1280 WHERE filename = 'image (29).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (3).jpg';
|
|
||||||
UPDATE medias SET width = 960, height = 1280 WHERE filename = 'image (30).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (31).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (32).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (33).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (34).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (35).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (36).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (37).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (38).jpg';
|
|
||||||
UPDATE medias SET width = 2048, height = 1365 WHERE filename = 'image (39).jpg';
|
|
||||||
UPDATE medias SET width = 1280, height = 960 WHERE filename = 'image (4).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (40).jpg';
|
|
||||||
UPDATE medias SET width = 8192, height = 1856 WHERE filename = 'image (41).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (42).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (43).jpg';
|
|
||||||
UPDATE medias SET width = 8192, height = 1856 WHERE filename = 'image (44).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (45).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (46).jpg';
|
|
||||||
UPDATE medias SET width = 640, height = 1038 WHERE filename = 'image (47).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (48).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (49).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (5).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (50).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (51).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (52).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (53).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (54).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (55).jpg';
|
|
||||||
UPDATE medias SET width = 3648, height = 5472 WHERE filename = 'image (56).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (57).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (58).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (59).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (6).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (60).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (61).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (62).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'image (63).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'image (7).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (8).jpg';
|
|
||||||
UPDATE medias SET width = 2448, height = 3264 WHERE filename = 'image (9).jpg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'DSC01187[1].JPG';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'DSC01477.JPG';
|
|
||||||
UPDATE medias SET width = 2726, height = 4089 WHERE filename = 'DSC03114.jpg';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_6011.MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = '156E315D-88AD-492C-BE97-9854FED48FF7.MOV';
|
|
||||||
UPDATE medias SET width = 2576, height = 1932 WHERE filename = '4D06AAF9-A244-4AEF-A1B0-A3C439673840.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '06361CBA-F514-4789-A498-47D681881DDF.MOV';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'B0A15DCC-B5BB-4BE3-ADBA-CBCB51C178F6.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = 'F827F48B-5CC4-4DA7-A80B-FFED47F6EC60.MOV';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'EC407D2D-0ECF-46C7-BC05-73F48D152182.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '7961DA2D-288D-4B0B-B4A6-400673E23BA6.jpeg';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'B43B0160-DAB4-433A-9064-918C40744D27.MOV';
|
|
||||||
UPDATE medias SET width = 1536, height = 2134 WHERE filename = 'C0D5CCF6-FE72-424C-A040-96D8C34FBE9E.jpeg';
|
|
||||||
UPDATE medias SET width = 2154, height = 1850 WHERE filename = '0940EF97-4C27-4304-A663-654F0DE5FAB2.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '7597DEC0-1BD3-4B93-926B-E4D8A4B28E61.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '3A1F777D-58F6-40BA-8AAE-1EA236581BA3.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'C6AC86F9-C819-4866-AA71-A31375E4CCC4.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'B936E022-4D70-4C9E-9EAE-308FB6F91816.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'C777A1C7-7C3A-4ADC-8A5C-CEE8FB047B79.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'B76D8452-FCC4-4FCE-8686-2A4B8C7832FF.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '313F8490-E885-42F5-BB59-ACFB12250F0F.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'F0C1EFDB-0A4F-4FC0-A46D-A396D8724054.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'E9339EEF-A21C-48A6-B6CC-23C3A512DA29.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '5150FFEF-A715-4F5A-8562-1502BE778B6A.MOV';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'C8CD8B78-3EC9-4700-9A46-478556496239.jpeg';
|
|
||||||
UPDATE medias SET width = 1536, height = 2048 WHERE filename = '3D83F7D3-B746-440F-8DD3-6DADF230AC28.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B9121A78-0B21-42E2-8392-A60BCE240EFE.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '5A3755D0-81CB-43B1-9750-AB34F413D526.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B9EFBC4F-4FC4-4D03-9722-9A1FF61F3B8E.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'F7C6FFFF-BF61-42BF-949B-72CD2CAAEFE2.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B0557309-579D-4C1A-863F-CF4898C42E77.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '2C75F8E9-C3E0-4FD5-AF2E-CE339545D6BC.jpeg';
|
|
||||||
UPDATE medias SET width = 3891, height = 2917 WHERE filename = 'C6E18BC2-B407-4F2C-82F9-87244A9AD311.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '0A4B5812-D5CD-4CB0-989B-C95D15526F1A.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '1548CCA0-C8C8-4DC6-BD96-ABAA4589E825.jpeg';
|
|
||||||
UPDATE medias SET width = 4685, height = 3116 WHERE filename = '7F80807F-D40F-4714-81AE-3CD7CD3FE8CD.jpeg';
|
|
||||||
UPDATE medias SET width = 5283, height = 3519 WHERE filename = '32F5B460-958D-4A13-92BD-371BBC0DA769.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'F99EEC87-C5CC-49AD-BCBF-8A14ADADD262.jpeg';
|
|
||||||
UPDATE medias SET width = 8192, height = 1856 WHERE filename = 'C243E61F-2A31-4179-97B4-AD54C02E88D5.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '85807A81-91CB-4B10-861B-1B3C5A60F066.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'DE99B389-738F-48CB-BEF1-D448DEB16E7E.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '6BBD7291-BDFC-460F-A620-9D2F68AF637F.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '7DB6662E-353A-4AC5-9331-D9122D956FE7.MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = '974841E5-AB13-4067-AD5F-3EDEFEAE28E4.MOV';
|
|
||||||
UPDATE medias SET width = 1536, height = 2304 WHERE filename = '09F007C7-53BA-4214-B3AF-DB0E0CDD1994.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '6B92D63D-EDA5-4787-8AC7-4A0F65DC071F.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'BAF3BB55-E012-40CD-8D8B-27C4398C1D00.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '8FA2F4F0-F220-4E98-9BC0-ACB607FC2F8E.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'C260B1AD-BA4C-4835-B132-A529A9319D4D.jpeg';
|
|
||||||
UPDATE medias SET width = 1536, height = 2304 WHERE filename = '92F8E35B-5FF8-414D-A627-46FF45E6CCCA.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '33AA17D3-CFD6-426A-B2D5-CD639F53C081.MOV';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '0015713D-18A2-45A7-B26F-3954AC0979D3.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '223A23C5-71BB-4419-8765-CE51F3E69480.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '9ED663DD-0257-4211-A993-C86CDAC9066B.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '1ECF5050-8821-441C-8DF7-E93B24941F8A.jpeg';
|
|
||||||
UPDATE medias SET width = 1536, height = 2304 WHERE filename = '68211D98-D6E7-4D7C-BB82-7E5E30884C7D.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '61747CFA-859E-4859-852F-3AE2650C7578.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'F17CD761-DFDC-4E5F-97A7-C16035A8D8EB.jpeg';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = '7EE0B25A-0BC6-4BF1-9CDF-9E4547CFEAF4.MOV';
|
|
||||||
UPDATE medias SET width = 3503, height = 2625 WHERE filename = '273092DD-F6CE-4C74-8878-A4D94A9C78F9.jpeg';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '4853B2CB-5BC4-45FE-AD02-0980953DB59A.MOV';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '789210A7-293D-4119-87EE-1B7CA0ACBE0A.jpeg';
|
|
||||||
UPDATE medias SET width = 2665, height = 1996 WHERE filename = '52D57195-22A2-423B-AA35-05D48B889950.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'F5644C0F-5244-4574-BBE1-4059794F87E1.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = '7BB3D57A-D5BE-45D5-8CAC-C3172A89C67A.jpeg';
|
|
||||||
UPDATE medias SET width = 2687, height = 2013 WHERE filename = '8345C480-1274-45DB-A990-40913DD219A7.jpeg';
|
|
||||||
UPDATE medias SET width = 4128, height = 3096 WHERE filename = '28567B3E-A067-41AE-AE69-37DD3C98F820.jpeg';
|
|
||||||
UPDATE medias SET width = 3096, height = 4128 WHERE filename = '20190827_133201_DxO.jpg';
|
|
||||||
UPDATE medias SET width = 3096, height = 4128 WHERE filename = '20190827_133201_DxO (1).jpg';
|
|
||||||
UPDATE medias SET width = 3096, height = 4128 WHERE filename = '20190827_133201_DxO (2).jpg';
|
|
||||||
UPDATE medias SET width = 3096, height = 4128 WHERE filename = '20190827_133201_DxO (3).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled.png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (1).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (2).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (3).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (4).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (5).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (6).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (7).png';
|
|
||||||
UPDATE medias SET width = 2000, height = 3000 WHERE filename = 'Untitled (8).png';
|
|
||||||
UPDATE medias SET width = 365, height = 600 WHERE filename = 'asunabg.png';
|
|
||||||
UPDATE medias SET width = 365, height = 600 WHERE filename = 'asunabg (1).png';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'iPhone 6S (1).jpeg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_2591.JPG';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'CF0432E7-5221-433D-A681-DBABE131EE99.jpeg';
|
|
||||||
UPDATE medias SET width = 694, height = 628 WHERE filename = 'Capture.PNG';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_2232 (1).jpg';
|
|
||||||
UPDATE medias SET width = 1350, height = 900 WHERE filename = 'Photo 2014-06-21 20-17-11 (_MG_1217).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (9).jpg';
|
|
||||||
UPDATE medias SET width = 1154, height = 770 WHERE filename = 'Photo 2014-06-21 20-17-11 (_MG_1217)_DxO (3).jpg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_2232 (2).jpg';
|
|
||||||
UPDATE medias SET width = 2320, height = 3088 WHERE filename = '9C0965E1-6A40-4691-8127-35B2F1D6BB58.jpeg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_3077.jpg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'AF7A1DBC-E1CC-4FEE-8411-AC25BF69C0B5.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'F7FC1246-6304-4662-A5F2-230A29728EBC.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'CA5BA9A6-2A53-430A-A0BF-B8D0C0CDC983.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '12E87114-6B4B-4051-945C-9042FBBF5E3E.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'F97B5058-C7D7-4B25-B727-914A8897CE58.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'D1E626E6-6F49-4F62-A3D5-B19CBC906F7B.jpeg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_1228_DxO.jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'IMG_1268_DxO.jpg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = 'IMG_2232.jpg';
|
|
||||||
UPDATE medias SET width = 2475, height = 2475 WHERE filename = 'IMG_2232_DxO (1).jpg';
|
|
||||||
UPDATE medias SET width = 2475, height = 2475 WHERE filename = 'IMG_2232_DxO.jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'IMG_2317.jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'IMG_2574 (1).jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'IMG_2574 (2).jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'IMG_2574.jpg';
|
|
||||||
UPDATE medias SET width = 1344, height = 672 WHERE filename = 'PHOTO-2019-12-24-23-40-26.jpg';
|
|
||||||
UPDATE medias SET width = 1512, height = 2688 WHERE filename = 'PXL_20210405_083835976.jpg';
|
|
||||||
UPDATE medias SET width = 3840, height = 2160 WHERE filename = 'PXL_20210405_091516836.jpg';
|
|
||||||
UPDATE medias SET width = 1350, height = 900 WHERE filename = 'Photo 2014-06-21 20-17-11 (_MG_1217)_DxO (1).jpg';
|
|
||||||
UPDATE medias SET width = 1350, height = 900 WHERE filename = 'Photo 2014-06-21 20-17-11 (_MG_1217)_DxO (2).jpg';
|
|
||||||
UPDATE medias SET width = 1350, height = 900 WHERE filename = 'Photo 2014-06-21 20-17-11 (_MG_1217)_DxO.jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (1).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (2).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (3).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (4).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (5).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (6).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (7).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945) (8).jpg';
|
|
||||||
UPDATE medias SET width = 2000, height = 1500 WHERE filename = 'Photo 2015-01-11 20-30-03 (P1020945).jpg';
|
|
||||||
UPDATE medias SET width = 1500, height = 2000 WHERE filename = 'Photo 2015-01-19 19-59-34 (P1040055).jpg';
|
|
||||||
UPDATE medias SET width = 3264, height = 2448 WHERE filename = 'TEST.jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'image (64).jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'image (65).jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'image.jpg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '083932A9-4248-4208-91CC-34DCDC374E7A.jpeg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = '102ED557-69B0-41F2-9193-DF52FEEFD35C.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '45289F93-5D82-40DE-A0B1-1871317C56C1.jpeg';
|
|
||||||
UPDATE medias SET width = 1200, height = 1600 WHERE filename = '5F97CB55-46C7-4BB7-9335-BBDFF77F1310.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '634716D8-D7E7-4128-B0D2-EEB4437411F3.jpeg';
|
|
||||||
UPDATE medias SET width = 3024, height = 4032 WHERE filename = '6C111386-591F-450D-9794-E812FB6FF036.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '6D718B33-020D-460A-9194-D637A2590ABC.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '866196A9-5428-4E6C-8C4A-03DB284A9448.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'A68E6383-095C-4CB2-876B-4EC59DB24419.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'APPLE (1).jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'APPLE.jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B9EFBC4F-4FC4-4D03-9722-9A1FF61F3B8E (1).jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B9EFBC4F-4FC4-4D03-9722-9A1FF61F3B8E (2).jpeg';
|
|
||||||
UPDATE medias SET width = 5472, height = 3648 WHERE filename = 'B9EFBC4F-4FC4-4D03-9722-9A1FF61F3B8E (3).jpeg';
|
|
||||||
UPDATE medias SET width = 1152, height = 1536 WHERE filename = 'BA37E256-C0B2-4DE6-B0E0-659EB2C3411B.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'D4009C41-7B4C-42D5-9FB4-9CEC7CC1B4B0.jpeg';
|
|
||||||
UPDATE medias SET width = 1200, height = 1600 WHERE filename = 'DDFADE5F-2785-4168-9EAB-D63818566929.jpeg';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = 'iPhone 6S.jpeg';
|
|
||||||
UPDATE medias SET width = 365, height = 600 WHERE filename = 'asunabg (2).png';
|
|
||||||
UPDATE medias SET width = 365, height = 600 WHERE filename = 'asunabg (3).png';
|
|
||||||
UPDATE medias SET width = 365, height = 600 WHERE filename = 'asunabg (4).png';
|
|
||||||
UPDATE medias SET width = 200, height = 120 WHERE filename = 'ffprobeall.png';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = 'temp_60a6954ea732b.png';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = 'temp_60a695501d507.png';
|
|
||||||
UPDATE medias SET width = 1080, height = 1920 WHERE filename = 'temp_60a695509009d.png';
|
|
||||||
UPDATE medias SET width = 1080, height = 1920 WHERE filename = 'temp_60a695520a9a0.png';
|
|
||||||
UPDATE medias SET width = 1080, height = 1920 WHERE filename = 'temp_60a695535d689.png';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '7DB6662E-353A-4AC5-9331-D9122D956FE7 (1).MOV';
|
|
||||||
UPDATE medias SET width = 1280, height = 720 WHERE filename = '7DB6662E-353A-4AC5-9331-D9122D956FE7 (2).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2584 (1).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2584.MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585 (1).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585 (2).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585 (3).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585 (4).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585 (5).MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'IMG_2585.MOV';
|
|
||||||
UPDATE medias SET width = 1920, height = 1080 WHERE filename = 'iPhone 6S.MOV';
|
|
||||||
UPDATE medias SET width = 4032, height = 3024 WHERE filename = '1620E5B9-C65D-4252-A495-18D5CAD63C6E.jpeg';
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
ALTER TABLE messages MODIFY ref_msg_id VARCHAR(15) NOT NULL;
|
|
||||||
ALTER TABLE messages ADD display BOOLEAN DEFAULT 1 AFTER weather_temp;
|
|
||||||
|
|
||||||
UPDATE messages SET display = 0 WHERE id_message = 197;
|
|
||||||
UPDATE messages SET display = 0 WHERE id_message = 216;
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
CREATE TABLE `projects` (
|
|
||||||
`id_project` int(10) UNSIGNED auto_increment,
|
|
||||||
`codename` VARCHAR(100),
|
|
||||||
`name` VARCHAR(100),
|
|
||||||
`active_from` DATETIME,
|
|
||||||
`active_to` DATETIME,
|
|
||||||
`geofile` VARCHAR(50),
|
|
||||||
`timezone` VARCHAR(100),
|
|
||||||
`led` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id_project`));
|
|
||||||
|
|
||||||
INSERT INTO projects (name, codename, active_from, active_to, geofile, timezone) VALUES ('Te Araroa', 'te_araroa', '2015-12-29 00:00:00', '2016-03-05 23:59:59', 'te_araroa.geojson', 'Pacific/Auckland');
|
|
||||||
INSERT INTO projects (name, codename, active_from, active_to, geofile, timezone) VALUES ('HRP', 'hrp', '2019-06-01 00:00:00', '2019-09-10 23:59:59', 'hrp.geojson', 'Europe/Paris');
|
|
||||||
|
|
||||||
ALTER TABLE feeds ADD COLUMN id_project int(10) UNSIGNED AFTER id_spot;
|
|
||||||
ALTER TABLE feeds ADD last_update DATETIME AFTER status;
|
|
||||||
ALTER TABLE feeds ADD FOREIGN KEY (`id_project`) REFERENCES projects(`id_project`);
|
|
||||||
UPDATE feeds SET last_update = led;
|
|
||||||
UPDATE feeds SET id_project = 1;
|
|
||||||
|
|
||||||
ALTER TABLE posts ADD COLUMN id_project int(10) UNSIGNED AFTER id_post;
|
|
||||||
ALTER TABLE posts ADD timestamp DATETIME AFTER content;
|
|
||||||
ALTER TABLE posts ADD FOREIGN KEY (`id_project`) REFERENCES projects(`id_project`);
|
|
||||||
UPDATE posts SET timestamp = led;
|
|
||||||
UPDATE posts SET id_project = 1;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
ALTER TABLE medias ADD latitude DECIMAL(7,5) AFTER timezone;
|
|
||||||
ALTER TABLE medias ADD longitude DECIMAL(8,5) AFTER latitude;
|
|
||||||
ALTER TABLE medias ADD altitude SMALLINT AFTER longitude;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
CREATE TABLE `pictures` (
|
|
||||||
`id_picture` int(10) UNSIGNED auto_increment,
|
|
||||||
`id_project` int(10) UNSIGNED,
|
|
||||||
`filename` VARCHAR(100) NOT NULL,
|
|
||||||
`taken_on` DATETIME,
|
|
||||||
`timestamp` DATETIME,
|
|
||||||
`rotate` SMALLINT,
|
|
||||||
`led` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id_picture`),
|
|
||||||
UNIQUE KEY `uni_file_name` (`filename`)
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE pictures ADD INDEX(`id_project`);
|
|
||||||
ALTER TABLE pictures ADD FOREIGN KEY (`id_project`) REFERENCES projects(`id_project`);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
ALTER TABLE messages ADD iso_time VARCHAR(24) AFTER longitude;
|
|
||||||
ALTER TABLE messages CHANGE COLUMN timestamp site_time TIMESTAMP DEFAULT 0;
|
|
||||||
ALTER TABLE messages CHANGE COLUMN unix_timestamp unix_time INT;
|
|
||||||
UPDATE messages SET iso_time = CONCAT(REPLACE(CONVERT_TZ(FROM_UNIXTIME(unix_time), @@session.time_zone, 'Pacific/Auckland'), ' ', 'T'), '+1200') WHERE id_feed = 1;
|
|
||||||
|
|
||||||
ALTER TABLE feeds MODIFY last_update TIMESTAMP DEFAULT 0;
|
|
||||||
|
|
||||||
ALTER TABLE projects MODIFY active_from TIMESTAMP DEFAULT 0;
|
|
||||||
ALTER TABLE projects MODIFY active_to TIMESTAMP DEFAULT 0;
|
|
||||||
|
|
||||||
ALTER TABLE posts CHANGE COLUMN timestamp site_time TIMESTAMP DEFAULT 0;
|
|
||||||
|
|
||||||
ALTER TABLE pictures CHANGE COLUMN timestamp posted_on TIMESTAMP DEFAULT 0;
|
|
||||||
UPDATE pictures INNER JOIN projects USING(id_project) SET taken_on = CONVERT_TZ(taken_on, projects.timezone, @@session.time_zone) where id_project = 1;
|
|
||||||
ALTER TABLE pictures MODIFY taken_on TIMESTAMP DEFAULT 0;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
UPDATE projects SET geofile = REPLACE(geofile, '.geojson', '');
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
RENAME TABLE pictures TO medias;
|
|
||||||
ALTER TABLE medias CHANGE COLUMN id_picture id_media INT(10) UNSIGNED NOT NULL auto_increment;
|
|
||||||
ALTER TABLE medias ADD COLUMN type VARCHAR(20) AFTER filename;
|
|
||||||
UPDATE medias SET type = 'image';
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/* Remove NO_ZERO_DATE mode, checks mode with: SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE; and: SET @@SQL_MODE = REPLACE(@@SQL_MODE, 'NO_ZERO_DATE', ''); */
|
|
||||||
ALTER TABLE medias ADD comment LONGTEXT AFTER rotate;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ALTER TABLE projects DROP COLUMN geofile;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
CREATE TABLE `users` (
|
|
||||||
`id_user` int(10) UNSIGNED auto_increment,
|
|
||||||
`name` VARCHAR(100),
|
|
||||||
`email` VARCHAR(320),
|
|
||||||
`language` VARCHAR(2),
|
|
||||||
`active` BOOLEAN,
|
|
||||||
`led` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id_user`),
|
|
||||||
UNIQUE KEY `uni_email` (`email`)
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE posts ADD COLUMN id_user int(10) UNSIGNED AFTER id_project;
|
|
||||||
ALTER TABLE posts ADD INDEX(`id_user`);
|
|
||||||
ALTER TABLE posts ADD FOREIGN KEY (`id_user`) REFERENCES users(`id_user`);
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
ALTER TABLE users ADD COLUMN timezone char(64) AFTER language;
|
|
||||||
ALTER TABLE users MODIFY COLUMN email VARCHAR(320) NOT NULL;
|
|
||||||
UPDATE users SET timezone = 'Europe/Paris';
|
|
||||||
|
|
||||||
ALTER TABLE projects MODIFY COLUMN timezone char(64);
|
|
||||||
Executable → Regular
+16
-17
@@ -1,20 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Settings
|
class Settings {
|
||||||
{
|
public const DB_SERVER = 'localhost';
|
||||||
const DB_SERVER = 'localhost';
|
public const DB_LOGIN = '';
|
||||||
const DB_LOGIN = '';
|
public const DB_PASS = '';
|
||||||
const DB_PASS = '';
|
public const DB_NAME = 'livetrail';
|
||||||
const DB_NAME = 'spot';
|
public const DB_ENC = 'utf8mb4';
|
||||||
const DB_ENC = 'utf8mb4';
|
public const TEXT_ENC = 'UTF-8';
|
||||||
const TEXT_ENC = 'UTF-8';
|
public const TIMEZONE = 'Europe/Zurich';
|
||||||
const TIMEZONE = 'Europe/Paris';
|
public const MAIL_SERVER = '';
|
||||||
const MAIL_SERVER = '';
|
public const MAIL_FROM = '';
|
||||||
const MAIL_FROM = '';
|
public const MAIL_USER = '';
|
||||||
const MAIL_USER = '';
|
public const MAIL_PASS = '';
|
||||||
const MAIL_PASS = '';
|
public const WEATHER_TOKEN = ''; //visualcrossing.com
|
||||||
const WEATHER_TOKEN = ''; //visualcrossing.com
|
public const TIMEZONE_USER = ''; //geonames.org
|
||||||
const TIMEZONE_USER = ''; //geonames.org
|
public const DEBUG = true;
|
||||||
const DEBUG = true;
|
public const LOG_FOLDER = __DIR__;
|
||||||
const LOG_FOLDER = __DIR__;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// ESLint flat config codifying the style already in use across src/.
|
||||||
|
// Goal: catch real mistakes and enforce the existing conventions, not impose
|
||||||
|
// an external style guide. Rules were derived by sampling src/scripts/*.js
|
||||||
|
// and src/components/*.vue, not from a template.
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import vue from 'eslint-plugin-vue';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
js.configs.recommended,
|
||||||
|
...vue.configs['flat/essential'],
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
sourceType: 'module',
|
||||||
|
globals: {
|
||||||
|
...globals.browser
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
//Indentation: tabs everywhere, one indent per level
|
||||||
|
'indent': 'off', //too many false positives on Vue template attr wrapping; keep manual
|
||||||
|
'no-tabs': 'off',
|
||||||
|
|
||||||
|
//Strings: single quotes (project uses single-quoted strings exclusively)
|
||||||
|
'quotes': ['warn', 'single', {avoidEscape: true, allowTemplateLiterals: true}],
|
||||||
|
|
||||||
|
//Semicolons: required almost everywhere. The one consistent
|
||||||
|
//exception is the top-level `export default {...}` in Vue SFCs,
|
||||||
|
//which never gets a trailing semicolon - ESLint's `semi` rule
|
||||||
|
//can't carve that one spot out, so this is 'warn' rather than
|
||||||
|
//'error' to avoid flagging every component's SFC boilerplate
|
||||||
|
//as a hard failure.
|
||||||
|
'semi': ['warn', 'always'],
|
||||||
|
|
||||||
|
//Equality: codebase mixes == and === deliberately (e.g. loose checks
|
||||||
|
//against numeric strings from the API) - don't force either
|
||||||
|
'eqeqeq': 'off',
|
||||||
|
|
||||||
|
//Function parens: no space before the parameter list - `function(x)`, not `function (x)`
|
||||||
|
'space-before-function-paren': ['warn', 'never'],
|
||||||
|
|
||||||
|
//Control structures: no space before the parenthesis -
|
||||||
|
//`if(x)`, `for(...)`, `switch(x)`, not `if (x)` etc.
|
||||||
|
//(100% consistent across src/ - checked via grep before writing this)
|
||||||
|
'keyword-spacing': ['warn', {
|
||||||
|
after: true,
|
||||||
|
overrides: {
|
||||||
|
if: {after: false},
|
||||||
|
for: {after: false},
|
||||||
|
while: {after: false},
|
||||||
|
switch: {after: false},
|
||||||
|
catch: {after: false}
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
'space-before-blocks': ['warn', 'always'],
|
||||||
|
|
||||||
|
//Object-curly-spacing is deliberately NOT configured: the codebase
|
||||||
|
//consistently uses `{a, b}` (no padding) for object literals and
|
||||||
|
//destructuring, but `import { x } from 'y'` (padded) for imports -
|
||||||
|
//and this rule can't apply different spacing to those two node
|
||||||
|
//kinds, so enforcing either would misfire on the other.
|
||||||
|
'object-curly-spacing': 'off',
|
||||||
|
'array-bracket-spacing': ['warn', 'never'],
|
||||||
|
|
||||||
|
//Prefix convention (Hungarian-ish: sString, iInt, aArray, oObject, bBool)
|
||||||
|
//is a project-wide naming discipline, not something ESLint can check;
|
||||||
|
//left undocumented here on purpose.
|
||||||
|
|
||||||
|
//Real-bug catchers - keep these strict regardless of style
|
||||||
|
//ignoreRestSiblings covers the `const {prev, ...rest} = obj` idiom
|
||||||
|
//(destructuring a key out just to exclude it from the rest), used
|
||||||
|
//in App.vue - that `prev` binding is intentionally unused.
|
||||||
|
'no-unused-vars': ['warn', {argsIgnorePattern: '^_', ignoreRestSiblings: true}],
|
||||||
|
'no-undef': 'error',
|
||||||
|
'no-var': 'warn', //codebase is ES module/class based; var only appears in one legacy fallback block
|
||||||
|
'prefer-const': 'off', //not consistently followed, don't force churn
|
||||||
|
|
||||||
|
//Vue-specific: components are registered and used with camelCase
|
||||||
|
//tags in templates (<appIcon>, <projectMapLink>). ESLint's
|
||||||
|
//component-name-in-template-casing rule only supports PascalCase
|
||||||
|
//or kebab-case, neither of which matches, so it's left off here
|
||||||
|
//rather than forced into a casing the codebase doesn't use.
|
||||||
|
'vue/component-name-in-template-casing': 'off',
|
||||||
|
'vue/multi-word-component-names': 'off', //AppIcon, Admin, Project etc. mix single/multi-word by design
|
||||||
|
'vue/attribute-hyphenation': 'off', //existing templates mix camelCase and kebab-case attrs; not consistent enough to enforce yet
|
||||||
|
'vue/require-default-prop': 'off',
|
||||||
|
'vue/no-v-html': 'error' //codebase currently has zero v-html usage - keep it that way
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ignores: ['public/**', 'vendor/**', 'node_modules/**']
|
||||||
|
}
|
||||||
|
];
|
||||||
-265
File diff suppressed because one or more lines are too long
-782
@@ -1,782 +0,0 @@
|
|||||||
// ==UserScript==
|
|
||||||
// @name GaiaGps Uploader
|
|
||||||
// @namespace https://greasyfork.org/users/583371
|
|
||||||
// @description Allow the user to upload multiple files at once and more than 1000 waypoints
|
|
||||||
// @grant none
|
|
||||||
// @version 3.1.2
|
|
||||||
// @author Franzz
|
|
||||||
// @license GNU GPLv3
|
|
||||||
// @match https://www.gaiagps.com/map/*
|
|
||||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
|
|
||||||
// ==/UserScript==
|
|
||||||
|
|
||||||
/* jshint esversion: 6 */
|
|
||||||
|
|
||||||
//Ctrl+Alt+Shift+I to open network tab on addon
|
|
||||||
|
|
||||||
/* GPXParser - v3.0.8 - https://github.com/Luuka/GPXParser.js/blob/master/src/GPXParser.js */
|
|
||||||
/* Personnal modifications have been applied, care on upgrade */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GPX file parser
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
let gpxParser = function () {
|
|
||||||
this.xmlSource = "";
|
|
||||||
this.metadata = {};
|
|
||||||
this.waypoints = [];
|
|
||||||
this.tracks = [];
|
|
||||||
this.routes = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a gpx formatted string to a GPXParser Object
|
|
||||||
*
|
|
||||||
* @param {string} gpxstring - A GPX formatted String
|
|
||||||
*
|
|
||||||
* @return {gpxParser} A GPXParser object
|
|
||||||
*/
|
|
||||||
gpxParser.prototype.parse = function (gpxstring) {
|
|
||||||
let keepThis = this;
|
|
||||||
|
|
||||||
let domParser = new window.DOMParser();
|
|
||||||
this.xmlSource = domParser.parseFromString(gpxstring, 'text/xml');
|
|
||||||
|
|
||||||
let metadata = this.xmlSource.querySelector('metadata');
|
|
||||||
if(metadata != null){
|
|
||||||
this.metadata.name = this.getElementValue(metadata, "name");
|
|
||||||
this.metadata.desc = this.getElementValue(metadata, "desc");
|
|
||||||
this.metadata.time = this.getElementValue(metadata, "time");
|
|
||||||
|
|
||||||
let author = {};
|
|
||||||
let authorElem = metadata.querySelector('author');
|
|
||||||
if(authorElem != null){
|
|
||||||
author.name = this.getElementValue(authorElem, "name");
|
|
||||||
author.email = {};
|
|
||||||
let emailElem = authorElem.querySelector('email');
|
|
||||||
if(emailElem != null){
|
|
||||||
author.email.id = emailElem.getAttribute("id");
|
|
||||||
author.email.domain = emailElem.getAttribute("domain");
|
|
||||||
}
|
|
||||||
|
|
||||||
let link = {};
|
|
||||||
let linkElem = authorElem.querySelector('link');
|
|
||||||
if(linkElem != null){
|
|
||||||
link.href = linkElem.getAttribute('href');
|
|
||||||
link.text = this.getElementValue(linkElem, "text");
|
|
||||||
link.type = this.getElementValue(linkElem, "type");
|
|
||||||
}
|
|
||||||
author.link = link;
|
|
||||||
}
|
|
||||||
this.metadata.author = author;
|
|
||||||
|
|
||||||
let link = {};
|
|
||||||
let linkElem = this.queryDirectSelector(metadata, 'link');
|
|
||||||
if(linkElem != null){
|
|
||||||
link.href = linkElem.getAttribute('href');
|
|
||||||
link.text = this.getElementValue(linkElem, "text");
|
|
||||||
link.type = this.getElementValue(linkElem, "type");
|
|
||||||
this.metadata.link = link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var wpts = [].slice.call(this.xmlSource.querySelectorAll('wpt'));
|
|
||||||
for (let idx in wpts){
|
|
||||||
var wpt = wpts[idx];
|
|
||||||
let pt = {};
|
|
||||||
pt.name = keepThis.getElementValue(wpt, "name");
|
|
||||||
pt.lat = parseFloat(wpt.getAttribute("lat"));
|
|
||||||
pt.lon = parseFloat(wpt.getAttribute("lon"));
|
|
||||||
//let floatValue = parseFloat(keepThis.getElementValue(wpt, "ele"));
|
|
||||||
//pt.ele = isNaN(floatValue) ? null : floatValue;
|
|
||||||
pt.ele = parseFloat(keepThis.getElementValue(wpt, "ele")) || null;
|
|
||||||
pt.cmt = keepThis.getElementValue(wpt, "cmt");
|
|
||||||
pt.desc = keepThis.getElementValue(wpt, "desc");
|
|
||||||
pt.sym = keepThis.getElementValue(wpt, "sym");
|
|
||||||
|
|
||||||
//let time = keepThis.getElementValue(wpt, "time");
|
|
||||||
//pt.time = time == null ? null : new Date(time);
|
|
||||||
pt.time = (keepThis.getElementValue(wpt, "time") || keepThis.metadata.time) || null;
|
|
||||||
|
|
||||||
keepThis.waypoints.push(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
var rtes = [].slice.call(this.xmlSource.querySelectorAll('rte'));
|
|
||||||
for (let idx in rtes){
|
|
||||||
let rte = rtes[idx];
|
|
||||||
let route = {};
|
|
||||||
route.name = keepThis.getElementValue(rte, "name");
|
|
||||||
route.cmt = keepThis.getElementValue(rte, "cmt");
|
|
||||||
route.desc = keepThis.getElementValue(rte, "desc");
|
|
||||||
route.src = keepThis.getElementValue(rte, "src");
|
|
||||||
route.number= keepThis.getElementValue(rte, "number");
|
|
||||||
|
|
||||||
let type = keepThis.queryDirectSelector(rte, "type");
|
|
||||||
route.type = type != null ? type.innerHTML : null;
|
|
||||||
|
|
||||||
let link = {};
|
|
||||||
let linkElem= rte.querySelector('link');
|
|
||||||
if(linkElem != null){
|
|
||||||
link.href = linkElem.getAttribute('href');
|
|
||||||
link.text = keepThis.getElementValue(linkElem, "text");
|
|
||||||
link.type = keepThis.getElementValue(linkElem, "type");
|
|
||||||
}
|
|
||||||
route.link = link;
|
|
||||||
|
|
||||||
let routepoints = [];
|
|
||||||
var rtepts = [].slice.call(rte.querySelectorAll('rtept'));
|
|
||||||
|
|
||||||
for (let idxIn in rtepts){
|
|
||||||
let rtept = rtepts[idxIn];
|
|
||||||
let pt = {};
|
|
||||||
pt.lat = parseFloat(rtept.getAttribute("lat"));
|
|
||||||
pt.lon = parseFloat(rtept.getAttribute("lon"));
|
|
||||||
//let floatValue = parseFloat(keepThis.getElementValue(rtept, "ele"));
|
|
||||||
//pt.ele = isNaN(floatValue) ? null : floatValue;
|
|
||||||
pt.ele = parseFloat(keepThis.getElementValue(rtept, "ele")) || null;
|
|
||||||
|
|
||||||
//let time = keepThis.getElementValue(rtept, "time");
|
|
||||||
//pt.time = time == null ? null : new Date(time);
|
|
||||||
pt.time = (keepThis.getElementValue(rtept, "time") || keepThis.metadata.time) || null;
|
|
||||||
|
|
||||||
routepoints.push(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
//route.distance = keepThis.calculDistance(routepoints);
|
|
||||||
//route.elevation = keepThis.calcElevation(routepoints);
|
|
||||||
//route.slopes = keepThis.calculSlope(routepoints, route.distance.cumul);
|
|
||||||
route.points = routepoints;
|
|
||||||
|
|
||||||
keepThis.routes.push(route);
|
|
||||||
}
|
|
||||||
|
|
||||||
var trks = [].slice.call(this.xmlSource.querySelectorAll('trk'));
|
|
||||||
for (let idx in trks){
|
|
||||||
let trk = trks[idx];
|
|
||||||
let track = {};
|
|
||||||
|
|
||||||
track.name = keepThis.getElementValue(trk, "name");
|
|
||||||
track.cmt = keepThis.getElementValue(trk, "cmt");
|
|
||||||
track.desc = keepThis.getElementValue(trk, "desc");
|
|
||||||
track.src = keepThis.getElementValue(trk, "src");
|
|
||||||
track.number= keepThis.getElementValue(trk, "number");
|
|
||||||
track.color = keepThis.getElementValue(trk, "DisplayColor");
|
|
||||||
track.time = keepThis.metadata.time;
|
|
||||||
|
|
||||||
let type = keepThis.queryDirectSelector(trk, "type");
|
|
||||||
track.type = type != null ? type.innerHTML : null;
|
|
||||||
|
|
||||||
let link = {};
|
|
||||||
let linkElem= trk.querySelector('link');
|
|
||||||
if(linkElem != null){
|
|
||||||
link.href = linkElem.getAttribute('href');
|
|
||||||
link.text = keepThis.getElementValue(linkElem, "text");
|
|
||||||
link.type = keepThis.getElementValue(linkElem, "type");
|
|
||||||
}
|
|
||||||
track.link = link;
|
|
||||||
|
|
||||||
let trackpoints = [];
|
|
||||||
let trkpts = [].slice.call(trk.querySelectorAll('trkpt'));
|
|
||||||
for (let idxIn in trkpts){
|
|
||||||
var trkpt = trkpts[idxIn];
|
|
||||||
let pt = {};
|
|
||||||
pt.lat = parseFloat(trkpt.getAttribute("lat"));
|
|
||||||
pt.lon = parseFloat(trkpt.getAttribute("lon"));
|
|
||||||
//let floatValue = parseFloat(keepThis.getElementValue(trkpt, "ele"));
|
|
||||||
//pt.ele = isNaN(floatValue) ? null : floatValue;
|
|
||||||
pt.ele = parseFloat(keepThis.getElementValue(trkpt, "ele")) || null;
|
|
||||||
|
|
||||||
//let time = keepThis.getElementValue(trkpt, "time");
|
|
||||||
//pt.time = time == null ? null : new Date(time);
|
|
||||||
pt.time = (keepThis.getElementValue(trkpt, "time") || keepThis.metadata.time) || null;
|
|
||||||
|
|
||||||
trackpoints.push(pt);
|
|
||||||
}
|
|
||||||
//track.distance = keepThis.calculDistance(trackpoints);
|
|
||||||
//track.elevation = keepThis.calcElevation(trackpoints);
|
|
||||||
//track.slopes = keepThis.calculSlope(trackpoints, track.distance.cumul);
|
|
||||||
track.points = trackpoints;
|
|
||||||
|
|
||||||
keepThis.tracks.push(track);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get value from a XML DOM element
|
|
||||||
*
|
|
||||||
* @param {Element} parent - Parent DOM Element
|
|
||||||
* @param {string} needle - Name of the searched element
|
|
||||||
*
|
|
||||||
* @return {} The element value
|
|
||||||
*/
|
|
||||||
gpxParser.prototype.getElementValue = function(parent, needle){
|
|
||||||
let elem = parent.querySelector(needle);
|
|
||||||
if(elem != null){
|
|
||||||
//Get value (in case of CDATA)
|
|
||||||
let sValue = (elem.innerHTML != undefined && elem.innerHTML.substring(0, 8) != '<![CDATA') ? elem.innerHTML : elem.childNodes[0].data;
|
|
||||||
|
|
||||||
//If decoded HTML, re-encode
|
|
||||||
if(sValue.substr(0, 4)== '<') sValue = $('<div>').html(sValue).text();
|
|
||||||
|
|
||||||
//Strip HTML tags & trim value
|
|
||||||
return $('<div>').html(sValue).text().trim();
|
|
||||||
}
|
|
||||||
return elem;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search the value of a direct child XML DOM element
|
|
||||||
*
|
|
||||||
* @param {Element} parent - Parent DOM Element
|
|
||||||
* @param {string} needle - Name of the searched element
|
|
||||||
*
|
|
||||||
* @return {} The element value
|
|
||||||
*/
|
|
||||||
gpxParser.prototype.queryDirectSelector = function(parent, needle) {
|
|
||||||
|
|
||||||
let elements = parent.querySelectorAll(needle);
|
|
||||||
let finalElem = elements[0];
|
|
||||||
|
|
||||||
if(elements.length > 1) {
|
|
||||||
let directChilds = parent.childNodes;
|
|
||||||
|
|
||||||
for(idx in directChilds) {
|
|
||||||
elem = directChilds[idx];
|
|
||||||
if(elem.tagName === needle) {
|
|
||||||
finalElem = elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalElem;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Gaia {
|
|
||||||
static get URL() { return 'https://www.gaiagps.com'; }
|
|
||||||
static get API() { return Gaia.URL+'/api/objects'; }
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.asFiles = [];
|
|
||||||
this.aoWaypoints = [];
|
|
||||||
this.aoTracks = [];
|
|
||||||
this.asFolders = {};
|
|
||||||
this.progress = {current:0, total:0};
|
|
||||||
}
|
|
||||||
|
|
||||||
setLayout() {
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
/* FIXME: adapts on GaiaGPS upgrade */
|
|
||||||
let $InputButton = $('a[href="https://help.gaiagps.com/hc/en-us/articles/360052763513"]').parent().find('button');
|
|
||||||
|
|
||||||
//If the button is found (=displayed)
|
|
||||||
if($InputButton.length > 0) {
|
|
||||||
this.$InputBox = $InputButton.parent();
|
|
||||||
|
|
||||||
//Add Feedback box
|
|
||||||
this.$Feedback = ($('#ggu-feedback').length > 0)?$('#ggu-feedback'):($('<div>', {
|
|
||||||
'id':'ggu-feedback',
|
|
||||||
'style':'width:calc(100% + 64px); height:400px; margin:1em 0 0 -32px; display:inline-block; text-align:left; overflow:auto;'
|
|
||||||
}).insertAfter($InputButton));
|
|
||||||
|
|
||||||
/*
|
|
||||||
//Add Folder Name Input next to button
|
|
||||||
this.$InputName = ($('#ggu-inputname').length > 0)?$('#ggu-inputname'):($('<input>', {
|
|
||||||
'type':'text',
|
|
||||||
'id': 'ggu-inputname',
|
|
||||||
'name':'ggu-inputname',
|
|
||||||
'placeholder':'Folder Name',
|
|
||||||
'style': 'border-width:2px; border-color:rgba(0, 0, 0, 0.1); border-radius:4px; font-family:Inter,Helvetica Neue,Helvetica,Arial; font-size:15px; padding:8px 12px; margin-bottom:12px;'
|
|
||||||
}).val('PCT').prependTo(this.$InputBox));
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Reset File Input DOM Element
|
|
||||||
let $InputFile = $('input[type=file]');
|
|
||||||
this.$InputFile = $InputFile.clone()
|
|
||||||
.insertAfter($InputFile)
|
|
||||||
.attr('multiple', 'multiple')
|
|
||||||
.attr('name', 'files[]')
|
|
||||||
.change(() => { this.readInputFiles(); });
|
|
||||||
$InputFile.remove();
|
|
||||||
|
|
||||||
//Reset button
|
|
||||||
this.$InputButton = $InputButton.clone()
|
|
||||||
.insertAfter($InputButton)
|
|
||||||
.click(() => {this.$InputFile.click();});
|
|
||||||
$InputButton.remove();
|
|
||||||
|
|
||||||
//Clear all upload notifications
|
|
||||||
this.resetNotif();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
feedback(sType, sMsg) {
|
|
||||||
let sColor = 'black';
|
|
||||||
let sIcon = '';
|
|
||||||
switch(sType) {
|
|
||||||
case 'error': sColor = 'red'; sIcon = '\u274C'; break;
|
|
||||||
case 'warning': sColor = 'orange'; sIcon = '\u26A0'; break;
|
|
||||||
case 'info': sColor = '#2D5E38'; sIcon = '\u2713'; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sFormattedMsg = sIcon+' '+sMsg+(sMsg.slice(-1)=='.'?'':'.');
|
|
||||||
console.log(sFormattedMsg);
|
|
||||||
|
|
||||||
this.$Feedback.append($('<p>', {'style': 'color: '+sColor+';'}).text(sFormattedMsg));
|
|
||||||
this.$Feedback.scrollTop(this.$Feedback.prop("scrollHeight"));
|
|
||||||
}
|
|
||||||
|
|
||||||
incProgress() {
|
|
||||||
if(!this.progress.current) {
|
|
||||||
this.progress.$Done = $('<div>', {'style':'overflow:hidden; background:#2D5E38; color: white; text-align:right;'});
|
|
||||||
this.progress.$Left = $('<div>', {'style':'overflow:hidden; background:white; color: #2D5E38; text-align:left;'});
|
|
||||||
this.progress.$Box = $('<div>', {'id':'ggu-progress', 'style':'margin-top:1em;'})
|
|
||||||
.append($('<div>', {'style':'display:flex; width:calc(100% + 64px); margin-left:-32px; border-radius:3px; border: 1px solid #2D5E38; box-sizing: border-box;'})
|
|
||||||
.append(this.progress.$Done)
|
|
||||||
.append(this.progress.$Left)
|
|
||||||
);
|
|
||||||
this.$Feedback.before(this.progress.$Box);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.progress.current++;
|
|
||||||
|
|
||||||
if(this.progress.current < this.progress.total) {
|
|
||||||
let iRatio = Math.round(this.progress.current / this.progress.total * 100);
|
|
||||||
let sTextDone = '', sTextLeft = '';
|
|
||||||
if(iRatio < 50) {
|
|
||||||
sTextDone = '';
|
|
||||||
sTextLeft = ' '+iRatio+'% ('+this.progress.current+' / '+this.progress.total+')';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sTextDone = '('+this.progress.current+' / '+this.progress.total+') '+iRatio+'% ';
|
|
||||||
sTextLeft = '';
|
|
||||||
}
|
|
||||||
this.progress.$Done.css('flex', iRatio+' 1 0%').html(sTextDone);
|
|
||||||
this.progress.$Left.css('flex', (100 - iRatio)+' 1 0%').html(sTextLeft);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.progress.$Box.remove();
|
|
||||||
this.progress = {current:0, total:0};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Marking all upload notifications as read
|
|
||||||
resetNotif() {
|
|
||||||
this.feedback('info', 'Marking all upload notifications as read');
|
|
||||||
$.get(Gaia.URL+'/social/notifications/popup/').done((asNotifs) => {
|
|
||||||
for(var i in asNotifs) {
|
|
||||||
if(!asNotifs[i].isViewed && asNotifs[i].html.indexOf('has completed') != -1) {
|
|
||||||
$.post(Gaia.URL+'/social/notifications/'+asNotifs[i].id+'/markviewed/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//Parse files from input (multiple)
|
|
||||||
readInputFiles() {
|
|
||||||
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
|
|
||||||
this.feedback('error', 'File APIs are not fully supported in this browser');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else this.feedback('info', 'Parsing input files');
|
|
||||||
|
|
||||||
//Get Folder Name (text input)
|
|
||||||
let aoReaders = [];
|
|
||||||
let iCount = 0;
|
|
||||||
this.asFiles = this.$InputFile.prop('files');
|
|
||||||
for(var i=0 ; i < this.asFiles.length ; i++) {
|
|
||||||
aoReaders[i] = new FileReader();
|
|
||||||
aoReaders[i].onload = ((oFileReader) => {
|
|
||||||
return (asResult) => {
|
|
||||||
iCount++;
|
|
||||||
this.feedback('info', 'Reading file "'+oFileReader.name+'" ('+iCount+'/'+this.asFiles.length+')');
|
|
||||||
this.parseFile(oFileReader.name, asResult.target.result);
|
|
||||||
this.asFolders[oFileReader.name] = {};
|
|
||||||
|
|
||||||
if(iCount == this.asFiles.length) {
|
|
||||||
this.progress.total = this.aoTracks.length + this.aoWaypoints.length + this.asFiles.length; //extra action per file: Create folder
|
|
||||||
this.createFolders();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})(this.asFiles[i]);
|
|
||||||
aoReaders[i].readAsText(this.asFiles[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Parse GPX files to consolidate tracks & waypoints
|
|
||||||
parseFile(sFileName, oContent) {
|
|
||||||
this.feedback('info', 'Parsing file "'+sFileName+'"');
|
|
||||||
|
|
||||||
var oGPX = new gpxParser();
|
|
||||||
oGPX.parse(oContent);
|
|
||||||
|
|
||||||
//Waypoints
|
|
||||||
for(var w in oGPX.waypoints) {
|
|
||||||
oGPX.waypoints[w].filename = sFileName;
|
|
||||||
var sWaypointName = oGPX.waypoints[w].name;
|
|
||||||
/* if(sWaypointName.indexOf('Milestone - ') != -1 && sWaypointName.substr(-2) != '00') { //1 milestone every 100 miles
|
|
||||||
this.feedback('info', 'Ignoring milestone waypoint "'+sWaypointName+'"');
|
|
||||||
}
|
|
||||||
else */this.aoWaypoints.push(oGPX.waypoints[w]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Tracks
|
|
||||||
for(var t in oGPX.tracks) {
|
|
||||||
oGPX.tracks[t].filename = sFileName;
|
|
||||||
this.aoTracks.push(oGPX.tracks[t]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Delete existing folder with same name & recreating it
|
|
||||||
createFolders() {
|
|
||||||
let iCount = 0;
|
|
||||||
$.each(this.asFolders, (sFileName, asFolder) => {
|
|
||||||
|
|
||||||
//Folder Name
|
|
||||||
let sFolderName = sFileName.replace(/\.[^\.]+$/, '');
|
|
||||||
|
|
||||||
this.feedback('info', 'Looking for existing folder "'+sFolderName+'"...');
|
|
||||||
$.get(Gaia.API+'/folder/?search='+sFolderName).done((asFolders) => {
|
|
||||||
if(asFolders != '' && !$.isEmptyObject(asFolders)) {
|
|
||||||
for(var f in asFolders) {
|
|
||||||
this.feedback('info', 'Deleting "'+asFolders[f].title+'" folder');
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/folder/'+asFolders[f].id+'/',
|
|
||||||
type: 'DELETE'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else this.feedback('info', 'No folder named "'+sFolderName+'" found');
|
|
||||||
|
|
||||||
this.feedback('info', 'Creating folder "'+sFolderName+'"');
|
|
||||||
let sTime = (new Date()).toISOString();
|
|
||||||
$.post({
|
|
||||||
url: Gaia.API+'/folder/',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({
|
|
||||||
title: sFolderName,
|
|
||||||
imported: true
|
|
||||||
})
|
|
||||||
}).done((asFolder) => {
|
|
||||||
this.feedback('info', 'Folder "'+asFolder.properties.name+'" created');
|
|
||||||
this.asFolders[sFileName] = asFolder;
|
|
||||||
this.incProgress();
|
|
||||||
|
|
||||||
iCount++;
|
|
||||||
if(iCount == Object.keys(this.asFolders).length) this.uploadTrack();
|
|
||||||
}).fail(() => {
|
|
||||||
this.feedback('error', 'Folder "'+sFolderName+'" could not be created');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//Build & Upload Track File
|
|
||||||
uploadTrack(iIndex) {
|
|
||||||
iIndex = iIndex || 0;
|
|
||||||
|
|
||||||
if(iIndex == 0) this.feedback('info', 'Uploading tracks...');
|
|
||||||
|
|
||||||
let aoTrack = this.aoTracks[iIndex];
|
|
||||||
this.feedback('info', 'Uploading track "'+aoTrack.name+'"');
|
|
||||||
|
|
||||||
let sColor = '#4ABD32';
|
|
||||||
switch(aoTrack.color) {
|
|
||||||
|
|
||||||
//Personal Colors
|
|
||||||
case 'DarkBlue': sColor = '#2D3FC7'; break;
|
|
||||||
case 'Magenta': sColor = '#B60DC3'; break;
|
|
||||||
|
|
||||||
//Garmin Colors
|
|
||||||
case 'Black': sColor = '#000000'; break;
|
|
||||||
case 'DarkRed': sColor = '#F90553'; break;
|
|
||||||
case 'DarkGreen': sColor = '#009B89'; break;
|
|
||||||
case 'DarkYellow': sColor = '#DCEE0E'; break;
|
|
||||||
//case 'DarkBlue': sColor = '#5E23CA'; break;
|
|
||||||
case 'DarkMagenta': sColor = '#B60DC3'; break;
|
|
||||||
case 'DarkCyan': sColor = '#00ACF8'; break;
|
|
||||||
case 'LightGray': sColor = '#A4A4A4'; break;
|
|
||||||
case 'DarkGray': sColor = '#577B8E'; break;
|
|
||||||
case 'Red': sColor = '#F90553'; break;
|
|
||||||
case 'Green': sColor = '#36C03B'; break;
|
|
||||||
case 'Yellow': sColor = '#FFF011'; break;
|
|
||||||
case 'Blue': sColor = '#2D3FC7'; break;
|
|
||||||
//case 'Magenta': sColor = '#B60DC3'; break;
|
|
||||||
case 'Cyan': sColor = '#00C3DD'; break;
|
|
||||||
case 'White': sColor = '#FFFFFF'; break;
|
|
||||||
case 'Transparent': sColor = '#784D3E'; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add track points
|
|
||||||
let aoCoords = [];
|
|
||||||
for(var p in aoTrack.points) {
|
|
||||||
let pt = aoTrack.points[p];
|
|
||||||
aoCoords.push([pt.lon, pt.lat, pt.ele, 0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Convert to geojson
|
|
||||||
let sPostedData = JSON.stringify({
|
|
||||||
geometry: {
|
|
||||||
coordinates: [aoCoords],
|
|
||||||
type: 'MultiLineString'
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
archived: false,
|
|
||||||
color: sColor,
|
|
||||||
//distance: 168405.62350073704,
|
|
||||||
filename: aoTrack.filename,
|
|
||||||
hexcolor: sColor,
|
|
||||||
isLatestImport: true,
|
|
||||||
isLocallyCreated: true,
|
|
||||||
isPublicTrack: false,
|
|
||||||
isValid: true,
|
|
||||||
localId: 'track'+(iIndex + 1),
|
|
||||||
notes: aoTrack.desc,
|
|
||||||
parent_folder_id: this.asFolders[aoTrack.filename].id,
|
|
||||||
routing_mode: null,
|
|
||||||
time_created: aoTrack.time || (new Date()).toISOString(),
|
|
||||||
title: aoTrack.name,
|
|
||||||
type: 'track',
|
|
||||||
writable: true
|
|
||||||
},
|
|
||||||
type: 'Feature'
|
|
||||||
});
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
$.post({
|
|
||||||
url: Gaia.API+'/track/',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: sPostedData,
|
|
||||||
trackName: aoTrack.name
|
|
||||||
}).done(function(asTrack) {
|
|
||||||
self.aoTracks[iIndex] = asTrack;
|
|
||||||
self.confirmTrack(iIndex, asTrack, this.data);
|
|
||||||
}).fail(function() {
|
|
||||||
self.feedback('error', 'Track "'+this.trackName+'" upload failed (stage 1). Retrying...');
|
|
||||||
self.uploadTrack(iIndex);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmTrack(iIndex, asTrack, sPostedData) {
|
|
||||||
iIndex = iIndex || 0;
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/track/'+asTrack.features[0].id+'/',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: sPostedData,
|
|
||||||
trackName: asTrack.features[0].properties.title
|
|
||||||
}).done(function() {
|
|
||||||
self.feedback('info', 'Track "'+this.trackName+'" uploaded');
|
|
||||||
self.incProgress();
|
|
||||||
iIndex++;
|
|
||||||
if(iIndex < self.aoTracks.length) self.uploadTrack(iIndex);
|
|
||||||
else {
|
|
||||||
self.feedback('info', 'All tracks uploaded');
|
|
||||||
self.uploadWayPoints();
|
|
||||||
}
|
|
||||||
}).fail(function() {
|
|
||||||
self.feedback('error', 'Track "'+this.trackName+'" upload failed (stage 2). Retrying...');
|
|
||||||
self.confirmTrack(iIndex, asTrack, sPostedData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
//Wait for file to be processed by Gaia
|
|
||||||
checkNotif() {
|
|
||||||
this.feedback('info', 'Waiting for Gaia to process consolidated track');
|
|
||||||
$.get(Gaia.URL+'/social/notifications/popup/').done((asNotifs) => {
|
|
||||||
for(var i in asNotifs) {
|
|
||||||
if(!asNotifs[i].isViewed && asNotifs[i].html.indexOf('has completed') != -1) {
|
|
||||||
this.feedback('info', 'Notification '+asNotifs[i].id+' found. Marking as read');
|
|
||||||
var $Notif = $('<span>').html(asNotifs[i].html);
|
|
||||||
this.sFolderId = $Notif.find('a').attr('href').split('/')[3];
|
|
||||||
$.post(Gaia.URL+'/social/notifications/'+asNotifs[i].id+'/markviewed/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.sFolderId != '') {
|
|
||||||
this.setTracksColor();
|
|
||||||
this.uploadWayPoints();
|
|
||||||
}
|
|
||||||
else setTimeout((() => {this.checkNotif();}), 1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
uploadWayPoints(iIndex) {
|
|
||||||
iIndex = iIndex || 0;
|
|
||||||
|
|
||||||
//Upload waypoints
|
|
||||||
var sWaypointName = this.aoWaypoints[iIndex].name;
|
|
||||||
var aoWaypoint = this.aoWaypoints[iIndex];
|
|
||||||
|
|
||||||
this.feedback('info', 'Uploading waypoint '+(iIndex + 1)+'/'+this.aoWaypoints.length+' ('+aoWaypoint.name+')');
|
|
||||||
var asPost = {
|
|
||||||
geometry: {
|
|
||||||
coordinates: [
|
|
||||||
aoWaypoint.lon,
|
|
||||||
aoWaypoint.lat,
|
|
||||||
aoWaypoint.ele
|
|
||||||
],
|
|
||||||
type: 'Point'
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
archived: false,
|
|
||||||
filename: aoWaypoint.filename,
|
|
||||||
icon: Gaia.getIconName(aoWaypoint.sym),
|
|
||||||
isLatestImport: true,
|
|
||||||
isLocallyCreated: true,
|
|
||||||
isValid: true,
|
|
||||||
localId: iIndex+'',
|
|
||||||
notes: aoWaypoint.desc,
|
|
||||||
parent_folder_id: this.asFolders[aoWaypoint.filename].id,
|
|
||||||
time_created: aoWaypoint.time || (new Date()).toISOString(),
|
|
||||||
title: aoWaypoint.name,
|
|
||||||
type: 'waypoint',
|
|
||||||
writable: true
|
|
||||||
},
|
|
||||||
type: 'Feature'
|
|
||||||
};
|
|
||||||
|
|
||||||
let sData = JSON.stringify(asPost);
|
|
||||||
var self = this;
|
|
||||||
$.post({
|
|
||||||
url: Gaia.API+'/waypoint/',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: sData
|
|
||||||
}).done(function(asWaypoint) {
|
|
||||||
self.aoWaypoints[iIndex] = asWaypoint;
|
|
||||||
self.confirmWayPoint(iIndex, asWaypoint, this.data);
|
|
||||||
}).fail(function(){
|
|
||||||
self.feedback('error', 'Failed to upload waypoint #'+(iIndex + 1)+' "'+sWaypointName+'" (Stage 1). Trying again...');
|
|
||||||
self.uploadWayPoints(iIndex);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmWayPoint(iIndex, asWaypoint, sPostedData) {
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/waypoint/'+asWaypoint.properties.id+'/',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: sPostedData
|
|
||||||
}).done(() => {
|
|
||||||
iIndex++;
|
|
||||||
this.incProgress();
|
|
||||||
if(iIndex < this.aoWaypoints.length) this.uploadWayPoints(iIndex);
|
|
||||||
//else this.assignElementsToFolders();
|
|
||||||
else this.feedback('info', 'Done');
|
|
||||||
}).fail(() => {
|
|
||||||
this.feedback('error', 'Failed to upload waypoint #'+(iIndex + 1)+' "'+asWaypoint.properties.title+'" (Stage 2). Trying again...');
|
|
||||||
this.confirmWayPoint(iIndex, asWaypoint, sPostedData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
assignElementsToFolders(iIndex) {
|
|
||||||
iIndex = iIndex || 0;
|
|
||||||
let asFolders = Object.keys(this.asFolders).map(key => this.asFolders[key]);
|
|
||||||
let asFolder = asFolders[iIndex];
|
|
||||||
|
|
||||||
this.feedback('info', 'Assigning elements of folder "'+asFolder.properties.name+'"');
|
|
||||||
|
|
||||||
//Folder metadata
|
|
||||||
let asData = {
|
|
||||||
cover_photo_id: asFolder.properties.cover_photo_id,
|
|
||||||
id: asFolder.id,
|
|
||||||
name: asFolder.properties.name,
|
|
||||||
notes: asFolder.properties.notes,
|
|
||||||
time_created: asFolder.properties.time_created,
|
|
||||||
updated_date: asFolder.properties.updated_date
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign waypoints to folder
|
|
||||||
asData.waypoints = [];
|
|
||||||
for(var w in this.aoWaypoints) {
|
|
||||||
if(this.aoWaypoints[w].parent_folder_id = asFolder.id) asData.waypoints.push(this.aoWaypoints[w].properties.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign tracks to folder
|
|
||||||
asData.tracks = [];
|
|
||||||
for(var t in this.aoTracks) {
|
|
||||||
if(this.aoTracks[t].parent_folder_id = asFolder.id) asData.tracks.push(this.aoTracks[t].features[0].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/folder/'+asFolder.id+'/',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify(asData)
|
|
||||||
}).done(() => {
|
|
||||||
iIndex++;
|
|
||||||
this.incProgress();
|
|
||||||
this.feedback('info', 'Tracks & waypoints assigned to folder "'+asFolder.properties.name+'"');
|
|
||||||
if(iIndex < asFolders.length) this.assignElementsToFolders(iIndex);
|
|
||||||
else this.feedback('info', 'Done');
|
|
||||||
}).fail(() => {
|
|
||||||
this.feedback('warning', 'Failed to assign waypoints & tracks to folder "'+asFolder.properties.name+'". Trying again...');
|
|
||||||
this.assignElementsToFolders(iIndex);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static getIconName(sGarminName) {
|
|
||||||
var asMapping = {
|
|
||||||
'Bridge': 'bridge',
|
|
||||||
'Campground': 'campsite-24',
|
|
||||||
'Car': 'car-24',
|
|
||||||
'Cemetery': 'cemetery-24',
|
|
||||||
'Church': 'ghost-town',
|
|
||||||
'City (Capitol)': 'city-24',
|
|
||||||
'Convenience Store': 'market',
|
|
||||||
'Drinking Water': 'potable-water',
|
|
||||||
'Flag, Blue': 'blue-pin-down',
|
|
||||||
'Flag, Green': 'green-pin',
|
|
||||||
'Flag, Red': 'red-pin-down',
|
|
||||||
'Forest': 'forest',
|
|
||||||
'Ground Transportation': 'car-24',
|
|
||||||
'Lodging': 'lodging-24',
|
|
||||||
'Park': 'park-24',
|
|
||||||
'Pharmacy': 'hospital-24',
|
|
||||||
'Picnic Area': 'picnic',
|
|
||||||
'Post Office': 'resupply',
|
|
||||||
'Powerline': 'petroglyph',
|
|
||||||
'Residence': 'building-24',
|
|
||||||
'Restaurant': 'restaurant-24',
|
|
||||||
'Restroom': 'toilets-24',
|
|
||||||
'Shopping Center': 'market',
|
|
||||||
'Ski Resort': 'skiing-24',
|
|
||||||
'Summit': 'peak',
|
|
||||||
'Toll Booth': 'ranger-station',
|
|
||||||
'Trail Head': 'known-route',
|
|
||||||
'Truck': 'car-24',
|
|
||||||
'Water Source': 'water-24'
|
|
||||||
};
|
|
||||||
return (sGarminName in asMapping)?asMapping[sGarminName]:'red-pin-down';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Loading GaiaGps Uploader '+GM_info.script.version);
|
|
||||||
|
|
||||||
let oGaia = new Gaia();
|
|
||||||
|
|
||||||
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
|
||||||
|
|
||||||
let observer = new MutationObserver((mutations, observer) => {
|
|
||||||
|
|
||||||
/* FIXME: adapts on GaiaGPS upgrade */
|
|
||||||
let $Import = $('div[aria-label="Import Data"]');
|
|
||||||
if($Import.length > 0) {
|
|
||||||
observer.disconnect();
|
|
||||||
$Import.parent('li').on('click', () => { setTimeout(() => { oGaia.setLayout(); }, 500)});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
observer.observe(document, { subtree: true, attributes: true});
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,182 +0,0 @@
|
|||||||
locale = en_NZ
|
|
||||||
page_og_desc = Keep contact with François when he is off hiking
|
|
||||||
error_commit_db = Issue committing to DB
|
|
||||||
unknown_field = Field "$0" is unknown
|
|
||||||
impossible_value = Value "$0" is not possible for field "$1"
|
|
||||||
|
|
||||||
nav_back = Back
|
|
||||||
|
|
||||||
admin = Admin Panel
|
|
||||||
admin_config = Config
|
|
||||||
admin_upload = Upload
|
|
||||||
save = Save
|
|
||||||
admin_save_success = Saved
|
|
||||||
admin_create_success= Created
|
|
||||||
admin_delete_success= Deleted
|
|
||||||
no_auth = No authorization
|
|
||||||
|
|
||||||
track_main = Main track
|
|
||||||
track_off-track = Off-track
|
|
||||||
track_hitchhiking = Hitchhiking
|
|
||||||
track_download = Download GPX Track
|
|
||||||
|
|
||||||
upload_title = Picture & Video Uploads
|
|
||||||
upload_mode_archived= Project "$0" is archived. No upload allowed
|
|
||||||
upload_success = $0 uploaded successfully
|
|
||||||
upload_media_exist = Picture $0 already exists
|
|
||||||
|
|
||||||
post_message = Message
|
|
||||||
post_name = Name
|
|
||||||
post_new_message = New message
|
|
||||||
and = and
|
|
||||||
counter = #$0
|
|
||||||
send = Send
|
|
||||||
|
|
||||||
maps = Base Maps
|
|
||||||
map_satellite = Satellite
|
|
||||||
map_otm = Open Topo Map
|
|
||||||
map_ign_france = IGN (France)
|
|
||||||
map_ign_spain = IGN (Spain)
|
|
||||||
map_linz = LINZ
|
|
||||||
map_usgs = USGS
|
|
||||||
map_natgeo = National Geographic
|
|
||||||
map_outdoors = Mapbox Outdoors
|
|
||||||
|
|
||||||
image = Picture
|
|
||||||
images = Pictures
|
|
||||||
image_taken = taken on $0
|
|
||||||
video = Video
|
|
||||||
video_taken = shot on $0
|
|
||||||
add_on = added on $0
|
|
||||||
click_watch = Click to watch video
|
|
||||||
click_zoom = Click to zoom
|
|
||||||
media_count = Media $0 / $1
|
|
||||||
media_no_id = Missing Media ID in request
|
|
||||||
media_comment_update= Comment of media "$0" updated
|
|
||||||
see_on_google = See on Google Maps
|
|
||||||
copy_to_clipboard = Copy direct link to clipboard
|
|
||||||
link_copied = Link copied!
|
|
||||||
|
|
||||||
city_time = $0 Time
|
|
||||||
local_time = $0 Local Time
|
|
||||||
your_time = $0 Your Time
|
|
||||||
date_time = $0 at $1
|
|
||||||
time_zone = Time Zone
|
|
||||||
|
|
||||||
id_project = Project ID
|
|
||||||
project = Project
|
|
||||||
projects = Projects
|
|
||||||
new_project = New Project
|
|
||||||
update_project = Update project messages
|
|
||||||
hikes = Hikes
|
|
||||||
mode = Mode
|
|
||||||
mode_previz = Project in preparation
|
|
||||||
mode_blog = Active Project
|
|
||||||
mode_histo = Archived Project
|
|
||||||
code_name = Code name
|
|
||||||
start = Start
|
|
||||||
end = End
|
|
||||||
feeds = Feeds
|
|
||||||
id_feed = Feed ID
|
|
||||||
ref_feed_id = Ref. Feed ID
|
|
||||||
new_feed = New feed
|
|
||||||
id_spot = Spot ID
|
|
||||||
name = Name
|
|
||||||
status = Status
|
|
||||||
last_update = Last Spot Check
|
|
||||||
ref_spot_id = Ref. Spot ID
|
|
||||||
model = Model
|
|
||||||
delete = Delete
|
|
||||||
id_user = User ID
|
|
||||||
user_name = User Name
|
|
||||||
active_users = Active Users
|
|
||||||
language = Language
|
|
||||||
clearance = Clearance
|
|
||||||
toolbox = Toolbox
|
|
||||||
|
|
||||||
unit_day = day
|
|
||||||
unit_days = days
|
|
||||||
unit_hour = h
|
|
||||||
|
|
||||||
newsletter = Keep in touch!
|
|
||||||
nl_email_placeholder= my@email.com
|
|
||||||
nl_invalid_email = It doesn't look like an email
|
|
||||||
nl_subscribed_desc = You're all set. We'll send you updates as soon as we get them
|
|
||||||
nl_unsubscribed_desc= Write down your email address and we'll send you François' position as soon as we get it :)
|
|
||||||
nl_email_exists = This email is already subscribed. You can unsubscribe by clicking on the button above.
|
|
||||||
nl_subscribe = Subscribe
|
|
||||||
nl_subscribed = Thanks! You'll receive a confirmation email shortly
|
|
||||||
nl_unsubscribe = Unsubscribe
|
|
||||||
nl_unsubscribed = Done. No more junk mail from us
|
|
||||||
nl_unknown_email = Unknown email address
|
|
||||||
|
|
||||||
email_unsubscribe = PS: Changed your mind?
|
|
||||||
email_unsub_btn = Unsubscribe
|
|
||||||
|
|
||||||
email_conf_subject = Successful Registration
|
|
||||||
conf_preheader = Thanks for keeping in touch!
|
|
||||||
conf_thanks_sub = You're all set!
|
|
||||||
conf_body_para_1 = Thank you for checking in on my wanderings :). I'll make sure to keep you posted on my progress along the trail.
|
|
||||||
conf_body_para_2 = I usually check-in once a day, plus sometimes on special events, like successful peak ascents. I am using a GPS-based device (PLB) which does not require phone reception to work. Thus the messages should be pretty frequent, but, being awestruck by the beauty of nature, I could also just forget to send a signal once in a while. So do not worry if you don't receive anything for a couple of days.
|
|
||||||
conf_body_para_3 = If I've posted some pictures recently, you should also get them in the same email.
|
|
||||||
conf_body_conclusion= See you down the road!
|
|
||||||
conf_signature = --François
|
|
||||||
|
|
||||||
email_update_subject= Spotted!
|
|
||||||
update_preheader = New position received
|
|
||||||
update_title = Message
|
|
||||||
update_latest_news = Latest news:
|
|
||||||
|
|
||||||
distance = Distance
|
|
||||||
elevation = Elevation
|
|
||||||
segment_length = Segment length
|
|
||||||
type = Track Type
|
|
||||||
legend = Legend
|
|
||||||
|
|
||||||
credits_project = Spotty Project
|
|
||||||
credits_git = Git Repository
|
|
||||||
credits_license = under GPLv3 license
|
|
||||||
|
|
||||||
weather_type_1 = Blowing Or Drifting Snow
|
|
||||||
weather_type_2 = Drizzle
|
|
||||||
weather_type_3 = Heavy Drizzle
|
|
||||||
weather_type_4 = Light Drizzle
|
|
||||||
weather_type_5 = Heavy Drizzle/Rain
|
|
||||||
weather_type_6 = Light Drizzle/Rain
|
|
||||||
weather_type_7 = Duststorm
|
|
||||||
weather_type_8 = Fog
|
|
||||||
weather_type_9 = Freezing Drizzle/Freezing Rain
|
|
||||||
weather_type_10 = Heavy Freezing Drizzle/Freezing Rain
|
|
||||||
weather_type_11 = Light Freezing Drizzle/Freezing Rain
|
|
||||||
weather_type_12 = Freezing Fog
|
|
||||||
weather_type_13 = Heavy Freezing Rain
|
|
||||||
weather_type_14 = Light Freezing Rain
|
|
||||||
weather_type_15 = Funnel Cloud/Tornado
|
|
||||||
weather_type_16 = Hail Showers
|
|
||||||
weather_type_17 = Ice
|
|
||||||
weather_type_18 = Lightning Without Thunder
|
|
||||||
weather_type_19 = Mist
|
|
||||||
weather_type_20 = Precipitation In Vicinity
|
|
||||||
weather_type_21 = Rain
|
|
||||||
weather_type_22 = Heavy Rain And Snow
|
|
||||||
weather_type_23 = Light Rain And Snow
|
|
||||||
weather_type_24 = Rain Showers
|
|
||||||
weather_type_25 = Heavy Rain
|
|
||||||
weather_type_26 = Light Rain
|
|
||||||
weather_type_27 = Sky Coverage Decreasing
|
|
||||||
weather_type_28 = Sky Coverage Increasing
|
|
||||||
weather_type_29 = Sky Unchanged
|
|
||||||
weather_type_30 = Smoke Or Haze
|
|
||||||
weather_type_31 = Snow
|
|
||||||
weather_type_32 = Snow And Rain Showers
|
|
||||||
weather_type_33 = Snow Showers
|
|
||||||
weather_type_34 = Heavy Snow
|
|
||||||
weather_type_35 = Light Snow
|
|
||||||
weather_type_36 = Squalls
|
|
||||||
weather_type_37 = Thunderstorm
|
|
||||||
weather_type_38 = Thunderstorm Without Precipitation
|
|
||||||
weather_type_39 = Diamond Dust
|
|
||||||
weather_type_40 = Hail
|
|
||||||
weather_type_41 = Overcast
|
|
||||||
weather_type_42 = Partially cloudy
|
|
||||||
weather_type_43 = Clear
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
locale = es_ES
|
|
||||||
page_og_desc = Mantente en contacto con François durante sus aventuras a la montaña
|
|
||||||
error_commit_db = Error SQL
|
|
||||||
unknown_field = Campo "$0" desconocido
|
|
||||||
impossible_value = Valor "$0" no es posible para campo "$1"
|
|
||||||
|
|
||||||
nav_back = Atrás
|
|
||||||
|
|
||||||
admin = Administración
|
|
||||||
admin_config = Configuración
|
|
||||||
admin_upload = Cargar
|
|
||||||
save = Guardar
|
|
||||||
admin_save_success = Guardado
|
|
||||||
admin_create_success= Creado
|
|
||||||
admin_delete_success= Eliminado
|
|
||||||
no_auth = No autorización
|
|
||||||
|
|
||||||
track_main = Camino principal
|
|
||||||
track_off-track = Variante
|
|
||||||
track_hitchhiking = Autostop
|
|
||||||
track_download = Descarga la ruta GPX
|
|
||||||
|
|
||||||
upload_title = Cargar fotos y videos
|
|
||||||
upload_mode_archived= El proyecto "$0" esta archivado. No se puede cargar
|
|
||||||
upload_success = $0 ha sido subido
|
|
||||||
upload_media_exist = La imagen $0 ya existe
|
|
||||||
|
|
||||||
post_message = Mensaje
|
|
||||||
post_name = Nombre
|
|
||||||
post_new_message = Mensaje nuevo
|
|
||||||
and = y
|
|
||||||
counter = No. $0
|
|
||||||
send = Enviar
|
|
||||||
|
|
||||||
maps = Mapas de base
|
|
||||||
map_satellite = Satélite
|
|
||||||
map_otm = Open Topo Map
|
|
||||||
map_ign_france = IGN (Francia)
|
|
||||||
map_ign_spain = IGN (España)
|
|
||||||
map_linz = LINZ
|
|
||||||
map_usgs = USGS
|
|
||||||
map_natgeo = National Geographic
|
|
||||||
map_outdoors = Mapbox Topo
|
|
||||||
|
|
||||||
image = Foto
|
|
||||||
images = Fotos
|
|
||||||
image_taken = Foto tomada el $0
|
|
||||||
video = Video
|
|
||||||
video_taken = Video filmado el $0
|
|
||||||
add_on = Agregado el $0
|
|
||||||
click_watch = Haz clic para ver el video
|
|
||||||
click_zoom = Haz clic para ampliar
|
|
||||||
media_count = Media $0 de $1
|
|
||||||
media_no_id = Falta el ID del sujeto
|
|
||||||
media_comment_update= Comentario "$0" actualizado
|
|
||||||
see_on_google = Ver la posición en Google Maps
|
|
||||||
copy_to_clipboard = Copiar el enlace
|
|
||||||
link_copied = ¡Enlace copiado!
|
|
||||||
|
|
||||||
city_time = Hora de $0
|
|
||||||
local_time = $0 hora local
|
|
||||||
your_time = $0 en tu zona horaria
|
|
||||||
date_time = $0 a la $1
|
|
||||||
time_zone = Huso horario
|
|
||||||
|
|
||||||
id_project = Proyecto ID
|
|
||||||
project = Proyecto
|
|
||||||
projects = Proyectos
|
|
||||||
new_project = Nuevo proyecto
|
|
||||||
update_project = Actualizar los mensajes del proyecto
|
|
||||||
hikes = Senderos
|
|
||||||
mode = Modo
|
|
||||||
mode_previz = Proyecto en preparación
|
|
||||||
mode_blog = Proyecto activo
|
|
||||||
mode_histo = Proyecto archivado
|
|
||||||
code_name = Nombre clave
|
|
||||||
start = Inicio
|
|
||||||
end = Fin
|
|
||||||
feeds = Feeds
|
|
||||||
id_feed = ID Feed
|
|
||||||
ref_feed_id = ID Feed ref.
|
|
||||||
new_feed = Nuevo feed
|
|
||||||
id_spot = ID Spot
|
|
||||||
name = Descripción
|
|
||||||
status = Estado
|
|
||||||
last_update = Última actualización de Spot
|
|
||||||
ref_spot_id = ID Spot ref.
|
|
||||||
model = Modelo
|
|
||||||
delete = Borrar
|
|
||||||
id_user = ID del usuario
|
|
||||||
user_name = Nombre
|
|
||||||
active_users = Usuarios activos
|
|
||||||
language = Idioma
|
|
||||||
clearance = Nivel de autorización
|
|
||||||
toolbox = Herramientas
|
|
||||||
|
|
||||||
unit_day = Día
|
|
||||||
unit_days = Días
|
|
||||||
unit_hour = h
|
|
||||||
|
|
||||||
newsletter = Mantenerse en contacto
|
|
||||||
nl_email_placeholder= nombre@email.com
|
|
||||||
nl_invalid_email = Esto no parece una dirección de correo electrónico
|
|
||||||
nl_subscribed_desc = Todo esta listo. Te enviaremos noticias frescas en cuanto las recibamos. Prometido...
|
|
||||||
nl_unsubscribed_desc= Anade tu dirección de correo electrónico y te enviaremos la posicion actualizada de François tan pronto como la recibamos :)
|
|
||||||
nl_email_exists = Esta dirección de correo electrónico ya está registrada. Puedes darte de baja haciendo clic en el botón de arriba.
|
|
||||||
nl_subscribe = Suscribir
|
|
||||||
nl_subscribed = ¡Gracias! Recibirás un correo electrónico de confirmación
|
|
||||||
nl_unsubscribe = Desinscribirse
|
|
||||||
nl_unsubscribed = Está hecho. ¡No más spam!
|
|
||||||
nl_unknown_email = Dirección de email desconocida
|
|
||||||
|
|
||||||
email_unsubscribe = PD: ¿Demasiados correos electrónicos?
|
|
||||||
email_unsub_btn = Desinscribirse
|
|
||||||
|
|
||||||
email_conf_subject = Confirmación
|
|
||||||
conf_preheader = ¡Gracias por mantenerte en contacto!
|
|
||||||
conf_thanks_sub = ¡Hecho!
|
|
||||||
conf_body_para_1 = Os agradezco mucho que sigais mi proyecto, y os intereseis de la evolucion. Os prometo que os mantendré informados sobre mi progreso.
|
|
||||||
conf_body_para_2 = Normalmente envío un mensaje una vez al día. Cuando voy a lugares guays, envío uno extra (cimas, ese tipo de cosas). Estoy usando una dispositivo GPS para enviar la señal, por lo que no necesito una red telefónica para que funcione. Sin embargo, puede haber ocasiones en las que presione el botón. Por lo tanto, no se preocupe si no recibe mensajes durante uno o dos días.
|
|
||||||
conf_body_para_3 = Cuando añada fotos en la página, también deberás encontrarlas en este correo electrónico.
|
|
||||||
conf_body_conclusion= ¡Nos vemos en el camino!
|
|
||||||
conf_signature = --François
|
|
||||||
|
|
||||||
email_update_subject= Nueva posición recibida
|
|
||||||
update_preheader = ¡Nueva posición!
|
|
||||||
update_title = Mensaje
|
|
||||||
update_latest_news = Últimas noticias:
|
|
||||||
|
|
||||||
distance = Distancia
|
|
||||||
elevation = Elevación
|
|
||||||
segment_length = Tamaño del segmento
|
|
||||||
type = Tipo de sendero
|
|
||||||
legend = Leyenda
|
|
||||||
|
|
||||||
credits_project = Proyecto Spotty
|
|
||||||
credits_git = Repositorio de Git
|
|
||||||
credits_license = bajo licencia GPLv3
|
|
||||||
|
|
||||||
weather_type_1 Nieve que sopla o a la deriva
|
|
||||||
weather_type_2 Llovizna
|
|
||||||
weather_type_3 Llovizna fuerte
|
|
||||||
weather_type_4 Llovizna ligera
|
|
||||||
weather_type_5 Fuerte llovizna / lluvia
|
|
||||||
weather_type_6 Llovizna ligera / Lluvia
|
|
||||||
weather_type_7 Tormenta de arena
|
|
||||||
weather_type_8 Niebla
|
|
||||||
weather_type_9 Llovizna helada / Lluvia helada
|
|
||||||
weather_type_10 Fuerte llovizna helada / lluvia helada
|
|
||||||
weather_type_11 Llovizna helada ligera / lluvia helada
|
|
||||||
weather_type_12 Niebla helada
|
|
||||||
weather_type_13 Lluvia helada intensa
|
|
||||||
weather_type_14 Lluvia helada ligera
|
|
||||||
weather_type_15 Nube de embudo / Tornado
|
|
||||||
weather_type_16 Lluvias de granizo
|
|
||||||
weather_type_17 Hielo
|
|
||||||
weather_type_18 Rayo sin trueno
|
|
||||||
weather_type_19 Niebla
|
|
||||||
weather_type_20 Precipitación en las proximidades
|
|
||||||
weather_type_21 Lluvia
|
|
||||||
weather_type_22 Fuertes lluvias y nieve
|
|
||||||
weather_type_23 Lluvia ligera y nieve
|
|
||||||
weather_type_24 Lluvias
|
|
||||||
weather_type_25 Lluvia Pesada
|
|
||||||
weather_type_26 Lluvia ligera
|
|
||||||
weather_type_27 Disminución de la cobertura del cielo
|
|
||||||
weather_type_28 Aumento de la cobertura del cielo
|
|
||||||
weather_type_29 Cielo sin cambios
|
|
||||||
weather_type_30 Humo o neblina
|
|
||||||
weather_type_31 Nieve
|
|
||||||
weather_type_32 Lluvias y nieve
|
|
||||||
weather_type_33 Duchas de nieve
|
|
||||||
weather_type_34 Fuertes nevadas
|
|
||||||
weather_type_35 Nieve ligera
|
|
||||||
weather_type_36 Chubascos
|
|
||||||
weather_type_37 Tormenta
|
|
||||||
weather_type_38 Tormenta sin precipitaciones
|
|
||||||
weather_type_39 Polvo de diamante
|
|
||||||
weather_type_40 Granizo
|
|
||||||
weather_type_41 Nublado
|
|
||||||
weather_type_42 Parcialmente nublado
|
|
||||||
weather_type_43 Claro
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
locale = fr_CH
|
|
||||||
page_og_desc = Gardez le contact avec François lorsqu'il part sur les chemins
|
|
||||||
error_commit_db = Error lors de la requête SQL
|
|
||||||
unknown_field = Champ "$0" inconnu
|
|
||||||
impossible_value = La valeur "$0" n'est pas possible pour le champ "$1"
|
|
||||||
|
|
||||||
nav_back = Retour
|
|
||||||
|
|
||||||
admin = Administration
|
|
||||||
admin_config = Paramètres
|
|
||||||
admin_upload = Uploader
|
|
||||||
save = Sauvegarder
|
|
||||||
admin_save_success = Sauvegardé
|
|
||||||
admin_create_success= Créé
|
|
||||||
admin_delete_success= Supprimé
|
|
||||||
no_auth = Pas d'authorisation
|
|
||||||
|
|
||||||
track_main = Trajet principal
|
|
||||||
track_off-track = Variante
|
|
||||||
track_hitchhiking = Hors rando
|
|
||||||
track_download = Télécharger la trace GPX
|
|
||||||
|
|
||||||
upload_title = Uploader photos & vidéos
|
|
||||||
upload_mode_archived= Le projet "$0" a été archivé. Aucun upload possible
|
|
||||||
upload_success = $0 a été uploadé
|
|
||||||
upload_media_exist = l'image $0 existe déjà
|
|
||||||
|
|
||||||
post_message = Message
|
|
||||||
post_name = Nom
|
|
||||||
post_new_message = Nouveau message
|
|
||||||
and = et
|
|
||||||
counter = N°$0
|
|
||||||
send = Envoyer
|
|
||||||
|
|
||||||
maps = Fonds de carte
|
|
||||||
map_satellite = Satellite
|
|
||||||
map_otm = Open Topo Map
|
|
||||||
map_ign_france = IGN (France)
|
|
||||||
map_ign_spain = IGN (Espagne)
|
|
||||||
map_linz = LINZ
|
|
||||||
map_usgs = USGS
|
|
||||||
map_natgeo = National Geographic
|
|
||||||
map_outdoors = Mapbox Topo
|
|
||||||
|
|
||||||
image = Photo
|
|
||||||
images = Photos
|
|
||||||
image_taken = prise le $0
|
|
||||||
video = Vidéo
|
|
||||||
video_taken = filmée le $0
|
|
||||||
add_on = ajoutée le $0
|
|
||||||
click_watch = Click pour voir la vidéo
|
|
||||||
click_zoom = Click pour zoomer
|
|
||||||
media_count = Média $0 sur $1
|
|
||||||
media_no_id = ID du média manquant
|
|
||||||
media_comment_update= Commentaire du media "$0" mis-à-jour
|
|
||||||
see_on_google = Voir la position sur Google Maps
|
|
||||||
copy_to_clipboard = Copie le lien dans le presse-papier
|
|
||||||
link_copied = Lien copié !
|
|
||||||
|
|
||||||
city_time = heure de $0
|
|
||||||
local_time = $0 heure locale
|
|
||||||
your_time = $0 dans votre fuseau horaire
|
|
||||||
date_time = $0 à $1
|
|
||||||
time_zone = Fuseau horaire
|
|
||||||
|
|
||||||
id_project = ID projet
|
|
||||||
project = Projet
|
|
||||||
projects = Projets
|
|
||||||
new_project = Nouveau projet
|
|
||||||
update_project = Mettre à jour les messages du projet
|
|
||||||
hikes = Randonnées
|
|
||||||
mode = Mode
|
|
||||||
mode_previz = Projet en cours de préparation
|
|
||||||
mode_blog = Projet actif
|
|
||||||
mode_histo = Projet archivé
|
|
||||||
code_name = Nom de code
|
|
||||||
start = Départ
|
|
||||||
end = Arrivée
|
|
||||||
feeds = Feeds
|
|
||||||
id_feed = ID Feed
|
|
||||||
ref_feed_id = ID Feed ref.
|
|
||||||
new_feed = Nouveau feed
|
|
||||||
id_spot = ID Spot
|
|
||||||
name = Description
|
|
||||||
status = Statut
|
|
||||||
last_update = Dernière vérification Spot
|
|
||||||
ref_spot_id = ID Spot ref.
|
|
||||||
model = Modèle
|
|
||||||
delete = Supprimer
|
|
||||||
id_user = ID Utilisateur
|
|
||||||
user_name = Nom
|
|
||||||
active_users = Utilisateurs actifs
|
|
||||||
language = Langue
|
|
||||||
clearance = Niveau d'autorisation
|
|
||||||
toolbox = Boite à outils
|
|
||||||
|
|
||||||
unit_day = jour
|
|
||||||
unit_days = jours
|
|
||||||
unit_hour = h
|
|
||||||
|
|
||||||
newsletter = Rester en contact
|
|
||||||
nl_email_placeholder= mon@email.com
|
|
||||||
nl_invalid_email = Ceci ne ressemble pas à une adresse email
|
|
||||||
nl_subscribed_desc = C'est tout bon. On t'envoie des nouvelles fraiches dès qu'on les reçoit. Parole de scout.
|
|
||||||
nl_unsubscribed_desc= Ajoute ton adresse email et on t'enverra la nouvelle position de François dès qu'on la reçoit :)
|
|
||||||
nl_email_exists = Cette adresse email est déjà enregistrée. Vous pouvez vous désinscrire en cliquant sur le bouton ci-dessus.
|
|
||||||
nl_subscribe = S'abonner
|
|
||||||
nl_subscribed = Merci ! Tu vas recevoir un email de confirmation très bientôt
|
|
||||||
nl_unsubscribe = Se désinscrire
|
|
||||||
nl_unsubscribed = C'est fait. Fini le spam!
|
|
||||||
nl_unknown_email = Adresse email inconnue
|
|
||||||
|
|
||||||
email_unsubscribe = PS: Trop d'emails ?
|
|
||||||
email_unsub_btn = Se désinscrire
|
|
||||||
|
|
||||||
email_conf_subject = Confirmation
|
|
||||||
conf_preheader = Merci de rester en contact !
|
|
||||||
conf_thanks_sub = C'est tout bon !
|
|
||||||
conf_body_para_1 = C'est gentil de venir voir où j'en suis. Promis, je vous tiendrais au courant de mon avancée.
|
|
||||||
conf_body_para_2 = En général, j'envoie un message une fois par jour. Lorsque je passe à des endroits sympas, j'en envoie un supplémentaire (ascension de sommets, ce genre de choses). J'utilise une balise GPS pour envoyer le signal, je n'ai donc pas besoin de réseau téléphonique pour que cela fonctionne. Cependant, il peut m'arriver d'appuyer sur le bouton. Donc pas de raison de s'inquiéter si vous ne recevez pas de messages pendant une journée ou deux.
|
|
||||||
conf_body_para_3 = Si j'ai ajouté des photos sur le site récemment, vous devriez aussi les retrouver dans cet email.
|
|
||||||
conf_body_conclusion= A bientôt sur les chemins !
|
|
||||||
conf_signature = --François
|
|
||||||
|
|
||||||
email_update_subject= Nouvelle position reçue
|
|
||||||
update_preheader = Nouvelle position !
|
|
||||||
update_title = Message
|
|
||||||
update_latest_news = Dernières nouvelles :
|
|
||||||
|
|
||||||
distance = Distance
|
|
||||||
elevation = Dénivelé
|
|
||||||
segment_length = Taille du segment
|
|
||||||
type = Type de rando
|
|
||||||
legend = Légende
|
|
||||||
|
|
||||||
credits_project = Projet Spotty
|
|
||||||
credits_git = Dépôt Git
|
|
||||||
credits_license = sous licence GPLv3
|
|
||||||
|
|
||||||
weather_type_1 = Poudrerie ou neige à la dérive
|
|
||||||
weather_type_2 = Bruine
|
|
||||||
weather_type_3 = Bruine lourde
|
|
||||||
weather_type_4 = Bruine légère
|
|
||||||
weather_type_5 = Forte bruine / pluie
|
|
||||||
weather_type_6 = Légère bruine / pluie
|
|
||||||
weather_type_7 = Tempête de poussière
|
|
||||||
weather_type_8 = Brouillard
|
|
||||||
weather_type_9 = Bruine verglaçante / Pluie verglaçante
|
|
||||||
weather_type_10 = Forte bruine verglaçante / pluie verglaçante
|
|
||||||
weather_type_11 = Légère bruine verglaçante / pluie verglaçante
|
|
||||||
weather_type_12 = Brouillard verglaçant
|
|
||||||
weather_type_13 = Forte pluie verglaçante
|
|
||||||
weather_type_14 = Légère pluie verglaçante
|
|
||||||
weather_type_15 = Nuage d'entonnoir / Tornade
|
|
||||||
weather_type_16 = Douches de grêle
|
|
||||||
weather_type_17 = La glace
|
|
||||||
weather_type_18 = Foudre sans tonnerre
|
|
||||||
weather_type_19 = Brouillard
|
|
||||||
weather_type_20 = Précipitations à proximité
|
|
||||||
weather_type_21 = Pluie
|
|
||||||
weather_type_22 = Forte pluie et neige
|
|
||||||
weather_type_23 = Légère pluie et neige
|
|
||||||
weather_type_24 = Averses de pluie
|
|
||||||
weather_type_25 = Forte pluie
|
|
||||||
weather_type_26 = Pluie légère
|
|
||||||
weather_type_27 = Couverture du ciel en baisse
|
|
||||||
weather_type_28 = Augmentation de la couverture du ciel
|
|
||||||
weather_type_29 = Ciel inchangé
|
|
||||||
weather_type_30 = Fumée ou brume
|
|
||||||
weather_type_31 = Neige
|
|
||||||
weather_type_32 = Averses de neige et de pluie
|
|
||||||
weather_type_33 = Douches de neige
|
|
||||||
weather_type_34 = Beaucoup de neige
|
|
||||||
weather_type_35 = Neige légère
|
|
||||||
weather_type_36 = Grains
|
|
||||||
weather_type_37 = Orage
|
|
||||||
weather_type_38 = Orage sans précipitations
|
|
||||||
weather_type_39 = La poussière de diamant
|
|
||||||
weather_type_40 = Saluer
|
|
||||||
weather_type_41 = Couvert
|
|
||||||
weather_type_42 = Partiellement nuageux
|
|
||||||
weather_type_43 = Clair
|
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Franzz\Livetrail;
|
||||||
|
|
||||||
|
use Franzz\Objects\PhpObject;
|
||||||
|
use Franzz\Objects\ToolBox;
|
||||||
|
|
||||||
|
//TODO Keep only local specificities and move bulk to Franzz\Objects\Controller
|
||||||
|
class Controller extends PhpObject {
|
||||||
|
private const MUTATING_ACTIONS = [
|
||||||
|
'add_post',
|
||||||
|
'subscribe',
|
||||||
|
'unsubscribe',
|
||||||
|
'login',
|
||||||
|
'logout',
|
||||||
|
'update_project',
|
||||||
|
'upload',
|
||||||
|
'add_comment',
|
||||||
|
'add_position',
|
||||||
|
'admin_set',
|
||||||
|
'admin_create',
|
||||||
|
'admin_delete'
|
||||||
|
];
|
||||||
|
private const SESSION_WRITING_ACTIONS = [
|
||||||
|
'login',
|
||||||
|
'logout'
|
||||||
|
];
|
||||||
|
|
||||||
|
private Livetrail $oLivetrail;
|
||||||
|
private array $asReq;
|
||||||
|
private string $sCsrfToken = '';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct(__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setReqVal(string $sKey, $oValue, string $sValidation=''): void {
|
||||||
|
$this->asReq[$sKey] = $this->validateValue($sValidation, $oValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle($sProcessPage, array $argv = []): string {
|
||||||
|
//Start buffering so warnings/notices can be collected
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
//Parse variables
|
||||||
|
$asReq = ToolBox::getRequest($argv);
|
||||||
|
$this->asReq = [];
|
||||||
|
$sAction = $asReq['a'] ?? '';
|
||||||
|
$this->setReqVal('t', $asReq['t'] ?? '');
|
||||||
|
$this->setReqVal('name', $asReq['name'] ?? '');
|
||||||
|
$this->setReqVal('content', $asReq['content'] ?? '');
|
||||||
|
$this->setReqVal('ref_type', $asReq['ref_type'] ?? '');
|
||||||
|
$this->setReqVal('ref_id', $asReq['ref_id'] ?? 0, 'positiveInt');
|
||||||
|
$this->setReqVal('id_project', $asReq['id_project'] ?? 0, 'positiveInt');
|
||||||
|
$this->setReqVal('id', $asReq['id'] ?? 0);
|
||||||
|
$this->setReqVal('id_entity', $asReq['id'] ?? 0, 'positiveInt');
|
||||||
|
$this->setReqVal('field', $asReq['field'] ?? '');
|
||||||
|
$this->setReqVal('value', $asReq['value'] ?? '');
|
||||||
|
$this->setReqVal('type', $asReq['type'] ?? '');
|
||||||
|
$this->setReqVal('email', $asReq['email'] ?? '');
|
||||||
|
$this->setReqVal('password', $asReq['password'] ?? '');
|
||||||
|
$this->setReqVal('latitude', $asReq['latitude'] ?? '');
|
||||||
|
$this->setReqVal('longitude', $asReq['longitude'] ?? '');
|
||||||
|
$this->setReqVal('timestamp', $asReq['timestamp'] ?? 0, 'positiveInt');
|
||||||
|
$this->setReqVal('csrf_token', $_SERVER['HTTP_X_CSRF_TOKEN'] ?? ($_POST['csrf_token'] ?? ''));
|
||||||
|
|
||||||
|
//Authentication and CSRF protection share the same server-side session.
|
||||||
|
$this->initCsrfToken();
|
||||||
|
|
||||||
|
//Create Livetrail instance
|
||||||
|
$this->oLivetrail = new Livetrail($sProcessPage, $this->asReq['t']);
|
||||||
|
|
||||||
|
//Validate CSRF, then release the session lock before long-running work.
|
||||||
|
$bValidMutationRequest = $this->validateMutationRequest($sAction);
|
||||||
|
if(!$bValidMutationRequest || !in_array($sAction, self::SESSION_WRITING_ACTIONS, true)) $this->closeSession();
|
||||||
|
|
||||||
|
if(!$bValidMutationRequest) $sResult = Livetrail::getJsonResult(false, Livetrail::UNAUTHORIZED);
|
||||||
|
else {
|
||||||
|
$this->oLivetrail->setProjectId($this->asReq['id_project']);
|
||||||
|
$sResult = ($sAction == '')?$this->oLivetrail->getAppMainPage($this->getCsrfToken()):$this->dispatch($sAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean errors
|
||||||
|
$sDebug = ob_get_clean();
|
||||||
|
if($sDebug != '') $this->oLivetrail->addUncaughtError($sDebug);
|
||||||
|
$this->closeSession();
|
||||||
|
|
||||||
|
return $sResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateMutationRequest(string $sAction): bool {
|
||||||
|
return
|
||||||
|
PHP_SAPI === 'cli'
|
||||||
|
||
|
||||||
|
!in_array($sAction, self::MUTATING_ACTIONS, true)
|
||||||
|
||
|
||||||
|
($_SERVER['REQUEST_METHOD'] ?? '') === 'POST' && $this->checkCsrfToken($this->asReq['csrf_token'])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCsrfToken(): string {
|
||||||
|
if($this->sCsrfToken === '') $this->initCsrfToken();
|
||||||
|
return $this->sCsrfToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setCsrfToken(): void {
|
||||||
|
if(empty($_SESSION['csrf_token'])) $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||||
|
$this->sCsrfToken = $_SESSION['csrf_token'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function initCsrfToken(): void {
|
||||||
|
if(PHP_SAPI === 'cli') return;
|
||||||
|
|
||||||
|
if(session_status() !== PHP_SESSION_ACTIVE) {
|
||||||
|
$bSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https');
|
||||||
|
session_set_cookie_params(['httponly' => true, 'secure' => $bSecure, 'samesite' => 'Lax']);
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setCsrfToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkCsrfToken(string $sClientToken): bool {
|
||||||
|
$sServerToken = $this->getCsrfToken();
|
||||||
|
return PHP_SAPI === 'cli' || ($sServerToken !== '' && is_string($sClientToken) && hash_equals($sServerToken, $sClientToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function closeSession(): void {
|
||||||
|
if(session_status() === PHP_SESSION_ACTIVE) session_write_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dispatch(string $sAction): string {
|
||||||
|
return match($sAction) {
|
||||||
|
'markers' => $this->oLivetrail->getMarkers(),
|
||||||
|
'last_update' => $this->oLivetrail->getLastUpdate(),
|
||||||
|
'next_feed' => $this->oLivetrail->getNextFeed($this->asReq['id']),
|
||||||
|
'new_feed' => $this->oLivetrail->getNewFeed($this->asReq['id']),
|
||||||
|
'add_post' => $this->oLivetrail->addPost($this->asReq['name'], $this->asReq['content'], $this->asReq['ref_type'], $this->asReq['ref_id']),
|
||||||
|
'subscribe' => $this->oLivetrail->subscribe(),
|
||||||
|
'unsubscribe' => $this->oLivetrail->unsubscribe(),
|
||||||
|
'login' => $this->oLivetrail->login($this->asReq['email'], $this->asReq['password'], $this->asReq['name']),
|
||||||
|
'logout' => $this->oLivetrail->logout(),
|
||||||
|
'update_project' => $this->oLivetrail->updateProject(),
|
||||||
|
default => $this->dispatchAdmin($sAction)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dispatchAdmin(string $sAction): string {
|
||||||
|
if(!$this->oLivetrail->checkUserClearance(User::CLEARANCE_ADMIN)) {
|
||||||
|
return Livetrail::getJsonResult(false, Livetrail::NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
return match($sAction) {
|
||||||
|
'upload' => $this->oLivetrail->upload(),
|
||||||
|
'add_comment' => $this->oLivetrail->addComment($this->asReq['id_entity'], $this->asReq['content']),
|
||||||
|
'add_position' => $this->oLivetrail->addPosition($this->asReq['latitude'], $this->asReq['longitude'], $this->asReq['timestamp']),
|
||||||
|
'admin_get' => $this->oLivetrail->getAdminSettings(),
|
||||||
|
'admin_set' => $this->oLivetrail->setAdminSettings($this->asReq['type'], $this->asReq['id_entity'], $this->asReq['field'], $this->asReq['value']),
|
||||||
|
'admin_create' => $this->oLivetrail->createAdminSettings($this->asReq['type']),
|
||||||
|
'admin_delete' => $this->oLivetrail->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
||||||
|
'sql' => $this->oLivetrail->getDbBuildScript(),
|
||||||
|
default => Livetrail::getJsonResult(false, Livetrail::NOT_FOUND)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function validateValue(string $sValidation, $oValue=0) {
|
||||||
|
return match($sValidation) {
|
||||||
|
'' => $oValue,
|
||||||
|
'positiveInt' => filter_var($oValue, FILTER_VALIDATE_INT, ['options' => ['default' => 0, 'min_range' => 0]])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-301
@@ -1,9 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\ToolBox;
|
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GPX to GeoJSON Converter
|
* GPX to GeoJSON Converter
|
||||||
@@ -12,9 +10,6 @@ use \Settings;
|
|||||||
* 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 {
|
||||||
|
|
||||||
@@ -22,7 +17,7 @@ class Converter extends PhpObject {
|
|||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convertToGeoJson($sCodeName) {
|
public static function convertToGeoJson(string $sCodeName) {
|
||||||
$oGpx = new Gpx($sCodeName);
|
$oGpx = new Gpx($sCodeName);
|
||||||
$oGeoJson = new GeoJson($sCodeName);
|
$oGeoJson = new GeoJson($sCodeName);
|
||||||
|
|
||||||
@@ -31,302 +26,23 @@ class Converter extends PhpObject {
|
|||||||
$oGeoJson->sortOffTracks();
|
$oGeoJson->sortOffTracks();
|
||||||
$oGeoJson->saveFile();
|
$oGeoJson->saveFile();
|
||||||
|
|
||||||
return $oGpx->getLog().'<br />'.$oGeoJson->getLog();
|
return [
|
||||||
|
'logs' => $oGpx->getLog().'<br />'.$oGeoJson->getLog(),
|
||||||
|
'center' => $oGeoJson->getCenter()
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isGeoJsonValid($sCodeName) {
|
public static function hasGpxFile(string $sCodeName) {
|
||||||
$bResult = false;
|
return ($sCodeName != '' && file_exists(Gpx::getBackendFilePath($sCodeName)));
|
||||||
$sGpxFilePath = Gpx::getFilePath($sCodeName);
|
}
|
||||||
$sGeoJsonFilePath = GeoJson::getFilePath($sCodeName);
|
|
||||||
|
public static function isGeoJsonValid(string $sCodeName) {
|
||||||
|
$sGpxFilePath = Gpx::getBackendFilePath($sCodeName);
|
||||||
|
$sGeoJsonFilePath = GeoJson::getBackendFilePath($sCodeName);
|
||||||
|
|
||||||
//No need to generate if gpx is missing
|
return
|
||||||
if(!file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Gpx::getFilePath($sCodeName))) $bResult = true;
|
!self::hasGpxFile($sCodeName) //No GPX, no need for geoJSON
|
||||||
return $bResult;
|
||
|
||||||
}
|
file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) >= filemtime($sGpxFilePath); //geoJSON needs to be (re)generated
|
||||||
}
|
|
||||||
|
|
||||||
class Geo extends PhpObject {
|
|
||||||
|
|
||||||
const GEO_FOLDER = '../geo/';
|
|
||||||
const OPT_SIMPLE = 'simplification';
|
|
||||||
|
|
||||||
protected $asTracks;
|
|
||||||
protected $sFilePath;
|
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
|
||||||
parent::__construct(get_class($this), Settings::DEBUG, PhpObject::MODE_HTML);
|
|
||||||
$this->sFilePath = self::getFilePath($sCodeName);
|
|
||||||
$this->asTracks = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFilePath($sCodeName) {
|
|
||||||
return self::GEO_FOLDER.$sCodeName.static::EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDistFilePath($sCodeName) {
|
|
||||||
return 'geo/'.$sCodeName.static::EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLog() {
|
|
||||||
return $this->getCleanMessageStack(PhpObject::NOTICE_TAB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Gpx extends Geo {
|
|
||||||
|
|
||||||
const EXT = '.gpx';
|
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
|
||||||
parent::__construct($sCodeName);
|
|
||||||
$this->parseFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTracks() {
|
|
||||||
return $this->asTracks;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function parseFile() {
|
|
||||||
$this->addNotice('Parsing: '.$this->sFilePath);
|
|
||||||
if(!file_exists($this->sFilePath)) $this->addError($this->sFilePath.' file missing');
|
|
||||||
else {
|
|
||||||
$oXml = simplexml_load_file($this->sFilePath);
|
|
||||||
|
|
||||||
//Tracks
|
|
||||||
$this->addNotice('Converting '.count($oXml->trk).' tracks');
|
|
||||||
foreach($oXml->trk as $aoTrack) {
|
|
||||||
$asTrack = array(
|
|
||||||
'name' => (string) $aoTrack->name,
|
|
||||||
'desc' => str_replace("\n", '', ToolBox::fixEOL((strip_tags($aoTrack->desc)))),
|
|
||||||
'cmt' => ToolBox::fixEOL((strip_tags($aoTrack->cmt))),
|
|
||||||
'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor,
|
|
||||||
'points'=> array()
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach($aoTrack->trkseg as $asSegment) {
|
|
||||||
foreach($asSegment as $asPoint) {
|
|
||||||
$asTrack['points'][] = array(
|
|
||||||
'lon' => (float) $asPoint['lon'],
|
|
||||||
'lat' => (float) $asPoint['lat'],
|
|
||||||
'ele' => (int) $asPoint->ele
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->asTracks[] = $asTrack;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Waypoints
|
|
||||||
$this->addNotice('Ignoring '.count($oXml->wpt).' waypoints');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GeoJson extends Geo {
|
|
||||||
|
|
||||||
const EXT = '.geojson';
|
|
||||||
const MAX_FILESIZE = 2; //MB
|
|
||||||
const MAX_DEVIATION_FLAT = 0.1; //10%
|
|
||||||
const MAX_DEVIATION_ELEV = 0.1; //10%
|
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
|
||||||
parent::__construct($sCodeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveFile() {
|
|
||||||
$this->addNotice('Saving '.$this->sFilePath);
|
|
||||||
file_put_contents($this->sFilePath, $this->buildGeoJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isSimplicationRequired() {
|
|
||||||
//Size in bytes
|
|
||||||
$iFileSize = strlen($this->buildGeoJson());
|
|
||||||
|
|
||||||
//Convert to MB
|
|
||||||
$iFileSize = round($iFileSize / pow(1024, 2), 2);
|
|
||||||
|
|
||||||
//Compare with max allowed size
|
|
||||||
$bFileTooLarge = ($iFileSize > self::MAX_FILESIZE);
|
|
||||||
if($bFileTooLarge) $this->addNotice('Output file is too large ('.$iFileSize.'MB > '.self::MAX_FILESIZE.'MB)');
|
|
||||||
|
|
||||||
return $bFileTooLarge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildTracks($asTracks, $bSimplify=false) {
|
|
||||||
$this->addNotice('Creating '.($bSimplify?'Simplified ':'').'GeoJson Tracks');
|
|
||||||
|
|
||||||
$iGlobalInvalidPointCount = 0;
|
|
||||||
$iGlobalPointCount = 0;
|
|
||||||
|
|
||||||
$this->asTracks = array();
|
|
||||||
foreach($asTracks as $asTrackProps) {
|
|
||||||
$asOptions = $this->parseOptions($asTrackProps['cmt']);
|
|
||||||
|
|
||||||
//Color mapping
|
|
||||||
switch($asTrackProps['color']) {
|
|
||||||
case 'DarkBlue':
|
|
||||||
$sType = 'main';
|
|
||||||
break;
|
|
||||||
case 'Magenta':
|
|
||||||
if($bSimplify && $asOptions[self::OPT_SIMPLE]!='keep') {
|
|
||||||
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (off-track)');
|
|
||||||
continue 2; //discard tracks
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sType = 'off-track';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'Red':
|
|
||||||
$sType = 'hitchhiking';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (unknown color "'.$asTrackProps['color'].'")');
|
|
||||||
continue 2; //discard tracks
|
|
||||||
}
|
|
||||||
|
|
||||||
$asTrack = array(
|
|
||||||
'type' => 'Feature',
|
|
||||||
'properties' => array(
|
|
||||||
'name' => $asTrackProps['name'],
|
|
||||||
'type' => $sType,
|
|
||||||
'description' => $asTrackProps['desc']
|
|
||||||
),
|
|
||||||
'geometry' => array(
|
|
||||||
'type' => 'LineString',
|
|
||||||
'coordinates' => array()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
//Track points
|
|
||||||
$asTrackPoints = $asTrackProps['points'];
|
|
||||||
$iPointCount = count($asTrackPoints);
|
|
||||||
$iInvalidPointCount = 0;
|
|
||||||
$asPrevPoint = array();
|
|
||||||
foreach($asTrackPoints as $iIndex=>$asPoint) {
|
|
||||||
$asNextPoint = ($iIndex < ($iPointCount - 1))?$asTrackPoints[$iIndex + 1]:array();
|
|
||||||
if($bSimplify && !empty($asPrevPoint) && !empty($asNextPoint)) {
|
|
||||||
if(!$this->isPointValid($asPrevPoint, $asPoint, $asNextPoint)) {
|
|
||||||
$iInvalidPointCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$asTrack['geometry']['coordinates'][] = array_values($asPoint);
|
|
||||||
$asPrevPoint = $asPoint;
|
|
||||||
}
|
|
||||||
$this->asTracks[] = $asTrack;
|
|
||||||
|
|
||||||
$iGlobalInvalidPointCount += $iInvalidPointCount;
|
|
||||||
$iGlobalPointCount += $iPointCount;
|
|
||||||
if($iInvalidPointCount > 0) $this->addNotice('Removing '.$iInvalidPointCount.'/'.$iPointCount.' points ('.round($iInvalidPointCount / $iPointCount * 100, 1).'%) from '.$asTrackProps['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($bSimplify) $this->addNotice('Total: '.$iGlobalInvalidPointCount.'/'.$iGlobalPointCount.' points removed ('.round($iGlobalInvalidPointCount / $iGlobalPointCount * 100, 1).'%)');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function sortOffTracks() {
|
|
||||||
$this->addNotice('Sorting off-tracks');
|
|
||||||
|
|
||||||
//Find first & last track points
|
|
||||||
$asTracksEnds = array();
|
|
||||||
$asTracks = array();
|
|
||||||
foreach($this->asTracks as $iTrackId=>$asTrack) {
|
|
||||||
$sTrackId = 't'.$iTrackId;
|
|
||||||
$asTracksEnds[$sTrackId] = array('first'=>reset($asTrack['geometry']['coordinates']), 'last'=>end($asTrack['geometry']['coordinates']));
|
|
||||||
$asTracks[$sTrackId] = $asTrack;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Find variants close-by tracks
|
|
||||||
$asClonedTracks = $asTracks;
|
|
||||||
foreach($asClonedTracks as $sTrackId=>$asTrack) {
|
|
||||||
if($asTrack['properties']['type'] != 'off-track') continue;
|
|
||||||
|
|
||||||
$iMinDistance = INF;
|
|
||||||
$sConnectedTrackId = 0;
|
|
||||||
$iPosition = 0;
|
|
||||||
|
|
||||||
//Test all track ending points to find the closest
|
|
||||||
foreach($asTracksEnds as $sTrackEndId=>$asTrackEnds) {
|
|
||||||
if($sTrackEndId != $sTrackId) {
|
|
||||||
//Calculate distance between the last point of the track and every starting point of other tracks
|
|
||||||
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['last'], $asTrackEnds['first']);
|
|
||||||
if($iDistance < $iMinDistance) {
|
|
||||||
$sConnectedTrackId = $sTrackEndId;
|
|
||||||
$iPosition = 0; //Track before the Connected Track
|
|
||||||
$iMinDistance = $iDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculate distance between the first point of the track and every ending point of other tracks
|
|
||||||
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['first'], $asTrackEnds['last']);
|
|
||||||
if($iDistance < $iMinDistance) {
|
|
||||||
$sConnectedTrackId = $sTrackEndId;
|
|
||||||
$iPosition = +1; //Track after the Connected Track
|
|
||||||
$iMinDistance = $iDistance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Move track
|
|
||||||
unset($asTracks[$sTrackId]);
|
|
||||||
$iOffset = array_search($sConnectedTrackId, array_keys($asTracks)) + $iPosition;
|
|
||||||
$asTracks = array_slice($asTracks, 0, $iOffset) + array($sTrackId => $asTrack) + array_slice($asTracks, $iOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->asTracks = array_values($asTracks);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function parseOptions($sComment){
|
|
||||||
$sComment = strip_tags(html_entity_decode($sComment));
|
|
||||||
$asOptions = array(self::OPT_SIMPLE=>'');
|
|
||||||
foreach(explode("\n", $sComment) as $sLine) {
|
|
||||||
$asOptions[mb_strtolower(trim(mb_strstr($sLine, ':', true)))] = mb_strtolower(trim(mb_substr(mb_strstr($sLine, ':'), 1)));
|
|
||||||
}
|
|
||||||
return $asOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
|
||||||
/* A----O Calculate angle AO^OB
|
|
||||||
* \ If angle is within [90% Pi ; 110% Pi], O can be discarded
|
|
||||||
* \ O is valid otherwise
|
|
||||||
* B
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Path Turn Check -> -> -> ->
|
|
||||||
//Law of Cosines (vector): angle = arccos(OA.OB / ||OA||.||OB||)
|
|
||||||
$fVectorOA = array('lon'=>($asPointA['lon'] - $asPointO['lon']), 'lat'=> ($asPointA['lat'] - $asPointO['lat']));
|
|
||||||
$fVectorOB = array('lon'=>($asPointB['lon'] - $asPointO['lon']), 'lat'=> ($asPointB['lat'] - $asPointO['lat']));
|
|
||||||
|
|
||||||
$fLengthOA = sqrt(pow($asPointA['lon'] - $asPointO['lon'], 2) + pow($asPointA['lat'] - $asPointO['lat'], 2));
|
|
||||||
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
|
|
||||||
|
|
||||||
$fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat'];
|
|
||||||
$fAngleAOB = ($fLengthOA != 0 && $fLengthOB != 0) ? acos($fVectorOAxOB/($fLengthOA * $fLengthOB)) : 0;
|
|
||||||
|
|
||||||
//Elevation Check
|
|
||||||
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
|
|
||||||
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
|
|
||||||
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2));
|
|
||||||
$fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2));
|
|
||||||
$fAngleAOBElev = ($fLengthOB != 0 && $fLengthAO != 0) ? (acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO))) : 0;
|
|
||||||
|
|
||||||
return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI ||
|
|
||||||
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildGeoJson() {
|
|
||||||
return json_encode(array('type'=>'FeatureCollection', 'features'=>$this->asTracks));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getDistance($asPointA, $asPointB) {
|
|
||||||
$fLatFrom = $asPointA[1];
|
|
||||||
$fLonFrom = $asPointA[0];
|
|
||||||
$fLatTo = $asPointB[1];
|
|
||||||
$fLonTo = $asPointB[0];
|
|
||||||
|
|
||||||
$fRad = M_PI / 180;
|
|
||||||
|
|
||||||
//Calculate distance from latitude and longitude
|
|
||||||
$fTheta = $fLonFrom - $fLonTo;
|
|
||||||
$fDistance = sin($fLatFrom * $fRad) * sin($fLatTo * $fRad) + cos($fLatFrom * $fRad) * cos($fLatTo * $fRad) * cos($fTheta * $fRad);
|
|
||||||
|
|
||||||
return acos($fDistance) / $fRad * 60 * 1.853;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Mask;
|
use Franzz\Objects\Mask;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
@@ -25,7 +25,7 @@ class Email extends PhpObject {
|
|||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
$this->sServName = $sServName;
|
$this->sServName = $sServName;
|
||||||
$this->setTemplate($sTemplateName);
|
$this->setTemplate($sTemplateName);
|
||||||
$this->asDests = array();
|
$this->asDests = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplate($sTemplateName) {
|
public function setTemplate($sTemplateName) {
|
||||||
@@ -39,7 +39,7 @@ class Email extends PhpObject {
|
|||||||
* @param array $asDests Contains: id_user, name, email, language, timezone, active
|
* @param array $asDests Contains: id_user, name, email, language, timezone, active
|
||||||
*/
|
*/
|
||||||
public function setDestInfo($asDests) {
|
public function setDestInfo($asDests) {
|
||||||
if(array_key_exists('email', $asDests)) $asDests = array($asDests);
|
if(array_key_exists('email', $asDests)) $asDests = [$asDests];
|
||||||
$this->asDests = $asDests;
|
$this->asDests = $asDests;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,12 +57,13 @@ class Email extends PhpObject {
|
|||||||
$oPHPMailer->Password = Settings::MAIL_PASS; //SMTP password
|
$oPHPMailer->Password = Settings::MAIL_PASS; //SMTP password
|
||||||
$oPHPMailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
|
$oPHPMailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
|
||||||
$oPHPMailer->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
|
$oPHPMailer->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
|
||||||
$oPHPMailer->setFrom(Settings::MAIL_FROM, 'Spotty');
|
$oPHPMailer->setFrom(Settings::MAIL_FROM, Livetrail::PROJECT_NAME);
|
||||||
$oPHPMailer->addReplyTo(Settings::MAIL_FROM, 'Spotty');
|
$oPHPMailer->addReplyTo(Settings::MAIL_FROM, Livetrail::PROJECT_NAME);
|
||||||
|
|
||||||
|
$bSuccess = true;
|
||||||
foreach($this->asDests as $asDest) {
|
foreach($this->asDests as $asDest) {
|
||||||
//Message
|
//Message
|
||||||
$this->oTemplate->setLanguage($asDest['language'], Spot::DEFAULT_LANG);
|
$this->oTemplate->setLanguage($asDest['language'], Livetrail::DEFAULT_LANG);
|
||||||
$this->oTemplate->setTimezone($asDest['timezone']);
|
$this->oTemplate->setTimezone($asDest['timezone']);
|
||||||
|
|
||||||
//Unsubscribe Link
|
//Unsubscribe Link
|
||||||
@@ -72,7 +73,7 @@ class Email extends PhpObject {
|
|||||||
$oPHPMailer->addCustomHeader('List-Unsubscribe-Post','List-Unsubscribe=One-Click');
|
$oPHPMailer->addCustomHeader('List-Unsubscribe-Post','List-Unsubscribe=One-Click');
|
||||||
|
|
||||||
//Email Content
|
//Email Content
|
||||||
$this->oTemplate->setTag('timezone', 'lang:city_time', self::getTimeZoneCity($asDest['timezone']));
|
$this->oTemplate->setTag('timezone', 'lang:time.city', self::getTimeZoneCity($asDest['timezone']));
|
||||||
$sHtmlMessage = $this->oTemplate->getMask();
|
$sHtmlMessage = $this->oTemplate->getMask();
|
||||||
$sPlainMessage = strip_tags(str_replace('<br />', "\n", $sHtmlMessage));
|
$sPlainMessage = strip_tags(str_replace('<br />', "\n", $sHtmlMessage));
|
||||||
|
|
||||||
@@ -86,11 +87,10 @@ class Email extends PhpObject {
|
|||||||
|
|
||||||
//Content
|
//Content
|
||||||
$oPHPMailer->isHTML(true);
|
$oPHPMailer->isHTML(true);
|
||||||
$oPHPMailer->Subject = $this->oTemplate->getTranslator()->getTranslation($this->sTemplateName.'_subject');
|
$oPHPMailer->Subject = $this->oTemplate->getTranslator()->getTranslation($this->sTemplateName.'.subject');
|
||||||
$oPHPMailer->Body = $sHtmlMessage;
|
$oPHPMailer->Body = $sHtmlMessage;
|
||||||
$oPHPMailer->AltBody = $sPlainMessage;
|
$oPHPMailer->AltBody = $sPlainMessage;
|
||||||
|
|
||||||
$bSuccess = true;
|
|
||||||
try {
|
try {
|
||||||
$bSuccess = $bSuccess && $oPHPMailer->send();
|
$bSuccess = $bSuccess && $oPHPMailer->send();
|
||||||
}
|
}
|
||||||
|
|||||||
+104
-72
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Db;
|
use Franzz\Objects\Db;
|
||||||
use Franzz\Objects\Translator;
|
use Franzz\Objects\Translator;
|
||||||
@@ -13,35 +13,32 @@ use \Settings;
|
|||||||
class Feed extends PhpObject {
|
class Feed extends PhpObject {
|
||||||
|
|
||||||
//Spot feed
|
//Spot feed
|
||||||
const FEED_HOOK = 'https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/';
|
private const FEED_HOOK = 'https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/';
|
||||||
const FEED_TYPE_XML = '/message.xml';
|
private const FEED_TYPE_XML = '/message.xml';
|
||||||
const FEED_TYPE_JSON = '/message.json';
|
private const FEED_TYPE_JSON = '/message.json';
|
||||||
const FEED_MAX_REFRESH = 5 * 60; //Seconds
|
private const FEED_MAX_REFRESH = 5 * 60; //Seconds
|
||||||
|
|
||||||
//Weather
|
//Weather
|
||||||
const WEATHER_HOOK = 'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline';
|
private const WEATHER_HOOK = 'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline';
|
||||||
const WEATHER_PARAM = array(
|
private const WEATHER_PARAM = [
|
||||||
'key' => Settings::WEATHER_TOKEN,
|
'key' => Settings::WEATHER_TOKEN,
|
||||||
'unitGroup' => 'metric',
|
'unitGroup' => 'metric',
|
||||||
'lang' => 'en',
|
'lang' => 'en',
|
||||||
'include' => 'current',
|
'include' => 'current',
|
||||||
'iconSet' => 'icons2'
|
'iconSet' => 'icons2'
|
||||||
);
|
];
|
||||||
|
|
||||||
//Timezone
|
//Timezone
|
||||||
const TIMEZONE_HOOK = 'http://api.geonames.org/timezoneJSON';
|
private const TIMEZONE_HOOK = 'http://api.geonames.org/timezoneJSON';
|
||||||
const TIMEZONE_PARAM = array(
|
|
||||||
'username' => Settings::TIMEZONE_USER
|
|
||||||
);
|
|
||||||
|
|
||||||
//DB Tables
|
//DB Tables
|
||||||
const SPOT_TABLE = 'spots';
|
public const SPOT_TABLE = 'spots';
|
||||||
const FEED_TABLE = 'feeds';
|
public const FEED_TABLE = 'feeds';
|
||||||
const MSG_TABLE = 'messages';
|
public const MSG_TABLE = 'messages';
|
||||||
|
|
||||||
//Hide/Display values
|
//Hide/Display values
|
||||||
const MSG_HIDDEN = 0;
|
public const MSG_HIDDEN = 0;
|
||||||
const MSG_DISPLAYED = 1;
|
public const MSG_DISPLAYED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Handle
|
* Database Handle
|
||||||
@@ -75,10 +72,10 @@ class Feed extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createFeedId($oProjectId) {
|
public function createFeedId($oProjectId) {
|
||||||
$this->setFeedId($this->oDb->insertRow(self::FEED_TABLE, array(
|
$this->setFeedId($this->oDb->insertRow(self::FEED_TABLE, [
|
||||||
Db::getId(Project::PROJ_TABLE) => $oProjectId,
|
Db::getId(Project::PROJ_TABLE) => $oProjectId,
|
||||||
'status' => 'INACTIVE'
|
'status' => 'INACTIVE'
|
||||||
)));
|
]));
|
||||||
return $this->getFeedId();
|
return $this->getFeedId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,14 +92,14 @@ class Feed extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSpots() {
|
public function getSpots() {
|
||||||
$asSpots = $this->oDb->selectRows(array('from'=>self::SPOT_TABLE));
|
$asSpots = $this->oDb->selectRows(['from'=>self::SPOT_TABLE]);
|
||||||
foreach($asSpots as &$asSpot) $asSpot['id'] = $asSpot[Db::getId(self::SPOT_TABLE)];
|
foreach($asSpots as &$asSpot) $asSpot['id'] = $asSpot[Db::getId(self::SPOT_TABLE)];
|
||||||
return $asSpots;
|
return $asSpots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFeeds($iFeedId=0) {
|
public function getFeeds($iFeedId=0) {
|
||||||
$asInfo = array('from'=>self::FEED_TABLE);
|
$asInfo = ['from'=>self::FEED_TABLE];
|
||||||
if($iFeedId > 0) $asInfo['constraint'] = array(Db::getId(self::FEED_TABLE)=>$iFeedId);
|
if($iFeedId > 0) $asInfo['constraint'] = [Db::getId(self::FEED_TABLE)=>$iFeedId];
|
||||||
$asFeeds = $this->oDb->selectRows($asInfo);
|
$asFeeds = $this->oDb->selectRows($asInfo);
|
||||||
|
|
||||||
foreach($asFeeds as &$asFeed) $asFeed['id'] = $asFeed[Db::getId(self::FEED_TABLE)];
|
foreach($asFeeds as &$asFeed) $asFeed['id'] = $asFeed[Db::getId(self::FEED_TABLE)];
|
||||||
@@ -114,21 +111,21 @@ class Feed extends PhpObject {
|
|||||||
return array_shift($asFeeds);
|
return array_shift($asFeeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMessages($asConstraints=array()) {
|
public function getMessages($asConstraints=[]) {
|
||||||
$sFeedIdCol = Db::getId(self::FEED_TABLE, true);
|
$sFeedIdCol = Db::getId(self::FEED_TABLE, true);
|
||||||
$asInfo = array(
|
$asInfo = [
|
||||||
'select' => array(
|
'select' => [
|
||||||
Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', //ID
|
Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', //ID
|
||||||
'latitude', 'longitude', //Position
|
'latitude', 'longitude', //Position
|
||||||
'site_time', 'timezone', 'unix_time', //Time
|
'site_time', 'timezone', 'unix_time', //Time
|
||||||
'weather_icon', 'weather_cond', 'weather_temp' //Weather
|
'weather_icon', 'weather_cond', 'weather_temp' //Weather
|
||||||
),
|
],
|
||||||
'from' => self::MSG_TABLE,
|
'from' => self::MSG_TABLE,
|
||||||
'join' => array(self::FEED_TABLE => Db::getId(self::FEED_TABLE)),
|
'join' => [self::FEED_TABLE => Db::getId(self::FEED_TABLE)],
|
||||||
'constraint'=> array($sFeedIdCol => $this->getFeedId(), 'display' => self::MSG_DISPLAYED),
|
'constraint'=> [$sFeedIdCol => $this->getFeedId(), 'display' => self::MSG_DISPLAYED],
|
||||||
'constOpe' => array($sFeedIdCol => "=", 'display' => "="),
|
'constOpe' => [$sFeedIdCol => '=', 'display' => '='],
|
||||||
'orderBy' => array('site_time'=>'ASC')
|
'orderBy' => ['site_time'=>'ASC']
|
||||||
);
|
];
|
||||||
if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints);
|
if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints);
|
||||||
|
|
||||||
$asResult = $this->oDb->selectRows($asInfo);
|
$asResult = $this->oDb->selectRows($asInfo);
|
||||||
@@ -137,7 +134,7 @@ class Feed extends PhpObject {
|
|||||||
$iCount = 0;
|
$iCount = 0;
|
||||||
foreach($asResult as &$asMsg) {
|
foreach($asResult as &$asMsg) {
|
||||||
if($asMsg['weather_icon'] == '' && $iCount < 3) {
|
if($asMsg['weather_icon'] == '' && $iCount < 3) {
|
||||||
$asWeather = $this->getWeather(array($asMsg['latitude'], $asMsg['longitude']), $asMsg['unix_time']);
|
$asWeather = $this->getWeather([$asMsg['latitude'], $asMsg['longitude']], $asMsg['unix_time']);
|
||||||
$asMsg = array_merge($asMsg, $asWeather);
|
$asMsg = array_merge($asMsg, $asWeather);
|
||||||
$this->oDb->updateRow(self::MSG_TABLE, $asMsg[Db::getId(self::MSG_TABLE)], $asWeather, false);
|
$this->oDb->updateRow(self::MSG_TABLE, $asMsg[Db::getId(self::MSG_TABLE)], $asWeather, false);
|
||||||
$iCount++;
|
$iCount++;
|
||||||
@@ -148,7 +145,7 @@ class Feed extends PhpObject {
|
|||||||
return $asResult;
|
return $asResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastMessageId($asConstraints=array()) {
|
public function getLastMessageId($asConstraints=[]) {
|
||||||
$asMessages = $this->getMessages($asConstraints);
|
$asMessages = $this->getMessages($asConstraints);
|
||||||
return end($asMessages)[Db::getId(self::MSG_TABLE)] ?? 0;
|
return end($asMessages)[Db::getId(self::MSG_TABLE)] ?? 0;
|
||||||
}
|
}
|
||||||
@@ -168,6 +165,31 @@ class Feed extends PhpObject {
|
|||||||
return $bNewMsg;
|
return $bNewMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addManualPosition($sLat, $sLng, $iTimestamp) {
|
||||||
|
$sTimeZone = date_default_timezone_get();
|
||||||
|
$oDateTime = new \DateTime('@'.$iTimestamp);
|
||||||
|
$oDateTime->setTimezone(new \DateTimeZone($sTimeZone));
|
||||||
|
$asWeather = $this->getWeather([$sLat, $sLng], $iTimestamp);
|
||||||
|
|
||||||
|
$asMsg = [
|
||||||
|
'ref_msg_id' => $iTimestamp.'/man',
|
||||||
|
'id_feed' => $this->getFeedId(),
|
||||||
|
'type' => 'OK',
|
||||||
|
'latitude' => $sLat,
|
||||||
|
'longitude' => $sLng,
|
||||||
|
'iso_time' => $oDateTime->format("Y-m-d\TH:i:sO"), //Incorrect ISO 8601 format, but compliant with Spot data
|
||||||
|
'site_time' => $oDateTime->format(Db::TIMESTAMP_FORMAT),
|
||||||
|
'timezone' => $sTimeZone,
|
||||||
|
'unix_time' => $iTimestamp,
|
||||||
|
'content' => '',
|
||||||
|
'battery_state' => '',
|
||||||
|
'posted_on' => date(Db::TIMESTAMP_FORMAT),
|
||||||
|
];
|
||||||
|
|
||||||
|
$iMessageId = $this->oDb->insertRow(self::MSG_TABLE, array_merge($asMsg, $asWeather));
|
||||||
|
return $iMessageId;
|
||||||
|
}
|
||||||
|
|
||||||
private function updateFeed() {
|
private function updateFeed() {
|
||||||
$bNewMsg = false;
|
$bNewMsg = false;
|
||||||
$asData = $this->retrieveFeed();
|
$asData = $this->retrieveFeed();
|
||||||
@@ -178,53 +200,53 @@ class Feed extends PhpObject {
|
|||||||
|
|
||||||
//Fix unstable Spot API Structure
|
//Fix unstable Spot API Structure
|
||||||
if(array_key_exists('message', $asMsgs)) $asMsgs = $asMsgs['message']; //Sometimes adds an extra "message" level
|
if(array_key_exists('message', $asMsgs)) $asMsgs = $asMsgs['message']; //Sometimes adds an extra "message" level
|
||||||
if(!array_key_exists(0, $asMsgs)) $asMsgs = array($asMsgs); //Jumps a level when there is only 1 message
|
if(!array_key_exists(0, $asMsgs)) $asMsgs = [$asMsgs]; //Jumps a level when there is only 1 message
|
||||||
|
|
||||||
//Update Spot, Feed & Messages
|
//Update Spot, Feed & Messages
|
||||||
if(!empty($asMsgs) && array_key_exists('messengerId', $asMsgs[0])) {
|
if(!empty($asMsgs) && array_key_exists('messengerId', $asMsgs[0])) {
|
||||||
|
|
||||||
//Update Spot Info from the first message
|
//Update Spot Info from the first message
|
||||||
$asSpotInfo = array(
|
$asSpotInfo = [
|
||||||
'ref_spot_id' => $asMsgs[0]['messengerId'],
|
'ref_spot_id' => $asMsgs[0]['messengerId'],
|
||||||
'name' => $asMsgs[0]['messengerName'],
|
'name' => $asMsgs[0]['messengerName'],
|
||||||
'model' => $asMsgs[0]['modelId']
|
'model' => $asMsgs[0]['modelId']
|
||||||
);
|
];
|
||||||
$iSpotId = $this->oDb->insertUpdateRow(self::SPOT_TABLE, $asSpotInfo, array('ref_spot_id'));
|
$iSpotId = $this->oDb->insertUpdateRow(self::SPOT_TABLE, $asSpotInfo, ['ref_spot_id']);
|
||||||
|
|
||||||
//Update Feed Info and last update date
|
//Update Feed Info and last update date
|
||||||
$asFeedInfo = array(
|
$asFeedInfo = [
|
||||||
'ref_feed_id' => $asFeed['id'],
|
'ref_feed_id' => $asFeed['id'],
|
||||||
Db::getId(self::SPOT_TABLE) => $iSpotId,
|
Db::getId(self::SPOT_TABLE) => $iSpotId,
|
||||||
'name' => $asFeed['name'],
|
'name' => $asFeed['name'],
|
||||||
'description' => $asFeed['description'],
|
'description' => $asFeed['description'],
|
||||||
'status' => $asFeed['status'],
|
'status' => $asFeed['status'],
|
||||||
'last_update' => $sNow
|
'last_update' => $sNow
|
||||||
);
|
];
|
||||||
$iFeedId = $this->oDb->insertUpdateRow(self::FEED_TABLE, $asFeedInfo, array('ref_feed_id'));
|
$iFeedId = $this->oDb->insertUpdateRow(self::FEED_TABLE, $asFeedInfo, ['ref_feed_id']);
|
||||||
|
|
||||||
//Update Messages
|
//Update Messages
|
||||||
foreach($asMsgs as $asMsg) {
|
foreach($asMsgs as $asMsg) {
|
||||||
$asMsg = array(
|
$asMsg = [
|
||||||
'ref_msg_id' => $asMsg['id'],
|
'ref_msg_id' => $asMsg['id'],
|
||||||
Db::getId(self::FEED_TABLE) => $iFeedId,
|
Db::getId(self::FEED_TABLE) => $iFeedId,
|
||||||
'type' => $asMsg['messageType'],
|
'type' => $asMsg['messageType'],
|
||||||
'latitude' => $asMsg['latitude'],
|
'latitude' => $asMsg['latitude'],
|
||||||
'longitude' => $asMsg['longitude'],
|
'longitude' => $asMsg['longitude'],
|
||||||
'iso_time' => $asMsg['dateTime'], //ISO 8601 time (backup)
|
'iso_time' => $asMsg['dateTime'], //ISO 8601 time (backup)
|
||||||
'site_time' => date(Db::TIMESTAMP_FORMAT, $asMsg['unixTime']), //Conversion to Site Time
|
'site_time' => date(Db::TIMESTAMP_FORMAT, $asMsg['unixTime']), //Conversion to Site Time
|
||||||
'timezone' => $this->getTimeZone(array($asMsg['latitude'], $asMsg['longitude']), $asMsg['unixTime']),
|
'timezone' => $this->getTimeZone($asMsg['latitude'], $asMsg['longitude']), //Get message time zone
|
||||||
'unix_time' => $asMsg['unixTime'], //UNIX Time (backup)
|
'unix_time' => $asMsg['unixTime'], //UNIX Time (backup)
|
||||||
'content' => $asMsg['messageContent'],
|
'content' => $asMsg['messageContent'],
|
||||||
'battery_state' => $asMsg['batteryState']
|
'battery_state' => $asMsg['batteryState']
|
||||||
);
|
];
|
||||||
|
|
||||||
$iMsgId = $this->oDb->selectId(self::MSG_TABLE, array('ref_msg_id'=>$asMsg['ref_msg_id']));
|
$iMsgId = $this->oDb->selectId(self::MSG_TABLE, ['ref_msg_id'=>$asMsg['ref_msg_id']]);
|
||||||
if(!$iMsgId) {
|
if(!$iMsgId) {
|
||||||
//First Catch
|
//First Catch
|
||||||
$asMsg['posted_on'] = $sNow;
|
$asMsg['posted_on'] = $sNow;
|
||||||
|
|
||||||
//Weather Data
|
//Weather Data
|
||||||
$asMsg = array_merge($asMsg, $this->getWeather(array($asMsg['latitude'], $asMsg['longitude']), $asMsg['unix_time']));
|
$asMsg = array_merge($asMsg, $this->getWeather([$asMsg['latitude'], $asMsg['longitude']], $asMsg['unix_time']));
|
||||||
|
|
||||||
$this->oDb->insertRow(self::MSG_TABLE, $asMsg);
|
$this->oDb->insertRow(self::MSG_TABLE, $asMsg);
|
||||||
$bNewMsg = true;
|
$bNewMsg = true;
|
||||||
@@ -233,7 +255,7 @@ class Feed extends PhpObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), array('last_update'=>$sNow));
|
else $this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), ['last_update'=>$sNow]);
|
||||||
|
|
||||||
return $bNewMsg;
|
return $bNewMsg;
|
||||||
}
|
}
|
||||||
@@ -256,20 +278,22 @@ class Feed extends PhpObject {
|
|||||||
$sWeatherIcon = 'unknown';
|
$sWeatherIcon = 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get Condition ID
|
//Get Condition Language ID
|
||||||
$sCondKey = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($sWeatherCond);
|
$sCondLangId = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($sWeatherCond);
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'weather_icon' => $sWeatherIcon,
|
'weather_icon' => $sWeatherIcon,
|
||||||
'weather_cond' => $sCondKey,
|
'weather_cond' => $sCondLangId,
|
||||||
'weather_temp' => floatval($sWeatherTemp)
|
'weather_temp' => floatval($sWeatherTemp)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTimeZone($asLatLng, $iTimeStamp) {
|
private function getTimeZone($iLat, $iLng) {
|
||||||
$asParams = self::TIMEZONE_PARAM;
|
$asParams = [
|
||||||
$asParams['lat'] = $asLatLng[0];
|
'username' => Settings::TIMEZONE_USER,
|
||||||
$asParams['lng'] = $asLatLng[1];
|
'lat' => $iLat,
|
||||||
|
'lng' => $iLng
|
||||||
|
];
|
||||||
$sApiUrl = self::TIMEZONE_HOOK.'?'.http_build_query($asParams);
|
$sApiUrl = self::TIMEZONE_HOOK.'?'.http_build_query($asParams);
|
||||||
|
|
||||||
$asTimeZone = json_decode(file_get_contents($sApiUrl), true);
|
$asTimeZone = json_decode(file_get_contents($sApiUrl), true);
|
||||||
@@ -278,32 +302,40 @@ class Feed extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function retrieveFeed() {
|
private function retrieveFeed() {
|
||||||
$sContent = '[]';
|
if($this->sRefFeedId == '') {
|
||||||
if($this->sRefFeedId !='') {
|
$sContent = '{"response":{"errors":{"error":{"code":"","text":"Feed reference ID missing","description":"Feed reference ID missing"}}}}';
|
||||||
|
}
|
||||||
|
else {
|
||||||
$sUrl = self::FEED_HOOK.$this->sRefFeedId.self::FEED_TYPE_JSON;
|
$sUrl = self::FEED_HOOK.$this->sRefFeedId.self::FEED_TYPE_JSON;
|
||||||
$sContent = file_get_contents($sUrl);
|
$sContent = file_get_contents($sUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_decode($sContent, true);
|
return json_decode($sContent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateField($sField, $oValue) {
|
private function updateField($sField, $oValue) {
|
||||||
$bResult = ($this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), array($sField=>$oValue)) > 0);
|
$bResult = ($this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), [$sField=>$oValue]) > 0);
|
||||||
$this->setFeedId($this->getFeedId());
|
$this->setFeedId($this->getFeedId());
|
||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$asResult = array();
|
$bSuccess = false;
|
||||||
if($this->getFeedId() > 0) {
|
$sLangId = '';
|
||||||
$asResult = array(
|
$asLangParams = [];
|
||||||
'id' => $this->getFeedId(),
|
$asData = [];
|
||||||
'del' => $this->oDb->deleteRow(self::FEED_TABLE, $this->getFeedId()),
|
|
||||||
'desc' => $this->oDb->getLastError()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else $asResult = array('del'=>false, 'desc'=>'Error while setting project: no Feed ID');
|
|
||||||
|
|
||||||
return $asResult;
|
if($this->getFeedId() > 0) {
|
||||||
|
$asData['id'] = $this->getFeedId();
|
||||||
|
$bSuccess = $this->oDb->deleteRow(self::FEED_TABLE, $this->getFeedId());
|
||||||
|
if(!$bSuccess) $sLangId = 'error.commit_db';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sLangId = 'error.impossible_value';
|
||||||
|
$asLangParams = [$this->getFeedId(), 'feed ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Livetrail::getResult($bSuccess, $sLangId, $asData, $asLangParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Franzz\Livetrail;
|
||||||
|
use Franzz\Objects\PhpObject;
|
||||||
|
use \Settings;
|
||||||
|
|
||||||
|
abstract class Geo extends PhpObject {
|
||||||
|
protected const EXT = '';
|
||||||
|
|
||||||
|
protected const GEO_FOLDER = 'geo';
|
||||||
|
protected const OPT_SIMPLE = 'simplification';
|
||||||
|
|
||||||
|
protected array $asTracks;
|
||||||
|
protected string $sFilePath;
|
||||||
|
|
||||||
|
public function __construct(string $sCodeName) {
|
||||||
|
parent::__construct(get_class($this), Settings::DEBUG, PhpObject::MODE_HTML);
|
||||||
|
$this->sFilePath = self::getBackEndFilePath($sCodeName);
|
||||||
|
$this->asTracks = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Access from backend
|
||||||
|
public static function getBackendFilePath(string $sCodeName) {
|
||||||
|
return '../resources/'.self::GEO_FOLDER.'/'.$sCodeName.static::EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Access from frontend (/public/geo is a symlink of /resources/geo)
|
||||||
|
public static function getFrontendFilePath(string $sCodeName) {
|
||||||
|
return self::GEO_FOLDER.'/'.$sCodeName.static::EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLog() {
|
||||||
|
return $this->getCleanMessageStack(PhpObject::NOTICE_TAB);
|
||||||
|
}
|
||||||
|
}
|
||||||
+230
@@ -0,0 +1,230 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Franzz\Livetrail;
|
||||||
|
|
||||||
|
class GeoJson extends Geo {
|
||||||
|
protected const EXT = '.geojson';
|
||||||
|
|
||||||
|
private const MAX_FILESIZE = 2; //MB
|
||||||
|
private const MAX_DEVIATION_FLAT = 0.1; //10%
|
||||||
|
private const MAX_DEVIATION_ELEV = 0.1; //10%
|
||||||
|
|
||||||
|
public function __construct($sCodeName) {
|
||||||
|
parent::__construct($sCodeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveFile() {
|
||||||
|
$this->addNotice('Saving '.$this->sFilePath);
|
||||||
|
file_put_contents($this->sFilePath, $this->buildGeoJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSimplicationRequired() {
|
||||||
|
//Size in bytes
|
||||||
|
$iFileSize = strlen($this->buildGeoJson());
|
||||||
|
|
||||||
|
//Convert to MB
|
||||||
|
$iFileSize = round($iFileSize / pow(1024, 2), 2);
|
||||||
|
|
||||||
|
//Compare with max allowed size
|
||||||
|
$bFileTooLarge = ($iFileSize > self::MAX_FILESIZE);
|
||||||
|
if($bFileTooLarge) $this->addNotice('Output file is too large ('.$iFileSize.'MB > '.self::MAX_FILESIZE.'MB)');
|
||||||
|
|
||||||
|
return $bFileTooLarge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildTracks($asTracks, $bSimplify=false) {
|
||||||
|
$this->addNotice('Creating '.($bSimplify?'Simplified ':'').'GeoJson Tracks');
|
||||||
|
|
||||||
|
$iGlobalInvalidPointCount = 0;
|
||||||
|
$iGlobalPointCount = 0;
|
||||||
|
|
||||||
|
$this->asTracks = [];
|
||||||
|
foreach($asTracks as $asTrackProps) {
|
||||||
|
$asOptions = $this->parseOptions($asTrackProps['cmt']);
|
||||||
|
|
||||||
|
//Color mapping
|
||||||
|
switch($asTrackProps['color']) {
|
||||||
|
case 'DarkBlue':
|
||||||
|
$sType = 'main';
|
||||||
|
break;
|
||||||
|
case 'Magenta':
|
||||||
|
if($bSimplify && $asOptions[self::OPT_SIMPLE]!='keep') {
|
||||||
|
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (off-track)');
|
||||||
|
continue 2; //discard tracks
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sType = 'off-track';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Red':
|
||||||
|
$sType = 'hitchhiking';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (unknown color "'.$asTrackProps['color'].'")');
|
||||||
|
continue 2; //discard tracks
|
||||||
|
}
|
||||||
|
|
||||||
|
$asTrack = [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'properties' => [
|
||||||
|
'name' => $asTrackProps['name'],
|
||||||
|
'type' => $sType,
|
||||||
|
'description' => $asTrackProps['desc']
|
||||||
|
],
|
||||||
|
'geometry' => [
|
||||||
|
'type' => 'LineString',
|
||||||
|
'coordinates' => []
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
if($sType != 'hitchhiking' && str_contains($asTrackProps['desc'], ' ➜ ')) {
|
||||||
|
list($sFrom, $sTo) = explode(' ➜ ', $asTrackProps['desc']);
|
||||||
|
$asTrack['properties']['leg'] = ['from'=> $sFrom, 'to'=> $sTo];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Track points
|
||||||
|
$asTrackPoints = $asTrackProps['points'];
|
||||||
|
$iPointCount = count($asTrackPoints);
|
||||||
|
$iInvalidPointCount = 0;
|
||||||
|
$asPrevPoint = [];
|
||||||
|
foreach($asTrackPoints as $iIndex=>$asPoint) {
|
||||||
|
$asNextPoint = ($iIndex < ($iPointCount - 1))?$asTrackPoints[$iIndex + 1]:[];
|
||||||
|
if($bSimplify && !empty($asPrevPoint) && !empty($asNextPoint)) {
|
||||||
|
if(!$this->isPointValid($asPrevPoint, $asPoint, $asNextPoint)) {
|
||||||
|
$iInvalidPointCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$asTrack['geometry']['coordinates'][] = array_values($asPoint);
|
||||||
|
$asPrevPoint = $asPoint;
|
||||||
|
}
|
||||||
|
$this->asTracks[] = $asTrack;
|
||||||
|
|
||||||
|
$iGlobalInvalidPointCount += $iInvalidPointCount;
|
||||||
|
$iGlobalPointCount += $iPointCount;
|
||||||
|
if($iInvalidPointCount > 0) $this->addNotice('Removing '.$iInvalidPointCount.'/'.$iPointCount.' points ('.round($iInvalidPointCount / $iPointCount * 100, 1).'%) from '.$asTrackProps['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($bSimplify) $this->addNotice('Total: '.$iGlobalInvalidPointCount.'/'.$iGlobalPointCount.' points removed ('.round($iGlobalInvalidPointCount / $iGlobalPointCount * 100, 1).'%)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sortOffTracks() {
|
||||||
|
$this->addNotice('Sorting off-tracks');
|
||||||
|
|
||||||
|
//Find first & last track points
|
||||||
|
$asTracksEnds = [];
|
||||||
|
$asTracks = [];
|
||||||
|
foreach($this->asTracks as $iTrackId=>$asTrack) {
|
||||||
|
$sTrackId = 't'.$iTrackId;
|
||||||
|
$asTracksEnds[$sTrackId] = ['first'=>reset($asTrack['geometry']['coordinates']), 'last'=>end($asTrack['geometry']['coordinates'])];
|
||||||
|
$asTracks[$sTrackId] = $asTrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find variants close-by tracks
|
||||||
|
$asClonedTracks = $asTracks;
|
||||||
|
foreach($asClonedTracks as $sTrackId=>$asTrack) {
|
||||||
|
if($asTrack['properties']['type'] != 'off-track') continue;
|
||||||
|
|
||||||
|
$iMinDistance = INF;
|
||||||
|
$sConnectedTrackId = 0;
|
||||||
|
$iPosition = 0;
|
||||||
|
|
||||||
|
//Test all track ending points to find the closest
|
||||||
|
foreach($asTracksEnds as $sTrackEndId=>$asTrackEnds) {
|
||||||
|
if($sTrackEndId != $sTrackId) {
|
||||||
|
//Calculate distance between the last point of the track and every starting point of other tracks
|
||||||
|
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['last'], $asTrackEnds['first']);
|
||||||
|
if($iDistance < $iMinDistance) {
|
||||||
|
$sConnectedTrackId = $sTrackEndId;
|
||||||
|
$iPosition = 0; //Track before the Connected Track
|
||||||
|
$iMinDistance = $iDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calculate distance between the first point of the track and every ending point of other tracks
|
||||||
|
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['first'], $asTrackEnds['last']);
|
||||||
|
if($iDistance < $iMinDistance) {
|
||||||
|
$sConnectedTrackId = $sTrackEndId;
|
||||||
|
$iPosition = +1; //Track after the Connected Track
|
||||||
|
$iMinDistance = $iDistance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Move track
|
||||||
|
unset($asTracks[$sTrackId]);
|
||||||
|
$iOffset = array_search($sConnectedTrackId, array_keys($asTracks)) + $iPosition;
|
||||||
|
$asTracks = array_slice($asTracks, 0, $iOffset) + [$sTrackId => $asTrack] + array_slice($asTracks, $iOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->asTracks = array_values($asTracks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCenter() {
|
||||||
|
$asCoords = [];
|
||||||
|
$asMainTracks = array_filter($this->asTracks, function ($astrack) {return $astrack['properties']['type'] == 'main';});
|
||||||
|
foreach($asMainTracks as $asMainTrack) {
|
||||||
|
foreach($asMainTrack['geometry']['coordinates'] as $aiCoords) {
|
||||||
|
$asCoords[] = $aiCoords;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $asCoords[(int) floor(count($asCoords) / 2)];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseOptions($sComment) {
|
||||||
|
$sComment = strip_tags(html_entity_decode($sComment));
|
||||||
|
$asOptions = [self::OPT_SIMPLE=>''];
|
||||||
|
foreach(explode("\n", $sComment) as $sLine) {
|
||||||
|
$asOptions[mb_strtolower(trim(mb_strstr($sLine, ':', true)))] = mb_strtolower(trim(mb_substr(mb_strstr($sLine, ':'), 1)));
|
||||||
|
}
|
||||||
|
return $asOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
||||||
|
/* A----O Calculate angle AO^OB
|
||||||
|
* \ If angle is within [90% Pi ; 110% Pi], O can be discarded
|
||||||
|
* \ O is valid otherwise
|
||||||
|
* B
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Path Turn Check -> -> -> ->
|
||||||
|
//Law of Cosines (vector): angle = arccos(OA.OB / ||OA||.||OB||)
|
||||||
|
$fVectorOA = ['lon'=>($asPointA['lon'] - $asPointO['lon']), 'lat'=> ($asPointA['lat'] - $asPointO['lat'])];
|
||||||
|
$fVectorOB = ['lon'=>($asPointB['lon'] - $asPointO['lon']), 'lat'=> ($asPointB['lat'] - $asPointO['lat'])];
|
||||||
|
|
||||||
|
$fLengthOA = sqrt(pow($asPointA['lon'] - $asPointO['lon'], 2) + pow($asPointA['lat'] - $asPointO['lat'], 2));
|
||||||
|
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
|
||||||
|
|
||||||
|
$fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat'];
|
||||||
|
$fAngleAOB = ($fLengthOA != 0 && $fLengthOB != 0) ? acos($fVectorOAxOB/($fLengthOA * $fLengthOB)) : 0;
|
||||||
|
|
||||||
|
//Elevation Check
|
||||||
|
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
|
||||||
|
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
|
||||||
|
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2));
|
||||||
|
$fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2));
|
||||||
|
$fAngleAOBElev = ($fLengthOB != 0 && $fLengthAO != 0) ? (acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO))) : 0;
|
||||||
|
|
||||||
|
return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI ||
|
||||||
|
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildGeoJson() {
|
||||||
|
return json_encode(['type'=>'FeatureCollection', 'features'=>$this->asTracks]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getDistance($asPointA, $asPointB) {
|
||||||
|
$fLatFrom = $asPointA[1];
|
||||||
|
$fLonFrom = $asPointA[0];
|
||||||
|
$fLatTo = $asPointB[1];
|
||||||
|
$fLonTo = $asPointB[0];
|
||||||
|
|
||||||
|
$fRad = M_PI / 180;
|
||||||
|
|
||||||
|
//Calculate distance from latitude and longitude
|
||||||
|
$fTheta = $fLonFrom - $fLonTo;
|
||||||
|
$fDistance = sin($fLatFrom * $fRad) * sin($fLatTo * $fRad) + cos($fLatFrom * $fRad) * cos($fLatTo * $fRad) * cos($fTheta * $fRad);
|
||||||
|
|
||||||
|
return acos($fDistance) / $fRad * 60 * 1.853;
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Franzz\Livetrail;
|
||||||
|
use Franzz\Objects\ToolBox;
|
||||||
|
|
||||||
|
class Gpx extends Geo {
|
||||||
|
|
||||||
|
public const EXT = '.gpx';
|
||||||
|
|
||||||
|
public function __construct($sCodeName) {
|
||||||
|
parent::__construct($sCodeName);
|
||||||
|
$this->parseFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTracks() {
|
||||||
|
return $this->asTracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseFile() {
|
||||||
|
$this->addNotice('Parsing: '.$this->sFilePath);
|
||||||
|
if(!file_exists($this->sFilePath)) $this->addError($this->sFilePath.' file missing');
|
||||||
|
else {
|
||||||
|
$oXml = simplexml_load_file($this->sFilePath);
|
||||||
|
|
||||||
|
//Tracks
|
||||||
|
$this->addNotice('Converting '.count($oXml->trk).' tracks');
|
||||||
|
foreach($oXml->trk as $aoTrack) {
|
||||||
|
$asTrack = [
|
||||||
|
'name' => (string) $aoTrack->name,
|
||||||
|
'desc' => str_replace("\n", '', ToolBox::fixEOL((strip_tags($aoTrack->desc)))),
|
||||||
|
'cmt' => ToolBox::fixEOL((strip_tags($aoTrack->cmt))),
|
||||||
|
'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor,
|
||||||
|
'points'=> []
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($aoTrack->trkseg as $asSegment) {
|
||||||
|
foreach($asSegment as $asPoint) {
|
||||||
|
$asTrack['points'][] = [
|
||||||
|
'lon' => (float) $asPoint['lon'],
|
||||||
|
'lat' => (float) $asPoint['lat'],
|
||||||
|
'ele' => (int) $asPoint->ele
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->asTracks[] = $asTrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Waypoints
|
||||||
|
$this->addNotice('Ignoring '.count($oXml->wpt).' waypoints');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+952
@@ -0,0 +1,952 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Franzz\Livetrail;
|
||||||
|
use Franzz\Objects\Db;
|
||||||
|
use Franzz\Objects\Main;
|
||||||
|
use Franzz\Objects\Translator;
|
||||||
|
use Franzz\Objects\ToolBox;
|
||||||
|
use \Settings;
|
||||||
|
|
||||||
|
/* Timezones
|
||||||
|
* ---------
|
||||||
|
* Site Time: Timestamp converted to the Timezone from which the user is viewing the Site (default PHP/SQL Timezone)
|
||||||
|
* Local Time: Timestamp converted to the Timezone from which the content (media/post/message) has been sent (Local Timezone stored in timezone field)
|
||||||
|
*
|
||||||
|
* - Feeds (table `feeds`):
|
||||||
|
* - last_update: timestamp in Site Time
|
||||||
|
* - Spot Messages (table `messages`):
|
||||||
|
* - unix_time: UNIX (int) in UTC
|
||||||
|
* - site_time: timestamp in Site Time
|
||||||
|
* - iso_time: raw ISO 8601 in UTC or Local Time (spot messages are unreliable, timezone is then calculated from GPS coordinates)
|
||||||
|
* - posted_on: timestamp in Site Time
|
||||||
|
* - timezone: Local Timezone
|
||||||
|
* - Medias (table `medias`):
|
||||||
|
* - posted_on: timestamp in Site Time
|
||||||
|
* - taken_on: timestamp in Site Time
|
||||||
|
* - timezone: Local Timezone
|
||||||
|
* - Posts (table `posts`):
|
||||||
|
* - site_time: timestamp in Site Time
|
||||||
|
* - timezone: Local Timezone
|
||||||
|
* - Users (table `users`):
|
||||||
|
* - timezone: Site Timezone (stored user's timezone for emails)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Livetrail extends Main {
|
||||||
|
//Database
|
||||||
|
public const POST_TABLE = 'posts';
|
||||||
|
private const REF_TYPES = ['post', 'media', 'message'];
|
||||||
|
|
||||||
|
private const FEED_CHUNK_SIZE = 15;
|
||||||
|
private const MAIL_CHUNK_SIZE = 5;
|
||||||
|
|
||||||
|
public const DEFAULT_LANG = 'en';
|
||||||
|
public const PROJECT_NAME = 'LiveTrail';
|
||||||
|
|
||||||
|
private const MAIN_PAGE = 'index';
|
||||||
|
private const VITE_APP = 'src/app.js';
|
||||||
|
|
||||||
|
private Project $oProject;
|
||||||
|
private Media $oMedia;
|
||||||
|
private User $oUser;
|
||||||
|
private Map $oMap;
|
||||||
|
|
||||||
|
public function __construct($sProcessPage, $sTimezone) {
|
||||||
|
parent::__construct($sProcessPage, true, $sTimezone);
|
||||||
|
|
||||||
|
$this->oUser = new User($this->oDb);
|
||||||
|
|
||||||
|
$this->oLang = new Translator('', self::DEFAULT_LANG);
|
||||||
|
|
||||||
|
$this->oProject = new Project($this->oDb);
|
||||||
|
$this->oMedia = new Media($this->oDb, $this->oProject);
|
||||||
|
|
||||||
|
$this->oMap = new Map($this->oDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function install() {
|
||||||
|
//Install DB
|
||||||
|
$this->oDb->install();
|
||||||
|
|
||||||
|
//Add first user
|
||||||
|
$iUserId = $this->oDb->insertRow(User::USER_TABLE, [
|
||||||
|
'name' => 'Admin',
|
||||||
|
'email' => 'admin@admin.com',
|
||||||
|
'language' => self::DEFAULT_LANG,
|
||||||
|
'timezone' => date_default_timezone_get(),
|
||||||
|
'subscribed'=> User::USER_SUBSCRIBED,
|
||||||
|
'clearance' => User::CLEARANCE_ADMIN
|
||||||
|
]);
|
||||||
|
$this->oUser->setUserId($iUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSqlOptions() {
|
||||||
|
return
|
||||||
|
[
|
||||||
|
'tables' =>
|
||||||
|
[
|
||||||
|
Feed::MSG_TABLE => ['ref_msg_id', Db::getId(Feed::FEED_TABLE), 'type', 'latitude', 'longitude', 'iso_time', 'site_time', 'timezone', 'unix_time', 'content', 'battery_state', 'posted_on', 'weather_icon', 'weather_cond', 'weather_temp', 'display'],
|
||||||
|
Feed::FEED_TABLE => ['ref_feed_id', Db::getId(Feed::SPOT_TABLE), Db::getId(Project::PROJ_TABLE), 'name', 'description', 'status', 'last_update'],
|
||||||
|
Feed::SPOT_TABLE => ['ref_spot_id', 'name', 'model'],
|
||||||
|
Project::PROJ_TABLE => ['name', 'codename', 'active_from', 'active_to'],
|
||||||
|
self::POST_TABLE => [Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone', 'ref_id', 'ref_type'],
|
||||||
|
Media::MEDIA_TABLE => [Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'latitude', 'longitude', 'altitude', 'width', 'height', 'rotate', 'comment'],
|
||||||
|
User::USER_TABLE => ['name', 'email', 'password', 'token', 'token_exp', 'gravatar', 'language', 'timezone', 'subscribed', 'clearance'],
|
||||||
|
Map::MAP_TABLE => ['codename', 'pattern', 'token', 'tile_size', 'min_zoom', 'max_zoom', 'attribution'],
|
||||||
|
Map::MAPPING_TABLE => [Db::getId(Map::MAP_TABLE) , Db::getId(Project::PROJ_TABLE)]
|
||||||
|
],
|
||||||
|
'types' =>
|
||||||
|
[
|
||||||
|
'clearance' => 'TINYINT(1) DEFAULT '.User::CLEARANCE_USER,
|
||||||
|
'active_from' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'active_to' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'battery_state' => 'VARCHAR(10)',
|
||||||
|
'codename' => 'VARCHAR(100)',
|
||||||
|
'content' => 'LONGTEXT',
|
||||||
|
'comment' => 'LONGTEXT',
|
||||||
|
'description' => 'VARCHAR(100)',
|
||||||
|
'email' => 'VARCHAR(320) NOT NULL',
|
||||||
|
'filename' => 'VARCHAR(100) NOT NULL',
|
||||||
|
'iso_time' => 'VARCHAR(24)',
|
||||||
|
'language' => 'VARCHAR(2)',
|
||||||
|
'last_update' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'latitude' => 'DECIMAL(8,6)',
|
||||||
|
'longitude' => 'DECIMAL(9,6)',
|
||||||
|
'altitude' => 'SMALLINT',
|
||||||
|
'model' => 'VARCHAR(20)',
|
||||||
|
'name' => 'VARCHAR(100)',
|
||||||
|
'pattern' => 'VARCHAR(200) NOT NULL',
|
||||||
|
'password' => "VARCHAR(255) NOT NULL DEFAULT ''",
|
||||||
|
'posted_on' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'ref_feed_id' => 'VARCHAR(40)',
|
||||||
|
'ref_msg_id' => 'VARCHAR(15)',
|
||||||
|
'ref_spot_id' => 'VARCHAR(10)',
|
||||||
|
'ref_id' => 'INT UNSIGNED',
|
||||||
|
'ref_type' => 'VARCHAR(20)',
|
||||||
|
'rotate' => 'SMALLINT',
|
||||||
|
'site_time' => 'TIMESTAMP DEFAULT 0', //DEFAULT 0 removes auto-set to current time
|
||||||
|
'status' => 'VARCHAR(10)',
|
||||||
|
'subscribed' => 'BOOLEAN DEFAULT '.User::USER_UNSUBSCRIBED,
|
||||||
|
'taken_on' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'timezone' => 'CHAR(64) NOT NULL', //see mysql.time_zone_name
|
||||||
|
'token' => 'VARCHAR(4096)',
|
||||||
|
'token_exp' => 'TIMESTAMP DEFAULT 0',
|
||||||
|
'type' => 'VARCHAR(20)',
|
||||||
|
'unix_time' => 'INT',
|
||||||
|
'min_zoom' => 'TINYINT UNSIGNED',
|
||||||
|
'max_zoom' => 'TINYINT UNSIGNED',
|
||||||
|
'attribution' => 'VARCHAR(100)',
|
||||||
|
'gravatar' => 'LONGTEXT',
|
||||||
|
'weather_icon' => 'VARCHAR(30)',
|
||||||
|
'weather_cond' => 'VARCHAR(30)',
|
||||||
|
'weather_temp' => 'DECIMAL(3,1)',
|
||||||
|
'tile_size' => 'SMALLINT UNSIGNED DEFAULT 256',
|
||||||
|
'width' => 'INT',
|
||||||
|
'height' => 'INT',
|
||||||
|
'display' => 'BOOLEAN DEFAULT '.Feed::MSG_DISPLAYED
|
||||||
|
],
|
||||||
|
'constraints' =>
|
||||||
|
[
|
||||||
|
Feed::MSG_TABLE => ['UNIQUE KEY `uni_ref_msg_id` (`ref_msg_id`)', 'INDEX(`ref_msg_id`)'],
|
||||||
|
Feed::FEED_TABLE => ['UNIQUE KEY `uni_ref_feed_id` (`ref_feed_id`)', 'INDEX(`ref_feed_id`)'],
|
||||||
|
Feed::SPOT_TABLE => ['UNIQUE KEY `uni_ref_spot_id` (`ref_spot_id`)', 'INDEX(`ref_spot_id`)'],
|
||||||
|
Project::PROJ_TABLE => 'UNIQUE KEY `uni_proj_name` (`codename`)',
|
||||||
|
Media::MEDIA_TABLE => 'UNIQUE KEY `uni_file_name` (`filename`)',
|
||||||
|
User::USER_TABLE => 'UNIQUE KEY `uni_email` (`email`)',
|
||||||
|
Map::MAP_TABLE => 'UNIQUE KEY `uni_map_name` (`codename`)',
|
||||||
|
Map::MAPPING_TABLE => 'default_on_generic_map_only CHECK (`default_map` = 0 OR `id_project` IS NULL)'
|
||||||
|
],
|
||||||
|
'cascading_delete' =>
|
||||||
|
[
|
||||||
|
Feed::SPOT_TABLE => [Feed::FEED_TABLE],
|
||||||
|
Feed::FEED_TABLE => [Feed::MSG_TABLE],
|
||||||
|
Project::PROJ_TABLE => [Feed::FEED_TABLE, Media::MEDIA_TABLE, self::POST_TABLE, Map::MAPPING_TABLE],
|
||||||
|
Map::MAP_TABLE => [Map::MAPPING_TABLE]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAppMainPage(string $sCsrfToken='') {
|
||||||
|
$asViteAssets = $this->getViteAssets();
|
||||||
|
|
||||||
|
return parent::getMainPage(
|
||||||
|
[
|
||||||
|
'projects' => $this->oProject->getProjects(),
|
||||||
|
'user' => $this->oUser->getUserInfo(),
|
||||||
|
'consts' => [
|
||||||
|
'modes' => Project::MODES,
|
||||||
|
'clearances' => User::CLEARANCES,
|
||||||
|
'default_timezone' => Settings::TIMEZONE,
|
||||||
|
'default_maps' => $this->oMap->getProjectMaps(-1),
|
||||||
|
'chunk_size' => self::FEED_CHUNK_SIZE,
|
||||||
|
'hash_sep' => '-',
|
||||||
|
'title' => self::PROJECT_NAME,
|
||||||
|
'default_page' => 'project',
|
||||||
|
'csrf_token' => $sCsrfToken
|
||||||
|
]
|
||||||
|
],
|
||||||
|
self::MAIN_PAGE,
|
||||||
|
[
|
||||||
|
'tags' => [
|
||||||
|
'language' => $this->oLang->getLanguage(),
|
||||||
|
'title' => self::PROJECT_NAME,
|
||||||
|
'app_entry' => $asViteAssets['app']
|
||||||
|
],
|
||||||
|
'instances' => [
|
||||||
|
'css' => $asViteAssets['css'],
|
||||||
|
'module' => $asViteAssets['module']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getViteAssets() {
|
||||||
|
$asManifest = json_decode(file_get_contents(__DIR__.'/../public/.vite/manifest.json'), true);
|
||||||
|
$asAppImport = $asManifest[self::VITE_APP];
|
||||||
|
|
||||||
|
//Recursive search for chunk imports
|
||||||
|
$asImports = [];
|
||||||
|
$asSeenImports = [self::VITE_APP => true];
|
||||||
|
$this->appendViteImportedChunks($asManifest, $asAppImport, $asSeenImports, $asImports);
|
||||||
|
|
||||||
|
//CSS
|
||||||
|
$asCssFiles = [];
|
||||||
|
foreach(array_merge([$asAppImport], $asImports) as $asChunk) {
|
||||||
|
foreach($asChunk['css'] ?? [] as $sCssFile) $asCssFiles[] = $sCssFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Modules
|
||||||
|
$asModuleFiles = [];
|
||||||
|
foreach($asImports as $asImport) {
|
||||||
|
if(str_ends_with($asImport['file'] ?? '', '.js')) $asModuleFiles[] = $asImport['file'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'app' => $asAppImport['file'],
|
||||||
|
'css' => $this->getViteAssetInstances($asCssFiles),
|
||||||
|
'module' => $this->getViteAssetInstances($asModuleFiles)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function appendViteImportedChunks($asManifest, $asChunk, &$asSeenImports, &$asImports) {
|
||||||
|
foreach($asChunk['imports'] ?? [] as $sImport) {
|
||||||
|
if(isset($asSeenImports[$sImport]) || !isset($asManifest[$sImport])) continue;
|
||||||
|
|
||||||
|
$asSeenImports[$sImport] = true;
|
||||||
|
$this->appendViteImportedChunks($asManifest, $asManifest[$sImport], $asSeenImports, $asImports);
|
||||||
|
$asImports[] = $asManifest[$sImport];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getViteAssetInstances($asFilePaths) {
|
||||||
|
return array_map(
|
||||||
|
function($sFilePath) { return ['filename' => $sFilePath]; },
|
||||||
|
$asFilePaths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkUserClearance($iClearance) {
|
||||||
|
return $this->oUser->checkUserClearance($iClearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Managing projects */
|
||||||
|
|
||||||
|
public function setProjectId($iProjectId=0) {
|
||||||
|
$this->oProject->setProjectId($iProjectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateProject() {
|
||||||
|
$bNewMsg = false;
|
||||||
|
$bSuccess = true;
|
||||||
|
$sLangId = '';
|
||||||
|
|
||||||
|
//Update all feeds belonging to the project
|
||||||
|
$asFeeds = $this->oProject->getFeedIds();
|
||||||
|
foreach($asFeeds as $iFeedId) {
|
||||||
|
$oFeed = new Feed($this->oDb, $iFeedId);
|
||||||
|
$bNewMsg = $bNewMsg || $oFeed->checkUpdateFeed($this->oProject->getMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send Update Email
|
||||||
|
if($bNewMsg) {
|
||||||
|
$bSuccess = $this->sendEmail();
|
||||||
|
$sLangId = $bSuccess?'email.sent':'email.failure';
|
||||||
|
}
|
||||||
|
else $sLangId = 'spot.no_new_msg';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sLangId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendEmail() {
|
||||||
|
$oEmail = new Email($this->asContext['serv_name'], 'email.update');
|
||||||
|
$oEmail->setDestInfo($this->oUser->getSubscribedUsersInfo());
|
||||||
|
|
||||||
|
//Add Position
|
||||||
|
$asSpotMessages = $this->getSpotMessages([$this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE))]);
|
||||||
|
$asLastMessage = array_shift($asSpotMessages);
|
||||||
|
$oEmail->oTemplate->setTags($asLastMessage);
|
||||||
|
$oEmail->oTemplate->setTag('date_time', 'time:'.$asLastMessage['unix_time'], 'd/m/Y, H:i');
|
||||||
|
|
||||||
|
//Add latest news feed
|
||||||
|
$asNews = $this->getNextFeed(0, true);
|
||||||
|
$iPostCount = 0;
|
||||||
|
foreach($asNews as $asPost) {
|
||||||
|
if($asPost['type'] != 'message') {
|
||||||
|
$oEmail->oTemplate->newInstance('news');
|
||||||
|
$oEmail->oTemplate->setInstanceTags('news', [
|
||||||
|
'local_server' => $this->asContext['serv_name'],
|
||||||
|
'project' => $this->oProject->getProjectCodeName(),
|
||||||
|
'type' => $asPost['type'],
|
||||||
|
'id' => $asPost['id_'.$asPost['type']]]
|
||||||
|
);
|
||||||
|
$oEmail->oTemplate->addInstance($asPost['type'], $asPost);
|
||||||
|
$oEmail->oTemplate->setInstanceTag($asPost['type'], 'local_server', $this->asContext['serv_name']);
|
||||||
|
$iPostCount++;
|
||||||
|
}
|
||||||
|
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $oEmail->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMarkers($asMessageIds=[], $asMediaIds=[], $bInternal=false) {
|
||||||
|
//Get messages
|
||||||
|
$asMessages = $this->getSpotMessages($asMessageIds);
|
||||||
|
foreach($asMessages as &$asMessage) {
|
||||||
|
$asMessage['id'] = $asMessage[Db::getId(Feed::MSG_TABLE)];
|
||||||
|
$asMessage['type'] = 'message';
|
||||||
|
$asMessage['subtype'] = 'message';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get Geo-positioned Medias
|
||||||
|
//FIXME Make more efficient than requesting images twice from DB
|
||||||
|
$asMedias = $this->getMedias('taken_on', $asMediaIds);
|
||||||
|
$asGeoMedias = $this->getMedias('posted_on', $asMediaIds, true);
|
||||||
|
foreach($asGeoMedias as &$asGeoMedia) {
|
||||||
|
$iId = $asGeoMedia[Db::getId(Media::MEDIA_TABLE)];
|
||||||
|
unset($asGeoMedia[Db::getId(Media::MEDIA_TABLE)]);
|
||||||
|
|
||||||
|
$asGeoMedia['id'] = $iId;
|
||||||
|
$asGeoMedia['type'] = 'media';
|
||||||
|
$asGeoMedia['medias'] = array_values(array_filter($asMedias, function($asMedia) use ($iId) {
|
||||||
|
return $asMedia['id_media'] == $iId;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Assign medias to closest message
|
||||||
|
if(!empty($asMessages)) {
|
||||||
|
usort($asMessages, function($a, $b) {return (int) $a['unix_time'] <=> (int) $b['unix_time'];});
|
||||||
|
usort($asMedias, function($a, $b) {return (int) $a['unix_time'] <=> (int) $b['unix_time'];});
|
||||||
|
|
||||||
|
$iIndex = 0;
|
||||||
|
$iMaxIndex = count($asMessages) - 1;
|
||||||
|
foreach($asMedias as $asMedia) {
|
||||||
|
while($iIndex <= $iMaxIndex && $asMedia['unix_time'] > $asMessages[$iIndex]['unix_time']) $iIndex++;
|
||||||
|
|
||||||
|
//All medias before first message or after last message are assigned to first/last message respectively
|
||||||
|
if($iIndex == 0) $iMsgIndex = $iIndex;
|
||||||
|
elseif($iIndex > $iMaxIndex) $iMsgIndex = $iMaxIndex;
|
||||||
|
else {
|
||||||
|
$iHalfWayPoint = ($asMessages[$iIndex - 1]['unix_time'] + $asMessages[$iIndex]['unix_time'])/2;
|
||||||
|
$iMsgIndex = ($asMedia['unix_time'] >= $iHalfWayPoint)?$iIndex:($iIndex - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$asMessages[$iMsgIndex]['medias'][] = $asMedia;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Combine markers
|
||||||
|
$asMarkers = [...$asMessages, ...$asGeoMedias];
|
||||||
|
usort($asMarkers, function($a, $b) {return (int) $a['unix_time'] <=> (int) $b['unix_time'];});
|
||||||
|
|
||||||
|
$asResult = [
|
||||||
|
'markers' => $asMarkers,
|
||||||
|
'maps' => $this->oMap->getProjectMaps($this->oProject->getProjectId())
|
||||||
|
];
|
||||||
|
|
||||||
|
return $bInternal?$asResult:self::getJsonResult(true, '', $asResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastUpdate() {
|
||||||
|
$asLastUpdate = [];
|
||||||
|
$this->addTimeStamp($asLastUpdate, $this->oProject->getLastUpdate());
|
||||||
|
return self::getJsonResult(true, '', $asLastUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login($sEmail, $sPassword, $sNickName) {
|
||||||
|
$asResult = $this->oUser->login($sEmail, $sPassword, $this->oLang->getLanguage(), date_default_timezone_get(), $sNickName);
|
||||||
|
|
||||||
|
if($asResult['result'] && $asResult['data']['subscribe']) return $this->subscribe();
|
||||||
|
else return self::getJsonResult($asResult['result'], $asResult['desc_lang_id'], $this->oUser->getUserInfo(), $asResult['desc_lang_params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout() {
|
||||||
|
$asResult = $this->oUser->logout();
|
||||||
|
return self::getJsonResult($asResult['result'], $asResult['desc_lang_id'], User::DEFAULT_USER, $asResult['desc_lang_params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subscribe() {
|
||||||
|
$asResult = $this->oUser->setSubscription(true);
|
||||||
|
$asUserInfo = $this->oUser->getUserInfo();
|
||||||
|
if($asResult['result'] && !Settings::DEBUG) {
|
||||||
|
$oConfEmail = new Email($this->asContext['serv_name'], 'email.confirmation');
|
||||||
|
$oConfEmail->setDestInfo($asUserInfo);
|
||||||
|
$oConfEmail->send();
|
||||||
|
}
|
||||||
|
return self::getJsonResult($asResult['result'], $asResult['desc_lang_id'], $asUserInfo, $asResult['desc_lang_params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unsubscribe() {
|
||||||
|
$asResult = $this->oUser->setSubscription(false);
|
||||||
|
return self::getJsonResult($asResult['result'], $asResult['desc_lang_id'], $this->oUser->getUserInfo(), $asResult['desc_lang_params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getSpotMessages($asMsgIds=[]) {
|
||||||
|
$asConstraints = $this->getFeedConstraints(Feed::MSG_TABLE);
|
||||||
|
if(!empty($asMsgIds)) {
|
||||||
|
$asConstraints['constraint'][Db::getId(Feed::MSG_TABLE)] = $asMsgIds;
|
||||||
|
$asConstraints['constOpe'][Db::getId(Feed::MSG_TABLE)] = 'IN';
|
||||||
|
}
|
||||||
|
|
||||||
|
$asCombinedMessages = [];
|
||||||
|
|
||||||
|
//Get messages from all feeds belonging to the project
|
||||||
|
$asFeeds = $this->oProject->getFeedIds();
|
||||||
|
foreach($asFeeds as $iFeedId) {
|
||||||
|
$oFeed = new Feed($this->oDb, $iFeedId);
|
||||||
|
$asMessages = $oFeed->getMessages($asConstraints);
|
||||||
|
foreach($asMessages as $asMessage) {
|
||||||
|
$asMessage['latitude'] = floatval($asMessage['latitude']);
|
||||||
|
$asMessage['longitude'] = floatval($asMessage['longitude']);
|
||||||
|
$asMessage['lat_dms'] = self::decToDms($asMessage['latitude'], 'lat');
|
||||||
|
$asMessage['lon_dms'] = self::decToDms($asMessage['longitude'], 'lon');
|
||||||
|
$asMessage['displayed_id'] = $asMessage[Db::getId(Feed::MSG_TABLE)];
|
||||||
|
$asMessage['static_img_url'] = $this->oMap->getMapUrl('static', ['x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']]);
|
||||||
|
$asMessage['marker_img_url'] = $this->oMap->getMapUrl('static_marker', ['x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']]);
|
||||||
|
|
||||||
|
$this->addTimeStamp($asMessage, $asMessage['unix_time'], $asMessage['timezone']);
|
||||||
|
$asCombinedMessages[] = $asMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $asCombinedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get valid medias based on $sTimeRefField:
|
||||||
|
* - taken_on: Date/time on which the media was taken
|
||||||
|
* - posted_on: Date/time on which the media was uploaded
|
||||||
|
* @param String $sTimeRefField Field to calculate relative times: 'taken_on' or 'posted_on'
|
||||||
|
* @return Array Medias info
|
||||||
|
*/
|
||||||
|
private function getMedias($sTimeRefField, $asMediaIds=[], $bOnlyGeoMedia=false) {
|
||||||
|
//Constraints
|
||||||
|
$asConstraints = $this->getFeedConstraints(Media::MEDIA_TABLE, $sTimeRefField);
|
||||||
|
if(!empty($asMediaIds)) {
|
||||||
|
$asConstraints['constOpe'][Db::getId(Media::MEDIA_TABLE)] = 'IN';
|
||||||
|
$asConstraints['constraint'][Db::getId(Media::MEDIA_TABLE)] = $asMediaIds;
|
||||||
|
}
|
||||||
|
if($bOnlyGeoMedia) {
|
||||||
|
$asConstraints['constOpe']['latitude'] = ' IS NOT ';
|
||||||
|
$asConstraints['constraint']['latitude'] = 'NULL';
|
||||||
|
$asConstraints['constOpe']['longitude'] = ' IS NOT ';
|
||||||
|
$asConstraints['constraint']['longitude'] = 'NULL';
|
||||||
|
}
|
||||||
|
|
||||||
|
$asMedias = $this->oMedia->getMediasInfo($asConstraints);
|
||||||
|
foreach($asMedias as &$asMedia) {
|
||||||
|
$asMedia['displayed_id'] = $asMedia[Db::getId(Media::MEDIA_TABLE)];
|
||||||
|
|
||||||
|
$this->addTimeStamp($asMedia, strtotime($asMedia[$sTimeRefField]), $asMedia['timezone']);
|
||||||
|
$this->addTimeStamp($asMedia, strtotime($asMedia['taken_on']), $asMedia['timezone'], 'taken_on');
|
||||||
|
$this->addTimeStamp($asMedia, strtotime($asMedia['posted_on']), $asMedia['timezone'], 'posted_on');
|
||||||
|
|
||||||
|
if($asMedia['latitude'] != '' && $asMedia['longitude'] != '') {
|
||||||
|
$asMedia['lat_dms'] = self::decToDms($asMedia['latitude'], 'lat');
|
||||||
|
$asMedia['lon_dms'] = self::decToDms($asMedia['longitude'], 'lon');
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($asMedia['taken_on']);
|
||||||
|
unset($asMedia['posted_on']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $asMedias;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPosts($asPostIds=[], $bResolveRef=true) {
|
||||||
|
$asInfo = [
|
||||||
|
'select' => [Db::getFullColumnName(self::POST_TABLE, '*'), 'gravatar'],
|
||||||
|
'from' => self::POST_TABLE,
|
||||||
|
'join' => [User::USER_TABLE => Db::getId(User::USER_TABLE)]
|
||||||
|
];
|
||||||
|
$asInfo = array_merge($asInfo, $this->getFeedConstraints(self::POST_TABLE));
|
||||||
|
|
||||||
|
if(!empty($asPostIds)) {
|
||||||
|
$asInfo['constraint'][Db::getId(self::POST_TABLE)] = $asPostIds;
|
||||||
|
$asInfo['constOpe'][Db::getId(self::POST_TABLE)] = 'IN';
|
||||||
|
}
|
||||||
|
$asPosts = $this->oDb->selectRows($asInfo);
|
||||||
|
|
||||||
|
foreach($asPosts as &$asPost) {
|
||||||
|
$iUnixTimeStamp = strtotime($asPost['site_time']); //assumes site timezone
|
||||||
|
$asPost['formatted_name'] = Toolbox::mb_ucwords($asPost['name']);
|
||||||
|
unset($asPost[Db::getId(User::USER_TABLE)]);
|
||||||
|
|
||||||
|
$this->addTimeStamp($asPost, $iUnixTimeStamp, $asPost['timezone']);
|
||||||
|
|
||||||
|
if($bResolveRef && !empty($asPost['ref_type']) && !empty($asPost['ref_id'])) {
|
||||||
|
switch($asPost['ref_type']) {
|
||||||
|
case 'post': $asRefs = $this->getPosts([$asPost['ref_id']], false); break;
|
||||||
|
case 'media': $asRefs = $this->getMedias('posted_on', [$asPost['ref_id']]); break;
|
||||||
|
case 'message': $asRefs = $this->getSpotMessages([$asPost['ref_id']]); break;
|
||||||
|
default: $asRefs = [];
|
||||||
|
}
|
||||||
|
$asPost['ref_item'] = reset($asRefs);
|
||||||
|
$asPost['ref_item']['type'] = $asPost['ref_type'];
|
||||||
|
$asPost['ref_item']['id'] = $asPost['ref_id'];
|
||||||
|
}
|
||||||
|
unset($asPost['ref_id']);
|
||||||
|
unset($asPost['ref_type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $asPosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addTimeStamp(&$asData, $iTime, $sTimeZone='', $sPrefix='') {
|
||||||
|
if($sPrefix != '') $sPrefix = $sPrefix.'_';
|
||||||
|
|
||||||
|
$asData[$sPrefix.'unix_time'] = (int) $iTime;
|
||||||
|
$asData[$sPrefix.'relative_time'] = Toolbox::getDateTimeDesc($iTime, $this->oLang->getLanguage());
|
||||||
|
$asData[$sPrefix.'formatted_time'] = $this->getTimeFormat($iTime);
|
||||||
|
|
||||||
|
if($sTimeZone != '') {
|
||||||
|
$asData[$sPrefix.'formatted_time_local'] = $this->getTimeFormat($iTime, $sTimeZone);
|
||||||
|
$asData[$sPrefix.'day_offset'] = self::getTimeZoneDayOffset($iTime, $sTimeZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFeedConstraints($sType, $sTimeField='site_time', $sReturnFormat='array') {
|
||||||
|
$asConsArray = [];
|
||||||
|
$sConsSql = '';
|
||||||
|
$asActPeriod = $this->oProject->getActivePeriod();
|
||||||
|
|
||||||
|
//Filter on Project ID
|
||||||
|
$sConsSql = 'WHERE '.Db::getId(Project::PROJ_TABLE).' = '.$this->oProject->getProjectId();
|
||||||
|
$asConsArray = [
|
||||||
|
'constraint'=> [Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId()],
|
||||||
|
'constOpe' => [Db::getId(Project::PROJ_TABLE) => '=']
|
||||||
|
];
|
||||||
|
|
||||||
|
//Time Filter
|
||||||
|
switch($sType) {
|
||||||
|
case Feed::MSG_TABLE:
|
||||||
|
$asConsArray['constraint'][$sTimeField] = $asActPeriod;
|
||||||
|
$asConsArray['constOpe'][$sTimeField] = 'BETWEEN';
|
||||||
|
$asConsArray['constraint']['display'] = Feed::MSG_DISPLAYED;
|
||||||
|
$asConsArray['constOpe']['display'] = '=';
|
||||||
|
$sConsSql .= ' AND '.$sTimeField." BETWEEN '".$asActPeriod['from']."' AND '".$asActPeriod['to']."' AND display = ".Feed::MSG_DISPLAYED;
|
||||||
|
break;
|
||||||
|
case Media::MEDIA_TABLE:
|
||||||
|
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];
|
||||||
|
$asConsArray['constOpe'][$sTimeField] = '<=';
|
||||||
|
$sConsSql .= ' AND '.$sTimeField." <= '".$asActPeriod['to']."'";
|
||||||
|
break;
|
||||||
|
case self::POST_TABLE:
|
||||||
|
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];
|
||||||
|
$asConsArray['constOpe'][$sTimeField] = '<=';
|
||||||
|
$sConsSql .= ' AND '.$sTimeField." <= '".$asActPeriod['to']."'";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($sReturnFormat=='array')?$asConsArray:$sConsSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNewFeed($iRefIdFirst) {
|
||||||
|
$asResult = [];
|
||||||
|
$sLangId = '';
|
||||||
|
|
||||||
|
if($this->oProject->isEditable()) {
|
||||||
|
$asMessageIds = $asMediaIds = [];
|
||||||
|
|
||||||
|
//New Feed Items
|
||||||
|
$asResult = $this->getFeed($iRefIdFirst, '>', 'DESC');
|
||||||
|
foreach($asResult['feed'] as $asItem) {
|
||||||
|
switch($asItem['type']) {
|
||||||
|
case 'message':
|
||||||
|
$asMessageIds[] = $asItem['id'];
|
||||||
|
break;
|
||||||
|
case 'media':
|
||||||
|
$asMediaIds[] = $asItem['id'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//New Markers
|
||||||
|
$asMarkers = $this->getMarkers(
|
||||||
|
empty($asMessageIds)?[0]:$asMessageIds,
|
||||||
|
empty($asMediaIds)?[0]:$asMediaIds,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$asResult = array_merge($asResult, $asMarkers);
|
||||||
|
}
|
||||||
|
else $sLangId = 'project.modes.histo';
|
||||||
|
|
||||||
|
return self::getJsonResult(true, $sLangId, $asResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextFeed($iRefIdLast=0, $bInternal=false) {
|
||||||
|
if($this->oProject->getMode() == Project::MODE_HISTO) {
|
||||||
|
$sDirection = '>';
|
||||||
|
$sSort = 'ASC';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sDirection = '<';
|
||||||
|
$sSort = 'DESC';
|
||||||
|
}
|
||||||
|
$asResult = $this->getFeed($iRefIdLast, $sDirection, $sSort);
|
||||||
|
return $bInternal?$asResult['feed']:self::getJsonResult(true, '', $asResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFeed($iRefId, $sDirection, $sSort) {
|
||||||
|
$sRefId = is_scalar($iRefId) && preg_match('/^\d+(?:\.\d+)?$/D', (string) $iRefId) ? (string) $iRefId : '0';
|
||||||
|
$sDirection = ($sDirection === '>')?'>':'<';
|
||||||
|
$sSort = ($sSort === 'ASC')?'ASC':'DESC';
|
||||||
|
|
||||||
|
$sProjectIdField = Db::getId(Project::PROJ_TABLE);
|
||||||
|
$sMsgIdField = Db::getId(Feed::MSG_TABLE);
|
||||||
|
$sMediaIdField = Db::getId(Media::MEDIA_TABLE);
|
||||||
|
$sPostIdField = Db::getId(self::POST_TABLE);
|
||||||
|
$sFeedIdField = Db::getId(Feed::FEED_TABLE);
|
||||||
|
$sQuery = implode(' ', [
|
||||||
|
'SELECT type, id, ref',
|
||||||
|
'FROM (',
|
||||||
|
"SELECT {$sProjectIdField}, {$sMsgIdField} AS id, 'message' AS type, CONCAT(UNIX_TIMESTAMP(site_time), '.0', {$sMsgIdField}) AS ref",
|
||||||
|
'FROM '.Feed::MSG_TABLE,
|
||||||
|
'INNER JOIN '.Feed::FEED_TABLE." USING({$sFeedIdField})",
|
||||||
|
$this->getFeedConstraints(Feed::MSG_TABLE, 'site_time', 'sql'),
|
||||||
|
'UNION',
|
||||||
|
"SELECT {$sProjectIdField}, {$sMediaIdField} AS id, 'media' AS type, CONCAT(UNIX_TIMESTAMP(posted_on), '.1', {$sMediaIdField}) AS ref",
|
||||||
|
'FROM '.Media::MEDIA_TABLE,
|
||||||
|
$this->getFeedConstraints(Media::MEDIA_TABLE, 'posted_on', 'sql'),
|
||||||
|
'UNION',
|
||||||
|
"SELECT {$sProjectIdField}, {$sPostIdField} AS id, 'post' AS type, CONCAT(UNIX_TIMESTAMP(site_time), '.2', {$sPostIdField}) AS ref",
|
||||||
|
'FROM '.self::POST_TABLE,
|
||||||
|
$this->getFeedConstraints(self::POST_TABLE, 'site_time', 'sql'),
|
||||||
|
') AS items',
|
||||||
|
($sRefId !== '0')?('WHERE ref '.$sDirection.' '.$sRefId):'',
|
||||||
|
'ORDER BY ref '.$sSort,
|
||||||
|
'LIMIT '.self::FEED_CHUNK_SIZE
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Get new chunk
|
||||||
|
$asItems = $this->oDb->getArrayQuery($sQuery, true);
|
||||||
|
|
||||||
|
//Update Reference Point with latest/earliest value
|
||||||
|
$iRefIdFirst = $iRefIdLast = 0;
|
||||||
|
if(!empty($asItems)) {
|
||||||
|
$iRefIdLast = end($asItems)['ref'];
|
||||||
|
$iRefIdFirst = reset($asItems)['ref'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Sort Table IDs by type & Get attributes
|
||||||
|
$asFeedIds = ['message'=>[], 'media'=>[], 'post'=>[]];
|
||||||
|
foreach($asItems as $asItem) {
|
||||||
|
$asFeedIds[$asItem['type']][$asItem['id']] = $asItem;
|
||||||
|
}
|
||||||
|
$asFeedAttrs = [
|
||||||
|
'message' => empty($asFeedIds['message'])?[]:$this->getSpotMessages(array_keys($asFeedIds['message'])),
|
||||||
|
'media' => empty($asFeedIds['media'])?[]:$this->getMedias('posted_on', array_keys($asFeedIds['media'])),
|
||||||
|
'post' => empty($asFeedIds['post'])?[]:$this->getPosts(array_keys($asFeedIds['post']))
|
||||||
|
];
|
||||||
|
|
||||||
|
//Replace Array Key with Item ID
|
||||||
|
$asFeeds = [];
|
||||||
|
foreach($asFeedAttrs as $sType=>$asFeedAttr) {
|
||||||
|
foreach($asFeedAttr as $asFeed) {
|
||||||
|
$asFeeds[$sType][$asFeed['id_'.$sType]] = $asFeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Assign
|
||||||
|
foreach($asItems as &$asItem) {
|
||||||
|
$asItem = array_merge($asFeeds[$asItem['type']][$asItem['id']], $asItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['ref_id_last'=>$iRefIdLast, 'ref_id_first'=>$iRefIdFirst, 'sort'=>$sSort, 'feed'=>$asItems];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPost($sName, $sPost, $sRefType='', $iRefId=0) {
|
||||||
|
$iPostId = 0;
|
||||||
|
$sLangId = '';
|
||||||
|
|
||||||
|
if($this->oProject->isEditable()) {
|
||||||
|
$bHasRef = ($iRefId > 0) && in_array($sRefType, self::REF_TYPES, true);
|
||||||
|
$asData = [
|
||||||
|
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
|
||||||
|
'name' => mb_strtolower(trim($sName)),
|
||||||
|
'content' => trim($sPost),
|
||||||
|
'site_time' => date(Db::TIMESTAMP_FORMAT), //Now in Site Time
|
||||||
|
'timezone' => date_default_timezone_get(), //Site Time Zone
|
||||||
|
'ref_id' => $bHasRef?$iRefId:'NULL',
|
||||||
|
'ref_type' => $bHasRef?$sRefType:'NULL'
|
||||||
|
];
|
||||||
|
if($this->oUser->getUserId() > 0) $asData[Db::getId(User::USER_TABLE)] = $this->oUser->getUserId();
|
||||||
|
|
||||||
|
$iPostId = $this->oDb->insertRow(self::POST_TABLE, $asData);
|
||||||
|
if($iPostId == 0) $sLangId = 'error.commit_db';
|
||||||
|
|
||||||
|
$this->oUser->updateNickname($sName);
|
||||||
|
}
|
||||||
|
else $sLangId = 'project.modes.histo';
|
||||||
|
|
||||||
|
return self::getJsonResult(($iPostId > 0), $sLangId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function upload() {
|
||||||
|
$oUploader = new Uploader($this->oMedia);
|
||||||
|
|
||||||
|
return $oUploader->sBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addComment($iMediaId, $sComment) {
|
||||||
|
$oMedia = new Media($this->oDb, $this->oProject, $iMediaId);
|
||||||
|
$asResult = $oMedia->setComment($sComment);
|
||||||
|
return self::getJsonResult($asResult['result'], $asResult['desc_lang_id'], $asResult['data'], $asResult['desc_lang_params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPosition($sLat, $sLng, $iTimestamp) {
|
||||||
|
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
|
||||||
|
$bSuccess = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
|
||||||
|
|
||||||
|
if($bSuccess) {
|
||||||
|
$bSuccess = $this->sendEmail();
|
||||||
|
$sLangId = $bSuccess?'email.sent':'email.failure';
|
||||||
|
}
|
||||||
|
else $sLangId = 'error.commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sLangId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdminSettings() {
|
||||||
|
$oFeed = new Feed($this->oDb);
|
||||||
|
$asData = [
|
||||||
|
'project' => $this->oProject->getProjects(),
|
||||||
|
'feed' => $oFeed->getFeeds(),
|
||||||
|
'spot' => $oFeed->getSpots(),
|
||||||
|
'user' => $this->oUser->getSubscribedUsersInfo()
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($asData['project'] as &$asProject) {
|
||||||
|
$asProject['active_from'] = substr($asProject['active_from'], 0, 10);
|
||||||
|
$asProject['active_to'] = substr($asProject['active_to'], 0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::getJsonResult(true, '', $asData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAdminSettings($sType, $iId, $sField, $sValue) {
|
||||||
|
$bSuccess = false;
|
||||||
|
$sLangId = '';
|
||||||
|
$asLangParams = [];
|
||||||
|
$asResult = [];
|
||||||
|
|
||||||
|
if($this->oDb->isId($sField) && $sValue <= 0) return self::getJsonResult(false, 'error.impossible_value', [], [$sValue, $sField]);
|
||||||
|
|
||||||
|
switch($sType) {
|
||||||
|
case 'project':
|
||||||
|
$oProject = new Project($this->oDb, $iId);
|
||||||
|
|
||||||
|
switch($sField) {
|
||||||
|
case 'name':
|
||||||
|
$bSuccess = $oProject->setProjectName($sValue);
|
||||||
|
break;
|
||||||
|
case 'codename':
|
||||||
|
$bSuccess = $oProject->setProjectCodeName($sValue);
|
||||||
|
break;
|
||||||
|
case 'active_from':
|
||||||
|
$bSuccess = $oProject->setActivePeriod($sValue.' 00:00:00', 'from');
|
||||||
|
break;
|
||||||
|
case 'active_to':
|
||||||
|
$bSuccess = $oProject->setActivePeriod($sValue.' 23:59:59', 'to');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sLangId = 'error.unknown_field';
|
||||||
|
$asLangParams = [$sField];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Identify missing GPX file
|
||||||
|
$sProjectCodeName = ($sField == 'codename')?$sValue:$oProject->getProjectCodeName();
|
||||||
|
if(!Converter::hasGpxFile($sProjectCodeName)) {
|
||||||
|
$bSuccess = true;
|
||||||
|
$sLangId = 'error.file_missing';
|
||||||
|
$asLangParams = ['GPX', $sProjectCodeName.Gpx::EXT];
|
||||||
|
}
|
||||||
|
|
||||||
|
$asResult = $oProject->getProject();
|
||||||
|
$asResult['active_from'] = substr($asResult['active_from'], 0, 10);
|
||||||
|
$asResult['active_to'] = substr($asResult['active_to'], 0, 10);
|
||||||
|
break;
|
||||||
|
case 'feed':
|
||||||
|
$oFeed = new Feed($this->oDb, $iId);
|
||||||
|
switch($sField) {
|
||||||
|
case 'ref_feed_id':
|
||||||
|
$bSuccess = $oFeed->setRefFeedId($sValue);
|
||||||
|
break;
|
||||||
|
case 'id_spot':
|
||||||
|
$bSuccess = $oFeed->setSpotId($sValue);
|
||||||
|
break;
|
||||||
|
case 'id_project':
|
||||||
|
$bSuccess = $oFeed->setProjectId($sValue);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sLangId = 'error.unknown_field';
|
||||||
|
$asLangParams = [$sField];
|
||||||
|
}
|
||||||
|
$asResult = $oFeed->getFeed();
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
switch($sField) {
|
||||||
|
case 'clearance':
|
||||||
|
$asReturnCode = $this->oUser->setUserClearance($iId, $sValue);
|
||||||
|
$bSuccess = $asReturnCode['result'];
|
||||||
|
$sLangId = $asReturnCode['desc_lang_id'];
|
||||||
|
$asLangParams = $asReturnCode['desc_lang_params'];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sLangId = 'error.unknown_field';
|
||||||
|
$asLangParams = [$sField];
|
||||||
|
}
|
||||||
|
$asResult = $this->oUser->getUserById($iId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!$bSuccess && $sLangId=='') $sLangId = 'error.commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sLangId, [$sType=>[$asResult]], $asLangParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createAdminSettings($sType) {
|
||||||
|
$bSuccess = false;
|
||||||
|
$sLangId = '';
|
||||||
|
$asResult = [];
|
||||||
|
|
||||||
|
switch($sType) {
|
||||||
|
case 'project':
|
||||||
|
$oProject = new Project($this->oDb);
|
||||||
|
$iNewProjectId = $oProject->createProjectId();
|
||||||
|
|
||||||
|
$oFeed = new Feed($this->oDb);
|
||||||
|
$oFeed->createFeedId($iNewProjectId);
|
||||||
|
|
||||||
|
$bSuccess = $iNewProjectId > 0;
|
||||||
|
$asResult = [
|
||||||
|
'project' => [$oProject->getProject()],
|
||||||
|
'feed' => [$oFeed->getFeed()]
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'feed':
|
||||||
|
$oFeed = new Feed($this->oDb);
|
||||||
|
$iNewFeedId = $oFeed->createFeedId($this->oProject->getProjectId());
|
||||||
|
$bSuccess = $iNewFeedId > 0;
|
||||||
|
$asResult = [
|
||||||
|
'feed' => [$oFeed->getFeed()]
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!$bSuccess && $sLangId=='') $sLangId = 'error.commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sLangId, $asResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAdminSettings($sType, $iId) {
|
||||||
|
$bSuccess = false;
|
||||||
|
$sLangId = '';
|
||||||
|
$asLangParams = [];
|
||||||
|
$asResult = [];
|
||||||
|
|
||||||
|
switch($sType) {
|
||||||
|
case 'project':
|
||||||
|
$oProject = new Project($this->oDb, $iId);
|
||||||
|
$asResult = $oProject->delete();
|
||||||
|
$sLangId = $asResult['project'][0]['desc_lang_id'];
|
||||||
|
$asLangParams = $asResult['project'][0]['desc_lang_params'];
|
||||||
|
$bSuccess = $asResult['project'][0]['del'];
|
||||||
|
break;
|
||||||
|
case 'feed':
|
||||||
|
$oFeed = new Feed($this->oDb, $iId);
|
||||||
|
$asResult = ['feed' => [$oFeed->delete()]];
|
||||||
|
$sLangId = $asResult['feed'][0]['desc_lang_id'];
|
||||||
|
$asLangParams = $asResult['feed'][0]['desc_lang_params'];
|
||||||
|
$bSuccess = $asResult['feed'][0]['result'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!$bSuccess && $sLangId=='') $sLangId = 'error.commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sLangId, $asResult, $asLangParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function decToDms($dValue, $sType) {
|
||||||
|
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
||||||
|
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
||||||
|
|
||||||
|
$dLeft = abs($dValue);
|
||||||
|
|
||||||
|
//Degrees
|
||||||
|
$iDegree = floor($dLeft);
|
||||||
|
$dLeft -= $iDegree;
|
||||||
|
|
||||||
|
//Minutes
|
||||||
|
$iMinute = floor($dLeft * 60);
|
||||||
|
$dLeft -= $iMinute / 60;
|
||||||
|
|
||||||
|
//Seconds
|
||||||
|
$fSecond = round($dLeft * 3600, 1);
|
||||||
|
|
||||||
|
return
|
||||||
|
$iDegree.'°'.
|
||||||
|
self::getNumberWithLeadingZeros($iMinute, 2, 0)."'".
|
||||||
|
self::getNumberWithLeadingZeros($fSecond, 2, 1).'"'.
|
||||||
|
$sDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNumberWithLeadingZeros($fValue, $iNbLeadingZeros, $iNbDigits) {
|
||||||
|
$sDecimalSeparator = '.';
|
||||||
|
if($iNbDigits > 0) $iNbLeadingZeros += mb_strlen($sDecimalSeparator) + $iNbDigits;
|
||||||
|
$sPattern = '%0'.$iNbLeadingZeros.$sDecimalSeparator.$iNbDigits.'f';
|
||||||
|
return sprintf($sPattern, $fValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTimeFormat($iTime, $sTimeZone='') {
|
||||||
|
if($sTimeZone == '') $sTimeZone = date_default_timezone_get();
|
||||||
|
|
||||||
|
$oDate = new \DateTime('@'.$iTime);
|
||||||
|
$oDate->setTimezone(new \DateTimeZone($sTimeZone));
|
||||||
|
|
||||||
|
$sDate = $oDate->format('d/m/Y');
|
||||||
|
$sTime = $oDate->format('H:i');
|
||||||
|
return $this->oLang->getTranslation('time.date_time', [$sDate, $sTime]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTimeZoneDayOffset($iTime, $sLocalTimeZone) {
|
||||||
|
$sSiteTimeZone = date_default_timezone_get();
|
||||||
|
$iLocalDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sLocalTimeZone))->format('Ymd');
|
||||||
|
$iSiteDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sSiteTimeZone ))->format('Ymd');
|
||||||
|
|
||||||
|
return ($iLocalDate == $iSiteDate)?'0':(($iLocalDate < $iSiteDate)?'+1':'-1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTimeZoneFromDate($sDate) {
|
||||||
|
$sTimeZone = null;
|
||||||
|
|
||||||
|
preg_match('/(?<timezone>(\+|\-)\d{2}:?(\d{2}|))$/', $sDate, $asMatch);
|
||||||
|
if(array_key_exists('timezone', $asMatch)) {
|
||||||
|
$sTimeZone = $asMatch['timezone'];
|
||||||
|
|
||||||
|
//Complete short form: +12 => +1200
|
||||||
|
if(strlen($sTimeZone) == 3) $sTimeZone .= '00';
|
||||||
|
|
||||||
|
//Add colon: +1200 => +12:00
|
||||||
|
if(!strpos($sTimeZone, ':')) $sTimeZone = substr_replace($sTimeZone, ':', 3, 0);
|
||||||
|
}
|
||||||
|
return $sTimeZone;
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
-12
@@ -1,38 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Db;
|
use Franzz\Objects\Db;
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
class Map extends PhpObject {
|
class Map extends PhpObject {
|
||||||
|
|
||||||
const MAP_TABLE = 'maps';
|
public const MAP_TABLE = 'maps';
|
||||||
const MAPPING_TABLE = 'mappings';
|
public const MAPPING_TABLE = 'mappings';
|
||||||
|
|
||||||
private Db $oDb;
|
private Db $oDb;
|
||||||
|
|
||||||
private $asMaps;
|
private $asMaps;
|
||||||
|
|
||||||
public function __construct(Db &$oDb) {
|
public function __construct(Db &$oDb) {
|
||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
$this->oDb = &$oDb;
|
$this->oDb = &$oDb;
|
||||||
$this->setMaps();
|
$this->asMaps = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setMaps() {
|
private function setMaps() {
|
||||||
$asMaps = $this->oDb->selectRows(array('from'=>self::MAP_TABLE));
|
$asMaps = $this->oDb->selectRows(['from'=>self::MAP_TABLE]);
|
||||||
foreach($asMaps as $asMap) $this->asMaps[$asMap['codename']] = $asMap;
|
foreach($asMaps as $asMap) $this->asMaps[$asMap['codename']] = $asMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getMaps($sCodeName='') {
|
||||||
|
if(empty($this->asMaps)) $this->setMaps();
|
||||||
|
return ($sCodeName=='')?$this->asMaps:$this->asMaps[$sCodeName];
|
||||||
|
}
|
||||||
|
|
||||||
public function getProjectMaps($iProjectId) {
|
public function getProjectMaps($iProjectId) {
|
||||||
$asMappings = $this->oDb->getArrayQuery("SELECT id_map FROM mappings WHERE id_project = ".$iProjectId." OR id_project IS NULL", true);
|
$asMappings = $this->oDb->selectRows(
|
||||||
return array_filter($this->asMaps, function($asMap) use($asMappings) {return in_array($asMap['id_map'], $asMappings);});
|
[
|
||||||
|
'select' => [Db::getId(self::MAP_TABLE), 'default_map'],
|
||||||
|
'from' => self::MAPPING_TABLE,
|
||||||
|
'constraint'=> ["IFNULL(id_project, {$iProjectId})" => $iProjectId]
|
||||||
|
],
|
||||||
|
Db::getId(self::MAP_TABLE)
|
||||||
|
);
|
||||||
|
|
||||||
|
$asProjectMaps = [];
|
||||||
|
foreach($this->getMaps() as $asMap) {
|
||||||
|
if(array_key_exists($asMap['id_map'], $asMappings)) {
|
||||||
|
$asMap['default_map'] = $asMappings[$asMap['id_map']];
|
||||||
|
$asProjectMaps[] = $asMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $asProjectMaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMapUrl($sCodeName, $asParams) {
|
public function getMapUrl($sCodeName, $asParams) {
|
||||||
$asParams['token'] = $this->asMaps[$sCodeName]['token'];
|
$asMap = $this->getMaps($sCodeName);
|
||||||
return self::populateParams($this->asMaps[$sCodeName]['pattern'], $asParams);
|
$asParams['token'] = $asMap['token'];
|
||||||
|
return self::populateParams($asMap['pattern'], $asParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function populateParams($sUrl, $asParams) {
|
private static function populateParams($sUrl, $asParams) {
|
||||||
@@ -42,4 +62,4 @@ class Map extends PhpObject {
|
|||||||
|
|
||||||
return $sUrl;
|
return $sUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-72
@@ -1,46 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Db;
|
use Franzz\Objects\Db;
|
||||||
use Franzz\Objects\ToolBox;
|
use Franzz\Objects\ToolBox;
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
class Media extends PhpObject {
|
class Media extends PhpObject {
|
||||||
|
|
||||||
//DB Tables
|
//DB Tables
|
||||||
const MEDIA_TABLE = 'medias';
|
public const MEDIA_TABLE = 'medias';
|
||||||
|
|
||||||
//Media folders
|
//Media folders (works because /public/files is a symlink of /files)
|
||||||
const MEDIA_FOLDER = 'files/';
|
public const MEDIA_FOLDER = 'files';
|
||||||
const THUMB_FOLDER = self::MEDIA_FOLDER.'thumbs/';
|
public const THUMB_FOLDER = self::MEDIA_FOLDER.'/thumbs';
|
||||||
|
|
||||||
const THUMB_MAX_WIDTH = 400;
|
private const THUMB_MAX_WIDTH = 400;
|
||||||
|
|
||||||
/**
|
private Db $oDb;
|
||||||
* Database Handle
|
private Project $oProject;
|
||||||
* @var Db
|
|
||||||
*/
|
|
||||||
private $oDb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Media Project
|
|
||||||
* @var Project
|
|
||||||
*/
|
|
||||||
private $oProject;
|
|
||||||
private $asMedia;
|
private $asMedia;
|
||||||
private $asMedias;
|
private $asMedias;
|
||||||
private $sSystemType;
|
|
||||||
|
|
||||||
private $iMediaId;
|
private $iMediaId;
|
||||||
|
|
||||||
public function __construct(Db &$oDb, &$oProject, $iMediaId=0) {
|
public function __construct(Db &$oDb, Project &$oProject, $iMediaId=0) {
|
||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
$this->oDb = &$oDb;
|
$this->oDb = &$oDb;
|
||||||
$this->oProject = &$oProject;
|
$this->oProject = &$oProject;
|
||||||
$this->asMedia = array();
|
$this->asMedia = [];
|
||||||
$this->asMedias = array();
|
$this->asMedias = [];
|
||||||
$this->sSystemType = (substr(php_uname(), 0, 7) == "Windows")?'win':'unix';
|
|
||||||
$this->setMediaId($iMediaId);
|
$this->setMediaId($iMediaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,16 +45,16 @@ class Media extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setComment($sComment) {
|
public function setComment($sComment) {
|
||||||
$sError = '';
|
$sLangId = '';
|
||||||
$asData = array();
|
$asData = [];
|
||||||
if($this->iMediaId > 0) {
|
if($this->iMediaId > 0) {
|
||||||
$bResult = $this->oDb->updateRow(self::MEDIA_TABLE, $this->iMediaId, array('comment'=>$sComment));
|
$bResult = $this->oDb->updateRow(self::MEDIA_TABLE, $this->iMediaId, ['comment'=>$sComment]);
|
||||||
if(!$bResult) $sError = 'error_commit_db';
|
if(!$bResult) $sLangId = 'error.commit_db';
|
||||||
else $asData = $this->getInfo();
|
else $asData = $this->getInfo();
|
||||||
}
|
}
|
||||||
else $sError = 'media_no_id';
|
else $sLangId = 'media.no_id';
|
||||||
|
|
||||||
return Spot::getResult(($sError==''), $sError, $asData);
|
return Livetrail::getResult(($sLangId==''), $sLangId, $asData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMediasInfo($oMediaIds=null) {
|
public function getMediasInfo($oMediaIds=null) {
|
||||||
@@ -75,11 +63,11 @@ class Media extends PhpObject {
|
|||||||
|
|
||||||
if($bOwnMedia && empty($this->asMedia) || !$bOwnMedia && empty($this->asMedias) || $bConstraintArray) {
|
if($bOwnMedia && empty($this->asMedia) || !$bOwnMedia && empty($this->asMedias) || $bConstraintArray) {
|
||||||
if($this->oProject->getProjectId()) {
|
if($this->oProject->getProjectId()) {
|
||||||
$asParams = array(
|
$asParams = [
|
||||||
'select' => array(Db::getId(self::MEDIA_TABLE), 'filename', 'taken_on', 'posted_on', 'timezone', 'latitude', 'longitude', 'altitude', 'width', 'height', 'rotate', 'type AS subtype', 'comment'),
|
'select' => [Db::getId(self::MEDIA_TABLE), 'filename', 'taken_on', 'posted_on', 'timezone', 'latitude', 'longitude', 'altitude', 'width', 'height', 'rotate', 'type AS subtype', 'comment'],
|
||||||
'from' => self::MEDIA_TABLE,
|
'from' => self::MEDIA_TABLE,
|
||||||
'constraint'=> array(Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId())
|
'constraint'=> [Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId()]
|
||||||
);
|
];
|
||||||
if($bOwnMedia) $asParams['constraint'][Db::getId(self::MEDIA_TABLE)] = $oMediaIds;
|
if($bOwnMedia) $asParams['constraint'][Db::getId(self::MEDIA_TABLE)] = $oMediaIds;
|
||||||
if($bConstraintArray) $asParams = array_merge($asParams, $oMediaIds);
|
if($bConstraintArray) $asParams = array_merge($asParams, $oMediaIds);
|
||||||
|
|
||||||
@@ -95,7 +83,7 @@ class Media extends PhpObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $bOwnMedia?$this->asMedia:$asMedias;
|
return $bOwnMedia?$this->asMedia:$asMedias ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInfo() {
|
public function getInfo() {
|
||||||
@@ -107,14 +95,14 @@ class Media extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function addMedia($sMediaName, $sMethod='upload') {
|
public function addMedia($sMediaName, $sMethod='upload') {
|
||||||
$sError = '';
|
$sLangId = '';
|
||||||
$asParams = array();
|
$asParams = [];
|
||||||
if(!$this->isProjectEditable() && $sMethod!='sync') {
|
if(!$this->isProjectEditable() && $sMethod!='sync') {
|
||||||
$sError = 'upload_mode_archived';
|
$sLangId = 'upload.mode_archived';
|
||||||
$asParams[] = $this->oProject->getProjectCodeName();
|
$asParams[] = $this->oProject->getProjectCodeName();
|
||||||
}
|
}
|
||||||
elseif($this->oDb->pingValue(self::MEDIA_TABLE, array('filename'=>$sMediaName)) && $sMethod!='sync') {
|
elseif($this->oDb->pingValue(self::MEDIA_TABLE, ['filename'=>$sMediaName]) && $sMethod!='sync') {
|
||||||
$sError = 'upload_media_exist';
|
$sLangId = 'upload.media.exists';
|
||||||
$asParams[] = $sMediaName;
|
$asParams[] = $sMediaName;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -122,7 +110,7 @@ class Media extends PhpObject {
|
|||||||
|
|
||||||
//Converting times to Site Time Zone, by using date()
|
//Converting times to Site Time Zone, by using date()
|
||||||
//Media Timezone is kept in a separate field for later conversion to Local Time
|
//Media Timezone is kept in a separate field for later conversion to Local Time
|
||||||
$asDbInfo = array(
|
$asDbInfo = [
|
||||||
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
|
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
|
||||||
'filename' => $sMediaName,
|
'filename' => $sMediaName,
|
||||||
'taken_on' => date(Db::TIMESTAMP_FORMAT, ($asMediaInfo['taken_ts'] > 0)?$asMediaInfo['taken_ts']:$asMediaInfo['file_ts']),
|
'taken_on' => date(Db::TIMESTAMP_FORMAT, ($asMediaInfo['taken_ts'] > 0)?$asMediaInfo['taken_ts']:$asMediaInfo['file_ts']),
|
||||||
@@ -135,23 +123,22 @@ class Media extends PhpObject {
|
|||||||
'height' => $asMediaInfo['height'],
|
'height' => $asMediaInfo['height'],
|
||||||
'rotate' => $asMediaInfo['rotate'],
|
'rotate' => $asMediaInfo['rotate'],
|
||||||
'type' => $asMediaInfo['type']
|
'type' => $asMediaInfo['type']
|
||||||
);
|
];
|
||||||
|
|
||||||
if($sMethod=='sync') $iMediaId = $this->oDb->insertUpdateRow(self::MEDIA_TABLE, $asDbInfo, array('filename'));
|
if($sMethod=='sync') $iMediaId = $this->oDb->insertUpdateRow(self::MEDIA_TABLE, $asDbInfo, ['filename']);
|
||||||
else $iMediaId = $this->oDb->insertRow(self::MEDIA_TABLE, $asDbInfo);
|
else $iMediaId = $this->oDb->insertRow(self::MEDIA_TABLE, $asDbInfo);
|
||||||
|
|
||||||
if(!$iMediaId) $sError = 'error_commit_db';
|
if(!$iMediaId) $sLangId = 'error.commit_db';
|
||||||
else {
|
else {
|
||||||
$this->setMediaId($iMediaId);
|
$this->setMediaId($iMediaId);
|
||||||
$asParams = $this->getInfo(); //Creates thumbnail
|
$asParams = $this->getInfo(); //Creates thumbnail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Spot::getResult(($sError==''), $sError, $asParams);
|
return Livetrail::getResult(($sLangId==''), $sLangId, $asParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMediaInfoFromFile($sMediaName)
|
private function getMediaInfoFromFile($sMediaName) {
|
||||||
{
|
|
||||||
$sMediaPath = self::getMediaPath($sMediaName);
|
$sMediaPath = self::getMediaPath($sMediaName);
|
||||||
$sType = self::getMediaType($sMediaName);
|
$sType = self::getMediaType($sMediaName);
|
||||||
$iPostedOn = filemtime($sMediaPath);
|
$iPostedOn = filemtime($sMediaPath);
|
||||||
@@ -165,8 +152,8 @@ class Media extends PhpObject {
|
|||||||
$iAlt = null;
|
$iAlt = null;
|
||||||
switch($sType) {
|
switch($sType) {
|
||||||
case 'video':
|
case 'video':
|
||||||
$asResult = array();
|
$asResult = [];
|
||||||
$sParams = implode(' ', array(
|
$sParams = implode(' ', [
|
||||||
'-loglevel error', //Remove comments
|
'-loglevel error', //Remove comments
|
||||||
'-select_streams v:0', //First video channel
|
'-select_streams v:0', //First video channel
|
||||||
'-show_entries '. //filter tags : Width, Height, Creation Time, Location & Rotation
|
'-show_entries '. //filter tags : Width, Height, Creation Time, Location & Rotation
|
||||||
@@ -175,14 +162,14 @@ class Media extends PhpObject {
|
|||||||
'stream=width,height',
|
'stream=width,height',
|
||||||
'-print_format json', //output format: json
|
'-print_format json', //output format: json
|
||||||
'-i' //input file
|
'-i' //input file
|
||||||
));
|
]);
|
||||||
exec('ffprobe '.$sParams.' "'.$sMediaPath.'"', $asResult);
|
exec('ffprobe '.$sParams.' '.escapeshellarg($sMediaPath), $asResult);
|
||||||
$asExif = json_decode(implode('', $asResult), true);
|
$asExif = json_decode(implode('', $asResult), true);
|
||||||
|
|
||||||
//Taken On
|
//Taken On
|
||||||
if(isset($asExif['format']['tags']['com.apple.quicktime.creationdate'])) {
|
if(isset($asExif['format']['tags']['com.apple.quicktime.creationdate'])) {
|
||||||
$sTakenOn = $asExif['format']['tags']['com.apple.quicktime.creationdate']; //contains Time Zone
|
$sTakenOn = $asExif['format']['tags']['com.apple.quicktime.creationdate']; //contains Time Zone
|
||||||
$sTimeZone = Spot::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
$sTimeZone = Livetrail::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||||
}
|
}
|
||||||
else $sTakenOn = $asExif['format']['tags']['creation_time'] ?? $asExif['streams'][0]['tags']['creation_time'];
|
else $sTakenOn = $asExif['format']['tags']['creation_time'] ?? $asExif['streams'][0]['tags']['creation_time'];
|
||||||
|
|
||||||
@@ -200,7 +187,7 @@ class Media extends PhpObject {
|
|||||||
break;
|
break;
|
||||||
case 'image':
|
case 'image':
|
||||||
$asExif = @exif_read_data($sMediaPath, 0, true);
|
$asExif = @exif_read_data($sMediaPath, 0, true);
|
||||||
if($asExif === false) $asExif = array();
|
if($asExif === false) $asExif = [];
|
||||||
list($iWidth, $iHeight) = getimagesize($sMediaPath);
|
list($iWidth, $iHeight) = getimagesize($sMediaPath);
|
||||||
|
|
||||||
//Posted On
|
//Posted On
|
||||||
@@ -216,7 +203,7 @@ class Media extends PhpObject {
|
|||||||
* 3. Timezone extracted from DateTimeOriginal
|
* 3. Timezone extracted from DateTimeOriginal
|
||||||
* 4. Uploader Browser Time Zone (PHP Default Time Zone)
|
* 4. Uploader Browser Time Zone (PHP Default Time Zone)
|
||||||
*/
|
*/
|
||||||
$sTimeZone = $asExif['EXIF']['OffsetTimeOriginal'] ?? $asExif['EXIF']['UndefinedTag:0x9011'] ?? Spot::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
$sTimeZone = $asExif['EXIF']['OffsetTimeOriginal'] ?? $asExif['EXIF']['UndefinedTag:0x9011'] ?? Livetrail::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Location
|
//Location
|
||||||
@@ -229,8 +216,7 @@ class Media extends PhpObject {
|
|||||||
|
|
||||||
//Orientation
|
//Orientation
|
||||||
if(array_key_exists('IFD0', $asExif) && array_key_exists('Orientation', $asExif['IFD0'])) {
|
if(array_key_exists('IFD0', $asExif) && array_key_exists('Orientation', $asExif['IFD0'])) {
|
||||||
switch($asExif['IFD0']['Orientation'])
|
switch($asExif['IFD0']['Orientation']) {
|
||||||
{
|
|
||||||
case 1: $sRotate = '0'; break; //None
|
case 1: $sRotate = '0'; break; //None
|
||||||
case 3: $sRotate = '180'; break; //Flip over
|
case 3: $sRotate = '180'; break; //Flip over
|
||||||
case 6: $sRotate = '90'; break; //Clockwise
|
case 6: $sRotate = '90'; break; //Clockwise
|
||||||
@@ -248,7 +234,7 @@ class Media extends PhpObject {
|
|||||||
$iTakenOn = $oTakenOn->format('U');
|
$iTakenOn = $oTakenOn->format('U');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'timezone' => $sTimeZone,
|
'timezone' => $sTimeZone,
|
||||||
'latitude' => $fLat,
|
'latitude' => $fLat,
|
||||||
'longitude' => $fLng,
|
'longitude' => $fLng,
|
||||||
@@ -259,11 +245,10 @@ class Media extends PhpObject {
|
|||||||
'height' => $iHeight,
|
'height' => $iHeight,
|
||||||
'rotate' => $sRotate,
|
'rotate' => $sRotate,
|
||||||
'type' => $sType
|
'type' => $sType
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMediaThumbnail($sMediaName)
|
private function getMediaThumbnail($sMediaName) {
|
||||||
{
|
|
||||||
$sMediaPath = self::getMediaPath($sMediaName);
|
$sMediaPath = self::getMediaPath($sMediaName);
|
||||||
$sThumbPath = self::getMediaPath($sMediaName, 'thumbnail');
|
$sThumbPath = self::getMediaPath($sMediaName, 'thumbnail');
|
||||||
|
|
||||||
@@ -276,36 +261,39 @@ class Media extends PhpObject {
|
|||||||
case 'video':
|
case 'video':
|
||||||
//Get a screenshot of the video 1 second in
|
//Get a screenshot of the video 1 second in
|
||||||
$sTempPath = self::getMediaPath(uniqid('temp_').'.png');
|
$sTempPath = self::getMediaPath(uniqid('temp_').'.png');
|
||||||
$asResult = array();
|
$asResult = [];
|
||||||
$sParams = implode(' ', array(
|
$sParams = implode(' ', [
|
||||||
'-i "'.$sMediaPath.'"', //input file
|
'-i '.escapeshellarg($sMediaPath), //input file
|
||||||
'-ss 00:00:01.000', //Image taken after x seconds
|
'-ss 00:00:01.000', //Image taken after x seconds
|
||||||
'-vframes 1', //number of video frames to output
|
'-vframes 1', //number of video frames to output
|
||||||
'"'.$sTempPath.'"', //output file
|
escapeshellarg($sTempPath), //output file
|
||||||
));
|
]);
|
||||||
exec('ffmpeg '.$sParams, $asResult);
|
exec('ffmpeg '.$sParams, $asResult);
|
||||||
|
|
||||||
//Resize
|
//Resize
|
||||||
$asThumbInfo = ToolBox::createThumbnail($sTempPath, self::THUMB_MAX_WIDTH, 0, $sThumbPath, true);
|
$asThumbInfo = ToolBox::createThumbnail($sTempPath, self::THUMB_MAX_WIDTH, 0, $sThumbPath, true);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$asThumbInfo = ['error'=>'error.unknown_type', 'out'=>''];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else $asThumbInfo = array('error'=>'', 'out'=>$sThumbPath);
|
else $asThumbInfo = ['error'=>'', 'out'=>$sThumbPath];
|
||||||
|
|
||||||
return ($asThumbInfo['error']=='')?$asThumbInfo['out']:$sMediaPath;
|
return ($asThumbInfo['error']=='')?$asThumbInfo['out']:$sMediaPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getMediaPath($sMediaName, $sFileType='media') {
|
private static function getMediaPath($sMediaName, $sFileType='media') {
|
||||||
if($sFileType=='thumbnail') return self::THUMB_FOLDER.$sMediaName.(strtolower(substr($sMediaName, -3))=='mov'?'.png':'');
|
if($sFileType=='thumbnail') return self::THUMB_FOLDER.'/'.$sMediaName.(strtolower(substr($sMediaName, -3))=='mov'?'.png':'');
|
||||||
else return self::MEDIA_FOLDER.$sMediaName;
|
else return self::MEDIA_FOLDER.'/'.$sMediaName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getMediaType($sMediaName) {
|
private static function getMediaType($sMediaName) {
|
||||||
$sMediaPath = self::getMediaPath($sMediaName);
|
$sMediaPath = self::getMediaPath($sMediaName);
|
||||||
$sMediaMime = mime_content_type($sMediaPath);
|
$sMediaMime = mime_content_type($sMediaPath);
|
||||||
switch($sMediaMime) {
|
switch($sMediaMime) {
|
||||||
case 'video/quicktime': $sType = 'video'; break;
|
case 'video/quicktime':
|
||||||
|
case 'video/mp4': $sType = 'video'; break;
|
||||||
default: $sType = 'image'; break;
|
default: $sType = 'image'; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +322,6 @@ class Media extends PhpObject {
|
|||||||
|
|
||||||
private static function getLatLngAltFromISO6709($sIso6709) {
|
private static function getLatLngAltFromISO6709($sIso6709) {
|
||||||
preg_match('/^(?P<lat>[\+\-][0,1]?\d{2}\.\d+)(?P<lng>[\+\-][0,1]?\d{2}\.\d+)(?P<alt>[\+\-]\d+)?/', $sIso6709, $asMatches);
|
preg_match('/^(?P<lat>[\+\-][0,1]?\d{2}\.\d+)(?P<lng>[\+\-][0,1]?\d{2}\.\d+)(?P<alt>[\+\-]\d+)?/', $sIso6709, $asMatches);
|
||||||
return array(floatval($asMatches['lat']), floatval($asMatches['lng']), floatval($asMatches['alt'] ?? 0));
|
return [floatval($asMatches['lat']), floatval($asMatches['lng']), floatval($asMatches['alt'] ?? 0)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-47
@@ -1,20 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Db;
|
use Franzz\Objects\Db;
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
class Project extends PhpObject {
|
class Project extends PhpObject {
|
||||||
|
|
||||||
//Spot Mode
|
//Spot Mode
|
||||||
const MODE_PREVIZ = 'P';
|
public const MODE_PREVIZ = 'P';
|
||||||
const MODE_BLOG = 'B';
|
public const MODE_BLOG = 'B';
|
||||||
const MODE_HISTO = 'H';
|
public const MODE_HISTO = 'H';
|
||||||
const MODES = array('previz'=>self::MODE_PREVIZ, 'blog'=>self::MODE_BLOG, 'histo'=>self::MODE_HISTO);
|
public const MODES = ['previz'=>self::MODE_PREVIZ, 'blog'=>self::MODE_BLOG, 'histo'=>self::MODE_HISTO];
|
||||||
|
|
||||||
//DB Tables
|
//DB Tables
|
||||||
const PROJ_TABLE = 'projects';
|
public const PROJ_TABLE = 'projects';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Handle
|
* Database Handle
|
||||||
@@ -22,13 +21,11 @@ class Project extends PhpObject {
|
|||||||
*/
|
*/
|
||||||
private $oDb;
|
private $oDb;
|
||||||
|
|
||||||
|
|
||||||
private $iProjectId;
|
private $iProjectId;
|
||||||
private $sName;
|
private $sName;
|
||||||
private $sCodeName;
|
private $sCodeName;
|
||||||
private $sMode;
|
private $sMode;
|
||||||
private $asActive;
|
private $asActive;
|
||||||
private $asGeo;
|
|
||||||
|
|
||||||
public function __construct(Db &$oDb, $iProjectId=0) {
|
public function __construct(Db &$oDb, $iProjectId=0) {
|
||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
@@ -53,17 +50,17 @@ class Project extends PhpObject {
|
|||||||
* Mode --P--][--------B--------][--P--][-----------B---------------][---P---][-----B-----][---------H----------
|
* Mode --P--][--------B--------][--P--][-----------B---------------][---P---][-----B-----][---------H----------
|
||||||
*/
|
*/
|
||||||
$sQuery =
|
$sQuery =
|
||||||
"SELECT MAX(id_project) ".
|
'SELECT MAX(id_project) '.
|
||||||
"FROM projects ".
|
'FROM projects '.
|
||||||
"WHERE active_to = (".
|
'WHERE active_to = ('.
|
||||||
"SELECT MIN(active_to) ". //Select closest project in the future
|
'SELECT MIN(active_to) '. //Select closest project in the future
|
||||||
"FROM projects ".
|
'FROM projects '.
|
||||||
"WHERE active_to > NOW() ". //Select Next project
|
'WHERE active_to > NOW() '. //Select Next project
|
||||||
"OR active_to = (". //In case there is no next project, select the last one
|
'OR active_to = ('. //In case there is no next project, select the last one
|
||||||
"SELECT MAX(active_to) ".
|
'SELECT MAX(active_to) '.
|
||||||
"FROM projects".
|
'FROM projects'.
|
||||||
")".
|
')'.
|
||||||
")";
|
')';
|
||||||
$asResult = $this->oDb->getArrayQuery($sQuery, true);
|
$asResult = $this->oDb->getArrayQuery($sQuery, true);
|
||||||
$this->iProjectId = array_shift($asResult);
|
$this->iProjectId = array_shift($asResult);
|
||||||
}
|
}
|
||||||
@@ -72,7 +69,7 @@ class Project extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createProjectId() {
|
public function createProjectId() {
|
||||||
$this->setProjectId($this->oDb->insertRow(self::PROJ_TABLE, array('codename'=>'')));
|
$this->setProjectId($this->oDb->insertRow(self::PROJ_TABLE, ['codename'=>'']));
|
||||||
return $this->getProjectId();
|
return $this->getProjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,39 +111,49 @@ class Project extends PhpObject {
|
|||||||
return $this->oDb->selectColumn(
|
return $this->oDb->selectColumn(
|
||||||
Feed::FEED_TABLE,
|
Feed::FEED_TABLE,
|
||||||
Db::getId(Feed::FEED_TABLE),
|
Db::getId(Feed::FEED_TABLE),
|
||||||
array(Db::getId(self::PROJ_TABLE) => $this->getProjectId())
|
[Db::getId(self::PROJ_TABLE) => $this->getProjectId()]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProjects($iProjectId=0) {
|
public function getProjects($iProjectId=0) {
|
||||||
$bSpecificProj = ($iProjectId > 0);
|
$bSpecificProj = ($iProjectId > 0);
|
||||||
$asInfo = array(
|
$sDefaultProjectCodeName = $this->getProjectCodeName();
|
||||||
'select'=> array(
|
$asInfo = [
|
||||||
Db::getId(self::PROJ_TABLE)." AS id",
|
'select'=> [
|
||||||
|
Db::getId(self::PROJ_TABLE).' AS id',
|
||||||
'codename',
|
'codename',
|
||||||
'name',
|
'name',
|
||||||
|
'latitude',
|
||||||
|
'longitude',
|
||||||
'active_from',
|
'active_from',
|
||||||
'active_to',
|
'active_to',
|
||||||
"IF(NOW() BETWEEN active_from AND active_to, 1, IF(NOW() < active_from, 0, 2)) AS mode"
|
'IF(NOW() BETWEEN active_from AND active_to, 1, IF(NOW() < active_from, 0, 2)) AS mode'
|
||||||
),
|
],
|
||||||
'from' => self::PROJ_TABLE
|
'from' => self::PROJ_TABLE,
|
||||||
);
|
'orderBy' => ['active_from' => 'ASC']
|
||||||
if($bSpecificProj) $asInfo['constraint'] = array(Db::getId(self::PROJ_TABLE)=>$iProjectId);
|
];
|
||||||
|
if($bSpecificProj) $asInfo['constraint'] = [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 geoJSON
|
||||||
|
if(Converter::hasGpxFile($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;
|
||||||
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
||||||
}
|
}
|
||||||
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
||||||
|
$asProject['gpxfilepath'] = Livetrail::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
||||||
if($sCodeName != '' && !Converter::isGeoJsonValid($sCodeName)) Converter::convertToGeoJson($sCodeName);
|
$asProject['geofilepath'] = Livetrail::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
|
||||||
|
|
||||||
$asProject['geofilepath'] = Spot::addTimestampToFilePath(GeoJson::getDistFilePath($sCodeName));
|
|
||||||
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getDistFilePath($sCodeName));
|
|
||||||
$asProject['codename'] = $sCodeName;
|
$asProject['codename'] = $sCodeName;
|
||||||
|
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
|
||||||
}
|
}
|
||||||
return $bSpecificProj?$asProject:$asProjects;
|
return $bSpecificProj?$asProject:$asProjects;
|
||||||
}
|
}
|
||||||
@@ -166,7 +173,7 @@ class Project extends PhpObject {
|
|||||||
return $iLastUpdate;
|
return $iLastUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastMessageId($asConstraints=array()): int {
|
public function getLastMessageId($asConstraints=[]): int {
|
||||||
$iLastMsg = 0;
|
$iLastMsg = 0;
|
||||||
|
|
||||||
$asFeedIds = $this->getFeedIds();
|
$asFeedIds = $this->getFeedIds();
|
||||||
@@ -184,34 +191,35 @@ class Project extends PhpObject {
|
|||||||
$this->sName = $asProject['name'];
|
$this->sName = $asProject['name'];
|
||||||
$this->sCodeName = $asProject['codename'];
|
$this->sCodeName = $asProject['codename'];
|
||||||
$this->sMode = $asProject['mode'];
|
$this->sMode = $asProject['mode'];
|
||||||
$this->asActive = array('from'=>$asProject['active_from'], 'to'=>$asProject['active_to']);
|
$this->asActive = ['from'=>$asProject['active_from'], 'to'=>$asProject['active_to']];
|
||||||
$this->asGeo = array('geofile'=>$asProject['geofilepath'], 'gpxfile'=>$asProject['gpxfilepath']);
|
|
||||||
}
|
}
|
||||||
else $this->addError('Error while setting project: no project ID');
|
else $this->addError('Error while setting project: no project ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateField($sField, $oValue) {
|
private function updateField($sField, $oValue) {
|
||||||
$bResult = ($this->oDb->updateRow(self::PROJ_TABLE, $this->getProjectId(), array($sField=>$oValue)) > 0);
|
$bResult = ($this->oDb->updateRow(self::PROJ_TABLE, $this->getProjectId(), [$sField=>$oValue]) > 0);
|
||||||
$this->setProjectInfo();
|
$this->setProjectInfo();
|
||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$asResult = array();
|
$asResult = [];
|
||||||
if($this->getProjectId() > 0) {
|
if($this->getProjectId() > 0) {
|
||||||
$asFeedIds = $this->getFeedIds();
|
$asFeedIds = $this->getFeedIds();
|
||||||
foreach($asFeedIds as $iFeedId) {
|
foreach($asFeedIds as $iFeedId) {
|
||||||
$asResult['feed'][] = (new Feed($this->oDb, $iFeedId))->delete();
|
$asResult['feed'][] = (new Feed($this->oDb, $iFeedId))->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$asResult['project'][] = array(
|
$bDeleted = $this->oDb->deleteRow(self::PROJ_TABLE, $this->getProjectId());
|
||||||
|
$asResult['project'][] = [
|
||||||
'id' => $this->getProjectId(),
|
'id' => $this->getProjectId(),
|
||||||
'del' => $this->oDb->deleteRow(self::PROJ_TABLE, $this->getProjectId()),
|
'del' => $bDeleted,
|
||||||
'desc' => $this->oDb->getLastError()
|
'desc_lang_id' => $bDeleted?'':'error.commit_db',
|
||||||
);
|
'desc_lang_params' => []
|
||||||
|
];
|
||||||
}
|
}
|
||||||
else $asResult['project'][] = array('del'=>false, 'desc'=>'Error while setting project: no project ID');
|
else $asResult['project'][] = ['del'=>false, 'desc_lang_id'=>'error.impossible_value', 'desc_lang_params'=>[$this->getProjectId(), 'project ID']];
|
||||||
|
|
||||||
return $asResult;
|
return $asResult;
|
||||||
}
|
}
|
||||||
@@ -220,7 +228,7 @@ class Project extends PhpObject {
|
|||||||
return self::isModeEditable($this->getMode());
|
return self::isModeEditable($this->getMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function isModeEditable($sMode) {
|
public static function isModeEditable($sMode) {
|
||||||
return ($sMode != self::MODE_HISTO);
|
return ($sMode != self::MODE_HISTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-837
@@ -1,837 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
|
||||||
use Franzz\Objects\Db;
|
|
||||||
use Franzz\Objects\Main;
|
|
||||||
use Franzz\Objects\Translator;
|
|
||||||
use Franzz\Objects\ToolBox;
|
|
||||||
use Franzz\Objects\Mask;
|
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
/* Timezones
|
|
||||||
* ---------
|
|
||||||
* Site Time: Timestamp converted to the Timezone from which the user is viewing the Site (default PHP/SQL Timezone)
|
|
||||||
* Local Time: Timestamp converted to the Timezone from which the content (media/post/message) has been sent (Local Timezone stored in timezone field)
|
|
||||||
*
|
|
||||||
* - Feeds (table `feeds`):
|
|
||||||
* - last_update: timestamp in Site Time
|
|
||||||
* - Spot Messages (table `messages`):
|
|
||||||
* - unix_time: UNIX (int) in UTC
|
|
||||||
* - site_time: timestamp in Site Time
|
|
||||||
* - iso_time: raw ISO 8601 in UTC or Local Time (spot messages are unreliable, timezone is then calculated from GPS coordinates)
|
|
||||||
* - posted_on: timestamp in Site Time
|
|
||||||
* - timezone: Local Timezone
|
|
||||||
* - Medias (table `medias`):
|
|
||||||
* - posted_on: timestamp in Site Time
|
|
||||||
* - taken_on: timestamp in Site Time
|
|
||||||
* - timezone: Local Timezone
|
|
||||||
* - Posts (table `posts`):
|
|
||||||
* - site_time: timestamp in Site Time
|
|
||||||
* - timezone: Local Timezone
|
|
||||||
* - Users (table `users`):
|
|
||||||
* - timezone: Site Timezone (stored user's timezone for emails)
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Spot extends Main
|
|
||||||
{
|
|
||||||
//Database
|
|
||||||
const POST_TABLE = 'posts';
|
|
||||||
|
|
||||||
const FEED_CHUNK_SIZE = 15;
|
|
||||||
const MAIL_CHUNK_SIZE = 5;
|
|
||||||
|
|
||||||
const DEFAULT_LANG = 'en';
|
|
||||||
|
|
||||||
const MAIN_PAGE = 'index';
|
|
||||||
|
|
||||||
private Project $oProject;
|
|
||||||
private Media $oMedia;
|
|
||||||
private User $oUser;
|
|
||||||
private Map $oMap;
|
|
||||||
|
|
||||||
public function __construct($sProcessPage, $sTimezone)
|
|
||||||
{
|
|
||||||
parent::__construct($sProcessPage, true, $sTimezone);
|
|
||||||
|
|
||||||
$this->oUser = new User($this->oDb);
|
|
||||||
|
|
||||||
$this->oLang = new Translator('', self::DEFAULT_LANG);
|
|
||||||
|
|
||||||
$this->oProject = new Project($this->oDb);
|
|
||||||
$this->oMedia = new Media($this->oDb, $this->oProject);
|
|
||||||
|
|
||||||
$this->oMap = new Map($this->oDb);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function install()
|
|
||||||
{
|
|
||||||
//Install DB
|
|
||||||
$this->oDb->install();
|
|
||||||
|
|
||||||
//Add first user
|
|
||||||
$iUserId = $this->oDb->insertRow(User::USER_TABLE, array(
|
|
||||||
'name' => 'Admin',
|
|
||||||
'email' => 'admin@admin.com',
|
|
||||||
'language' => self::DEFAULT_LANG,
|
|
||||||
'timezone' => date_default_timezone_get(),
|
|
||||||
'active' => User::USER_ACTIVE,
|
|
||||||
'clearance' => User::CLEARANCE_ADMIN
|
|
||||||
));
|
|
||||||
$this->oUser->setUserId($iUserId);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getSqlOptions()
|
|
||||||
{
|
|
||||||
return array
|
|
||||||
(
|
|
||||||
'tables' => array
|
|
||||||
(
|
|
||||||
Feed::MSG_TABLE => array('ref_msg_id', Db::getId(Feed::FEED_TABLE), 'type', 'latitude', 'longitude', 'iso_time', 'site_time', 'timezone', 'unix_time', 'content', 'battery_state', 'posted_on', 'weather_icon', 'weather_cond', 'weather_temp', 'display'),
|
|
||||||
Feed::FEED_TABLE => array('ref_feed_id', Db::getId(Feed::SPOT_TABLE), Db::getId(Project::PROJ_TABLE), 'name', 'description', 'status', 'last_update'),
|
|
||||||
Feed::SPOT_TABLE => array('ref_spot_id', 'name', 'model'),
|
|
||||||
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
|
|
||||||
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone'),
|
|
||||||
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'latitude', 'longitude', 'altitude', 'width', 'height', 'rotate', 'comment'),
|
|
||||||
User::USER_TABLE => array('name', 'email', 'gravatar', 'language', 'timezone', 'active', 'clearance'),
|
|
||||||
Map::MAP_TABLE => array('codename', 'pattern', 'token', 'tile_size', 'min_zoom', 'max_zoom', 'attribution'),
|
|
||||||
Map::MAPPING_TABLE => array(Db::getId(Map::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
|
||||||
),
|
|
||||||
'types' => array
|
|
||||||
(
|
|
||||||
'active' => "BOOLEAN DEFAULT ".User::USER_INACTIVE,
|
|
||||||
'clearance' => "TINYINT(1) DEFAULT ".User::CLEARANCE_USER,
|
|
||||||
'active_from' => "TIMESTAMP DEFAULT 0",
|
|
||||||
'active_to' => "TIMESTAMP DEFAULT 0",
|
|
||||||
'battery_state' => "VARCHAR(10)",
|
|
||||||
'codename' => "VARCHAR(100)",
|
|
||||||
'content' => "LONGTEXT",
|
|
||||||
'comment' => "LONGTEXT",
|
|
||||||
'description' => "VARCHAR(100)",
|
|
||||||
'email' => "VARCHAR(320) NOT NULL",
|
|
||||||
'filename' => "VARCHAR(100) NOT NULL",
|
|
||||||
'iso_time' => "VARCHAR(24)",
|
|
||||||
'language' => "VARCHAR(2)",
|
|
||||||
'last_update' => "TIMESTAMP DEFAULT 0",
|
|
||||||
'latitude' => "DECIMAL(7,5)",
|
|
||||||
'longitude' => "DECIMAL(8,5)",
|
|
||||||
'altitude' => "SMALLINT",
|
|
||||||
'model' => "VARCHAR(20)",
|
|
||||||
'name' => "VARCHAR(100)",
|
|
||||||
'pattern' => "VARCHAR(200) NOT NULL",
|
|
||||||
'posted_on' => "TIMESTAMP DEFAULT 0",
|
|
||||||
'ref_feed_id' => "VARCHAR(40)",
|
|
||||||
'ref_msg_id' => "VARCHAR(15)",
|
|
||||||
'ref_spot_id' => "VARCHAR(10)",
|
|
||||||
'rotate' => "SMALLINT",
|
|
||||||
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
|
|
||||||
'status' => "VARCHAR(10)",
|
|
||||||
'taken_on' => "TIMESTAMP DEFAULT 0",
|
|
||||||
'timezone' => "CHAR(64) NOT NULL", //see mysql.time_zone_name
|
|
||||||
'token' => "VARCHAR(4096)",
|
|
||||||
'type' => "VARCHAR(20)",
|
|
||||||
'unix_time' => "INT",
|
|
||||||
'min_zoom' => "TINYINT UNSIGNED",
|
|
||||||
'max_zoom' => "TINYINT UNSIGNED",
|
|
||||||
'attribution' => "VARCHAR(100)",
|
|
||||||
'gravatar' => "LONGTEXT",
|
|
||||||
'weather_icon' => "VARCHAR(30)",
|
|
||||||
'weather_cond' => "VARCHAR(30)",
|
|
||||||
'weather_temp' => "DECIMAL(3,1)",
|
|
||||||
'tile_size' => "SMALLINT UNSIGNED DEFAULT 256",
|
|
||||||
'width' => "INT",
|
|
||||||
'height' => "INT",
|
|
||||||
'display' => "BOOLEAN DEFAULT ".Feed::MSG_DISPLAYED
|
|
||||||
),
|
|
||||||
'constraints' => array
|
|
||||||
(
|
|
||||||
Feed::MSG_TABLE => array("UNIQUE KEY `uni_ref_msg_id` (`ref_msg_id`)", "INDEX(`ref_msg_id`)"),
|
|
||||||
Feed::FEED_TABLE => array("UNIQUE KEY `uni_ref_feed_id` (`ref_feed_id`)", "INDEX(`ref_feed_id`)"),
|
|
||||||
Feed::SPOT_TABLE => array("UNIQUE KEY `uni_ref_spot_id` (`ref_spot_id`)", "INDEX(`ref_spot_id`)"),
|
|
||||||
Project::PROJ_TABLE => "UNIQUE KEY `uni_proj_name` (`codename`)",
|
|
||||||
Media::MEDIA_TABLE => "UNIQUE KEY `uni_file_name` (`filename`)",
|
|
||||||
User::USER_TABLE => "UNIQUE KEY `uni_email` (`email`)",
|
|
||||||
Map::MAP_TABLE => "UNIQUE KEY `uni_map_name` (`codename`)"
|
|
||||||
),
|
|
||||||
'cascading_delete' => array
|
|
||||||
(
|
|
||||||
Feed::SPOT_TABLE => array(Feed::FEED_TABLE),
|
|
||||||
Feed::FEED_TABLE => array(Feed::MSG_TABLE),
|
|
||||||
Project::PROJ_TABLE => array(Feed::FEED_TABLE, Media::MEDIA_TABLE, self::POST_TABLE, Map::MAPPING_TABLE),
|
|
||||||
Map::MAP_TABLE => array(Map::MAPPING_TABLE)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAppMainPage() {
|
|
||||||
|
|
||||||
//Cache Page List
|
|
||||||
$asPages = array_diff($this->asMasks, array('email_update', 'email_conf'));
|
|
||||||
if(!$this->oUser->checkUserClearance(User::CLEARANCE_ADMIN)) {
|
|
||||||
$asPages = array_diff($asPages, array('admin', 'upload'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getMainPage(
|
|
||||||
array(
|
|
||||||
'vars' => array(
|
|
||||||
'chunk_size' => self::FEED_CHUNK_SIZE,
|
|
||||||
'default_project_codename' => $this->oProject->getProjectCodeName(),
|
|
||||||
'projects' => $this->oProject->getProjects(),
|
|
||||||
'user' => $this->oUser->getUserInfo()
|
|
||||||
),
|
|
||||||
'consts' => array(
|
|
||||||
'modes' => Project::MODES,
|
|
||||||
'clearances' => User::CLEARANCES,
|
|
||||||
'default_timezone' => Settings::TIMEZONE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
self::MAIN_PAGE,
|
|
||||||
array(
|
|
||||||
'language' => $this->oLang->getLanguage(),
|
|
||||||
'filepath_css' => self::addTimestampToFilePath('spot.css'),
|
|
||||||
'filepath_js' => self::addTimestampToFilePath('../dist/app.js'),
|
|
||||||
),
|
|
||||||
$asPages
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkUserClearance($iClearance) {
|
|
||||||
return $this->oUser->checkUserClearance($iClearance);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Managing projects */
|
|
||||||
|
|
||||||
public function setProjectId($iProjectId=0) {
|
|
||||||
$this->oProject->setProjectId($iProjectId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateProject() {
|
|
||||||
$bNewMsg = false;
|
|
||||||
$bSuccess = true;
|
|
||||||
$sDesc = '';
|
|
||||||
|
|
||||||
//Update all feeds belonging to the project
|
|
||||||
$asFeeds = $this->oProject->getFeedIds();
|
|
||||||
foreach($asFeeds as $iFeedId) {
|
|
||||||
$oFeed = new Feed($this->oDb, $iFeedId);
|
|
||||||
$bNewMsg = $bNewMsg || $oFeed->checkUpdateFeed($this->oProject->getMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send Update Email
|
|
||||||
if($bNewMsg) {
|
|
||||||
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
|
||||||
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
|
||||||
|
|
||||||
//Add Position
|
|
||||||
$asLastMessage = array_shift($this->getSpotMessages(array($this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE)))));
|
|
||||||
$oEmail->oTemplate->setTags($asLastMessage);
|
|
||||||
$oEmail->oTemplate->setTag('date_time', 'time:'.$asLastMessage['unix_time'], 'd/m/Y, H:i');
|
|
||||||
|
|
||||||
//Add latest news feed
|
|
||||||
$asNews = $this->getNextFeed(0, true);
|
|
||||||
$iPostCount = 0;
|
|
||||||
foreach($asNews as $asPost) {
|
|
||||||
if($asPost['type'] != 'message') {
|
|
||||||
$oEmail->oTemplate->newInstance('news');
|
|
||||||
$oEmail->oTemplate->setInstanceTags('news', array(
|
|
||||||
'local_server' => $this->asContext['serv_name'],
|
|
||||||
'project' => $this->oProject->getProjectCodeName(),
|
|
||||||
'type' => $asPost['type'],
|
|
||||||
'id' => $asPost['id_'.$asPost['type']])
|
|
||||||
);
|
|
||||||
$oEmail->oTemplate->addInstance($asPost['type'], $asPost);
|
|
||||||
$oEmail->oTemplate->setInstanceTag($asPost['type'], 'local_server', $this->asContext['serv_name']);
|
|
||||||
$iPostCount++;
|
|
||||||
}
|
|
||||||
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bSuccess = $oEmail->send();
|
|
||||||
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
|
||||||
}
|
|
||||||
else $sDesc = 'no_new_msg';
|
|
||||||
|
|
||||||
return self::getJsonResult($bSuccess, $sDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function genCronFile() {
|
|
||||||
//$bSuccess = (file_put_contents('spot_cron.sh', '#!/bin/bash'."\n".'cd '.dirname($_SERVER['SCRIPT_FILENAME'])."\n".'php -f index.php a=update_feed')!==false);
|
|
||||||
$sFileName = 'spot_cron.sh';
|
|
||||||
$sContent =
|
|
||||||
'#!/bin/bash'."\n".
|
|
||||||
'wget -qO- '.$this->asContext['serv_name'].'index.php?a=update_project > /dev/null'."\n".
|
|
||||||
'#Crontab job: 0 * * * * . '.dirname($_SERVER['SCRIPT_FILENAME']).'/'.$sFileName.' > /dev/null'."\n";
|
|
||||||
$bSuccess = (file_put_contents($sFileName, $sContent)!==false);
|
|
||||||
return self::getJsonResult($bSuccess, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMarkers($asMessageIds=array(), $asMediaIds=array(), $bInternal=false)
|
|
||||||
{
|
|
||||||
$asMessages = $this->getSpotMessages($asMessageIds);
|
|
||||||
$asGeoMedias = array();
|
|
||||||
usort($asMessages, function($a, $b){return $a['unix_time'] > $b['unix_time'];});
|
|
||||||
$bHasMsg = !empty($asMessages);
|
|
||||||
|
|
||||||
//Add medias
|
|
||||||
$asMedias = $this->getMedias('taken_on', $asMediaIds);
|
|
||||||
usort($asMedias, function($a, $b){return $a['unix_time'] > $b['unix_time'];});
|
|
||||||
|
|
||||||
//Assign medias to closest message
|
|
||||||
$iIndex = 0;
|
|
||||||
$iMaxIndex = count($asMessages) - 1;
|
|
||||||
foreach($asMedias as $asMedia) {
|
|
||||||
if($asMedia['latitude']!='' && $asMedia['longitude']!='') $asGeoMedias[] = $asMedia;
|
|
||||||
elseif($bHasMsg) {
|
|
||||||
while($iIndex <= $iMaxIndex && $asMedia['unix_time'] > $asMessages[$iIndex]['unix_time']) $iIndex++;
|
|
||||||
|
|
||||||
//All medias before first message or after last message are assigned to first/last message respectively
|
|
||||||
if($iIndex == 0) $iMsgIndex = $iIndex;
|
|
||||||
elseif($iIndex > $iMaxIndex) $iMsgIndex = $iMaxIndex;
|
|
||||||
else {
|
|
||||||
$iHalfWayPoint = ($asMessages[$iIndex - 1]['unix_time'] + $asMessages[$iIndex]['unix_time'])/2;
|
|
||||||
$iMsgIndex = ($asMedia['unix_time'] >= $iHalfWayPoint)?$iIndex:($iIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$asMessages[$iMsgIndex]['medias'][] = $asMedia;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Spot Last Update
|
|
||||||
$asLastUpdate = array();
|
|
||||||
$this->addTimeStamp($asLastUpdate, $this->oProject->getLastUpdate());
|
|
||||||
|
|
||||||
$asResult = array(
|
|
||||||
'messages' => $asMessages,
|
|
||||||
'medias' => $asGeoMedias,
|
|
||||||
'maps' => $this->oMap->getProjectMaps($this->oProject->getProjectId()),
|
|
||||||
'last_update' => $asLastUpdate
|
|
||||||
);
|
|
||||||
|
|
||||||
return $bInternal?$asResult:self::getJsonResult(true, '', $asResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function subscribe($sEmail, $sNickName) {
|
|
||||||
$asResult = $this->oUser->addUser($sEmail, $this->oLang->getLanguage(), date_default_timezone_get(), $sNickName);
|
|
||||||
$asUserInfo = $this->oUser->getUserInfo();
|
|
||||||
|
|
||||||
//Send Confirmation Email
|
|
||||||
if($asResult['result'] && $asResult['desc']=='lang:nl_subscribed') {
|
|
||||||
$oConfEmail = new Email($this->asContext['serv_name'], 'email_conf');
|
|
||||||
$oConfEmail->setDestInfo($asUserInfo);
|
|
||||||
$oConfEmail->send();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::getJsonResult($asResult['result'], $asResult['desc'], $asUserInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unsubscribe() {
|
|
||||||
$asResult = $this->oUser->removeUser();
|
|
||||||
return self::getJsonResult($asResult['result'], $asResult['desc'], $asResult['data']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unsubscribeFromEmail($iUserId) {
|
|
||||||
$this->oUser->setUserId($iUserId);
|
|
||||||
$this->oLang->setLanguage($this->oUser->getLang(), self::DEFAULT_LANG);
|
|
||||||
$asResult = $this->oUser->removeUser();
|
|
||||||
|
|
||||||
$sDesc = explode(':', $asResult['desc'])[1];
|
|
||||||
return $this->oLang->getTranslation($sDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getSpotMessages($asMsgIds=array())
|
|
||||||
{
|
|
||||||
$asConstraints = $this->getFeedConstraints(Feed::MSG_TABLE);
|
|
||||||
if(!empty($asMsgIds)) {
|
|
||||||
$asConstraints['constraint'][Db::getId(Feed::MSG_TABLE)] = $asMsgIds;
|
|
||||||
$asConstraints['constOpe'][Db::getId(Feed::MSG_TABLE)] = 'IN';
|
|
||||||
}
|
|
||||||
|
|
||||||
$asCombinedMessages = array();
|
|
||||||
|
|
||||||
//Get messages from all feeds belonging to the project
|
|
||||||
$asFeeds = $this->oProject->getFeedIds();
|
|
||||||
foreach($asFeeds as $iFeedId) {
|
|
||||||
$oFeed = new Feed($this->oDb, $iFeedId);
|
|
||||||
$asMessages = $oFeed->getMessages($asConstraints);
|
|
||||||
foreach($asMessages as $asMessage)
|
|
||||||
{
|
|
||||||
$asMessage['latitude'] = floatval($asMessage['latitude']);
|
|
||||||
$asMessage['longitude'] = floatval($asMessage['longitude']);
|
|
||||||
$asMessage['lat_dms'] = self::decToDms($asMessage['latitude'], 'lat');
|
|
||||||
$asMessage['lon_dms'] = self::decToDms($asMessage['longitude'], 'lon');
|
|
||||||
$asMessage['displayed_id'] = $asMessage[Db::getId(Feed::MSG_TABLE)];
|
|
||||||
$asMessage['static_img_url'] = $this->oMap->getMapUrl('static', array('x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']));
|
|
||||||
$asMessage['marker_img_url'] = $this->oMap->getMapUrl('static_marker', array('x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']));
|
|
||||||
|
|
||||||
$this->addTimeStamp($asMessage, $asMessage['unix_time'], $asMessage['timezone']);
|
|
||||||
$asCombinedMessages[] = $asMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $asCombinedMessages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get valid medias based on $sTimeRefField:
|
|
||||||
* - taken_on: Date/time on which the media was taken
|
|
||||||
* - posted_on: Date/time on which the media was uploaded
|
|
||||||
* @param String $sTimeRefField Field to calculate relative times: 'taken_on' or 'posted_on'
|
|
||||||
* @return Array Medias info
|
|
||||||
*/
|
|
||||||
private function getMedias($sTimeRefField, $asMediaIds=array())
|
|
||||||
{
|
|
||||||
//Constraints
|
|
||||||
$asConstraints = $this->getFeedConstraints(Media::MEDIA_TABLE, $sTimeRefField);
|
|
||||||
if(!empty($asMediaIds)) {
|
|
||||||
$asConstraints['constraint'][Db::getId(Media::MEDIA_TABLE)] = $asMediaIds;
|
|
||||||
$asConstraints['constOpe'][Db::getId(Media::MEDIA_TABLE)] = 'IN';
|
|
||||||
}
|
|
||||||
|
|
||||||
$asMedias = $this->oMedia->getMediasInfo($asConstraints);
|
|
||||||
foreach($asMedias as &$asMedia) {
|
|
||||||
$iTimeStampTakenOn = strtotime($asMedia['taken_on']);
|
|
||||||
$iTimeStampPostedOn = strtotime($asMedia['posted_on']);
|
|
||||||
$asMedia['taken_on_formatted'] = $this->getTimeFormat($iTimeStampTakenOn);
|
|
||||||
$asMedia['taken_on_formatted_local'] = $this->getTimeFormat($iTimeStampTakenOn, $asMedia['timezone']);
|
|
||||||
$asMedia['posted_on_formatted'] = $this->getTimeFormat($iTimeStampPostedOn);
|
|
||||||
$asMedia['posted_on_formatted_local'] = $this->getTimeFormat($iTimeStampPostedOn, $asMedia['timezone']);
|
|
||||||
$asMedia['displayed_id'] = $asMedia[Db::getId(Media::MEDIA_TABLE)];
|
|
||||||
|
|
||||||
$this->addTimeStamp($asMedia, strtotime($asMedia[$sTimeRefField]), $asMedia['timezone']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $asMedias;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getPosts($asPostIds=array())
|
|
||||||
{
|
|
||||||
$asInfo = array(
|
|
||||||
'select' => array(Db::getFullColumnName(self::POST_TABLE, '*'), 'gravatar'),
|
|
||||||
'from' => self::POST_TABLE,
|
|
||||||
'join' => array(User::USER_TABLE => Db::getId(User::USER_TABLE))
|
|
||||||
);
|
|
||||||
$asInfo = array_merge($asInfo, $this->getFeedConstraints(self::POST_TABLE));
|
|
||||||
|
|
||||||
if(!empty($asPostIds)) {
|
|
||||||
$asInfo['constraint'][Db::getId(self::POST_TABLE)] = $asPostIds;
|
|
||||||
$asInfo['constOpe'][Db::getId(self::POST_TABLE)] = 'IN';
|
|
||||||
}
|
|
||||||
$asPosts = $this->oDb->selectRows($asInfo);
|
|
||||||
|
|
||||||
foreach($asPosts as &$asPost) {
|
|
||||||
$iUnixTimeStamp = strtotime($asPost['site_time']); //assumes site timezone
|
|
||||||
$asPost['formatted_name'] = Toolbox::mb_ucwords($asPost['name']);
|
|
||||||
unset($asPost[Db::getId(User::USER_TABLE)]);
|
|
||||||
|
|
||||||
$this->addTimeStamp($asPost, $iUnixTimeStamp, $asPost['timezone']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $asPosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addTimeStamp(&$asData, $iTime, $sTimeZone='') {
|
|
||||||
$asData['unix_time'] = (int) $iTime;
|
|
||||||
$asData['relative_time'] = Toolbox::getDateTimeDesc($iTime, $this->oLang->getLanguage());
|
|
||||||
$asData['formatted_time'] = $this->getTimeFormat($iTime);
|
|
||||||
|
|
||||||
if($sTimeZone != '') {
|
|
||||||
$asData['formatted_time_local'] = $this->getTimeFormat($iTime, $sTimeZone);
|
|
||||||
$asData['day_offset'] = self::getTimeZoneDayOffset($iTime, $sTimeZone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getFeedConstraints($sType, $sTimeField='site_time', $sReturnFormat='array') {
|
|
||||||
$asConsArray = array();
|
|
||||||
$sConsSql = "";
|
|
||||||
$asActPeriod = $this->oProject->getActivePeriod();
|
|
||||||
|
|
||||||
//Filter on Project ID
|
|
||||||
$sConsSql = "WHERE ".Db::getId(Project::PROJ_TABLE)." = ".$this->oProject->getProjectId();
|
|
||||||
$asConsArray = array(
|
|
||||||
'constraint'=> array(Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId()),
|
|
||||||
'constOpe' => array(Db::getId(Project::PROJ_TABLE) => "=")
|
|
||||||
);
|
|
||||||
|
|
||||||
//Time Filter
|
|
||||||
switch($sType) {
|
|
||||||
case Feed::MSG_TABLE:
|
|
||||||
$asConsArray['constraint'][$sTimeField] = $asActPeriod;
|
|
||||||
$asConsArray['constOpe'][$sTimeField] = "BETWEEN";
|
|
||||||
$asConsArray['constraint']['display'] = Feed::MSG_DISPLAYED;
|
|
||||||
$asConsArray['constOpe']['display'] = "=";
|
|
||||||
$sConsSql .= " AND ".$sTimeField." BETWEEN '".$asActPeriod['from']."' AND '".$asActPeriod['to']."' AND display = ".Feed::MSG_DISPLAYED;
|
|
||||||
break;
|
|
||||||
case Media::MEDIA_TABLE:
|
|
||||||
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];
|
|
||||||
$asConsArray['constOpe'][$sTimeField] = "<=";
|
|
||||||
$sConsSql .= " AND ".$sTimeField." <= '".$asActPeriod['to']."'";
|
|
||||||
break;
|
|
||||||
case self::POST_TABLE:
|
|
||||||
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];
|
|
||||||
$asConsArray['constOpe'][$sTimeField] = "<=";
|
|
||||||
$sConsSql .= " AND ".$sTimeField." <= '".$asActPeriod['to']."'";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ($sReturnFormat=='array')?$asConsArray:$sConsSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNewFeed($iRefIdFirst) {
|
|
||||||
$asResult = array();
|
|
||||||
$sDesc = '';
|
|
||||||
|
|
||||||
if($this->oProject->isEditable()) {
|
|
||||||
$asMessageIds = $asMediaIds = array();
|
|
||||||
|
|
||||||
//New Feed Items
|
|
||||||
$asResult = $this->getFeed($iRefIdFirst, ">", "DESC");
|
|
||||||
foreach($asResult['feed'] as $asItem) {
|
|
||||||
switch($asItem['type']) {
|
|
||||||
case 'message':
|
|
||||||
$asMessageIds[] = $asItem['id'];
|
|
||||||
break;
|
|
||||||
case 'media':
|
|
||||||
$asMediaIds[] = $asItem['id'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//New Markers
|
|
||||||
$asMarkers = $this->getMarkers(
|
|
||||||
empty($asMessageIds)?array(0):$asMessageIds,
|
|
||||||
empty($asMediaIds)?array(0):$asMediaIds,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
$asResult = array_merge($asResult, $asMarkers);
|
|
||||||
}
|
|
||||||
else $sDesc = 'mode_histo';
|
|
||||||
|
|
||||||
return self::getJsonResult(true, $sDesc, $asResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNextFeed($iRefIdLast=0, $bInternal=false) {
|
|
||||||
if($this->oProject->getMode() == Project::MODE_HISTO) {
|
|
||||||
$sDirection = ">";
|
|
||||||
$sSort = "ASC";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sDirection = "<";
|
|
||||||
$sSort = "DESC";
|
|
||||||
}
|
|
||||||
$asResult = $this->getFeed($iRefIdLast, $sDirection, $sSort);
|
|
||||||
return $bInternal?$asResult['feed']:self::getJsonResult(true, '', $asResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFeed($iRefId=0, $sDirection, $sSort) {
|
|
||||||
$this->oDb->cleanSql($iRefId);
|
|
||||||
$this->oDb->cleanSql($sDirection);
|
|
||||||
$this->oDb->cleanSql($sSort);
|
|
||||||
|
|
||||||
$sMediaRefField = 'posted_on';
|
|
||||||
$sProjectIdField = Db::getId(Project::PROJ_TABLE);
|
|
||||||
$sMsgIdField = Db::getId(Feed::MSG_TABLE);
|
|
||||||
$sMediaIdField = Db::getId(Media::MEDIA_TABLE);
|
|
||||||
$sPostIdField = Db::getId(self::POST_TABLE);
|
|
||||||
$sFeedIdField = Db::getId(Feed::FEED_TABLE);
|
|
||||||
$sQuery = implode(" ", array(
|
|
||||||
"SELECT type, id, ref",
|
|
||||||
"FROM (",
|
|
||||||
"SELECT {$sProjectIdField}, {$sMsgIdField} AS id, 'message' AS type, CONCAT(UNIX_TIMESTAMP(site_time), '.0', {$sMsgIdField}) AS ref",
|
|
||||||
"FROM ".Feed::MSG_TABLE,
|
|
||||||
"INNER JOIN ".Feed::FEED_TABLE." USING({$sFeedIdField})",
|
|
||||||
$this->getFeedConstraints(Feed::MSG_TABLE, 'site_time', 'sql'),
|
|
||||||
"UNION",
|
|
||||||
"SELECT {$sProjectIdField}, {$sMediaIdField} AS id, 'media' AS type, CONCAT(UNIX_TIMESTAMP({$sMediaRefField}), '.1', {$sMediaIdField}) AS ref",
|
|
||||||
"FROM ".Media::MEDIA_TABLE,
|
|
||||||
$this->getFeedConstraints(Media::MEDIA_TABLE, $sMediaRefField, 'sql'),
|
|
||||||
"UNION",
|
|
||||||
"SELECT {$sProjectIdField}, {$sPostIdField} AS id, 'post' AS type, CONCAT(UNIX_TIMESTAMP(site_time), '.2', {$sPostIdField}) AS ref",
|
|
||||||
"FROM ".self::POST_TABLE,
|
|
||||||
$this->getFeedConstraints(self::POST_TABLE, 'site_time', 'sql'),
|
|
||||||
") AS items",
|
|
||||||
($iRefId > 0)?("WHERE ref ".$sDirection." ".$iRefId):"",
|
|
||||||
"ORDER BY ref ".$sSort,
|
|
||||||
"LIMIT ".self::FEED_CHUNK_SIZE
|
|
||||||
));
|
|
||||||
|
|
||||||
//Get new chunk
|
|
||||||
$asItems = $this->oDb->getArrayQuery($sQuery, true);
|
|
||||||
|
|
||||||
//Update Reference Point with latest/earliest value
|
|
||||||
$iRefIdFirst = $iRefIdLast = 0;
|
|
||||||
if(!empty($asItems)) {
|
|
||||||
$iRefIdLast = end($asItems)['ref'];
|
|
||||||
$iRefIdFirst = reset($asItems)['ref'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Sort Table IDs by type & Get attributes
|
|
||||||
$asFeedIds = array('message'=>array(), 'media'=>array(), 'message'=>array());
|
|
||||||
foreach($asItems as $asItem) {
|
|
||||||
$asFeedIds[$asItem['type']][$asItem['id']] = $asItem;
|
|
||||||
}
|
|
||||||
$asFeedAttrs = array(
|
|
||||||
'message' => empty($asFeedIds['message'])?array():$this->getSpotMessages(array_keys($asFeedIds['message'])),
|
|
||||||
'media' => empty($asFeedIds['media'])?array():$this->getMedias($sMediaRefField, array_keys($asFeedIds['media'])),
|
|
||||||
'post' => empty($asFeedIds['post'])?array():$this->getPosts(array_keys($asFeedIds['post']))
|
|
||||||
);
|
|
||||||
|
|
||||||
//Replace Array Key with Item ID
|
|
||||||
foreach($asFeedAttrs as $sType=>$asFeedAttr) {
|
|
||||||
foreach($asFeedAttr as $asFeed) {
|
|
||||||
$asFeeds[$sType][$asFeed['id_'.$sType]] = $asFeed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign
|
|
||||||
foreach($asItems as &$asItem) {
|
|
||||||
$asItem = array_merge($asFeeds[$asItem['type']][$asItem['id']], $asItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array('ref_id_last'=>$iRefIdLast, 'ref_id_first'=>$iRefIdFirst, 'sort'=>$sSort, 'feed'=>$asItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPost($sName, $sPost)
|
|
||||||
{
|
|
||||||
$iPostId = 0;
|
|
||||||
$sDesc = '';
|
|
||||||
|
|
||||||
if($this->oProject->isEditable()) {
|
|
||||||
$asData = array(
|
|
||||||
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
|
|
||||||
'name' => mb_strtolower(trim($sName)),
|
|
||||||
'content' => trim($sPost),
|
|
||||||
'site_time' => date(Db::TIMESTAMP_FORMAT), //Now in Site Time
|
|
||||||
'timezone' => date_default_timezone_get() //Site Time Zone
|
|
||||||
);
|
|
||||||
if($this->oUser->getUserId() > 0) $asData[Db::getId(User::USER_TABLE)] = $this->oUser->getUserId();
|
|
||||||
|
|
||||||
$iPostId = $this->oDb->insertRow(self::POST_TABLE, $asData);
|
|
||||||
|
|
||||||
$this->oUser->updateNickname($sName);
|
|
||||||
}
|
|
||||||
else $sDesc = 'mode_histo';
|
|
||||||
|
|
||||||
return self::getJsonResult(($iPostId > 0), $sDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function upload()
|
|
||||||
{
|
|
||||||
$oUploader = new Uploader($this->oMedia, $this->oLang);
|
|
||||||
|
|
||||||
return $oUploader->sBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addComment($iMediaId, $sComment) {
|
|
||||||
$oMedia = new Media($this->oDb, $this->oProject, $iMediaId);
|
|
||||||
$asResult = $oMedia->setComment($sComment);
|
|
||||||
return self::getJsonResult($asResult['result'], $asResult['desc'], $asResult['data']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAdminSettings($sType='') {
|
|
||||||
$oFeed = new Feed($this->oDb);
|
|
||||||
$asData = array(
|
|
||||||
'project' => $this->oProject->getProjects(),
|
|
||||||
'feed' => $oFeed->getFeeds(),
|
|
||||||
'spot' => $oFeed->getSpots(),
|
|
||||||
'user' => $this->oUser->getActiveUsersInfo()
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach($asData['project'] as &$asProject) {
|
|
||||||
$asProject['active_from'] = substr($asProject['active_from'], 0, 10);
|
|
||||||
$asProject['active_to'] = substr($asProject['active_to'], 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::getJsonResult(true, '', $asData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAdminSettings($sType, $iId, $sField, $sValue) {
|
|
||||||
$bSuccess = false;
|
|
||||||
$sDesc = '';
|
|
||||||
$asResult = array();
|
|
||||||
|
|
||||||
if($this->oDb->isId($sField) && $sValue <= 0) return self::getJsonResult(false, $this->oLang->getTranslation('impossible_value', [$sValue, $sField]));
|
|
||||||
|
|
||||||
switch($sType) {
|
|
||||||
case 'project':
|
|
||||||
$oProject = new Project($this->oDb, $iId);
|
|
||||||
switch($sField) {
|
|
||||||
case 'name':
|
|
||||||
$bSuccess = $oProject->setProjectName($sValue);
|
|
||||||
break;
|
|
||||||
case 'codename':
|
|
||||||
$bSuccess = $oProject->setProjectCodeName($sValue);
|
|
||||||
break;
|
|
||||||
case 'active_from':
|
|
||||||
$bSuccess = $oProject->setActivePeriod($sValue.' 00:00:00', 'from');
|
|
||||||
break;
|
|
||||||
case 'active_to':
|
|
||||||
$bSuccess = $oProject->setActivePeriod($sValue.' 23:59:59', 'to');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDesc = $this->oLang->getTranslation('unknown_field', $sField);
|
|
||||||
}
|
|
||||||
$asResult = $oProject->getProject();
|
|
||||||
$asResult['active_from'] = substr($asResult['active_from'], 0, 10);
|
|
||||||
$asResult['active_to'] = substr($asResult['active_to'], 0, 10);
|
|
||||||
break;
|
|
||||||
case 'feed':
|
|
||||||
$oFeed = new Feed($this->oDb, $iId);
|
|
||||||
switch($sField) {
|
|
||||||
case 'ref_feed_id':
|
|
||||||
$bSuccess = $oFeed->setRefFeedId($sValue);
|
|
||||||
break;
|
|
||||||
case 'id_spot':
|
|
||||||
$bSuccess = $oFeed->setSpotId($sValue);
|
|
||||||
break;
|
|
||||||
case 'id_project':
|
|
||||||
$bSuccess = $oFeed->setProjectId($sValue);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDesc = $this->oLang->getTranslation('unknown_field', $sField);
|
|
||||||
}
|
|
||||||
$asResult = $oFeed->getFeed();
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
switch($sField) {
|
|
||||||
case 'clearance':
|
|
||||||
$asReturnCode = $this->oUser->setUserClearance($iId, $sValue);
|
|
||||||
$bSuccess = $asReturnCode['result'];
|
|
||||||
$sDesc = $asReturnCode['desc'];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDesc = $this->oLang->getTranslation('unknown_field', $sField);
|
|
||||||
}
|
|
||||||
$asResult = $this->oUser->getActiveUserInfo($iId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(!$bSuccess && $sDesc=='') $sDesc = Mask::LANG_PREFIX.'error_commit_db';
|
|
||||||
|
|
||||||
return self::getJsonResult($bSuccess, $sDesc, array($sType=>array($asResult)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createAdminSettings($sType) {
|
|
||||||
$bSuccess = false;
|
|
||||||
$sDesc = '';
|
|
||||||
$asResult = array();
|
|
||||||
|
|
||||||
switch($sType) {
|
|
||||||
case 'project':
|
|
||||||
$oProject = new Project($this->oDb);
|
|
||||||
$iNewProjectId = $oProject->createProjectId();
|
|
||||||
|
|
||||||
$oFeed = new Feed($this->oDb);
|
|
||||||
$oFeed->createFeedId($iNewProjectId);
|
|
||||||
|
|
||||||
$bSuccess = $iNewProjectId > 0;
|
|
||||||
$asResult = array(
|
|
||||||
'project' => array($oProject->getProject()),
|
|
||||||
'feed' => array($oFeed->getFeed())
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'feed':
|
|
||||||
$oFeed = new Feed($this->oDb);
|
|
||||||
$iNewFeedId = $oFeed->createFeedId($this->oProject->getProjectId());
|
|
||||||
$bSuccess = $iNewFeedId > 0;
|
|
||||||
$asResult = array(
|
|
||||||
'feed' => array($oFeed->getFeed())
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteAdminSettings($sType, $iId) {
|
|
||||||
$bSuccess = false;
|
|
||||||
$sDesc = '';
|
|
||||||
$asResult = array();
|
|
||||||
|
|
||||||
switch($sType) {
|
|
||||||
case 'project':
|
|
||||||
$oProject = new Project($this->oDb, $iId);
|
|
||||||
$asResult = $oProject->delete();
|
|
||||||
$sDesc = $asResult['project'][0]['desc'];
|
|
||||||
$bSuccess = $asResult['project'][0]['del'];
|
|
||||||
break;
|
|
||||||
case 'feed':
|
|
||||||
$oFeed = new Feed($this->oDb, $iId);
|
|
||||||
$asResult = array('feed' => array($oFeed->delete()));
|
|
||||||
$sDesc = $asResult['feed'][0]['desc'];
|
|
||||||
$bSuccess = $asResult['feed'][0]['del'];
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
$asResult = array('user' => array($this->oUser->removeUser($iId)));
|
|
||||||
$sDesc = $asResult['user'][0]['desc'];
|
|
||||||
$bSuccess = $asResult['user'][0]['result'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function decToDms($dValue, $sType) {
|
|
||||||
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
|
||||||
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
|
||||||
|
|
||||||
$dLeft = abs($dValue);
|
|
||||||
|
|
||||||
//Degrees
|
|
||||||
$iDegree = floor($dLeft);
|
|
||||||
$dLeft -= $iDegree;
|
|
||||||
|
|
||||||
//Minutes
|
|
||||||
$iMinute = floor($dLeft * 60);
|
|
||||||
$dLeft -= $iMinute / 60;
|
|
||||||
|
|
||||||
//Seconds
|
|
||||||
$fSecond = round($dLeft * 3600, 1);
|
|
||||||
|
|
||||||
return
|
|
||||||
$iDegree.'°'.
|
|
||||||
self::getNumberWithLeadingZeros($iMinute, 2, 0)."'".
|
|
||||||
self::getNumberWithLeadingZeros($fSecond, 2, 1).'"'.
|
|
||||||
$sDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getNumberWithLeadingZeros($fValue, $iNbLeadingZeros, $iNbDigits){
|
|
||||||
$sDecimalSeparator = ".";
|
|
||||||
if($iNbDigits > 0) $iNbLeadingZeros += mb_strlen($sDecimalSeparator) + $iNbDigits;
|
|
||||||
$sPattern = '%0'.$iNbLeadingZeros.$sDecimalSeparator.$iNbDigits.'f';
|
|
||||||
return sprintf($sPattern, $fValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimeFormat($iTime, $sTimeZone='') {
|
|
||||||
if($sTimeZone == '') $sTimeZone = date_default_timezone_get();
|
|
||||||
|
|
||||||
$oDate = new \DateTime('@'.$iTime);
|
|
||||||
$oDate->setTimezone(new \DateTimeZone($sTimeZone));
|
|
||||||
|
|
||||||
$sDate = $oDate->format('d/m/Y');
|
|
||||||
$sTime = $oDate->format('H:i');
|
|
||||||
return $this->oLang->getTranslation('date_time', array($sDate, $sTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTimeZoneDayOffset($iTime, $sLocalTimeZone) {
|
|
||||||
$sSiteTimeZone = date_default_timezone_get();
|
|
||||||
$iLocalDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sLocalTimeZone))->format('Ymd');
|
|
||||||
$iSiteDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sSiteTimeZone ))->format('Ymd');
|
|
||||||
|
|
||||||
return ($iLocalDate == $iSiteDate)?'0':(($iLocalDate > $iSiteDate)?'+1':'-1');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTimeZoneFromDate($sDate) {
|
|
||||||
$sTimeZone = null;
|
|
||||||
|
|
||||||
preg_match('/(?<timezone>(\+|\-)\d{2}:?(\d{2}|))$/', $sDate, $asMatch);
|
|
||||||
if(array_key_exists('timezone', $asMatch)) {
|
|
||||||
$sTimeZone = $asMatch['timezone'];
|
|
||||||
|
|
||||||
//Complete short form: +12 => +1200
|
|
||||||
if(strlen($sTimeZone) == 3) $sTimeZone .= '00';
|
|
||||||
|
|
||||||
//Add colon: +1200 => +12:00
|
|
||||||
if(!strpos($sTimeZone, ':')) $sTimeZone = substr_replace($sTimeZone, ':', 3, 0);
|
|
||||||
}
|
|
||||||
return $sTimeZone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+28
-31
@@ -1,36 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\UploadHandler;
|
use Franzz\Objects\UploadHandler;
|
||||||
use Franzz\Objects\Translator;
|
|
||||||
|
|
||||||
class Uploader extends UploadHandler
|
class Uploader extends UploadHandler {
|
||||||
{
|
private Media $oMedia;
|
||||||
/**
|
|
||||||
* Medias Management
|
|
||||||
* @var Media
|
|
||||||
*/
|
|
||||||
private $oMedia;
|
|
||||||
|
|
||||||
/**
|
public string $sBody;
|
||||||
* Languages
|
|
||||||
* @var Translator
|
|
||||||
*/
|
|
||||||
private $oLang;
|
|
||||||
|
|
||||||
public $sBody;
|
public function __construct(Media &$oMedia) {
|
||||||
|
|
||||||
function __construct(Media &$oMedia, Translator &$oLang)
|
|
||||||
{
|
|
||||||
$this->oMedia = &$oMedia;
|
$this->oMedia = &$oMedia;
|
||||||
$this->oLang = &$oLang;
|
|
||||||
$this->sBody = '';
|
$this->sBody = '';
|
||||||
|
|
||||||
parent::__construct(array(
|
parent::__construct([
|
||||||
'upload_dir' => Media::MEDIA_FOLDER,
|
'upload_dir' => Media::MEDIA_FOLDER.'/',
|
||||||
'image_versions' => array(),
|
'image_versions' => [],
|
||||||
'accept_file_types' => '/\.(gif|jpe?g|png|mov|mp4)$/i'
|
'accept_file_types' => '/\.(gif|jpe?g|png|mov|mp4)$/i'
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function validate($uploaded_file, $file, $error, $index, $content_range) {
|
protected function validate($uploaded_file, $file, $error, $index, $content_range) {
|
||||||
@@ -38,7 +24,9 @@ class Uploader extends UploadHandler
|
|||||||
|
|
||||||
//Check project mode
|
//Check project mode
|
||||||
if(!$this->oMedia->isProjectEditable()) {
|
if(!$this->oMedia->isProjectEditable()) {
|
||||||
$file->error = $this->get_error_message('upload_mode_archived', array($this->oMedia->getProjectCodeName()));
|
$file->error = true;
|
||||||
|
$file->desc_lang_id = 'upload.mode_archived';
|
||||||
|
$file->desc_lang_params = [$this->oMedia->getProjectCodeName()];
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,16 +34,28 @@ class Uploader extends UploadHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) {
|
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) {
|
||||||
$file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
|
$sExt = strtolower(pathinfo((string) $name, PATHINFO_EXTENSION));
|
||||||
|
$sStoredName = bin2hex(random_bytes(16)).($sExt !== ''?'.'.$sExt:'');
|
||||||
|
$file = parent::handle_file_upload($uploaded_file, $sStoredName, $size, $type, $error, $index, $content_range);
|
||||||
|
|
||||||
if(empty($file->error)) {
|
if(empty($file->error)) {
|
||||||
$asResult = $this->oMedia->addMedia($file->name);
|
$asResult = $this->oMedia->addMedia($file->name);
|
||||||
if(!$asResult['result']) $file->error = $this->get_error_message($asResult['desc'], $asResult['data']);
|
if(!$asResult['result']) {
|
||||||
|
$file->error = true;
|
||||||
|
$file->desc_lang_id = $asResult['desc_lang_id'];
|
||||||
|
$file->desc_lang_params = $asResult['data'];
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
$file->original_name = basename((string) $name);
|
||||||
$file->id = $this->oMedia->getMediaId();
|
$file->id = $this->oMedia->getMediaId();
|
||||||
$file->thumbnail = $asResult['data']['thumb_path'];
|
$file->thumbnail = $asResult['data']['thumb_path'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!empty($file->error)) {
|
||||||
|
if(empty($file->desc_lang_id)) $file->desc_lang_id = is_string($file->error)?$file->error:'upload.error';
|
||||||
|
if(empty($file->desc_lang_params)) $file->desc_lang_params = [];
|
||||||
|
$file->error = true;
|
||||||
|
}
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
@@ -64,10 +64,7 @@ class Uploader extends UploadHandler
|
|||||||
$this->sBody .= $sBodyPart;
|
$this->sBody .= $sBodyPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_error_message($sError, $asParams=array()) {
|
protected function get_error_message($sLangId, $asParams=[]) {
|
||||||
$sTranslatedError = $this->oLang->getTranslation($sError, $asParams);
|
return array_key_exists($sLangId, $this->error_messages)?'upload.error':$sLangId;
|
||||||
if($sTranslatedError) return $sTranslatedError;
|
|
||||||
elseif(array_key_exists($sError, $this->error_messages)) return $this->error_messages[$sError];
|
|
||||||
else return $sError;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+236
-105
@@ -1,25 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Franzz\Spot;
|
namespace Franzz\Livetrail;
|
||||||
use Franzz\Objects\PhpObject;
|
use Franzz\Objects\PhpObject;
|
||||||
use Franzz\Objects\Db;
|
use Franzz\Objects\Db;
|
||||||
use \Settings;
|
|
||||||
|
|
||||||
class User extends PhpObject {
|
class User extends PhpObject {
|
||||||
|
|
||||||
//DB Tables
|
//DB Tables
|
||||||
const USER_TABLE = 'users';
|
public const USER_TABLE = 'users';
|
||||||
|
|
||||||
//Clearance Levels
|
//Clearance Levels
|
||||||
const USER_ACTIVE = 1;
|
public const CLEARANCE_USER = 0;
|
||||||
const USER_INACTIVE = 0;
|
public const CLEARANCE_ADMIN = 9;
|
||||||
const CLEARANCE_USER = 0;
|
public const CLEARANCES = ['user'=>self::CLEARANCE_USER, 'admin'=>self::CLEARANCE_ADMIN];
|
||||||
const CLEARANCE_ADMIN = 9;
|
|
||||||
const CLEARANCES = array('user'=>self::CLEARANCE_USER, 'admin'=>self::CLEARANCE_ADMIN);
|
|
||||||
|
|
||||||
//Cookie
|
public const USER_SUBSCRIBED = 1;
|
||||||
const COOKIE_ID_USER = 'subscriber';
|
public const USER_UNSUBSCRIBED = 0;
|
||||||
const COOKIE_DURATION = 60 * 60 * 24 * 365; //1 year
|
|
||||||
|
public const DEFAULT_USER = [
|
||||||
|
'id' => 0,
|
||||||
|
'id_user' => 0,
|
||||||
|
'name' => '',
|
||||||
|
'email' => '',
|
||||||
|
'language' => '',
|
||||||
|
'timezone' => '',
|
||||||
|
'subscribed'=> self::USER_UNSUBSCRIBED,
|
||||||
|
'clearance' => self::CLEARANCE_USER
|
||||||
|
];
|
||||||
|
|
||||||
|
//Session & Cookie
|
||||||
|
private const SESSION_ID_USER = 'id_user';
|
||||||
|
private const SESSION_ADMIN = 'admin_authenticated';
|
||||||
|
private const COOKIE_TOKEN = 'login';
|
||||||
|
private const COOKIE_DURATION = 60 * 60 * 24 * 365; //1 year
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Handle
|
* Database Handle
|
||||||
@@ -35,17 +48,7 @@ class User extends PhpObject {
|
|||||||
parent::__construct(__CLASS__);
|
parent::__construct(__CLASS__);
|
||||||
$this->oDb = &$oDb;
|
$this->oDb = &$oDb;
|
||||||
$this->setUserId(0);
|
$this->setUserId(0);
|
||||||
$this->asUserInfo = array(
|
$this->checkSession();
|
||||||
'id' => 0,
|
|
||||||
Db::getId(self::USER_TABLE) => 0,
|
|
||||||
'name' => '',
|
|
||||||
'email' => '',
|
|
||||||
'language' => '',
|
|
||||||
'timezone' => '',
|
|
||||||
'active' => self::USER_INACTIVE,
|
|
||||||
'clearance' => self::CLEARANCE_USER
|
|
||||||
);
|
|
||||||
$this->checkUserCookie();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserId() {
|
public function getUserId() {
|
||||||
@@ -54,9 +57,10 @@ class User extends PhpObject {
|
|||||||
|
|
||||||
public function setUserId($iUserId) {
|
public function setUserId($iUserId) {
|
||||||
$this->iUserId = 0;
|
$this->iUserId = 0;
|
||||||
|
$this->asUserInfo = self::DEFAULT_USER;
|
||||||
|
|
||||||
if($iUserId > 0) {
|
if($iUserId > 0) {
|
||||||
$asUser = $this->getActiveUserInfo($iUserId);
|
$asUser = $this->getUserById($iUserId);
|
||||||
if(!empty($asUser)) {
|
if(!empty($asUser)) {
|
||||||
$this->iUserId = $iUserId;
|
$this->iUserId = $iUserId;
|
||||||
$this->asUserInfo = $asUser;
|
$this->asUserInfo = $asUser;
|
||||||
@@ -68,27 +72,23 @@ class User extends PhpObject {
|
|||||||
return $this->asUserInfo;
|
return $this->asUserInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActiveUserInfo($iUserId) {
|
public function getUserById($iUserId) {
|
||||||
$asUsersInfo = array();
|
$asUsersInfo = [];
|
||||||
if($iUserId > 0) $asUsersInfo = $this->getActiveUsersInfo($iUserId);
|
if($iUserId > 0) $asUsersInfo = $this->getUsersInfo($iUserId);
|
||||||
return empty($asUsersInfo)?array():array_shift($asUsersInfo);
|
return empty($asUsersInfo)?[]:array_shift($asUsersInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActiveUsersInfo($iUserId=-1) {
|
public function getUsersInfo($iUserId=-1) {
|
||||||
|
|
||||||
//Mapping between user fields and DB fields
|
//Mapping between user fields and DB fields
|
||||||
$asSelect = array_keys($this->asUserInfo);
|
$asSelect = array_keys($this->asUserInfo);
|
||||||
$asSelect[array_search('id', $asSelect)] = Db::getId(self::USER_TABLE)." AS id";
|
$asSelect[array_search('id', $asSelect)] = Db::getId(self::USER_TABLE).' AS id';
|
||||||
|
|
||||||
//Non-admin cannot access clearance info
|
$asInfo = [
|
||||||
if(!$this->checkUserClearance(self::CLEARANCE_ADMIN)) unset($asSelect['clearance']);
|
|
||||||
|
|
||||||
$asInfo = array(
|
|
||||||
'select' => $asSelect,
|
'select' => $asSelect,
|
||||||
'from' => self::USER_TABLE,
|
'from' => self::USER_TABLE
|
||||||
'constraint'=> array('active'=>self::USER_ACTIVE)
|
];
|
||||||
);
|
if($iUserId != -1) $asInfo['constraint'] = [Db::getId(self::USER_TABLE) => $iUserId];
|
||||||
if($iUserId != -1) $asInfo['constraint'][Db::getId(self::USER_TABLE)] = $iUserId;
|
|
||||||
|
|
||||||
return $this->oDb->selectRows($asInfo);
|
return $this->oDb->selectRows($asInfo);
|
||||||
}
|
}
|
||||||
@@ -97,114 +97,245 @@ class User extends PhpObject {
|
|||||||
return $this->asUserInfo['language'];
|
return $this->asUserInfo['language'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUser($sEmail, $sLang, $sTimezone, $sNickName='') {
|
private function addUser($sEmail, $sLang, $sTimezone, $sNickName='') {
|
||||||
$bSuccess = false;
|
$bSuccess = false;
|
||||||
$sDesc = '';
|
$sLangId = '';
|
||||||
$sEmail = trim($sEmail);
|
|
||||||
|
|
||||||
//Check Email availability
|
$iUserId = $this->oDb->insertRow(
|
||||||
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>self::USER_ACTIVE));
|
self::USER_TABLE,
|
||||||
|
['email'=>$sEmail, 'language'=>$sLang, 'timezone'=>$sTimezone]
|
||||||
|
);
|
||||||
|
|
||||||
if($iUserId > 0) {
|
if($iUserId == 0) $sLangId = 'error.commit_db';
|
||||||
//Just log user in
|
else $bSuccess = true;
|
||||||
$sDesc = 'lang:nl_email_exists';
|
|
||||||
$bSuccess = true;
|
//Extra optional values
|
||||||
|
if($bSuccess) {
|
||||||
|
$this->updateNickname($sNickName);
|
||||||
|
$this->updateGravatar($iUserId, $sEmail);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Livetrail::getResult($bSuccess, $sLangId, [Db::getId(self::USER_TABLE) => $iUserId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSubscription($bSubscribed) {
|
||||||
|
if($this->getUserId() > 0) {
|
||||||
|
$iSubscribed = $bSubscribed?1:0;
|
||||||
|
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->getUserId(), ['subscribed'=>$iSubscribed]);
|
||||||
|
if(!$iUserId) return Livetrail::getResult(false, 'error.commit_db');
|
||||||
|
$this->asUserInfo['subscribed'] = $iSubscribed;
|
||||||
|
return Livetrail::getResult(true, $iSubscribed?'account.subscribed':'account.unsubscribed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubscribedUsersInfo() {
|
||||||
|
$asSelect = array_keys($this->asUserInfo);
|
||||||
|
$asSelect[array_search('id', $asSelect)] = Db::getId(self::USER_TABLE).' AS id';
|
||||||
|
return $this->oDb->selectRows([
|
||||||
|
'select'=>$asSelect,
|
||||||
|
'from'=>self::USER_TABLE,
|
||||||
|
'constraint'=>['subscribed'=>self::USER_SUBSCRIBED]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login($sEmail, $sPassword, $sLang, $sTimezone, $sNickName='') {
|
||||||
|
$bSuccess = false;
|
||||||
|
$bSubscribe = false;
|
||||||
|
$sLangId = '';
|
||||||
|
$sEmail = strtolower(trim($sEmail));
|
||||||
|
|
||||||
|
//Check email value
|
||||||
|
if(!filter_var($sEmail, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$sLangId = 'account.invalid_email';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Add/Reactivate user
|
//Check Email presence in DB
|
||||||
$iUserId = $this->oDb->insertUpdateRow(
|
$asDBUser = $this->oDb->selectRow(
|
||||||
self::USER_TABLE,
|
self::USER_TABLE,
|
||||||
array('email'=>$sEmail, 'language'=>$sLang, 'timezone'=>$sTimezone, 'active'=>self::USER_ACTIVE),
|
['email' => $sEmail],
|
||||||
array('email')
|
[Db::getId(self::USER_TABLE), 'password', 'clearance']
|
||||||
);
|
);
|
||||||
|
$iUserId = $asDBUser[Db::getId(self::USER_TABLE)] ?? 0;
|
||||||
|
|
||||||
|
//User exists
|
||||||
|
if($iUserId > 0) {
|
||||||
|
//Is Admin
|
||||||
|
if($asDBUser['clearance'] >= self::CLEARANCE_ADMIN) {
|
||||||
|
//Request a password
|
||||||
|
if($sPassword === '') $sLangId = empty($asDBUser['password'])?'account.set_password':'account.password_required';
|
||||||
|
|
||||||
|
//Set password
|
||||||
|
elseif(empty($asDBUser['password'])) {
|
||||||
|
if(!$this->oDb->updateRow(self::USER_TABLE, $iUserId, ['password' => password_hash($sPassword, PASSWORD_DEFAULT)])) $sLangId = 'error.commit_db';
|
||||||
|
else {
|
||||||
|
$sLangId = 'account.password_set';
|
||||||
|
$bSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
//Check password
|
||||||
|
elseif(password_verify($sPassword, $asDBUser['password'])) {
|
||||||
|
$bSuccess = true;
|
||||||
|
$sLangId = 'account.logged_in';
|
||||||
|
}
|
||||||
|
else $sLangId = 'account.invalid_credentials';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$bSuccess = true;
|
||||||
|
$sLangId = 'account.logged_in';
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$sDesc = 'lang:nl_subscribed';
|
//Unknown user, create it
|
||||||
$bSuccess = true;
|
$asAddResult = $this->addUser($sEmail, $sLang, $sTimezone, $sNickName);
|
||||||
|
$bSuccess = $asAddResult['result'];
|
||||||
|
$bSubscribe = $bSuccess;
|
||||||
|
$sLangId = $bSuccess?'':$asAddResult['desc_lang_id'];
|
||||||
|
$iUserId = $asAddResult['data'][Db::getId(self::USER_TABLE)] ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bSuccess) {
|
if($bSuccess) {
|
||||||
$this->setUserId($iUserId);
|
$this->setUserId($iUserId);
|
||||||
|
$this->setSession();
|
||||||
//Set Cookie (valid 1 year)
|
$this->setTokenCookie();
|
||||||
$this->updateCookie(self::COOKIE_DURATION);
|
|
||||||
|
|
||||||
//Update Nickname if user has already posted
|
|
||||||
$this->updateNickname($sNickName);
|
|
||||||
|
|
||||||
//Retrieve Gravatar image
|
|
||||||
$this->updateGravatar($iUserId, $sEmail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Spot::getResult($bSuccess, $sDesc);
|
return Livetrail::getResult($bSuccess, $sLangId, ['subscribe'=>$bSubscribe]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeUser($iUserId=0) {
|
public function logout() {
|
||||||
$iUserId = ($iUserId > 0)?$iUserId:$this->getUserId();
|
if($this->getUserId() > 0) $this->oDb->updateRow(self::USER_TABLE, $this->getUserId(), ['token' => '', 'token_exp' => '0000-00-00 00:00:00']);
|
||||||
$bSelf = ($iUserId == $this->getUserId());
|
$this->clearSession();
|
||||||
$bSuccess = false;
|
$this->clearCookie();
|
||||||
$sDesc = '';
|
$this->setUserId(0);
|
||||||
|
return Livetrail::getResult(true, 'account.logged_out');
|
||||||
if($bSelf || $this->checkUserClearance(self::CLEARANCE_ADMIN)) {
|
|
||||||
if($this->getUserId() > 0) {
|
|
||||||
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $iUserId, array('active' => self::USER_INACTIVE));
|
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
|
||||||
else {
|
|
||||||
$sDesc = 'lang:nl_unsubscribed';
|
|
||||||
if($bSelf) $this->updateCookie(-60 * 60); //Set Cookie in the past, deleting it
|
|
||||||
$bSuccess = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $sDesc = 'lang:nl_unknown_email';
|
|
||||||
}
|
|
||||||
else $sDesc = 'lang:no_auth';
|
|
||||||
|
|
||||||
return Spot::getResult($bSuccess, $sDesc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateNickname($sNickname) {
|
public function updateNickname($sNickname) {
|
||||||
if($this->getUserId() > 0 && $sNickname!='') $this->oDb->updateRow(self::USER_TABLE, $this->getUserId(), array('name'=>$sNickname));
|
if($this->getUserId() > 0 && $sNickname!='') $this->oDb->updateRow(self::USER_TABLE, $this->getUserId(), ['name'=>$sNickname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateGravatar($iUserId, $sEmail) {
|
private function updateGravatar($iUserId, $sEmail) {
|
||||||
$sImage = ($sEmail != '')?@file_get_contents('https://www.gravatar.com/avatar/'.md5($sEmail).'.png?d=404&s=24'):'';
|
$sImage = ($sEmail != '')?@file_get_contents('https://www.gravatar.com/avatar/'.md5($sEmail).'.png?d=404&s=24'):'';
|
||||||
$this->oDb->updateRow(self::USER_TABLE, $iUserId, array('gravatar' => base64_encode($sImage)));
|
$this->oDb->updateRow(self::USER_TABLE, $iUserId, ['gravatar' => base64_encode($sImage)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkUserCookie() {
|
public function checkUserClearance($iClearance) {
|
||||||
if(isset($_COOKIE[self::COOKIE_ID_USER])){
|
|
||||||
$this->setUserId($_COOKIE[self::COOKIE_ID_USER]);
|
|
||||||
|
|
||||||
//Extend cookie life
|
|
||||||
if($this->getUserId() > 0) $this->updateCookie(self::COOKIE_DURATION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkUserClearance($iClearance)
|
|
||||||
{
|
|
||||||
return ($this->asUserInfo['clearance'] >= $iClearance);
|
return ($this->asUserInfo['clearance'] >= $iClearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUserClearance($iUserId, $iClearance) {
|
public function setUserClearance($iUserId, $iClearance) {
|
||||||
$bSuccess = false;
|
$bSuccess = false;
|
||||||
$sDesc = '';
|
$sLangId = '';
|
||||||
|
$asLangParams = [];
|
||||||
|
|
||||||
if(!$this->checkUserClearance(self::CLEARANCE_ADMIN)) $sDesc = 'unauthorized';
|
if(!$this->checkUserClearance(self::CLEARANCE_ADMIN)) $sLangId = 'error.no_auth';
|
||||||
else {
|
else {
|
||||||
if(!in_array($iClearance, self::CLEARANCES)) $sDesc = 'Setting wrong clearance "'.$iClearance.'" to user ID "'.$iUserId.'"';
|
if(!in_array($iClearance, self::CLEARANCES)) {
|
||||||
|
$sLangId = 'error.impossible_value';
|
||||||
|
$asLangParams = [$iClearance, 'clearance'];
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $iUserId, array('clearance'=>$iClearance));
|
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $iUserId, ['clearance'=>$iClearance]);
|
||||||
if(!$iUserId) $sDesc = 'lang:error_commit_db';
|
if(!$iUserId) $sLangId = 'error.commit_db';
|
||||||
else $bSuccess = true;
|
else $bSuccess = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Spot::getResult($bSuccess, $sDesc);
|
return Livetrail::getResult($bSuccess, $sLangId, [], $asLangParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateCookie($iDeltaTime) {
|
/* Session */
|
||||||
setcookie(self::COOKIE_ID_USER, ($iDeltaTime < 0)?'':$this->getUserId(), array('samesite' => 'Lax', 'expires' => time() + $iDeltaTime));
|
|
||||||
|
private function checkSession() {
|
||||||
|
$iUserId = (int) ($_SESSION[self::SESSION_ID_USER] ?? 0);
|
||||||
|
if($iUserId > 0) {
|
||||||
|
$this->setUserId($iUserId);
|
||||||
|
if($this->checkUserClearance(self::CLEARANCE_ADMIN) && empty($_SESSION[self::SESSION_ADMIN])) $this->logout();
|
||||||
|
}
|
||||||
|
else $this->checkTokenCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setSession() {
|
||||||
|
session_regenerate_id(true);
|
||||||
|
$_SESSION[self::SESSION_ID_USER] = $this->getUserId();
|
||||||
|
$_SESSION[self::SESSION_ADMIN] = $this->checkUserClearance(self::CLEARANCE_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clearSession() {
|
||||||
|
unset($_SESSION[self::SESSION_ID_USER], $_SESSION[self::SESSION_ADMIN]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cookie */
|
||||||
|
|
||||||
|
private function checkTokenCookie() {
|
||||||
|
$sCookieValue = $this->getCookie();
|
||||||
|
|
||||||
|
//Check cookie structure
|
||||||
|
$asToken = explode(':', $sCookieValue, 3);
|
||||||
|
$iUserId = $asToken[0];
|
||||||
|
if(count($asToken) !== 3 || !ctype_digit($iUserId) || !ctype_digit($asToken[1]) || !preg_match('/^[a-f0-9]{64}$/', $asToken[2])) {
|
||||||
|
if($sCookieValue !== '') $this->clearCookie();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get user info
|
||||||
|
$asUser = $this->oDb->selectRow(
|
||||||
|
self::USER_TABLE,
|
||||||
|
$iUserId,
|
||||||
|
['clearance', 'token', 'token_exp']
|
||||||
|
);
|
||||||
|
|
||||||
|
//Check token value
|
||||||
|
if(!empty($asUser)
|
||||||
|
&& $asUser['clearance'] == $asToken[1]
|
||||||
|
&& time() <= strtotime($asUser['token_exp'])
|
||||||
|
&& hash_equals($asUser['token'], hash('sha256', $sCookieValue))
|
||||||
|
) {
|
||||||
|
$this->setUserId($iUserId);
|
||||||
|
$this->setSession();
|
||||||
|
}
|
||||||
|
else $this->clearCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setTokenCookie() {
|
||||||
|
$sToken = bin2hex(random_bytes(32));
|
||||||
|
$iClearance = $this->asUserInfo['clearance'];
|
||||||
|
$sCookieValue = implode(':', [$this->getUserId(), $iClearance, $sToken]);
|
||||||
|
|
||||||
|
$this->oDb->updateRow(
|
||||||
|
self::USER_TABLE,
|
||||||
|
$this->getUserId(),
|
||||||
|
[
|
||||||
|
'token' => hash('sha256', $sCookieValue),
|
||||||
|
'token_exp' => date(Db::TIMESTAMP_FORMAT, time() + self::COOKIE_DURATION)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setCookie($sCookieValue, time() + self::COOKIE_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCookie() {
|
||||||
|
return $_COOKIE[self::COOKIE_TOKEN] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setCookie($sValue, $iExpires) {
|
||||||
|
setcookie(
|
||||||
|
self::COOKIE_TOKEN,
|
||||||
|
$sValue,
|
||||||
|
[
|
||||||
|
'expires' => $iExpires,
|
||||||
|
'path' => '/',
|
||||||
|
'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https'),
|
||||||
|
'httponly' => true,
|
||||||
|
'samesite' => 'Lax'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clearCookie() {
|
||||||
|
$this->setCookie('', time() - 3600);
|
||||||
|
unset($_COOKIE[self::COOKIE_TOKEN]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-104
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/* Requests Handler */
|
|
||||||
|
|
||||||
//Start buffering
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
//Run from /dist/
|
|
||||||
$oLoader = require __DIR__.'/../vendor/autoload.php';
|
|
||||||
|
|
||||||
use Franzz\Objects\ToolBox;
|
|
||||||
use Franzz\Objects\Main;
|
|
||||||
use Franzz\Spot\Spot;
|
|
||||||
use Franzz\Spot\User;
|
|
||||||
|
|
||||||
ToolBox::fixGlobalVars($argv ?? array());
|
|
||||||
|
|
||||||
//Available variables
|
|
||||||
$sAction = $_REQUEST['a'] ?? '';
|
|
||||||
$sTimezone = $_REQUEST['t'] ?? '';
|
|
||||||
$sName = $_GET['name'] ?? '';
|
|
||||||
$sContent = $_GET['content'] ?? '';
|
|
||||||
$iProjectId = $_REQUEST['id_project'] ?? 0 ;
|
|
||||||
$sField = $_REQUEST['field'] ?? '';
|
|
||||||
$oValue = $_REQUEST['value'] ?? '';
|
|
||||||
$iId = $_REQUEST['id'] ?? 0 ;
|
|
||||||
$sType = $_REQUEST['type'] ?? '';
|
|
||||||
$sEmail = $_REQUEST['email'] ?? '';
|
|
||||||
|
|
||||||
//Initiate class
|
|
||||||
$oSpot = new Spot(__FILE__, $sTimezone);
|
|
||||||
$oSpot->setProjectId($iProjectId);
|
|
||||||
|
|
||||||
$sResult = '';
|
|
||||||
if($sAction!='')
|
|
||||||
{
|
|
||||||
switch($sAction)
|
|
||||||
{
|
|
||||||
case 'markers':
|
|
||||||
$sResult = $oSpot->getMarkers();
|
|
||||||
break;
|
|
||||||
case 'next_feed':
|
|
||||||
$sResult = $oSpot->getNextFeed($iId);
|
|
||||||
break;
|
|
||||||
case 'new_feed':
|
|
||||||
$sResult = $oSpot->getNewFeed($iId);
|
|
||||||
break;
|
|
||||||
case 'add_post':
|
|
||||||
$sResult = $oSpot->addPost($sName, $sContent);
|
|
||||||
break;
|
|
||||||
case 'subscribe':
|
|
||||||
$sResult = $oSpot->subscribe($sEmail, $sName);
|
|
||||||
break;
|
|
||||||
case 'unsubscribe':
|
|
||||||
$sResult = $oSpot->unsubscribe();
|
|
||||||
break;
|
|
||||||
case 'unsubscribe_email':
|
|
||||||
$sResult = $oSpot->unsubscribeFromEmail($iId);
|
|
||||||
break;
|
|
||||||
case 'update_project':
|
|
||||||
$sResult = $oSpot->updateProject();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if($oSpot->checkUserClearance(User::CLEARANCE_ADMIN))
|
|
||||||
{
|
|
||||||
switch($sAction)
|
|
||||||
{
|
|
||||||
case 'upload':
|
|
||||||
$sResult = $oSpot->upload();
|
|
||||||
break;
|
|
||||||
case 'add_comment':
|
|
||||||
$sResult = $oSpot->addComment($iId, $sContent);
|
|
||||||
break;
|
|
||||||
case 'admin_get':
|
|
||||||
$sResult = $oSpot->getAdminSettings();
|
|
||||||
break;
|
|
||||||
case 'admin_set':
|
|
||||||
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
|
||||||
break;
|
|
||||||
case 'admin_create':
|
|
||||||
$sResult = $oSpot->createAdminSettings($sType);
|
|
||||||
break;
|
|
||||||
case 'admin_delete':
|
|
||||||
$sResult = $oSpot->deleteAdminSettings($sType, $iId);
|
|
||||||
break;
|
|
||||||
case 'generate_cron':
|
|
||||||
$sResult = $oSpot->genCronFile();
|
|
||||||
break;
|
|
||||||
case 'sql':
|
|
||||||
$sResult = $oSpot->getDbBuildScript();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else $sResult = $oSpot->getAppMainPage();
|
|
||||||
|
|
||||||
$sDebug = ob_get_clean();
|
|
||||||
if(Settings::DEBUG && $sDebug!='') $oSpot->addUncaughtError($sDebug);
|
|
||||||
|
|
||||||
echo $sResult;
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
|
||||||
<title>[#]lang:email_conf_subject[#]</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<span style="color: transparent; display: none !important; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">[#]lang:conf_preheader[#]</span>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;max-width:600px;">
|
|
||||||
<tr>
|
|
||||||
<td width="20%"><img src="[#]local_server[#]images/icons/mstile-144x144.png" width="90%" border="0" alt="logo" /></td>
|
|
||||||
<td><h1>[#]lang:conf_thanks_sub[#]</h1></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<p align="justify">[#]lang:conf_body_para_1[#]</p>
|
|
||||||
<p align="justify">[#]lang:conf_body_para_2[#]</p>
|
|
||||||
<p align="justify">[#]lang:conf_body_para_3[#]</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<p>[#]lang:conf_body_conclusion[#]<br />[#]lang:conf_signature[#]</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<p>[#]lang:email_unsubscribe[#] <a href="[#]unsubscribe_link[#]" target="_blank" rel="noopener">[#]lang:email_unsub_btn[#]</a></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Generated
+2467
-5254
File diff suppressed because it is too large
Load Diff
+27
-39
@@ -1,50 +1,38 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
"name": "livetrail",
|
||||||
"@babel/core": "^7.23.2",
|
"description": "Self-hosted live journey map combining SPOT GPS tracking, GPX routes, posts, and media",
|
||||||
"@babel/preset-env": "^7.23.2",
|
"version": "3.0.1",
|
||||||
"@vue-leaflet/vue-leaflet": "^0.10.1",
|
|
||||||
"babel-loader": "^9.1.3",
|
|
||||||
"resolve-url-loader": "^5.0.0",
|
|
||||||
"symlink-webpack-plugin": "^1.1.0",
|
|
||||||
"vue-loader": "^17.3.1",
|
|
||||||
"vue-template-compiler": "^2.7.15",
|
|
||||||
"webpack": "^5.89.0",
|
|
||||||
"webpack-cli": "^5.1.4"
|
|
||||||
},
|
|
||||||
"name": "spot",
|
|
||||||
"description": "FindMeSpot & GPX integration",
|
|
||||||
"version": "2.0.0",
|
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack --config build/webpack.dev.js",
|
"dev": "vite build --mode development --watch",
|
||||||
"prod": "webpack --config build/webpack.prod.js"
|
"prod": "vite build",
|
||||||
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Franzz",
|
"author": "Franzz",
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^10.0.1",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.8",
|
||||||
|
"eslint": "^10.9.1",
|
||||||
|
"eslint-plugin-vue": "^10.10.0",
|
||||||
|
"globals": "^17.11.0",
|
||||||
|
"vite": "^8.1.5"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
||||||
|
"@fortawesome/vue-fontawesome": "^3.2.0",
|
||||||
|
"@uppy/core": "^6.0.0",
|
||||||
|
"@uppy/xhr-upload": "^6.0.0",
|
||||||
"autosize": "^6.0.1",
|
"autosize": "^6.0.1",
|
||||||
"blueimp-file-upload": "^10.32.0",
|
"maplibre-gl": "^6.0.0",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"sass": "^1.97.2",
|
||||||
"copy-webpack-plugin": "^11.0.0",
|
"simplebar-vue": "^2.3.3",
|
||||||
"css-loader": "^6.8.1",
|
"vue": "^3.5.40"
|
||||||
"d3": "^7.8.5",
|
},
|
||||||
"file-loader": "^6.2.0",
|
"allowScripts": {
|
||||||
"html-loader": "^4.2.0",
|
"@parcel/watcher@2.6.0": true,
|
||||||
"jquery": "^3.7.1",
|
"vue-demi@0.13.11": true
|
||||||
"jquery-mousewheel": "^3.1.13",
|
|
||||||
"jquery.waitforimages": "^2.4.0",
|
|
||||||
"leaflet": "^1.9.4",
|
|
||||||
"leaflet-geometryutil": "^0.10.2",
|
|
||||||
"leaflet.heightgraph": "^1.4.0",
|
|
||||||
"lightbox2": "^2.11.4",
|
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
|
||||||
"sass": "^1.69.4",
|
|
||||||
"sass-loader": "^13.3.2",
|
|
||||||
"simplebar": "^6.2.5",
|
|
||||||
"style-loader": "^3.3.3",
|
|
||||||
"url-loader": "^4.1.1",
|
|
||||||
"vue": "^3.3.8",
|
|
||||||
"vue-style-loader": "^4.1.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
use Franzz\Livetrail\Controller;
|
||||||
|
|
||||||
|
echo (new Controller())->handle(__FILE__, $argv ?? []);
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
# Spot Project
|
# Live Trail Project
|
||||||
[Spot](https://www.findmespot.com) & GPX integration
|
|
||||||
|
Live Trail is a self-hosted web application for sharing journeys on an interactive map. It combines live GPS positions from a [SPOT](https://www.findmespot.com) tracker with GPX routes, posts, photos, videos, and a chronological activity feed, supporting both real-time tracking and historical travel stories.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
* npm 18+
|
|
||||||
|
* npm 24+
|
||||||
* composer
|
* composer
|
||||||
* php-mbstring
|
* php-mbstring
|
||||||
* php-imagick
|
* php-imagick
|
||||||
@@ -11,25 +14,54 @@
|
|||||||
* ffprobe & ffmpeg
|
* ffprobe & ffmpeg
|
||||||
* STARTTLS Email Server (use Gmail if none available)
|
* STARTTLS Email Server (use Gmail if none available)
|
||||||
* Optional: Geo Caching Server (WMTS Caching Service)
|
* Optional: Geo Caching Server (WMTS Caching Service)
|
||||||
|
|
||||||
## PHP Configuration
|
## PHP Configuration
|
||||||
|
|
||||||
* max_execution_time = 300
|
* max_execution_time = 300
|
||||||
* memory_limit = 500M
|
* memory_limit = 500M
|
||||||
* post_max_size = 4G
|
* post_max_size = 4G
|
||||||
* upload_max_filesize = 4G
|
* upload_max_filesize = 4G
|
||||||
* max_file_uploads = 50
|
* max_file_uploads = 50
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
1. Clone Git onto web server
|
1. Clone Git onto web server
|
||||||
2. composer install
|
2. Update php.ini parameters
|
||||||
3. npm run dev
|
3. Copy timezone data: mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb -u root mysql
|
||||||
4. Update php.ini parameters
|
4. Copy settings-sample.php to settings.php and populate
|
||||||
5. Copy timezone data: mariadb_tzinfo_to_sql /usr/share/zoneinfo | mariadb -u root mysql
|
5. Follow CI/CD script in .gitea/workflows/deploy.yml
|
||||||
6. Copy settings-sample.php to settings.php and populate
|
6. Add a GPX file named <project_codename>.gpx to /resources/geo/
|
||||||
7. Go to #admin and create a new project, feed & maps
|
7. Go to #admin and create a new project (with code name = <project_codename>) & feed
|
||||||
8. Add a GPX file named <project_codename>.gpx to /geo/
|
|
||||||
|
|
||||||
|
## Web Root
|
||||||
|
|
||||||
|
The web server should serve `public/` as the application document root. PHP source, configuration, Composer dependencies, uploaded files, and GPX data stay outside the public tree; `public/index.php` is the front controller and Vite writes generated frontend assets to `public/assets/`.
|
||||||
|
|
||||||
|
Runtime data is exposed through symlinks only: `public/files -> ../files` and `public/geo -> ../resources/geo`. The build must not copy uploaded media or GPX data into `public/`.
|
||||||
|
|
||||||
|
## Local Development
|
||||||
|
|
||||||
|
`npm run dev` watches and builds development assets into `public/assets/`. `npm run prod` builds hashed production assets into `public/assets/`. PHP reads `public/.vite/manifest.json` and populates the CSS, module, and preload parts defined in `resources/masks/index.html` while rendering the request.
|
||||||
|
|
||||||
|
When developing Livetrail and the sibling `objects` library together, install dependencies through the local Composer manifest:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
COMPOSER=composer.dev.json composer update
|
||||||
|
```
|
||||||
|
|
||||||
|
This makes Composer link `vendor/franzz/objects` to `../objects` and autoload that namespace directly from the local source path. Production continues to use `composer.json`, which installs `franzz/objects` from its Git repository. Commit and publish `objects` changes before updating/deploying a Livetrail version that relies on them.
|
||||||
|
|
||||||
|
## Before Committing
|
||||||
|
|
||||||
|
Run manually before pushing:
|
||||||
|
|
||||||
|
* `composer lint` - checks PHP style (php-cs-fixer, dry-run); `composer lint-fix` applies it. Requires the dev dependencies (`COMPOSER=composer.dev.json composer update`, see Local Development above).
|
||||||
|
* `npm run lint` - checks JS/Vue style (ESLint) on demand. It also already runs automatically as part of `npm run dev` (reports issues but never blocks the watcher) and `npm run prod` (aborts the build if any lint error is found).
|
||||||
|
|
||||||
## To Do List
|
## To Do List
|
||||||
* ECMA import/export
|
|
||||||
* Add mail frequency slider
|
* Add mail frequency slider
|
||||||
* Use WMTS servers directly when not using Geo Caching Server
|
* Use WMTS servers directly when not using Geo Caching Server
|
||||||
* Allow HEIF picture format
|
* Allow HEIF picture format
|
||||||
* Vector tiles support (https://www.arcgis.com/home/item.html?id=7dc6cea0b1764a1f9af2e679f642f0f5) + Use of GL library. Use Mapbox GL JS / Maplibre GL JS / ESRI-Leaflet-vector?
|
* Garmin InReach Integration
|
||||||
* Fix .MOV playback on windows firefox
|
|
||||||
|
|||||||
+215376
File diff suppressed because it is too large
Load Diff
+1208
-189
File diff suppressed because it is too large
Load Diff
+2536
-320
File diff suppressed because it is too large
Load Diff
+69644
File diff suppressed because it is too large
Load Diff
+119461
-117849
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,237 @@
|
|||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"back": "Back",
|
||||||
|
"delete": "Delete",
|
||||||
|
"save": "Save",
|
||||||
|
"send": "Send"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"login": "Log in",
|
||||||
|
"logout": "Log out",
|
||||||
|
"confirm_password": "Confirm password",
|
||||||
|
"email_placeholder": "my@email.com",
|
||||||
|
"invalid_credentials": "Incorrect password",
|
||||||
|
"invalid_email": "This doesn't look like a valid email address",
|
||||||
|
"logged_in": "Logged in",
|
||||||
|
"logged_out": "Logged out",
|
||||||
|
"newsletter": "Email me new updates",
|
||||||
|
"password": "Password",
|
||||||
|
"password_mismatch": "The passwords don't match",
|
||||||
|
"password_required": "Enter your password to continue",
|
||||||
|
"password_set": "Your password has been set successfully.",
|
||||||
|
"set_password": "Set a password for this administrator account",
|
||||||
|
"subscribed": "Thanks! You'll receive a confirmation email shortly.",
|
||||||
|
"unsubscribed": "Done. No more junk mail from me.",
|
||||||
|
"title": "Account",
|
||||||
|
"status": {
|
||||||
|
"logged_in": "You're logged in.",
|
||||||
|
"logged_in_named": "Hello $0, you're logged in.",
|
||||||
|
"logged_out": "Enter your email address below to receive my position as soon as I find it :)",
|
||||||
|
"subscribed": "You're all set. I'll send you updates!"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"admin": {
|
||||||
|
"config": "Settings",
|
||||||
|
"create_success": "Created",
|
||||||
|
"delete_success": "Deleted",
|
||||||
|
"save_success": "Saved",
|
||||||
|
"title": "Admin Panel",
|
||||||
|
"toolbox": "Toolbox",
|
||||||
|
"upload": "Upload"
|
||||||
|
},
|
||||||
|
"credits": {
|
||||||
|
"git": "Git repository",
|
||||||
|
"license": "licensed under GPLv3",
|
||||||
|
"project": "$0 Project"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"confirmation": {
|
||||||
|
"body_1": "Thank you for following my wanderings :). I'll make sure to keep you posted on my progress along the trail.",
|
||||||
|
"body_2": "I usually check in once a day, and sometimes at special moments too, like successful peak ascents. I'm using a GPS-based device (PLB), which doesn't require phone reception to work. So messages should be fairly frequent, but — being awestruck by the beauty of nature — I might also just forget to send a signal once in a while. So don't worry if you don't receive anything for a couple of days.",
|
||||||
|
"body_3": "If I've posted any pictures recently, you'll also find them in the same email.",
|
||||||
|
"conclusion": "See you down the road!",
|
||||||
|
"preheader": "Thanks for keeping in touch!",
|
||||||
|
"signature": "--François",
|
||||||
|
"subject": "Registration confirmed",
|
||||||
|
"thanks_subject": "You're all set!"
|
||||||
|
},
|
||||||
|
"failure": "Failed to send the update email",
|
||||||
|
"sent": "Update email sent",
|
||||||
|
"unsubscribe": "PS: Changed your mind?",
|
||||||
|
"unsubscribe_button": "Unsubscribe",
|
||||||
|
"update": {
|
||||||
|
"latest_news": "Latest news:",
|
||||||
|
"preheader": "New position received",
|
||||||
|
"subject": "Spotted!",
|
||||||
|
"title": "Message"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"commit_db": "Error committing to database",
|
||||||
|
"file_missing": "$0 file \"$1\" is missing",
|
||||||
|
"impossible_value": "Value \"$0\" is not valid for field \"$1\"",
|
||||||
|
"no_auth": "Not authorized",
|
||||||
|
"not_found": "Unknown action",
|
||||||
|
"unknown_field": "Unknown field \"$0\"",
|
||||||
|
"unknown_type": "Unknown type \"$0\""
|
||||||
|
},
|
||||||
|
"feed": {
|
||||||
|
"counter": "#$0",
|
||||||
|
"id": "Feed ID",
|
||||||
|
"last_update": "Last SPOT update",
|
||||||
|
"name": "Name",
|
||||||
|
"new": "New feed",
|
||||||
|
"plural": "Feeds",
|
||||||
|
"ref_id": "Feed reference ID",
|
||||||
|
"status": "Status"
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
"ign_france": "IGN (France)",
|
||||||
|
"ign_spain": "IGN (Spain)",
|
||||||
|
"linz": "LINZ",
|
||||||
|
"natgeo": "National Geographic",
|
||||||
|
"otm": "Open Topo Map",
|
||||||
|
"outdoors": "Mapbox Outdoors",
|
||||||
|
"satellite": "Satellite",
|
||||||
|
"see_on_google": "View position on Google Maps",
|
||||||
|
"terrain": "3D terrain",
|
||||||
|
"title": "Base maps",
|
||||||
|
"usgs": "USGS"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"click_watch": "Click to watch the video",
|
||||||
|
"click_zoom": "Click to zoom",
|
||||||
|
"comment_update": "Comment for media \"$0\" updated",
|
||||||
|
"image": "Picture",
|
||||||
|
"image_taken_on": "Taken on $0",
|
||||||
|
"images": "Pictures",
|
||||||
|
"nearby": "Nearby pictures",
|
||||||
|
"no_id": "Missing media ID in request",
|
||||||
|
"posted_on": "Posted on $0",
|
||||||
|
"video": "Video",
|
||||||
|
"video_taken_on": "Shot on $0"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"locale": "en_NZ",
|
||||||
|
"page_og_desc": "Stay in touch while I'm away hiking."
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"copy_to_clipboard": "Copy direct link to clipboard",
|
||||||
|
"link_copied": "Link copied!",
|
||||||
|
"message": "Message",
|
||||||
|
"name": "Name",
|
||||||
|
"new_message": "New message",
|
||||||
|
"reply": "Reply to this message"
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"wip": "In progress",
|
||||||
|
"code_name": "Code name",
|
||||||
|
"end": "End",
|
||||||
|
"hikes": "Hikes",
|
||||||
|
"id": "Project ID",
|
||||||
|
"mode": "Mode",
|
||||||
|
"modes": {
|
||||||
|
"blog": "Active project",
|
||||||
|
"histo": "Archived project",
|
||||||
|
"previz": "Project in preparation"
|
||||||
|
},
|
||||||
|
"new": "New project",
|
||||||
|
"overview": "Overview",
|
||||||
|
"plural": "Projects",
|
||||||
|
"single": "Project",
|
||||||
|
"start": "Start",
|
||||||
|
"update_messages": "Update project messages"
|
||||||
|
},
|
||||||
|
"spot": {
|
||||||
|
"id": "Spot ID",
|
||||||
|
"model": "Model",
|
||||||
|
"name": "Spot name",
|
||||||
|
"no_new_msg": "No new messages",
|
||||||
|
"plural": "Spots",
|
||||||
|
"ref_id": "Ref. Spot ID"
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"duration": "Duration",
|
||||||
|
"distance": "Distance",
|
||||||
|
"elevation": "Elevation",
|
||||||
|
"elevation_gain": "Elevation gain",
|
||||||
|
"elevation_loss": "Elevation loss",
|
||||||
|
"from": "Start",
|
||||||
|
"legend": "Legend",
|
||||||
|
"segment_length": "Segment length",
|
||||||
|
"to": "Finish",
|
||||||
|
"type": "Track type"
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"city": "$0 time",
|
||||||
|
"date_time": "$0 at $1",
|
||||||
|
"local": "$0 local time",
|
||||||
|
"user": "$0 your time",
|
||||||
|
"zone": "Time zone"
|
||||||
|
},
|
||||||
|
"track": {
|
||||||
|
"download": "Download GPX track",
|
||||||
|
"hitchhiking": "Hitchhiking",
|
||||||
|
"main": "Main track",
|
||||||
|
"off-track": "Off-track"
|
||||||
|
},
|
||||||
|
"unit": {
|
||||||
|
"day": "day",
|
||||||
|
"day_short": "D",
|
||||||
|
"days": "days",
|
||||||
|
"hour": "h"
|
||||||
|
},
|
||||||
|
"upload": {
|
||||||
|
"error": "Upload failed",
|
||||||
|
"media": {
|
||||||
|
"exists": "Picture $0 already exists",
|
||||||
|
"title": "Picture and video uploads"
|
||||||
|
},
|
||||||
|
"mode_archived": "Project \"$0\" is archived. Uploads are not allowed.",
|
||||||
|
"position": {
|
||||||
|
"determining": "Determining position…",
|
||||||
|
"error": "Unable to determine position",
|
||||||
|
"new": "New position",
|
||||||
|
"permission_denied": "Location permission was denied",
|
||||||
|
"sending": "Sending position…",
|
||||||
|
"success": "Position uploaded successfully",
|
||||||
|
"timeout": "Position request timed out",
|
||||||
|
"title": "Add position",
|
||||||
|
"unavailable": "Position is unavailable",
|
||||||
|
"unsupported": "This browser does not support geolocation"
|
||||||
|
},
|
||||||
|
"success": "$0 uploaded successfully"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"subscribed": "Subscribed users",
|
||||||
|
"clearance": "Clearance",
|
||||||
|
"email": "Email",
|
||||||
|
"id": "User ID",
|
||||||
|
"language": "Language",
|
||||||
|
"name": "User name"
|
||||||
|
},
|
||||||
|
"weather": {
|
||||||
|
"clear-day": "Cloud cover is less than 20% during the day",
|
||||||
|
"clear-night": "Cloud cover is less than 20% during the night",
|
||||||
|
"cloudy": "Cloud cover is greater than 90%",
|
||||||
|
"fog": "Visibility is low (less than 1km)",
|
||||||
|
"hail": "Hail showers",
|
||||||
|
"partly-cloudy-day": "Cloud cover is greater than 20% during the day",
|
||||||
|
"partly-cloudy-night": "Cloud cover is greater than 20% during the night",
|
||||||
|
"rain": "Rainfall is greater than zero",
|
||||||
|
"rain-snow": "Snow and rain showers",
|
||||||
|
"rain-snow-showers-day": "Possible rain/snow throughout the day",
|
||||||
|
"rain-snow-showers-night": "Possible rain/snow throughout the night",
|
||||||
|
"showers-day": "Rain showers during the day",
|
||||||
|
"showers-night": "Rain showers during the night",
|
||||||
|
"sleet": "Sleet",
|
||||||
|
"snow": "Snowfall is greater than zero",
|
||||||
|
"snow-showers-day": "Periods of snow during the day",
|
||||||
|
"snow-showers-night": "Periods of snow during the night",
|
||||||
|
"thunder": "Thunderstorms",
|
||||||
|
"thunder-rain": "Thunderstorms throughout the day or night",
|
||||||
|
"thunder-showers-day": "Possible thunderstorms throughout the day",
|
||||||
|
"thunder-showers-night": "Possible thunderstorms throughout the night",
|
||||||
|
"wind": "Wind speed is high (greater than 30 km/h)"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"back": "Atrás",
|
||||||
|
"delete": "Borrar",
|
||||||
|
"save": "Guardar",
|
||||||
|
"send": "Enviar"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"login": "Iniciar sesión",
|
||||||
|
"logout": "Cerrar sesión",
|
||||||
|
"confirm_password": "Confirmar contraseña",
|
||||||
|
"email_placeholder": "nombre@email.com",
|
||||||
|
"invalid_credentials": "Contraseña incorrecta",
|
||||||
|
"invalid_email": "Esto no parece una dirección de correo electrónico",
|
||||||
|
"logged_in": "Sesión iniciada",
|
||||||
|
"logged_out": "Sesión cerrada",
|
||||||
|
"newsletter": "Enviarme nuevas actualizaciones por correo",
|
||||||
|
"password": "Contraseña",
|
||||||
|
"password_mismatch": "Las contraseñas no coinciden",
|
||||||
|
"password_required": "Introduce tu contraseña para continuar",
|
||||||
|
"password_set": "Tu contraseña se ha establecido correctamente.",
|
||||||
|
"set_password": "Establece una contraseña para esta cuenta administradora",
|
||||||
|
"subscribed": "¡Gracias! Recibirás un correo electrónico de confirmación.",
|
||||||
|
"unsubscribed": "Listo. ¡No más spam!",
|
||||||
|
"title": "Cuenta",
|
||||||
|
"status": {
|
||||||
|
"logged_in": "Has iniciado sesión.",
|
||||||
|
"logged_in_named": "Hola $0, has iniciado sesión.",
|
||||||
|
"logged_out": "Añade tu dirección de correo electrónico y te enviaré mi posición actualizada tan pronto como la reciba :)",
|
||||||
|
"subscribed": "Todo está listo. Te enviaré noticias frescas en cuanto las reciba. Prometido..."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"admin": {
|
||||||
|
"config": "Configuración",
|
||||||
|
"create_success": "Creado",
|
||||||
|
"delete_success": "Eliminado",
|
||||||
|
"save_success": "Guardado",
|
||||||
|
"title": "Administración",
|
||||||
|
"toolbox": "Herramientas",
|
||||||
|
"upload": "Cargar"
|
||||||
|
},
|
||||||
|
"credits": {
|
||||||
|
"git": "Repositorio de Git",
|
||||||
|
"license": "bajo licencia GPLv3",
|
||||||
|
"project": "Proyecto $0"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"confirmation": {
|
||||||
|
"body_1": "Te agradezco mucho que sigas mi proyecto y que te intereses por su evolución. Te prometo que te mantendré informado sobre mi progreso.",
|
||||||
|
"body_2": "Normalmente envío un mensaje una vez al día. Cuando voy a lugares especiales, envío uno extra (cimas, ese tipo de cosas). Uso un dispositivo GPS para enviar la señal, así que no necesito cobertura telefónica para que funcione. Sin embargo, puede haber ocasiones en las que no presione el botón. Por lo tanto, no te preocupes si no recibes mensajes durante uno o dos días.",
|
||||||
|
"body_3": "Cuando añada fotos a la página, también las encontrarás en este correo electrónico.",
|
||||||
|
"conclusion": "¡Nos vemos en el camino!",
|
||||||
|
"preheader": "¡Gracias por mantenerte en contacto!",
|
||||||
|
"signature": "--François",
|
||||||
|
"subject": "Confirmación",
|
||||||
|
"thanks_subject": "¡Hecho!"
|
||||||
|
},
|
||||||
|
"failure": "No se pudo enviar el correo de actualización",
|
||||||
|
"sent": "Correo de actualización enviado",
|
||||||
|
"unsubscribe": "PD: ¿Demasiados correos electrónicos?",
|
||||||
|
"unsubscribe_button": "Darse de baja",
|
||||||
|
"update": {
|
||||||
|
"latest_news": "Últimas noticias:",
|
||||||
|
"preheader": "¡Nueva posición!",
|
||||||
|
"subject": "Nueva posición recibida",
|
||||||
|
"title": "Mensaje"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"commit_db": "Error SQL",
|
||||||
|
"file_missing": "Falta el archivo $0 \"$1\"",
|
||||||
|
"impossible_value": "El valor \"$0\" no es posible para el campo \"$1\"",
|
||||||
|
"no_auth": "Sin autorización",
|
||||||
|
"not_found": "Acción desconocida",
|
||||||
|
"unknown_field": "Campo \"$0\" desconocido",
|
||||||
|
"unknown_type": "Tipo \"$0\" desconocido"
|
||||||
|
},
|
||||||
|
"feed": {
|
||||||
|
"counter": "N.º $0",
|
||||||
|
"id": "ID Feed",
|
||||||
|
"last_update": "Última actualización de SPOT",
|
||||||
|
"name": "Descripción",
|
||||||
|
"new": "Nuevo feed",
|
||||||
|
"plural": "Feeds",
|
||||||
|
"ref_id": "ID Feed ref.",
|
||||||
|
"status": "Estado"
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
"ign_france": "IGN (Francia)",
|
||||||
|
"ign_spain": "IGN (España)",
|
||||||
|
"linz": "LINZ",
|
||||||
|
"natgeo": "National Geographic",
|
||||||
|
"otm": "Open Topo Map",
|
||||||
|
"outdoors": "Mapbox Topo",
|
||||||
|
"satellite": "Satélite",
|
||||||
|
"see_on_google": "Ver la posición en Google Maps",
|
||||||
|
"terrain": "Relieve 3D",
|
||||||
|
"title": "Mapas de base",
|
||||||
|
"usgs": "USGS"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"click_watch": "Haz clic para ver el vídeo",
|
||||||
|
"click_zoom": "Haz clic para ampliar",
|
||||||
|
"comment_update": "Comentario \"$0\" actualizado",
|
||||||
|
"image": "Foto",
|
||||||
|
"image_taken_on": "Foto tomada el $0",
|
||||||
|
"images": "Fotos",
|
||||||
|
"nearby": "Fotos cercanas",
|
||||||
|
"no_id": "Falta el ID del archivo multimedia",
|
||||||
|
"posted_on": "Añadido el $0",
|
||||||
|
"video": "Vídeo",
|
||||||
|
"video_taken_on": "Vídeo grabado el $0"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"locale": "es_ES",
|
||||||
|
"page_og_desc": "Mantente en contacto conmigo durante mis aventuras en la montaña."
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"copy_to_clipboard": "Copiar el enlace",
|
||||||
|
"link_copied": "¡Enlace copiado!",
|
||||||
|
"message": "Mensaje",
|
||||||
|
"name": "Nombre",
|
||||||
|
"new_message": "Mensaje nuevo",
|
||||||
|
"reply": "Responder a este mensaje"
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"wip": "En curso",
|
||||||
|
"code_name": "Nombre clave",
|
||||||
|
"end": "Fin",
|
||||||
|
"hikes": "Senderos",
|
||||||
|
"id": "ID del proyecto",
|
||||||
|
"mode": "Modo",
|
||||||
|
"modes": {
|
||||||
|
"blog": "Proyecto activo",
|
||||||
|
"histo": "Proyecto archivado",
|
||||||
|
"previz": "Proyecto en preparación"
|
||||||
|
},
|
||||||
|
"new": "Nuevo proyecto",
|
||||||
|
"overview": "Vista general",
|
||||||
|
"plural": "Proyectos",
|
||||||
|
"single": "Proyecto",
|
||||||
|
"start": "Inicio",
|
||||||
|
"update_messages": "Actualizar los mensajes del proyecto"
|
||||||
|
},
|
||||||
|
"spot": {
|
||||||
|
"id": "ID de Spot",
|
||||||
|
"model": "Modelo",
|
||||||
|
"name": "Spot",
|
||||||
|
"no_new_msg": "No hay mensajes nuevos",
|
||||||
|
"plural": "Spots",
|
||||||
|
"ref_id": "ID de referencia de Spot"
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"duration": "Duración",
|
||||||
|
"distance": "Distancia",
|
||||||
|
"elevation": "Elevación",
|
||||||
|
"elevation_gain": "Ascenso acumulado",
|
||||||
|
"elevation_loss": "Descenso acumulado",
|
||||||
|
"from": "Inicio",
|
||||||
|
"legend": "Leyenda",
|
||||||
|
"segment_length": "Tamaño del segmento",
|
||||||
|
"to": "Fin",
|
||||||
|
"type": "Tipo de sendero"
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"city": "Hora en $0",
|
||||||
|
"date_time": "$0 a las $1",
|
||||||
|
"local": "$0 hora local",
|
||||||
|
"user": "$0 en tu zona horaria",
|
||||||
|
"zone": "Huso horario"
|
||||||
|
},
|
||||||
|
"track": {
|
||||||
|
"download": "Descargar la ruta GPX",
|
||||||
|
"hitchhiking": "Autostop",
|
||||||
|
"main": "Camino principal",
|
||||||
|
"off-track": "Variante"
|
||||||
|
},
|
||||||
|
"unit": {
|
||||||
|
"day": "día",
|
||||||
|
"day_short": "D",
|
||||||
|
"days": "días",
|
||||||
|
"hour": "h"
|
||||||
|
},
|
||||||
|
"upload": {
|
||||||
|
"error": "Error al subir el archivo",
|
||||||
|
"media": {
|
||||||
|
"exists": "La imagen $0 ya existe",
|
||||||
|
"title": "Cargar fotos y vídeos"
|
||||||
|
},
|
||||||
|
"mode_archived": "El proyecto \"$0\" está archivado. No se puede cargar.",
|
||||||
|
"position": {
|
||||||
|
"determining": "Determinando la posición…",
|
||||||
|
"error": "No se puede determinar la posición",
|
||||||
|
"new": "Nueva posición",
|
||||||
|
"permission_denied": "Se ha denegado el permiso de ubicación",
|
||||||
|
"sending": "Enviando la posición…",
|
||||||
|
"success": "Posición subida correctamente",
|
||||||
|
"timeout": "La solicitud de posición ha agotado el tiempo de espera",
|
||||||
|
"title": "Subir posición",
|
||||||
|
"unavailable": "La posición no está disponible",
|
||||||
|
"unsupported": "Este navegador no admite la geolocalización"
|
||||||
|
},
|
||||||
|
"success": "$0 se ha subido correctamente."
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"subscribed": "Usuarios suscritos",
|
||||||
|
"clearance": "Nivel de autorización",
|
||||||
|
"email": "Correo electrónico",
|
||||||
|
"id": "ID del usuario",
|
||||||
|
"language": "Idioma",
|
||||||
|
"name": "Nombre"
|
||||||
|
},
|
||||||
|
"weather": {
|
||||||
|
"clear-day": "La nubosidad es inferior al 20 % durante el día",
|
||||||
|
"clear-night": "La nubosidad es inferior al 20 % durante la noche",
|
||||||
|
"cloudy": "La nubosidad es superior al 90 %",
|
||||||
|
"fog": "La visibilidad es baja (menos de 1km)",
|
||||||
|
"hail": "Chubascos de granizo",
|
||||||
|
"partly-cloudy-day": "La nubosidad es superior al 20 % durante el día",
|
||||||
|
"partly-cloudy-night": "La nubosidad es superior al 20 % durante la noche",
|
||||||
|
"rain": "La cantidad de lluvia es superior a cero",
|
||||||
|
"rain-snow": "Chubascos de nieve y lluvia",
|
||||||
|
"rain-snow-showers-day": "Posible lluvia/nieve durante todo el día",
|
||||||
|
"rain-snow-showers-night": "Posible lluvia/nieve durante toda la noche",
|
||||||
|
"showers-day": "Chubascos de lluvia durante el día",
|
||||||
|
"showers-night": "Chubascos de lluvia durante la noche",
|
||||||
|
"sleet": "Aguanieve",
|
||||||
|
"snow": "La cantidad de nieve es superior a cero",
|
||||||
|
"snow-showers-day": "Periodos de nieve durante el día",
|
||||||
|
"snow-showers-night": "Periodos de nieve durante la noche",
|
||||||
|
"thunder": "Tormentas",
|
||||||
|
"thunder-rain": "Tormentas durante el día o la noche",
|
||||||
|
"thunder-showers-day": "Posibles tormentas durante todo el día",
|
||||||
|
"thunder-showers-night": "Posibles tormentas durante toda la noche",
|
||||||
|
"wind": "La velocidad del viento es alta (más de 30 km/h)"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"back": "Retour",
|
||||||
|
"delete": "Supprimer",
|
||||||
|
"save": "Sauvegarder",
|
||||||
|
"send": "Envoyer"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"login": "Se connecter",
|
||||||
|
"logout": "Se déconnecter",
|
||||||
|
"confirm_password": "Confirmer le mot de passe",
|
||||||
|
"email_placeholder": "mon@email.com",
|
||||||
|
"invalid_credentials": "Mot de passe incorrect",
|
||||||
|
"invalid_email": "Ceci ne ressemble pas à une adresse e-mail",
|
||||||
|
"logged_in": "Connexion réussie",
|
||||||
|
"logged_out": "Déconnexion réussie",
|
||||||
|
"newsletter": "M'envoyer les nouvelles mises à jour par e-mail",
|
||||||
|
"password": "Mot de passe",
|
||||||
|
"password_mismatch": "Les mots de passe ne correspondent pas",
|
||||||
|
"password_required": "Saisis ton mot de passe pour continuer",
|
||||||
|
"password_set": "Ton mot de passe a bien été défini.",
|
||||||
|
"set_password": "Définis un mot de passe pour ce compte administrateur",
|
||||||
|
"subscribed": "Merci ! Tu vas recevoir un e-mail de confirmation très bientôt.",
|
||||||
|
"unsubscribed": "C'est fait. Fini le spam !",
|
||||||
|
"title": "Compte",
|
||||||
|
"status": {
|
||||||
|
"logged_in": "Tu es connecté.",
|
||||||
|
"logged_in_named": "Bonjour $0, tu es connecté.",
|
||||||
|
"logged_out": "Ajoute ton adresse e-mail et je t'enverrai ma nouvelle position dès que je la trouve :)",
|
||||||
|
"subscribed": "C'est tout bon. Je t'enverrai des nouvelles fraîches. Parole de scout."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"admin": {
|
||||||
|
"config": "Paramètres",
|
||||||
|
"create_success": "Créé",
|
||||||
|
"delete_success": "Supprimé",
|
||||||
|
"save_success": "Sauvegardé",
|
||||||
|
"title": "Administration",
|
||||||
|
"toolbox": "Boîte à outils",
|
||||||
|
"upload": "Téléverser"
|
||||||
|
},
|
||||||
|
"credits": {
|
||||||
|
"git": "Dépôt Git",
|
||||||
|
"license": "sous licence GPLv3",
|
||||||
|
"project": "Projet $0"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"confirmation": {
|
||||||
|
"body_1": "C'est gentil de venir voir où j'en suis. Promis, je te tiendrai au courant de mon avancée.",
|
||||||
|
"body_2": "En général, j'envoie un message une fois par jour. Lorsque je passe par des endroits sympas, j'en envoie un supplémentaire (sommets, ce genre de choses). J'utilise une balise GPS pour envoyer le signal, je n'ai donc pas besoin de réseau téléphonique pour que cela fonctionne. Cependant, il peut m'arriver d'oublier d'appuyer sur le bouton. Donc pas de raison de t'inquiéter si tu ne reçois pas de messages pendant une journée ou deux.",
|
||||||
|
"body_3": "Si j'ai ajouté des photos sur le site récemment, tu devrais aussi les retrouver dans cet e-mail.",
|
||||||
|
"conclusion": "À bientôt sur les chemins !",
|
||||||
|
"preheader": "Merci de rester en contact !",
|
||||||
|
"signature": "--François",
|
||||||
|
"subject": "Confirmation",
|
||||||
|
"thanks_subject": "C'est tout bon !"
|
||||||
|
},
|
||||||
|
"failure": "Échec de l’envoi de l’e-mail de mise à jour",
|
||||||
|
"sent": "E-mail de mise à jour envoyé",
|
||||||
|
"unsubscribe": "PS : Trop d'e-mails ?",
|
||||||
|
"unsubscribe_button": "Se désinscrire",
|
||||||
|
"update": {
|
||||||
|
"latest_news": "Dernières nouvelles :",
|
||||||
|
"preheader": "Nouvelle position !",
|
||||||
|
"subject": "Nouvelle position reçue",
|
||||||
|
"title": "Message"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"commit_db": "Erreur lors de la requête SQL",
|
||||||
|
"file_missing": "Le fichier $0 \"$1\" est manquant",
|
||||||
|
"impossible_value": "La valeur \"$0\" n'est pas possible pour le champ \"$1\"",
|
||||||
|
"no_auth": "Pas d'autorisation",
|
||||||
|
"not_found": "Action inconnue",
|
||||||
|
"unknown_field": "Champ \"$0\" inconnu",
|
||||||
|
"unknown_type": "Type \"$0\" inconnu"
|
||||||
|
},
|
||||||
|
"feed": {
|
||||||
|
"counter": "N°$0",
|
||||||
|
"id": "ID feed",
|
||||||
|
"last_update": "Dernière vérification de SPOT",
|
||||||
|
"name": "Description",
|
||||||
|
"new": "Nouveau feed",
|
||||||
|
"plural": "Feeds",
|
||||||
|
"ref_id": "ID Feed ref.",
|
||||||
|
"status": "Statut"
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
"ign_france": "IGN (France)",
|
||||||
|
"ign_spain": "IGN (Espagne)",
|
||||||
|
"linz": "LINZ",
|
||||||
|
"natgeo": "National Geographic",
|
||||||
|
"otm": "Open Topo Map",
|
||||||
|
"outdoors": "Mapbox Topo",
|
||||||
|
"satellite": "Satellite",
|
||||||
|
"see_on_google": "Voir la position sur Google Maps",
|
||||||
|
"terrain": "Relief 3D",
|
||||||
|
"title": "Fonds de carte",
|
||||||
|
"usgs": "USGS"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"click_watch": "Cliquer pour voir la vidéo",
|
||||||
|
"click_zoom": "Cliquer pour zoomer",
|
||||||
|
"comment_update": "Commentaire du média \"$0\" mis à jour",
|
||||||
|
"image": "Photo",
|
||||||
|
"image_taken_on": "Prise le $0",
|
||||||
|
"images": "Photos",
|
||||||
|
"nearby": "Photos prises dans le coin",
|
||||||
|
"no_id": "ID du média manquant",
|
||||||
|
"posted_on": "Ajouté le $0",
|
||||||
|
"video": "Vidéo",
|
||||||
|
"video_taken_on": "Filmé le $0"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"locale": "fr_CH",
|
||||||
|
"page_og_desc": "Garde le contact lorsque je suis sur les chemins."
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"copy_to_clipboard": "Copier le lien dans le presse-papiers",
|
||||||
|
"link_copied": "Lien copié !",
|
||||||
|
"message": "Message",
|
||||||
|
"name": "Nom",
|
||||||
|
"new_message": "Nouveau message",
|
||||||
|
"reply": "Répondre à ce message"
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"wip": "En cours",
|
||||||
|
"code_name": "Nom de code",
|
||||||
|
"end": "Arrivée",
|
||||||
|
"hikes": "Randonnées",
|
||||||
|
"id": "ID projet",
|
||||||
|
"mode": "Mode",
|
||||||
|
"modes": {
|
||||||
|
"blog": "Projet actif",
|
||||||
|
"histo": "Projet archivé",
|
||||||
|
"previz": "Projet en cours de préparation"
|
||||||
|
},
|
||||||
|
"new": "Nouveau projet",
|
||||||
|
"overview": "Vue d'ensemble",
|
||||||
|
"plural": "Projets",
|
||||||
|
"single": "Projet",
|
||||||
|
"start": "Départ",
|
||||||
|
"update_messages": "Mettre à jour les messages du projet"
|
||||||
|
},
|
||||||
|
"spot": {
|
||||||
|
"id": "ID Spot",
|
||||||
|
"model": "Modèle",
|
||||||
|
"name": "Spot",
|
||||||
|
"no_new_msg": "Aucun nouveau message",
|
||||||
|
"plural": "Spots",
|
||||||
|
"ref_id": "ID Spot ref."
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"duration": "Durée",
|
||||||
|
"distance": "Distance",
|
||||||
|
"elevation": "Dénivelé",
|
||||||
|
"elevation_gain": "Dénivelé positif",
|
||||||
|
"elevation_loss": "Dénivelé négatif",
|
||||||
|
"from": "Départ",
|
||||||
|
"legend": "Légende",
|
||||||
|
"segment_length": "Taille du segment",
|
||||||
|
"to": "Arrivée",
|
||||||
|
"type": "Type de rando"
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"city": "Heure à $0",
|
||||||
|
"date_time": "$0 à $1",
|
||||||
|
"local": "$0 heure locale",
|
||||||
|
"user": "$0 dans ton fuseau horaire",
|
||||||
|
"zone": "Fuseau horaire"
|
||||||
|
},
|
||||||
|
"track": {
|
||||||
|
"download": "Télécharger la trace GPX",
|
||||||
|
"hitchhiking": "Auto-stop",
|
||||||
|
"main": "Itinéraire",
|
||||||
|
"off-track": "Variante"
|
||||||
|
},
|
||||||
|
"unit": {
|
||||||
|
"day": "jour",
|
||||||
|
"day_short": "J",
|
||||||
|
"days": "jours",
|
||||||
|
"hour": "h"
|
||||||
|
},
|
||||||
|
"upload": {
|
||||||
|
"error": "Erreur lors du téléversement",
|
||||||
|
"media": {
|
||||||
|
"exists": "L'image $0 existe déjà",
|
||||||
|
"title": "Téléverser des photos et vidéos"
|
||||||
|
},
|
||||||
|
"mode_archived": "Le projet \"$0\" a été archivé. Aucun téléversement possible.",
|
||||||
|
"position": {
|
||||||
|
"determining": "Détermination de la position…",
|
||||||
|
"error": "Impossible de déterminer la position",
|
||||||
|
"new": "Nouvelle position",
|
||||||
|
"permission_denied": "L’autorisation d’accéder à la position a été refusée",
|
||||||
|
"sending": "Envoi de la position…",
|
||||||
|
"success": "Position téléversée avec succès",
|
||||||
|
"timeout": "La demande de position a expiré",
|
||||||
|
"title": "Position supplémentaire",
|
||||||
|
"unavailable": "La position n’est pas disponible",
|
||||||
|
"unsupported": "Ce navigateur ne prend pas en charge la géolocalisation"
|
||||||
|
},
|
||||||
|
"success": "$0 a été téléversé"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"subscribed": "Utilisateurs abonnés",
|
||||||
|
"clearance": "Niveau d'autorisation",
|
||||||
|
"email": "E-mail",
|
||||||
|
"id": "ID utilisateur",
|
||||||
|
"language": "Langue",
|
||||||
|
"name": "Nom"
|
||||||
|
},
|
||||||
|
"weather": {
|
||||||
|
"clear-day": "La couverture nuageuse est inférieure à 20 % pendant la journée",
|
||||||
|
"clear-night": "La couverture nuageuse est inférieure à 20 % pendant la nuit",
|
||||||
|
"cloudy": "La couverture nuageuse est supérieure à 90 %",
|
||||||
|
"fog": "La visibilité est faible (moins de 1km)",
|
||||||
|
"hail": "Averses de grêle",
|
||||||
|
"partly-cloudy-day": "La couverture nuageuse est supérieure à 20 % pendant la journée",
|
||||||
|
"partly-cloudy-night": "La couverture nuageuse est supérieure à 20 % pendant la nuit",
|
||||||
|
"rain": "La quantité de pluie est supérieure à zéro",
|
||||||
|
"rain-snow": "Averses de neige et de pluie",
|
||||||
|
"rain-snow-showers-day": "Pluie/neige possible tout au long de la journée",
|
||||||
|
"rain-snow-showers-night": "Pluie/neige possible tout au long de la nuit",
|
||||||
|
"showers-day": "Averses de pluie pendant la journée",
|
||||||
|
"showers-night": "Averses de pluie pendant la nuit",
|
||||||
|
"sleet": "Grésil",
|
||||||
|
"snow": "La quantité de neige est supérieure à zéro",
|
||||||
|
"snow-showers-day": "Périodes de neige pendant la journée",
|
||||||
|
"snow-showers-night": "Périodes de neige pendant la nuit",
|
||||||
|
"thunder": "Orages",
|
||||||
|
"thunder-rain": "Orages tout au long de la journée ou de la nuit",
|
||||||
|
"thunder-showers-day": "Orages possibles tout au long de la journée",
|
||||||
|
"thunder-showers-night": "Orages possibles tout au long de la nuit",
|
||||||
|
"wind": "La vitesse du vent est élevée (plus de 30 km/h)"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||||
|
<title>[#]lang:email.confirmation.subject[#]</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span style="color: transparent; display: none !important; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">[#]lang:email.confirmation.preheader[#]</span>
|
||||||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;max-width:600px;">
|
||||||
|
<tr>
|
||||||
|
<td width="20%"><img src="[#]local_server[#]assets/images/icons/favicon-96x96.png" width="90%" border="0" alt="logo" /></td>
|
||||||
|
<td><h1>[#]lang:email.confirmation.thanks_subject[#]</h1></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<p align="justify">[#]lang:email.confirmation.body_1[#]</p>
|
||||||
|
<p align="justify">[#]lang:email.confirmation.body_2[#]</p>
|
||||||
|
<p align="justify">[#]lang:email.confirmation.body_3[#]</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<p>[#]lang:email.confirmation.conclusion[#]<br />[#]lang:email.confirmation.signature[#]</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<p>[#]lang:email.unsubscribe[#] <a href="[#]unsubscribe_link[#]" target="_blank" rel="noopener">[#]lang:email.unsubscribe_button[#]</a></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||||
<title>[#]lang:email_update_subject[#]</title>
|
<title>[#]lang:email.update.subject[#]</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<span style="color: transparent; display: none !important; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">[#]lang:update_preheader[#]</span>
|
<span style="color: transparent; display: none !important; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">[#]lang:email.update.preheader[#]</span>
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;max-width:600px;">
|
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;max-width:600px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20%"><img src="[#]local_server[#]images/icons/mstile-144x144.png" width="90%" border="0" alt="logo" /></td>
|
<td width="20%"><img src="[#]local_server[#]assets/images/icons/favicon-96x96.png" width="90%" border="0" alt="logo" /></td>
|
||||||
<td><h1>[#]lang:update_title[#] [#]type[#] #[#]displayed_id[#]</h1></td>
|
<td><h1>[#]lang:email.update.title[#] [#]type[#] #[#]displayed_id[#]</h1></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<h2>[#]lang:update_latest_news[#]</h2>
|
<h2>[#]lang:email.update.latest_news[#]</h2>
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||||
<!-- [PART] news [START] -->
|
<!-- [PART] news [START] -->
|
||||||
<tr>
|
<tr>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<p>[#]lang:email_unsubscribe[#] <a href="[#]unsubscribe_link[#]" target="_blank" rel="noopener">[#]lang:email_unsub_btn[#]</a></p>
|
<p>[#]lang:email.unsubscribe[#] <a href="[#]unsubscribe_link[#]" target="_blank" rel="noopener">[#]lang:email.unsubscribe_button[#]</a></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="[#]language[#]">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="description" content="[#]lang:meta.page_og_desc[#]">
|
||||||
|
<meta property="og:title" content="[#]title[#]" />
|
||||||
|
<meta property="og:description" content="[#]lang:meta.page_og_desc[#]" />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:url" content="[#]server[#]" />
|
||||||
|
<meta property="og:image" content="assets/images/icons/ogp.svg?v=20260528" />
|
||||||
|
<meta property="og:locale" content="[#]lang:meta.locale[#]" />
|
||||||
|
<link rel="icon" type="image/png" href="assets/images/icons/favicon-96x96.png?v=20260528" sizes="96x96" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="assets/images/icons/favicon.svg?v=20260528" />
|
||||||
|
<link rel="shortcut icon" href="assets/images/icons/favicon.ico?v=20260528" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/icons/apple-touch-icon.png?v=20260528" />
|
||||||
|
<meta name="apple-mobile-web-app-title" content="[#]title[#]" />
|
||||||
|
<link rel="manifest" href="assets/images/icons/site.webmanifest?v=20260528" />
|
||||||
|
<meta name="theme-color" content="#081B19">
|
||||||
|
<script id="app-config" type="application/json">[#]app_config[#]</script>
|
||||||
|
<title>[#]title[#]</title>
|
||||||
|
<!-- [PART] css [START] -->
|
||||||
|
<link rel="stylesheet" href="[#]filename[#]" />
|
||||||
|
<!-- [PART] css [END] -->
|
||||||
|
<!-- [PART] module [START] -->
|
||||||
|
<link rel="modulepreload" href="[#]filename[#]" />
|
||||||
|
<!-- [PART] module [END] -->
|
||||||
|
<script type="module" src="[#]app_entry[#]"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
<script>
|
||||||
|
import { defineAsyncComponent } from 'vue';
|
||||||
|
import Project from '@components/Project';
|
||||||
|
|
||||||
|
const aoRoutes = {
|
||||||
|
'project': Project, //Merge app.js and project.js calls to avoid extra http request on inital page
|
||||||
|
'admin': defineAsyncComponent(() => import('@components/Admin')),
|
||||||
|
'upload': defineAsyncComponent(() => import('@components/Upload'))
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
hash: {page: '', items: [], prev: {}},
|
||||||
|
consts: this.appConfig.consts,
|
||||||
|
mobile: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
hash: this.hash,
|
||||||
|
consts: this.consts,
|
||||||
|
isMobile: () => this.isMobile(),
|
||||||
|
getAnchor: this.getAnchor,
|
||||||
|
getPrevAnchor: () => this.getPrevAnchor(),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
route() {
|
||||||
|
return aoRoutes[this.hash.page];
|
||||||
|
},
|
||||||
|
hashSnapshot() {
|
||||||
|
const { prev, ...asHash } = this.hash;
|
||||||
|
return JSON.stringify(asHash);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inject: ['appConfig'],
|
||||||
|
created() {
|
||||||
|
this.mobileMediaQuery = window.matchMedia('only screen and (max-width: 800px)');
|
||||||
|
this.mobileMediaQuery.addEventListener('change', this.updateMobile);
|
||||||
|
this.updateMobile();
|
||||||
|
|
||||||
|
//Set initial page
|
||||||
|
this.setVarHash(this.validateRoute(this.getBrowserHash()));
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
//Catch browser hash change
|
||||||
|
window.addEventListener('hashchange', this.onBrowserHashChange);
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
hashSnapshot(jNewHash, jOldHash) {
|
||||||
|
const asNewHash = this.validateRoute(JSON.parse(jNewHash));
|
||||||
|
|
||||||
|
//Sync variable -> #hash
|
||||||
|
if(asNewHash != this.getBrowserHash()) {
|
||||||
|
this.setBrowserHash(asNewHash.page, asNewHash.items);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Store previous value
|
||||||
|
this.hash.prev = JSON.parse(jOldHash);
|
||||||
|
|
||||||
|
this.setPageTitle(asNewHash.page);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
isMobile() {
|
||||||
|
return this.mobile;
|
||||||
|
},
|
||||||
|
updateMobile() {
|
||||||
|
this.mobile = this.mobileMediaQuery.matches;
|
||||||
|
},
|
||||||
|
setPageTitle(sTitle) {
|
||||||
|
document.title = this.consts.title + ' - ' + sTitle.trim();
|
||||||
|
},
|
||||||
|
setVarHash(asHash) {
|
||||||
|
this.hash.page = asHash.page || '';
|
||||||
|
this.hash.items = Array.isArray(asHash.items) ? [...asHash.items.filter(n => n)] : [];
|
||||||
|
},
|
||||||
|
onBrowserHashChange() { //Sync #hash -> variable
|
||||||
|
let asHash = this.getBrowserHash();
|
||||||
|
if(asHash != this.hash) this.setVarHash(asHash);
|
||||||
|
},
|
||||||
|
getBrowserHash() {
|
||||||
|
let sHash = window.location.hash.slice(1);
|
||||||
|
let asHash = sHash.split(this.consts.hash_sep).filter(n => n);
|
||||||
|
let sPage = asHash.shift() || '';
|
||||||
|
return {page: sPage, items: asHash};
|
||||||
|
},
|
||||||
|
setBrowserHash(sPage = '', asItems = []) {
|
||||||
|
if(typeof asItems == 'string' && asItems != '') asItems = [asItems];
|
||||||
|
window.location.hash = this.getAnchor([sPage, ...asItems]);
|
||||||
|
},
|
||||||
|
getAnchor(asBreadCrumbs) {
|
||||||
|
return '#' + asBreadCrumbs.filter(Boolean).join(this.consts.hash_sep);
|
||||||
|
},
|
||||||
|
getPrevAnchor() {
|
||||||
|
return this.getAnchor([this.hash.prev.page, ...this.hash.prev.items]);
|
||||||
|
},
|
||||||
|
validateRoute(asHash) {
|
||||||
|
if(!Object.keys(aoRoutes).includes(asHash.page)) asHash.page = this.consts.default_page;
|
||||||
|
return asHash;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
window.removeEventListener('hashchange', this.onBrowserHashChange);
|
||||||
|
this.mobileMediaQuery.removeEventListener('change', this.updateMobile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div id="main">
|
||||||
|
<component :is="route" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Project from './components/project.vue';
|
|
||||||
import Admin from './components/admin.vue';
|
|
||||||
|
|
||||||
const aoRoutes = {
|
|
||||||
'project': Project,
|
|
||||||
'admin': Admin
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
//spot: window.oSpot,
|
|
||||||
hash: {}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: ['spot'],
|
|
||||||
computed: {
|
|
||||||
currentView() {
|
|
||||||
this.spot.vars('page', this.hash.page);
|
|
||||||
return aoRoutes[this.hash.page];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
window.addEventListener('hashchange', () => {this.onHashChange();});
|
|
||||||
var oEvent = new Event('hashchange');
|
|
||||||
window.dispatchEvent(oEvent);
|
|
||||||
}
|
|
||||||
,
|
|
||||||
methods: {
|
|
||||||
_hash(hash, bReboot) {
|
|
||||||
bReboot = bReboot || false;
|
|
||||||
if(!hash) return window.location.hash.slice(1);
|
|
||||||
else window.location.hash = '#'+hash;
|
|
||||||
|
|
||||||
if(bReboot) location.reload();
|
|
||||||
},
|
|
||||||
onHashChange() {
|
|
||||||
let asHash = this.getHash();
|
|
||||||
if(asHash.hash !='' && asHash.page != '') this.hash = asHash;
|
|
||||||
else if(!this.hash.page) this.setHash(this.spot.consts.default_page);
|
|
||||||
},
|
|
||||||
getHash() {
|
|
||||||
let sHash = this._hash();
|
|
||||||
let asHash = sHash.split(this.spot.consts.hash_sep);
|
|
||||||
let sPage = asHash.shift() || '';
|
|
||||||
return {hash:sHash, page:sPage, items:asHash};
|
|
||||||
},
|
|
||||||
setHash(sPage, asItems, bReboot) {
|
|
||||||
bReboot = bReboot || false;
|
|
||||||
sPage = sPage || '';
|
|
||||||
asItems = asItems || [];
|
|
||||||
if(typeof asItems == 'string') asItems = [asItems];
|
|
||||||
|
|
||||||
if(sPage != '') {
|
|
||||||
let sItems = (asItems.length > 0)?this.spot.consts.hash_sep+asItems.join(this.spot.consts.hash_sep):'';
|
|
||||||
this._hash(sPage+sItems, bReboot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div id="#main">
|
|
||||||
<component :is="currentView" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
//Librairies
|
||||||
|
import 'vite/modulepreload-polyfill';
|
||||||
|
import Api from '@scripts/api';
|
||||||
|
import Lang from '@scripts/lang';
|
||||||
|
import Projects from '@scripts/projects';
|
||||||
|
import User from '@scripts/user';
|
||||||
|
import { createApp, reactive } from 'vue';
|
||||||
|
|
||||||
|
//Main template
|
||||||
|
import App from './App.vue';
|
||||||
|
|
||||||
|
//Style
|
||||||
|
import '@styles/livetrail.scss';
|
||||||
|
|
||||||
|
//App Configuration from PHP
|
||||||
|
const appConfig = JSON.parse(document.getElementById('app-config').textContent);
|
||||||
|
|
||||||
|
//Instances
|
||||||
|
const oProjects = new Projects(appConfig.projects);
|
||||||
|
const oUser = reactive(new User(appConfig.user, appConfig.consts.default_timezone));
|
||||||
|
const oLang = new Lang({translations: appConfig.consts.lang, prefix: appConfig.consts.lang_prefix});
|
||||||
|
const oApi = new Api({
|
||||||
|
server: appConfig.consts.server,
|
||||||
|
processPage: appConfig.consts.process_page,
|
||||||
|
timezone: oUser.timezone,
|
||||||
|
csrfToken: appConfig.consts.csrf_token,
|
||||||
|
errorCode: appConfig.consts.error,
|
||||||
|
lang: oLang
|
||||||
|
});
|
||||||
|
|
||||||
|
//Mount app
|
||||||
|
const oApp = createApp(App);
|
||||||
|
oApp.provide('appConfig', appConfig);
|
||||||
|
oApp.provide('api', oApi);
|
||||||
|
oApp.provide('lang', oLang);
|
||||||
|
oApp.provide('projects', oProjects);
|
||||||
|
oApp.provide('user', oUser);
|
||||||
|
oApp.mount('#container');
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
<script>
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import AppButton from '@components/AppButton';
|
||||||
|
import AdminInput from '@components/AdminInput';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon,
|
||||||
|
AppButton,
|
||||||
|
AdminInput
|
||||||
|
},
|
||||||
|
inject: ['api', 'lang', 'getPrevAnchor'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
elems: {},
|
||||||
|
feedbacks: [],
|
||||||
|
saveTimer: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if(this.saveTimer) clearTimeout(this.saveTimer);
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setProjects();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
l(sLangId, asLangParams=[]) {
|
||||||
|
return this.lang.get(sLangId, asLangParams);
|
||||||
|
},
|
||||||
|
addFeedback(sType, sMsg, asContext = {}) {
|
||||||
|
delete asContext.a;
|
||||||
|
delete asContext.t;
|
||||||
|
sMsg += ' (';
|
||||||
|
for(const [sKey, sElem] of Object.entries(asContext)) {
|
||||||
|
sMsg += sKey+'='+sElem+' / ' ;
|
||||||
|
}
|
||||||
|
sMsg = sMsg.slice(0, -3)+')';
|
||||||
|
|
||||||
|
this.feedbacks.push({type:sType, msg:sMsg});
|
||||||
|
},
|
||||||
|
async setProjects() {
|
||||||
|
let aoElemTypes = await this.api.get('admin_get');
|
||||||
|
|
||||||
|
for(const [sType, aoElems] of Object.entries(aoElemTypes)) {
|
||||||
|
this.elems[sType] = {};
|
||||||
|
for(const oElem of Object.values(aoElems)) {
|
||||||
|
oElem.type = sType;
|
||||||
|
this.elems[sType][oElem.id] = oElem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createElem(sType) {
|
||||||
|
this.api.post('admin_create', {type: sType})
|
||||||
|
.then((aoNewElemTypes) => {
|
||||||
|
for(const [sType, aoNewElems] of Object.entries(aoNewElemTypes)) {
|
||||||
|
for(const oNewElem of Object.values(aoNewElems)) {
|
||||||
|
oNewElem.type = sType;
|
||||||
|
this.elems[sType][oNewElem.id] = oNewElem;
|
||||||
|
this.addFeedback('success', this.l('admin.create_success'), {'create':sType});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((oError) => {this.addFeedback('error', oError.desc_lang_text, {'create':sType});});
|
||||||
|
},
|
||||||
|
updateElem(oElem, oEvent) {
|
||||||
|
if(this.saveTimer) clearTimeout(this.saveTimer);
|
||||||
|
|
||||||
|
let sOldVal = this.elems[oElem.type][oElem.id][oEvent.target.name];
|
||||||
|
let sNewVal = oEvent.target.value;
|
||||||
|
if(sOldVal != sNewVal) {
|
||||||
|
let asInputs = {
|
||||||
|
type: oElem.type,
|
||||||
|
id: oElem.id,
|
||||||
|
field: oEvent.target.name,
|
||||||
|
value: sNewVal
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api.request('admin_set', asInputs, 'POST')
|
||||||
|
.then((oResponse) => {
|
||||||
|
this.elems[oElem.type][oElem.id][oEvent.target.name] = sNewVal;
|
||||||
|
const bSuccess = (oResponse.desc_lang_id == '');
|
||||||
|
const sType = bSuccess?'success':'warning';
|
||||||
|
const sText = this.l(bSuccess?'admin.save_success':oResponse.desc_lang_id, oResponse.desc_lang_params);
|
||||||
|
this.addFeedback(sType, sText, asInputs);
|
||||||
|
})
|
||||||
|
.catch((oError) => {
|
||||||
|
oEvent.target.value = sOldVal;
|
||||||
|
this.addFeedback('error', oError.desc_lang_text, asInputs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deleteElem(oElem) {
|
||||||
|
const asInputs = {
|
||||||
|
type: oElem.type,
|
||||||
|
id: oElem.id
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api.post('admin_delete', asInputs)
|
||||||
|
.then(() => {
|
||||||
|
delete this.elems[asInputs.type][asInputs.id];
|
||||||
|
this.addFeedback('success', this.l('admin.delete_success'), asInputs);
|
||||||
|
})
|
||||||
|
.catch((oError) => {
|
||||||
|
this.addFeedback('error', oError.desc_lang_text, asInputs);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
queue(oElem, oEvent) {
|
||||||
|
if(this.saveTimer) clearTimeout(this.saveTimer);
|
||||||
|
this.saveTimer = setTimeout(() => {this.updateElem(oElem, oEvent);}, 2000);
|
||||||
|
},
|
||||||
|
updateProject() {
|
||||||
|
this.api.request('update_project', {}, 'POST')
|
||||||
|
.then((oResponse) => {this.addFeedback('success', oResponse.desc_lang_text, {'update':'project'});})
|
||||||
|
.catch((oError) => {this.addFeedback('error', oError.desc_lang_text, {'update':'project'});});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div id="admin">
|
||||||
|
<a name="back" class="button" :href="getPrevAnchor()"><AppIcon :icon="'back'" :text="l('action.back')" /></a>
|
||||||
|
<h1>{{ l('project.plural') }}</h1>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ l('project.id') }}</th>
|
||||||
|
<th>{{ l('project.single') }}</th>
|
||||||
|
<th>{{ l('project.mode') }}</th>
|
||||||
|
<th>{{ l('project.code_name') }}</th>
|
||||||
|
<th>{{ l('project.start') }}</th>
|
||||||
|
<th>{{ l('project.end') }}</th>
|
||||||
|
<th>{{ l('action.delete') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="project in elems.project" :key="project.id">
|
||||||
|
<td>{{ project.id }}</td>
|
||||||
|
<td><AdminInput :type="'text'" :name="'name'" :elem="project" /></td>
|
||||||
|
<td>{{ project.mode }}</td>
|
||||||
|
<td><AdminInput :type="'text'" :name="'codename'" :elem="project" /></td>
|
||||||
|
<td><AdminInput :type="'date'" :name="'active_from'" :elem="project" /></td>
|
||||||
|
<td><AdminInput :type="'date'" :name="'active_to'" :elem="project" /></td>
|
||||||
|
<td><AppButton :icon="'close'" iconSize="lg" @click="deleteElem(project)" /></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<AppButton :classes="'new'" :text="l('project.new')" :icon="'new'" @click="createElem('project')" />
|
||||||
|
</div>
|
||||||
|
<h1>{{ l('feed.plural') }}</h1>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ l('feed.id') }}</th>
|
||||||
|
<th>{{ l('feed.ref_id') }}</th>
|
||||||
|
<th>{{ l('spot.id') }}</th>
|
||||||
|
<th>{{ l('project.id') }}</th>
|
||||||
|
<th>{{ l('feed.name') }}</th>
|
||||||
|
<th>{{ l('feed.status') }}</th>
|
||||||
|
<th>{{ l('feed.last_update') }}</th>
|
||||||
|
<th>{{ l('action.delete') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="feed in elems.feed" :key="feed.id">
|
||||||
|
<td>{{ feed.id }}</td>
|
||||||
|
<td><AdminInput :type="'text'" :name="'ref_feed_id'" :elem="feed" /></td>
|
||||||
|
<td><AdminInput :type="'number'" :name="'id_spot'" :elem="feed" /></td>
|
||||||
|
<td><AdminInput :type="'number'" :name="'id_project'" :elem="feed" /></td>
|
||||||
|
<td>{{ feed.name }}</td>
|
||||||
|
<td>{{ feed.status }}</td>
|
||||||
|
<td>{{ feed.last_update }}</td>
|
||||||
|
<td><AppButton :icon="'close'" iconSize="lg" @click="deleteElem(feed)" /></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<AppButton :classes="'new'" :text="l('feed.new')" :icon="'new'" @click="createElem('feed')" />
|
||||||
|
</div>
|
||||||
|
<h1>{{ l('spot.plural') }}</h1>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ l('spot.id') }}</th>
|
||||||
|
<th>{{ l('spot.ref_id') }}</th>
|
||||||
|
<th>{{ l('spot.name') }}</th>
|
||||||
|
<th>{{ l('spot.model') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="spot in elems.spot" :key="spot.id">
|
||||||
|
<td>{{ spot.id }}</td>
|
||||||
|
<td>{{ spot.ref_spot_id }}</td>
|
||||||
|
<td>{{ spot.name }}</td>
|
||||||
|
<td>{{ spot.model }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h1>{{ l('user.subscribed') }}</h1>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ l('user.id') }}</th>
|
||||||
|
<th>{{ l('user.name') }}</th>
|
||||||
|
<th>{{ l('user.email') }}</th>
|
||||||
|
<th>{{ l('user.language') }}</th>
|
||||||
|
<th>{{ l('time.zone') }}</th>
|
||||||
|
<th>{{ l('user.clearance') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="user in elems.user" :key="user.id">
|
||||||
|
<td>{{ user.id }}</td>
|
||||||
|
<td class="left">{{ user.name }}</td>
|
||||||
|
<td class="left">{{ user.email }}</td>
|
||||||
|
<td>{{ user.language }}</td>
|
||||||
|
<td>{{ user.timezone }}</td>
|
||||||
|
<td><AdminInput :type="'number'" :name="'clearance'" :elem="user" /></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h1>{{ l('admin.toolbox') }}</h1>
|
||||||
|
<div id="toolbox">
|
||||||
|
<AppButton :classes="'refresh'" :text="l('project.update_messages')" :icon="'refresh'" @click="updateProject" />
|
||||||
|
</div>
|
||||||
|
<div id="feedback" class="feedback">
|
||||||
|
<p v-for="(feedback, index) in feedbacks" :key="index" :class="feedback.type">{{ feedback.msg }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -10,8 +10,9 @@
|
|||||||
return this.elem[this.name];
|
return this.elem[this.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<input :type="type" :name="name" :value="value" @change="$parent.updateElem(elem, $event)" @keyup="$parent.queue(elem, $event)" />
|
<input :type="type" :name="name" :value="value" @change="$parent.updateElem(elem, $event)" @keyup="$parent.queue(elem, $event)" />
|
||||||
</template>
|
</template>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<script>
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
classes: String,
|
||||||
|
text: String,
|
||||||
|
icon: String,
|
||||||
|
iconClasses: String,
|
||||||
|
iconSize: String
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<button :class="classes"><AppIcon :icon="icon" :text="text" :classes="iconClasses" :size="iconSize" /></button>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<script>
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
|
import { getIcon } from '@scripts/icons';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
FontAwesomeIcon
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
icon: String,
|
||||||
|
width: String,
|
||||||
|
size: String,
|
||||||
|
classes: String,
|
||||||
|
title: String,
|
||||||
|
text: String,
|
||||||
|
margin: String,
|
||||||
|
textClasses: String,
|
||||||
|
transform: String
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
resolvedFixedWidth() {
|
||||||
|
return (this.width == 'fixed') || null;
|
||||||
|
},
|
||||||
|
resolvedAutoWidth() {
|
||||||
|
return (this.width == 'auto') || null;
|
||||||
|
},
|
||||||
|
hasText() {
|
||||||
|
return this.text && this.text != '';
|
||||||
|
},
|
||||||
|
iconDefinition() {
|
||||||
|
return getIcon(this.icon);
|
||||||
|
},
|
||||||
|
resolvedSize() {
|
||||||
|
return this.size || null;
|
||||||
|
},
|
||||||
|
resolvedTransform() {
|
||||||
|
return this.transform || null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span :title="title" :class="hasText?'app-icon-with-text':null">
|
||||||
|
<span class="app-icon-symbol">
|
||||||
|
<FontAwesomeIcon
|
||||||
|
:icon="iconDefinition"
|
||||||
|
:class="['app-icon', this.icon, this.classes, this.margin?'margin-'+this.margin:null]"
|
||||||
|
:fixed-width="resolvedFixedWidth"
|
||||||
|
:width-auto="resolvedAutoWidth"
|
||||||
|
:size="resolvedSize"
|
||||||
|
:transform="resolvedTransform"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span v-if="hasText" :class="['app-icon-text', textClasses]">{{ text }}</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@use "@styles/var";
|
||||||
|
|
||||||
|
.app-icon-with-text {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: var.$text-spacing;
|
||||||
|
|
||||||
|
.app-icon-symbol {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-icon-text {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-icon {
|
||||||
|
&.margin-right {
|
||||||
|
margin-right: var.$text-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.margin-left {
|
||||||
|
margin-left: var.$text-spacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<script>
|
||||||
|
import { FontAwesomeLayers } from '@fortawesome/vue-fontawesome';
|
||||||
|
import appIcon from '@components/AppIcon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
FontAwesomeLayers,
|
||||||
|
appIcon
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
mainClasses: String,
|
||||||
|
iconMain: String,
|
||||||
|
iconMainClasses: String,
|
||||||
|
iconMainTransform: String,
|
||||||
|
iconSub: String,
|
||||||
|
iconSubClasses: String,
|
||||||
|
iconSubTransform: String
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
mainClass() {
|
||||||
|
return 'app-icon-stack clickable'+(this.mainClasses?' '+this.mainClasses:'');
|
||||||
|
},
|
||||||
|
iconMainClass() {
|
||||||
|
return this.mergeClasses('main clickable', this.iconMainClasses);
|
||||||
|
},
|
||||||
|
iconSubClass() {
|
||||||
|
return this.mergeClasses('sub', this.iconSubClasses);
|
||||||
|
},
|
||||||
|
iconSubTransformValue() {
|
||||||
|
return this.mergeClasses('shrink-9 up-2', this.iconSubTransform);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
mergeClasses(sClassesA, sClassesB) {
|
||||||
|
return [
|
||||||
|
...(sClassesA || '').split(/\s+/),
|
||||||
|
...(sClassesB || '').split(/\s+/)
|
||||||
|
].filter(Boolean).join(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span :class="mainClass">
|
||||||
|
<FontAwesomeLayers>
|
||||||
|
<appIcon :icon="iconMain" :classes="iconMainClass" :transform="iconMainTransform" />
|
||||||
|
<appIcon v-if="iconSub" :icon="iconSub" :classes="iconSubClass" :transform="iconSubTransformValue" />
|
||||||
|
</FontAwesomeLayers>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,596 @@
|
|||||||
|
<script>
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import ProjectRelTime from '@components/ProjectRelTime';
|
||||||
|
import { getStyleProperty } from '@scripts/common';
|
||||||
|
|
||||||
|
/* lightbox (https://github.com/lokesh/lightbox2) converted to a vue component and improved to support videos */
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon,
|
||||||
|
ProjectRelTime
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
alwaysShowNavOnTouchDevices: {type: Boolean, default: false},
|
||||||
|
positionFromTop: {type: Number, default: 50},
|
||||||
|
wrapAround: {type: Boolean, default: false},
|
||||||
|
disableScrolling: {type: Boolean, default: false},
|
||||||
|
hasVideo: {type: Boolean, default: true},
|
||||||
|
maxWidth: {type: Number, default: null},
|
||||||
|
maxHeight: {type: Number, default: null}
|
||||||
|
},
|
||||||
|
emits: ['media-change', 'closing'],
|
||||||
|
inject: ['isMobile'],
|
||||||
|
data() {
|
||||||
|
/*
|
||||||
|
fadeDuration/imageFadeDuration/resizeDuration read --trans-quick/--trans-slow
|
||||||
|
directly rather than being passed down as props from Project.vue: they're
|
||||||
|
declared on :root (_common.scss), so they're available immediately.
|
||||||
|
No need to wait on Project.vue's own $el to mount first, and no risk of
|
||||||
|
a parent-to-child prop update lagging behind the first time this opens.
|
||||||
|
*/
|
||||||
|
const fadeDuration = parseFloat(getStyleProperty('--trans-quick'));
|
||||||
|
const resizeDuration = parseFloat(getStyleProperty('--trans-slow'));
|
||||||
|
|
||||||
|
return {
|
||||||
|
album: [],
|
||||||
|
currentImageIndex: 0,
|
||||||
|
gMouseDownOffsetX: 0,
|
||||||
|
gMouseDownOffsetY: 0,
|
||||||
|
resizeTimer: null,
|
||||||
|
containerPadding: null,
|
||||||
|
imageBorderWidth: null,
|
||||||
|
videoBorderWidth: null,
|
||||||
|
fadeDuration,
|
||||||
|
imageFadeDuration: fadeDuration,
|
||||||
|
resizeDuration
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
currentMedia() {
|
||||||
|
return this.album[this.currentImageIndex] || null;
|
||||||
|
},
|
||||||
|
relTimeLines() {
|
||||||
|
const media = this.currentMedia;
|
||||||
|
if(!media || this.isMobile()) return [];
|
||||||
|
|
||||||
|
const postedOn = {
|
||||||
|
key: 'posted',
|
||||||
|
icon: 'upload',
|
||||||
|
titleWrapperLangId: 'media.posted_on',
|
||||||
|
localTime: media.postedOnLocalTime,
|
||||||
|
siteTime: media.postedOnSiteTime,
|
||||||
|
offset: media.postedOnDayOffset
|
||||||
|
};
|
||||||
|
const takenOn = {
|
||||||
|
key: 'taken',
|
||||||
|
icon: media.type+'-shot',
|
||||||
|
titleWrapperLangId: 'media.'+media.type+'_taken_on',
|
||||||
|
localTime: media.takenOnLocalTime,
|
||||||
|
siteTime: media.takenOnSiteTime,
|
||||||
|
offset: media.takenOnDayOffset
|
||||||
|
};
|
||||||
|
return (media.source == 'marker') ? [takenOn, postedOn] : [postedOn, takenOn];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setVisible(this.$refs.overlay, false);
|
||||||
|
this.setVisible(this.$refs.lightboxEl, false);
|
||||||
|
|
||||||
|
this.containerPadding = this.getBoxMetrics(this.$refs.container, 'padding');
|
||||||
|
this.imageBorderWidth = this.getBoxMetrics(this.$refs.image, 'border');
|
||||||
|
this.videoBorderWidth = this.getBoxMetrics(this.$refs.video, 'border');
|
||||||
|
|
||||||
|
this.$refs.nav.addEventListener('wheel', this.onWheel, {passive: false});
|
||||||
|
this.$refs.nav.addEventListener('mousedown', this.onDragStart);
|
||||||
|
window.addEventListener('mouseup', this.onDragEnd);
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if(this.resizeTimer) clearTimeout(this.resizeTimer);
|
||||||
|
window.removeEventListener('mouseup', this.onDragEnd);
|
||||||
|
window.removeEventListener('resize', this.sizeOverlay);
|
||||||
|
window.removeEventListener('mousemove', this.onDragMove);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
open(album, startId, source) {
|
||||||
|
this.sizeOverlay();
|
||||||
|
this.album = album.map((options) => this.mapMedia(options, source));
|
||||||
|
const startIndex = Math.max(this.album.findIndex((media) => media.id == startId), 0);
|
||||||
|
|
||||||
|
this.fade(this.$refs.overlay, true, this.fadeDuration);
|
||||||
|
this.fade(this.$refs.lightboxEl, true, this.fadeDuration);
|
||||||
|
|
||||||
|
if(this.disableScrolling) document.body.classList.add('lb-disable-scrolling');
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.sizeOverlay);
|
||||||
|
this.changeImage(startIndex);
|
||||||
|
},
|
||||||
|
end(dispose = false) {
|
||||||
|
this.disableKeyboardNav();
|
||||||
|
this.$refs.video?.pause();
|
||||||
|
this.$refs.video?.removeAttribute('src');
|
||||||
|
this.$refs.container?.classList.remove('lb-video-nav', 'moveable', 'moving');
|
||||||
|
window.removeEventListener('resize', this.sizeOverlay);
|
||||||
|
window.removeEventListener('mousemove', this.onDragMove);
|
||||||
|
|
||||||
|
if(dispose) {
|
||||||
|
this.album = [];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.fade(this.$refs.lightboxEl, false, this.fadeDuration);
|
||||||
|
this.fade(this.$refs.overlay, false, this.fadeDuration);
|
||||||
|
this.$emit('closing');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.disableScrolling) document.body.classList.remove('lb-disable-scrolling');
|
||||||
|
},
|
||||||
|
mapMedia(options, source) {
|
||||||
|
return {
|
||||||
|
alt: '',
|
||||||
|
link: options.media_path,
|
||||||
|
orientation: parseInt(options.rotate || '0', 10),
|
||||||
|
type: options.subtype || 'image',
|
||||||
|
id: options.id_media,
|
||||||
|
width: parseInt(options.width || '0', 10),
|
||||||
|
height: parseInt(options.height || '0', 10),
|
||||||
|
source,
|
||||||
|
comment: options.comment || '',
|
||||||
|
postedOnLocalTime: options.posted_on_formatted_time_local || '',
|
||||||
|
postedOnSiteTime: options.posted_on_formatted_time || '',
|
||||||
|
postedOnDayOffset: options.posted_on_day_offset || '',
|
||||||
|
takenOnLocalTime: options.taken_on_formatted_time_local || '',
|
||||||
|
takenOnSiteTime: options.taken_on_formatted_time || '',
|
||||||
|
takenOnDayOffset: options.taken_on_day_offset || ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
hasMediaAfterCurrent() {
|
||||||
|
return this.currentImageIndex < this.album.length - 1;
|
||||||
|
},
|
||||||
|
refreshAlbum(album) {
|
||||||
|
const current = this.currentMedia;
|
||||||
|
if(!current) return;
|
||||||
|
|
||||||
|
const existingIds = new Set(this.album.map((media) => media.id));
|
||||||
|
album.forEach((options) => {
|
||||||
|
if(existingIds.has(options.id_media)) return;
|
||||||
|
|
||||||
|
this.album.push(this.mapMedia(options, current.source));
|
||||||
|
existingIds.add(options.id_media);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.updateNav();
|
||||||
|
},
|
||||||
|
getMaxSizes(mediaType) {
|
||||||
|
let maxWidth = window.innerWidth - this.containerPadding.left - this.containerPadding.right;
|
||||||
|
let maxHeight = window.innerHeight - this.containerPadding.top - this.containerPadding.bottom - this.positionFromTop;
|
||||||
|
const border = mediaType === 'image' ? this.imageBorderWidth : this.videoBorderWidth;
|
||||||
|
maxWidth -= border.left + border.right;
|
||||||
|
maxHeight -= border.top + border.bottom;
|
||||||
|
maxHeight -= this.getDataContainerHeight(maxWidth + this.containerPadding.left + this.containerPadding.right + border.left + border.right);
|
||||||
|
|
||||||
|
return {
|
||||||
|
maxWidth: Math.max(maxWidth, 1),
|
||||||
|
maxHeight: Math.max(maxHeight, 1)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getDataContainerHeight(width = null) {
|
||||||
|
if(!this.$refs.dataContainer) return 0;
|
||||||
|
|
||||||
|
const currentWidth = this.$refs.dataContainer.style.width;
|
||||||
|
if(width !== null) this.$refs.dataContainer.style.width = `${width}px`;
|
||||||
|
const height = Math.ceil(this.$refs.dataContainer.getBoundingClientRect().height || this.$refs.dataContainer.offsetHeight || 0);
|
||||||
|
this.$refs.dataContainer.style.width = currentWidth;
|
||||||
|
|
||||||
|
return height;
|
||||||
|
},
|
||||||
|
getMediaSize(media, maxWidth, maxHeight) {
|
||||||
|
if(media.width <= maxWidth && media.height <= maxHeight) {
|
||||||
|
return {
|
||||||
|
width: media.width,
|
||||||
|
height: media.height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const widthRatio = media.width / maxWidth;
|
||||||
|
const heightRatio = media.height / maxHeight;
|
||||||
|
|
||||||
|
if(widthRatio > heightRatio) {
|
||||||
|
return {
|
||||||
|
width: maxWidth,
|
||||||
|
height: Math.round(media.height / widthRatio)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
width: Math.round(media.width / heightRatio),
|
||||||
|
height: maxHeight
|
||||||
|
};
|
||||||
|
},
|
||||||
|
fitSizeWithDataContainer(size, mediaType) {
|
||||||
|
const border = mediaType === 'image' ? this.imageBorderWidth : this.videoBorderWidth;
|
||||||
|
const maxOuterHeight = Math.max(window.innerHeight - this.positionFromTop, 1);
|
||||||
|
let fittedSize = size;
|
||||||
|
|
||||||
|
for(let i = 0; i < 5; i++) {
|
||||||
|
const containerWidth = fittedSize.width + this.containerPadding.left + this.containerPadding.right + border.left + border.right;
|
||||||
|
const containerHeight = fittedSize.height + this.containerPadding.top + this.containerPadding.bottom + border.top + border.bottom;
|
||||||
|
const dataHeight = this.getDataContainerHeight(containerWidth);
|
||||||
|
const overflow = Math.ceil(containerHeight + dataHeight - maxOuterHeight);
|
||||||
|
if(overflow <= 0 || fittedSize.height <= 1) break;
|
||||||
|
|
||||||
|
const height = Math.max(fittedSize.height - overflow, 1);
|
||||||
|
fittedSize = {
|
||||||
|
width: Math.max(Math.round(fittedSize.width * (height / fittedSize.height)), 1),
|
||||||
|
height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return fittedSize;
|
||||||
|
},
|
||||||
|
updateSize(index) {
|
||||||
|
const media = this.album[index];
|
||||||
|
const maxSizes = this.getMaxSizes(media.type);
|
||||||
|
const maxWidth = this.maxWidth ? Math.min(this.maxWidth, maxSizes.maxWidth) : maxSizes.maxWidth;
|
||||||
|
const maxHeight = this.maxHeight ? Math.min(this.maxHeight, maxSizes.maxHeight) : maxSizes.maxHeight;
|
||||||
|
const size = this.fitSizeWithDataContainer(this.getMediaSize(media, maxWidth, maxHeight), media.type);
|
||||||
|
|
||||||
|
const target = media.type === 'video' ? this.$refs.video : this.$refs.image;
|
||||||
|
target.width = size.width;
|
||||||
|
target.height = size.height;
|
||||||
|
this.sizeContainer(size.width, size.height, media.type);
|
||||||
|
},
|
||||||
|
changeImage(index) {
|
||||||
|
const media = this.album[index];
|
||||||
|
if(!media) return;
|
||||||
|
|
||||||
|
this.updateDetails(media, false);
|
||||||
|
this.hideElements([this.$refs.dataContainer]);
|
||||||
|
this.disableKeyboardNav();
|
||||||
|
this.fade(this.$refs.overlay, true, this.fadeDuration);
|
||||||
|
this.fade(this.$refs.loader, true, 200);
|
||||||
|
this.hideElements([this.$refs.image, this.$refs.video, this.$refs.nav, this.$refs.prev, this.$refs.next]);
|
||||||
|
this.resetImageTransform();
|
||||||
|
this.$refs.outerContainer.classList.add('animating');
|
||||||
|
this.$refs.container.classList.remove('moveable', 'moving', 'lb-video-nav');
|
||||||
|
this.currentImageIndex = index;
|
||||||
|
|
||||||
|
this.$emit('media-change', media);
|
||||||
|
|
||||||
|
if(media.type === 'video') {
|
||||||
|
this.$refs.image.removeAttribute('src');
|
||||||
|
this.$refs.container.classList.add('lb-video-nav');
|
||||||
|
this.$refs.video.onloadedmetadata = () => {
|
||||||
|
media.width = this.$refs.video.videoWidth;
|
||||||
|
media.height = this.$refs.video.videoHeight;
|
||||||
|
this.$refs.video.onloadedmetadata = null;
|
||||||
|
this.updateSize(index);
|
||||||
|
};
|
||||||
|
this.$refs.video.src = media.link;
|
||||||
|
} else {
|
||||||
|
this.$refs.video.pause();
|
||||||
|
this.$refs.video.removeAttribute('src');
|
||||||
|
this.$refs.image.onload = () => {
|
||||||
|
this.$refs.image.alt = media.alt;
|
||||||
|
let width = this.$refs.image.naturalWidth;
|
||||||
|
let height = this.$refs.image.naturalHeight;
|
||||||
|
if(Math.abs(media.orientation) === 90 && width > height) {
|
||||||
|
const tmp = width;
|
||||||
|
width = height;
|
||||||
|
height = tmp;
|
||||||
|
}
|
||||||
|
media.width = width;
|
||||||
|
media.height = height;
|
||||||
|
this.$refs.image.onload = null;
|
||||||
|
this.updateSize(index);
|
||||||
|
};
|
||||||
|
this.$refs.image.src = media.link;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sizeOverlay() {
|
||||||
|
if(this.resizeTimer) clearTimeout(this.resizeTimer);
|
||||||
|
if(!this.album.length) return;
|
||||||
|
|
||||||
|
this.resizeTimer = window.setTimeout(() => {
|
||||||
|
const current = this.album[this.currentImageIndex];
|
||||||
|
if(!current) return;
|
||||||
|
if(current.type === 'image') this.changeImage(this.currentImageIndex);
|
||||||
|
else this.updateSize(this.currentImageIndex);
|
||||||
|
}, 200);
|
||||||
|
},
|
||||||
|
sizeContainer(width, height, mediaType = 'image') {
|
||||||
|
const border = mediaType === 'image' ? this.imageBorderWidth : this.videoBorderWidth;
|
||||||
|
const newWidth = width + this.containerPadding.left + this.containerPadding.right + border.left + border.right;
|
||||||
|
const newHeight = height + this.containerPadding.top + this.containerPadding.bottom + border.top + border.bottom;
|
||||||
|
const dataHeight = this.getDataContainerHeight(newWidth);
|
||||||
|
|
||||||
|
this.$refs.outerContainer.style.transition = `width ${this.resizeDuration}ms, height ${this.resizeDuration}ms`;
|
||||||
|
this.$refs.outerContainer.style.width = `${newWidth}px`;
|
||||||
|
this.$refs.outerContainer.style.height = `${newHeight + dataHeight}px`;
|
||||||
|
this.$refs.container.style.height = `${newHeight}px`;
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.$refs.overlay.focus();
|
||||||
|
this.showImage();
|
||||||
|
this.$refs.outerContainer.style.transition = '';
|
||||||
|
}, this.resizeDuration);
|
||||||
|
},
|
||||||
|
showImage() {
|
||||||
|
this.fade(this.$refs.loader, false, 0);
|
||||||
|
if(this.hasVideo && this.album[this.currentImageIndex].type === 'video') this.fade(this.$refs.video, true, this.imageFadeDuration);
|
||||||
|
else this.fade(this.$refs.image, true, this.imageFadeDuration);
|
||||||
|
|
||||||
|
this.updateNav();
|
||||||
|
this.updateDetails();
|
||||||
|
this.preloadNeighboringImages();
|
||||||
|
this.enableKeyboardNav();
|
||||||
|
},
|
||||||
|
updateNav() {
|
||||||
|
this.setVisible(this.$refs.nav, true);
|
||||||
|
this.setVisible(this.$refs.prev, false);
|
||||||
|
this.setVisible(this.$refs.next, false);
|
||||||
|
|
||||||
|
const alwaysShowNav = ('ontouchstart' in window) && this.alwaysShowNavOnTouchDevices;
|
||||||
|
if(this.album.length <= 1) return;
|
||||||
|
|
||||||
|
if(this.wrapAround) {
|
||||||
|
this.setVisible(this.$refs.prev, true);
|
||||||
|
this.setVisible(this.$refs.next, true);
|
||||||
|
} else {
|
||||||
|
if(this.currentImageIndex > 0) this.setVisible(this.$refs.prev, true);
|
||||||
|
if(this.currentImageIndex < this.album.length - 1) this.setVisible(this.$refs.next, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(alwaysShowNav) {
|
||||||
|
this.$refs.prev.style.opacity = '1';
|
||||||
|
this.$refs.next.style.opacity = '1';
|
||||||
|
} else {
|
||||||
|
this.$refs.prev.style.opacity = '';
|
||||||
|
this.$refs.next.style.opacity = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hasCaption(media) {
|
||||||
|
return !!(media && (media.comment || media.postedOnSiteTime || media.takenOnSiteTime));
|
||||||
|
},
|
||||||
|
updateDetails(media = this.album[this.currentImageIndex], show = true) {
|
||||||
|
if(!media) return;
|
||||||
|
|
||||||
|
if(this.hasCaption(media)) {
|
||||||
|
if(show) this.fade(this.$refs.caption, true, 200);
|
||||||
|
else this.setVisible(this.$refs.caption, true);
|
||||||
|
} else {
|
||||||
|
this.setVisible(this.$refs.caption, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(show) {
|
||||||
|
this.fade(this.$refs.closeButton, true, 200);
|
||||||
|
this.$refs.outerContainer.classList.remove('animating');
|
||||||
|
this.fade(this.$refs.dataContainer, true, this.resizeDuration);
|
||||||
|
} else {
|
||||||
|
this.setVisible(this.$refs.closeButton, true);
|
||||||
|
this.setVisible(this.$refs.dataContainer, false);
|
||||||
|
this.$refs.dataContainer.style.transition = '';
|
||||||
|
this.$refs.dataContainer.style.opacity = '0';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preloadNeighboringImages() {
|
||||||
|
const next = this.album[this.currentImageIndex + 1];
|
||||||
|
const prev = this.album[this.currentImageIndex - 1];
|
||||||
|
if(next && next.type === 'image') {
|
||||||
|
const preloadNext = new Image();
|
||||||
|
preloadNext.src = next.link;
|
||||||
|
}
|
||||||
|
if(prev && prev.type === 'image') {
|
||||||
|
const preloadPrev = new Image();
|
||||||
|
preloadPrev.src = prev.link;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enableKeyboardNav() {
|
||||||
|
this.disableKeyboardNav();
|
||||||
|
this.$refs.lightboxEl.addEventListener('keyup', this.keyboardAction);
|
||||||
|
this.$refs.overlay.addEventListener('keyup', this.keyboardAction);
|
||||||
|
},
|
||||||
|
disableKeyboardNav() {
|
||||||
|
this.$refs.lightboxEl?.removeEventListener('keyup', this.keyboardAction);
|
||||||
|
this.$refs.overlay?.removeEventListener('keyup', this.keyboardAction);
|
||||||
|
},
|
||||||
|
keyboardAction(event) {
|
||||||
|
switch(event.key) {
|
||||||
|
case 'Escape':
|
||||||
|
event.stopPropagation();
|
||||||
|
this.end();
|
||||||
|
break;
|
||||||
|
case 'ArrowLeft':
|
||||||
|
if(this.currentImageIndex !== 0) this.changeImage(this.currentImageIndex - 1);
|
||||||
|
else if(this.wrapAround && this.album.length > 1) this.changeImage(this.album.length - 1);
|
||||||
|
break;
|
||||||
|
case 'ArrowRight':
|
||||||
|
if(this.currentImageIndex !== this.album.length - 1) this.changeImage(this.currentImageIndex + 1);
|
||||||
|
else if(this.wrapAround && this.album.length > 1) this.changeImage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCloseKeyup(event) {
|
||||||
|
if(event.key === 'Enter' || event.key === ' ') this.end();
|
||||||
|
},
|
||||||
|
onPrevClick() {
|
||||||
|
if(this.currentImageIndex === 0) this.changeImage(this.album.length - 1);
|
||||||
|
else this.changeImage(this.currentImageIndex - 1);
|
||||||
|
},
|
||||||
|
onNextClick() {
|
||||||
|
if(this.currentImageIndex === this.album.length - 1) this.changeImage(0);
|
||||||
|
else this.changeImage(this.currentImageIndex + 1);
|
||||||
|
},
|
||||||
|
onOuterContainerClick(event) {
|
||||||
|
if(event.target === this.$refs.outerContainer) this.end();
|
||||||
|
},
|
||||||
|
onLightboxClick(event) {
|
||||||
|
if(event.target === this.$refs.lightboxEl) this.end();
|
||||||
|
},
|
||||||
|
onWheel(event) {
|
||||||
|
const media = this.album[this.currentImageIndex];
|
||||||
|
if(!media || media.type === 'video') return;
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const rect = this.$refs.image.getBoundingClientRect();
|
||||||
|
const oldTransform = this.getImageTransform();
|
||||||
|
const oldZoom = oldTransform.scale;
|
||||||
|
const maxZoom = Math.max(media.width / Math.max(this.$refs.image.width, 1), media.height / Math.max(this.$refs.image.height, 1), 1);
|
||||||
|
const newZoom = Math.min(Math.max(oldZoom + (-Math.sign(event.deltaY) / 10), 1), maxZoom);
|
||||||
|
|
||||||
|
const imageCenterX = rect.left + rect.width / 2 - oldTransform.translateX;
|
||||||
|
const imageCenterY = rect.top + rect.height / 2 - oldTransform.translateY;
|
||||||
|
const cursorX = event.clientX - imageCenterX;
|
||||||
|
const cursorY = event.clientY - imageCenterY;
|
||||||
|
const zoomRatio = newZoom / oldZoom;
|
||||||
|
const transform = this.clampImageTransform({
|
||||||
|
scale: newZoom,
|
||||||
|
translateX: cursorX - zoomRatio * (cursorX - oldTransform.translateX),
|
||||||
|
translateY: cursorY - zoomRatio * (cursorY - oldTransform.translateY)
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$refs.container.classList.toggle('moveable', newZoom > 1);
|
||||||
|
this.setImageTransform(transform);
|
||||||
|
},
|
||||||
|
onDragStart(event) {
|
||||||
|
const scale = parseFloat(this.$refs.image.style.getPropertyValue('--scale') || '1');
|
||||||
|
if(scale <= 1) return;
|
||||||
|
|
||||||
|
this.gMouseDownOffsetX = event.clientX - parseFloat(this.$refs.image.style.getPropertyValue('--translate-x') || '0');
|
||||||
|
this.gMouseDownOffsetY = event.clientY - parseFloat(this.$refs.image.style.getPropertyValue('--translate-y') || '0');
|
||||||
|
this.$refs.container.classList.add('moving');
|
||||||
|
window.addEventListener('mousemove', this.onDragMove);
|
||||||
|
},
|
||||||
|
onDragMove(event) {
|
||||||
|
const zoom = parseFloat(this.$refs.image.style.getPropertyValue('--scale') || '1');
|
||||||
|
const transform = this.clampImageTransform({
|
||||||
|
scale: zoom,
|
||||||
|
translateX: event.clientX - this.gMouseDownOffsetX,
|
||||||
|
translateY: event.clientY - this.gMouseDownOffsetY
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setImageTransform(transform);
|
||||||
|
},
|
||||||
|
onDragEnd() {
|
||||||
|
window.removeEventListener('mousemove', this.onDragMove);
|
||||||
|
this.$refs.container?.classList.remove('moving');
|
||||||
|
},
|
||||||
|
getBoxMetrics(element, type) {
|
||||||
|
const styles = getComputedStyle(element);
|
||||||
|
return {
|
||||||
|
top: parseInt(styles[`${type}-top-width`], 10) || 0,
|
||||||
|
right: parseInt(styles[`${type}-right-width`], 10) || 0,
|
||||||
|
bottom: parseInt(styles[`${type}-bottom-width`], 10) || 0,
|
||||||
|
left: parseInt(styles[`${type}-left-width`], 10) || 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
resetImageTransform() {
|
||||||
|
this.setImageTransform({scale: 1, translateX: 0, translateY: 0});
|
||||||
|
},
|
||||||
|
getImageTransform() {
|
||||||
|
return {
|
||||||
|
scale: parseFloat(this.$refs.image.style.getPropertyValue('--scale') || '1'),
|
||||||
|
translateX: parseFloat(this.$refs.image.style.getPropertyValue('--translate-x') || '0'),
|
||||||
|
translateY: parseFloat(this.$refs.image.style.getPropertyValue('--translate-y') || '0')
|
||||||
|
};
|
||||||
|
},
|
||||||
|
clampImageTransform(transform) {
|
||||||
|
const maxTranslateX = (transform.scale - 1) * this.$refs.image.width / 2;
|
||||||
|
const maxTranslateY = (transform.scale - 1) * this.$refs.image.height / 2;
|
||||||
|
|
||||||
|
return {
|
||||||
|
scale: transform.scale,
|
||||||
|
translateX: Math.max(Math.min(transform.translateX, maxTranslateX), -maxTranslateX),
|
||||||
|
translateY: Math.max(Math.min(transform.translateY, maxTranslateY), -maxTranslateY)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
setImageTransform(transform) {
|
||||||
|
if(!this.$refs.image) return;
|
||||||
|
this.$refs.image.style.setProperty('--scale', String(transform.scale));
|
||||||
|
this.$refs.image.style.setProperty('--translate-x', `${transform.translateX}px`);
|
||||||
|
this.$refs.image.style.setProperty('--translate-y', `${transform.translateY}px`);
|
||||||
|
},
|
||||||
|
hideElements(elements) {
|
||||||
|
elements.forEach((element) => {
|
||||||
|
this.setVisible(element, false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setVisible(element, visible) {
|
||||||
|
if(!element) return;
|
||||||
|
element.style.visibility = visible ? 'visible' : 'hidden';
|
||||||
|
element.style.pointerEvents = visible ? '' : 'none';
|
||||||
|
},
|
||||||
|
fade(element, show, duration, done) {
|
||||||
|
if(!element) return;
|
||||||
|
|
||||||
|
const safeDuration = duration || 0;
|
||||||
|
element.style.transition = `opacity ${safeDuration}ms`;
|
||||||
|
if(show) {
|
||||||
|
this.setVisible(element, true);
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
element.style.opacity = element === this.$refs.overlay ? '0.8' : '1';
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
element.style.opacity = '0';
|
||||||
|
element.style.pointerEvents = 'none';
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.setVisible(element, false);
|
||||||
|
}, safeDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof done === 'function') {
|
||||||
|
window.setTimeout(done, safeDuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div id="lightboxOverlay" ref="overlay" tabindex="-1" class="lightboxOverlay" @click="end()"></div>
|
||||||
|
<div id="lightbox" ref="lightboxEl" tabindex="-1" class="lightbox" @click="onLightboxClick">
|
||||||
|
<div class="lb-outerContainer" ref="outerContainer" @click.stop="onOuterContainerClick">
|
||||||
|
<div class="lb-container" ref="container">
|
||||||
|
<img class="lb-image" ref="image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt="" />
|
||||||
|
<video class="lb-video" ref="video" controls autoplay></video>
|
||||||
|
<div class="lb-nav" ref="nav">
|
||||||
|
<div class="lb-prev-area">
|
||||||
|
<a class="lb-prev" ref="prev" aria-label="Previous image" href="" role="button" @click.prevent="onPrevClick">
|
||||||
|
<AppIcon :icon="'prev'" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="lb-next-area">
|
||||||
|
<a class="lb-next" ref="next" aria-label="Next image" href="" role="button" @click.prevent="onNextClick"><AppIcon :icon="'next'" /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="lb-loader" ref="loader" @click.prevent="end()">
|
||||||
|
<a class="lb-cancel" ref="cancel" href="#">
|
||||||
|
<AppIcon :icon="'cancel'" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="lb-dataContainer" ref="dataContainer" @click="end()">
|
||||||
|
<div class="lb-data">
|
||||||
|
<div class="lb-details">
|
||||||
|
<span class="lb-caption" ref="caption">
|
||||||
|
<template v-if="hasCaption(currentMedia)">
|
||||||
|
<span v-if="!!currentMedia?.comment" class="lb-caption-line comment">
|
||||||
|
<AppIcon icon="post" width="fixed" size="lg" text-classes="comment-text" :text="currentMedia.comment" />
|
||||||
|
</span>
|
||||||
|
<span v-for="line in relTimeLines" :key="line.key" class="lb-caption-line">
|
||||||
|
<ProjectRelTime :icon="line.icon" :titleWrapperLangId="line.titleWrapperLangId" :localTime="line.localTime" :siteTime="line.siteTime" :offset="line.offset" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="lb-closeContainer">
|
||||||
|
<a class="lb-close" ref="closeButton" href="#" role="button" @click.prevent.stop="end()" @keyup="onCloseKeyup">
|
||||||
|
<AppIcon :icon="'close'" :classes="'fa-lg'" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
<script>
|
||||||
|
import Lightbox from '@components/Lightbox';
|
||||||
|
import ProjectMap, { BASE_MAP_PADDING } from '@components/ProjectMap';
|
||||||
|
import { getStyleProperty } from '@scripts/common';
|
||||||
|
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import ProjectFeed from '@components/ProjectFeed';
|
||||||
|
import ProjectSettings from '@components/ProjectSettings';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon,
|
||||||
|
ProjectFeed,
|
||||||
|
ProjectSettings,
|
||||||
|
ProjectMap,
|
||||||
|
Lightbox
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
panels: {
|
||||||
|
leftOpen: false,
|
||||||
|
rightOpen: false
|
||||||
|
},
|
||||||
|
feed: null,
|
||||||
|
settings: null,
|
||||||
|
project: null,
|
||||||
|
modeHisto: null,
|
||||||
|
baseMaps: [],
|
||||||
|
baseMap: null,
|
||||||
|
terrainEnabled: false,
|
||||||
|
mapInitializing: false,
|
||||||
|
hikes: {
|
||||||
|
colors: {},
|
||||||
|
width: null,
|
||||||
|
transitions: {
|
||||||
|
lineWidthTransition: {duration:null}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
overview: {
|
||||||
|
id: 0,
|
||||||
|
codename: 'overview',
|
||||||
|
name: this.lang.get('project.overview')
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
projectOptions() {
|
||||||
|
return [
|
||||||
|
this.overview,
|
||||||
|
...Object.values(this.projects)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'hash.items.0'(newProjectCodename, oldProjectCodename) { //hash.items.0 = Project Code Name
|
||||||
|
if(newProjectCodename != oldProjectCodename) {
|
||||||
|
this.hash.items = [newProjectCodename]; //Force removal of direct link
|
||||||
|
this.settings.toggle(false, 0);
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
map: {
|
||||||
|
panToBetweenPanels: this.panToBetweenPanels,
|
||||||
|
openMarkerPopup: (iMarkerId, sMarkerType) => this.$refs.mapCtrl.openMarkerPopup(iMarkerId, sMarkerType),
|
||||||
|
closePopup: () => this.$refs.mapCtrl.closePopup(),
|
||||||
|
isMarkerVisible: (oLngLat) => this.$refs.mapCtrl.isMarkerVisible(oLngLat),
|
||||||
|
findMarkerByMediaId: (iMediaId) => this.$refs.mapCtrl.findMarkerByMediaId(iMediaId)
|
||||||
|
},
|
||||||
|
lightbox: {
|
||||||
|
open: (iMediaId, sSource) => this.openLightbox(iMediaId, sSource)
|
||||||
|
},
|
||||||
|
project: this
|
||||||
|
};
|
||||||
|
},
|
||||||
|
inject: ['api', 'lang', 'hash', 'projects', 'consts', 'isMobile'],
|
||||||
|
mounted() {
|
||||||
|
//Starts default project init() through watcher
|
||||||
|
if(this.hash.items.length == 0) {
|
||||||
|
this.hash.items[0] = (this.projects.getDefaultProject().mode == this.consts.modes.blog)?this.projects.getDefaultCodeName():this.overview.codename;
|
||||||
|
}
|
||||||
|
else this.init();
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
this.$refs.lightbox.end(true);
|
||||||
|
this.$refs.mapCtrl.destroy();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async init() {
|
||||||
|
this.hikes.colors = {
|
||||||
|
'main': getStyleProperty('--track-main'),
|
||||||
|
'off-track': getStyleProperty('--track-off-track'),
|
||||||
|
'hitchhiking': getStyleProperty('--track-hitchhiking')
|
||||||
|
};
|
||||||
|
this.hikes.width = parseFloat(getStyleProperty('--track-width'));
|
||||||
|
this.hikes.transitions.lineWidthTransition.duration = parseFloat(getStyleProperty('--trans-quick'));
|
||||||
|
|
||||||
|
//Reset values
|
||||||
|
this.project = null;
|
||||||
|
this.$refs.mapCtrl.removeMapContent();
|
||||||
|
|
||||||
|
//Build Map
|
||||||
|
this.mapInitializing = true;
|
||||||
|
if(this.hash.items[0] && this.projects[this.hash.items[0]]) await this.initProject(this.hash.items[0]);
|
||||||
|
else await this.initOverview();
|
||||||
|
this.mapInitializing = false;
|
||||||
|
},
|
||||||
|
async initOverview() {
|
||||||
|
this.modeHisto = true;
|
||||||
|
this.hash.items = [this.overview.codename];
|
||||||
|
this.feed.toggle(false, 0);
|
||||||
|
|
||||||
|
await this.initOverviewMap();
|
||||||
|
},
|
||||||
|
async initProject(sProjectCodeName) {
|
||||||
|
this.project = this.projects[sProjectCodeName];
|
||||||
|
this.modeHisto = (this.project.mode == this.consts.modes.histo);
|
||||||
|
|
||||||
|
await this.$nextTick();
|
||||||
|
const pMapReady = this.initProjectMap();
|
||||||
|
await this.feed.init(pMapReady);
|
||||||
|
},
|
||||||
|
openLightbox(iMediaId, sSource) {
|
||||||
|
const aoAlbum = (sSource == 'marker')
|
||||||
|
? (this.$refs.mapCtrl.findMarkerByMediaId(iMediaId)?.medias || [])
|
||||||
|
: this.feed.posts.filter((oPost) => oPost.type == 'media');
|
||||||
|
this.$refs.lightbox.open(aoAlbum, iMediaId, sSource);
|
||||||
|
},
|
||||||
|
async onLightboxMediaChange(oMedia) {
|
||||||
|
this.hash.items = [this.project.codename, 'media', oMedia.id];
|
||||||
|
if(oMedia.source == 'post') {
|
||||||
|
(await this.feed.findPost('media', oMedia.id))?.panMapToMarker();
|
||||||
|
if(!this.$refs.lightbox.hasMediaAfterCurrent()) {
|
||||||
|
await this.feed.getNextFeed();
|
||||||
|
this.$refs.lightbox.refreshAlbum(this.feed.posts.filter((oPost) => oPost.type == 'media'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLightboxClosing() {
|
||||||
|
this.hash.items = [this.hash.items[0]];
|
||||||
|
},
|
||||||
|
async initProjectMap() {
|
||||||
|
const [{maps: baseMaps, markers}, track] = await Promise.all([
|
||||||
|
this.api.get('markers', {id_project: this.project.id}),
|
||||||
|
this.api.getAsset(this.project.geofilepath)
|
||||||
|
]);
|
||||||
|
this.baseMaps = baseMaps;
|
||||||
|
|
||||||
|
await this.$refs.mapCtrl.initMap({
|
||||||
|
project: this.project,
|
||||||
|
hikes: this.hikes,
|
||||||
|
baseMaps,
|
||||||
|
markers,
|
||||||
|
track,
|
||||||
|
padding: this.getMapPadding()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async initOverviewMap() {
|
||||||
|
this.baseMaps = this.consts.default_maps;
|
||||||
|
const markers = Object.values(this.projects).map((asProject) => ({
|
||||||
|
type: 'project',
|
||||||
|
subtype: 'project',
|
||||||
|
...asProject,
|
||||||
|
opacityWhenCovered: 0.3
|
||||||
|
}));
|
||||||
|
|
||||||
|
await this.$refs.mapCtrl.initMap({
|
||||||
|
project: null,
|
||||||
|
hikes: this.hikes,
|
||||||
|
baseMaps: this.baseMaps,
|
||||||
|
markers,
|
||||||
|
track: null,
|
||||||
|
padding: this.getMapPadding()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addNewMarkers(aoMarkers) {
|
||||||
|
this.$refs.mapCtrl.addNewMarkers(aoMarkers);
|
||||||
|
},
|
||||||
|
panToBetweenPanels(oLngLat, iZoom, iAnimDuration=500) {
|
||||||
|
return this.$refs.mapCtrl.panTo(oLngLat, iZoom, this.getMapPadding(), iAnimDuration);
|
||||||
|
},
|
||||||
|
getMapPadding() {
|
||||||
|
let bIsMobile = this.isMobile();
|
||||||
|
return {
|
||||||
|
top: BASE_MAP_PADDING,
|
||||||
|
bottom: BASE_MAP_PADDING,
|
||||||
|
left: BASE_MAP_PADDING + ((!bIsMobile && this.panels.leftOpen && this.settings)?this.settings.getWidth():0),
|
||||||
|
right: BASE_MAP_PADDING + ((!bIsMobile && this.panels.rightOpen && this.feed)?this.feed.getWidth():0)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
updateMapPadding(iDuration=0) {
|
||||||
|
this.$refs.mapCtrl.setPadding(this.getMapPadding(), iDuration);
|
||||||
|
},
|
||||||
|
onPanelToggle(sPanel, bNewValue, iAnimDuration=500) {
|
||||||
|
const sPanelKey = sPanel + 'Open';
|
||||||
|
let bOldValue = this.panels[sPanelKey];
|
||||||
|
this.panels[sPanelKey] = bNewValue;
|
||||||
|
|
||||||
|
if(bOldValue != bNewValue) {
|
||||||
|
//Adjust map center
|
||||||
|
if(!this.isMobile() && this.$refs.mapCtrl.map) this.updateMapPadding(iAnimDuration);
|
||||||
|
|
||||||
|
//Open Close panels
|
||||||
|
this.$el.classList.toggle('with-'+sPanel+'-panel');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setFeed(vPanel) {
|
||||||
|
this.feed = vPanel;
|
||||||
|
},
|
||||||
|
setSettings(vPanel) {
|
||||||
|
this.settings = vPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="projects">
|
||||||
|
<div id="space"></div>
|
||||||
|
<div id="submap">
|
||||||
|
<div class="loader">
|
||||||
|
<AppIcon :icon="'map'" :classes="'flicker'" width="fixed" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ProjectMap
|
||||||
|
ref="mapCtrl"
|
||||||
|
v-model:base-map="baseMap"
|
||||||
|
:terrain-enabled="terrainEnabled"
|
||||||
|
/>
|
||||||
|
<ProjectSettings
|
||||||
|
:ref="setSettings"
|
||||||
|
:projects="projectOptions"
|
||||||
|
v-model:project-code-name="hash.items[0]"
|
||||||
|
:base-maps="baseMaps"
|
||||||
|
v-model:base-map="baseMap"
|
||||||
|
v-model:terrain-enabled="terrainEnabled"
|
||||||
|
:map-initializing="mapInitializing"
|
||||||
|
:hikes="hikes"
|
||||||
|
@toggle="(bIsOpen, iAnimDuration) => onPanelToggle('left', bIsOpen, iAnimDuration)"
|
||||||
|
/>
|
||||||
|
<ProjectFeed
|
||||||
|
:ref="setFeed"
|
||||||
|
:project="project"
|
||||||
|
:mode-histo="modeHisto"
|
||||||
|
@request-last-update="settings?.setLastUpdate"
|
||||||
|
@new-markers="addNewMarkers"
|
||||||
|
@toggle="(bIsOpen, iAnimDuration) => onPanelToggle('right', bIsOpen, iAnimDuration)"
|
||||||
|
/>
|
||||||
|
<Lightbox
|
||||||
|
ref="lightbox"
|
||||||
|
:always-show-nav-on-touch-devices="true"
|
||||||
|
:position-from-top="0"
|
||||||
|
:has-video="true"
|
||||||
|
@media-change="onLightboxMediaChange"
|
||||||
|
@closing="onLightboxClosing"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<script>
|
||||||
|
import AppButton from '@components/AppButton';
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppButton,
|
||||||
|
AppIcon
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
feedbacks: [],
|
||||||
|
loginLoading: false,
|
||||||
|
newsletterLoading: false,
|
||||||
|
passwordMode: false,
|
||||||
|
settingPassword: false,
|
||||||
|
password: '',
|
||||||
|
passwordConfirmation: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
buttonClasses() {
|
||||||
|
return [
|
||||||
|
'manage',
|
||||||
|
this.action,
|
||||||
|
this.loginLoading?'loading':''
|
||||||
|
].filter(n => n).join(' ');
|
||||||
|
},
|
||||||
|
loggedIn() {
|
||||||
|
return this.user.id_user > 0;
|
||||||
|
},
|
||||||
|
action() {
|
||||||
|
return this.loggedIn?'logout':'login';
|
||||||
|
},
|
||||||
|
status() {
|
||||||
|
return this.loggedIn?(this.user.subscribed?'subscribed':(this.user.name?'logged_in_named':'logged_in')):'logged_out';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inject: ['api', 'lang', 'user'],
|
||||||
|
methods: {
|
||||||
|
manageSubscription() {
|
||||||
|
if(this.newsletterLoading) return;
|
||||||
|
this.newsletterLoading = true;
|
||||||
|
this.api.request(this.user.subscribed?'subscribe':'unsubscribe', {}, 'POST')
|
||||||
|
.then((asResponse) => {
|
||||||
|
this.user.setInfo(asResponse.data);
|
||||||
|
this.feedbacks.push({type:asResponse.result, msg:asResponse.desc_lang_text});
|
||||||
|
})
|
||||||
|
.catch((sDesc) => {
|
||||||
|
this.user.subscribed = !this.user.subscribed;
|
||||||
|
this.feedbacks.push({type:'error', msg:sDesc?.message || sDesc});
|
||||||
|
})
|
||||||
|
.finally(() => {this.newsletterLoading = false;});
|
||||||
|
},
|
||||||
|
manageLogin() {
|
||||||
|
if(this.loginLoading) return;
|
||||||
|
|
||||||
|
let regexEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
if(!regexEmail.test(this.user.email)) this.feedbacks.push({type:'error', 'msg':this.lang.get('account.invalid_email')});
|
||||||
|
else if(this.settingPassword && this.password !== this.passwordConfirmation) this.feedbacks.push({type:'error', 'msg':this.lang.get('account.password_mismatch')});
|
||||||
|
else {
|
||||||
|
const sAction = this.action;
|
||||||
|
this.loginLoading = true;
|
||||||
|
|
||||||
|
this.api.request(sAction, {'email': this.user.email, 'password': this.password, 'name': this.user.name}, 'POST')
|
||||||
|
.then((asResponse) => {
|
||||||
|
this.feedbacks.push({type: asResponse.result, msg: asResponse.desc_lang_text});
|
||||||
|
this.user.setInfo(asResponse.data);
|
||||||
|
this.passwordMode = false;
|
||||||
|
this.settingPassword = false;
|
||||||
|
this.password = '';
|
||||||
|
this.passwordConfirmation = '';
|
||||||
|
})
|
||||||
|
.catch((oError) => {
|
||||||
|
switch(oError.desc_lang_id) {
|
||||||
|
case 'account.set_password':
|
||||||
|
this.passwordMode = true;
|
||||||
|
this.settingPassword = true;
|
||||||
|
this.feedbacks.push({type:'warning', msg:oError.message});
|
||||||
|
break;
|
||||||
|
case 'account.password_required':
|
||||||
|
this.passwordMode = true;
|
||||||
|
this.feedbacks.push({type:'success', msg:oError.message});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.feedbacks.push({type:'error', msg:oError.message});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {this.loginLoading = false;});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="sub-section status">{{ lang.get('account.status.'+status, this.user.name) }}</div>
|
||||||
|
<div class="sub-section account-login">
|
||||||
|
<input type="email" name="email" id="email" :placeholder="lang.get('account.email_placeholder')" v-model="user.email" :disabled="loginLoading || loggedIn || passwordMode" @keyup.enter="manageLogin" />
|
||||||
|
<input v-if="passwordMode" type="password" name="password" id="password" :placeholder="lang.get('account.password')" v-model="password" :disabled="loginLoading" :autocomplete="settingPassword?'new-password':'current-password'" @keyup.enter="manageLogin" />
|
||||||
|
<input v-if="settingPassword" type="password" name="password_confirmation" id="password-confirmation" :placeholder="lang.get('account.confirm_password')" v-model="passwordConfirmation" :disabled="loginLoading" autocomplete="new-password" @keyup.enter="manageLogin" />
|
||||||
|
<AppButton :classes="buttonClasses" :title="lang.get('account.'+action)" :icon="action" @click="manageLogin" />
|
||||||
|
</div>
|
||||||
|
<div class="sub-section newsletter radio" v-if="loggedIn">
|
||||||
|
<input type="checkbox" id="account-newsletter" v-model="user.subscribed" :true-value="1" :false-value="0" :disabled="newsletterLoading" @change="manageSubscription" />
|
||||||
|
<label for="account-newsletter">{{ lang.get('account.newsletter') }}</label>
|
||||||
|
</div>
|
||||||
|
<div v-if="feedbacks.length" class="sub-section feedback">
|
||||||
|
<p v-for="feedback in feedbacks" :key="feedback.type + '-' + feedback.msg" :class="feedback.type">
|
||||||
|
<AppIcon :icon="feedback.type" :text="feedback.msg" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
<script>
|
||||||
|
import Simplebar from 'simplebar-vue';
|
||||||
|
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import ProjectPost from '@components/ProjectPost';
|
||||||
|
import { createSwipeToClose, initialSwipeState } from '@scripts/swipeToClose';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon,
|
||||||
|
ProjectPost,
|
||||||
|
Simplebar
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
project: Object,
|
||||||
|
modeHisto: Boolean
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loadingFeed: false,
|
||||||
|
loadingPost: false,
|
||||||
|
updatable: true,
|
||||||
|
outOfData: false,
|
||||||
|
refIdFirst: 0,
|
||||||
|
refIdLast: 0,
|
||||||
|
firstChunk: true,
|
||||||
|
isOpen: false,
|
||||||
|
posts: [],
|
||||||
|
refreshRate: 60,
|
||||||
|
swipe: initialSwipeState()
|
||||||
|
};
|
||||||
|
},
|
||||||
|
emits: ['request-last-update', 'new-markers', 'toggle'],
|
||||||
|
inject: ['api', 'lang', 'consts', 'hash', 'isMobile'],
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
feed: {
|
||||||
|
checkNewFeed: this.checkNewFeed,
|
||||||
|
toggle: this.toggle,
|
||||||
|
reply: this.reply,
|
||||||
|
findLinkedPost: this.findLinkedPost
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
project() {
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
},
|
||||||
|
modeHisto() {
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
},
|
||||||
|
firstChunk() {
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getScrollElement()?.addEventListener('scroll', this.onFeedScroll);
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
this.getScrollElement()?.removeEventListener('scroll', this.onFeedScroll);
|
||||||
|
this.setUpdateTimer(-1);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
loading() {
|
||||||
|
return this.loadingFeed || this.loadingPost;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async init(pMapIsReady) {
|
||||||
|
this.setUpdateTimer(-1);
|
||||||
|
this.loadingFeed = false;
|
||||||
|
this.loadingPost = false;
|
||||||
|
this.updatable = true;
|
||||||
|
this.outOfData = false;
|
||||||
|
this.refIdFirst = 0;
|
||||||
|
this.refIdLast = 0;
|
||||||
|
this.firstChunk = true;
|
||||||
|
this.posts = [];
|
||||||
|
|
||||||
|
this.toggle(!this.isMobile(), 0);
|
||||||
|
this.getScrollElement().scrollTop = 0;
|
||||||
|
|
||||||
|
//Direct link post action
|
||||||
|
await(this.hash.items.length == 3
|
||||||
|
? this.findLinkedPost(this.hash.items[1], this.hash.items[2], pMapIsReady)
|
||||||
|
: this.getNextFeed()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
},
|
||||||
|
getScrollElement() {
|
||||||
|
return this.$refs.feedSimpleBar?.scrollElement;
|
||||||
|
},
|
||||||
|
async findLinkedPost(sPostType, iPostId, pMapIsReady=Promise.resolve()) {
|
||||||
|
let vPost = await this.findPost(sPostType, iPostId, true);
|
||||||
|
if(vPost) {
|
||||||
|
await pMapIsReady;
|
||||||
|
await vPost.executeMainAction(0);
|
||||||
|
return vPost;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
},
|
||||||
|
async findPost(sPostType, iPostId, bHidePosts=false) {
|
||||||
|
if(bHidePosts) this.loadingPost = true;
|
||||||
|
|
||||||
|
let avPosts = this.$refs?.posts?.filter((post) => {return post.postId == sPostType+'-'+iPostId;});
|
||||||
|
if(avPosts && avPosts.length > 0) {
|
||||||
|
let vPost = avPosts[0];
|
||||||
|
this.loadingPost = false;
|
||||||
|
|
||||||
|
//Force next update to have enough subsequent elements to position the post on top of the page
|
||||||
|
await this.getNextFeed();
|
||||||
|
|
||||||
|
//Position the post on top of the page
|
||||||
|
const $ScrollElement = this.getScrollElement();
|
||||||
|
$ScrollElement.scrollTop += Math.round(
|
||||||
|
vPost.$el.getBoundingClientRect().top
|
||||||
|
- $ScrollElement.getBoundingClientRect().top
|
||||||
|
- parseFloat(getComputedStyle(this.$refs.feedSimpleBar.$el).paddingTop)
|
||||||
|
);
|
||||||
|
|
||||||
|
return vPost;
|
||||||
|
}
|
||||||
|
else if(!this.outOfData) {
|
||||||
|
await this.getNextFeed();
|
||||||
|
return this.findPost(sPostType, iPostId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loadingPost = false;
|
||||||
|
console.log('Missing element ID "'+iPostId+'" of type "'+sPostType+'"');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getNextFeed() {
|
||||||
|
if(!this.project || this.outOfData || this.loadingFeed) return true;
|
||||||
|
|
||||||
|
//Get next chunk
|
||||||
|
this.loadingFeed = true;
|
||||||
|
let aoData = await this.api.get('next_feed', {id_project: this.project.id, id: this.refIdLast});
|
||||||
|
let iPostCount = Object.keys(aoData.feed).length;
|
||||||
|
|
||||||
|
//Update pointers
|
||||||
|
this.outOfData = (iPostCount < this.consts.chunk_size);
|
||||||
|
if(iPostCount > 0) {
|
||||||
|
this.refIdLast = aoData.ref_id_last;
|
||||||
|
if(this.firstChunk) this.refIdFirst = aoData.ref_id_first;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add posts
|
||||||
|
this.posts.push(...aoData.feed);
|
||||||
|
|
||||||
|
this.loadingFeed = false;
|
||||||
|
this.firstChunk = false;
|
||||||
|
|
||||||
|
await this.$nextTick();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
onFeedScroll(oEvent) {
|
||||||
|
const box = oEvent.currentTarget;
|
||||||
|
const content = box.querySelector('.simplebar-content');
|
||||||
|
|
||||||
|
if((box.scrollTop + box.clientHeight) / (content?.offsetHeight || 1) >= 0.8) this.getNextFeed();
|
||||||
|
},
|
||||||
|
...createSwipeToClose(1),
|
||||||
|
setUpdateTimer(iSeconds) {
|
||||||
|
if(typeof this.feedTimer != 'undefined') clearTimeout(this.feedTimer);
|
||||||
|
if(iSeconds >= 0) this.feedTimer = setTimeout(this.onUpdateTimer, iSeconds * 1000);
|
||||||
|
},
|
||||||
|
syncUpdateTimer() {
|
||||||
|
this.setUpdateTimer((!!this.project && !this.modeHisto && !this.firstChunk)?this.refreshRate:-1);
|
||||||
|
},
|
||||||
|
async onUpdateTimer() {
|
||||||
|
await this.checkNewFeed();
|
||||||
|
this.syncUpdateTimer();
|
||||||
|
},
|
||||||
|
async checkNewFeed() {
|
||||||
|
if(!this.project) return;
|
||||||
|
|
||||||
|
let aoData = await this.api.get('new_feed', {id_project: this.project.id, id: this.refIdFirst});
|
||||||
|
const aoFeed = aoData.feed || [];
|
||||||
|
const aoMarkers = aoData.markers || [];
|
||||||
|
|
||||||
|
if(aoFeed.length > 0) {
|
||||||
|
//Update pointer
|
||||||
|
this.refIdFirst = aoData.ref_id_first;
|
||||||
|
|
||||||
|
//Add new posts
|
||||||
|
this.posts.unshift(...aoFeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(aoMarkers.length > 0) this.$emit('new-markers', aoMarkers);
|
||||||
|
this.$emit('request-last-update');
|
||||||
|
},
|
||||||
|
reply(oQuote) {
|
||||||
|
this.$refs.poster?.addQuote(oQuote);
|
||||||
|
},
|
||||||
|
toggle(bShow, iAnimDuration=500) {
|
||||||
|
this.isOpen = (typeof bShow == 'boolean')?bShow:(!this.isOpen);
|
||||||
|
this.$emit('toggle', this.isOpen, iAnimDuration);
|
||||||
|
return this.isOpen;
|
||||||
|
},
|
||||||
|
getWidth() {
|
||||||
|
return this.$el.getBoundingClientRect().width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div id="feed" class="panel panel-right" @touchstart.passive="onTouchStart" @touchmove.passive="onTouchMove" @touchend.passive="onTouchEnd">
|
||||||
|
<Simplebar id="feed-panel" class="panel-content" ref="feedSimpleBar" :aria-busy="loading">
|
||||||
|
<div id="feed-header">
|
||||||
|
<ProjectPost v-if="modeHisto" :options="{type: 'archived', headerless: true}" />
|
||||||
|
<ProjectPost v-else :options="{type: 'poster', relative_time: lang.get('post.new_message')}" ref="poster" />
|
||||||
|
</div>
|
||||||
|
<div v-if="project" v-show="!loadingPost" id="feed-posts">
|
||||||
|
<ProjectPost v-for="post in posts" :key="post.ref" :options="post" ref="posts" />
|
||||||
|
</div>
|
||||||
|
<div id="feed-footer" v-if="loading">
|
||||||
|
<ProjectPost :options="{type: 'loading', headerless: true}" />
|
||||||
|
</div>
|
||||||
|
</Simplebar>
|
||||||
|
<div v-if="project" :class="'panel-control panel-control-'+(isMobile()?'bottom':'top')" @click="toggle">
|
||||||
|
<div class="panel-control-elem panel-control-icon">
|
||||||
|
<AppIcon :icon="isOpen?'next':'post'" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,522 @@
|
|||||||
|
<script>
|
||||||
|
import { Map, Marker, LngLatBounds, LngLat, Popup, ScaleControl, NavigationControl, setWorkerUrl } from 'maplibre-gl';
|
||||||
|
import maplibreWorkerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
|
||||||
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
||||||
|
|
||||||
|
import { createApp } from 'vue';
|
||||||
|
|
||||||
|
import { getStyleProperty } from '@scripts/common';
|
||||||
|
import ProjectPopup from '@components/ProjectPopup';
|
||||||
|
import AppIconStack from '@components/AppIconStack';
|
||||||
|
|
||||||
|
setWorkerUrl(maplibreWorkerUrl);
|
||||||
|
|
||||||
|
//Padding shared with Project.vue's own panel-width padding calculation: 1rem + marker height
|
||||||
|
export const BASE_MAP_PADDING = 16 + 32;
|
||||||
|
|
||||||
|
const MARKER_PROPS = {
|
||||||
|
project: {mainClasses: 'project', iconMain: 'marker', iconSub: 'project'},
|
||||||
|
image: {mainClasses: 'media', iconMain: 'marker', iconSub: 'image'},
|
||||||
|
video: {mainClasses: 'media', iconMain: 'marker', iconSub: 'video'},
|
||||||
|
message: {mainClasses: 'message', iconMain: 'marker', iconSub: 'footprint', iconSubTransform: 'rotate-270'}
|
||||||
|
};
|
||||||
|
|
||||||
|
class GroupedScaleControl {
|
||||||
|
constructor(options) {
|
||||||
|
this.scale = new ScaleControl(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
onAdd(map) {
|
||||||
|
this.container = document.createElement('div');
|
||||||
|
this.container.className = 'maplibregl-ctrl maplibregl-ctrl-group';
|
||||||
|
|
||||||
|
const scaleElement = this.scale.onAdd(map);
|
||||||
|
scaleElement.classList.remove('maplibregl-ctrl');
|
||||||
|
this.container.appendChild(scaleElement);
|
||||||
|
|
||||||
|
return this.container;
|
||||||
|
}
|
||||||
|
|
||||||
|
onRemove() {
|
||||||
|
this.scale.onRemove();
|
||||||
|
this.container.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Owns the MapLibre map instance and everything drawn on it (base maps,
|
||||||
|
//terrain, track, markers, popups). Project.vue keeps the reactive state
|
||||||
|
//its own template/props need (baseMaps, hikes, project...) and drives
|
||||||
|
//this component's imperative API through a template ref, the same way
|
||||||
|
//it would drive a plain class - most of what happens here is imperative
|
||||||
|
//MapLibre calls (addLayer, jumpTo) rather than declarative rendering, so
|
||||||
|
//the <template> is just the map container div.
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
terrainEnabled: Boolean,
|
||||||
|
baseMap: String
|
||||||
|
},
|
||||||
|
emits: ['update:base-map'],
|
||||||
|
inject: ['lang', 'consts', 'isMobile', 'projects', 'hash', 'lightbox'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
map: null,
|
||||||
|
baseMaps: [],
|
||||||
|
markers: [],
|
||||||
|
track: null,
|
||||||
|
hikes: null,
|
||||||
|
project: null,
|
||||||
|
popup: {content: null, element: null},
|
||||||
|
markerHeight: 32, //FIXME
|
||||||
|
maxZoom: 15,
|
||||||
|
initialPitch: 45
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
baseMap(sNewBaseMap, sOldBaseMap) {
|
||||||
|
if(!this.map?.isStyleLoaded()) return;
|
||||||
|
if(sOldBaseMap && this.map.getLayer(sOldBaseMap)) this.map.setLayoutProperty(sOldBaseMap, 'visibility', 'none');
|
||||||
|
if(sNewBaseMap && this.map.getLayer(sNewBaseMap)) this.map.setLayoutProperty(sNewBaseMap, 'visibility', 'visible');
|
||||||
|
},
|
||||||
|
terrainEnabled(bEnabled) {
|
||||||
|
if(!this.map?.isStyleLoaded()) return;
|
||||||
|
if(bEnabled) this.addTerrain();
|
||||||
|
else this.removeTerrain();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async initMap({project, hikes, baseMaps, markers, track, padding}) {
|
||||||
|
this.project = project;
|
||||||
|
this.hikes = hikes;
|
||||||
|
this.baseMaps = baseMaps;
|
||||||
|
this.markers = markers;
|
||||||
|
this.track = track;
|
||||||
|
|
||||||
|
if(!this.map) this.addMap();
|
||||||
|
this.setPadding(padding);
|
||||||
|
|
||||||
|
//Force wait for load event
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
if(this.map.isStyleLoaded()) resolve();
|
||||||
|
else this.map.once('load', resolve);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.map.resize();
|
||||||
|
this.setInitialProjectCamera();
|
||||||
|
|
||||||
|
//Add content: Base Maps, Tracks, Markers
|
||||||
|
this.addMapContent();
|
||||||
|
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
if(this.map.loaded() && this.map.areTilesLoaded()) resolve();
|
||||||
|
else this.map.once('idle', resolve);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addMap() {
|
||||||
|
this.map = new Map({
|
||||||
|
container: this.$el,
|
||||||
|
aroundCenter: true,
|
||||||
|
style: {
|
||||||
|
version: 8,
|
||||||
|
projection: {type: 'globe'},
|
||||||
|
sky: {
|
||||||
|
'sky-color': getStyleProperty('--space'),
|
||||||
|
'horizon-color': getStyleProperty('--horizon'),
|
||||||
|
'sky-horizon-blend': 0.35,
|
||||||
|
'atmosphere-blend': 0.8
|
||||||
|
},
|
||||||
|
sources: {},
|
||||||
|
layers: []
|
||||||
|
},
|
||||||
|
attributionControl: false
|
||||||
|
});
|
||||||
|
this.map.addControl(new GroupedScaleControl({unit: 'metric'}), 'bottom-right');
|
||||||
|
this.map.addControl(new NavigationControl({showZoom: false, visualizePitch: true}), 'bottom-right');
|
||||||
|
},
|
||||||
|
destroy() {
|
||||||
|
this.removeMapContent();
|
||||||
|
this.map?.remove();
|
||||||
|
this.map = null;
|
||||||
|
},
|
||||||
|
addMapContent() {
|
||||||
|
this.baseMaps.forEach(this.addBaseMap);
|
||||||
|
if(this.terrainEnabled) this.addTerrain();
|
||||||
|
this.addTrack();
|
||||||
|
this.markers.forEach(this.addMarker);
|
||||||
|
},
|
||||||
|
removeMapContent() {
|
||||||
|
if(!this.map) return;
|
||||||
|
|
||||||
|
this.closePopup();
|
||||||
|
this.removeTrack();
|
||||||
|
this.markers.forEach(this.removeMarker);
|
||||||
|
this.removeTerrain();
|
||||||
|
this.baseMaps.forEach(this.removeBaseMap);
|
||||||
|
},
|
||||||
|
addTerrain() {
|
||||||
|
// MapLibre terrain's fog matrix is only implemented for Mercator.
|
||||||
|
this.map.setProjection({type: 'mercator'});
|
||||||
|
//One shared raster-dem source feeds both the 3D elevation mesh
|
||||||
|
//(setTerrain) and the hillshade layer below - they used to be two
|
||||||
|
//separate sources pointed at the identical tile URL, which meant
|
||||||
|
//every DEM tile was downloaded and decoded twice per viewport.
|
||||||
|
if(!this.map.getSource('terrain-dem')) {
|
||||||
|
this.map.addSource('terrain-dem', {
|
||||||
|
type: 'raster-dem',
|
||||||
|
tiles: ['https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png'],
|
||||||
|
tileSize: 256,
|
||||||
|
maxzoom: 15,
|
||||||
|
encoding: 'terrarium'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(!this.map.getLayer('terrain-hillshade')) {
|
||||||
|
this.map.addLayer({
|
||||||
|
id: 'terrain-hillshade',
|
||||||
|
type: 'hillshade',
|
||||||
|
source: 'terrain-dem',
|
||||||
|
paint: {
|
||||||
|
'hillshade-exaggeration': 0.35,
|
||||||
|
'hillshade-shadow-color': '#2d342b',
|
||||||
|
'hillshade-highlight-color': '#ffffff'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.map.setTerrain({source: 'terrain-dem', exaggeration: 1.25});
|
||||||
|
},
|
||||||
|
removeTerrain() {
|
||||||
|
if(!this.map) return;
|
||||||
|
if(this.map.getTerrain()) this.map.setTerrain(null);
|
||||||
|
if(this.map.getLayer('terrain-hillshade')) this.map.removeLayer('terrain-hillshade');
|
||||||
|
if(this.map.getSource('terrain-dem')) this.map.removeSource('terrain-dem');
|
||||||
|
this.map.setProjection({type: 'globe'});
|
||||||
|
},
|
||||||
|
addBaseMap(asBaseMap) {
|
||||||
|
if(asBaseMap.default_map) this.$emit('update:base-map', asBaseMap.codename);
|
||||||
|
if(this.map.getSource(asBaseMap.codename) && this.map.getLayer(asBaseMap.codename)) return;
|
||||||
|
this.map.addSource(asBaseMap.codename, {
|
||||||
|
type: 'raster',
|
||||||
|
tiles: [asBaseMap.pattern],
|
||||||
|
tileSize: asBaseMap.tile_size
|
||||||
|
});
|
||||||
|
this.map.addLayer({
|
||||||
|
id: asBaseMap.codename,
|
||||||
|
type: 'raster',
|
||||||
|
source: asBaseMap.codename,
|
||||||
|
'layout': {'visibility': asBaseMap.default_map?'visible':'none'},
|
||||||
|
minZoom: asBaseMap.min_zoom,
|
||||||
|
maxZoom: asBaseMap.max_zoom
|
||||||
|
});
|
||||||
|
},
|
||||||
|
removeBaseMap(asBaseMap) {
|
||||||
|
if(this.map.getLayer(asBaseMap.codename)) this.map.removeLayer(asBaseMap.codename);
|
||||||
|
if(this.map.getSource(asBaseMap.codename)) this.map.removeSource(asBaseMap.codename);
|
||||||
|
},
|
||||||
|
addTrack() {
|
||||||
|
if(!this.track) return;
|
||||||
|
|
||||||
|
this.track.features.forEach((oFeature, iFeatureId) => {
|
||||||
|
oFeature.properties.track_id = iFeatureId;
|
||||||
|
});
|
||||||
|
this.map.addSource('track', {
|
||||||
|
'type': 'geojson',
|
||||||
|
'data': this.track
|
||||||
|
});
|
||||||
|
|
||||||
|
//Color mapping
|
||||||
|
let asColorMapping = ['match', ['get', 'type']];
|
||||||
|
for(const [sHikeType, sColor] of Object.entries(this.hikes.colors)) {
|
||||||
|
asColorMapping.push(sHikeType);
|
||||||
|
asColorMapping.push(sColor);
|
||||||
|
}
|
||||||
|
asColorMapping.push('black'); //fallback value
|
||||||
|
|
||||||
|
//Track layer
|
||||||
|
this.map.addLayer({
|
||||||
|
'id': 'track',
|
||||||
|
'type': 'line',
|
||||||
|
'source': 'track',
|
||||||
|
'layout': {
|
||||||
|
'line-join': 'round',
|
||||||
|
'line-cap': 'round'
|
||||||
|
},
|
||||||
|
'paint': {
|
||||||
|
'line-color': asColorMapping,
|
||||||
|
'line-width': this.hikes.width
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Enlarged track (click hit box)
|
||||||
|
this.map.addLayer({
|
||||||
|
'id': 'track-hitbox',
|
||||||
|
'type': 'line',
|
||||||
|
'source': 'track',
|
||||||
|
'paint': {
|
||||||
|
'line-opacity': 0,
|
||||||
|
'line-width': this.hikes.width + BASE_MAP_PADDING
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.map.on('click', 'track-hitbox', this.openTrackPopup);
|
||||||
|
this.map.on('mouseenter', 'track-hitbox', this.onTrackHover);
|
||||||
|
this.map.on('mouseleave', 'track-hitbox', this.onTrackHover);
|
||||||
|
},
|
||||||
|
removeTrack() {
|
||||||
|
//Over clickable track
|
||||||
|
if(this.map.getLayer('track-hitbox')) {
|
||||||
|
this.map.off('click', 'track-hitbox', this.openTrackPopup);
|
||||||
|
this.map.off('mouseenter', 'track-hitbox', this.onTrackHover);
|
||||||
|
this.map.off('mouseleave', 'track-hitbox', this.onTrackHover);
|
||||||
|
this.map.removeLayer('track-hitbox');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Actual track
|
||||||
|
if(this.map.getLayer('track')) this.map.removeLayer('track');
|
||||||
|
|
||||||
|
//Track source
|
||||||
|
if(this.map.getSource('track')) this.map.removeSource('track');
|
||||||
|
},
|
||||||
|
addMarker(oMarker) {
|
||||||
|
const $Marker = document.createElement('div');
|
||||||
|
oMarker.app = createApp(AppIconStack, MARKER_PROPS[oMarker.subtype]);
|
||||||
|
oMarker.app.mount($Marker);
|
||||||
|
|
||||||
|
oMarker.marker = new Marker({element: $Marker, anchor: 'bottom', opacityWhenCovered: oMarker.opacityWhenCovered ?? 0})
|
||||||
|
.setLngLat([oMarker.longitude, oMarker.latitude])
|
||||||
|
.addTo(this.map);
|
||||||
|
|
||||||
|
const $MarkerElement = oMarker.marker.getElement();
|
||||||
|
$MarkerElement.addEventListener('click', (oEvent) => {this.onMarkerClick(oEvent, oMarker);});
|
||||||
|
$MarkerElement.addEventListener('mouseenter', (oEvent) => {this.onMarkerHover(oEvent, oMarker);});
|
||||||
|
$MarkerElement.addEventListener('mouseleave', (oEvent) => {this.onMarkerHover(oEvent, oMarker);});
|
||||||
|
},
|
||||||
|
removeMarker(oMarker) {
|
||||||
|
if(oMarker.app) {
|
||||||
|
oMarker.app.unmount();
|
||||||
|
delete oMarker.app;
|
||||||
|
}
|
||||||
|
if(oMarker.marker) {
|
||||||
|
oMarker.marker.remove();
|
||||||
|
delete oMarker.marker;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addNewMarkers(aoMarkers) { //FIXME Use its own marker update API
|
||||||
|
this.markers.push(...aoMarkers);
|
||||||
|
aoMarkers.forEach(this.addMarker);
|
||||||
|
},
|
||||||
|
onTrackHover(oEvent) {
|
||||||
|
this.map.getCanvas().style.cursor = (oEvent.type == 'mouseenter')?'pointer':'';
|
||||||
|
},
|
||||||
|
onMarkerClick(oEvent, oMarker) {
|
||||||
|
oEvent.preventDefault();
|
||||||
|
oEvent.stopPropagation();
|
||||||
|
switch(oMarker.type) {
|
||||||
|
case 'project':
|
||||||
|
this.hash.items = [oMarker.codename];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.openMarkerPopup(oMarker.id, oMarker.type);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onMarkerHover(oEvent, oMarker) {
|
||||||
|
switch(oMarker.type) {
|
||||||
|
case 'project':
|
||||||
|
if(oEvent.type == 'mouseenter') this.openProjectPopup(oMarker);
|
||||||
|
else this.closePopup();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openProjectPopup(oProject) {
|
||||||
|
this.openPopup({
|
||||||
|
lnglat: [oProject.longitude, oProject.latitude],
|
||||||
|
options: oProject,
|
||||||
|
offset: [0, -1 * this.markerHeight * getStyleProperty('--zoom-scale')]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
findMarkerByMediaId(iMediaId) {
|
||||||
|
return this.markers.find((oMarker) => oMarker.type == 'media' && oMarker.id == iMediaId) //Look for an actual media marker first
|
||||||
|
|| this.markers.find((oMarker) => (oMarker.medias || []).some((oMedia) => oMedia.id_media == iMediaId)) //Look for a media within a message marker
|
||||||
|
|| null;
|
||||||
|
},
|
||||||
|
openMarkerPopup(iMarkerId, sMarkerType) {
|
||||||
|
let oMarker = this.markers.find((oCandidate) => oCandidate.id == iMarkerId && oCandidate.type == sMarkerType);
|
||||||
|
this.openPopup({
|
||||||
|
lnglat: [oMarker.longitude, oMarker.latitude],
|
||||||
|
options: oMarker,
|
||||||
|
//NB: `this.isMobile` here is the injected function itself, not a call to it - always
|
||||||
|
//truthy, so this branch always applies. Pre-existing behavior, kept as-is by this split.
|
||||||
|
offset: [0, -1 * this.markerHeight * (this.isMobile?getStyleProperty('--zoom-scale'):1)]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openTrackPopup(oEvent) {
|
||||||
|
this.openPopup({
|
||||||
|
lnglat: oEvent.lngLat,
|
||||||
|
options: this.projects.getTrackInfo(oEvent.features[0], this.track, this.lang),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openPopup({lnglat, options={}, offset=[0, 0]} = {}) {
|
||||||
|
this.closePopup();
|
||||||
|
const $Popup = document.createElement('div');
|
||||||
|
this.popup.element = new Popup({
|
||||||
|
anchor: 'bottom',
|
||||||
|
offset: offset,
|
||||||
|
closeButton: false
|
||||||
|
})
|
||||||
|
.setDOMContent($Popup)
|
||||||
|
.setLngLat(lnglat)
|
||||||
|
.addTo(this.map);
|
||||||
|
|
||||||
|
this.popup.content = createApp(ProjectPopup, {
|
||||||
|
options: options,
|
||||||
|
project: this.project,
|
||||||
|
hikes: this.hikes
|
||||||
|
});
|
||||||
|
this.popup.content
|
||||||
|
.provide('lang', this.lang)
|
||||||
|
.provide('consts', this.consts)
|
||||||
|
.provide('isMobile', this.isMobile)
|
||||||
|
.provide('lightbox', this.lightbox)
|
||||||
|
.mount($Popup);
|
||||||
|
},
|
||||||
|
closePopup() {
|
||||||
|
if(this.popup.content) {
|
||||||
|
this.popup.content.unmount();
|
||||||
|
this.popup.content = null;
|
||||||
|
}
|
||||||
|
if(this.popup.element) {
|
||||||
|
this.popup.element.remove();
|
||||||
|
this.popup.element = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setInitialProjectCamera() {
|
||||||
|
let oHashMarker;
|
||||||
|
if(this.hash.items.length == 3) {
|
||||||
|
oHashMarker = this.markers.find((oMarker) => (
|
||||||
|
oMarker.type == this.hash.items[1] &&
|
||||||
|
oMarker.id == this.hash.items[2] &&
|
||||||
|
oMarker.longitude != null &&
|
||||||
|
oMarker.latitude != null
|
||||||
|
)) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let oLastMarker = this.markers.at(-1);
|
||||||
|
|
||||||
|
//Overview map: Center on default project
|
||||||
|
if(!this.project) {
|
||||||
|
//Center on default project
|
||||||
|
const oDefaultProject = this.projects.getDefaultProject();
|
||||||
|
|
||||||
|
//Get Map / Canvas size
|
||||||
|
const $Canvas = this.map.getCanvas();
|
||||||
|
const oMapBounds = this.map.getContainer().getBoundingClientRect();
|
||||||
|
|
||||||
|
//Adapt zoom to see whole planet
|
||||||
|
const iTargetRadius = Math.max(1, Math.min(oMapBounds.width || $Canvas.clientWidth, oMapBounds.height || $Canvas.clientHeight) / 2);
|
||||||
|
const iWorldSize = iTargetRadius * 2 * Math.PI * Math.cos(oDefaultProject.latitude * Math.PI / 180);
|
||||||
|
|
||||||
|
this.map.jumpTo({
|
||||||
|
center: new LngLat(oDefaultProject.longitude, oDefaultProject.latitude),
|
||||||
|
zoom: Math.log2(iWorldSize / 512),
|
||||||
|
pitch: 0,
|
||||||
|
bearing: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//Direct link to marker
|
||||||
|
else if(oHashMarker) {
|
||||||
|
this.map.jumpTo({
|
||||||
|
center: new LngLat(oHashMarker.longitude, oHashMarker.latitude),
|
||||||
|
zoom: 13,
|
||||||
|
pitch: this.initialPitch
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//Blog Mode: Fit to last marker
|
||||||
|
else if(this.project.mode == this.consts.modes.blog && oLastMarker) {
|
||||||
|
this.map.jumpTo({
|
||||||
|
center: new LngLat(oLastMarker.longitude, oLastMarker.latitude),
|
||||||
|
zoom: this.maxZoom,
|
||||||
|
pitch: this.initialPitch,
|
||||||
|
bearing: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//Pre Mode, Histo Mode, Blog Mode without markers or missing direct link marker: Fit to track
|
||||||
|
else {
|
||||||
|
let oBounds = new LngLatBounds();
|
||||||
|
const aoTrackCoordinates = [];
|
||||||
|
for(const iFeatureId in this.track.features) {
|
||||||
|
oBounds = this.track.features[iFeatureId].geometry.coordinates.reduce(
|
||||||
|
(bounds, coord) => {
|
||||||
|
aoTrackCoordinates.push(coord);
|
||||||
|
return bounds.extend(coord);
|
||||||
|
},
|
||||||
|
oBounds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.map.fitBounds(oBounds, {
|
||||||
|
padding: BASE_MAP_PADDING,
|
||||||
|
animate: false,
|
||||||
|
maxZoom: this.maxZoom,
|
||||||
|
pitch: this.initialPitch,
|
||||||
|
bearing: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
this.fixPitchedCameraCenter(aoTrackCoordinates);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fixPitchedCameraCenter(aoTrackCoordinates) {
|
||||||
|
//Project min/max coords (lat, lng) onto map rectangle corner points (x, y)
|
||||||
|
const oScreenBounds = aoTrackCoordinates.reduce((oBounds, coord) => {
|
||||||
|
const oPoint = this.map.project(coord);
|
||||||
|
return {
|
||||||
|
minX: Math.min(oBounds.minX, oPoint.x),
|
||||||
|
minY: Math.min(oBounds.minY, oPoint.y),
|
||||||
|
maxX: Math.max(oBounds.maxX, oPoint.x),
|
||||||
|
maxY: Math.max(oBounds.maxY, oPoint.y)
|
||||||
|
};
|
||||||
|
}, {
|
||||||
|
minX: Infinity,
|
||||||
|
minY: Infinity,
|
||||||
|
maxX: -Infinity,
|
||||||
|
maxY: -Infinity
|
||||||
|
});
|
||||||
|
|
||||||
|
//Current Rectangle center
|
||||||
|
const oTrackCenter = {
|
||||||
|
x: (oScreenBounds.minX + oScreenBounds.maxX) / 2,
|
||||||
|
y: (oScreenBounds.minY + oScreenBounds.maxY) / 2
|
||||||
|
};
|
||||||
|
|
||||||
|
//Convert back center point (x, y) to coords and Move map to the track center
|
||||||
|
this.map.jumpTo({
|
||||||
|
center: this.map.unproject([
|
||||||
|
oTrackCenter.x,
|
||||||
|
oTrackCenter.y
|
||||||
|
])
|
||||||
|
});
|
||||||
|
},
|
||||||
|
panTo(oLngLat, iZoom, padding, iAnimDuration=500) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if(!this.map) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.map.once('moveend', resolve);
|
||||||
|
this.map.easeTo({
|
||||||
|
center: oLngLat,
|
||||||
|
zoom: iZoom,
|
||||||
|
padding: padding,
|
||||||
|
duration: iAnimDuration
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setPadding(padding, iDuration=0) {
|
||||||
|
if(iDuration > 0) this.map.easeTo({padding, duration: iDuration});
|
||||||
|
else this.map.jumpTo({padding});
|
||||||
|
},
|
||||||
|
isMarkerVisible(oLngLat) {
|
||||||
|
return !!this.map && this.map.getBounds().contains(oLngLat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div id="map"></div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
options: Object
|
||||||
|
},
|
||||||
|
inject: ['lang']
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a
|
||||||
|
:href="'https://www.google.com/maps/place/'+options.lat_dms+'+'+options.lon_dms+'/@'+options.latitude+','+options.longitude+',10z'"
|
||||||
|
:title="lang.get('map.see_on_google')"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
@click.stop
|
||||||
|
>{{ options.lat_dms+' '+options.lon_dms }}</a>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<script>
|
||||||
|
import appIcon from '@components/AppIcon';
|
||||||
|
import projectMapLink from '@components/ProjectMapLink';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
appIcon,
|
||||||
|
projectMapLink
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
options: Object,
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
emits: ['opening-lightbox'],
|
||||||
|
inject: ['lang', 'isMobile', 'lightbox'],
|
||||||
|
methods: {
|
||||||
|
openMedia() {
|
||||||
|
this.$emit('opening-lightbox', this.options);
|
||||||
|
this.lightbox.open(this.options.id_media, this.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a
|
||||||
|
class="media-link drill"
|
||||||
|
:href="options.media_path"
|
||||||
|
@click.prevent="openMedia"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="options.thumb_path"
|
||||||
|
:width="options.width"
|
||||||
|
:height="options.height"
|
||||||
|
:title="lang.get((options.subtype == 'video')?'media.click_watch':'media.click_zoom')"
|
||||||
|
class="clickable"
|
||||||
|
/>
|
||||||
|
<span class="drill-icon"><appIcon :icon="'drill-'+options.subtype" /></span>
|
||||||
|
<div v-if="options.comment && type == 'post'" class="comment">
|
||||||
|
<p>
|
||||||
|
<appIcon icon="post" :text="options.comment" size="lg" />
|
||||||
|
</p>
|
||||||
|
<p v-if="!isMobile() && options.latitude && options.longitude">
|
||||||
|
<appIcon icon="coords" margin="right" size="lg" />
|
||||||
|
<projectMapLink :options="options" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
<script>
|
||||||
|
import projectMapLink from '@components/ProjectMapLink';
|
||||||
|
import appIcon from '@components/AppIcon';
|
||||||
|
import projectRelTime from '@components/ProjectRelTime';
|
||||||
|
import projectMediaLink from '@components/ProjectMediaLink';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
appIcon,
|
||||||
|
projectMapLink,
|
||||||
|
projectMediaLink,
|
||||||
|
projectRelTime
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
options: Object,
|
||||||
|
project: Object,
|
||||||
|
hikes: Object
|
||||||
|
},
|
||||||
|
inject: ['lang', 'consts', 'isMobile'],
|
||||||
|
computed: {
|
||||||
|
activeTimeInterval() {
|
||||||
|
if(this.options.mode == this.consts.modes.blog) return this.lang.get('project.wip');
|
||||||
|
|
||||||
|
const sYearFrom = this.options.active_from.substr(0, 4);
|
||||||
|
const sYearTo = this.options.active_to.substr(0, 4);
|
||||||
|
return (sYearFrom == sYearTo)?sYearFrom:(sYearFrom + '-' + sYearTo);
|
||||||
|
},
|
||||||
|
timeinfo() {
|
||||||
|
return (this.options.type == 'media')?
|
||||||
|
{
|
||||||
|
icon: 'image-shot',
|
||||||
|
local_time: this.options.taken_on_formatted_time_local,
|
||||||
|
site_time: this.options.taken_on_formatted_time,
|
||||||
|
offset: this.options.taken_on_day_offset,
|
||||||
|
relative_time: this.options.taken_on_relative_time
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
icon: 'time',
|
||||||
|
local_time: this.options.formatted_time_local,
|
||||||
|
site_time: this.options.formatted_time,
|
||||||
|
offset: this.options.day_offset,
|
||||||
|
relative_time: this.options.relative_time
|
||||||
|
};
|
||||||
|
},
|
||||||
|
localTime() {
|
||||||
|
return this.timeinfo.local_time +
|
||||||
|
((this.project.mode == this.consts.modes.blog)?' (' + this.timeinfo.relative_time + ')':'')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="options.type+' '+options.subtype">
|
||||||
|
<div class="header" v-if="options.type == 'track' || options.type == 'project'">
|
||||||
|
<h1>
|
||||||
|
<appIcon v-if="options.type == 'project'" :icon="options.subtype" :classes="'track-'+options.subtype" size="lg" :text="this.options.name" width="auto" />
|
||||||
|
<span v-else class="track" :title="lang.get('track.'+options.subtype)">
|
||||||
|
<span class="line" :style="'background-color:'+hikes.colors[options.subtype]+';'"></span>
|
||||||
|
<span class="desc">{{ this.options.name }}</span>
|
||||||
|
</span>
|
||||||
|
</h1>
|
||||||
|
<p v-if="options.description && !options.leg" class="description">{{ options.description }}</p>
|
||||||
|
<div v-if="options.subtype!='hitchhiking'" class="separator"></div>
|
||||||
|
</div>
|
||||||
|
<div v-if="options.type=='track'">
|
||||||
|
<div v-if="options.leg" class="section destination">
|
||||||
|
<appIcon :title="lang.get('stats.from')" icon="start" width="fixed" size="lg" :text="options.leg.from" />
|
||||||
|
<appIcon :title="lang.get('stats.to')" icon="start" transform="rotate-180" width="fixed" size="lg" :text="options.leg.to" />
|
||||||
|
</div>
|
||||||
|
<div v-if="options.leg" class="separator"></div>
|
||||||
|
<div v-if="options.subtype!='hitchhiking'" class="section track-stats">
|
||||||
|
<appIcon :title="lang.get('stats.distance')" icon="distance" width="fixed" size="lg" :text="options.distance+'km'" />
|
||||||
|
<appIcon :title="lang.get('stats.duration')" icon="time" width="fixed" size="lg" :text="options.duration" />
|
||||||
|
<appIcon :title="lang.get('stats.elevation_gain')" icon="elev-gain" width="fixed" size="lg" :text="options.elev_gain+'m'" />
|
||||||
|
<appIcon :title="lang.get('stats.elevation_loss')" icon="elev-drop" width="fixed" size="lg" :text="options.elev_drop+'m'" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="options.type=='project'" class="section year">{{ activeTimeInterval }}</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="section" v-if="options.comment">
|
||||||
|
<appIcon icon="post" width="fixed" size="lg" :text="options.comment" />
|
||||||
|
</div>
|
||||||
|
<div class="section time">
|
||||||
|
<projectRelTime :icon="timeinfo.icon" :localTime="localTime" :siteTime="timeinfo.site_time" :offset="timeinfo.offset" />
|
||||||
|
</div>
|
||||||
|
<div v-if="!isMobile()" class="section coordinates">
|
||||||
|
<appIcon icon="coords" width="fixed" size="lg" margin="right" />
|
||||||
|
<projectMapLink :options="options" />
|
||||||
|
</div>
|
||||||
|
<div v-if="options.altitude" class="section altitude">
|
||||||
|
<appIcon icon="altitude" width="fixed" size="lg" :text="options.altitude+'m'" />
|
||||||
|
</div>
|
||||||
|
<div class="section weather" v-if="options.weather_icon && options.weather_icon!='unknown'" :title="options.weather_cond==''?'':lang.get('weather.'+options.weather_icon)">
|
||||||
|
<appIcon :icon="options.weather_icon" width="fixed" size="lg" :text="options.weather_temp+'°C'" />
|
||||||
|
</div>
|
||||||
|
<div v-if="options.medias" class="section medias">
|
||||||
|
<appIcon v-if="options.type=='message'" icon="media" width="fixed" size="lg" :text="lang.get('media.nearby')" />
|
||||||
|
<div class="medias-list">
|
||||||
|
<projectMediaLink v-for="media in options?.medias" :key="media.id_media" :options="media" :type="'marker'" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,297 @@
|
|||||||
|
<script>
|
||||||
|
import appIcon from '@components/AppIcon';
|
||||||
|
import appIconStack from '@components/AppIconStack';
|
||||||
|
import appButton from '@components/AppButton';
|
||||||
|
import projectMediaLink from '@components/ProjectMediaLink';
|
||||||
|
import projectMapLink from '@components/ProjectMapLink';
|
||||||
|
import projectRelTime from '@components/ProjectRelTime';
|
||||||
|
import projectPostQuote from '@components/ProjectPostQuote';
|
||||||
|
import projectPostSignature from '@components/ProjectPostSignature';
|
||||||
|
import { LngLat } from 'maplibre-gl';
|
||||||
|
import { copyTextToClipboard } from '@scripts/common';
|
||||||
|
|
||||||
|
import autosize from 'autosize';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
appIcon,
|
||||||
|
appIconStack,
|
||||||
|
appButton,
|
||||||
|
projectMediaLink,
|
||||||
|
projectMapLink,
|
||||||
|
projectRelTime,
|
||||||
|
projectPostQuote,
|
||||||
|
projectPostSignature
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
options: Object
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
mouseOverHeader: false,
|
||||||
|
absTime: this.options.formatted_time,
|
||||||
|
absTimeLocal: this.options.formatted_time_local,
|
||||||
|
timeDiff: (this.options.formatted_time && this.options.formatted_time_local != this.options.formatted_time),
|
||||||
|
anchorVisible: ['message', 'media', 'post'].includes(this.options.type),
|
||||||
|
anchorTitle: this.lang.get('post.copy_to_clipboard'),
|
||||||
|
anchorIcon: 'link',
|
||||||
|
replyTitle: this.lang.get('post.reply'),
|
||||||
|
popupRequested: false,
|
||||||
|
mouseOverDrill: false,
|
||||||
|
postMessage: '',
|
||||||
|
quote: null,
|
||||||
|
sending: false,
|
||||||
|
focusZoomLevel: 15,
|
||||||
|
panAnimDuration: 500 //ms
|
||||||
|
};
|
||||||
|
},
|
||||||
|
inject: ['api', 'lang', 'project', 'feed', 'user', 'map', 'hash', 'consts', 'isMobile', 'getAnchor'],
|
||||||
|
computed: {
|
||||||
|
postClass() {
|
||||||
|
let sHeaderLess = this.options.headerless?' headerless':'';
|
||||||
|
return 'post-item '+this.options.type+sHeaderLess;
|
||||||
|
},
|
||||||
|
postId() {
|
||||||
|
return this.options.id?(this.options.type+'-'+this.options.id):'';
|
||||||
|
},
|
||||||
|
subType() {
|
||||||
|
return this.options.subtype || this.options.type;
|
||||||
|
},
|
||||||
|
displayedId() {
|
||||||
|
return this.options.displayed_id?(this.lang.get('feed.counter', this.options.displayed_id)):'';
|
||||||
|
},
|
||||||
|
drillMainIcon() {
|
||||||
|
return this.mouseOverDrill?'drill-message':'marker';
|
||||||
|
},
|
||||||
|
drillSubIcon() {
|
||||||
|
return this.mouseOverDrill?null:'footprint';
|
||||||
|
},
|
||||||
|
anchorLink() {
|
||||||
|
return this.getAnchor([this.hash.page, this.project.project.codename, this.options.type, this.options.id]);
|
||||||
|
},
|
||||||
|
modeHisto() {
|
||||||
|
return (this.project?.project?.mode == this.consts.modes.histo);
|
||||||
|
},
|
||||||
|
replyVisible() {
|
||||||
|
return this.anchorVisible && !this.modeHisto;
|
||||||
|
},
|
||||||
|
relTime() {
|
||||||
|
return this.modeHisto?
|
||||||
|
(this.options.formatted_time || '').substr(0, 10):
|
||||||
|
this.options.relative_time;
|
||||||
|
},
|
||||||
|
relatedMarker() {
|
||||||
|
//Find corresponding marker
|
||||||
|
if(!this.options.longitude && !this.options.latitude && this.options.type == 'media') {
|
||||||
|
return this.map.findMarkerByMediaId(this.options.id_media);
|
||||||
|
}
|
||||||
|
else if(
|
||||||
|
['message', 'media'].includes(this.options.type)
|
||||||
|
&& this.options.longitude
|
||||||
|
&& this.options.latitude
|
||||||
|
) {
|
||||||
|
return this.options;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
},
|
||||||
|
relatedMarkerLatLng() {
|
||||||
|
let oRelatedMarker = this.relatedMarker;
|
||||||
|
return new LngLat(oRelatedMarker.longitude, oRelatedMarker.latitude);
|
||||||
|
},
|
||||||
|
messageLines() {
|
||||||
|
return (this.options.content || '').split('\n');
|
||||||
|
},
|
||||||
|
quoteRef() {
|
||||||
|
return this.options.ref_item?this.buildQuote(this.options.ref_item):null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
buildQuote(oItem) {
|
||||||
|
let sContent = '', sImage = null;
|
||||||
|
switch(oItem.type) {
|
||||||
|
case 'post':
|
||||||
|
sContent = oItem.content || '';
|
||||||
|
break;
|
||||||
|
case 'media':
|
||||||
|
sContent = oItem.comment || this.lang.get('media.posted_on', oItem.posted_on_formatted_time);
|
||||||
|
sImage = oItem.thumb_path;
|
||||||
|
break;
|
||||||
|
case 'message':
|
||||||
|
sContent = oItem.lat_dms+' '+oItem.lon_dms;
|
||||||
|
sImage = oItem.static_img_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: oItem.type,
|
||||||
|
id: oItem.id,
|
||||||
|
author: oItem.formatted_name || '',
|
||||||
|
gravatar: oItem.gravatar || null,
|
||||||
|
content: sContent,
|
||||||
|
image: sImage
|
||||||
|
};
|
||||||
|
},
|
||||||
|
reply() {
|
||||||
|
this.feed.reply(this.buildQuote(this.options));
|
||||||
|
},
|
||||||
|
goToQuote() {
|
||||||
|
if(this.quoteRef) this.feed.findLinkedPost(this.quoteRef.type, this.quoteRef.id);
|
||||||
|
},
|
||||||
|
addQuote(oQuote) {
|
||||||
|
this.quote = oQuote;
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.post.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
formatQuote(oQuote) {
|
||||||
|
return (oQuote.author?oQuote.author+':\n':'')
|
||||||
|
+ oQuote.content.split('\n').map((sLine) => '> '+sLine).join('\n');
|
||||||
|
},
|
||||||
|
copyAnchor() {
|
||||||
|
copyTextToClipboard(this.consts.server+this.anchorLink);
|
||||||
|
this.anchorTitle = this.lang.get('post.link_copied');
|
||||||
|
this.anchorIcon = 'copied';
|
||||||
|
setTimeout(()=>{ //TODO animation
|
||||||
|
this.anchorTitle = this.lang.get('post.copy_to_clipboard');
|
||||||
|
this.anchorIcon = 'link';
|
||||||
|
}, 5000);
|
||||||
|
},
|
||||||
|
panMapToMarker(bCloseFeed=false) {
|
||||||
|
this.popupRequested = true;
|
||||||
|
|
||||||
|
if(bCloseFeed===true) this.feed.toggle(false);
|
||||||
|
this.hash.items = [this.project.project.codename, this.options.type, this.options.id];
|
||||||
|
|
||||||
|
return this.map.panToBetweenPanels(this.relatedMarkerLatLng, this.focusZoomLevel, this.panAnimDuration).then(() => {
|
||||||
|
this.openMarkerPopup();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onMouseEnter() {
|
||||||
|
this.mouseOverDrill = true;
|
||||||
|
this.openMarkerPopup();
|
||||||
|
},
|
||||||
|
onMouseLeave() {
|
||||||
|
this.mouseOverDrill = false;
|
||||||
|
this.closeMarkerPopup();
|
||||||
|
},
|
||||||
|
openMarkerPopup() {
|
||||||
|
const oRelatedMarker = this.relatedMarker;
|
||||||
|
if(oRelatedMarker && this.map.isMarkerVisible(this.relatedMarkerLatLng)) {
|
||||||
|
this.map.openMarkerPopup(oRelatedMarker.id, oRelatedMarker.type);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeMarkerPopup() {
|
||||||
|
if(!this.popupRequested) this.map.closePopup();
|
||||||
|
this.popupRequested = false;
|
||||||
|
},
|
||||||
|
send() {
|
||||||
|
if(this.postMessage != '' && this.user.name != '') {
|
||||||
|
this.sending = true;
|
||||||
|
this.api.post(
|
||||||
|
'add_post',
|
||||||
|
{
|
||||||
|
id_project: this.project.project.id,
|
||||||
|
name: this.user.name,
|
||||||
|
content: this.postMessage,
|
||||||
|
ref_type: this.quote?.type || '',
|
||||||
|
ref_id: this.quote?.id || 0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
this.postMessage = '';
|
||||||
|
this.quote = null;
|
||||||
|
this.feed.checkNewFeed();
|
||||||
|
this.sending = false;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.sending = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
executeMainAction() {
|
||||||
|
switch(this.options.type) {
|
||||||
|
case 'message':
|
||||||
|
return this.openMarkerPopup();
|
||||||
|
case 'media':
|
||||||
|
this.$refs.medialink.openMedia();
|
||||||
|
if(this.relatedMarker) return this.openMarkerPopup();
|
||||||
|
else return Promise.resolve();
|
||||||
|
default:
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
//Auto-adjust text area height
|
||||||
|
if(this.options.type == 'poster') autosize(this.$refs.post);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="postClass" :id="postId">
|
||||||
|
<div class="header" v-if="!options.headerless">
|
||||||
|
<div class="index">
|
||||||
|
<appIcon :icon="subType" :text="displayedId" width="auto" />
|
||||||
|
<a v-if="replyVisible" class="reply clickable" @click="reply" :title="replyTitle">
|
||||||
|
<appIcon :icon="'reply'" />
|
||||||
|
</a>
|
||||||
|
<a v-if="anchorVisible && !isMobile()" class="link" @click="copyAnchor" ref="anchor" :href="anchorLink" :title="anchorTitle">
|
||||||
|
<appIcon :icon="anchorIcon" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="time" @mouseleave="mouseOverHeader = false" @mouseover="mouseOverHeader = true" :title="timeDiff?lang.get('time.local', absTimeLocal):''">
|
||||||
|
<Transition name="fade" mode="out-in">
|
||||||
|
<span v-if="mouseOverHeader">{{ timeDiff?lang.get('time.user', absTime):absTime }}</span>
|
||||||
|
<span v-else>{{ relTime }}</span>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<div v-if="options.type == 'message'" class="body-box">
|
||||||
|
<div class="drill" @click.prevent="()=>{panMapToMarker(isMobile());}" @pointerenter="onMouseEnter" @pointerleave="onMouseLeave">
|
||||||
|
<span v-if="options.weather_icon && options.weather_icon!='unknown'" class="weather clickable" :title="lang.get('weather.'+options.weather_icon)">
|
||||||
|
<appIcon :icon="options.weather_icon" :text="Math.round(options.weather_temp)+'°C'" text-classes="temperature" />
|
||||||
|
</span>
|
||||||
|
<img class="staticmap clickable" :title="lang.get('media.click_zoom')" :src="options.static_img_url" />
|
||||||
|
<appIconStack mainClasses="message drill-icon" :iconMain="drillMainIcon" :iconSub="drillSubIcon" icon-sub-transform="rotate-270" />
|
||||||
|
<div class="comment" @click.stop>
|
||||||
|
<p v-if="!isMobile()">
|
||||||
|
<appIcon :icon="'coords'" margin="right" size="lg" />
|
||||||
|
<projectMapLink :options="options" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<projectRelTime :icon="'time'" :localTime="absTimeLocal" :siteTime="options.formatted_time" :offset="options.day_offset" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="options.type == 'media'" class="body-box" @pointerenter="onMouseEnter" @pointerleave="onMouseLeave">
|
||||||
|
<projectMediaLink :options="options" :type="'post'" ref="medialink" @opening-lightbox="panMapToMarker" />
|
||||||
|
</div>
|
||||||
|
<template v-else-if="options.type == 'post'">
|
||||||
|
<projectPostQuote v-if="quoteRef" :quote="quoteRef" class="clickable" @click="goToQuote" />
|
||||||
|
<div class="message">
|
||||||
|
<p v-for="(sLine, iIndex) in messageLines" :key="iIndex">{{ sLine }}</p>
|
||||||
|
</div>
|
||||||
|
<projectPostSignature :name="options.formatted_name" :gravatar="options.gravatar" />
|
||||||
|
</template>
|
||||||
|
<div v-else-if="options.type == 'poster'" class="poster-form">
|
||||||
|
<projectPostQuote v-if="quote" :quote="quote" />
|
||||||
|
<textarea ref="post" name="post" :placeholder="lang.get('post.message')" class="autoExpand" rows="1" v-model="postMessage"></textarea>
|
||||||
|
<div class="poster-actions">
|
||||||
|
<input type="text" name="name" :placeholder="lang.get('post.name')" v-model="user.name" />
|
||||||
|
<appButton name="submit" :aria-label="lang.get('action.send')" :title="lang.get('action.send')" :icon="'send'" @click="send()" :iconClasses="sending?'flicker':''" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template v-else-if="options.type == 'archived'">
|
||||||
|
<p><appIcon :icon="'success'" /></p>
|
||||||
|
<p>{{ lang.get('project.modes.histo') }}</p>
|
||||||
|
</template>
|
||||||
|
<p v-else-if="options.type == 'loading'" class="flicker">
|
||||||
|
<appIcon :icon="'post'" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<script>
|
||||||
|
import projectPostSignature from '@components/ProjectPostSignature';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
projectPostSignature
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
quote: Object
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="'quote '+quote.type">
|
||||||
|
<img v-if="quote.image" class="image" :src="quote.image" />
|
||||||
|
<div class="text">
|
||||||
|
<p class="content">{{ quote.content }}</p>
|
||||||
|
<projectPostSignature v-if="quote.author" :name="quote.author" :gravatar="quote.gravatar" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
name: String,
|
||||||
|
gravatar: String
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="signature">
|
||||||
|
<img v-if="gravatar" :src="'data:image/png;base64, '+gravatar" width="24" height="24" alt="--" />
|
||||||
|
<span v-else>-- </span>
|
||||||
|
<span>{{ name }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.signature {
|
||||||
|
text-align: right;
|
||||||
|
font-style: italic;
|
||||||
|
|
||||||
|
img {
|
||||||
|
vertical-align: baseline;
|
||||||
|
margin: 0 0.2em calc((1em - 24px)/2) 0;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<script>
|
||||||
|
import appIcon from '@components/AppIcon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
appIcon
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
localTime: String,
|
||||||
|
siteTime: String,
|
||||||
|
offset: String,
|
||||||
|
classes: String,
|
||||||
|
icon: String,
|
||||||
|
titleWrapperLangId: String
|
||||||
|
},
|
||||||
|
inject: ['lang'],
|
||||||
|
computed: {
|
||||||
|
title() {
|
||||||
|
const bDifferentTimeZone = (this.localTime != this.siteTime);
|
||||||
|
const sTime =
|
||||||
|
this.lang.get('time.user', this.siteTime.slice(-5))
|
||||||
|
+ ((this.offset != '0')?' ('+this.lang.get('unit.day_short')+this.offset+')':'');
|
||||||
|
|
||||||
|
return (this.titleWrapperLangId)?
|
||||||
|
this.lang.get(this.titleWrapperLangId, bDifferentTimeZone?sTime:this.siteTime)
|
||||||
|
:
|
||||||
|
(bDifferentTimeZone?sTime:null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<appIcon v-if="icon" :icon="icon" :title="title" :text="localTime" width="fixed" size="lg" />
|
||||||
|
<span v-else :class="classes" :title="title">{{ localTime }}</span>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<script>
|
||||||
|
import Simplebar from 'simplebar-vue';
|
||||||
|
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import ProjectAccount from '@components/ProjectAccount';
|
||||||
|
import logoIconUrl from '@images/icons/favicon.svg';
|
||||||
|
import logoTitleUrl from '@images/logo_title.svg';
|
||||||
|
import { createSwipeToClose, initialSwipeState } from '@scripts/swipeToClose';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AppIcon,
|
||||||
|
ProjectAccount,
|
||||||
|
Simplebar
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
projects: Array,
|
||||||
|
projectCodeName: String,
|
||||||
|
baseMaps: Array,
|
||||||
|
baseMap: String,
|
||||||
|
terrainEnabled: Boolean,
|
||||||
|
mapInitializing: Boolean,
|
||||||
|
hikes: Object
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isOpen: false,
|
||||||
|
lastUpdate: {unix_time: 0, relative_time: '', formatted_time: ''},
|
||||||
|
logoIconUrl,
|
||||||
|
logoTitleUrl,
|
||||||
|
swipe: initialSwipeState()
|
||||||
|
};
|
||||||
|
},
|
||||||
|
emits: ['update:baseMap', 'update:projectCodeName', 'update:terrainEnabled', 'toggle'],
|
||||||
|
inject: ['api', 'lang', 'user', 'consts', 'isMobile', 'hash'],
|
||||||
|
computed: {
|
||||||
|
project() {
|
||||||
|
return this.projects.find((project) => project.codename == this.projectCodeName);
|
||||||
|
},
|
||||||
|
projectCodeNameModel: {
|
||||||
|
get() {
|
||||||
|
return this.projectCodeName;
|
||||||
|
},
|
||||||
|
set(sProjectCodeName) {
|
||||||
|
this.$emit('update:projectCodeName', sProjectCodeName);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
baseMapModel: {
|
||||||
|
get() {
|
||||||
|
return this.baseMap;
|
||||||
|
},
|
||||||
|
set(sBaseMap) {
|
||||||
|
this.$emit('update:baseMap', sBaseMap);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
terrainEnabledModel: {
|
||||||
|
get() {
|
||||||
|
return this.terrainEnabled;
|
||||||
|
},
|
||||||
|
set(bTerrainEnabled) {
|
||||||
|
this.$emit('update:terrainEnabled', bTerrainEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
projectCodeName() {
|
||||||
|
this.setLastUpdate();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setLastUpdate();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async setLastUpdate() {
|
||||||
|
if(this.project?.mode == this.consts.modes.blog) {
|
||||||
|
this.lastUpdate = await this.api.get('last_update', {id_project: this.project.id});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggle(bShow, iAnimDuration=500) {
|
||||||
|
this.isOpen = (typeof bShow == 'boolean')?bShow:(!this.isOpen);
|
||||||
|
this.$emit('toggle', this.isOpen, iAnimDuration);
|
||||||
|
return this.isOpen;
|
||||||
|
},
|
||||||
|
getWidth() {
|
||||||
|
return this.$el.getBoundingClientRect().width;
|
||||||
|
},
|
||||||
|
...createSwipeToClose(-1)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div id="settings" class="panel panel-left" @touchstart.passive="onTouchStart" @touchmove.passive="onTouchMove" @touchend.passive="onTouchEnd">
|
||||||
|
<div id="settings-panel" class="panel-content">
|
||||||
|
<div class="settings-header settings-box">
|
||||||
|
<img :src="logoIconUrl" class="logo-icon clickable" :title="lang.get('project.overview')" @click="hash.items = []" />
|
||||||
|
<img :src="logoTitleUrl" class="logo-title" :alt="consts.title" />
|
||||||
|
<div class="last_update" v-if="project?.mode == consts.modes.blog && lastUpdate.unix_time > 0" :title="lastUpdate.formatted_time">
|
||||||
|
<AppIcon icon="find-me-spot" :text="lang.get('feed.last_update')+' '+lastUpdate.relative_time" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="settings-sections">
|
||||||
|
<Simplebar id="settings-sections-scrollbox">
|
||||||
|
<div class="settings-section settings-box">
|
||||||
|
<h1><AppIcon :icon="'project'" width="fixed" :text="lang.get('project.hikes')" /></h1>
|
||||||
|
<div class="settings-section-body">
|
||||||
|
<div class="radio" v-for="project in projects" :key="'project-'+project.id">
|
||||||
|
<input type="radio" :id="'project-'+project.id" :value="project.codename" v-model="projectCodeNameModel" :disabled="mapInitializing" />
|
||||||
|
<label :for="'project-'+project.id">
|
||||||
|
<span>{{ project.name }}</span>
|
||||||
|
<a v-if="!isMobile() && project.gpxfilepath" class="download" :href="project.gpxfilepath" :download="project.codename + '.gpx'" :title="lang.get('track.download')" @click.stop="()=>{}">
|
||||||
|
<AppIcon :icon="'download'" margin="left" />
|
||||||
|
</a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="settings-section settings-box">
|
||||||
|
<h1><AppIcon :icon="'map'" width="fixed" :text="lang.get('map.title')" /></h1>
|
||||||
|
<div class="settings-section-body">
|
||||||
|
<div class="radio" v-for="bm in baseMaps" :key="'map-'+bm.id_map">
|
||||||
|
<input type="radio" :id="'map-'+bm.id_map" :value="bm.codename" v-model="baseMapModel" :disabled="mapInitializing" />
|
||||||
|
<label :for="'map-'+bm.id_map">{{ lang.get('map.'+bm.codename) }}</label>
|
||||||
|
</div>
|
||||||
|
<div v-if="projectCodeName != 'overview'" class="radio">
|
||||||
|
<input type="checkbox" id="map-terrain" v-model="terrainEnabledModel" :disabled="mapInitializing" />
|
||||||
|
<label for="map-terrain">{{ lang.get('map.terrain') }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="settings-section settings-box account">
|
||||||
|
<h1><AppIcon :icon="'account'" width="fixed" :text="lang.get('account.title')" /></h1>
|
||||||
|
<div class="settings-section-body">
|
||||||
|
<ProjectAccount />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="settings-section settings-box admin" v-if="user.hasClearance(consts.clearances.admin)">
|
||||||
|
<h1><AppIcon :icon="'admin'" width="fixed" :text="lang.get('admin.title')" /></h1>
|
||||||
|
<div class="settings-section-body admin-actions">
|
||||||
|
<a class="button" href="#admin"><AppIcon :icon="'config'" :text="lang.get('admin.config')" /></a>
|
||||||
|
<a class="button" href="#upload"><AppIcon :icon="'upload'" :text="lang.get('admin.upload')" /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Simplebar>
|
||||||
|
</div>
|
||||||
|
<div v-if="!isMobile()" class="settings-footer">
|
||||||
|
<a href="https://git.lutran.fr/franzz/livetrail" :title="lang.get('credits.git')" target="_blank" rel="noopener">
|
||||||
|
<AppIcon :icon="'credits'" width="auto" :text="lang.get('credits.project', consts.title)" />
|
||||||
|
</a>
|
||||||
|
<span> {{ lang.get('credits.license') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div :class="'panel-control panel-control-'+(isMobile()?'bottom':'top')">
|
||||||
|
<div class="panel-control-elem panel-control-icon" @click="toggle">
|
||||||
|
<AppIcon :icon="isOpen?'prev':'menu'" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="project?.id && !isMobile()" id="legend" class="panel-control panel-control-bottom">
|
||||||
|
<div class="panel-control-elem">
|
||||||
|
<div v-for="(color, hikeType) in hikes.colors" :key="hikeType" class="track">
|
||||||
|
<span class="line" :style="'background-color:'+color+';'"></span>
|
||||||
|
<span class="desc">{{ lang.get('track.'+hikeType) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="project?.id" id="title" :class="'panel-control panel-control-'+(isMobile()?'bottom':'top')">
|
||||||
|
<div class="panel-control-elem"><span>{{ project.name }}</span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
<script>
|
||||||
|
import { markRaw } from 'vue';
|
||||||
|
import Uppy from '@uppy/core';
|
||||||
|
import XHRUpload from '@uppy/xhr-upload';
|
||||||
|
import '@uppy/core/css/style.min.css';
|
||||||
|
|
||||||
|
import AppIcon from '@components/AppIcon';
|
||||||
|
import AppButton from '@components/AppButton';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'upload',
|
||||||
|
components: { AppButton, AppIcon },
|
||||||
|
inject: ['api', 'lang', 'projects', 'consts', 'user', 'getPrevAnchor'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
project: this.projects.getDefaultProject(),
|
||||||
|
files: [],
|
||||||
|
logs: [],
|
||||||
|
progress: 0,
|
||||||
|
uppy: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if(!this.project.editable) {
|
||||||
|
this.addLog('upload.mode_archived', [this.project.name]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initUploader();
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if(this.uppy) {
|
||||||
|
this.uppy.destroy();
|
||||||
|
this.uppy = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addLog(sLangId = 'upload.error', asLangParams = []) {
|
||||||
|
this.logs.push({lang_id: sLangId, lang_params: asLangParams});
|
||||||
|
},
|
||||||
|
initUploader() {
|
||||||
|
const endpoint = `${this.consts.process_page}?a=upload`;
|
||||||
|
|
||||||
|
this.uppy = markRaw(new Uppy({
|
||||||
|
autoProceed: true,
|
||||||
|
restrictions: {
|
||||||
|
allowedFileTypes: ['.gif', '.jpg', '.jpeg', '.png', '.mov', '.mp4']
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.uppy.setMeta({t: this.user.timezone});
|
||||||
|
|
||||||
|
this.uppy.use(XHRUpload, {
|
||||||
|
endpoint,
|
||||||
|
fieldName: 'files[]',
|
||||||
|
formData: true,
|
||||||
|
headers: {'X-CSRF-Token': this.consts.csrf_token},
|
||||||
|
allowedMetaFields: ['t', 'name', 'type'],
|
||||||
|
getResponseData(xhr) {
|
||||||
|
return JSON.parse(xhr.responseText || '{}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.uppy.on('progress', (progress) => {
|
||||||
|
this.progress = progress;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.uppy.on('upload-success', (file, response) => {
|
||||||
|
const uploadedFiles = response?.body?.files || [];
|
||||||
|
uploadedFiles.forEach((uploadedFile) => {
|
||||||
|
const hasError = Object.prototype.hasOwnProperty.call(uploadedFile, 'error');
|
||||||
|
if(hasError) this.addLog(uploadedFile.desc_lang_id, uploadedFile.desc_lang_params);
|
||||||
|
else this.addLog('upload.success', [uploadedFile.original_name || uploadedFile.name]);
|
||||||
|
if(!hasError) this.files.push({...uploadedFile, content: ''});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.uppy.on('upload-error', (file, error, response) => {
|
||||||
|
this.addLog(response?.body?.desc_lang_id || 'upload.error', response?.body?.desc_lang_params || []);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.uppy.on('complete', () => {
|
||||||
|
this.progress = 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onFileChange(event) {
|
||||||
|
const files = Array.from(event.target.files || []);
|
||||||
|
if(files.length > 0 && this.uppy) this.uppy.addFiles(files.map((file) => ({source: 'local', name: file.name, type: file.type, data: file})));
|
||||||
|
event.target.value = '';
|
||||||
|
},
|
||||||
|
addComment(oFile) {
|
||||||
|
this.api.post('add_comment', {
|
||||||
|
id: oFile.id,
|
||||||
|
content: oFile.content
|
||||||
|
})
|
||||||
|
.then((asData) => {this.addLog('media.comment_update', [asData.filename]);})
|
||||||
|
.catch((oError) => {this.addLog(oError.desc_lang_id, oError.desc_lang_params);});
|
||||||
|
},
|
||||||
|
addPosition() {
|
||||||
|
if(navigator.geolocation) {
|
||||||
|
this.addLog('upload.position.determining');
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
(position) => {
|
||||||
|
this.addLog('upload.position.sending');
|
||||||
|
this.api.post('add_position', {
|
||||||
|
'latitude': position.coords.latitude,
|
||||||
|
'longitude': position.coords.longitude,
|
||||||
|
'timestamp': Math.round(position.timestamp / 1000)
|
||||||
|
})
|
||||||
|
.then(() => {this.addLog('upload.position.success');})
|
||||||
|
.catch((oError) => {this.addLog(oError.desc_lang_id, oError.desc_lang_params);});
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
const asErrorLangIds = {
|
||||||
|
1: 'upload.position.permission_denied',
|
||||||
|
2: 'upload.position.unavailable',
|
||||||
|
3: 'upload.position.timeout'
|
||||||
|
};
|
||||||
|
this.addLog(asErrorLangIds[error.code] || 'upload.position.error');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else this.addLog('upload.position.unsupported');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div id="upload">
|
||||||
|
<div class="section header">
|
||||||
|
<a name="back" class="button" :href="getPrevAnchor()"><AppIcon :icon="'back'" :text="lang.get('action.back')" /></a>
|
||||||
|
<h1>{{ this.project.name }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="section" v-if="project.editable">
|
||||||
|
<h2>{{ lang.get('upload.media.title') }}</h2>
|
||||||
|
<input id="fileupload" type="file" name="files[]" multiple accept=".gif,.jpg,.jpeg,.png,.mov,.mp4" @change="onFileChange" />
|
||||||
|
</div>
|
||||||
|
<div class="section progress" v-if="progress > 0">
|
||||||
|
<div class="total"></div>
|
||||||
|
<div class="bar" :style="{width:progress+'%'}"></div>
|
||||||
|
</div>
|
||||||
|
<div class="section comment" v-for="file in files" :key="file.id">
|
||||||
|
<img class="thumb" :src="file.thumbnail" />
|
||||||
|
<div class="form">
|
||||||
|
<input class="content" name="content" type="text" v-model="file.content" />
|
||||||
|
<input class="id" name="id" type="hidden" :value="file.id" />
|
||||||
|
<AppButton :classes="'save'" :icon="'save'" :text="lang.get('action.save')" @click="addComment(file)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="section location" v-if="project.editable">
|
||||||
|
<h2>{{ lang.get('upload.position.title') }}</h2>
|
||||||
|
<AppButton :icon="'marker'" :text="lang.get('upload.position.new')" @click="addPosition()" />
|
||||||
|
</div>
|
||||||
|
<div class="section logs" v-if="logs.length > 0">
|
||||||
|
<p class="log" v-for="(log, index) in logs" :key="index">{{ lang.get(log.lang_id, log.lang_params) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
<script>
|
|
||||||
import SpotButton from './spotButton.vue';
|
|
||||||
import AdminInput from './adminInput.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
SpotButton,
|
|
||||||
AdminInput
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
elems: {},
|
|
||||||
feedbacks: []
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: ['spot'],
|
|
||||||
methods: {
|
|
||||||
l(id) {
|
|
||||||
return this.spot.lang(id);
|
|
||||||
},
|
|
||||||
async setProjects() {
|
|
||||||
let aoElemTypes = await this.spot.get2('admin_get');
|
|
||||||
|
|
||||||
for(const [sType, aoElems] of Object.entries(aoElemTypes)) {
|
|
||||||
this.elems[sType] = {};
|
|
||||||
for(const [iKey, oElem] of Object.entries(aoElems)) {
|
|
||||||
oElem.type = sType;
|
|
||||||
this.elems[sType][oElem.id] = oElem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
createElem(sType) {
|
|
||||||
this.spot.get2('admin_create', {type: sType})
|
|
||||||
.then((aoNewElemTypes) => {
|
|
||||||
console.log(aoNewElemTypes);
|
|
||||||
for(const [sType, aoNewElems] of Object.entries(aoNewElemTypes)) {
|
|
||||||
for(const [iKey, oNewElem] of Object.entries(aoNewElems)) {
|
|
||||||
oNewElem.type = sType;
|
|
||||||
this.elems[sType][oNewElem.id] = oNewElem;
|
|
||||||
this.spot.onFeedback('success', this.spot.lang('admin_create_success'), {'create':sType});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((sMsg) => {console.log(sMsg);this.spot.onFeedback('error', sMsg, {'create':sType});});
|
|
||||||
},
|
|
||||||
deleteElem(oElem) {
|
|
||||||
const asInputs = {
|
|
||||||
type: oElem.type,
|
|
||||||
id: oElem.id
|
|
||||||
};
|
|
||||||
|
|
||||||
this.spot.get(
|
|
||||||
'admin_delete',
|
|
||||||
(asData) => {
|
|
||||||
delete this.elems[asInputs.type][asInputs.id];
|
|
||||||
this.spot.onFeedback('success', this.spot.lang('admin_delete_success'), asInputs);
|
|
||||||
},
|
|
||||||
asInputs,
|
|
||||||
(sError) => {
|
|
||||||
this.spot.onFeedback('error', sError, asInputs);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
updateElem(oElem, oEvent) {
|
|
||||||
if(typeof this.spot.tmp('wait') != 'undefined') clearTimeout(this.spot.tmp('wait'));
|
|
||||||
|
|
||||||
let sOldVal = this.elems[oElem.type][oElem.id][oEvent.target.name];
|
|
||||||
let sNewVal = oEvent.target.value;
|
|
||||||
if(sOldVal != sNewVal) {
|
|
||||||
let asInputs = {
|
|
||||||
type: oElem.type,
|
|
||||||
id: oElem.id,
|
|
||||||
field: oEvent.target.name,
|
|
||||||
value: sNewVal
|
|
||||||
};
|
|
||||||
|
|
||||||
this.spot.get2('admin_set', asInputs)
|
|
||||||
.then((asData) => {
|
|
||||||
this.elems[oElem.type][oElem.id][oEvent.target.name] = sNewVal;
|
|
||||||
this.spot.onFeedback('success', this.spot.lang('admin_save_success'), asInputs);
|
|
||||||
})
|
|
||||||
.catch((sError) => {
|
|
||||||
oEvent.target.value = sOldVal;
|
|
||||||
this.spot.onFeedback('error', sError, asInputs);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
queue(oElem, oEvent) {
|
|
||||||
if(typeof this.spot.tmp('wait') != 'undefined') clearTimeout(this.spot.tmp('wait'));
|
|
||||||
this.spot.tmp('wait', setTimeout(() => {this.updateElem(oElem, oEvent);}, 2000));
|
|
||||||
},
|
|
||||||
updateProject() {
|
|
||||||
this.spot.get2('update_project')
|
|
||||||
.then((asData, sMsg) => {this.spot.onFeedback('success', sMsg, {'update':'project'});})
|
|
||||||
.catch((sMsg) => {this.spot.onFeedback('error', sMsg, {'update':'project'});});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.spot.addPage('admin', {
|
|
||||||
onFeedback: (sType, sMsg, asContext) => {
|
|
||||||
delete asContext.a;
|
|
||||||
delete asContext.t;
|
|
||||||
sMsg += ' (';
|
|
||||||
for(const [sKey, sElem] of Object.entries(asContext)) {
|
|
||||||
sMsg += sKey+'='+sElem+' / ' ;
|
|
||||||
}
|
|
||||||
sMsg = sMsg.slice(0, -3)+')';
|
|
||||||
|
|
||||||
this.feedbacks.push({type:sType, msg:sMsg});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.setProjects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div id="admin">
|
|
||||||
<a name="back" class="button" href="#project"><i class="fa fa-back push"></i>{{ l('nav_back') }}</a>
|
|
||||||
<h1>{{ l('projects') }}</h1>
|
|
||||||
<div id="project_section">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{{ l('id_project') }}</th>
|
|
||||||
<th>{{ l('project') }}</th>
|
|
||||||
<th>{{ l('mode') }}</th>
|
|
||||||
<th>{{ l('code_name') }}</th>
|
|
||||||
<th>{{ l('start') }}</th>
|
|
||||||
<th>{{ l('end') }}</th>
|
|
||||||
<th>{{ l('delete') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="project in elems.project">
|
|
||||||
<td>{{ project.id }}</td>
|
|
||||||
<td><AdminInput :type="'text'" :name="'name'" :elem="project" /></td>
|
|
||||||
<td>{{ project.mode }}</td>
|
|
||||||
<td><AdminInput :type="'text'" :name="'codename'" :elem="project" /></td>
|
|
||||||
<td><AdminInput :type="'date'" :name="'active_from'" :elem="project" /></td>
|
|
||||||
<td><AdminInput :type="'date'" :name="'active_to'" :elem="project" /></td>
|
|
||||||
<td><SpotButton :iconClass="'close fa-lg'" @click="deleteElem(project)" /></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<SpotButton :buttonClass="'new'" :buttonText="l('new_project')" :iconClass="'new'" @click="createElem('project')" />
|
|
||||||
</div>
|
|
||||||
<h1>{{ l('feeds') }}</h1>
|
|
||||||
<div id="feed_section">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{{ l('id_feed') }}</th>
|
|
||||||
<th>{{ l('ref_feed_id') }}</th>
|
|
||||||
<th>{{ l('id_spot') }}</th>
|
|
||||||
<th>{{ l('id_project') }}</th>
|
|
||||||
<th>{{ l('name') }}</th>
|
|
||||||
<th>{{ l('status') }}</th>
|
|
||||||
<th>{{ l('last_update') }}</th>
|
|
||||||
<th>{{ l('delete') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="feed in elems.feed">
|
|
||||||
<td>{{ feed.id }}</td>
|
|
||||||
<td><AdminInput :type="'text'" :name="'ref_feed_id'" :elem="feed" /></td>
|
|
||||||
<td><AdminInput :type="'number'" :name="'id_spot'" :elem="feed" /></td>
|
|
||||||
<td><AdminInput :type="'number'" :name="'id_project'" :elem="feed" /></td>
|
|
||||||
<td>{{ feed.name }}</td>
|
|
||||||
<td>{{ feed.status }}</td>
|
|
||||||
<td>{{ feed.last_update }}</td>
|
|
||||||
<td><SpotButton :iconClass="'close fa-lg'" @click="deleteElem(feed)" /></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<SpotButton :buttonClass="'new'" :buttonText="l('new_feed')" :iconClass="'new'" @click="createElem('feed')" />
|
|
||||||
</div>
|
|
||||||
<h1>Spots</h1>
|
|
||||||
<div id="spot_section">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{{ l('id_spot') }}</th>
|
|
||||||
<th>{{ l('ref_spot_id') }}</th>
|
|
||||||
<th>{{ l('name') }}</th>
|
|
||||||
<th>{{ l('model') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="spot in elems.spot">
|
|
||||||
<td>{{ spot.id }}</td>
|
|
||||||
<td>{{ spot.ref_spot_id }}</td>
|
|
||||||
<td>{{ spot.name }}</td>
|
|
||||||
<td>{{ spot.model }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<h1>{{ l('active_users') }}</h1>
|
|
||||||
<div id="user_section">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{{ l('id_user') }}</th>
|
|
||||||
<th>{{ l('user_name') }}</th>
|
|
||||||
<th>{{ l('language') }}</th>
|
|
||||||
<th>{{ l('time_zone') }}</th>
|
|
||||||
<th>{{ l('clearance') }}</th>
|
|
||||||
<th>{{ l('delete') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="user in elems.user">
|
|
||||||
<td>{{ user.id }}</td>
|
|
||||||
<td>{{ user.name }}</td>
|
|
||||||
<td>{{ user.language }}</td>
|
|
||||||
<td>{{ user.timezone }}</td>
|
|
||||||
<td><AdminInput :type="'number'" :name="'clearance'" :elem="user" /></td>
|
|
||||||
<td><SpotButton :iconClass="'close fa-lg'" @click="deleteElem(user)" /></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<h1>{{ l('toolbox') }}</h1>
|
|
||||||
<div id="toolbox">
|
|
||||||
<SpotButton :buttonClass="'refresh'" :buttonText="l('update_project')" :iconClass="'refresh'" @click="updateProject" />
|
|
||||||
</div>
|
|
||||||
<div id="feedback" class="feedback">
|
|
||||||
<p v-for="feedback in feedbacks" :class="feedback.type">{{ feedback.msg }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<script>
|
|
||||||
//Leaflet
|
|
||||||
import 'leaflet';
|
|
||||||
import 'leaflet-geometryutil';
|
|
||||||
import 'leaflet.heightgraph';
|
|
||||||
import '../scripts/leaflet.helpers';
|
|
||||||
import { LMap, LTileLayer } from "@vue-leaflet/vue-leaflet";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
LMap,
|
|
||||||
LTileLayer
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
server: this.spot.consts.server,
|
|
||||||
zoom: 13
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: ['spot'],
|
|
||||||
mounted() {
|
|
||||||
if(this.$parent.hash.items.length==0) this.$parent.setHash(this.$parent.hash.page, [this.spot.vars('default_project_codename')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div id="projects">
|
|
||||||
<div id="background"></div>
|
|
||||||
<div id="submap">
|
|
||||||
<div class="loader fa fa-fw fa-map flicker" id="map_loading"></div>
|
|
||||||
</div>
|
|
||||||
<div id="map">
|
|
||||||
<l-map ref="map" v-model:zoom="zoom" :center="[47.41322, -1.219482]">
|
|
||||||
<l-tile-layer
|
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
||||||
layer-type="base"
|
|
||||||
name="OpenStreetMap"
|
|
||||||
></l-tile-layer>
|
|
||||||
</l-map>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="mobile" class="mobile"></div>
|
|
||||||
</template>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<script>
|
|
||||||
import SpotIcon from './spotIcon.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
SpotIcon
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
buttonClass: String,
|
|
||||||
buttonText: String,
|
|
||||||
iconClass: String
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
margin: !!this.buttonText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<button :class="buttonClass"><SpotIcon :iconClass="iconClass" :margin="margin" />{{ buttonText }}</button>
|
|
||||||
</template>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
iconClass: String,
|
|
||||||
margin: Boolean,
|
|
||||||
otherClasses: String
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
classNames: 'fa fa-'+this.iconClass+(this.margin?' push':'')+(this.otherClasses?' '+this.otherClasses:'')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<i :class="classNames"></i>
|
|
||||||
</template>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 10 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user