Compare commits

...

8 Commits
master ... v1

  1. 177
      base/gis.php
  2. 223
      base/gis_upgrade.php
  3. 341
      formulaires/article_gis.php
  4. 163
      formulaires/editer_gis.php
  5. 27
      gis_options.php
  6. 161
      gis_pipeline.php
  7. 13
      inc/cambiar_coordenadas.php
  8. 447
      inc/parte_privada.php
  9. 39
      lang/gis_en.php
  10. 109
      lang/gis_es.php
  11. 113
      lang/gis_fr.php
  12. 113
      lang/gis_gl.php
  13. 46
      plugin.xml

177
base/gis.php

@ -1,89 +1,90 @@
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
global $tables_principales;
global $tables_auxiliaires;
//taboa gis ------------------------------------------
$spip_gis = array(
"id_gis" => "bigint(21) NOT NULL",
"id_article" => "int(11) NULL NULL",
"id_rubrique" => "int(11) NULL NULL",
"lat" => "float(21) NULL NULL",
"lonx" => "float(21) NULL NULL",
"zoom" => "tinyint(4) NULL NULL",
"pays" => "text NOT NULL DEFAULT ''",
"code_pays" => "varchar(255) NOT NULL DEFAULT ''",
"region" => "text NOT NULL DEFAULT ''",
"ville" => "text NOT NULL DEFAULT ''",
"code_postal" => "varchar(255) NOT NULL DEFAULT ''"
);
$spip_gis_key = array(
"PRIMARY KEY" => "id_gis",
"KEY id_article" => "id_article",
"KEY id_rubrique" => "id_rubrique"
);
$spip_gis_join = array(
"id_article"=>"id_article",
"id_rubrique"=>"id_rubrique",
);
$tables_principales['spip_gis'] = array(
'field' => &$spip_gis,
'key' => &$spip_gis_key,
'joint' => &$spip_gis_join
);
//------------------------------------------------------
//taboa gis_mots --------------------------------------
$spip_gis_mots = array(
"id_gis" => "bigint(21) NOT NULL",
"id_mot" => "int(11) NULL NULL",
"lat" => "float(21) NULL NULL",
"lonx" => "float(21) NULL NULL",
"zoom" => "tinyint(4) NULL NULL"
);
$spip_gis_mots_key = array(
"PRIMARY KEY" => "id_gis",
"KEY id_mot" => "id_mot"
);
$spip_gis_mots_join = array(
"id_mot"=>"id_mot"
);
$tables_principales['spip_gis_mots'] = array(
'field' => &$spip_gis_mots,
'key' => &$spip_gis_mots_key,
'joint' => &$spip_gis_most_join
);
//------------------------------------------------------
//on ajoute les kml à la table spip_types_documents --------------------------------------
$res = spip_query("SELECT extension FROM spip_types_documents WHERE extension='kml'");
if (!$row = spip_fetch_array($res))
spip_query("INSERT INTO `spip_types_documents` ( `id_type` , `titre` , `descriptif` , `extension` , `mime_type` , `inclus` , `upload` , `maj` ) VALUES ('', 'Google Earth Placemark', '', 'kml', 'application/vnd.google-earth.kml+xml', 'non', 'oui', NOW( ));");
//-- Relaci—ns ----------------------------------------------------
global $table_des_tables;
$table_des_tables['gis']='gis';
$table_des_tables['gis_config']='gis_config';
$table_des_tables['gis_mots']='gis_mots';
//-- Jointures ----------------------------------------------------
//Les jointures sont pas necessaires parce que le champs a utiliser comme criteres sont dejà
//dans les tables de GIS
//global $tables_jointures;
//$tables_jointures['spip_articles'][]= 'gis';
//$tables_jointures['spip_gis'][] = 'articles';
//$tables_jointures['spip_rubriques'][]= 'gis';
//$tables_jointures['spip_gis'][] = 'rubriques';
//$tables_jointures['spip_mots'][]= 'gis_mots';
//$tables_jointures['spip_gis_mots'][] = 'mots';
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
global $tables_principales;
global $tables_auxiliaires;
//taboa gis ------------------------------------------
$spip_gis = array(
"id_gis" => "bigint(21) NOT NULL",
"id_article" => "int(11) NULL NULL",
"id_rubrique" => "int(11) NULL NULL",
"lat" => "float(21) NULL NULL",
"lonx" => "float(21) NULL NULL",
"zoom" => "tinyint(4) NULL NULL",
"pays" => "text NOT NULL DEFAULT ''",
"code_pays" => "varchar(255) NOT NULL DEFAULT ''",
"region" => "text NOT NULL DEFAULT ''",
"ville" => "text NOT NULL DEFAULT ''",
"code_postal" => "varchar(255) NOT NULL DEFAULT ''"
);
$spip_gis_key = array(
"PRIMARY KEY" => "id_gis",
"KEY id_article" => "id_article",
"KEY id_rubrique" => "id_rubrique"
);
$spip_gis_join = array(
"id_article"=>"id_article",
"id_rubrique"=>"id_rubrique",
);
$tables_principales['spip_gis'] = array(
'field' => &$spip_gis,
'key' => &$spip_gis_key,
'joint' => &$spip_gis_join
);
//------------------------------------------------------
//taboa gis_mots --------------------------------------
$spip_gis_mots = array(
"id_gis" => "bigint(21) NOT NULL",
"id_mot" => "int(11) NULL NULL",
"lat" => "float(21) NULL NULL",
"lonx" => "float(21) NULL NULL",
"zoom" => "tinyint(4) NULL NULL"
);
$spip_gis_mots_key = array(
"PRIMARY KEY" => "id_gis",
"KEY id_mot" => "id_mot"
);
$spip_gis_mots_join = array(
"id_mot"=>"id_mot"
);
$tables_principales['spip_gis_mots'] = array(
'field' => &$spip_gis_mots,
'key' => &$spip_gis_mots_key,
'joint' => &$spip_gis_most_join
);
//------------------------------------------------------
//on ajoute les kml à la table spip_types_documents --------------------------------------
$res = spip_query("SELECT extension FROM spip_types_documents WHERE extension='kml'");
if (!$row = spip_fetch_array($res))
spip_query("INSERT INTO `spip_types_documents` ( `id_type` , `titre` , `descriptif` , `extension` , `mime_type` , `inclus` , `upload` , `maj` ) VALUES ('', 'Google Earth Placemark', '', 'kml', 'application/vnd.google-earth.kml+xml', 'non', 'oui', NOW( ));");
//-- Relaci—ns ----------------------------------------------------
global $table_des_tables;
$table_des_tables['gis']='gis';
$table_des_tables['gis_config']='gis_config';
$table_des_tables['gis_mots']='gis_mots';
//-- Jointures ----------------------------------------------------
//Les jointures sont pas necessaires parce que le champs a utiliser comme criteres sont dejà
//dans les tables de GIS
//global $tables_jointures;
//$tables_jointures['spip_articles'][]= 'gis';
//$tables_jointures['spip_gis'][] = 'articles';
//$tables_jointures['spip_rubriques'][]= 'gis';
//$tables_jointures['spip_gis'][] = 'rubriques';
//$tables_jointures['spip_mots'][]= 'gis_mots';
//$tables_jointures['spip_gis_mots'][] = 'mots';
?>

223
base/gis_upgrade.php

