Skip to content

Commit

Permalink
Merge pull request #997 from OpenDevelopmentMekong/master
Browse files Browse the repository at this point in the history
merging to prod for releasing v2.2.45
  • Loading branch information
Alex Corbi authored Jun 8, 2017
2 parents a83c07d + 91964b4 commit fd40e14
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 25 deletions.
9 changes: 8 additions & 1 deletion inc/embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,15 @@ function display_embedded_map($mapID, $layerID = null, $show_odlogo = null) {
display_baselayer_navigation();
$base_layers = get_post_meta_of_all_baselayer();
$show_cat = get_post_meta($mapID, '_jeo_map_show_cat', true);
if(isset($_GET['show_cat'])){
$show_cat = $_GET['show_cat'];
}
$show_hierarchy = get_post_meta($mapID, '_jeo_map_show_hierarchy', true);
if(isset($_GET['show_hierarchy'])){
$show_hierarchy = $_GET['show_hierarchy'];
}
//Show Menu Layers and legendbox
display_map_layer_sidebar_and_legend_box($layers, $show_cat);
display_map_layer_sidebar_and_legend_box($layers, $show_cat, $show_hierarchy);
printing_map_footnote();
?>
</div>
Expand Down
3 changes: 0 additions & 3 deletions inc/jeo-scripts/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
$(this).siblings(".layer-toggle-info").removeClass('show_it');
});

$(window).scroll(function () {
$('.map-legend-container').css('bottom', "5px");
});
//Hide and show on click the collapse and expend icon
$(document).on('click',".hide_show_container h2 > .hide_show_icon, .hide_show_container h5 > .hide_show_icon", function (e) {
e.stopPropagation();
Expand Down
50 changes: 41 additions & 9 deletions inc/layers.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function post_layers_box($post = false) {
$layers = array();
$post_layers = $post ? $this->get_map_layers($post->ID) : false;
$show_cat = get_post_meta($post->ID, '_jeo_map_show_cat', true);
$show_hierarchy = get_post_meta($post->ID, '_jeo_map_show_hierarchy', true);
?>

<p>
Expand Down Expand Up @@ -122,25 +123,29 @@ function post_layers_box($post = false) {
<table class="layers-list available-layers">
<tbody data-bind="foreach: filteredLayers">
<tr>
<td><strong data-bind="text: title"></strong></td>
<td><strong><a data-bind="text: title, attr: {href: url}" target="_blank"></a></strong></td>
<td data-bind="text: type"></td>
<td><a target="_blank" data-bind="attr: {href:'<?php echo get_bloginfo("url")."/wp-admin/post.php?action=edit&post="; ?>'+ID}" title="<?php _e('edit', 'odm'); ?>"><?php _e('Edit'); ?></a></td>
<td style="width:1%;"><a class="button" data-bind="click: $parent.addLayer" href="javascript:void(0);" title="<?php _e('Add layer', 'odm'); ?>">+ <?php _e('Add'); ?></a></td>
</tr>
</tbody>
</table>

<h4 class="selected-title"><?php _e('Selected layers', 'odm'); ?></h4>
<p class='jeo_map_show_cat'>
<input type="checkbox" name="_jeo_map_show_cat" id="_jeo_map_show_cat" value="1" <?php checked(1, $show_cat);?>>
<label for="_jeo_map_show_cat"><?php _e('Group layers by showing category', 'odm'); ?></label>
<input type="checkbox" name="_jeo_map_show_cat" id="jeo_map_show_cat" value="1" <?php checked(1, $show_cat);?>>
<label for="jeo_map_show_cat"><?php _e('Group layers by showing category', 'odm'); ?></label> &nbsp;&nbsp;

<input type="checkbox" name="_jeo_map_show_hierarchy" id="jeo_map_show_hierarchy" disabled value="1" <?php checked(1, $show_hierarchy);?>>
<label for="jeo_map_show_hierarchy"><?php _e('Show category layers in hierarchy', 'odm'); ?></label>
</p>

<table class="layers-list selected-layers">
<tbody class="selected-layers-list">
<!-- ko foreach: {data: selectedLayers} -->
<tr class="layer-item">
<td style="width: 30%;">
<p><strong data-bind="text: title"></strong></p>
<td style="width: 60%;">
<p><strong><a data-bind="text: title, attr: {href: url}" target="_blank"></a></strong></p>
<p data-bind="text: type"></p>
</td>
<td>
Expand All @@ -165,6 +170,7 @@ function post_layers_box($post = false) {
</div>
</div>
</td>
<td><a target="_blank" data-bind="attr: {href:'<?php echo get_bloginfo("url")."/wp-admin/post.php?action=edit&post="; ?>'+ID}" title="<?php _e('edit', 'odm'); ?>"><?php _e('Edit'); ?></a></td>
<td style="width:1%;"><a class="button" data-bind="click: $parent.removeLayer" href="javascript:void(0);" title="<?php _e('Remove layer', 'odm'); ?>"><?php _e('Remove'); ?></a></td>
</tr>
<!-- /ko -->
Expand All @@ -184,16 +190,22 @@ function post_layers_box($post = false) {
}
#post-layers .selected-layers .layer-item {
width: 100%;
height: 100px;
max-height: 100px;
font-size: 14px;
}
#post-layers .layers-list tr td {
margin: 0;
border: 1px solid #f0f0f0;
padding: 5px 8px;
font-size: 14px;
}
#post-layers .layers-list tr:hover td {
background: #fff;
}

#post-layers p{
margin: 5px 0
}
.jeo_map_show_cat{
display: none;
}
Expand Down Expand Up @@ -330,7 +342,18 @@ function LayersModel() {
var model = new LayersModel();
model.bindSort('.selected-layers-list', 'selectedLayers');
ko.applyBindings(model);

enable_hierarchy_checkbox();
$("#jeo_map_show_cat").click(enable_hierarchy_checkbox);
});

