Browse Source

rangement branches/trunk phase 2

v1
brunobergot@gmail.com 11 years ago
commit
d6a70cece2
  1. 35
      .gitattributes
  2. 166
      balise/formulaire_gis.php
  3. 89
      base/gis.php
  4. 111
      base/gis_upgrade.php
  5. 104
      fonds/cfg_gis.html
  6. 114
      formulaires/article_gis.html
  7. 171
      formulaires/article_gis.php
  8. 27
      formulaires/documents_gis.html
  9. 163
      formulaires/editer_gis.html
  10. 82
      formulaires/editer_gis.php
  11. 73
      formulaires/formulaire_gis.html
  12. 14
      gis_options.php
  13. 81
      gis_pipeline.php
  14. BIN
      img_pack/attente.gif
  15. BIN
      img_pack/correxir.png
  16. BIN
      img_pack/loading.gif
  17. BIN
      img_pack/loadingAnimation.gif
  18. BIN
      img_pack/musicplayer.swf
  19. BIN
      img_pack/shadow.png
  20. 7
      inc/cambiar_coordenadas.php
  21. 224
      inc/parte_privada.php
  22. 8
      js/swfobject.js
  23. 21
      json-gis-marker.html
  24. 17
      json-gis-zoom.html
  25. 17
      json-gis.html
  26. 19
      lang/gis_en.php
  27. 54
      lang/gis_es.php
  28. 57
      lang/gis_fr.php
  29. 57
      lang/gis_gl.php
  30. 15
      modeles/carte_gis.html
  31. 15
      modeles/carte_gis_json.html
  32. BIN
      musicplayer.swf
  33. 56
      plugin.xml
  34. 79
      rss-gis-recursive.html
  35. 49
      rss-gis.html

35
.gitattributes vendored

@ -0,0 +1,35 @@
* text=auto !eol
balise/formulaire_gis.php -text
base/gis.php -text
base/gis_upgrade.php -text
fonds/cfg_gis.html -text
formulaires/article_gis.html -text
formulaires/article_gis.php -text
formulaires/documents_gis.html -text
formulaires/editer_gis.html -text
formulaires/editer_gis.php -text
formulaires/formulaire_gis.html -text
/gis_options.php -text
/gis_pipeline.php -text
img_pack/attente.gif -text
img_pack/correxir.png -text
img_pack/loading.gif -text
img_pack/loadingAnimation.gif -text
img_pack/musicplayer.swf -text
img_pack/shadow.png -text
inc/cambiar_coordenadas.php -text
inc/parte_privada.php -text
js/swfobject.js -text
/json-gis-marker.html -text
/json-gis-zoom.html -text
/json-gis.html -text
lang/gis_en.php -text
lang/gis_es.php -text svneol=unset#application/octet-stream
lang/gis_fr.php -text
lang/gis_gl.php -text
modeles/carte_gis.html -text
modeles/carte_gis_json.html -text
/musicplayer.swf -text
/plugin.xml -text
/rss-gis-recursive.html -text
/rss-gis.html -text

166
balise/formulaire_gis.php

