Commit 281a7493 authored by Simon's avatar Simon

divisions fixed

parent ca5492fb
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
### DB backup ### 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` - `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` - `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 ### DB restore
......
This diff is collapsed.
...@@ -8,10 +8,10 @@ ...@@ -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; .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; }
&:hover { background-color: #DDE6F5; }
}
/*a.c-division { color: #004ED4; }*/
/* critical:end */ /* 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 @@ ...@@ -88,7 +88,7 @@
<?php <?php
endif; 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 <?php
// global $time_start; // global $time_start;
......
...@@ -483,8 +483,7 @@ function start_session() { ...@@ -483,8 +483,7 @@ function start_session() {
} }
} }
function getBiuroDivisions ( $request ) {
function getDivisions ( $request ) {
$res = array(); $res = array();
$params = $request->get_params(); $params = $request->get_params();
...@@ -492,34 +491,24 @@ function getDivisions ( $request ) { ...@@ -492,34 +491,24 @@ function getDivisions ( $request ) {
exit; exit;
} }
$lang = (string) $params['lang']; $langID = (int) $params['langID'];
$divisions = pods( 'division', array(
'limit' => -1
) );
if ( 0 < $divisions->total() ):
while ( $divisions->fetch() ) :
$slug = $divisions->display( 'city.slug' );
if ($lang !== pll_get_post_language( $divisions->display( 'ID' ) ) || !$divisions->display( 'lat' ) || !$divisions->display( 'lng' )): $divisions = getDivisions($langID);
continue;
endif;
if ( !$res[ $slug ] ) : foreach ($divisions as &$division) :
$res[ $slug ] = array(); $slug = $division['slug'];
endif;
array_push($res[ $slug ], array( if ( !$res[ $slug ] ) :
'title' => $divisions->display( 'title' ), $res[ $slug ] = array();
'content' => $divisions->display( 'content' ), endif;
'lat' => $divisions->display( 'lat' ),
'lng' => $divisions->display( 'lng' ),
) );
array_push($res[ $slug ], array(
endwhile; 'title' => $division['title'],
endif; 'content' => nl2br($division['content']),
'lat' => $division['lat'],
'lng' => $division['lng'],
) );
endforeach;
return new WP_REST_Response( $res, 200 ); return new WP_REST_Response( $res, 200 );
} }
...@@ -528,9 +517,9 @@ add_action( 'rest_api_init', function () { ...@@ -528,9 +517,9 @@ add_action( 'rest_api_init', function () {
register_rest_route( 'api/v1', '/divisions', array( register_rest_route( 'api/v1', '/divisions', array(
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => 'getDivisions', 'callback' => 'getBiuroDivisions',
'args' => array( 'args' => array(
'lang' => array( 'langID' => array(
'validate_callback' => function($param, $request, $key) { 'validate_callback' => function($param, $request, $key) {
return is_string( $param ); return is_string( $param );
} }
...@@ -817,3 +806,28 @@ function getResults($taxonomy, $term, $termID) { ...@@ -817,3 +806,28 @@ function getResults($taxonomy, $term, $termID) {
return $wpdb->get_results($sql, ARRAY_A); 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 @@ ...@@ -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-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" > <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-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" 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> <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> </noscript>
<?php wp_head(); ?> <?php wp_head(); ?>
......
...@@ -28,16 +28,16 @@ ...@@ -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-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" > <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-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" 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> <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> </noscript>
<?php wp_head(); ?> <?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) { ...@@ -47,7 +47,7 @@ if (module.hot) {
return; 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((t) => t.json())
.then((data) => { .then((data) => {
initDivisionsMap(node, data); initDivisionsMap(node, data);
...@@ -126,8 +126,9 @@ const mapStyles = [ ...@@ -126,8 +126,9 @@ const mapStyles = [
} }
]; ];
var info;
function setMarkers (map, positions, focus) { function setMarkers (map, positions, focus) {
var info;
var bounds = new window.google.maps.LatLngBounds(); var bounds = new window.google.maps.LatLngBounds();
for (var i = 0; i < positions.length; i++) { for (var i = 0; i < positions.length; i++) {
...@@ -141,15 +142,16 @@ function setMarkers (map, positions, focus) { ...@@ -141,15 +142,16 @@ function setMarkers (map, positions, focus) {
title: position.title || '' title: position.title || ''
}); });
if (info) {
info.close();
}
bounds.extend(pos); bounds.extend(pos);
if (position.content) { if (position.content) {
marker['content'] = position.content; marker['content'] = position.content;
window.google.maps.event.addListener(marker, 'click', function () { window.google.maps.event.addListener(marker, 'click', function () {
if (info) {
info.close();
}
info = new window.google.maps.InfoWindow({ info = new window.google.maps.InfoWindow({
content: this.content content: this.content
......
This diff is collapsed.
...@@ -16,9 +16,12 @@ global $post; ...@@ -16,9 +16,12 @@ global $post;
$pageID = $post->ID; $pageID = $post->ID;
$langs = pll_the_languages(array('raw'=>1));
$langID = $langs[pll_current_language('slug')]['id'];
get_header(); ?> 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"> <div id="content" class="l-content--divisions">
<main id="main" class="l-main l-main--divisions"> <main id="main" class="l-main l-main--divisions">
...@@ -38,38 +41,39 @@ get_header(); ?> ...@@ -38,38 +41,39 @@ get_header(); ?>
// $total = $related->total(); // $total = $related->total();
$divisions = pods( 'division', array( // delog($langID, '$langID');
'limit' => -1
) ); $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(); $cities = array();
?> ?>
<div class="c-divisions"> <div class="c-divisions">
<?php <?php
if ( 1 < $divisions->total() ): if ( 1 < count($divisions) ):
?> ?>
<span class="js-division c-division"><?php _e('All', 'biuro'); ?></span> <span class="js-division c-division"><?php _e('All', 'biuro'); ?></span>
<?php <?php
endif; endif;
while ( $divisions->fetch() ) : foreach ($divisions as &$division) :
$slug = $divisions->display( 'city.slug' ); $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 <?php
array_push($cities, $slug); array_push($cities, $slug);
endif; endif;
endwhile; endforeach;
?> ?>
</div> </div>
</main><!-- .l-main --> </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