YaWK  24.1
Yet another WebKit
blogWidget.php
Go to the documentation of this file.
1 <?php
3  /**
4  * @details<b>Embed plugin: blog</b>
5  *
6  * <p>This is the widget to the blog plugin. With this widget you can embed any blog that you
7  * you've created before using the blog plugin. Simply set the ID of the blog you would like
8  * to embed, setup your settings, choose the position and page where you like to display your
9  * blog and you're good to go. </p>
10  *
11  *
12  * @author Daniel Retzl <[email protected]>
13  * @copyright 2019 Daniel Retzl
14  * @version 1.0.0
15  * @brief Embed a blog on your website.
16  */
17  class blogWidget extends \YAWK\widget
18  {
19  /** @param object global widget object data */
20  public $widget = '';
21  /** @param int Gallery ID */
22  public $blogID = '';
23  /** @param string Title that will be shown above widget */
24  public $blogHeading = '';
25  /** @param string Subtext will be displayed beside title */
26  public $blogSubtext = '';
27  /** @param int Limit Entries (if 0 all items will be displayed)
28  * This can overrule the global blog setting and has only impact
29  * to the specific blog widget */
30  public $blogLimitEntries = '';
31 
32  // for more specific settings take a look at the blog plugin
33 
34  /**
35  * @details 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 Print all object data
51  * @details (for development and testing purpose)
52  */
53  public function printObject()
54  {
55  echo "<pre>";
56  print_r($this);
57  echo "</pre>";
58  }
59 
60  /**
61  * @brief Init Gallery and load methods
62  * @details load Javascript and draw image gallery
63  */
64  public function init($db)
65  {
66  // $this->printObject();
67  $this->drawBlogWidget($db);
68  }
69 
70 
71  /**
72  * @brief Draw the blog
73  * @param db object Database object
74  * @details (for development and testing purpose)
75  */
76  public function drawBlogWidget($db)
77  {
78  /** @param $db \YAWK\db * */
79  error_reporting(1);
80  if (!isset($this->blogID) || (empty($this->blogID)))
81  {
82  echo "Error: unable to load blog because there was no blog ID given.";
83  }
84  else
85  { // include blog plugin base class
86  require_once 'system/plugins/blog/classes/blog.php';
87 
88  // include required JS files
89  /* echo "<script type=\"text/javascript\" src=\"../../../plugins/blog/js/comments.js\"></script>
90  <script type=\"text/javascript\" src=\"../../../plugins/blog/js/voting.js\"></script>";
91  */
92 
93 
94  /*
95  * FRONTEND BLOG PAGE
96  */
97  // create new blog object
98  $blog = new \YAWK\PLUGINS\BLOG\blog();
99 
100  /* a blog can be called by GET variable or via page include */
101  // assign blog ID
102  $blog->blogid = $this->blogID;
103 
104  // load global blog settings
105  $blog->loadBlogProperties($db, $blog->blogid);
106 
107  // for debug purpose
108  // print_r($blog);
109 
110  /* get templateID */
112 
113  // if blog is not offline, get entries from db + draw it on screen.
114  if ($blog->published != 0) {
115  /** @param $widget \YAWK\widget */
116  // get headline
117  $this->headline = $this->getHeading($this->blogHeading, $this->blogSubtext);
118 
119  if (!isset($blog->itemid)) {
120  $blog->itemid = 0;
121  }
122 
123  // load blog title
124  $blog->getTitle($db, $blog->blogid);
125 
126  // check if full view is set
127  if (!isset($full_view)) {
128  $full_view = 0;
129  }
130 
131  // load the blog entries into blog object
132  $blog->getFrontendEntries($db, $blog->blogid, $blog->itemid, $full_view, $this->blogLimitEntries);
133  // check footer setting and load it on demand
134  // if ($blog->getBlogProperty($db, $blog->blogid, "footer")) {
135  // $blog->getFooter($db);
136  // }
137  // finally: draw the blog
138  print $blog->draw();
139  print "</div>";
140  }
141  else
142  { // blog is not published, draw message
143  echo \YAWK\alert::draw("warning", "Entschuldigung!", "Dieser Bereich ist im Moment offline, da gerade daran gearbeitet wird. Bitte komm sp&auml;ter wieder.", "", "4800");
144  }
145  }
146  }
147  }
148 }
149 ?>
$blog
Definition: blog.php:122
$templateID
Definition: blog.php:9
Embed a blog on your website.
Definition: blogWidget.php:18
drawBlogWidget($db)
Draw the blog.
Definition: blogWidget.php:76
printObject()
Print all object data.
Definition: blogWidget.php:53
init($db)
Init Gallery and load methods.
Definition: blogWidget.php:64
__construct($db)
Load all widget settings on object init.
Definition: blogWidget.php:39
static getCurrentTemplateId(object $db)
return ID of current (active) template
Definition: template.php:73
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