YaWK  24.1
Yet another WebKit
template-manage.php
Go to the documentation of this file.
1 <script type="text/javascript">
2  $(document).ready(function() {
3  $('#table-sort').dataTable( {
4  "bPaginate": false,
5  "bLengthChange": false,
6  "bFilter": true,
7  "bSort": false,
8  "bInfo": true,
9  "bAutoWidth": false
10  } );
11  } );
12 </script>
13 <?php
14 
15 use YAWK\alert;
16 use YAWK\backend;
17 use YAWK\db;
18 use YAWK\language;
19 use YAWK\settings;
20 use YAWK\template;
21 use YAWK\user;
22 /** @var $db db */
23 /** @var $lang language */
24 
25 // check user obj
26 if (!isset($user))
27 { // create new user obj
28  $user = new user($db);
29 }
30 // disable preview (overrideTemplate)
31 $user->setUserTemplate($db, 0, settings::getSetting($db, "selectedTemplate"), $user->id);
32 $user->overrideTemplate = 0;
33 
34 if (isset($_GET['toggle']) && ($_GET['toggle'] === "1"))
35 {
36  if (isset($_GET['templateID']) && (is_numeric($_GET['templateID'])))
37  { // escape chars
38  $_GET['templateID'] = $db->quote($_GET['templateID']);
39  if (settings::setSetting($db, "selectedTemplate", $_GET['templateID'], $lang))
40  { // additional: set this template as active in template database
41  template::setTemplateActive($db, $_GET['templateID']);
42  $user->setUserTemplate($db, 0, $_GET['templateID'], $user->id);
43  $user->overrideTemplate = 0;
44  }
45  else
46  {
47  alert::draw("warning", "$lang[TPL_SWITCH_FAILED]", "$lang[TPL_SWITCH_FAILED_SUBTEXT]", "page=template-manage", 3000);
48  }
49  }
50 }
51 
52 // DELETE TEMPLATE
53 if (isset($_GET['delete']) && ($_GET['delete'] === "1"))
54 { // check, if the given ID is correct
55  if (isset($_GET['templateID']) && (is_numeric($_GET['templateID'])))
56  { // escape chars
57  $_GET['templateID'] = $db->quote($_GET['templateID']);
58  if (template::deleteTemplate($db, $_GET['templateID']))
59  { // throw success msg
60  alert::draw("success", "<i class=\"fa fa-trash-o\"></i> $lang[TPL] $lang[DELETED]", "$lang[SUCCESS]", "", 3000);
61  }
62  else
63  {
64  alert::draw("danger", "$lang[TPL_FAILED_TO_DELETE] $_GET[templateID]", "$lang[PLEASE_TRY_AGAIN]", "", 3000);
65  }
66  }
67 }
68 
69 ?>
70 <?php
71 // TEMPLATE WRAPPER - HEADER & breadcrumbs
72 echo "
73  <!-- Content Wrapper. Contains page content -->
74  <div class=\"content-wrapper\" id=\"content-FX\">
75  <!-- Content Header (Page header) -->
76  <section class=\"content-header\">";
77 /* draw Title on top */
78 echo backend::getTitle($lang['TPL_MANAGER'], $lang['TEMPLATES_SUBTEXT']);
79 echo"<ol class=\"breadcrumb\">
80  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
81  <li><a href=\"index.php?page=template-manage\" class=\"active\" title=\"$lang[TPL_MANAGER]\"> $lang[TPL_MANAGER]</a></li>
82  </ol>
83  </section>
84  <!-- Main content -->
85  <section class=\"content\">";
86 /* page content start here */
87 ?>
88 <div class="box box-default">
89  <div class="box-body">
90 
91 <a class="btn btn-success" href="#" style="float:right;">
92 <i class="glyphicon glyphicon-plus"></i> &nbsp;<?php print $lang['TEMPLATE']; ?></a>
93 
94 <table style="width:100%;" class="table table-striped table-hover table-responsive" id="table-sort">
95  <thead>
96  <tr>
97  <td style="width:3%;"><strong>&nbsp;</strong></td>
98  <td style="width:3%;"><strong><?php echo $lang['ID']; ?></strong></td>
99  <td style="width:20%;"><strong><i class="fa fa-caret-down"></i> <?php print $lang['TEMPLATE']; ?></strong></td>
100  <td style="width:40%;"><strong><i class="fa fa-caret-down"></i> <?php print $lang['DESCRIPTION']; ?></strong></td>
101  <td style="width:24%;"><strong><?php print $lang['SCREENSHOT']; ?></strong></td>
102  <td style="width: 10%;" class="text-center"><strong><?php print $lang['ACTIONS']; ?></strong></td>
103  </tr>
104  </thead>
105  <tbody>
106 
107  <?php
108  $i_pages = 0;
111  // get active tpl name
112  $activeTemplate = template::getCurrentTemplateName($db, "backend", "");
113  if ($res = $db->query("SELECT * FROM {templates} ORDER BY active DESC"))
114  {
115  // fetch templates and draw a tbl row in a while loop
116  while($row = mysqli_fetch_assoc($res))
117  { // get active template id
118  $activeTemplateId = settings::getSetting($db, "selectedTemplate");
119 
120  if ($row['id'] === $activeTemplateId)
121  { // set published online
122  $pub = "success"; $pubtext="$lang[ONLINE]";
124  // do not allow to delete current active template
125  $deleteIcon = "<i class=\"fa fa-ban\" title=\"$lang[TPL_DEL_FAILED_DUE_ACTIVE]\"></i>";
126  }
127  else if ($row['id'] === "1" && ($activeTemplateId !== $row['id']))
128  { // do not allow to delete default template
129  $pub = "danger"; $pubtext = "$lang[OFFLINE]";
130  $deleteIcon = "<i class=\"fa fa-ban\" title=\"$lang[TPL_DEL_DEFAULT_FAILED]\"></i>";
131  }
132  else
133  { // set published offline
134  $pub = "danger"; $pubtext = "$lang[OFFLINE]";
136  // delete template button
137  $deleteIcon = "<a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$lang[TPL_DEL_CONFIRM] &laquo;".$row['name']." / ".$row['id']."&raquo;\"
138  title=\"".$lang['DELETE']."\" href=\"index.php?page=template-manage&delete=1&templateID=".$row['id']."\">
139  </a>";
140  }
141 
142  // set template image (screen shot)
143  $screenshot = "../system/templates/".$activeTemplate."/img/screenshot.jpg";
144  if (!file_exists($screenshot))
145  { // sorry, no screenshot available
146  $screenshot = "$lang[NO_SCREENSHOT]";
147  }
148  else
149  { // screenshot found, display
150  $screenshot = "<img src=\"../system/templates/".$activeTemplate."/img/screenshot.jpg\" width=\"200\" class=\"img-rounded\">";
151  }
152 
153  $row['positions'] = str_replace(':', '<br>',$row['positions']); //wordwrap($row['positions'], 20, "<br>\n");
154  echo "<tr>
155  <td class=\"text-center\">
156  <a title=\"toggle&nbsp;status\" href=\"index.php?page=template-manage&toggle=1&templateID=".$row['id']."\">
157  <span class=\"label label-$pub\">$pubtext</span></a>&nbsp;</td>
158  <td>".$row['id']."</td>
159  <td><a href=\"index.php?page=template-edit&overrideTemplate=1&id=".$row['id']."\"><div style=\"width:100%\">".$row['name']."</div></a></td>
160  <td><a href=\"index.php?page=template-edit&id=".$row['id']."\" style=\"color: #7A7376;\"><div style=\"width:100%\">".$row['description']."<br><small>".$row['positions']."</small></div></a></td>
161  <td><a href=\"index.php?page=template-edit&id=".$row['id']."\" title=\"$lang[EDIT]: ".$row['name']."\">".$screenshot."</a></td>
162  <td class=\"text-center\">
163  $deleteIcon
164  </td>
165  </tr>";
166  }
167  }
168  ?>
169  </tbody>
170 </table>
171 
172  </div>
173 </div>
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
Settings class: get and set YaWK system settings.
Definition: settings.php:9
The template controller - get and set template settings.
Definition: template.php:16
The default user class. Provide all functions to handle the user object.
Definition: user.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
$i_pages_unpublished
$i_pages_published
print $lang['TEMPLATE']
$activeTemplate
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);});})