PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/admin_widgets.php +25 -12 1.7.0 → 1.8.16 View file →
@@ -31,8 +31,17 @@
31 31 */
32 32 protected static $helper = null;
33 33
34 34 /**
35 + * List of preloaded widgets.
36 + *
37 + * @var array
38 + *
39 + * @since 1.18.3 (J) - 1.8.3 (WP)
40 + */
41 + protected static $preloaded = [];
42 +
43 + /**
35 44 * The database handler instance.
36 45 *
37 46 * @var object
38 47 */
@@ -217,8 +226,9 @@
217 226 // start container
218 227 $container = new stdClass;
219 228 $container->size = 'small';
220 229 $container->widgets = [
230 + 'aitools',
221 231 'forecast',
222 232 'bookings_calendar',
223 233 'reminders',
224 234 ];
@@ -267,8 +277,9 @@
267 277 $container = new stdClass;
268 278 $container->size = 'medium';
269 279 $container->widgets = [
270 280 'finance',
281 + 'inquiries_chat',
271 282 'currency_converter',
272 283 ];
273 284 // push container
274 285 array_push($section->containers, $container);
@@ -386,13 +397,17 @@
386 397 $descr = $widget->getDescription();
387 398
388 399 if ($preload) {
389 400 // preload widget's CSS/JS assets (if any)
390 - $watch_data = $widget->preload();
401 + $watch_data = array_key_exists($id, static::$preloaded) ? static::$preloaded[$id] : $widget->preload();
402 +
391 403 if ($watch_data) {
392 404 // assign watching data to this widget
393 405 $watch[$id] = $watch_data;
394 406 }
407 +
408 + // overwrite cache for the preloaded widget result
409 + static::$preloaded[$id] = $watch_data;
395 410 }
396 411
397 412 // build widget info object
398 413 $wtdata = new stdClass;
@@ -459,11 +474,12 @@
459 474 * containers and widgets.
460 475 */
461 476 public function getWidgetsMap()
462 477 {
463 - $q = "SELECT `setting` FROM `#__vikbooking_config` WHERE `param`='admin_widgets_map';";
464 - $this->dbo->setQuery($q);
465 - $map = $this->dbo->loadResult();
478 + $config = VBOFactory::getConfig();
479 +
480 + $map = $config->get('admin_widgets_map', null);
481 +
466 482 if ($map) {
467 483 $map = json_decode($map);
468 484 return is_object($map) && !empty($map->sections) && is_array($map->sections) ? $map : $this->getDefaultWidgetsMap();
469 485 }
@@ -468,12 +484,11 @@
468 484 return is_object($map) && !empty($map->sections) && is_array($map->sections) ? $map : $this->getDefaultWidgetsMap();
469 485 }
470 486
471 487 $default_map = $this->getDefaultWidgetsMap();
472 - $q = "INSERT INTO `#__vikbooking_config` (`param`,`setting`) VALUES ('admin_widgets_map', " . $this->dbo->quote(json_encode($default_map)) . ");";
473 - $this->dbo->setQuery($q);
474 - $this->dbo->execute();
475 488
489 + $config->set('admin_widgets_map', $default_map);
490 +
476 491 return $default_map;
477 492 }
478 493
479 494 /**
@@ -492,11 +507,9 @@
492 507 // prepare new map object
493 508 $map = new stdClass;
494 509 $map->sections = $sections;
495 510
496 - $q = "UPDATE `#__vikbooking_config` SET `setting`=" . $this->dbo->quote(json_encode($map)) . " WHERE `param`='admin_widgets_map';";
497 - $this->dbo->setQuery($q);
498 - $this->dbo->execute();
511 + VBOFactory::getConfig()->set('admin_widgets_map', $map);
499 512
500 513 return true;
501 514 }
502 515
@@ -520,13 +533,13 @@
520 533 /**
521 534 * Forces the rendering of a specific widget identifier.
522 535 *
523 536 * @param string $id the widget identifier.
524 - * @param VBOMultitaskData $data optional multitask data for the widget.
537 + * @param ?VBOMultitaskData $data optional multitask data for the widget.
525 538 *
526 539 * @return void
527 540 */
528 - public function renderWidget($id, VBOMultitaskData $data = null)
541 + public function renderWidget($id, ?VBOMultitaskData $data = null)
529 542 {
530 543 $id = $this->simplifyId($id);
531 544
532 545 foreach ($this->widgets as $widget) {