YaWK  24.1
Yet another WebKit
fb_video.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Facebook video - embed any public facebook video on your page</b>
6  *
7  * <p>Use this widget if you want to embed a facebook video on your page.
8  * You can embed any video, as long as it is public. </p>
9  *
10  *
11  * @author Daniel Retzl <[email protected]>
12  * @copyright 2018 Daniel Retzl
13  * @version 1.0.0
14  * @brief Facebook Like Page - embed like my facebook page
15  */
16  class fbVideo extends \YAWK\widget
17  {
18  /** @param object global widget object data */
19  public $widget = '';
20  /** @param string Html code that you get from facebook */
21  public $fbVideoEmbedCode = "";
22  /** @param string Width of the video in px or percent */
23  public $fbVideoWidth = "450";
24  /** @param string Height of the video in px or percent */
25  public $fbVideoHeight = "265";
26  /** @param object string Heading above the facebook video */
27  public $fbVideoHeading = "";
28  /** @param object string Subtext beside the heading */
29  public $fbVideoSubtext = "";
30 
31  /**
32  * @brief Load all widget settings from database and fill object
33  * @param object $db Database Object
34  * @brief Load all widget settings on object init.
35  */
36  public function __construct($db)
37  {
38  // load this widget settings from db
39  $this->widget = new \YAWK\widget();
41  foreach ($settings as $property => $value) {
42  $this->$property = $value;
43  }
44  }
45 
46  /**
47  * @brief Init facebook video
48  * @brief Facebook video Widget
49  */
50  public function init()
51  {
52  // embed heading
53  echo $this->getHeading($this->fbVideoHeading, $this->fbVideoSubtext);
54  // embed like Page
55  $this->embedvideo();
56  }
57 
58  /**
59  * @brief Embed any public facebook video on your page
60  * @brief Embed any public facebook video on your page
61  */
62  public function embedVideo()
63  { // check if url is set
64  if (isset($this->fbVideoEmbedCode) && (!empty($this->fbVideoEmbedCode)))
65  { // encode url string
66  $this->fbVideoEmbedCode = str_replace("width=\"500\"", "width=\"$this->fbVideoWidth\"", $this->fbVideoEmbedCode);
67  $this->fbVideoEmbedCode = str_replace("height=\"625\"", "height=\"$this->fbVideoHeight\"", $this->fbVideoEmbedCode);
68  // embed facebook video
69  // REMEMBER: this could be blocked by AdBlock Browser Plugins
71  }
72  else
73  { // html embed code is not set - throw msg
74  echo "Unable to load Facebook video: Embed html code is not set or empty.";
75  }
76  }
77  }
78 }
79 ?>
Facebook Like Page - embed like my facebook page.
Definition: fb_video.php:16
embedVideo()
Embed any public facebook video on your page.
Definition: fb_video.php:61
init()
Init facebook video.
Definition: fb_video.php:49
__construct($db)
Load all widget settings from database and fill object.
Definition: fb_video.php:35
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