Skip to content

Commit a629406

Browse files
author
Emmanuel Garette
committed
add map in description
1 parent 2defdd7 commit a629406

9 files changed

Lines changed: 86 additions & 27 deletions

File tree

admin/admin_config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@
135135
'popupinfo_comment' => isset($_POST['osm_left_popupinfo_comment']),
136136
'popupinfo_author' => isset($_POST['osm_left_popupinfo_author']),
137137
),
138+
'category_description' => array(
139+
'enabled' => get_boolean($_POST['osm_category_description']),
140+
'height' => $_POST['osm_cat_height'],
141+
'width' => $_POST['osm_cat_width'],
142+
),
138143
'map' => array(
139144
'baselayer' => $_POST['osm_baselayer'],
140145
'custombaselayer' => $_POST['osm_custombaselayer'],

admin/admin_config.tpl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,27 @@ Refer to the <a href="https://github.com/xbgmsharp/piwigo-openstreetmap/wiki" ta
104104
</li>
105105
</ul>
106106
</fieldset>
107+
<fieldset>
108+
<legend>{'C_MAP'|@translate}</legend>
109+
<ul>
110+
<li>
111+
<label>{'SHOWCMAP'|@translate} : </label>
112+
<label><input type="radio" name="osm_category_description" value="true" {if $category_description.enabled}checked="checked"{/if}/> {'Yes'|@translate}</label>
113+
<label><input type="radio" name="osm_category_description" value="false" {if not $category_description.enabled}checked="checked"{/if}/> {'No'|@translate}</label>
114+
<br/><small>{'SHOWCMAP'|@translate}</small>
115+
</li>
116+
<li>
117+
<label>{'HEIGHT'|@translate} : </label>
118+
<input type="text" value="{$category_description.height}" name="osm_cat_height" size="4" required/>
119+
<br/><small>{'HEIGHT_DESC'|@translate}</small>
120+
</li>
121+
<li>
122+
<label>{'WIDTH'|@translate} : </label>
123+
<input type="text" value="{$category_description.width}" name="osm_cat_width" size="4" required/>
124+
<br/><small>{'WIDTH_DESC'|@translate}</small>
125+
</li>
126+
</ul>
127+
</fieldset>
107128
<fieldset>
108129
<legend>{'G_MAP'|@translate}</legend>
109130
<ul>
@@ -293,4 +314,4 @@ window.onload = pin_preview();
293314
window.onload = tile_preview();
294315
295316
</script>
296-
{/literal}
317+
{/literal}

include/functions_map.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,20 @@ function osm_get_js($conf, $local_conf, $js_data)
380380
\t}";
381381
$js .= "\nif (typeof L.MarkerClusterGroup === 'function')\n";
382382
$js .= " map.addLayer(markers);\n";
383+
if (isset($local_conf['auto_center']) and $local_conf['auto_center'] === 0 ) {
384+
$js .= "var group = new L.featureGroup(MarkerClusterList);";
385+
$js .= "this.map.whenReady(function () {
386+
window.setTimeout(function () {
387+
map.fitBounds(group.getBounds());
388+
}.bind(this), 200);
389+
}, this);";
390+
}
383391
return $js;
384392
}
385393

386394
function osm_gen_template($conf, $js, $js_data, $tmpl, $template)
387395
{
388-
$linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : 'OS World Map';
396+
$linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : l10n('OSWorldMap');
389397
$template->set_filename('map', dirname(__FILE__). '/../template/' . $tmpl);
390398

391399
$template->assign(

language/en_UK/plugin.lang.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
$lang['POPUPCOMMENT'] = "Comment of the image";
3636
$lang['POPUPAUTHOR'] = "Author of the image";
3737

38+
$lang['C_MAP'] = "Category's description";
39+
$lang['SHOWCMAP'] = "Add a map in category's description";
40+
$lang['WIDTH'] = 'Map width';
41+
$lang['WIDTH_DESC'] = 'in px or auto';
42+
3843
$lang['G_MAP'] = "Map configuration";
3944
$lang['BASELAYER'] = "Map style";
4045
$lang['BASELAYER_DESC'] = "Mapnik is the default style of OpenStreetMap.";
@@ -87,6 +92,9 @@
8792
$lang['EDIT_MAP'] = 'Map';
8893
$lang['EDIT_UPDATE_LOCATION_DESC'] = 'Click inside the map to update location.';
8994

95+
$lang['DISPLAY_ON_MAP'] = 'displays %s on a map';
96+
$lang['MAP'] = 'Map';
97+
9098
$lang['PLUGIN_BY'] = 'Plugin by <a href="https://github.com/xbgmsharp/piwigo-openstreetmap" target="_blank">xbgmsharp</a>';
9199
$lang['OSM_CONTRIBUTORS'] = '<a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a> contributors, (<a href="http://www.openstreetmap.org/copyright" target="_blank">ODbL</a>)';
92100
$lang['VIEW_OSM'] = 'View on OpenStreetMap';

language/fr_FR/plugin.lang.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
$lang['POPUPCOMMENT'] = "Commentaire de l'image";
3535
$lang['POPUPAUTHOR'] = "Auteur de l'image";
3636

37+
$lang['C_MAP'] = "Description de la catégorie";
38+
$lang['SHOWCMAP'] = "Ajouter la carte dans la description de la catégorie";
39+
$lang['WIDTH'] = 'Largeur de la carte';
40+
$lang['WIDTH_DESC'] = 'en pixel ou auto';
41+
3742
$lang['G_MAP'] = "Configuration de la Carte";
3843
$lang['BASELAYER'] = "Style de Carte";
3944
$lang['BASELAYER_DESC'] = "Mapnik est le style par défaut d'OpenStreetMap.";
@@ -90,6 +95,9 @@
9095
$lang['LONGITUDE'] = 'Longitude';
9196
$lang['EDIT_MAP'] = 'Carte';
9297

98+
$lang['DISPLAY_ON_MAP'] = 'Afficher %s sur un fond de carte';
99+
$lang['MAP'] = 'Carte';
100+
93101
$lang['PLUGIN_BY'] = 'Plugin par <a href="https://github.com/xbgmsharp/piwigo-openstreetmap" target="_blank">xbgmsharp</a>';
94102
$lang['OSM_CONTRIBUTORS'] = 'Contributeurs <a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a>, (<a href="http://www.openstreetmap.org/copyright" target="_blank">ODbL</a>)';
95103
$lang['VIEW_OSM'] = 'Afficher sur OpenStreetMap';

main.inc.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
{
2525
include_once(dirname(__FILE__).'/picture.inc.php');
2626
}
27+
elseif (script_basename() == 'index')
28+
{
29+
include_once(dirname(__FILE__).'/index.inc.php');
30+
}
2731

2832
// Do we have to show a link on the left menu
2933
if ($conf['osm_conf']['left_menu']['enabled'])
@@ -77,9 +81,9 @@ function osm_end_index()
7781
osm_load_language();
7882

7983
$map_url = osm_duplicate_map_index_url( array(), array('start') );
80-
$link_title = sprintf( l10n('displays %s on a map'), strip_tags($page['title']) );
84+
$link_title = sprintf( l10n('DISPLAY_ON_MAP'), strip_tags($page['title']) );
8185
$template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(OSM_ACTION_MODEL,
82-
$map_url, $link_title, '', 'map', l10n('Map')
86+
$map_url, $link_title, '', 'map', l10n('MAP')
8387
).'</li>');
8488
}
8589

