YaWK  24.1
Yet another WebKit
widgets.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\sys;
8  use YAWK\widget;
9 
10  /** @var $db db */
11  /** @var $lang language */
12 
13 // ADD WIDGET
14 if (isset($_GET['add']) && ($_GET['add'] === "1"))
15 { // prepare vars
16  $pageID = $db->quote($_POST['pageID']);
17  $widgetType = $db->quote($_POST['widgetType']);
18  $positions = $db->quote($_POST['positions']);
19  $date_publish = sys::now();
20 
21  $newWidgetID = widget::create($db, $widgetType, $pageID, $positions);
22  if (is_int($newWidgetID) || (is_numeric($newWidgetID)))
23  { // success
24  print alert::draw("success", "$lang[SUCCESS]", "$lang[WIDGET_CREATE_OK]", "page=widget-edit&widget=$newWidgetID", 800);
25  }
26  else
27  { // throw error
28  print alert::draw("danger", "$lang[ERROR]", "$lang[WIDGET_CREATE_FAILED]<br>Widget ID: $newWidgetID", "", 5800);
29  }
30 }
31 
32  if (!isset($widget))
33  { // create new widget obj
34  $widget = new YAWK\widget();
35  }
36 // COPY WIDGET
37 if(isset($_GET['copy']) && ($_GET['copy'] === "true")) {
38  if ($widget->copy($db, $_GET['widget']))
39  { // widget copied
40  print alert::draw("success", "$lang[SUCCESS]", "$lang[WIDGET] $lang[ID]: ".$_GET['widget']." $lang[COPIED]","page=widgets","1800");
41  }
42  else
43  { // throw error
44  print alert::draw("danger", "$lang[ERROR]", "$lang[WIDGET] ".$_GET['widget']." $lang[ID] <b>$lang[NOT] $lang[COPIED]</b>","page=widgets","4800");
45  }
46  }
47 
48 // DELETE WIDGET
49 if (isset($_GET['del']) && ($_GET['del'] === "1"))
50 {
51  if (isset($_GET['widget']) && (isset($_GET['delete']) && ($_GET['delete'] == "true")))
52  { // delete widget
53  if($widget->delete($db, $_GET['widget']))
54  { // delete successful
55  YAWK\alert::draw("success", "$lang[SUCCESS]", "$lang[WIDGET] $lang[ID]: ".$_GET['widget']." $lang[DELETED]","","800");
56  }
57  else
58  { // q failed, throw error
59  alert::draw("danger", "$lang[ERROR]", "$lang[WIDGET_DEL_FAILED] $lang[WIDGET] $lang[ID]: ".$_GET['widget']."","","5800");
60  }
61  }
62 }
63 ?>
64 <script type="text/javascript">
65  $(document).ready(function() {
66  $('#table-sort').dataTable( {
67  "bPaginate": false,
68  "bLengthChange": false,
69  "bFilter": true,
70  "bSort": true,
71  "bInfo": true,
72  "bAutoWidth": false
73  } );
74  } );
75 </script>
76 <?php
77 // TEMPLATE WRAPPER - HEADER & breadcrumbs
78 echo "
79  <!-- Content Wrapper. Contains page content -->
80  <div class=\"content-wrapper\" id=\"content-FX\">
81  <!-- Content Header (Page header) -->
82  <section class=\"content-header\">";
83 /* draw Title on top */
84 echo backend::getTitle($lang['WIDGETS'], $lang['WIDGETS_SUBTEXT']);
85 echo"<ol class=\"breadcrumb\">
86  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
87  <li class=\"active\"><a href=\"index.php?page=widgets\" title=\"$lang[WIDGETS]\"> $lang[WIDGETS]</a></li>
88  </ol>
89  </section>
90  <!-- Main content -->
91  <section class=\"content\">";
92 /* page content start here */
93 ?>
94 
95 <div class="box box-default">
96  <div class="box-body">
97 <a class="btn btn-success pull-right" title="<?php echo $lang['WIDGET+']; ?>" href="index.php?page=widget-new">
98 <i class="glyphicon glyphicon-plus"></i> &nbsp;<?php print $lang['WIDGET']; ?></a>
99 <a class="btn btn-success pull-right" title="<?php echo $lang['WIDGET_MANAGER']; ?>" href="index.php?page=widgets-manage">
100 <i class="glyphicon glyphicon-folder-open"></i> &nbsp;&nbsp;<?php print $lang['WIDGET_MANAGER']; ?></a>
101 
102 <table style="width: 100%;" class="table table-striped table-hover table-responsive" id="table-sort">
103  <thead>
104  <tr>
105  <td style="width: 3%;"><strong>&nbsp;</strong></td>
106  <td style="width: 5%;" class="text-center"><strong><?php echo "$lang[ID]"; ?></strong></td>
107  <td style="width: 25%;"><strong><?php echo "$lang[WIDGET]"; ?></strong></td>
108  <td style="width: 30%;"><strong><?php echo "$lang[PAGE]"; ?></strong></td>
109  <td style="width: 7%;" class="text-center"><strong><?php echo "$lang[SORTATION]"; ?></strong></td>
110  <td style="width: 20%;" class="text-center"><strong><?php echo "$lang[POSITION]"; ?></strong></td>
111  <td style="width: 10%;" class="text-center"><strong><?php echo "$lang[ACTIONS]"; ?></strong></td>
112  </tr>
113  </thead>
114  <tbody>
115  <?php
116  if ($res = $db->query("SELECT cw.*, cwt.name, CASE WHEN cp.title IS NULL THEN '$lang[ON_ALL_PAGES]'
117  ELSE cp.title END as title
118  FROM {widgets} as cw
119  JOIN {widget_types} as cwt on cw.widgetType = cwt.id
120  LEFT JOIN {pages} as cp on cw.pageID = cp.id
121  ORDER BY cw.pageID,cw.sort"))
122  {
123  while($row = mysqli_fetch_assoc($res)){
124  if ($row['published']==1)
125  {
126  $pub = "success"; $pubtext="$lang[ONLINE]";
127  } else {
128  $pub = "danger"; $pubtext="$lang[OFFLINE]";}
129  echo "<tr>
130  <td class=\"text-center\">
131  <a href=\"index.php?page=widget-toggle&widget=".$row['id']."&published=".$row['published']."\">
132  <span class=\"label label-$pub\">$pubtext</span></a></td>
133  <td class=\"text-center\">".$row['id']."</td>
134  <td><a href=\"index.php?page=widget-edit&widget=".$row['id']."\"><div style=\"width:100%\">".$row['name']."</div></a>
135  <small>".$row['widgetTitle']."</small></td>
136  <td><a href=\"index.php?page=widget-edit&widget=".$row['id']."\" style=\"color: #7A7376;\"><div style=\"width:100%\">".$row['title']."</div></a></td>
137 
138  <td class=\"text-center\">".$row['sort']."</td>
139  <td class=\"text-center\">".$row['position']."</td>
140  <td class=\"text-center\">
141 
142  <a class=\"fa fa-copy\" title=\"".$lang['WIDGET_COPY']."\" href=\"index.php?page=widgets&copy=true&widget=".$row['id']."\"></a>&nbsp;
143  <a class=\"fa fa-edit\" title=\"EDIT: ".$row['name']."\" href=\"index.php?page=widget-edit&widget=".$row['id']."\"></a>&nbsp;
144  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"".$lang['WIDGET']." &laquo; # $row[id] &raquo; ".$lang['DELETE']."?\"
145  title=\"$lang[DELETE]\" href=\"index.php?page=widgets&del=1&widget=$row[id]&delete=true\">
146  </a>
147  </td>
148  </tr>";
149  }
150  }
151  ?>
152  </tbody>
153 </table>
154  </div>
155 </div>
Throws a fancy Bootstrap Alert (success, info, warning or danger)
Definition: alert.php:19
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
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
The sys class - handles yawk's system core functions.
Definition: sys.php:17
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
print $page title
Definition: page-edit.php:377
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
$positions
Definition: index.php:55
print $lang['WIDGET']
Definition: widgets.php:84
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);});})