YaWK  24.1
Yet another WebKit
twitterTweet.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Twitter Tweet Widget - embed Twitter Tweet</b>
6  *
7  * <p>Embed Twitter Tweet. All you need is the URL of your tweet
8  * and the amount of items you wish to embed. You will get
9  * the latest tweets.</p>
10  *
11  *
12  * @author Daniel Retzl <[email protected]>
13  * @copyright 2018 Daniel Retzl
14  * @version 1.0.0
15  * @brief Embed Twitter Tweet
16  */
17  class twitterTweet extends \YAWK\widget
18  {
19  /** @param object global widget object data */
20  public $widget = '';
21  /** @param string Title that will be shown above widget */
22  public $twitterSingleTweetHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $twitterSingleTweetSubtext = '';
25  /** @param string URL of your twitter Tweet */
26  public $twitterSingleTweetUrl = "https://twitter.com/danielretzl";
27  /** @param string How many tweets (latest n) */
28  public $twitterSingleTweetTweetLimit = "5";
29  /** @param string Hide data cards */
31  /** @param string How many tweets (latest n) */
33 
34  /**
35  * @brief Load all widget settings from database and fill object
36  * @param object $db Database Object
37  * @brief Load all widget settings on object init.
38  */
39  public function __construct($db)
40  {
41  // load this widget settings from db
42  $this->widget = new \YAWK\widget();
44  foreach ($settings as $property => $value) {
45  $this->$property = $value;
46  }
47  }
48 
49  /**
50  * @brief Init Twitter Tweet Widget
51  * @brief Embed a single tweet from twitter
52  */
53  public function init()
54  { // display heading
55  echo $this->getHeading($this->twitterSingleTweetHeading, $this->twitterSingleTweetSubtext);
56 
57  /* CHECK SETTINGS AND SET THEM CORRECTLY */
58  /* DATA CONVERSATION */
59  // if data conversation is set to 1, conversation will be shown in this tweet
60  if ($this->twitterSingleTweetDataConversation === "1")
61  {
62  $this->twitterSingleTweetDataConversation = '';
63  }
64  else
65  { // conversation will be hidden from this tweet
66  $this->twitterSingleTweetDataConversation = 'data-conversation="none"';
67  }
68 
69  /* HIDE MEDIA */
70  // if data-cards is set to 1, media files will be shown
71  if ($this->twitterSingleTweetHideDataCards === "1")
72  {
73  $this->twitterSingleTweetHideDataCards = 'data-cards="hidden"';
74  }
75  else
76  { // otherwise, media will be hidden from this tweet
77  $this->twitterSingleTweetHideDataCards = '';
78  }
79 
80 echo "<blockquote class=\"twitter-tweet\" $this->twitterSingleTweetHideDataCards $this->twitterSingleTweetDataConversation><a href=\"$this->twitterSingleTweetUrl\"></a></blockquote>
81 <script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>";
82  }
83  }
84 }
init()
Init Twitter Tweet Widget.
__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
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669
if(isset($_POST['save'])) $settings
$value