YaWK  24.1
Yet another WebKit
googleMaps.php
Go to the documentation of this file.
1 <?php
3  /**
4  * @details<b>Google Maps Widget - Embed a Google Map on your page</b>
5  *
6  * <p>This Widget serves all methods to draw any Google Map on your website.
7  * To do this: go to Google Maps, click on embed and you will get a piece of html code.
8  * Simply copy/paste the code into the textarea, click save and your google map
9  * will be displayed in your chosen widget position.</p>
10  *
11  *
12  * @author Daniel Retzl <[email protected]>
13  * @copyright 2018 Daniel Retzl
14  * @version 1.0.0
15  * @brief Embed Google Maps on your page.
16  */
17  class googleMaps extends \YAWK\widget
18  {
19  /** @param object global widget object data */
20  public $widget = '';
21  /** @param string the html code you'll get from google <iframe...> */
23  /** @param string Heading above Google Map */
24  public $googleMapsHeading = '';
25  /** @param string Subtext beside heading */
26  public $googleMapsSubtext = '';
27 
28  /**
29  * @brief Load all widget settings from database and fill object
30  * @param object $db Database Object
31  * @brief Load all widget settings on object init.
32  */
33  public function __construct($db)
34  {
35  // load this widget settings from db
36  $this->widget = new \YAWK\widget();
38  foreach ($settings as $property => $value) {
39  $this->$property = $value;
40  }
41  }
42 
43  /**
44  * @brief Print all object data
45  * @brief (for development and testing purpose)
46  */
47  public function printObject()
48  { // output data to screen
49  echo "<pre>";
50  print_r($this);
51  echo "</pre>";
52  }
53 
54  /**
55  * @brief Init and embed Google Maps
56  * @brief Embed Google Maps
57  */
58  public function init()
59  { // embed Google Maps
60  $this->embed();
61  }
62 
63  public function embed()
64  {
65  // draw heading above google map
66  echo $this->getHeading($this->googleMapsHeading, $this->googleMapsSubtext);
67 
68  // check if embed html code is set and correct data type
69  if (isset($this->googleMapsEmbedHtmlCode)
70  && (!empty($this->googleMapsEmbedHtmlCode))
71  && (is_string($this->googleMapsEmbedHtmlCode)))
72  {
73  // embed code seems to be valid -
74  // draw Google Map...
76  }
77  else
78  {
79  echo "Here should be a Google Map, but the required embed code was not set.";
80  }
81  }
82  }
83 }
Embed Google Maps on your page.
Definition: googleMaps.php:18
__construct($db)
Load all widget settings from database and fill object.
Definition: googleMaps.php:33
init()
Init and embed Google Maps.
Definition: googleMaps.php:58
printObject()
Print all object data.
Definition: googleMaps.php:47
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
getWidgetSettingsArray($db)
Get widget settings and return it as array.
Definition: widget.php:69
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669
if(isset($_POST['save'])) $settings
$value