@ -0,0 +1,166 @@
<?php
if (!defined("_ECRIRE_INC_VERSION")) return; #securite
// includes para as funcions
include_spip('inc/texte');
include_spip('inc/lang');
include_spip('inc/mail');
include_spip('inc/date');
include_spip ("inc/meta");
include_spip ("inc/session");
include_spip ("inc/filtres");
include_spip ("inc/acces");
include_spip('base/abstract_sql');
include_spip ('inc/ajouter_documents');
spip_connect();
if(function_exists(charger_generer_url)) charger_generer_url();
/* Assurer une compat SPIP 2.1*/
else generer_url_entite();
//Le contexte indique dans quelle rubrique le visiteur peut proposer l article
function balise_FORMULAIRE_GIS ($p) {
$p = calculer_balise_dynamique($p,'FORMULAIRE_GIS', array('id_rubrique'));
return $p;
}
function balise_FORMULAIRE_GIS_stat($args, $filtres) {
// Pas d'id_rubrique ? Erreur de squelette
if (!$args[0])
return erreur_squelette(
_T('zbug_champ_hors_motif',
array ('champ' => '#FORMULAIRE_GIS',
'motif' => 'RUBRIQUES')), '');
// Verifier que les visisteurs sont autorises a proposer un article
return ($args);
}
function balise_FORMULAIRE_GIS_dyn($id_rubrique) {
global $_FILES, $_HTTP_POST_FILES; // ces variables sont indispensables pour récuperer les documents joints
global $REMOTE_ADDR, $afficher_texte, $_COOKIE, $_POST;
$titre= stripslashes(_request('titre'));
$chapo= stripslashes(_request('chapo'));
$texte= stripslashes(_request('texte'));
// form gis
$lat= _request('lat');
$lonx= _request('lonx');
$commentimg= _request('commentimg');
$commentsound= _request('commentsound');
$auteur= _request('auteur');
$lang = _request('var_lang');
$nom = 'changer_lang';
lang_select();
$langues = liste_options_langues($nom, $lang);
// retourver le secteur et la langue de la rubrique
$s = spip_query("SELECT id_secteur, lang FROM spip_rubriques WHERE id_rubrique = '$id_rubrique' ");
if ($r = spip_fetch_array($s)) {
$id_secteur = $r["id_secteur"];
$lang = $r["lang"];
}
$valider= _request('valider');
$media=_request('media');
$bouton= '';
// statut de l'article, et formulaire de login en fonction de la configuration choisie
if($valider)
{
// intégrer à la base de données
$time=time();
$date=date('Y-m-d H:i:s',$time);
$statut= 'publie';
// ajouter le contenu de l'article
spip_abstract_insert('spip_articles', "(surtitre, titre, soustitre, descriptif, chapo, texte, ps, statut, date, date_redac, id_rubrique, id_article)", "(
" . spip_abstract_quote($surtitre) . ",
" . spip_abstract_quote($titre) . ",
" . spip_abstract_quote($soustitre) . ",
" . spip_abstract_quote($descriptif) . ",
" . spip_abstract_quote($chapo) . ",
" . spip_abstract_quote($texte) . ",
" . spip_abstract_quote($nom_inscription) . ",
" . spip_abstract_quote($statut) . ",
" . spip_abstract_quote($date) . ",
" . spip_abstract_quote($date_redac) . ",
" . intval($id_rubrique) .",
" . intval($id_article) ."
)");
// Insertamos nunha variable unha nova id para sustituir por id_article
$id_novo_article = spip_insert_id();
// insertamos as coordenadas do artigo
spip_abstract_insert("spip_gis", "(id_article, lat, lonx)", "(" . $id_novo_article .",".$lat." ,".$lonx.")");
// insertamos o autor do artigo, tomado da cookie de sesion
spip_abstract_insert("spip_auteurs_articles", "(id_auteur, id_article)", "(" . $auteur . ", " . $id_novo_article . ")");
//proba subir imaxe
if ((isset($_FILES['commentimg'])) AND ($_FILES['commentimg']['error'] == "0")) {
$freshfile = $_FILES['commentimg'];
move_uploaded_file($freshfile['tmp_name'], _DIR_PLUGIN_GIS.$freshfile['name']) OR die ("<p>Error!</p>");
inc_ajouter_documents_dist (_DIR_PLUGIN_GIS.$freshfile['name'], $freshfile['name'], 'article', $id_novo_article , 'document', $id_document, $documents_actifs);
unlink (_DIR_PLUGIN_GIS.$freshfile['name']);
} else {
echo "no fai nada coa imaxe";
}
//proba subir son
if ((isset($_FILES['commentsound'])) AND ($_FILES['commentsound']['error'] == "0")) {
$freshfile = $_FILES['commentsound'];
echo $freshfile['tmp_name'];
move_uploaded_file($freshfile['tmp_name'], _DIR_PLUGIN_GIS.$freshfile['name']) OR die ("<p>Error!</p>");
inc_ajouter_documents_dist (_DIR_PLUGIN_GIS.$freshfile['name'], $freshfile['name'], 'article', $id_novo_article , 'document', $id_document, $documents_actifs);
unlink (_DIR_PLUGIN_GIS.$freshfile['name']);
} else {
echo "no fai nada co son";
}
if ($r = spip_fetch_array($s)){
$id_article = $r["id_article"];
}
return _T('form_prop_enregistre');
echo ($id_article);
}else{ // SI NON E if($valider), e decir, si non se lle da o boton enviar (podeselle dar o boton previsualizaar por exemplo, ou engadir imaxe)
return array('formulaires/formulaire_gis', 0,
array(
'formulaire_date' => $formulaire_date,
'url' => $url,
'langues' => $langues,
'previsu' => $previsu,
'surtitre' => $surtitre,
'titre' => interdire_scripts(typo($titre)),
'soustitre' => $soustitre,
'descriptif' => $descriptif,
'chapo' => $chapo,
'texte' => $texte,
'ps' => $ps,
'lien_titre' => $lien_titre,
'lien_url' => $lien_url,
'id_rubrique' => $id_rubrique,
'id_secteur' => $id_secteur,
'id_auteur_session' => $id_auteur_session,
'mot' => $mot,
'auteur' => $auteur,
'lat' => $lat,
'lonx' => $lonx,
'commentimg' => $commentimg,
'commentsound' => $commentsound
)
);
} // FIN if($valider)
} // FIN function balise_FORMULAIRE_GIS_dyn($id_rubrique)
?>