@@ -98,8 +102,8 @@ function osm_blockmanager_apply($mb_arr)
98102
include_once( dirname(__FILE__) .'/include/functions.php');
99103
load_language('plugin.lang', OSM_PATH);
100104
global $conf;
101-
$linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : 'OS World Map';
102-
$link_title = sprintf( l10n('displays %s on a map'), strip_tags($conf['gallery_title']) );
105+
$linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : l10n('OSWorldMap');
106+
$link_title = sprintf( l10n('DISPLAY_ON_MAP'), strip_tags($conf['gallery_title']) );
103107
$block->data['osm'] = array(
104108
'URL' => osm_make_map_index_url( array('section'=>'categories') ),
105109
'TITLE' => $link_title,

maintain.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ function plugin_install()
6363
'popupinfo_comment' => true,
6464
'popupinfo_author' => true,
6565
),
66+
'category_description' => array(
67+
'enabled' => true,
68+
'height' => '200',
69+
'width' => 'auto',
70+
),
6671
'map' => array(
6772
'baselayer' => 'mapnik',
6873
'custombaselayer' => null,

picture.inc.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ function osm_insert_map($content, &$smarty)
6363
<div id="map-info" class="imageInfo">
6464
<dt {$OSMNAMECSS}>{$OSMNAME}</dt>
6565
<dd>
66-
<div id="map"></div>
67-
<script type="text/javascript">{$OSMJS}</script>
68-
<div id="osm_attrib" style="visibility: hidden; display: none;">
69-
<ul>
70-
<li>{"PLUGIN_BY"|@translate}</li>
71-
<li><a href="http://leafletjs.com/" target="_blank">Leaflet</a></li>
72-
<li>&copy; {"OSM_CONTRIBUTORS"|@translate}</li>
73-
</ul>
74-
</div>
75-
{if $SHOWOSM}
66+
<div id="map"></div>
67+
<script type="text/javascript">{$OSMJS}</script>
68+
<div id="osm_attrib" style="visibility: hidden; display: none;">
69+
<ul>
70+
<li>{"PLUGIN_BY"|@translate}</li>
71+
<li><a href="http://leafletjs.com/" target="_blank">Leaflet</a></li>
72+
<li>&copy; {"OSM_CONTRIBUTORS"|@translate}</li>
73+
</ul>
74+
</div>
75+
{if $SHOWOSM}
7676
<a href="{$OSMLINK}" target="_blank">{"VIEW_OSM"|@translate}</a>
77-
{/if}
77+
{/if}
7878
</dd>
7979
</div>
8080
{/if}
@@ -138,15 +138,15 @@ function osm_render_element_content()
138138

139139
// Assign the template variables
140140
$template->assign(
141-
array(
142-
'HEIGHT' => $height,
143-
'OSMJS' => $js,
144-
'OSM_PATH' => embellish_url(get_absolute_root_url().OSM_PATH),
145-
'OSMNAME' => $osmname,
146-
'OSMNAMECSS' => $osmnamecss,
147-
'SHOWOSM' => $showosm,
148-
'OSMLINK' => $osmlink,
149-
)
141+
array(
142+
'HEIGHT' => $height,
143+
'OSMJS' => $js,
144+
'OSM_PATH' => embellish_url(get_absolute_root_url().OSM_PATH),
145+
'OSMNAME' => $osmname,
146+
'OSMNAMECSS' => $osmnamecss,
147+
'SHOWOSM' => $showosm,
148+
'OSMLINK' => $osmlink,
149+
)
150150
);
151151

152152
// Return the rendered html

template/osm-map2.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ function toggle(arrow)
359359
var popup = L.popup();
360360
popup
361361
.setLatLng(e.latlng)
362-
.setContent({/literal}{'CLICKED_MAP'|@translate}{literal} + e.latlng.toString())
362+
.setContent("{/literal}{'CLICKED_MAP'|@translate}{literal}" + e.latlng.toString())
363363
.openOn(map);
364364
}
365365

0 commit comments

Comments
 (0)