@ -1,111 +1,112 @@
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
include_spip('inc/meta');
function gis_upgrade($nom_meta_base_version,$version_cible){
$current_version = 0.0;
if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
|| (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
if ($current_version==0.0){
include_spip('base/gis');
include_spip('base/create');
creer_base();
ecrire_meta($nom_meta_base_version,$current_version=$version_cible);
}
if (version_compare($current_version,"0.1.1","<")){
spip_query("ALTER TABLE spip_gis ADD INDEX ( id_article )");
ecrire_meta($nom_meta_base_version,$current_version="0.1.1");
}
if (version_compare($current_version,"0.1.2","<")){
$key = "";
$res = spip_query("SELECT name, value FROM spip_gis_config WHERE name='googlemapkey'");
if ($row = spip_fetch_array($res))
$key = $row['value'];
ecrire_meta('geomap_googlemapkey',$key);
spip_query("DROP TABLE spip_gis_config");
ecrire_meta($nom_meta_base_version,$current_version="0.1.2");
}
if (version_compare($current_version,"0.1.3","<")){
spip_query("CREATE TABLE `spip_gis_mots` (
`id_gis` bigint(21) NOT NULL auto_increment,
`id_mot` int(11) default NULL,
`lat` float default NULL,
`lonx` float default NULL,
`zoom` tinyint(4) default NULL,
PRIMARY KEY (`id_gis`)
)");
ecrire_meta($nom_meta_base_version,$current_version="0.1.3");
}
if (version_compare($current_version,"0.1.4","<")){
$res = spip_query("SELECT extension FROM spip_types_documents WHERE extension='kml'");
if (!$row = spip_fetch_array($res))
spip_query("INSERT INTO `spip_types_documents` ( `id_type` , `titre` , `descriptif` , `extension` , `mime_type` , `inclus` , `upload` , `maj` ) VALUES ('', 'Google Earth Placemark', '', 'kml', 'application/vnd.google-earth.kml+xml', 'non', 'oui', NOW( ));");
ecrire_meta($nom_meta_base_version,$current_version="0.1.4");
}
if (version_compare($current_version,"0.1.5","<")){
spip_query("ALTER TABLE spip_gis ADD id_rubrique int(11) NULL NULL AFTER id_article");
spip_query("ALTER TABLE spip_gis ADD INDEX ( id_rubrique )");
ecrire_meta($nom_meta_base_version,$current_version="0.1.5");
}
/*esto es para realizar los cambios de nombre de variables*/
if (version_compare($current_version,"0.1.6","<")){
$value = "";
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_lat'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_lat',$value);
} else {
effacer_meta('gis_default_lat');
}
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_lonx'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_lonx',$value);
} else {
effacer_meta('gis_default_lonx');
}
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_zoom'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_zoom',$value);
} else {
effacer_meta('gis_default_zoom');
}
effacer_meta("geomap_default_lat");
effacer_meta("geomap_default_lonx");
effacer_meta("geomap_default_zoom");
ecrire_meta('gis_map', 'no');
spip_query("ALTER TABLE spip_gis ADD zoom int(4) NULL NULL AFTER lonx");
ecrire_meta($nom_meta_base_version,$current_version="0.1.6");
}
if (version_compare($current_version,"0.1.7","<")){
spip_query("ALTER TABLE spip_gis ADD pays text NOT NULL DEFAULT '' AFTER zoom");
spip_query("ALTER TABLE spip_gis ADD code_pays varchar(255) NOT NULL DEFAULT '' AFTER pays");
spip_query("ALTER TABLE spip_gis ADD region text NOT NULL DEFAULT '' AFTER code_pays");
spip_query("ALTER TABLE spip_gis ADD ville text NOT NULL DEFAULT '' AFTER region");
spip_query("ALTER TABLE spip_gis ADD code_postal varchar(255) NOT NULL DEFAULT '' AFTER ville");
ecrire_meta($nom_meta_base_version,$current_version="0.1.7");
}
/*se encaga de trasladar las variables generales de geomap a gis*/
ecrire_metas();
}
}
function gis_vider_tables($nom_meta_base_version) {
spip_query("DROP TABLE spip_gis");
spip_query("DROP TABLE spip_gis_mots");
effacer_meta($nom_meta_base_version);
ecrire_metas();
}
?>
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/meta');
function gis_upgrade($nom_meta_base_version,$version_cible){
$current_version = 0.0;
if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
|| (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
if ($current_version==0.0){
include_spip('base/gis');
include_spip('base/create');
creer_base();
ecrire_meta($nom_meta_base_version,$current_version=$version_cible);
}
if (version_compare($current_version,"0.1.1","<")){
spip_query("ALTER TABLE spip_gis ADD INDEX ( id_article )");
ecrire_meta($nom_meta_base_version,$current_version="0.1.1");
}
if (version_compare($current_version,"0.1.2","<")){
$key = "";
$res = spip_query("SELECT name, value FROM spip_gis_config WHERE name='googlemapkey'");
if ($row = spip_fetch_array($res))
$key = $row['value'];
ecrire_meta('geomap_googlemapkey',$key);
spip_query("DROP TABLE spip_gis_config");
ecrire_meta($nom_meta_base_version,$current_version="0.1.2");
}
if (version_compare($current_version,"0.1.3","<")){
spip_query("CREATE TABLE `spip_gis_mots` (
`id_gis` bigint(21) NOT NULL auto_increment,
`id_mot` int(11) default NULL,
`lat` float default NULL,
`lonx` float default NULL,
`zoom` tinyint(4) default NULL,
PRIMARY KEY (`id_gis`)
)");
ecrire_meta($nom_meta_base_version,$current_version="0.1.3");
}
if (version_compare($current_version,"0.1.4","<")){
$res = spip_query("SELECT extension FROM spip_types_documents WHERE extension='kml'");
if (!$row = spip_fetch_array($res))
spip_query("INSERT INTO `spip_types_documents` ( `id_type` , `titre` , `descriptif` , `extension` , `mime_type` , `inclus` , `upload` , `maj` ) VALUES ('', 'Google Earth Placemark', '', 'kml', 'application/vnd.google-earth.kml+xml', 'non', 'oui', NOW( ));");
ecrire_meta($nom_meta_base_version,$current_version="0.1.4");
}
if (version_compare($current_version,"0.1.5","<")){
spip_query("ALTER TABLE spip_gis ADD id_rubrique int(11) NULL NULL AFTER id_article");
spip_query("ALTER TABLE spip_gis ADD INDEX ( id_rubrique )");
ecrire_meta($nom_meta_base_version,$current_version="0.1.5");
}
/*esto es para realizar los cambios de nombre de variables*/
if (version_compare($current_version,"0.1.6","<")){
$value = "";
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_lat'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_lat',$value);
} else {
effacer_meta('gis_default_lat');
}
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_lonx'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_lonx',$value);
} else {
effacer_meta('gis_default_lonx');
}
$res = spip_query("SELECT name, value FROM spip_meta WHERE name='geomap_default_zoom'");
if ($row = spip_fetch_array($res)) {
$value = $row['value'];
ecrire_meta('gis_default_zoom',$value);
} else {
effacer_meta('gis_default_zoom');
}
effacer_meta("geomap_default_lat");
effacer_meta("geomap_default_lonx");
effacer_meta("geomap_default_zoom");
ecrire_meta('gis_map', 'no');
spip_query("ALTER TABLE spip_gis ADD zoom int(4) NULL NULL AFTER lonx");
ecrire_meta($nom_meta_base_version,$current_version="0.1.6");
}
if (version_compare($current_version,"0.1.7","<")){
spip_query("ALTER TABLE spip_gis ADD pays text NOT NULL DEFAULT '' AFTER zoom");
spip_query("ALTER TABLE spip_gis ADD code_pays varchar(255) NOT NULL DEFAULT '' AFTER pays");
spip_query("ALTER TABLE spip_gis ADD region text NOT NULL DEFAULT '' AFTER code_pays");
spip_query("ALTER TABLE spip_gis ADD ville text NOT NULL DEFAULT '' AFTER region");
spip_query("ALTER TABLE spip_gis ADD code_postal varchar(255) NOT NULL DEFAULT '' AFTER ville");
ecrire_meta($nom_meta_base_version,$current_version="0.1.7");
}
/*se encaga de trasladar las variables generales de geomap a gis*/
ecrire_metas();
}
}
function gis_vider_tables($nom_meta_base_version) {
spip_query("DROP TABLE spip_gis");
spip_query("DROP TABLE spip_gis_mots");
effacer_meta($nom_meta_base_version);
ecrire_metas();
}
?>

