YaWK  24.1
Yet another WebKit
embedPage.php
Go to the documentation of this file.
1 <?php
3  /**
4  * @details<b>Embed any static page in any widget position.</b>
5  *
6  * <p>Simply set the page you want to embed.</p>
7  *
8  *
9  * @author Daniel Retzl <[email protected]>
10  * @copyright 2018 Daniel Retzl
11  * @version 1.0.0
12  * @brief Embed any static page in any widget position.
13  */
14  class embedPage
15  {
16  /** @param object global widget object data */
17  public $widget = '';
18  /** @param string The name of the page to embed */
19  public $embedPageName = '';
20  /** @param string File url, including path */
21  public $file = '';
22 
23  /**
24  * @brief Load all widget settings from database and fill object
25  * @param object $db Database Object
26  * @brief Load all widget settings on object init.
27  */
28  public function __construct($db)
29  {
30  // load this widget settings from db
31  $this->widget = new \YAWK\widget();
33  foreach ($settings as $property => $value) {
34  $this->$property = $value;
35  }
36  }
37 
38  /**
39  * @brief Init and embed static page
40  * @param object $db Database Object
41  * @brief Init and include static page.
42  */
43  public function init()
44  { // check if embed page name is set
45  if (isset($this->embedPageName) && (!empty($this->embedPageName)))
46  {
47  // generate file name including path
48  $this->file = "content/pages/$this->embedPageName";
49  // check file extension
50  if (substr($this->file, -5) == ".html")
51  { // remove last 5 chars and add .php to include correct file
52  $this->file = substr($this->file, 0, -5);
53  $this->file = $this->file.".php";
54  }
55  // check if file can be loaded
56  if (is_file($this->file))
57  { // ok, include it
58  include ($this->file);
59  }
60  // if not, check if embedPageName can be loaded
61  else if (is_file($this->embedPageName))
62  { // ok, include it
63  include ($this->embedPageName);
64  }
65  else
66  { // file not found
67  echo "Embed: $this->file not found!";
68  }
69  }
70  else
71  { // no file was set...
72  echo "Embed page name $this->embedPageName not set";
73  }
74  }
75  }
76 }
Embed any static page in any widget position.
Definition: embedPage.php:15
init()
Init and embed static page.
Definition: embedPage.php:43
__construct($db)
Load all widget settings from database and fill object.
Definition: embedPage.php:28
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
if(isset($_POST['save'])) $settings
$value