YaWK  24.1
Yet another WebKit
twitterTimeline.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Twitter Timeline Widget - embed Twitter Timeline</b>
6  *
7  * <p>Embed Twitter Timeline. All you need is the URL of your twitter
8  * timeline 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 Timeline
16  */
17  class twitterTimeline 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 $twitterTimelineHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $twitterTimelineSubtext = '';
25  /** @param string URL of your twitter timeline */
26  public $twitterTimelineUrl = "https://twitter.com/danielretzl";
27  /** @param string How many tweets (latest n) */
28  public $twitterTimelineTweetLimit = "5";
29 
30  /**
31  * @brief Load all widget settings from database and fill object
32  * @param object $db Database Object
33  * @brief Load all widget settings on object init.
34  */
35  public function __construct($db)
36  {
37  // load this widget settings from db
38  $this->widget = new \YAWK\widget();
40  foreach ($settings as $property => $value) {
41  $this->$property = $value;
42  }
43  }
44 
45  /**
46  * @brief Init Twitter Timeline Widget
47  * @brief Twitter Timeline Widget Init
48  */
49  public function init()
50  { // display heading
51  echo $this->getHeading($this->twitterTimelineHeading, $this->twitterTimelineSubtext);
52 
53  // remove trailing slash from url
54  $this->twitterTimelineUrl = rtrim($this->twitterTimelineUrl,"/");
55  // explode user from URL
56  $twitterUserArray = explode("/", $this->twitterTimelineUrl);
57  $twitterUser = $twitterUserArray['3'];
58 
59 echo "<a class=\"twitter-timeline\" data-tweet-limit=\"$this->twitterTimelineTweetLimit\" href=\"$this->twitterTimelineUrl\">Tweets by $twitterUser</a>
60 <script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>";
61  }
62  }
63 }
__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