YaWK  24.1
Yet another WebKit
blog-entries.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\alert;
4 use YAWK\db;
5 
6 include '../system/plugins/blog/classes/blog.php';
7 // check if blog object is set
8 if (!isset($blog)) { $blog = new \YAWK\PLUGINS\BLOG\blog(); }
9 // check if language is set
10 if (!isset($language) || (!isset($lang)))
11 { // inject (add) language tags to core $lang array
12  $lang = \YAWK\language::inject(@$lang, "../system/plugins/blog/language/");
13 }
14 if (!isset($db)){
15  $db = new db();
16 }
17 // SET BLOG ITEM PROPERTIES
18 if (isset($_GET['blogid']))
19  { // pickup + store the blog ID from GET variable
20  $blog->id = $_GET['blogid'];
21  }
22  else
23  { // default value:
24  $blog->id = 1;
25  }
26 // get BLOG properties
27 $blog->name = $blog->getBlogProperty($db, $blog->id, "name");
28 $blog->icon = $blog->getBlogProperty($db, $blog->id, "icon");
29 $blog->comments = $blog->getBlogProperty($db, $blog->id, "comments");
30 
31 // TOGGLE ITEM
32 if (isset($_GET['toggle']))
33 {
34  $published = $_GET['published'];
35  if (isset($_GET['id']) && (!empty($_GET['id']) && (is_numeric($_GET['id']))))
36  {
37  $blog->itemid = $_GET['id'];
38  }
39  else
40  {
41  $blog->itemid = 0;
42  }
43 
44 // check status and toggle it
45  if ($published == '1') {
46  $published = 0;
47  $status = "$lang[OFFLINE]";
48  $color = "success";
49  } else {
50  $published = 1;
51  $status = "$lang[ONLINE]";
52  $color = "success";
53  }
54 
55  if ($blog->toggleItemOffline($db, $blog->itemid, $published))
56  { //
57  print alert::draw($color, "$lang[PAGE] $lang[IS] $lang[NOW] $status", "$lang[PAGE_TOGGLE] $lang[SUCCESSFUL]", "", 800);
58  }
59  else
60  {
61  print alert::draw("danger", "$lang[ERROR]", "$lang[PAGE_TOGGLE_FAILED]", "", 6800);
62  }
63 
64 }
65 
66 // COPY ENTRY
67 if (isset($_GET['copy']))
68 {
69  if (isset($_GET['blogid']) && (isset($_GET['itemid'])))
70  {
71  // new blog object
72  $page = new \YAWK\page();
73  $blog = new \YAWK\PLUGINS\BLOG\blog();
74  $blog->id = $db->quote($_GET['blogid']);
75  $blog->itemid = $db->quote($_GET['itemid']);
76  $blog->itemgid = $db->quote($_GET['itemgid']);
77  $blog->loadItemProperties($db, $blog->id, $blog->itemid);
78  $blog->sort++;
79  $blog->alias = $page->getProperty($db, $blog->pageid, "alias");
80  // call copy method
81 
82  if($_GET['copy'] === "true")
83  {
84  if($blog->copyItem($db))
85  { // success
86  alert::draw("success", "$lang[SUCCESS]", "$lang[BLOG] $lang[ITEM] ".$_GET['itemid']." $lang[COPIED]","","2000");
87  }
88  else
89  { // copy failed, throw error
90  alert::draw("danger", "$lang[ERROR]", "$lang[BLOG] $lang[ITEM]", "plugin=blog&pluginpage=blog-entries&blogid=$blog->id $lang[COPY] $lang[FAILED]","3800");
91  }
92  }
93  }
94 }
95 
96 // DELETE ENTRY
97 if (isset($_GET['delete']) || ($_GET === "1"))
98 {
99  // if an itemID is set, just delete THIS itemID
100  if (isset($_GET['itemid'])) { $_GET['itemid'] = $db->quote($_GET['itemid']); }
101  if (isset($_GET['blogid'])) { $_GET['blogid'] = $db->quote($_GET['blogid']); }
102  if (isset($_GET['pageid'])) { $_GET['pageid'] = $db->quote($_GET['pageid']); }
103  if (isset($_GET['title'])) { $_GET['title'] = $db->quote($_GET['title']); }
104  if (isset($_GET['itemid']))
105  { // delete blog item
106  if (!$blog->deleteItem($db, $_GET['blogid'], $_GET['itemid'], $_GET['pageid']))
107  { // delete item failed, throw error
108  alert::draw("danger", "$lang[ERROR] $lang[ID] #$_GET[itemid] / $_GET[title]", "$lang[PAGE_DEL_FAILED]", "", 5800);
109  }
110  }
111 }
112 // set blog object properties
113 if (isset($_GET['deletecomment']))
114 {
115  // DELETE COMMENT
116  if ($_GET['deletecomment'] === "true") {
117  // delete comment
118  if (isset($_GET['commentid']) && (isset($_GET['itemid']) && (isset($_GET['blogid'])))) {
119  if ($blog->deleteComment($db, $_GET['blogid'], $_GET['itemid'], $_GET['commentid'])) {
120  alert::draw("success", "$lang[SUCCESS] ", "$lang[COMMENT] $lang[ID] " . $_GET['id'] . " $lang[DELETED]", "","1200");
121  }
122  else
123  {
124  alert::draw("danger", "$lang[ERROR] ", "$lang[DELETE] $lang[COMMENT] $lang[ID] " . $_GET['id'] . " ", "","3800");
125  }
126  }
127  }
128 }
129 /* draw Title on top */
130 
131 ?>
132 <script type="text/javascript">
133  $(document).ready(function () {
134  $('#table-sort').dataTable({
135  "bPaginate": false,
136  "bLengthChange": false,
137  "bFilter": true,
138  "bSort": true,
139  "bInfo": true,
140  "bAutoWidth": false
141  });
142  });
143 </script>
144 <?php
145 // TEMPLATE WRAPPER - HEADER & breadcrumbs
146 echo "
147 <!-- Content Wrapper. Contains page content -->
148 <div class=\"content-wrapper\" id=\"content-FX\">
149  <!-- Content Header (Page header) -->
150  <section class=\"content-header\">";
151  /* draw Title on top */
152  \YAWK\PLUGINS\BLOG\blog::getBlogTitle($blog->name, $lang['MANAGE'], $blog->icon);
153  echo"<ol class=\"breadcrumb\">
154  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
155  <li><a href=\"index.php?page=plugins\" title=\"$lang[PLUGINS]\"> $lang[PLUGINS]</a></li>
156  <li class=\"active\"><a href=\"index.php?plugin=blog\" title=\"$lang[BLOG]\"> $lang[BLOG]</a></li>
157  </ol>
158  </section>
159  <!-- Main content -->
160  <section class=\"content\">";
161  /* page content start here */
162 ?>
163 <div class="box box-default">
164  <div class="box-body">
165 
166 <a class="btn btn-success" href="index.php?plugin=blog&pluginpage=blog-newitem&blogid=<?php echo $blog->id; ?>" style="float:right;">
167  <i class="glyphicon glyphicon-plus"></i> &nbsp;<?php print $lang['BLOG+']; ?></a>
168 
169 <a class="btn btn-default" href="index.php?plugin=blog" style="float:right;">
170  <i class="glyphicon glyphicon-backward"></i> &nbsp;<?php print $lang['BACK']; ?></a>
171 
172 <table width="100%" cellpadding="4" cellspacing="0" border="0" class="table table-striped table-hover" id="table-sort">
173  <thead>
174  <tr>
175  <td width="3%"><strong>&nbsp;</strong></td>
176  <td width="5%" class="text-center"><strong><?php print $lang['ID']; ?></strong></td>
177  <td width="25%"><strong><?php print $lang['TITLE']; ?></strong></td>
178  <td width="30%"><strong><?php print $lang['SUBTITLE']; ?></strong></td>
179  <td width="5%" class="text-center"><strong><?php print $lang['AUTHOR']; ?></strong></td>
180  <td width="5%" class="text-center"><strong><?php print $lang['GROUP']; ?></strong></td>
181  <td width="10%" class="text-center"><strong><?php print $lang['START_PUBLISH']; ?></strong></td>
182  <td width="7%" class="text-center"><strong><?php print $lang['COMMENTS']; ?></strong></td>
183  <td width="10%" class="text-center"><strong><?php print $lang['ACTIONS']; ?></strong></td>
184  </tr>
185  </thead>
186  <tbody>
187  <?php
188 
189  if ($res = $db->query("SELECT ci.*, cu.username as username, cr.value as gid FROM {blog_items} as ci
190  INNER JOIN {users} as cu on ci.uid = cu.id
191  INNER JOIN {user_groups} as cr on ci.itemgid = cr.id
192  WHERE blogid = '" . $blog->id . "' ORDER BY date_publish"))
193  {
194  while ($row = mysqli_fetch_assoc($res))
195  {
196  $date_publish = $row['date_publish'];
197  $date_unpublish = $row['date_unpublish'];
198  $atm = date("Y-m-d H:i:s");
199 
200  // on / off badge logic
201  switch ($row['published']) {
202  case 0:
203  $pub = "danger";
204  $pubtext = "$lang[OFFLINE]";
205  break;
206  case 1:
207  $pub = "success";
208  $pubtext = "$lang[ONLINE]";
209  break;
210  }
211 
212  // group id badge logic
213  switch ($row['itemgid']) {
214  case 1:
215  $rcolor = "success";
216  break;
217  case 2:
218  $rcolor = "warning";
219  break;
220  default:
221  $rcolor = "danger";
222  break;
223  }
224 
225  if ($atm < $date_publish) {
226  $pub = "warning";
227  $pubtext = "$lang[IN_QUEUE]";
228  }
229  if (!is_null($date_unpublish)){
230  if ($atm >= $date_unpublish) {
231  $pub = "default";
232  $pubtext = "$lang[EXPIRED]";
233  }
234  }
235 
236  // count comments
237  $i_comments = \YAWK\PLUGINS\BLOG\blog::countActiveComments($db, $blog->id, $row['id']);
238  if ($i_comments !== '0') {
239  $commentIcon = "<a href=\"index.php?plugin=blog&pluginpage=blog-comments&itemid=".$row['id']."&blogid=".$blog->id."\"><i class=\"fa fa-comments-o\"></i></a>&nbsp;&nbsp;";
240  }
241  else {
242  $commentIcon = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
243  $i_comments = '';
244  }
245  // draw table and badges
246  echo "<tr>
247  <td class=\"text-center\">
248  <a href=\"index.php?plugin=blog&pluginpage=blog-entries&toggle=1&published=" . $row['published'] . "&blogid=" . $blog->id . "&id=" . $row['id'] . "\">
249  <span class=\"label label-$pub\">$pubtext</span></a>&nbsp;</td>
250  <td class=\"text-center\">" . $row['id'] . "</td>
251  <td><a href=\"index.php?plugin=blog&pluginpage=blog-edit&itemid=" . $row['id'] . "&blogid=" . $blog->id . "\"><div style=\"width:100%\">" . $row['title'] . "</div></a></td>
252  <td><a href=\"index.php?plugin=blog&pluginpage=blog-edit&itemid=" . $row['id'] . "&blogid=" . $blog->id . "\" style=\"color: #7A7376;\"><div style=\"width:100%\">" . $row['subtitle'] . "</div></a></td>
253  <td class=\"text-center\">" . $row['username'] . "</td>
254 
255  <td class=\"text-center\">
256  <a href=\"index.php?plugin=blog&pluginpage=blog-togglegroup&itemgid=" . $row['itemgid'] . "&blogid=" . $blog->id . "&itemid=" . $row['id'] . "\">
257  <span class=\"label label-$rcolor\">" . $row['gid'] . "</span></a></td>
258 
259  <td class=\"text-center\">" . $date_publish . "</td>
260  <td class=\"text-center\">" . $i_comments . "</td>
261  <td class=\"text-center\">
262  ".$commentIcon."
263  <a class=\"fa fa-copy\" title=\"" . $lang['COPY'] . ": " . $row['title'] . "\" href=\"index.php?plugin=blog&pluginpage=blog-entries&copy=true&itemgid=" . $row['itemgid'] . "&itemid=".$row['id']."&blogid=" . $blog->id . "\"></a>&nbsp;
264 
265 
266 
267  <a class=\"fa fa-edit\" title=\"" . $lang['EDIT'] . ": " . $row['title'] . "\" href=\"index.php?plugin=blog&pluginpage=blog-edit&itemid=" . $row['id'] . "&blogid=" . $blog->id . "\"></a>&nbsp;
268  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"".$lang['ENTRY']." &laquo;" . $row['id'] . " / " . $row['title'] . "&raquo; ".$lang['BLOG_ITEM_DEL_REQUEST']."\"
269  title=\"" . $lang['DEL'] . "\" href=\"index.php?plugin=blog&pluginpage=blog-entries&title=".$row['title']."&pageid=" . $row['pageid'] . "&itemid=" . $row['id'] . "&blogid=" . $blog->id . "&delete=1\">
270  </a>
271  </td>
272  </tr>";
273  }
274  }
275  else
276  {
277  alert::draw("warning", "$lang[WARNING] ", "$lang[BLOG_ENTRY_DEL_FAILED]", "","3800");
278  }
279  ?>
280  </tbody>
281 </table>
282 
283  </div>
284 </div>
$blog
Definition: blog.php:122
print $lang['BLOG+']
Throws a fancy Bootstrap Alert (success, info, warning or danger)
Definition: alert.php:19
Mysqli database class; returns db connection object.
Definition: db.php:16
static inject(array $lang, string $pathToFile)
allow plugins to inject language tags to $lang array
Definition: language.php:439
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
print $_GET['id']
Definition: page-edit.php:357
$page
Definition: pages.php:355
function i(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
print $tourdates date
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);});})