YaWK  24.1
Yet another WebKit
blog.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\alert;
4 use YAWK\backend;
5 use YAWK\db;
6 use YAWK\language;
7 use YAWK\PLUGINS\BLOG\blog;
8 
9 include '../system/plugins/blog/classes/blog.php';
10 // check if blog object is set
11 if (!isset($blog)) { $blog = new blog(); }
12 // check if language is set
13 if (!isset($language) || (!isset($lang)))
14 { // inject (add) language tags to core $lang array
15  $lang = language::inject(@$lang, "../system/plugins/blog/language/");
16 }
17 if (!isset($db)){
18  $db = new db();
19 }
20 
21 // ADD BLOG
22 if (isset($_GET['addblog']))
23 { // user comes from blog-new
24  if ($_GET['addblog'] == "1")
25  { // check if vars are set
26  if (!empty($_POST['name']) || (!empty($_POST['description'])))
27  { // escape vars
28  $name = $db->quote($_POST['name']);
29  $description = $db->quote($_POST['description']);
30  }
31  else
32  { // empty
33  $name = '';
34  $description = '';
35  }
36  // prepare rest of vars
37  if (!empty($_POST['menuID'])) { $menuID = $db->quote($_POST['menuID']); } else { $menuID = ''; }
38  if (!empty($_POST['icon'])) { $icon = $db->quote($_POST['icon']); } else { $icon = ''; }
39  // create new blog
40  if ($blog->create($db, $name, $description, $menuID, $icon) === true)
41  { // if the user did not set an icon, notify him that he should / can do that.
42  if (empty($icon))
43  { // no icon is set, throw a info alert in users face
44  alert::draw("info", "$lang[DID_YOU_KNOW]", "$lang[BLOG_TIP_ICONS]", "", 12400);
45  }
46  print alert::draw("success", "$lang[SUCCESS]", "$lang[BLOG_ADD_OK]", "", 800);
47  }
48  else
49  { // could not create blog, throw error
50  print alert::draw("danger", "$lang[ERROR]", "$lang[BLOG_ADD_FAILED] $name","",3800);
51  }
52  }
53 }
54 
55 // DELETE BLOG
56 if (isset($_GET['delete']) || ($_GET == "1"))
57 {
58  // if all is set to 1, the full blog, including all items will be deleted
59  if (isset($_GET['all']) && ($_GET['all'] === "true"))
60  { // check if a blogID is set
61  if (isset($_GET['blog']))
62  { // delete full blog including whole content
63  if (!$blog->delete($db, $_GET['blog']))
64  { // delete blog failed, throw error
65  alert::draw("warning", "$lang[ERROR]", "$lang[BLOG_DEL_FAILED] " . $_GET['itemid'] . " ","plugin=blog", 5800);
66  }
67  }
68  }
69 }
70 ?>
71 <script type="text/javascript">
72  $(document).ready(function () {
73  $('#table-sort').dataTable({
74  "bPaginate": false,
75  "bLengthChange": false,
76  "bFilter": true,
77  "bSort": true,
78  "bInfo": true,
79  "bAutoWidth": false
80  });
81  });
82 </script>
83 <?php
84 // TEMPLATE WRAPPER - HEADER & breadcrumbs
85 echo "
86  <!-- Content Wrapper. Contains page content -->
87  <div class=\"content-wrapper\" id=\"content-FX\">
88  <!-- Content Header (Page header) -->
89  <section class=\"content-header\">";
90 /* draw Title on top */
91 echo backend::getTitle($lang['BLOG'], $lang['BLOGS_SUBTEXT']);
92 echo"<ol class=\"breadcrumb\">
93  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
94  <li><a href=\"index.php?page=plugins\" title=\"$lang[PLUGINS]\"> $lang[PLUGINS]</a></li>
95  <li class=\"active\"><a href=\"index.php?plugin=blog\" title=\"$lang[BLOG]\"> $lang[BLOG]</a></li>
96  </ol>
97  </section>
98  <!-- Main content -->
99  <section class=\"content\">";
100 /* page content start here */
101 ?>
102 <div class="box box-default">
103  <div class="box-body">
104 
105 <a class="btn btn-success" href="index.php?plugin=blog&pluginpage=blog-new" style="float:right;">
106  <i class="glyphicon glyphicon-plus"></i> &nbsp;<?php print $lang['BLOG_ADD']; ?></a>
107 
108 <table width="100%" cellpadding="4" cellspacing="0" border="0" class="table table-hover" id="table-sort">
109  <thead>
110  <tr>
111  <td width="3%"><strong>&nbsp;</strong></td>
112  <td width="5%" class="text-center"><strong><?php echo $lang['ID']; ?></strong></td>
113  <td width="3%" class="text-center"><strong>&nbsp;</strong></td>
114  <td width="15%"><strong><?php echo $lang['BLOG']; ?></strong></td>
115  <td width="57%"><strong><?php echo $lang['DESCRIPTION']; ?></strong></td>
116  <td width="7%" class="text-center"><strong><?php echo $lang['ENTRIES']; ?></strong></td>
117  <td width="10%" class="text-center"><strong><?php echo $lang['ACTIONS']; ?></strong></td>
118  </tr>
119  </thead>
120  <tbody>
121  <?php
122  $blog = new blog();
123 
124  if ($res = $db->query("SELECT * FROM {blog} ORDER BY id"))
125  {
126  while ($row = mysqli_fetch_assoc($res)) {
127  $blog->blogid = $row['id'];
128  $blog->name = $row['name'];
129  $blog->description = $row['description'];
130  $blog->icon = $row['icon'];
131  $blog->comments = $row['comments'];
132  // get icon status
133  if (!empty($blog->icon)) {
134  $iconHtml = "<i class=\"fa " . $blog->icon . "\"></i>";
135  } else {
136  $iconHtml = "&nbsp;";
137  }
138  // get published status
139  if ($row['published'] == 1) {
140  $pub = "success";
141  $pubtext = "$lang[ONLINE]";
142  } else {
143  $pub = "danger";
144  $pubtext = "$lang[OFFLINE]";
145  }
146  // if comments are enabled, show 'edit comments' action icon
147  if (isset($blog->comments) && ($blog->comments === '1')) {
148  $commentIcon = "<a href=\"index.php?plugin=blog&pluginpage=blog-comments&blogid=".$blog->blogid."\"><i class=\"fa fa-comments-o\"></i></a>&nbsp;&nbsp;";
149  } else {
150  $commentIcon = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
151  }
152  // count item entries to view in blog overview table
153  if ($res2 = $db->query("SELECT COUNT(id) FROM {blog_items} WHERE blogid = '".$blog->blogid."'"))
154  {
155  $item_count = mysqli_fetch_row($res2);
156  $items = $item_count[0];
157 
158  echo "<tr>
159  <td class=\"text-center\">
160  <a title=\"toggle&nbsp;status\" href=\"index.php?plugin=blog&pluginpage=blog-toggle&blog=" . $row['id'] . "&published=" . $row['published'] . "\">
161  <span class=\"label label-$pub\">$pubtext</span></a>&nbsp;</td>
162  <td class=\"text-center\">" . $row['id'] . "</td>
163  <td>" . $iconHtml . "</td>
164  <td><a href=\"index.php?plugin=blog&pluginpage=blog-entries&blogid=" . $row['id'] . "\"><div style=\"width:100%\">" . $row['name'] . "</div></a></td>
165  <td><a href=\"index.php?plugin=blog&pluginpage=blog-entries&blogid=" . $row['id'] . "\" style=\"color: #7A7376;\"><div style=\"width:100%\">" . $row['description'] . "</div></a></td>
166 
167  <td class=\"text-center\">" . $items . "</td>
168  <td class=\"text-center\">
169  " . $commentIcon . "
170 
171  <a href=\"index.php?plugin=blog&pluginpage=blog-setup&blogid=" . $row['id'] . "\" title=\"" . $row['name'] . "&nbsp;" . $lang['CONFIGURE'] . "\"><i class=\"fa fa-wrench\"></i></a>&nbsp;&nbsp;
172  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$lang[BLOG_DEL_REQUEST] $lang[BLOG] # &laquo;" . $row['id'] . " - " . $row['name'] . "&raquo;\" title=\"" . $lang['BLOG_DELETE'] . "&nbsp;" . $row['name'] . "\" href=\"index.php?plugin=blog&delete=1&blog=" . $row['id'] . "&all=true\">
173  </a>
174  </td>
175  </tr>";
176  }
177  else
178  {
179  alert::draw("warning", "$lang[WARNING]", "$lang[BLOG_FETCH_FAILED]","","3800");
180  }
181  }
182  }
183  else
184  {
185  alert::draw("warning", "$lang[WARNING]", "$lang[BLOG_FETCH_FAILED]","","3800");
186  }
187  ?>
188  </tbody>
189 </table>
190 
191  </div>
192 </div>
$name
Definition: add-comment.php:11
$blog
Definition: blog.php:122
print $lang['BLOG_ADD']
Definition: blog.php:91
Throws a fancy Bootstrap Alert (success, info, warning or danger)
Definition: alert.php:19
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
Mysqli database class; returns db connection object.
Definition: db.php:16
The language class - support multilingual backend.
Definition: language.php:17
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
print $_GET['id']
Definition: page-edit.php:357
function i(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})