YaWK  24.1
Yet another WebKit
widget-toggle.php
Go to the documentation of this file.
1 <?php
2 use YAWK\alert;
3 use YAWK\backend;
4 use YAWK\db;
5 use YAWK\language;
6 use YAWK\widget;
7 
8 /** @var $db db */
9 /** @var $lang language */
10 
11 if (!isset($widget))
12 { // create new widget object
13  $widget = new widget();
14 }
15 // load properties for given widget
16 if (isset($_GET['widget']) && (!empty($_GET['widget'])) && (isset($_GET['published']) && (!empty($_GET['published']))))
17 {
18  // if widget is set
19  $_GET['widget'] = $db->quote($_GET['widget']);
20  $_GET['published'] = $db->quote($_GET['published']);
21  // $widget->loadProperties($db, $_GET['widget']);
22 
23 }
24 // set published status
25 if ($_GET['published'] === '1')
26 { // if 1, set to zero
27  $widget->published = 0;
28 }
29 else
30 { // else set to one
31  $widget->published = 1;
32 }
33 // now toggle it
34 if($widget->toggleOffline($db, $_GET['widget'], $widget->published))
35  { // all good, redirect to widget overview
36  backend::setTimeout("index.php?page=widgets",0);
37  }
38  else
39  { // q failed, throw error
40  print alert::draw("danger", "$lang[ERROR]", "$lang[WIDGET_TOGGLE_FAILED]", "page=widgets","4800");
41  }
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
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
print $_GET['id']
Definition: page-edit.php:357