Skip to content

Commit

Permalink
fix #441, #442, also use of meeting_count and extra_meetings
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Nov 13, 2023
1 parent d1ddcc6 commit 46f6a93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions crouton.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private function hasShortcode()
// Also, it seems wrong to output this HTML during the enqueue scripts phase, but that's how 3.15 worked
echo '<div class="bootstrap-bmlt" id="please-wait"><button class="btn btn-lg btn-info"><span class="glyphicon glyphicon-repeat glyphicon-repeat-animate"></span>Fetching...</button></div>';
$split = explode("show_map", $shortcode[3]);
if (count($split) > 1) {
if (count($split) > 1 || isset($_GET['show_map'])) {
$this->hasMap = true;
}
}
Expand Down Expand Up @@ -318,8 +318,6 @@ private function sharedRender()
$output = "";
if (isset($_GET['this_title'])) {
$output .= '<div class="bmlt_tabs_title">' . $_GET['this_title'] . '</div>';
} else {
$output .= $sub_title = $meeting_count = $group_count= '';
}

if (isset($_GET['sub_title'])) {
Expand Down Expand Up @@ -429,18 +427,27 @@ private function initCrouton($atts)

public function meetingCount($atts)
{
if (isset($_GET['meeting-id'])) {
return '1';
}
$random_id = rand(10000, 99999);
return $this->getInitializeCroutonBlock(...$this->getCroutonJsConfig($atts)) . "<script type='text/javascript'>jQuery(document).ready(function() { crouton.meetingCount(function(res) { document.getElementById('meeting-count-$random_id').innerHTML = res; }) })</script><span id='meeting-count-$random_id'></span>";
}

public function groupCount($atts)
{
if (isset($_GET['meeting-id'])) {
return '1';
}
$random_id = rand(10000, 99999);
return $this->getInitializeCroutonBlock(...$this->getCroutonJsConfig($atts)) . "<script type='text/javascript'>jQuery(document).ready(function() { crouton.groupCount(function(res) { document.getElementById('group-count-$random_id').innerHTML = res; }) })</script><span id='group-count-$random_id'></span>";
}

public function serviceBodyNames($atts)
{
if (isset($_GET['meeting-id'])) {
return '';
}
$random_id = rand(10000, 99999);
return $this->getInitializeCroutonBlock(...$this->getCroutonJsConfig($atts)) . "<script type='text/javascript'>jQuery(document).ready(function() { crouton.serviceBodyNames(function(res) { document.getElementById('service-body-names-$random_id').innerHTML = res; }) })</script><span id='service-body-names-$random_id'></span>";
}
Expand Down Expand Up @@ -964,8 +971,10 @@ private function templateToParameter($name)
{
if (isset($atts[$name]) && $atts[$name] !== null && $atts[$name] !== "") {
$template = $atts[$name];
} else {
} elseif (isset($this->options[$name])) {
$template = $this->options[$name];
} else {
$template = "";
}
return html_entity_decode($template);
}
Expand Down Expand Up @@ -1097,7 +1106,7 @@ private function getCroutonJsConfig($atts)
$mapParams['google_api_key'] = $this->options['google_api_key'];
$mapParams['template_path'] = $params['template_path'];
$extra_meetings_array = [];
if (isset($this->options['extra_meetings'])) {
if (isset($this->options['extra_meetings']) && !isset($_GET['meeting-id'])) {
foreach ($this->options['extra_meetings'] as $value) {
$data = array(" [", "]");
array_push($extra_meetings_array, str_replace($data, "", $value));
Expand All @@ -1107,7 +1116,7 @@ private function getCroutonJsConfig($atts)
$params['extra_meetings'] = $extra_meetings_array;

if (empty($params['meeting_details_href'])) {
$params['meeting_details_href'] = $_SERVER["REQUEST_URI"];
$params['meeting_details_href'] = strtok($_SERVER["REQUEST_URI"], '?');
}
$this->options['meeting_details_href'] = $params['meeting_details_href'];

Expand Down
2 changes: 1 addition & 1 deletion croutonjs/src/js/crouton-default-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var croutonDefaultTemplates = {
<div class="location-text">{{{this.location_text}}}</div>
<div class="meeting-address">{{this.formatted_address}}</div>
<div class="location-information">{{{this.formatted_location_info}}}</div>
'<a href="https://www.google.com/maps/dir/?api=1&destination={{this.latitude}}%2C{{this.longitude}}" class="bootstrap-bmlt" ><div class="btn btn-primary bmlt-xs get-directions"><span class="glyphicon glyphicon-road"></span> {{getWord "google_directions"}}</div></a>'
<a href="https://www.google.com/maps/dir/?api=1&destination={{this.latitude}}%2C{{this.longitude}}" class="bootstrap-bmlt" ><div class="btn btn-primary bmlt-xs get-directions"><span class="glyphicon glyphicon-road"></span> {{getWord "google_directions"}}</div></a>
<br/>
{{/isInPersonOrHybrid}}
{{#isVirtualOrHybrid this}}
Expand Down

0 comments on commit 46f6a93

Please sign in to comment.