89
base/gis.php

@ -0,0 +1,89 @@
<?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';
?>

111
base/gis_upgrade.php

@ -0,0 +1,111 @@
<?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();
}
?>

104
fonds/cfg_gis.html

@ -0,0 +1,104 @@
#CACHE{0}
[(#REM) titre=GIS]
[(#REM) descriptif=
<h4>Configuration du plugin GIS</h4>
Choisissez dans quelles rubriques activer le plugin.
]
<div class="formulaire_spip formulaire_editer formulaire_cfg">
<form method="post"><div>
[(#ENV{_cfg_}|form_hidden)]
<ul>
#SET{wichrub,#CONFIG{gis/rubriques_gis,#ARRAY{0,-1}}}
<li class="editer_api_carte_gis">
<label><:gis:api_carte:></label>
<div class="choix">
<input type="radio" name="api_carte" class="radio" value="geomap" id="api_carte_geomap"[ (#ENV{api_carte}|=={geomap}|?{'checked="checked"'})] />
<label for="api_carte_geomap"><:gis:api_carte_geomap:></label>
</div>
<div class="choix">
<input type="radio" name="api_carte" class="radio" value="openlayer" id="api_carte_openlayer"[ (#ENV{api_carte}|=={openlayer}|?{'checked="checked"'})] />
<label for="api_carte_openlayer"><:gis:api_carte_openlayer:></label>
</div>
</li>
<li class="editer_rubriques_gis">
<label for="rubriques_gis"><:gis:pages_prive:></label>
<p class="explications"><:gis:explication_pages_prive:></p>
<select name="rubriques_gis[]" multiple="multiple" size="9">
<option value="-1"[ (#EVAL{-1}|in_array{#GET{wichrub}}|?{' selected="selected"'})]>Toutes</option>
<BOUCLE_secteurs(RUBRIQUES) {racine} {par titre}{tout}>
<option value="#ID_RUBRIQUE"[ (#ID_RUBRIQUE|in_array{#GET{wichrub}}|?{' selected="selected"'})]>
Secteur #ID_RUBRIQUE : #TITRE
</option>
<BOUCLE_rubriques(RUBRIQUES) {id_parent} {par titre}{tout}>
<option value="#ID_RUBRIQUE"[ (#ID_RUBRIQUE|in_array{#GET{wichrub}}|?{' selected="selected"'})]>
&rarr; Rubrique #ID_RUBRIQUE : #TITRE
</option>
<BOUCLE_sous_rubriques(BOUCLE_rubriques)></BOUCLE_sous_rubriques>
</BOUCLE_rubriques>
</BOUCLE_secteurs>
</select>
</li>
<li class="editer_swfobject_gis">
<label><:gis:pages_public:></label>
<p class="explications"><:gis:explication_swfobject:></p>
<div class="choix">
<input type="checkbox" name="swfobject" class="checkbox" value="non" id="swfobject_non"[ (#ENV{swfobject}|=={non}|?{'checked="checked"'})] />
<label for="swfobject_non"><:gis:desactiver_swfobject:></label>
</div>
</li>
<li class="editer_geocoding_gis">
<label><:gis:geocoding:></label>
<p class="explications"><:gis:explication_geocoding:></p>
<div class="choix">
<input type="checkbox" name="geocoding" class="checkbox" value="oui" id="geocoding"[ (#ENV{geocoding}|=={oui}|?{'checked="checked"'})] />
<label for="geocoding"><:gis:activer_geocoding:></label>
</div>
</li>
</ul>
<fieldset>
<legend><:gis:parametres_formulaire:></legend>
<ul>
<li class="editer_rubrique_formulaire_gis">
<label for="rubrique_cible"><:gis:rubrique_cible:></label>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{rubrique_cible})</span>]
<select name="rubrique_cible">
<BOUCLE_r1(RUBRIQUES){racine}{par num titre}>
<option value=''></option>
<optgroup label="<:gis:secteur:> [(#TITRE|couper{40})]">
<option value="#ID_RUBRIQUE"[(#ENV{rubrique_cible}|=={#ID_RUBRIQUE}|?{' selected="selected"'})]>[(#TITRE|couper{40})] (<:gis:racine:>)</option>
<B_r2>
<option value="" class='mysteric_hr' disabled='disabled'><:gis:ou_choisir:></option>
<BOUCLE_r2(RUBRIQUES){id_parent}{par num titre}>
<option value="#ID_RUBRIQUE"[(#ENV{rubrique_cible}|=={#ID_RUBRIQUE}|?{' selected="selected"'})]>[(#TITRE|couper{40})]</option>
</BOUCLE_r2>
</optgroup>
</BOUCLE_r1>
</select>
</li>
<li class="editer_statut_formulaire_gis">
<label for="statut"><:gis:statut_articles:></label>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{statut})</span>]
<select name="statut">
<option value='prepa'[(#ENV{statut}|=={prepa}|?{' selected="selected"'})]>En cours de rédaction</option>
<option value='prop'[(#ENV{statut}|=={prop}|?{' selected="selected"'})]>Proposé</option>
<option value='publie'[(#ENV{statut}|=={publie}|?{' selected="selected"'})]>Publié</option>
</select>
</li>
<li class="editer_formats_documents[ (#ENV**{erreurs}|table_valeur{formats_documents}|?{'erreur'})]">
<label for="formats_documents"><:gis:formats_documents:></label>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{formats_documents})</span>]
<p class="explications"><:gis:texte_formats_documents:></p>
<input type="text" name="formats_documents" class="text" value="#ENV{formats_documents,'jpg,png,gif'}" />
</li>
</ul>
</fieldset>
<p class="boutons">
<input type="submit" name="_cfg_ok" class="submit" value="<:valider:>" />
<input type="submit" name="_cfg_delete" class="submit" value="<:effacer:>" />
</p>
</div></form>
</div>
#CFG_ARBO{gis}

114
formulaires/article_gis.html

@ -0,0 +1,114 @@
#CACHE{0}
<div id="formMap" name="formMap" style="width: 100%; height: 350px"></div>
<script type="text/javascript">
//<![CDATA[
var letraNH = String.fromCharCode(241);
var letraNHNH = String.fromCharCode(209);
var letraAacute = String.fromCharCode(225);
var letraAAacute = String.fromCharCode(193);
var letraEacute = String.fromCharCode(233);
var letraEEacute = String.fromCharCode(201);
var letraIacute = String.fromCharCode(237);
var letraIIacute = String.fromCharCode(205);
var letraOacute = String.fromCharCode(243);
var letraOOacute = String.fromCharCode(211);
var letraUacute = String.fromCharCode(250);
var letraUUacute = String.fromCharCode(218);
fecha = new Date();
if (GBrowserIsCompatible()) {
// create the map
var map = new GMap2(document.getElementById("formMap"));
var default_lat = [(#CONFIG**{[(#CONFIG**{gis/api_carte})]/latitude,0})];
var default_lonx = [(#CONFIG**{[(#CONFIG**{gis/api_carte})]/longitude,0})];
var default_zoom = [(#CONFIG**{[(#CONFIG**{gis/api_carte})]/zoom,0})];
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(default_lat,default_lonx), default_zoom, G_NORMAL_MAP);
// creamos el evento para crear nuevos marcadores
GEvent.addListener(map, "click", function(overlay, point){
map.clearOverlays();
if (point) {
map.addOverlay(new GMarker(point));
map.panTo(point);
document.forms.formulaire_article_gis.lat.value = point.y;
document.forms.formulaire_article_gis.lonx.value = point.x;
}
});
[(#ENV**{lat}|oui)
map.addOverlay(new GMarker(new GLatLng([(#ENV**{lat})],[(#ENV**{lonx})])));
map.setCenter(new GLatLng([(#ENV**{lat})],[(#ENV**{lonx})]));
]
} else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
//]]>
</script>
<div class="formulaire_spip formulaire_editer formulaire_article_gis">
<!-- br class='spacer' / -->
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
[(#ENV{editable})
<form method='post' action='#ENV{action}' enctype='multipart/form-data' name='formulaire_article_gis' id='formulaire_article_gis'><div>
[(#REM) declarer les hidden qui declencheront le service du formulaire
parametre : url d'action ]
#ACTION_FORMULAIRE{#ENV{action}}
<ul>
<li>
<label for="lat">Latitude</label>
<input type="text" name="lat" id="lat" class="text" value="[(#ENV**{lat})]" />
</li>
<li>
<label for="lonx">Lonxitude</label>
<input type="text" name="lonx" id="lonx" class="text" value="[(#ENV**{lonx})]" />
</li>
[<li class='saisie_document_gis[ (#ENV**{erreurs}|table_valeur{erreur_upload}|oui)erreur]'>
<fieldset>
<legend><:gis:document_joint:></legend>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{document})</span>]
(#ENV**{erreurs}|table_valeur{form_doc})
</fieldset>
</li>]
<li class="editer_titre obligatoire[ (#ENV**{erreurs}|table_valeur{titre}|oui)erreur]">
<label for="titre"><:info_titre:></label>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{titre})</span>]
<input type='text' name='titre' id='titre' class='text' value="[(#ENV**{titre})]"/>
</li>
[(#ENV**{config}|table_valeur{articles_texte}|=={non}|?{#ENV**{texte,''},' '}|oui)
<li class="editer_texte[ (#ENV**{erreurs}|table_valeur{texte}|oui)erreur]">
<label for="texte"><:info_texte:></label>
[<span class='erreur'>(#ENV**{erreurs}|table_valeur{texte})</span>]
[(#ENV**{_texte_trop_long,''})]
<div class="explication"><:texte_enrichir_mise_a_jour:></div>
<textarea name='texte' id='texte' class='barre_inserer' rows='7' cols='40'[
(#ENV**{browser_caret,''})]>[(#ENV**{texte})]</textarea>
<script type='text/javascript'><!--
jQuery(function(){
jQuery('#text_area')
.height((jQuery(window).height()-80)+'px');
});
//--></script>
</li>]
</ul>
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ]
<!--extra-->
<p class='boutons'><input class='submit' type='submit' value='<:bouton_enregistrer:>' /></p>
</div></form>
]
</div>

171
formulaires/article_gis.php

@ -0,0 +1,171 @@
<?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);
}
?>

27
formulaires/documents_gis.html

@ -0,0 +1,27 @@
#CACHE{0}
<B_docs>
#ANCRE_PAGINATION
<BOUCLE_docs(DOCUMENTS){id_article=#ENV{id_article}}{!par id_document}{tout}{pagination 3}>
<div style="float: left; margin: 5px; text-align: center;">
<div>
[(#SET{logo,[(#LOGO_DOCUMENT|#URL_DOCUMENT|inserer_attribut{title,#TYPE_DOCUMENT[ - (#TAILLE|taille_en_octets)]})]})]
[(#GET{logo}|extraire_attribut{width}|>{78}|?{[(#SET{logo,[(#GET{logo}|image_reduire{140,140}|image_recadre{78,78})]})]})]
#GET{logo}
</div>
<div>
<input type="checkbox" name="supprimer[]" id="supprimer" value="#ID_DOCUMENT" title="<:lien_supprimer:>" /> <:lien_supprimer:>
</div>
</div>
</BOUCLE_docs>
[<p class="pagination">(#PAGINATION)</p>]
</B_docs>
[<p class="pagination">(#PAGINATION)</p>]
<//B_docs>
<ul>
<li>
[<label for="doc">(#CONFIG{gis/formats_documents})</label>]
<input name='doc' id='doc' type='file' style='width: 100%;' />
<input type='hidden' name='id_article' class="hidden" value="#ENV**{id_article}" />
</li>
</ul>
<p class='boutons'><input name='document' type='submit' value='<:gis:bouton_documents:>' class='submit' /></p>

163
formulaires/editer_gis.html

@ -0,0 +1,163 @@
#CACHE{0}
<div id="formMap" name="formMap" style="width: 100%; height: 350px"></div>
<script type="text/javascript">
//<![CDATA[
(function($){
var initMap = function() {
if (GBrowserIsCompatible()) {
// creer la carte
var map = new GMap2(document.getElementById("formMap"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng([(#ENV**{lat})],[(#ENV**{lonx})]), [(#ENV**{zoom})], G_NORMAL_MAP);
[(#CONFIG{gis/geocoding}|oui)
// reverse geocoding
var geocode = function(lat,lonx) {
var geocoder;
geocoder = new GClientGeocoder();
function showAddress(response) {
if (!response || response.Status.code != 200) {
return false;
} else {
$("#pays,#code_pays,#region,#ville,#code_postal").val("");
CountryName = '';
CountryNameCode = '';
AdministrativeAreaName = '';
LocalityName = '';
PostalCodeNumber = '';
place = response.Placemark[(#VAL{91}|chr)]0[(#VAL{93}|chr)];
$("#map_adresse").val(place.address);
if (Country = place.AddressDetails.Country){
if (CountryName = Country.CountryName)
$("#pays").val(CountryName);
if (CountryNameCode = Country.CountryNameCode)
$("#code_pays").val(CountryNameCode);
if (AdministrativeArea = Country.AdministrativeArea){
if (AdministrativeAreaName = AdministrativeArea.AdministrativeAreaName)
$("#region").val(AdministrativeAreaName);
if ((SubAdministrativeArea = AdministrativeArea.SubAdministrativeArea) && (Locality = SubAdministrativeArea.Locality)){
if (LocalityName = Locality.LocalityName)
$("#ville").val(LocalityName);
if ((PostalCode = Locality.PostalCode) && (PostalCodeNumber = PostalCode.PostalCodeNumber))
$("#code_postal").val(PostalCodeNumber);
}
}
}
}
}
geocoder.getLocations(new GLatLng(lat,lonx), showAddress);
};]
// mettre a jour les coordonnees quand on clique la carte
GEvent.addListener(map, "click", function(overlay, point){
map.clearOverlays();
if (point) {
map.addOverlay(new GMarker(point));
map.panTo(point);
jQuery("#formulaire_editer_gis #lat").val(point.y);
jQuery("#formulaire_editer_gis #lonx").val(point.x);
[(#CONFIG{gis/geocoding}|oui)
geocode(point.y,point.x);]
}
});
// mettre à jour le zoom quand on le modifie
GEvent.addListener(map, "zoomend", function(oldlevel, newlevel){
jQuery("#formulaire_editer_gis #zoom").val(newlevel);
});
[(#ENV**{lat}|oui)
map.addOverlay(new GMarker(new GLatLng([(#ENV**{lat})],[(#ENV**{lonx})])));
map.setCenter(new GLatLng([(#ENV**{lat})],[(#ENV**{lonx})]));
[(#CONFIG{gis/geocoding}|oui)
geocode([(#ENV**{lat})],[(#ENV**{lonx})]);]
]
[(#ENV**{recherche}|oui)
jQuery("#map_adresse").focus(function(){jQuery(this).val("");});
$(".rechercher_adresse #rechercher").css("cursor","pointer").click(function(){
var adresse = $("#map_adresse").attr("value");
var geocoder = new GClientGeocoder();
if (geocoder) {
geocoder.getLatLng(adresse, function(point) {
if (!point) {
alert(adresse + " not found");
} else {
map.setCenter(point);
map.clearOverlays();
marker = new GMarker(point,{draggable:true});
map.addOverlay(marker);
marker.openInfoWindowHtml(adresse);
[(#CONFIG{gis/geocoding}|oui)
geocode(point.lat(),point.lng());]
jQuery("#formulaire_editer_gis #lat").val(point.lat());
jQuery("#formulaire_editer_gis #lonx").val(point.lng());
jQuery("#formulaire_editer_gis #zoom").val(map.getZoom());
GEvent.addListener(marker, 'dragend', function(){
var center = marker.getPoint();
jQuery("#formulaire_editer_gis #lat").val(center.lat());
jQuery("#formulaire_editer_gis #lonx").val(center.lng());
[(#CONFIG{gis/geocoding}|oui)
geocode(center.lat(),center.lng());]
});
}
});
}
return false;
});
// ne pas soumettre le formulaire si on presse Entree depuis le champ de recherche
$('#map_adresse').keypress(function(e){
if (e.which == 13) {
$('a#rechercher').trigger("click");
return false;
}
});]
} else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
};
$(function(){
initMap();
onAjaxLoad(initMap);
});
})(jQuery);
//]]>
</script>
<div class="formulaire_spip formulaire_editer formulaire_editer_gis">
<!-- br class='spacer' / -->
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
[(#ENV{editable})
<form method='post' action='#ENV{action}' enctype='multipart/form-data' name='formulaire_editer_gis' id='formulaire_editer_gis'><div>
[(#REM) declarer les hidden qui declencheront le service du formulaire
parametre : url d'action ]
#ACTION_FORMULAIRE{#ENV{action}}
<input type='hidden' name='pays' id='pays' value='' />
<input type='hidden' name='code_pays' id='code_pays' value='' />
<input type='hidden' name='region' id='region' value='' />
<input type='hidden' name='ville' id='ville' value='' />
<input type='hidden' name='code_postal' id='code_postal' value='' />
<ul>[(#ENV{recherche}|oui)
<li class="rechercher_adresse">
<input type="text" class="text" name="map_adresse" id="map_adresse" value="<:gis:address:>" />
<a id="rechercher"><:gis:label_address:></a>
</li>]
<li class="editer_lat obligatoire[ (#ENV**{erreurs}|table_valeur{lat}|oui)erreur]">
<label for="lat">Latitude</label>
<input type="text" name="lat" id="lat" class="text" value="[(#ENV**{lat})]" />
</li>
<li class="editer_lonx obligatoire[ (#ENV**{erreurs}|table_valeur{lonx}|oui)erreur]">
<label for="lonx">Longitude</label>
<input type="text" name="lonx" id="lonx" class="text" value="[(#ENV**{lonx})]" />
</li>
<li class="editer_zoom obligatoire[ (#ENV**{erreurs}|table_valeur{zoom}|oui)erreur]">
<label for="zoom">Zoom</label>
<input type="text" name="zoom" id="zoom" class="text" value="[(#ENV**{zoom})]" />
</li>
</ul>
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ]
<!--extra-->
<p class='boutons'><input class='submit' type='submit' value='<:bouton_enregistrer:>' /></p>
</div></form>
]
</div>

82
formulaires/editer_gis.php

@ -0,0 +1,82 @@
<?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;
}
?>

73
formulaires/formulaire_gis.html

@ -0,0 +1,73 @@
<div id="formMap" name="formMap" style="width: 780px; height: 350px"></div>
<div id="adress" style="position:relative; top:-30px; left: 10px; display:none;">
<form action="#" onsubmit="showAddress(this.address.value); return false">
<nobr><input size="40" name="address" value="calle, ciudad, pais" type="text"> <input value="Go!" type="submit"></nobr>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
var letraNH = String.fromCharCode(241);
var letraNHNH = String.fromCharCode(209);
var letraAacute = String.fromCharCode(225);
var letraAAacute = String.fromCharCode(193);
var letraEacute = String.fromCharCode(233);
var letraEEacute = String.fromCharCode(201);
var letraIacute = String.fromCharCode(237);
var letraIIacute = String.fromCharCode(205);
var letraOacute = String.fromCharCode(243);
var letraOOacute = String.fromCharCode(211);
var letraUacute = String.fromCharCode(250);
var letraUUacute = String.fromCharCode(218);
fecha = new Date();
if (GBrowserIsCompatible()) {
// create the map
var map = new GMap2(document.getElementById("formMap"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng([(#CONFIG**{gis_default_lat,0})],[(#CONFIG**{gis_default_lonx,0})]), [(#CONFIG**{gis_default_zoom,0})], G_NORMAL_MAP);
// creamos el evento para crear nuevos marcadores
GEvent.addListener(map, "click", function(overlay, point){
map.clearOverlays();
if (point) {
map.addOverlay(new GMarker(point));
map.panTo(point);
document.forms.formulaire_gis.lat.value = point.y;
document.forms.formulaire_gis.lonx.value = point.x;
}
});
} else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
//]]>
</script>
<form action="[(#ENV{url})]" method="post" name="formulaire_gis" id="Formulaire_gis" enctype="multipart/form-data">
[(#ENV*{previsu}) ]
<fieldset>
<input type="text" name="lat" size="20">Latitude</br>
<input type="text" name="lonx" size="20">Lonxitude
</fieldset>
<div><input type="file" accept="image/*" id="commentimg" name="commentimg"></input>Imaxe</div>
<div><input type="file" accept="audio/*" id="commentsound" name="commentsound">Son</input></div>
<input type="hidden" name="auteur" size="20" value="#SESSION{id_auteur}"><br>
<fieldset>
<input class="id_rubrique" type="hidden" name="titre" value="[(#ENV*{id_rubrique})]" size="50">
<input class="id_rubrique" type="hidden" name="statut" value="publie" >
<label><:texte_titre_obligatoire:></label>
<input type="text" name="titre" value="[(#ENV**{titre})]" size="50"><br>
<label>#CHAPO</label>
<textarea class="chapo" name="chapo" cols="25" rows="5">[(#ENV*{chapo})]</textarea>
<label>#TEXTO</label>
[(#ENV*{texte})]
</fieldset>
<div align="right"><input type="submit" name="valider" class="spip_bouton" value="<:valider:>" /></div>
</fieldset>
</form>

14
gis_options.php

@ -0,0 +1,14 @@
<?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');
?>

81
gis_pipeline.php

@ -0,0 +1,81 @@
<?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;
}
}
?>

BIN
img_pack/attente.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
img_pack/correxir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
img_pack/loading.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
img_pack/loadingAnimation.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
img_pack/musicplayer.swf

Binary file not shown.

BIN
img_pack/shadow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

7
inc/cambiar_coordenadas.php

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

224
inc/parte_privada.php

@ -0,0 +1,224 @@
<?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=