YaWK  24.1
Yet another WebKit
instagram.php
Go to the documentation of this file.
1 <?php
3  /**
4  * @details<b>Instagram Widget - embed any single instagram posting</b>
5  *
6  * <p>If you want to embed instagram on your page, this is the widget to do it.
7  * All you need is a valid instagram url and (optional) some settings, like width
8  * or link target. Of course you can set a custom heading and subtext above posting.</p>
9  *
10  *
11  * @author Daniel Retzl <[email protected]>
12  * @copyright 2018 Daniel Retzl
13  * @version 1.0.0
14  * @brief Embed Instagram on your page.
15  */
16  class instagram extends \YAWK\widget
17  {
18  /** @param object global widget object data */
19  public $widget = '';
20  /** @param string Any valid instagram url */
21  public $instagramUrl = '';
22  /** @param string Width of your posting */
23  public $instagramWidth = '';
24  /** @param string Link target (_blank, _parent, _self) */
25  public $instagramTarget = '';
26  /** @param string Heading above widget */
27  public $instagramHeading = '';
28  /** @param string Subtext beside heading */
29  public $instagramSubtext = '';
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 Print all object data
48  * @brief (for development and testing purpose)
49  */
50  public function printObject()
51  { // output data to screen
52  echo "<pre>";
53  print_r($this);
54  echo "</pre>";
55  }
56 
57  /**
58  * @brief Init and embed Instagram
59  * @brief Embed Google Maps
60  */
61  public function init()
62  { // embed Instagram
63  $this->embed();
64  }
65 
66  public function embed()
67  {
68  // draw heading above google map
69  echo $this->getHeading($this->instagramHeading, $this->instagramSubtext);
70 
71  // check if embed html code is set and correct data type
72  if (isset($this->instagramUrl)
73  && (!empty($this->instagramUrl))
74  && (is_string($this->instagramUrl)))
75  {
76  // url seems to be valid...
77  echo '
78 <blockquote class="instagram-media"
79  data-instgrm-captioned data-instgrm-version="7"
80  style="background:#fff;
81  border:0;
82  border-radius:3px;
83  box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15);
84  margin: 1px;
85  max-width:'.$this->instagramWidth.';
86  padding:0;
87  width:'.$this->instagramWidth.';">
88 
89  <p style="margin:8px 0 0 0; padding:0 4px;">
90  <a href="'.$this->instagramUrl.'"
91  style="color:#000;
92  font-family:Arial,sans-serif;
93  font-size:14px;
94  font-style:normal;
95  font-weight:normal;
96  line-height:17px;
97  text-decoration:none;
98  word-wrap:break-word;"
99  target="'.$this->instagramTarget.'"></a>
100  </p>
101 </blockquote>
102 <script async defer src="//platform.instagram.com/en_US/embeds.js"></script>';
103  }
104  else
105  { // url not valid, throw error msg
106  echo "Here should be an Instagram posting, but the required url was not set.";
107  }
108  }
109  }
110 }
Embed Instagram on your page.
Definition: instagram.php:17
__construct($db)
Load all widget settings from database and fill object.
Definition: instagram.php:36
init()
Init and embed Instagram.
Definition: instagram.php:61
printObject()
Print all object data.
Definition: instagram.php:50
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