341
formulaires/article_gis.php

@ -1,171 +1,172 @@
<?php
include_spip('inc/session');
include_spip('inc/securiser_action');
include_spip('public/assembler');
function formulaires_article_gis_charger_dist(){
$valeurs = array(
'titre'=>'',
'texte'=>'',
'lat'=>'',
'lonx'=>'',
'editable'=>true
);
// si on a pas de rubrique, on n'edite pas le formulaire !
if (!$id_rubrique = lire_config('gis/rubrique_cible')){
$valeurs['editable']=false;
}
// si l'on vien juste de poster le formlaire et qu'il a ete valide
// on veut pouvoir recommencer a poster un nouvelle photo
// on ne prend du coup pas les anciennes valeurs dans l'environnement
// pour ne pas polluer le nouveau formulaire
if (_request('soumission_gis_enregistre')){
unset ($valeurs['titre']);
unset ($valeurs['texte']);
unset ($valeurs['lat']);
unset ($valeurs['lonx']);
}
return $valeurs;
}
function formulaires_article_gis_verifier_dist(){
$erreurs = array();
$id_article = _request('id_article');
if ($id_article AND !_request('document'))
return $erreurs;
if (!$titre = _request('titre')){
$erreurs['titre'] = _T('gis:erreur_titre');
}
if (!$texte = _request('texte')){
$erreurs['texte'] = _T('gis:erreur_texte');
}
if (!count($erreurs)){
if ($afficher_texte != 'non') {
// ajout de l'article et de ses coordonnées
if(!$id_article){
include_spip('base/abstract_sql');
include_spip('inc/texte');
// pour le traitement :
// 1) on demande un nouvel article
// 2) on lui donne un titre et un statut et on y colle le texte
//3) on insère les coordonnées de l'article
// 1
include_spip('action/editer_article');
$id_rubrique = lire_config('gis/rubrique_cible');
if (!$id_article = insert_article($id_rubrique)){
return array(1,_T('gis:erreur_ajout_article'));
}
// 2
$titre = _request('titre');
$statut = lire_config('gis/statut','prop');
$texte = sql_quote(_request('texte'));
$c = array(
'titre'=> $titre,
'statut'=> $statut
);
include_spip('inc/modifier');
revision_article($id_article, $c);
instituer_article($id_article, $c);
sql_update('spip_articles', array('texte' => $texte), 'id_article=' . sql_quote($id_article));
//3
$lat = _request('lat');
$lonx = _request('lonx');
sql_insertq("spip_gis", array("id_article" => $id_article , "lat" => $lat, "lonx" => $lonx));
}
// ajout des documents
if(_request('document')) {
// compatibilite php < 4.1
if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
// recuperation des variables
$fichier = $_FILES['doc']['name'];
$size = $_FILES['doc']['size'];
$tmp = $_FILES['doc']['tmp_name'];
$type = $_FILES['doc']['type'];
$error = $_FILES['doc']['error'];
$doc = &$_FILES['doc'];
// verification si upload OK
if( !is_uploaded_file($tmp) ) {
$erreurs['document'] = _T('gis:erreur_upload');
}
else {
// on récupère l'extension du document envoyé
include_spip('base/abstract_sql');
include_spip('inc/ajouter_documents');
list($extension,$fichier) = fixer_extension_document($doc);
$acceptes = array_map('trim', explode(',',lire_config('gis/formats_documents','jpg,png,gif')));
// on vérifie que l'extension du document est autorisée
if (!in_array($extension, $acceptes)) {
if (!$formats = join(', ',$acceptes))
$formats = _L('aucun');
$erreurs['document'] = _T('gis:erreur_formats_acceptes',array('formats' => $formats));
}
else {
// ajout du document
$ajouter_documents = charger_fonction('ajouter_documents','inc');
if(!$ajouter_documents($tmp, $fichier, "article", $id_article, 'document', $id_document=0, $docs_actifs=array()))
$erreurs['document'] = _T('gis:erreur_copie_impossible');
}
}
// supprimer des documents ?
if (is_array(_request('supprimer')))
foreach (_request('supprimer') as $supprimer) {
if ($supprimer = intval($supprimer)) {
include_spip('inc/autoriser');
$supprimer_document = charger_fonction('supprimer_document','action');
$supprimer_document($supprimer);
$erreurs['document'] = _T('gis:document_supprime');
}
}
}
$form_doc = inclure_formulaire_doc_gis($id_article);
$erreurs['form_doc'] = $form_doc;
}
}
return $erreurs;
}
function formulaires_article_gis_traiter_dist(){
// signaler que l'on vient de soumettre le formulaire
// pour que charger ne remette pas les anciennes valeurs
// puisqu'on propose sa reedition dans la foulee
set_request('soumission_gis_enregistre',true);
return array('editable'=>true,'message_ok'=>_T('gis:ok_formulaire_soumis'));
}
function inclure_formulaire_doc_gis($id_article)
{
$contexte = array();
$contexte = array_merge(
$contexte,
array(
'id_article' => $id_article
)
);
return inclure_balise_dynamique(array('formulaires/documents_gis',0,$contexte),false);
}
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/session');
include_spip('inc/securiser_action');
include_spip('public/assembler');
function formulaires_article_gis_charger_dist(){
$valeurs = array(
'titre'=>'',
'texte'=>'',
'lat'=>'',
'lonx'=>'',
'editable'=>true
);
// si on a pas de rubrique, on n'edite pas le formulaire !
if (!$id_rubrique = lire_config('gis/rubrique_cible')){
$valeurs['editable']=false;
}
// si l'on vien juste de poster le formlaire et qu'il a ete valide
// on veut pouvoir recommencer a poster un nouvelle photo
// on ne prend du coup pas les anciennes valeurs dans l'environnement
// pour ne pas polluer le nouveau formulaire
if (_request('soumission_gis_enregistre')){
unset ($valeurs['titre']);
unset ($valeurs['texte']);
unset ($valeurs['lat']);
unset ($valeurs['lonx']);
}
return $valeurs;
}
function formulaires_article_gis_verifier_dist(){
$erreurs = array();
$id_article = _request('id_article');
if ($id_article AND !_request('document'))
return $erreurs;
if (!$titre = _request('titre')){
$erreurs['titre'] = _T('gis:erreur_titre');
}
if (!$texte = _request('texte')){
$erreurs['texte'] = _T('gis:erreur_texte');
}
if (!count($erreurs)){
if ($afficher_texte != 'non') {
// ajout de l'article et de ses coordonnées
if(!$id_article){
include_spip('base/abstract_sql');
include_spip('inc/texte');
// pour le traitement :
// 1) on demande un nouvel article
// 2) on lui donne un titre et un statut et on y colle le texte
//3) on insère les coordonnées de l'article
// 1
include_spip('action/editer_article');
$id_rubrique = lire_config('gis/rubrique_cible');
if (!$id_article = insert_article($id_rubrique)){
return array(1,_T('gis:erreur_ajout_article'));
}
// 2
$titre = _request('titre');
$statut = lire_config('gis/statut','prop');
$texte = sql_quote(_request('texte'));
$c = array(
'titre'=> $titre,
'statut'=> $statut
);
include_spip('inc/modifier');
revision_article($id_article, $c);
instituer_article($id_article, $c);
sql_update('spip_articles', array('texte' => $texte), 'id_article=' . sql_quote($id_article));
//3
$lat = _request('lat');
$lonx = _request('lonx');
sql_insertq("spip_gis", array("id_article" => $id_article , "lat" => $lat, "lonx" => $lonx));
}
// ajout des documents
if(_request('document')) {
// compatibilite php < 4.1
if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
// recuperation des variables
$fichier = $_FILES['doc']['name'];
$size = $_FILES['doc']['size'];
$tmp = $_FILES['doc']['tmp_name'];
$type = $_FILES['doc']['type'];
$error = $_FILES['doc']['error'];
$doc = &$_FILES['doc'];
// verification si upload OK
if( !is_uploaded_file($tmp) ) {
$erreurs['document'] = _T('gis:erreur_upload');
}
else {
// on récupère l'extension du document envoyé
include_spip('base/abstract_sql');
include_spip('inc/ajouter_documents');
list($extension,$fichier) = fixer_extension_document($doc);
$acceptes = array_map('trim', explode(',',lire_config('gis/formats_documents','jpg,png,gif')));
// on vérifie que l'extension du document est autorisée
if (!in_array($extension, $acceptes)) {
if (!$formats = join(', ',$acceptes))
$formats = _L('aucun');
$erreurs['document'] = _T('gis:erreur_formats_acceptes',array('formats' => $formats));
}
else {
// ajout du document
$ajouter_documents = charger_fonction('ajouter_documents','inc');
if(!$ajouter_documents($tmp, $fichier, "article", $id_article, 'document', $id_document=0, $docs_actifs=array()))
$erreurs['document'] = _T('gis:erreur_copie_impossible');
}
}
// supprimer des documents ?
if (is_array(_request('supprimer')))
foreach (_request('supprimer') as $supprimer) {
if ($supprimer = intval($supprimer)) {
include_spip('inc/autoriser');
$supprimer_document = charger_fonction('supprimer_document','action');
$supprimer_document($supprimer);
$erreurs['document'] = _T('gis:document_supprime');
}
}
}
$form_doc = inclure_formulaire_doc_gis($id_article);
$erreurs['form_doc'] = $form_doc;
}
}
return $erreurs;
}
function formulaires_article_gis_traiter_dist(){
// signaler que l'on vient de soumettre le formulaire
// pour que charger ne remette pas les anciennes valeurs
// puisqu'on propose sa reedition dans la foulee
set_request('soumission_gis_enregistre',true);
return array('editable'=>true,'message_ok'=>_T('gis:ok_formulaire_soumis'));
}
function inclure_formulaire_doc_gis($id_article)
{
$contexte = array();
$contexte = array_merge(
$contexte,
array(
'id_article' => $id_article
)
);
return inclure_balise_dynamique(array('formulaires/documents_gis',0,$contexte),false);
}
?>

163
formulaires/editer_gis.php

@ -1,82 +1,83 @@
<?php
function formulaires_editer_gis_charger_dist($id_article, $recherche='', $retour=''){
$valeurs = array(
'lat'=> '',
'lonx'=> '',
'zoom'=> '',
'recherche'=> $recherche,
'editable'=>true
);
$row = sql_fetsel("lat,lonx,zoom", "spip_gis", "id_article=$id_article");
if ($row) {
$valeurs['lat'] = $row['lat'];
$valeurs['lonx'] = $row['lonx'];
$valeurs['zoom'] = $row['zoom'];
}else{
$api_carte = lire_config('gis/api_carte');
$valeurs['lat'] = lire_config($api_carte.'/latitude');
$valeurs['lonx'] = lire_config($api_carte.'/longitude');
$valeurs['zoom'] = lire_config($api_carte.'/zoom');
}
return $valeurs;
}
function formulaires_editer_gis_verifier_dist($id_article, $recherche='', $retour=''){
$erreurs = array();
return $erreurs;
}
function formulaires_editer_gis_traiter_dist($id_article, $recherche='', $retour=''){
$res = array('editable'=>' ');
// recuperation des donnees
$lat = _request('lat');
$lonx = _request('lonx');
$zoom = _request('zoom');
include_spip('base/abstract_sql');
$c = array(
"id_article" => $id_article ,
"lat" => $lat,
"lonx" => $lonx,
"zoom" => $zoom
);
if(lire_config('gis/geocoding') == 'oui'){
$geocoding = array(
"pays" => _request('pays'),
"code_pays" => _request('code_pays'),
"region" => _request('region'),
"ville" => _request('ville'),
"code_postal" => _request('code_postal')
);
$c = array_merge($c,$geocoding);
}
// mise a jour ou creation ?
if ($id_gis = sql_getfetsel("id_gis", "spip_gis", "id_article=$id_article")) {
sql_updateq("spip_gis", $c, "id_gis=$id_gis");
$res['message_ok'] = _T('gis:coord_maj');
}else{
sql_insertq("spip_gis", $c);
$res['message_ok'] = _T('gis:coord_enregistre');
}
if ($retour){
include_spip('inc/headers');
$res['redirect'] = $retour;
}
return $res;
}
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
function formulaires_editer_gis_charger_dist($id_article, $recherche='', $retour=''){
$valeurs = array(
'lat'=> '',
'lonx'=> '',
'zoom'=> '',
'recherche'=> $recherche,
'editable'=>true
);
$row = sql_fetsel("lat,lonx,zoom", "spip_gis", "id_article=$id_article");
if ($row) {
$valeurs['lat'] = $row['lat'];
$valeurs['lonx'] = $row['lonx'];
$valeurs['zoom'] = $row['zoom'];
}else{
$api_carte = lire_config('gis/api_carte');
$valeurs['lat'] = lire_config($api_carte.'/latitude');
$valeurs['lonx'] = lire_config($api_carte.'/longitude');
$valeurs['zoom'] = lire_config($api_carte.'/zoom');
}
return $valeurs;
}
function formulaires_editer_gis_verifier_dist($id_article, $recherche='', $retour=''){
$erreurs = array();
return $erreurs;
}
function formulaires_editer_gis_traiter_dist($id_article, $recherche='', $retour=''){
$res = array('editable'=>' ');
// recuperation des donnees
$lat = _request('lat');
$lonx = _request('lonx');
$zoom = _request('zoom');
include_spip('base/abstract_sql');
$c = array(
"id_article" => $id_article ,
"lat" => $lat,
"lonx" => $lonx,
"zoom" => $zoom
);
if(lire_config('gis/geocoding') == 'oui'){
$geocoding = array(
"pays" => _request('pays'),
"code_pays" => _request('code_pays'),
"region" => _request('region'),
"ville" => _request('ville'),
"code_postal" => _request('code_postal')
);
$c = array_merge($c,$geocoding);
}
// mise a jour ou creation ?
if ($id_gis = sql_getfetsel("id_gis", "spip_gis", "id_article=$id_article")) {
sql_updateq("spip_gis", $c, "id_gis=$id_gis");
$res['message_ok'] = _T('gis:coord_maj');
}else{
sql_insertq("spip_gis", $c);
$res['message_ok'] = _T('gis:coord_enregistre');
}
if ($retour){
include_spip('inc/headers');
$res['redirect'] = $retour;
}
return $res;
}
?>

