Deuxième jet POI avec cohérence globale mais formulaire pas vraiment envoyé

This commit is contained in:
leosw
2026-01-18 15:09:42 +01:00
parent 397f8b770a
commit 69ab7ce1fb
4 changed files with 44 additions and 9 deletions

View File

@@ -18,11 +18,13 @@ switch ($controller->splitted_url[1]) {
$poi->lon = $_POST['lon']; $poi->lon = $_POST['lon'];
$poi->ele = $_POST['ele']; $poi->ele = $_POST['ele'];
$poi->author = $user->id; $poi->author = $user->id;
$poi->source = "k"; $poi->source = "kab";
$poi->is_commentable = isset($_POST['is_commentable'])?'t':'f';
$poi->parameters = '';
if(!$poi->checkPermalink($_POST['permalink'],1)) { if(!$poi->checkPermalink($_POST['permalink'],1)) {
$poi->permalink = $_POST['permalink']; $poi->permalink = $_POST['permalink'];
$poi->insert(); $poi->insert();
header('Location: '.$config['rel_root_folder']."blog/".$poi->permalink); header('Location: '.$config['rel_root_folder']."poi/".$poi->permalink);
} }
else { else {
$head['title'] = $poi->name; $head['title'] = $poi->name;

View File

@@ -109,15 +109,17 @@ class Poi
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass']) $con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n"); or die ("Could not connect to server\n");
$query = "INSERT INTO contents (is_public, permalink, creation_date, name, type, poi_type) VALUES pg_query($con, "BEGIN");
(TRUE, $1, $2, $3, $4, $5) RETURNING id";
$query = "INSERT INTO contents (is_commentable, is_public, permalink, creation_date, name, type, poi_type) VALUES
($1, TRUE, $2, $3, $4, $5, $6) RETURNING id";
pg_prepare($con, "prepare1", $query) pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n"); or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->permalink, date('r'), $this->name, $this->type, $this->poi_type)) $result = pg_execute($con, "prepare1", array($this->is_commentable, $this->permalink, date('r'), $this->name, $this->type, $this->poi_type))
or die ("Cannot execute statement\n"); or die ("Cannot execute statement\n");
$this->poi_id = pg_fetch_assoc($result)['id']; $this->content_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_locales (content_id, locale, author) VALUES $query = "INSERT INTO content_locales (content_id, locale, author) VALUES
($1, $2, $3) RETURNING id"; ($1, $2, $3) RETURNING id";
@@ -151,11 +153,13 @@ class Poi
$query = "INSERT INTO content_contributors (content, contributor) VALUES $query = "INSERT INTO content_contributors (content, contributor) VALUES
($1, $2)"; ($1, $2)";
pg_prepare($con, "prepare4", $query) pg_prepare($con, "prepare5", $query)
or die ("Cannot prepare statement\n"); or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare4", array($this->locale_id, $user->id)) $result = pg_execute($con, "prepare5", array($this->locale_id, $user->id))
or die ("Cannot execute statement\n"); or die ("Cannot execute statement\n");
pg_query($con, "COMMIT");
pg_close($con); pg_close($con);
error_log( error_log(

View File

@@ -162,6 +162,30 @@ form.form input[type=radio]+label img {
font-style: italic; font-style: italic;
} }
form.form input[type="checkbox"] {
display:none;
}
form.form input[type="checkbox"] + span:before {
font-family: "Font Awesome 5 Free";
font-weight: 400;
vertical-align: middle;
padding: 2px 5px 2px 4px;
margin-right: 10px;
display: inline-block;
width: 21px;
background: #ddd;
font-size: 25px;
}
form.form input[type="checkbox"] + span:before {
content: "\f0c8"; /* check-empty */
}
form.form input[type="checkbox"]:checked + span:before {
content: "\f14a"; /* check */
}
#permalink_container { #permalink_container {
position: relative; position: relative;
margin: 2px 0; margin: 2px 0;

View File

@@ -123,10 +123,15 @@
<p id="abstract"></p> <p id="abstract"></p>
<div id="specific_form"></div> <div id="specific_form"></div>
<label for="is_commentable">
<input type="checkbox" name="is_commentable" id="is_commentable" />
<span>Autoriser les commentaires</span>
</label>
<? if(isset($new) AND $new==1) { ?> <? if(isset($new) AND $new==1) { ?>
<div id="permalink_container"> <div id="permalink_container">
<label id="permalink_label" for="permalink"><?=$config['web_root_folder']?>poi/</label> <label id="permalink_label" for="permalink"><?=$config['web_root_folder']?>poi/</label>
<input type="text" name="permalink" id="permalink" placeholder="URL"> <input type="text" name="permalink" id="permalink" placeholder="URL" required>
</div> </div>
<? } ?> <? } ?>