YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\YOUTUBE\VIDEO\youtube Class Reference

Embed any YouTube Video on your pages. More...

Public Member Functions

 __construct ($db)
 Load all widget settings on object init. More...
 
 embedVideo ()
 Check settings and embed the YouTube Video. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

 $cssMarkup = ''
 
 $descriptionMarkup = ''
 
 $headlineMarkup = ''
 
 $widget = ''
 
 $youtubeAutoplay = true
 
 $youtubeAutoplayMarkup = ''
 
 $youtubeCssClass = ''
 
 $youtubeDescription = ''
 
 $youtubeFullscreen = true
 
 $youtubeFullscreenMarkup = ''
 
 $youtubeHeading = ''
 
 $youtubeHeight = '720'
 
 $youtubeSubtext = ''
 
 $youtubeVideoUrl = ''
 
 $youtubeWidth = '100%'
 

Detailed Description

Embed any YouTube Video on your pages.

Embed any Facebook Video on your page.

With this widget, you are able to embed any public YouTube Video that you like. Simply enter the Video URL, set a few settings and you're good to go. You do not need to play around with html or any YouTube embed code. This widget does all the work for you!

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 16 of file youtube.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::__construct (   $db)

Load all widget settings on object init.

Load all widget settings from database and fill object params

Parameters
object$dbDatabase Object

Definition at line 54 of file youtube.php.

56  {
57  // load this widget settings from db
58  $this->widget = new \YAWK\widget();
59  $settings = $this->widget->getWidgetSettingsArray($db);
60  foreach ($settings as $property => $value) {
61  $this->$property = $value;
62  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ embedVideo()

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::embedVideo ( )

Check settings and embed the YouTube Video.

This method does the setup and embed job

Definition at line 79 of file youtube.php.

81  {
82  // check if full screen is allowed
83  if ($this->youtubeFullscreen == "true")
84  { // set full screen html markup
85  $this->youtubeFullscreenMarkup = "allowfullscreen=\"true\"";
86  }
87  else
88  { // no full screen, no markup
89  $this->youtubeFullscreenMarkup = '';
90  }
91 
92  // check if autoplay is allowed
93  if ($this->youtubeAutoplay == "true")
94  { // set autoplay markup
95  $this->youtubeAutoplayMarkup = "?autoplay=1";
96  }
97  else
98  { // no autoplay, no markup
99  $this->youtubeAutoplayMarkup = '';
100  }
101 
102  // check if a class is set
103  if (isset($this->youtubeCssClass) && (!empty($this->youtubeCssClass)))
104  {
105  $this->cssMarkup = " class=\"$this->youtubeCssClass\"";
106  }
107  else
108  {
109  $this->cssMarkup = '';
110  }
111 
112  // if a heading is set and not empty
113  if (isset($this->youtubeHeading) && (!empty($this->youtubeHeading)))
114  {
115  // check if subtext is set, add <small> subtext to string
116  if (isset($this->youtubeSubtext) && (!empty($this->youtubeSubtext)))
117  { // build a headline with heading and subtext
118  $this->youtubeSubtext = "<small>$this->youtubeSubtext</small>";
119  $this->headlineMarkup = "<h1>$this->youtubeHeading&nbsp;$this->youtubeSubtext</h1>";
120  }
121  else
122  { // build headline - without subtext
123  $this->headlineMarkup = "<h1>$this->youtubeHeading</h1>"; // draw just the heading
124  }
125  }
126  else
127  { // leave empty if it's not set
128  $this->headlineMarkup = '';
129  }
130 
131  // if description is set, add <p> to string
132  if (isset($this->youtubeDescription) && (!empty($this->youtubeDescription)))
133  { // set description string
134  $this->descriptionMarkup = "<p>$this->youtubeDescription</p>";
135  }
136  else
137  { // no description is set
138  $this->descriptionMarkup = '';
139  }
140 
141  // switch plain youtube url to correct embed url string
142  $this->youtubeVideoUrl = str_replace("watch?v=","embed/",$this->youtubeVideoUrl.$this->youtubeAutoplayMarkup);
143 
144 
145  // css style to make it responsive
146  echo "
147 
148 <style>
149 .videoWrapper {
150  position: relative;
151  padding-bottom: 56.25%; /* 16:9 */
152  padding-top: 25px;
153  height: 0;
154 }
155 .videoWrapper iframe {
156  position: absolute;
157  top: 0;
158  left: 0;
159  width: 100%;
160  height: 100%;
161 }
162 </style>";
163 
164  // YouTube Video Embed HTML markup
165  echo "
166 $this->headlineMarkup
167 <!-- youtube video wrapper -->
168 <div class=\"videoWrapper\">
169 <!-- youtube video iframe -->
170 <iframe width=\"$this->youtubeWidth\"
171  height=\"$this->youtubeHeight\"
172  src=\"$this->youtubeVideoUrl\"
173  frameborder=\"0\"
174  scrolling=\"no\"
175  $this->youtubeFullscreenMarkup
176  $this->cssMarkup>
177 </iframe>
178 $this->descriptionMarkup
179 <!-- end video wrapper -->
180 </div>";

◆ printObject()

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::printObject ( )

Print all object data.

(for development and testing purpose)

Definition at line 68 of file youtube.php.

70  {
71  echo "<pre>";
72  print_r($this);
73  echo "</pre>";

Member Data Documentation

◆ $cssMarkup

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$cssMarkup = ''
Parameters
stringcss markup

Definition at line 47 of file youtube.php.

◆ $descriptionMarkup

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$descriptionMarkup = ''
Parameters
stringdescription markup below video

Definition at line 45 of file youtube.php.

◆ $headlineMarkup

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$headlineMarkup = ''
Parameters
stringheading markup above video

Definition at line 43 of file youtube.php.

◆ $widget

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$widget = ''
Parameters
objectglobal widget object data

Definition at line 19 of file youtube.php.

◆ $youtubeAutoplay

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeAutoplay = true
Parameters
booltrue|false Should the video automatically start on page load?

Definition at line 27 of file youtube.php.

◆ $youtubeAutoplayMarkup

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeAutoplayMarkup = ''
Parameters
boolstring autoplay html markup

Definition at line 29 of file youtube.php.

◆ $youtubeCssClass

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeCssClass = ''
Parameters
stringCSS Class

Definition at line 41 of file youtube.php.

◆ $youtubeDescription

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeDescription = ''
Parameters
stringDescription below heading

Definition at line 39 of file youtube.php.

◆ $youtubeFullscreen

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeFullscreen = true
Parameters
booltrue|false Allow embeded full screen mode?

Definition at line 23 of file youtube.php.

◆ $youtubeFullscreenMarkup

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeFullscreenMarkup = ''
Parameters
boolstring html markup for fullscreen mode

Definition at line 25 of file youtube.php.

◆ $youtubeHeading

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeHeading = ''
Parameters
stringHeading above video

Definition at line 35 of file youtube.php.

◆ $youtubeHeight

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeHeight = '720'
Parameters
stringVideo Height

Definition at line 31 of file youtube.php.

◆ $youtubeSubtext

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeSubtext = ''
Parameters
stringSubtext beside heading

Definition at line 37 of file youtube.php.

◆ $youtubeVideoUrl

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeVideoUrl = ''
Parameters
stringYouTube Video URL

Definition at line 21 of file youtube.php.

◆ $youtubeWidth

YAWK\WIDGETS\YOUTUBE\VIDEO\youtube::$youtubeWidth = '100%'
Parameters
stringVideo Width

Definition at line 33 of file youtube.php.


The documentation for this class was generated from the following file: