YaWK  24.1
Yet another WebKit
culturalbroadcasting.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Embed audio player from cultural broadcasting archive.</b>
6  *
7  * <p>Cultural Broadcasting Archive is an austrian podcast archive.
8  * You can embed any public broadcast and set a few settings like
9  * player details, waveform display, social media links and much more.
10  * All you need to embed a player, is the URL to the cba podcast.</p>
11  *
12  *
13  * @author Daniel Retzl <[email protected]>
14  * @copyright 2018 Daniel Retzl
15  * @version 1.0.0
16  * @brief Embed CBA (Cultural Broadcasting Archive) Podcast Player.
17  */
19  {
20  /** @param object global widget object data */
21  public $widget = '';
22  /** @param string cba podcast URL */
23  public $cbaUrl = '';
24  /** @param string Headline */
25  public $cbaHeadline = '';
26  /** @param string Heading */
27  public $cbaHeading = '';
28  /** @param string Subtext */
29  public $cbaSubtext = '';
30  /** @param string Height */
31  public $cbaHeight = '';
32  /** @param string Width */
33  public $cbaWidth = '';
34  /** @param string Display waveform? */
35  public $cbaWaveform = '';
36  /** @param string CBA Title */
37  public $cbaTitle = '';
38  /** @param string Socialmedia Links */
39  public $cbaSocialmedia = '';
40  /** @param string Podcast */
41  public $cbaPodcast = '';
42  /** @param string Series */
43  public $cbaSeries = '';
44  /** @param string Description */
45  public $cbaDescription = '';
46  /** @param string Meta Tags */
47  public $cbaMeta = '';
48  /** @param string Embed Code */
49  public $cbaEmbedCode = '';
50  /** @param string Source URL */
51  public $cbaSource = '';
52 
53  /**
54  * @brief Load all widget settings from database and fill object
55  * @param object $db Database Object
56  * @brief Load all widget settings on object init.
57  */
58  public function __construct($db)
59  {
60  // load this widget settings from db
61  $this->widget = new \YAWK\widget();
63  foreach ($settings as $property => $value) {
64  $this->$property = $value;
65  }
66  }
67 
68  /**
69  * @brief Print all object data
70  * @brief (for development and testing purpose)
71  */
72  public function printObject()
73  {
74  echo "<pre>";
75  print_r($this);
76  echo "</pre>";
77  }
78 
79  /**
80  * @brief Initialize: prepare proerties and load javascript
81  * @brief use this method to run the clock
82  */
83  public function init()
84  {
85  $this->setProperties();
86  $this->embed();
87  }
88 
89  public function setProperties()
90  {
91  // if a heading is set and not empty
92  if (isset($this->cbaHeading) && (!empty($this->cbaHeading)))
93  { // add a h1 tag to heading string
94  $this->cbaHeading = "$this->cbaHeading";
95 
96  // if subtext is set, add <small> subtext to string
97  if (isset($this->cbaSubtext) && (!empty($this->cbaSubtext)))
98  { // build a headline with heading and subtext
99  $this->cbaSubtext = "<small>$this->cbaSubtext</small>";
100  $this->headline = "<h1>$this->cbaHeading&nbsp;"."$this->cbaSubtext</h1>";
101  }
102  else
103  { // build just a headline - without subtext
104  $this->headline = "<h1>$this->cbaHeading</h1>"; // draw just the heading
105  }
106  }
107  else
108  { // leave empty if it's not set
109  $this->headline = '';
110  }
111 
112  /* check if waveform is set to true or false */
113  if ($this->cbaWaveform === "1")
114  {
115  $this->cbaWaveform = "&waveform=true";
116  }
117  else
118  { /* waveform false: adjust height correctly */
119  $this->cbaWaveform = "&waveform=false";
120  }
121 
122  /* is a title set? */
123  if ($this->cbaTitle === "1")
124  {
125  $this->cbaTitle = "&title=true";
126  }
127  else
128  {
129  $this->cbaTitle = "&title=false";
130  }
131 
132  /* is socialmedia set? */
133  if ($this->cbaSocialmedia === "1")
134  {
135  $this->cbaSocialmedia = "&socialmedia=true";
136  }
137  else
138  {
139  $this->cbaSocialmedia = "&socialmedia=false";
140  }
141 
142  /* is series set? */
143  if ($this->cbaSeries === "1")
144  {
145  $this->cbaSeries = "&series_link=true";
146  }
147  else
148  {
149  $this->cbaSeries = "&series_link=false";
150  }
151 
152  /* is podcast set? */
153  if ($this->cbaPodcast === "1")
154  {
155  $this->cbaPodcast = "&subscribe=true";
156  }
157  else
158  {
159  $this->cbaSeries = "&subscribe=false";
160  }
161 
162  /* is description set? */
163  if ($this->cbaDescription === "1")
164  {
165  $this->cbaDescription = "&description=true";
166  }
167  else
168  {
169  $this->cbaDescription = "&description=false";
170  }
171 
172  /* is meta set? */
173  if ($this->cbaMeta === "1")
174  {
175  $this->cbaMeta = "&meta=true";
176  }
177  else
178  {
179  $this->cbaMeta = "&meta=false";
180  }
181  }
182 
183  public function embed()
184  {
185 
186  if (isset($cbaEmbedCode) && (!empty($cbaEmbedCode)))
187  {
188  echo $this->cbaHeadline;
189  echo $cbaEmbedCode;
190  }
191  else
192  {
193  $this->cbaSource = $this->cbaUrl."/embed?".$this->cbaWaveform.$this->cbaTitle.$this->cbaSocialmedia.$this->cbaPodcast.$this->cbaSeries.$this->cbaDescription.$this->cbaMeta;
194  // HTML output
195  echo "
196  <!-- cba stream iframe -->
197  $this->cbaHeadline
198  <iframe width=\"$this->cbaWidth\"
199  height=\"$this->cbaHeight\"
200  src=\"$this->cbaSource\"
201  frameborder=\"0\"
202  scrolling=\"no\"
203  style=\"border:none; width:$this->cbaWidth; height:$this->cbaHeight;\">
204  </iframe>";
205  }
206  }
207  }
208 }
Embed CBA (Cultural Broadcasting Archive) Podcast Player.
init()
Initialize: prepare proerties and load javascript.
__construct($db)
Load all widget settings from database and fill object.
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