27
gis_options.php

@ -1,14 +1,15 @@
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
include_spip('base/gis');
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonz‡lez, Berio Molina
* (c) 2007 - Distribu’do baixo licencia GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('base/gis');
?>

161
gis_pipeline.php

@ -1,81 +1,82 @@
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonzalez, Berio Molina
* (c) 2007 - Distribudo baixo licencia GNU/GPL
*
*/
function gis_gismot($flux){
if ((_request('exec')=='mots_edit') AND (_request('new')!=oui)){
include_spip('inc/parte_privada');
$flux['data'] .= gis_mots($flux['args']['id_mot']);
}
return $flux;
}
function gis_insertar_map($flux){
if ($flux['args']['exec']=='articles'){
//on teste si cfg est actif
if (function_exists('lire_config')) {
$arracfgrubriques_gis=lire_config("gis/rubriques_gis",array(0,-1));
$id_article = $flux['args']["id_article"];
if ($id_article!=''){
//on cherche la rubrique de l'article
$s = spip_query("SELECT id_rubrique FROM spip_articles WHERE id_article=$id_article");
$row = spip_fetch_array($s);
$id_rubrique = $row['id_rubrique'];
//et si la rubrique est dans l'arrayrub
if (in_array(-1,$arracfgrubriques_gis) OR in_array($id_rubrique, $arracfgrubriques_gis)) {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_article'],"article","articles");
}
}
}else {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_article'],"article","articles");
}
} else if ($flux['args']['exec']=='naviguer'){
//on teste si cfg est actif
if (function_exists('lire_config')) {
$arracfgrubriques_gis=lire_config("gis/rubriques_gis",array(0,-1));
$id_rubrique = $flux['args']["id_rubrique"];
if ($id_rubrique!=''){
//et si la rubrique est dans l'arrayrub
if (in_array(-1,$arracfgrubriques_gis) OR in_array($id_rubrique, $arracfgrubriques_gis)) {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_rubrique'],"rubrique","naviguer");
}
}
}else {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_rubrique'],"rubrique","naviguer");
}
}
return $flux;
}
// --------------------------------
// inserta no head da parte PUBLICA
// --------------------------------
function gis_affichage_final($flux){
if ((strpos($flux, '<div id="map') == true) or (strpos($flux, '<div id="formMap') == true) or (strpos($flux, "<div id='map") == true)){
$incHead = '';
if (function_exists('lire_config') && lire_config('gis/api_carte')) {
if (function_exists('lire_config') && lire_config("gis/swfobject") != 'non')
$incHead .= '
<script type="text/javascript" src="'._DIR_PLUGIN_GIS.'js/swfobject.js"></script>';
}
return substr_replace($flux, $incHead, strpos($flux, '</head>'), 0);
} else {
return $flux;
}
}
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonzalez, Berio Molina
* (c) 2007 - Distribudo baixo licencia GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
function gis_gismot($flux){
if ((_request('exec')=='mots_edit') AND (_request('new')!=oui)){
include_spip('inc/parte_privada');
$flux['data'] .= gis_mots($flux['args']['id_mot']);
}
return $flux;
}
function gis_insertar_map($flux){
if ($flux['args']['exec']=='articles'){
//on teste si cfg est actif
if (function_exists('lire_config')) {
$arracfgrubriques_gis=lire_config("gis/rubriques_gis",array(0,-1));
$id_article = $flux['args']["id_article"];
if ($id_article!=''){
//on cherche la rubrique de l'article
$s = spip_query("SELECT id_rubrique FROM spip_articles WHERE id_article=$id_article");
$row = spip_fetch_array($s);
$id_rubrique = $row['id_rubrique'];
//et si la rubrique est dans l'arrayrub
if (in_array(-1,$arracfgrubriques_gis) OR in_array($id_rubrique, $arracfgrubriques_gis)) {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_article'],"article","articles");
}
}
}else {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_article'],"article","articles");
}
} else if ($flux['args']['exec']=='naviguer'){
//on teste si cfg est actif
if (function_exists('lire_config')) {
$arracfgrubriques_gis=lire_config("gis/rubriques_gis",array(0,-1));
$id_rubrique = $flux['args']["id_rubrique"];
if ($id_rubrique!=''){
//et si la rubrique est dans l'arrayrub
if (in_array(-1,$arracfgrubriques_gis) OR in_array($id_rubrique, $arracfgrubriques_gis)) {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_rubrique'],"rubrique","naviguer");
}
}
}else {
include_spip('inc/parte_privada');
$flux['data'].= gis_cambiar_coord($flux['args']['id_rubrique'],"rubrique","naviguer");
}
}
return $flux;
}
// --------------------------------
// inserta no head da parte PUBLICA
// --------------------------------
function gis_affichage_final($flux){
if ((strpos($flux, '<div id="map') == true) or (strpos($flux, '<div id="formMap') == true) or (strpos($flux, "<div id='map") == true)){
$incHead = '';
if (function_exists('lire_config') && lire_config('gis/api_carte')) {
if (function_exists('lire_config') && lire_config("gis/swfobject") != 'non')
$incHead .= '
<script type="text/javascript" src="'._DIR_PLUGIN_GIS.'js/swfobject.js"></script>';
}
return substr_replace($flux, $incHead, strpos($flux, '</head>'), 0);
} else {
return $flux;
}
}
?>

13
inc/cambiar_coordenadas.php

@ -1,7 +1,8 @@
<?php
if(isset ($_GET['envio'])) {
$query = "UPDATE spip_gis SET value='".$_POST['numeromap']."' WHERE name='googlemapkey'";
$result= spip_query($query);
//echo $query;
}
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
if(isset ($_GET['envio'])) {
$query = "UPDATE spip_gis SET value='".$_POST['numeromap']."' WHERE name='googlemapkey'";
$result= spip_query($query);
//echo $query;
}
?>

447
inc/parte_privada.php

@ -1,224 +1,225 @@
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonzalez, Berio Molina
* (c) 2007 - Distribudo baixo licencia GNU/GPL
*
*/
include_spip('base/abstract_sql');
include_spip('inc/vieilles_defs');
include_spip('inc/autoriser');
function gis_cambiar_coord($id,$table,$exec) {
global $spip_lang_left, $spip_lang_right;
$pkey = id_table_objet($table);
// on recupere l'id de l'auteur en cours
if ($GLOBALS["auteur_session"])
$id_auteur_session = $GLOBALS['auteur_session']['id_auteur'];
// et on verifie qu'il est autorisé à modifier l'élément en cours
$autoriser = autoriser("modifier",$table,$id);
$glat = NULL;
$glonx = NULL;
$gzoom = NULL;
$gicon = NULL;
$mapa = "";
$defaut = _DIR_PLUGIN_GEOMAP ? 'geomap' : '';
$api_carte = lire_config('gis/api_carte',$defaut);
if (lire_config('gis/geocoding'))
$geocoding = true;
$result= spip_query("SELECT * FROM spip_gis WHERE $pkey = " . intval($id));
if ($row = spip_fetch_array($result)){
$glat = $row['lat'];
$glonx = $row['lonx'];
$gzoom = $row['zoom'];
}
if(_request('actualizar')){
$glat = _request('lat');
$glonx = _request('lonx');
$gzoom = _request('zoom');
if ($geocoding){
$pays = _request('pays');
$code_pays = _request('code_pays');
$region = _request('region');
$ville = _request('ville');
$code_postal = _request('code_postal');
}
if (!$row){
if ($geocoding) {
spip_abstract_insert("spip_gis",
"($pkey, lat, lonx, zoom, pays, code_pays, region, ville, code_postal)",
"("._q($id) .", "._q($glat).", "._q($glonx).", "._q($gzoom).", "._q($pays).", "._q($code_pays).", "._q($region).", "._q($ville).", "._q($code_postal).")"
);
} else {
spip_abstract_insert("spip_gis",
"($pkey, lat, lonx, zoom)",
"("._q($id) .", "._q($glat).", "._q($glonx).", "._q($gzoom).")"
);
}
} else {
if ($geocoding) {
spip_query("UPDATE spip_gis SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom).", pays="._q($pays).", code_pays="._q($code_pays).", region="._q($region).", ville="._q($ville).", code_postal="._q($code_postal)." WHERE $pkey = " . _q($id));
} else {
spip_query("UPDATE spip_gis SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom)." WHERE $pkey = " . _q($id));
}
}
}
if(_request('supprimer')){
sql_delete("spip_gis", array("$pkey = " . sql_quote($id)));
}
if ($glat!==NULL){
$resultMots = spip_query("SELECT * FROM spip_mots_{$table}s WHERE $pkey = ".intval($id));
$marker_icon_name = 'marker_icon';
if (isset($_GET['marker_icon_name'])) {
$marker_icon_name = $_GET['marker_icon_name'];
}
while ($rowMot = spip_fetch_array($resultMots)) {
$resultMotIcon = spip_query("SELECT * FROM spip_mots WHERE type ='"._q($marker_icon_name)."' AND id_mot=".$rowMot['id_mot']);
if ($rowMotIcon = spip_fetch_array($resultMotIcon)){
if (file_exists("../IMG/"."moton".$rowMot['id_mot'].".png")) {
$gicon = "moton".$rowMot['id_mot'].".png";
} else if (file_exists("../IMG/"."moton".$rowMot['id_mot'].".gif")) {
$gicon = "moton".$rowMot['id_mot'].".gif";
}
}
}
if ($api_carte) {
$gis_append_view_map = charger_fonction($api_carte.'_append_view_map','inc');
$mapa = '<div id="viewMap" style="width:477px;height:100px;border:1px solid #000;overflow:hidden;"></div>';
$mapa .= $gis_append_view_map('viewMap',$glat,$glonx,$zoom,array(array('lonx'=>$glonx,'lat'=>$glat)),$gicon);
} else {
$mapa = '<div>' . _T('gis:falta_plugin') . '</div>';
}
}
$s .= '';
// Ajouter un formulaire de modification si l'auteur est autorisé
if ($autoriser){
// On teste la version de SPIP utilisee 2 ou 1.9
if(function_exists('bouton_block_depliable')){
$s .= debut_cadre('e', _DIR_PLUGIN_GIS."img_pack/correxir.png",'',bouton_block_depliable('&nbsp;&nbsp;&nbsp;<span style="text-transform: uppercase;">'._T('gis:cambiar').'</span>', false, "cadroFormulario"));
}else{
$s .= debut_cadre('r', _DIR_PLUGIN_GIS."img_pack/correxir.png");
$s .= bouton_block_invisible("ajouter_form");
$s .= '&nbsp;&nbsp;&nbsp;<strong class="verdana3" style="text-transform: uppercase;">' . _T('gis:cambiar') . ' <a onclick="$(\'#cadroFormulario\').slideToggle(\'slow\')">(' . _T('gis:clic_desplegar') . ')</a></strong>';
}
$s .= debut_block_visible("ajouter_form");
$s .= '<div id="cadroFormulario" class="formulaire_spip formulaire_editer formulaire_cfg" style="margin-bottom:5px;">
<span class="verdana2">' . _T("gis:clic_mapa") . '</span>';
if ($api_carte) {
$gis_append_clicable_map = charger_fonction($api_carte.'_append_clicable_map','inc');
$s .= '<div id="formMap" style="width: 467px; height: 350px; margin:5px auto; overflow:hidden;"></div>';
$s .= $gis_append_clicable_map('formMap','form_lat','form_long',$glat,$glonx,'form_zoom',$gzoom,$row?true:false);
} else {
$s .= '<div>' . _T('gis:falta_plugin') . '</div>';
}
// Formulario para actualizar as coordenadas do mapa______________________.
$s .= '
<form id="formulaire_address" action="#">
<ul style="text-align:center;">
<li style="padding-left:0; display:inline;">
<input type="text" class="text" size="50" name="map_address" id="map_address" value="'._T('gis:address').'" onfocus="this.value=\'\';" style="width:360px; margin-right:10px;" />
<input type="submit" value="'._T('gis:label_address').'" />
</li>
</ul>
</form>
<form id="formulaire_coordenadas" action="'.generer_url_ecrire($exec,"$pkey=".$id).'" method="post">
'.($geocoding?'<input type="hidden" name="code_pays" id="code_pays" value="" />
<input type="hidden" name="region" id="region" value="" />
<input type="hidden" name="code_postal" id="code_postal" value="" />':'').'
<ul style="text-align:center;">
<li style="padding-left:0; display:inline;"><label for="form_lat" style="margin-left:0; float:none; display:inline;">'._T('gis:lat').': </label><input type="text" class="text" name="lat" id="form_lat" value="'.$glat.'" size="12" style="width:80px;" /></li>
<li style="padding-left:0; display:inline;"><label for="form_long" style="margin-left:0; float:none; display:inline;">'._T('gis:long').': </label><input type="text" class="text" name="lonx" id="form_long" value="'.$glonx.'" size="12" style="width:80px;" /></li>
<li style="padding-left:0; display:inline;"><label for="form_zoom" style="margin-left:0; float:none; display:inline;">'._T('gis:zoom').': </label><input type="text" class="text" name="zoom" id="form_zoom" value="'.$gzoom.'" size="6" style="width:30px;" /></li>
</ul>
'.($geocoding?'<ul style="text-align:center;">
<li style="padding-left:0; display:inline;">
<label for="pays" style="margin-left:0; float:none; display:inline;">'._T('gis:label_pays').': </label>
<input type="text" class="text" name="pays" id="pays" value="'.$row['pays'].'" style="width:95px;" />
</li>
<li style="padding-left:0; display:inline;">
<label for="ville" style="margin-left:0; float:none; display:inline;">'._T('gis:label_ville').': </label>
<input type="text" class="text" name="ville" id="ville" value="'.$row['ville'].'" style="width:95px;" />
</li>
</ul>':'').'
<p class="boutons">
<input type="submit" name="actualizar" value="'._T("gis:boton_actualizar").'" /><input type="submit" name="supprimer" value="'._T("gis:bouton_supprimer").'" />
</p>
</form>
</div>';
$s .= $mapa;
$s .= fin_block();
$s .= fin_cadre(true);
}else{
$s .= debut_cadre('e', _DIR_PLUGIN_GIS."img_pack/correxir.png",'',_T("gis:coord"),'','', true);
$s .= $mapa;
$s .= fin_cadre(true);
}
return $s;
}
function gis_mots($id_mot) {
global $spip_lang_left, $spip_lang_right;
$glat = NULL;
$glonx = NULL;
$gzoom = NULL;
$result = spip_query("SELECT * FROM spip_gis_mots WHERE id_mot = ".intval($id_mot));
if ($row = spip_fetch_array($result)){
$glat = $row['lat'];
$glonx = $row['lonx'];
$gzoom = $row['zoom'];
}
if(_request('actualizar')){
$glat = _request('lat');
$glonx = _request('lonx');
$gzoom = _request('zoom');
if (!$row)
spip_abstract_insert("spip_gis_mots", "(id_mot, lat, lonx, zoom)", "("._q($id_mot).", "._q($glat).", "._q($glonx).", "._q($gzoom).")");
else
spip_query("UPDATE spip_gis_mots SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom)." WHERE id_mot = "._q($id_mot));
}
$s .= debut_cadre('r', _DIR_PLUGIN_GIS."img_pack/correxir.png");
$s .= bouton_block_invisible("ajouter_form");
$s .= '&nbsp;&nbsp;&nbsp;<strong class="verdana3" style="text-transform: uppercase;">'. _T("gis:cambiar") .' '. $id_mot .' <a onclick="$(\'#cadroFormulario\').slideToggle(\'slow\')">('. _T('gis:clic_desplegar') .')</a></strong>';
$s .= debut_block_visible("ajouter_form");
$s .= '<div class="verdana2">'. _T("gis:clic_mapa") .'</div>';
$s .= debut_block_visible("ajouter_form");
$s .= '<div id="cadroFormulario" style="border:1px solid #000">';
if ($api_carte = lire_config('gis/api_carte')) {
$gis_append_mini_map = charger_fonction($api_carte.'_append_mini_map','inc');
$s .= '<div id="formMap" name="formMap" style="width: 180px; height: 180px;overflow:hidden;"></div>';
$s .= $gis_append_mini_map('formMap','form_lat','form_long',$glat,$glonx,'form_zoom',$gzoom,$row?true:false);
} else {
$s .= '<div>'. _T('gis:falta_plugin') .'</div>';
}
// Formulario para actualizar as coordenadas do mapa
$s .= '<form id="formulaire_coordenadas" name="formulaire_coordenadas" action="'.generer_url_ecrire("mots_edit","&id_mot=".$id_mot).'" method="post">
<div style="height:20px; padding:4px;"><input type="text" name="lat" id="form_lat" value="'.$glat.'" size="12" style="float:right"/><label>'._T('gis:lat').': </label></div>
<div style="height:20px; padding:4px;"><input type="text" name="lonx" id="form_long" value="'.$glonx.'" size="12" style="float:right"/><label>'._T('gis:long').': </label></div>
<div style="height:20px; padding:4px;"><input type="text" name="zoom" id="form_zoom" value="'.$gzoom.'" size="12" style="float:right"/><label>'._T('gis:zoom').': </label></div>
<div style="height:20px; padding:4px;"><input type="submit" name="actualizar" value="'._T("gis:boton_actualizar").'" /></div>
</form>
</div>';
$s .= fin_block();
$s .= fin_block();
$s .= fin_cadre(true);
return $s;
}
<?php
/*
* Spip Gis plugin
* Insetar google maps en SPIP
*
* Autores :
* Horacio Gonzalez, Berio Molina
* (c) 2007 - Distribudo baixo licencia GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('base/abstract_sql');
include_spip('inc/vieilles_defs');
include_spip('inc/autoriser');
function gis_cambiar_coord($id,$table,$exec) {
global $spip_lang_left, $spip_lang_right;
$pkey = id_table_objet($table);
// on recupere l'id de l'auteur en cours
if ($GLOBALS["auteur_session"])
$id_auteur_session = $GLOBALS['auteur_session']['id_auteur'];
// et on verifie qu'il est autorisé à modifier l'élément en cours
$autoriser = autoriser("modifier",$table,$id);
$glat = NULL;
$glonx = NULL;
$gzoom = NULL;
$gicon = NULL;
$mapa = "";
$defaut = _DIR_PLUGIN_GEOMAP ? 'geomap' : '';
$api_carte = lire_config('gis/api_carte',$defaut);
if (lire_config('gis/geocoding'))
$geocoding = true;
$result= spip_query("SELECT * FROM spip_gis WHERE $pkey = " . intval($id));
if ($row = spip_fetch_array($result)){
$glat = $row['lat'];
$glonx = $row['lonx'];
$gzoom = $row['zoom'];
}
if(_request('actualizar')){
$glat = _request('lat');
$glonx = _request('lonx');
$gzoom = _request('zoom');
if ($geocoding){
$pays = _request('pays');
$code_pays = _request('code_pays');
$region = _request('region');
$ville = _request('ville');
$code_postal = _request('code_postal');
}
if (!$row){
if ($geocoding) {
spip_abstract_insert("spip_gis",
"($pkey, lat, lonx, zoom, pays, code_pays, region, ville, code_postal)",
"("._q($id) .", "._q($glat).", "._q($glonx).", "._q($gzoom).", "._q($pays).", "._q($code_pays).", "._q($region).", "._q($ville).", "._q($code_postal).")"
);
} else {
spip_abstract_insert("spip_gis",
"($pkey, lat, lonx, zoom)",
"("._q($id) .", "._q($glat).", "._q($glonx).", "._q($gzoom).")"
);
}
} else {
if ($geocoding) {
spip_query("UPDATE spip_gis SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom).", pays="._q($pays).", code_pays="._q($code_pays).", region="._q($region).", ville="._q($ville).", code_postal="._q($code_postal)." WHERE $pkey = " . _q($id));
} else {
spip_query("UPDATE spip_gis SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom)." WHERE $pkey = " . _q($id));
}
}
}
if(_request('supprimer')){
sql_delete("spip_gis", array("$pkey = " . sql_quote($id)));
}
if ($glat!==NULL){
$resultMots = spip_query("SELECT * FROM spip_mots_{$table}s WHERE $pkey = ".intval($id));
$marker_icon_name = 'marker_icon';
if (isset($_GET['marker_icon_name'])) {
$marker_icon_name = $_GET['marker_icon_name'];
}
while ($rowMot = spip_fetch_array($resultMots)) {
$resultMotIcon = spip_query("SELECT * FROM spip_mots WHERE type ='"._q($marker_icon_name)."' AND id_mot=".$rowMot['id_mot']);
if ($rowMotIcon = spip_fetch_array($resultMotIcon)){
if (file_exists("../IMG/"."moton".$rowMot['id_mot'].".png")) {
$gicon = "moton".$rowMot['id_mot'].".png";
} else if (file_exists("../IMG/"."moton".$rowMot['id_mot'].".gif")) {
$gicon = "moton".$rowMot['id_mot'].".gif";
}
}
}
if ($api_carte) {
$gis_append_view_map = charger_fonction($api_carte.'_append_view_map','inc');
$mapa = '<div id="viewMap" style="width:477px;height:100px;border:1px solid #000;overflow:hidden;"></div>';
$mapa .= $gis_append_view_map('viewMap',$glat,$glonx,$zoom,array(array('lonx'=>$glonx,'lat'=>$glat)),$gicon);
} else {
$mapa = '<div>' . _T('gis:falta_plugin') . '</div>';
}
}
$s .= '';
// Ajouter un formulaire de modification si l'auteur est autorisé
if ($autoriser){
// On teste la version de SPIP utilisee 2 ou 1.9
if(function_exists('bouton_block_depliable')){
$s .= debut_cadre('e', _DIR_PLUGIN_GIS."img_pack/correxir.png",'',bouton_block_depliable('&nbsp;&nbsp;&nbsp;<span style="text-transform: uppercase;">'._T('gis:cambiar').'</span>', false, "cadroFormulario"));
}else{
$s .= debut_cadre('r', _DIR_PLUGIN_GIS."img_pack/correxir.png");
$s .= bouton_block_invisible("ajouter_form");
$s .= '&nbsp;&nbsp;&nbsp;<strong class="verdana3" style="text-transform: uppercase;">' . _T('gis:cambiar') . ' <a onclick="$(\'#cadroFormulario\').slideToggle(\'slow\')">(' . _T('gis:clic_desplegar') . ')</a></strong>';
}
$s .= debut_block_visible("ajouter_form");
$s .= '<div id="cadroFormulario" class="formulaire_spip formulaire_editer formulaire_cfg" style="margin-bottom:5px;">
<span class="verdana2">' . _T("gis:clic_mapa") . '</span>';
if ($api_carte) {
$gis_append_clicable_map = charger_fonction($api_carte.'_append_clicable_map','inc');
$s .= '<div id="formMap" style="width: 467px; height: 350px; margin:5px auto; overflow:hidden;"></div>';
$s .= $gis_append_clicable_map('formMap','form_lat','form_long',$glat,$glonx,'form_zoom',$gzoom,$row?true:false);
} else {
$s .= '<div>' . _T('gis:falta_plugin') . '</div>';
}
// Formulario para actualizar as coordenadas do mapa______________________.
$s .= '
<form id="formulaire_address" action="#">
<ul style="text-align:center;">
<li style="padding-left:0; display:inline;">
<input type="text" class="text" size="50" name="map_address" id="map_address" value="'._T('gis:address').'" onfocus="this.value=\'\';" style="width:360px; margin-right:10px;" />
<input type="submit" value="'._T('gis:label_address').'" />
</li>
</ul>
</form>
<form id="formulaire_coordenadas" action="'.generer_url_ecrire($exec,"$pkey=".$id).'" method="post">
'.($geocoding?'<input type="hidden" name="code_pays" id="code_pays" value="" />
<input type="hidden" name="region" id="region" value="" />
<input type="hidden" name="code_postal" id="code_postal" value="" />':'').'
<ul style="text-align:center;">
<li style="padding-left:0; display:inline;"><label for="form_lat" style="margin-left:0; float:none; display:inline;">'._T('gis:lat').': </label><input type="text" class="text" name="lat" id="form_lat" value="'.$glat.'" size="12" style="width:80px;" /></li>
<li style="padding-left:0; display:inline;"><label for="form_long" style="margin-left:0; float:none; display:inline;">'._T('gis:long').': </label><input type="text" class="text" name="lonx" id="form_long" value="'.$glonx.'" size="12" style="width:80px;" /></li>
<li style="padding-left:0; display:inline;"><label for="form_zoom" style="margin-left:0; float:none; display:inline;">'._T('gis:zoom').': </label><input type="text" class="text" name="zoom" id="form_zoom" value="'.$gzoom.'" size="6" style="width:30px;" /></li>
</ul>
'.($geocoding?'<ul style="text-align:center;">
<li style="padding-left:0; display:inline;">
<label for="pays" style="margin-left:0; float:none; display:inline;">'._T('gis:label_pays').': </label>
<input type="text" class="text" name="pays" id="pays" value="'.$row['pays'].'" style="width:95px;" />
</li>
<li style="padding-left:0; display:inline;">
<label for="ville" style="margin-left:0; float:none; display:inline;">'._T('gis:label_ville').': </label>
<input type="text" class="text" name="ville" id="ville" value="'.$row['ville'].'" style="width:95px;" />
</li>
</ul>':'').'
<p class="boutons">
<input type="submit" name="actualizar" value="'._T("gis:boton_actualizar").'" /><input type="submit" name="supprimer" value="'._T("gis:bouton_supprimer").'" />
</p>
</form>
</div>';
$s .= $mapa;
$s .= fin_block();
$s .= fin_cadre(true);
}else{
$s .= debut_cadre('e', _DIR_PLUGIN_GIS."img_pack/correxir.png",'',_T("gis:coord"),'','', true);
$s .= $mapa;
$s .= fin_cadre(true);
}
return $s;
}
function gis_mots($id_mot) {
global $spip_lang_left, $spip_lang_right;
$glat = NULL;
$glonx = NULL;
$gzoom = NULL;
$result = spip_query("SELECT * FROM spip_gis_mots WHERE id_mot = ".intval($id_mot));
if ($row = spip_fetch_array($result)){
$glat = $row['lat'];
$glonx = $row['lonx'];
$gzoom = $row['zoom'];
}
if(_request('actualizar')){
$glat = _request('lat');
$glonx = _request('lonx');
$gzoom = _request('zoom');
if (!$row)
spip_abstract_insert("spip_gis_mots", "(id_mot, lat, lonx, zoom)", "("._q($id_mot).", "._q($glat).", "._q($glonx).", "._q($gzoom).")");
else
spip_query("UPDATE spip_gis_mots SET lat="._q($glat).", lonx="._q($glonx).", zoom="._q($gzoom)." WHERE id_mot = "._q($id_mot));
}
$s .= debut_cadre('r', _DIR_PLUGIN_GIS."img_pack/correxir.png");
$s .= bouton_block_invisible("ajouter_form");
$s .= '&nbsp;&nbsp;&nbsp;<strong class="verdana3" style="text-transform: uppercase;">'. _T("gis:cambiar") .' '. $id_mot .' <a onclick="$(\'#cadroFormulario\').slideToggle(\'slow\')">('. _T('gis:clic_desplegar') .')</a></strong>';
$s .= debut_block_visible("ajouter_form");
$s .= '<div class="verdana2">'. _T("gis:clic_mapa") .'</div>';
$s .= debut_block_visible("ajouter_form");
$s .= '<div id="cadroFormulario" style="border:1px solid #000">';