Commit 281a7493 authored by Simon's avatar Simon

divisions fixed

parent ca5492fb
......@@ -59,7 +59,7 @@
### DB backup
- `C:\web\dev.biuro> docker exec -i dev-biuro-mysql mysqldump -udev_user -pY6V6bFkD6@GyD!wTShgFmWz! --default-character-set=utf8 dev_biuro > docker/mariadb/data-004.sql`
- `sudo docker exec -i biuro-staging-mysql mysqldump -ustaging_user -p'qzl8pMNV^gZ&c1!7ebVsXqQh' --default-character-set=utf8 staging_biuro > docker/mariadb/data-018.sql`
- `sudo docker exec -i biuro-staging-mysql mysqldump -ustaging_user -p'qzl8pMNV^gZ&c1!7ebVsXqQh' --default-character-set=utf8 staging_biuro > docker/mariadb/data-019.sql`
- `sudo docker exec -i biuro-www-mysql mysqldump -uwww_user -p'qzl8pMNV^gZ&c1!7ebVsXqQh' --default-character-set=utf8 www_biuro > docker/mariadb/data-018.sql`
### DB restore
......
This diff is collapsed.
......@@ -8,10 +8,10 @@
}
}
.c-division { flex: 0 0 auto; height: 30px; margin: 0 10px 10px 0; padding: 0 20px; border-radius: 3px; background-color: #E8F0FF; color: #004ED4; font-weight: 500; line-height: 30px; white-space: nowrap; text-decoration: none; cursor: pointer;
&:hover { background-color: #DDE6F5; }
}
/*a.c-division { color: #004ED4; }*/
.c-division { flex: 0 0 auto; height: 30px; margin: 0 10px 10px 0; padding: 0 20px; background-color: #E8F0FF; line-height: 30px; white-space: nowrap; }
/* critical:end */
.c-division { user-select: none; cursor: pointer; border-radius: 3px; color: #004ED4; font-weight: 500;
&:hover { background-color: #DDE6F5; }
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -88,7 +88,7 @@
<?php
endif;
?>
<script src="/wp-content/themes/biuro/js/main-ef4b0946.min.js" async></script>
<script src="/wp-content/themes/biuro/js/main.min.js" async></script>
<?php
// global $time_start;
......
......@@ -483,8 +483,7 @@ function start_session() {
}
}
function getDivisions ( $request ) {
function getBiuroDivisions ( $request ) {
$res = array();
$params = $request->get_params();
......@@ -492,34 +491,24 @@ function getDivisions ( $request ) {
exit;
}
$lang = (string) $params['lang'];
$divisions = pods( 'division', array(
'limit' => -1
) );
if ( 0 < $divisions->total() ):
while ( $divisions->fetch() ) :
$slug = $divisions->display( 'city.slug' );
$langID = (int) $params['langID'];
if ($lang !== pll_get_post_language( $divisions->display( 'ID' ) ) || !$divisions->display( 'lat' ) || !$divisions->display( 'lng' )):
continue;
endif;
$divisions = getDivisions($langID);
if ( !$res[ $slug ] ) :
$res[ $slug ] = array();
endif;
foreach ($divisions as &$division) :
$slug = $division['slug'];
array_push($res[ $slug ], array(
'title' => $divisions->display( 'title' ),
'content' => $divisions->display( 'content' ),
'lat' => $divisions->display( 'lat' ),
'lng' => $divisions->display( 'lng' ),
) );
if ( !$res[ $slug ] ) :
$res[ $slug ] = array();
endif;
endwhile;
endif;
array_push($res[ $slug ], array(
'title' => $division['title'],
'content' => nl2br($division['content']),
'lat' => $division['lat'],
'lng' => $division['lng'],
) );
endforeach;
return new WP_REST_Response( $res, 200 );
}
......@@ -528,9 +517,9 @@ add_action( 'rest_api_init', function () {
register_rest_route( 'api/v1', '/divisions', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'getDivisions',
'callback' => 'getBiuroDivisions',
'args' => array(
'lang' => array(
'langID' => array(
'validate_callback' => function($param, $request, $key) {
return is_string( $param );
}
......@@ -817,3 +806,28 @@ function getResults($taxonomy, $term, $termID) {
return $wpdb->get_results($sql, ARRAY_A);
}
function getDivisions($ID) {
global $wpdb;
$langID = (int) $ID;
$prefix = $wpdb->prefix;
$sql = "SELECT DISTINCT `t`.post_title as title, `t`.post_content as content, `lat`.meta_value as lat, `lng`.meta_value as lng, `term`.name as city, `term`.slug as slug
FROM `{$prefix}posts` AS `t`
LEFT JOIN `{$prefix}postmeta` AS `lat` ON `lat`.`meta_key` = 'lat' AND `lat`.`post_id` = `t`.`ID`
LEFT JOIN `{$prefix}postmeta` AS `lng` ON `lng`.`meta_key` = 'lng' AND `lng`.`post_id` = `t`.`ID`
LEFT JOIN `{$prefix}term_relationships` AS `rel_term` ON `rel_term`.`object_id` = `t`.`ID`
INNER JOIN `{$prefix}term_taxonomy` AS `rel_tt_term` ON `rel_tt_term`.`taxonomy` = 'city' AND `rel_tt_term`.`term_taxonomy_id` = `rel_term`.`term_taxonomy_id`
LEFT JOIN `{$prefix}terms` AS `term` ON `term`.`term_id` = `rel_tt_term`.`term_id`
LEFT JOIN `{$prefix}term_relationships` AS `polylang_languages` ON `polylang_languages`.`object_id` = `t`.`ID` AND `polylang_languages`.`term_taxonomy_id` = $langID
WHERE ( ( `t`.`post_status` IN ( 'publish' ) ) AND ( `t`.`post_type` = 'division' ) AND ( `polylang_languages`.`object_id` IS NOT NULL ) )
ORDER BY `t`.`menu_order`, `t`.`post_title`, `t`.`post_date`";
return $wpdb->get_results($sql, ARRAY_A);
}
......@@ -28,16 +28,16 @@
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-500.woff2" crossorigin="anonymous" >
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-regular.woff2" crossorigin="anonymous" >
<style><?php include 'css/core-6f505ba98b.min.css'; ?></style>
<style><?php include 'css/core.min.css'; ?></style>
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-300.woff2" crossorigin="anonymous" >
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-700.woff2" crossorigin="anonymous" >
<link rel="preload" href="/wp-content/themes/biuro/css/main-452cf2643c.min.css" as="style" onload="this.rel='stylesheet'">
<link rel="preload" href="/wp-content/themes/biuro/css/main.min.css" as="style" onload="this.rel='stylesheet'">
<noscript>
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main-452cf2643c.min.css">
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main.min.css">
</noscript>
<?php wp_head(); ?>
......
......@@ -28,16 +28,16 @@
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-500.woff2" crossorigin="anonymous" >
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-regular.woff2" crossorigin="anonymous" >
<style><?php include 'css/core-6f505ba98b.min.css'; ?></style>
<style><?php include 'css/core.min.css'; ?></style>
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-300.woff2" crossorigin="anonymous" >
<link rel="preload" as="font" type="font/woff2" href="/wp-content/themes/biuro/fonts/roboto-v19-cyrillic_latin_cyrillic-ext_latin-ext-700.woff2" crossorigin="anonymous" >
<link rel="preload" href="/wp-content/themes/biuro/css/main-452cf2643c.min.css" as="style" onload="this.rel='stylesheet'">
<link rel="preload" href="/wp-content/themes/biuro/css/main.min.css" as="style" onload="this.rel='stylesheet'">
<noscript>
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main-452cf2643c.min.css">
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main.min.css">
</noscript>
<?php wp_head(); ?>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -47,7 +47,7 @@ if (module.hot) {
return;
}
fetch('/wp-json/api/v1/divisions?lang=' + node.dataset.lang)
fetch('/wp-json/api/v1/divisions?langID=' + node.dataset.id)
.then((t) => t.json())
.then((data) => {
initDivisionsMap(node, data);
......@@ -126,8 +126,9 @@ const mapStyles = [
}
];
var info;
function setMarkers (map, positions, focus) {
var info;
var bounds = new window.google.maps.LatLngBounds();
for (var i = 0; i < positions.length; i++) {
......@@ -141,15 +142,16 @@ function setMarkers (map, positions, focus) {
title: position.title || ''
});
if (info) {
info.close();
}
bounds.extend(pos);
if (position.content) {
marker['content'] = position.content;
window.google.maps.event.addListener(marker, 'click', function () {
if (info) {
info.close();
}
info = new window.google.maps.InfoWindow({
content: this.content
......
This diff is collapsed.
......@@ -16,9 +16,12 @@ global $post;
$pageID = $post->ID;
$langs = pll_the_languages(array('raw'=>1));
$langID = $langs[pll_current_language('slug')]['id'];
get_header(); ?>
<div class="l-map" id="js-map--divisions" data-lang="<?php echo pll_current_language(); ?>"></div>
<div class="l-map" id="js-map--divisions" data-id="<?php echo $langID; ?>"></div>
<div id="content" class="l-content--divisions">
<main id="main" class="l-main l-main--divisions">
......@@ -38,38 +41,39 @@ get_header(); ?>
// $total = $related->total();
$divisions = pods( 'division', array(
'limit' => -1
) );
// delog($langID, '$langID');
$divisions = getDivisions($langID);
// debug($divisions);
// global $wpdb;
// delog(pll_current_language());
// delog($wpdb->last_query);
// debug($wpdb->last_result);
if ( 0 < $divisions->total() ):
$divs = pods( 'division', array(
'limit' => -1
) );
if ( 0 < count($divisions) ):
$cities = array();
?>
<div class="c-divisions">
<?php
if ( 1 < $divisions->total() ):
if ( 1 < count($divisions) ):
?>
<span class="js-division c-division"><?php _e('All', 'biuro'); ?></span>
<?php
endif;
while ( $divisions->fetch() ) :
$slug = $divisions->display( 'city.slug' );
foreach ($divisions as &$division) :
$slug = $division['slug'];
if ( !in_array($slug, $cities) && $divisions->display( 'name' ) ) :
if ( !in_array($slug, $cities) && $division['city'] ) :
?>
<span class="js-division c-division" data-id="<?php echo $slug; ?>"><?php echo $divisions->display( 'city' ); ?></span>
<span class="js-division c-division" data-id="<?php echo $slug; ?>"><?php echo $division['city']; ?></span>
<?php
array_push($cities, $slug);
endif;
endwhile;
endforeach;
?>
</div>
</main><!-- .l-main -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment