YaWK  24.1
Yet another WebKit
pages.php
Go to the documentation of this file.
1 <?php
2 // IMPORT REQUIRED CLASSES
3 use YAWK\alert;
4 use YAWK\backend;
5 use YAWK\db;
6 use YAWK\language;
7 
8 // CHECK REQUIRED OBJECTS
9 if (!isset($page)) // if no page object is set
10 { // create new page object
11  $page = new YAWK\page();
12 }
13 if (!isset($db))
14 { // create database object
15  $db = new db();
16 }
17 if (!isset($lang))
18 { // create language object
19  $lang = new language();
20 }
21 
22 // TOGGLE PAGE
23 if (isset($_GET['toggle']) && ($_GET['toggle'] === "1"))
24 { // check if vars are set
25  if (isset($_GET['id']) && isset($_GET['published']) && isset($_GET['title']))
26  { // toggle page
27  if(!$page->toggleOffline($db, $_GET['id'], $_GET['published'], $_GET['title']))
28  { // all good, notify msg
29  alert::draw("danger", "$lang[ERROR]", "$lang[PAGE_TOGGLE_FAILED]", "", 5800);
30  }
31  }
32 }
33 
34 // LOCK PAGE
35 if (isset($_GET['lock']) && ($_GET['lock']) === "1")
36 {
37  // check if vars are set
38  if (isset($_GET['id']) && (isset($_GET['locked'])))
39  {
40  // escape vars
41  $id = $db->quote($_GET['id']);
42  $locked = $db->quote($_GET['locked']);
43 
44  $color = '';
45  if ($locked === '1') { $setLock = 0; $status = "$lang[UNLOCKED]"; $color="success"; }
46  if ($locked === '0') { $setLock = 1; $status = "$lang[LOCKED]"; $color="danger"; }
47  else { $setLock = 0; $status=''; }
48 
49  // execute page lock
50  if ($page->toggleLock($db, $id, $setLock))
51  {
52  // successful, throw notification
53  alert::draw("$color", "$lang[PAGE] $lang[IS] $status", "$lang[PAGE] $lang[IS] $status", "",800);
54  }
55  else
56  { // throw error msg
57  alert::draw("danger", "$lang[ERROR]", "$lang[PAGE_LOCK_FAILED]","page=pages", 4300);
58  }
59  }
60 }
61 
62 // DELETE PAGE
63 if (isset($_GET['del']) && ($_GET['del'] === "1"))
64 {
65  if (isset($_GET['delete']) && ($_GET['delete'] == "true")){
66  // if page obj != set
67  if (isset($_GET['id']))
68  { // quote alias and load properties
69  $_GET['id'] = $db->quote($_GET['id']);
70  $page->loadPropertiesByID($db, $_GET['id']);
71  $page->id = $_GET['id'];
72  }
73  // ok, delete page
74  if ($page->delete($db))
75  { // success
76  alert::draw("success", "Erfolg!", "$lang[PAGE] " . $_GET['alias'] . " $lang[PAGE_DEL_OK]","", 800);
77  // \YAWK\backend::setTimeout("index.php?page=pages",1260);
78  }
79  else
80  { // failed
81  alert::draw("danger", "Error!", "$lang[PAGE] " . $_GET['alias'] . " $lang[PAGE_DEL_FAILED]", "", 6800);
82  }
83  }
84 }
85 
86 // COPY PAGE
87 if (isset($_GET['copy']) && ($_GET['copy'] === "true"))
88 { // check if vars are set
89  if (isset($_GET['alias']))
90  { // escape vars
91  $_GET['alias'] = $db->quote($_GET['alias']);
92  // load properties for given page
93  $page->loadProperties($db, $_GET['alias']);
94 
95  echo "<pre>";
96  print_r($_POST);
97  echo "</pre>";
98 
99  // copy page as new language
100  if (isset($_GET['newLanguage']) && ($_GET['newLanguage'] === "true"))
101  { // check, if new language was set in modal dialogue
102  if (isset($_POST['language']) && (!empty($_POST['language'])))
103  { // set vars for copy page as new language
104  $page->language = mb_substr($_POST['language'], 0,2);
105  $page->title_new = $_POST['modalTitle'];
106  $page->alias_new = $_POST['modalAlias'];
107  $page->id = $_POST['pageID'];
108  $page->newLanguage = true;
109  }
110  }
111  else
112  { // simple copy file, no new language requested
113  $page->title_new = $page->title."_copy";
114  $page->alias_new = $page->alias."_copy";
115  $page->id = $_GET['id'];
116  $page->newLanguage = false;
117  }
118 
119  // copy page
120  if($page->copy($db))
121  { // all good.
122  print alert::draw("success", "$lang[SUCCESS]", "$lang[PAGE] ".$_GET['alias']." $lang[PAGE_COPY_OK]", "", "1200");
123  }
124  else
125  { // copy failed, throw error
126  print alert::draw("danger", "$lang[ERROR]", "$_GET[alias] $lang[PAGE_COPY_FAILED]", "", "6800");
127  }
128  }
129 }
130 
131 ?>
132 <script type="text/javascript">
133 
134 $(document).ready(function() {
135 
136  // copy page as new language click handler (modal window send btn)
137  $(document).on("click", "#languageCopyLink", function () {
138  const pageID = $(this).data('id');
139  const alias = $(this).data('alias');
140  const title = $(this).data('title');
141 
142  // update form fields with values
143  $("#pageID").val(pageID);
144  $("#modalAlias").val(alias);
145  $("#alias").val(alias);
146  $("#modalTitle").val(title);
147  // update modal form action (insert new alias)
148  $('#modalForm').attr('action', 'index.php?page=pages&copy=1&newLanguage=true&copy=true&alias='+alias);
149 
150  // update
151  $("#titlePageID").text("ID"+pageID+" "+alias+ " "+title);
152  });
153 
154  $('#table-sort').dataTable( {
155  "bPaginate": false,
156  "bLengthChange": false,
157  "bFilter": true,
158  "bSort": true,
159  "bInfo": true,
160  "bAutoWidth": false
161  } );
162 });
163 </script>
164 
165 <!-- Modal --MOVE TO ARCHIVE-- -->
166 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal2Label" aria-hidden="true">
167  <div class="modal-dialog">
168  <div class="modal-content">
169  <form enctype="multipart/form-data" id="modalForm" action="index.php?page=pages&copy=1&newLanguage=true&copy=true" method="POST">
170  <input type="hidden" id="pageID" name="pageID">
171  <div class="modal-header">
172  <!-- modal header with close controls -->
173  <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> </button>
174  <br>
175  <div class="col-md-1"><h3 class="modal-title"><i class="fa fa-language"></i></h3></div>
176  <div class="col-md-11"><h3 class="modal-title"><?php echo $lang['COPY_PAGE_NEW_LANGUAGE']; ?> </h3>
177  <div id="titlePageID"></div>
178  </div>
179  </div>
180 
181  <!-- modal body -->
182  <div class="modal-body">
183  <label for="modalAlias"><?php echo $lang['FILENAME']; ?></label>
184  <input type="text" class="form-control" id="modalAlias" name="modalAlias" placeholder="<?php echo $lang['FILENAME']; ?>" readonly>
185 
186  <label for="modalTitle"><?php echo $lang['NEW_PAGE_TITLE']; ?></label>
187  <input type="text" class="form-control" id="modalTitle" name="modalTitle" placeholder="<?php echo $lang['NEW_PAGE_TITLE']; ?>">
188 
189  <label for="language"><?php echo $lang['ASSIGN_NEW_LANGUAGE']; ?></label>
190  <select id="language" name="language" class="form-control">
191  <?php echo language::drawLanguageSelectOptions(); ?>
192  </select>
193  </div>
194 
195  <!-- modal footer /w submit btn -->
196  <div class="modal-footer">
197  <input class="btn btn-large btn-default" data-dismiss="modal" aria-hidden="true" type="submit" value="<?php echo $lang['CANCEL']; ?>">
198  <button class="btn btn-large btn-success" type="submit"><i class="fa fa-check"></i>&nbsp; <?php echo $lang['PAGE_COPY']; ?></button>
199  <br><br>
200  </div>
201  </form>
202  </div> <!-- modal content -->
203  </div> <!-- modal dialog -->
204 </div> <!-- modal fade window -->
205 
206 <?php
207  // TEMPLATE WRAPPER - HEADER & breadcrumbs
208 echo "
209  <!-- Content Wrapper. Contains page content -->
210  <div class=\"content-wrapper\" id=\"content-FX\">
211  <!-- Content Header (Page header) -->
212  <section class=\"content-header\">";
213  /* draw Title on top */
214  echo backend::getTitle($lang['PAGES'], $lang['PAGES_SUBTEXT']);
215  echo"<ol class=\"breadcrumb\">
216  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
217  <li class=\"active\"><a href=\"index.php?page=pages\" title=\"$lang[PAGES]\"> $lang[PAGES]</a></li>
218  </ol>
219  </section>
220  <!-- Main content -->
221  <section class=\"content\">";
222  /* page content start here */
223 ?>
224 
225 <!--
226 <div class="box box-default">
227  <div class="box-body"> -->
228 
229 <div class="box box-default">
230  <div class="box-body">
231  <a class="btn btn-success pull-right" href="index.php?page=page-new">
232  <i class="glyphicon glyphicon-plus"></i> &nbsp;<?php print $lang['PAGE+']; ?></a>
233 
234 <table style="width: 100%; border-collapse: collapse;" class="table table-striped table-hover table-responsive" id="table-sort">
235  <thead>
236  <tr>
237  <td style="width: 3%;"><b><?php echo $lang['STATUS']; ?> </b></td>
238  <td style="width: 3%;"><b>&nbsp;</b></td>
239  <td style="width: 3%;"><b><?php echo $lang['ID']; ?> </b></td>
240  <td style="width: 30%;"><b><i class="fa fa-caret-down"></i> <?php print $lang['TITLE']; ?></b></td>
241  <td style="width: 30%;"><b><i class="fa fa-caret-down"></i> <?php print $lang['FILENAME']; ?></b></td>
242  <td style="width: 5%" class="text-center"><b><?php print $lang['TYPE']; ?></b></td>
243  <td style="width: 5%" class="text-center"><b><?php print $lang['RIGHTS']; ?></b></td>
244  <td style="width: 5%" class="text-center"><b><?php print $lang['LANGUAGE']; ?></b></td>
245  <td style="width: 16%" class="text-center"><b><?php print $lang['ACTIONS']; ?></b></td>
246  </tr>
247  </thead>
248  <tbody>
249 
250 <?php
254 
255  /* get all pages */
256  $rows = backend::getPagesArray($db);
257  foreach ($rows AS $row) {
258  $i_pages++;
259  if ($row['published']==='1')
260  {
261  $pub = "success"; $pubtext="On";
263  }
264  else {
265  $pub = "danger"; $pubtext = "Off";
267  }
268  // check type of page...
269  // does it host a plugin?
270  if ($row['plugin'] !== '0'){
271  $type = "<a href=\"index.php?plugin=".$row['plugin']."\">$lang[PLUGIN]</a>";
272  }
273  else {
274  // is it a blog?
275  if ($row['blogid'] !== '0')
276  {
277  $type = "<a href=\"index.php?plugin=blog&pluginpage=blog-entries&blogid=".$row['blogid']."\">$lang[BLOG]</a>";
278  } else {
279  // its surely a static page
280  $type = "$lang[PAGE]";
281  }
282  }
283 
284  if ($row['locked'] !== '0')
285  { // PAGE IS LOCKED
286  $lockIcon = "<i class=\"fa fa-lock\"></i>";
287  $lockHover = "style=\"cursor:not-allowed;\"";
288  $lockHref = "href=\"#\"";
289  $lockLink = "href=\"index.php?page=pages&lock=1&id=".$row['id']."&locked=".$row['locked']."\"";
290  $lockTitle = "title=\"".$lang['PAGE_UNLOCK']."\"";
291  $lockLinkTitle = "title=\"".$lang['PAGE_LOCKED']."\"";
292  $lockLanguageCopyTitle = "title=\"".$lang['ASSIGN_NEW_LANGUAGE']."\"";
293  $lockAction = "<a class=\"fa fa-unlock-alt\" ".$lockTitle." ".$lockLink."></a>&nbsp;";
294  $lockEditLink = "href=\"index.php?page=pages&lock=1&id=".$row['id']."&locked=".$row['locked']."\"";
295  $lockDeleteLink = "href = \"#\" ".$lockHover." ";
296  $lockCopyLink = "".$lockHover." href=\"#\"";
297  $lockLanguageCopyLink = "".$lockHover." href=\"#\"";
298  }
299  else
300  { // PAGE IS NOT LOCKED
301  $lockIcon = '';
302  $lockHover = '';
303  $lockLink = "href=\"index.php?page=pages&lock=1&id=".$row['id']."&locked=".$row['locked']."\"";
304  $lockHref = "href=\"index.php?page=page-edit&id=".$row['id']."\"";
305  $lockTitle = "title=\"".$lang['PAGE_LOCK']."\"";
306  $lockLinkTitle = "title=\"".$lang['EDIT']."\"";
307  $lockLanguageCopyTitle = "title=\"".$lang['ASSIGN_NEW_LANGUAGE']."\"";
308  $lockAction = "<a class=\"fa fa-lock\" ".$lockTitle." ".$lockLink."></a>&nbsp;";
309  $lockCopyLink = "title=\"".$lang['PAGE_COPY']."\" href=\"index.php?page=pages&copy=1&title=".$row['title']."&id=".$row['id']."&alias=".$row['alias']."&copy=true\"";
310  $lockDeleteLink = "role=\"dialog\" data-confirm=\"$lang[PAGE] &laquo;".$row['title']." / ".$row['alias'].".html&raquo; $lang[PAGE_DEL_CONFIRM]\"
311  title=\"".$lang['PAGE_DELETE']."\" href=\"index.php?page=pages&del=1&alias=".$row['alias']."&id=".$row['id']."&delete=true\"";
312  $lockLanguageCopyLink = "id=\"languageCopyLink\" data-toggle=\"modal\" data-target=\"#myModal\" data-title=\"".$row['title']."\" data-alias=\"".$row['alias']."\" data-id=\"".$row['id']."\" ";
313  }
314 
315  echo "<tr>
316  <td class=\"text-center\">
317  <a title=\"toggle&nbsp;status\" href=\"index.php?page=pages&toggle=1&id=".$row['id']."&title=".$row['title']."&published=".$row['published']."\">
318  <span class=\"label label-$pub\">$pubtext</span></a>&nbsp;</td>
319  <td>".$lockIcon."</i></td>
320  <td>".$row['id']."</td>
321  <td><a ".$lockHover." ".$lockLinkTitle." ".$lockHref."><div style=\"width:100%\">".$row['title']."</div></a></td>
322  <td><a ".$lockHover." ".$lockLinkTitle." ".$lockHref."><div style=\"width:100%\">".$row['alias'].".html</div></a></td>
323 
324  <td class=\"text-center\">".$type."</td>
325  <td class=\"text-center\">".$row['gid']."</td>
326  <td class=\"text-center\">".$row['lang']."</td>
327  <td class=\"text-center\">
328  ".$lockAction."
329  <a class=\"fa fa-copy\" ".$lockCopyLink." ></a>&nbsp;
330  <a class=\"fa fa-edit\" ".$lockHover." ".$lockLinkTitle." ".$lockHref."></a>&nbsp;
331  <a class=\"fa fa-language\" style=\"cursor: pointer\" ".$lockLanguageCopyLink." ".$lockLanguageCopyTitle."></a>&nbsp;
332  <a class=\"fa fa-trash-o\" ".$lockDeleteLink."></a>&nbsp;
333  </td>
334  </tr>";
335  }
336 ?>
337 
338  </tbody>
339 </table>
340 
341 <!-- End of Page -->
342 <br>
343 
344 
345  </div>
346 </div>
347 
348 <!-- Start FOOTER -->
349 <div class="box box-default">
350  <div class="box-header with-border">
351  <h3 class="box-title"><i class="glyphicon glyphicon-stats"></i> &nbsp;<?php print $lang['PAGE_STATS']; ?></h3>
352  </div>
353  <div class="box-body">
354  <?php
355  $page = $lang['PAGE'];
356  $pages = $lang['PAGES'];
357 
358  if ($i_pages > 1) { $seiten="$i_pages $pages $lang[OVERALL]"; }
359  else if ($i_pages = 1) { $seiten="$i_pages $page"; }
360  else { $seiten = "$lang[NO_PAGE_CREATED]"; }
361 
362  if ($i_pages_published > 1) { $pub="$i_pages_published $pages $lang[PUBLISHED]"; }
363  else if ($i_pages_published == 1) { $pub="$i_pages_published $page $lang[PUBLISHED]."; }
364  else { $pub = "$lang[NO_PAGE_PUBLISHED]"; }
365 
366  if ($i_pages_unpublished > 1) { $unpub="$i_pages_unpublished $pages $lang[OFFLINE]"; }
367  else if ($i_pages_unpublished === '1') { $unpub="$i_pages_unpublished $page "; }
368  else { $unpub = $lang['PAGES_ONLINE']; }
369 
370  // stats on bottom of page
371  echo "$seiten<br>
372  $pub<br>
373  $unpub";
374  ?>
375  </div>
376 </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
The default pages class. Provide all functions to handle static pages.
Definition: page.php:20
if(!isset($db)) $id
function window
Definition: fuckAdBlock.js:8
FuckAdBlock prototype on
Definition: fuckAdBlock.js:227
function b(a)
Definition: browser.js:14
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
$type
$page alias
Definition: page-edit.php:68
print $page title
Definition: page-edit.php:377
print $_GET['id']
Definition: page-edit.php:357
$page
Definition: pages.php:355
$pages
Definition: pages.php:356
$i_pages
Definition: pages.php:251
$i_pages_unpublished
Definition: pages.php:253
$i_pages_published
Definition: pages.php:252
$rows
Definition: pages.php:256
print $lang['PAGE+']
Definition: pages.php:183
function i(e, t)
Definition: plyr.js:1
function w(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$template name
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);});})