YaWK  24.1
Yet another WebKit
blog-toggle.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\db;
4 
5 include '../system/plugins/blog/classes/blog.php';
6 // check if blog object is set
7 if (!isset($blog)) { $blog = new \YAWK\PLUGINS\BLOG\blog(); }
8 // check if language is set
9 if (!isset($language) || (!isset($lang)))
10 { // inject (add) language tags to core $lang array
11  $lang = \YAWK\language::inject(@$lang, "../system/plugins/blog/language/");
12 }
13 if (!isset($db)){
14  $db = new db();
15 }
16 
17 $blog->published = $_GET['published'];
18 
19 // check status and toggle it
20 if ($blog->published === '1') {
21  $blog->published = 0;
22  $progress = "danger";
23 } else {
24  $blog->published = 1;
25  $progress = "success";
26 }
27 
28 if ($blog->toggleOffline($db, $_GET['blog'], $blog->published))
29 { // success, redirect user to blog overview
30  \YAWK\backend::setTimeout("index.php?plugin=blog", 0);
31 }
32 else
33 { // failed, throw error
34  print \YAWK\alert::draw("danger", "$lang[ERROR]", "$lang[TOGGLE_BLOG_FAILED].","plugin=blog","3800");
35 }
$blog
Definition: blog.php:122
print $lang['FILEMAN_UPLOAD']
$progress
Definition: blog-toggle.php:25
static setTimeout($location, $wait)
Definition: backend.php:106
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
print $_GET['id']
Definition: page-edit.php:357