function enable_hierarchy_checkbox() {
if ($('#jeo_map_show_cat').is(":checked")) {
$("input#jeo_map_show_hierarchy").removeAttr("disabled");
} else {
$("input#jeo_map_show_hierarchy").attr("disabled", true);
}
}
</script>
<?php
wp_reset_query();
Expand Down Expand Up @@ -822,6 +845,12 @@ function map_save($post_id) {
update_post_meta($post_id, '_jeo_map_show_cat', FALSE);
}

if(isset($_REQUEST['_jeo_map_show_hierarchy'])) {
update_post_meta($post_id, '_jeo_map_show_hierarchy', TRUE);
}else{
update_post_meta($post_id, '_jeo_map_show_hierarchy', FALSE);
}

}
}

Expand All @@ -838,12 +867,12 @@ function get_map_layers($post_id = false, $filter = "") {
$layer['filtering'] = $l['filtering'];

if($filter == "baselayer") {
if($layer['map_category'] == "base-layers"){
if($layer['map_category']['name'] == "base-layers"){
$layer['post_title'] = $l['title'];
$layers[] = $layer;
}
}elseif($filter == "layer") {
if($layer['map_category'] != "base-layers"){
if($layer['map_category']['name'] != "base-layers"){
$layers[] = $layer;
}
}else{
Expand Down Expand Up @@ -889,11 +918,14 @@ function get_layer($post_id = false) {
$layer = array(
'ID' => $post->ID,
'title' => get_the_title(),
'url' => get_permalink(),
'type' => $type
);

if (!empty($in_category)):
$layer['map_category'] = $in_category[0]->slug;
$layer['map_category']['id'] = $in_category[0]->term_id;
$layer['map_category']['name'] = $in_category[0]->slug;
$layer['map_category']['parent'] = $in_category[0]->parent;
endif;

if($type == 'tilelayer') {
Expand Down
43 changes: 36 additions & 7 deletions inc/utils/mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,68 @@ function get_post_meta_of_all_baselayer($num=5, $cat='base-layers', $include_chi
return $base_layers;
}
//************//
function display_map_layer_sidebar_and_legend_box($layers, $show_cat = null){
function display_map_layer_sidebar_and_legend_box($layers, $show_cat = null, $is_hierarchy = false){
if (!empty($layers)){
unset($layers[0]); //basemap

echo '<div class="category-map-layers box-shadow hide_show_container">';
echo '<h2 class="sidebar_header map_headline widget_headline">'.__("Map Layers", "odm");
echo "<i class='fa fa-caret-down hide_show_icon'></i>";
echo '</h2>';
echo '<div class="interactive-map-layers dropdown">';
if($show_cat):
$tmp_category = array();
foreach ($layers as $key => $row) {
foreach ($layers as $key => $row) :
$tmp_category[$key] = null;
if(isset($row['map_category'])):
$tmp_category[$key] = $row['map_category'];
$layer_cat[] = $row['map_category'];
if($is_hierarchy):
if($row['map_category']['parent'] == 0):
$tmp_category[$key] = $row['map_category']['name'];
$layer_cat[] = $row['map_category']['name'];
else:
$parent_cat = $row['map_category']['parent'];
$layer_subcat[$parent_cat][] = $row['map_category']['name'];
endif;
else:
$tmp_category[$key] = $row['map_category']['name'];
$layer_cat[] = $row['map_category']['name'];
endif;
endif;
}
endforeach;
$layer_category = array_unique($layer_cat);
asort($layer_category);
array_multisort($tmp_category, SORT_ASC, $layers);

echo '<ul class="categories layer-category">';
foreach ($layer_category as $cat) {
$category = get_term_by('slug', $cat, 'layer-category');
echo '<li class="cat-item cat-item-'.$category->term_id.'" id="post-'.$category->term_id.'">';
echo'<a href="#">'.$category->name.'</a>';
echo "<ul class='cat-layers switch-layers cat-layer-items'>";
foreach ($layers as $id => $layer) {
if($layer['map_category'] == $cat):
if($layer['map_category']['name'] == $cat):
display_layer_as_menu_item_on_mapNavigation($layer['ID'], 1, $layer['filtering']);
endif;
}
echo "</ul>";
if(isset($layer_subcat[$category->term_id])):
$layer_subcategory = array_unique($layer_subcat[$category->term_id]);
asort($layer_subcategory);
foreach ($layer_subcategory as $subcat):
echo '<ul class="children">';
$sub_category = get_term_by('slug', $subcat, 'layer-category');
echo '<li class="cat-item cat-item-'.$sub_category->term_id.'" id="post-'.$sub_category->term_id.'">';
echo'<a href="#">'.$sub_category->name.'</a>';
echo "<ul class='cat-layers switch-layers cat-layer-items'>";
foreach ($layers as $id => $layer) {
if($layer['map_category']['name'] == $subcat):
display_layer_as_menu_item_on_mapNavigation($layer['ID'], 1, $layer['filtering']);
endif;
}
echo "</ul>";
echo "</li>";
echo "</ul>";
endforeach;
endif;
echo "</li>";
}

Expand Down
4 changes: 0 additions & 4 deletions less/_map-explorer.less
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,6 @@ html#map-embed {
#embeded-interactive-map {
height: 100%;

.map-legend-container {
bottom: 0;
}

.jeo-date-range-slider {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Author: Open Development Mekong
Author URI: http://github.com/OpenDevelopmentMekong
Description: Open Development Mekong's wordpress theme. Based on JEO child theme
Template: jeo
Version: 2.2.44
Version: 2.2.45
License: GNU General Public License v3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand Down

0 comments on commit fd40e14

Please sign in to comment.