YaWK  24.1
Yet another WebKit
twitterGrid.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Twitter Widget - embed Twitter Timeline as grid</b>
6  *
7  * <p>Twitter Timelines can be embeded as grid view. All you need is
8  * the URL of your twitter timeline and the amount of items you wish
9  * to embed. You will get 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 as grid
16  */
17  class twitterGrid 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 $twitterGridHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $twitterGridSubtext = '';
25  /** @param string URL of your twitter timeline */
26  public $twitterGridUrl = "https://twitter.com/TwitterDev/timelines/539487832448843776";
27  /** @param string How many tweets (latest n) */
28  public $twitterGridTweetLimit = "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 widget
47  * @brief Twitter Widget Init
48  */
49  public function init()
50  { // display heading
51  echo $this->getHeading($this->twitterGridHeading, $this->twitterGridSubtext);
52 
53  // remove trailing slash from url
54  $this->twitterGridUrl = rtrim($this->twitterGridUrl,"/");
55  // explode user from URL
56  $twitterUserArray = explode("/", $this->twitterGridUrl);
57  $twitterUser = $twitterUserArray['3'];
58 
59 echo "<a class=\"twitter-grid\" data-limit=\"$this->twitterGridTweetLimit\" href=\"$this->twitterGridUrl\">$twitterUser Tweets</a>
60 <script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>";
61 
62  }
63  }
64 }
65 ?>
Embed Twitter Timeline as grid.
Definition: twitterGrid.php:17
__construct($db)
Load all widget settings from database and fill object.
Definition: twitterGrid.php:34
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