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 +24 -12 1.7.2 → 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 */
@@ -268,8 +277,9 @@
268 277 $container = new stdClass;
269 278 $container->size = 'medium';
270 279 $container->widgets = [
271 280 'finance',
281 + 'inquiries_chat',
272 282 'currency_converter',
273 283 ];
274 284 // push container
275 285 array_push($section->containers, $container);
@@ -387,13 +397,17 @@
387 397 $descr = $widget->getDescription();
388 398
389 399 if ($preload) {
390 400 // preload widget's CSS/JS assets (if any)
391 - $watch_data = $widget->preload();
401 + $watch_data = array_key_exists($id, static::$preloaded) ? static::$preloaded[$id] : $widget->preload();
402 +
392 403 if ($watch_data) {
393 404 // assign watching data to this widget
394 405 $watch[$id] = $watch_data;
395 406 }
407 +
408 + // overwrite cache for the preloaded widget result
409 + static::$preloaded[$id] = $watch_data;
396 410 }
397 411
398 412 // build widget info object
399 413 $wtdata = new stdClass;
@@ -460,11 +474,12 @@
460 474 * containers and widgets.
461 475 */
462 476 public function getWidgetsMap()
463 477 {
464 - $q = "SELECT `setting` FROM `#__vikbooking_config` WHERE `param`='admin_widgets_map';";
465 - $this->dbo->setQuery($q);
466 - $map = $this->dbo->loadResult();
478 + $config = VBOFactory::getConfig();
479 +
480 + $map = $config->get('admin_widgets_map', null);
481 +
467 482 if ($map) {
468 483 $map = json_decode($map);
469 484 return is_object($map) && !empty($map->sections) && is_array($map->sections) ? $map : $this->getDefaultWidgetsMap();
470 485 }
@@ -469,12 +484,11 @@
469 484 return is_object($map) && !empty($map->sections) && is_array($map->sections) ? $map : $this->getDefaultWidgetsMap();
470 485 }
471 486
472 487 $default_map = $this->getDefaultWidgetsMap();
473 - $q = "INSERT INTO `#__vikbooking_config` (`param`,`setting`) VALUES ('admin_widgets_map', " . $this->dbo->quote(json_encode($default_map)) . ");";
474 - $this->dbo->setQuery($q);
475 - $this->dbo->execute();
476 488
489 + $config->set('admin_widgets_map', $default_map);
490 +
477 491 return $default_map;
478 492 }
479 493
480 494 /**
@@ -493,11 +507,9 @@
493 507 // prepare new map object
494 508 $map = new stdClass;
495 509 $map->sections = $sections;
496 510
497 - $q = "UPDATE `#__vikbooking_config` SET `setting`=" . $this->dbo->quote(json_encode($map)) . " WHERE `param`='admin_widgets_map';";
498 - $this->dbo->setQuery($q);
499 - $this->dbo->execute();
511 + VBOFactory::getConfig()->set('admin_widgets_map', $map);
500 512
501 513 return true;
502 514 }
503 515
@@ -521,13 +533,13 @@
521 533 /**
522 534 * Forces the rendering of a specific widget identifier.
523 535 *
524 536 * @param string $id the widget identifier.
525 - * @param VBOMultitaskData $data optional multitask data for the widget.
537 + * @param ?VBOMultitaskData $data optional multitask data for the widget.
526 538 *
527 539 * @return void
528 540 */
529 - public function renderWidget($id, VBOMultitaskData $data = null)
541 + public function renderWidget($id, ?VBOMultitaskData $data = null)
530 542 {
531 543 $id = $this->simplifyId($id);
532 544
533 545 foreach ($this->widgets as $widget) {