YaWK  24.1
Yet another WebKit
backend.php
Go to the documentation of this file.
1 <?php
2 namespace YAWK {
3  /**
4  * @details <b>backend Interface Helper Functions</b>
5  *
6  * This class serves a few useful functions for the admin backend.<br>
7  *
8  * <code><?php YAWK\backend::getTitle("title", "subtext"); ?></code>
9  * Brings up the title on every page in admin panel.
10  *
11  * <code><?php YAWK\backend::setTimeout("index.php?pages=dashboard", "200"); ?></code>
12  * Set a javascript redirection url and $wait time in ms before redirecting
13  *
14  * <code><?php YAWK\backend::setFocus("$field"); ?></code>
15  * Set focus to any form input field on document ready.
16  *
17  * More backend helper functions may come in future releases.
18  * <p><i>Class covers backend functionality.
19  * See Methods Summary for Details!</i></p>
20  *
21  * @author Daniel Retzl <[email protected]>
22  * @copyright 2009-2015 Daniel Retzl yawk.io
23  * @license https://opensource.org/licenses/MIT/
24  * @brief Backend class serves a few useful functions for the admin backend.
25  */
26  class backend
27  {
28 
29  /**
30  * @brief Return breadcrumbs for settings pages
31  * @param array $lang Language Array
32  * @return string html code
33  */
34  static function getSettingsBreadcrumbs($lang)
35  {
36  return "<ol class=\"breadcrumb\">
37  <li><i class=\"fa fa-globe\"></i> &nbsp;<a href=\"index.php?page=settings-frontend\" title=\"$lang[EDIT]\"> $lang[FRONTEND]</a></li>
38  <li><i class=\"fa fa-sign-in\"></i> &nbsp;<a href=\"index.php?page=settings-backend\" title=\"$lang[EDIT]\"> $lang[BACKEND]</a></li>
39  <li><i class=\"fa fa-cogs\"></i> &nbsp;<a href=\"index.php?page=settings-system\" title=\"$lang[EDIT]\"> $lang[SYSTEM]</a></li>
40  <li><i class=\"fa fa-envelope-o\"></i> &nbsp;<a href=\"index.php?page=settings-webmail\" title=\"$lang[WEBMAIL]\"> $lang[WEBMAIL]</a></li>
41  <li><i class=\"fa fa-language\"></i> &nbsp;<a href=\"index.php?page=settings-language\" title=\"$lang[EDIT]\"> $lang[LANGUAGES]</a></li>
42  <li><i class=\"fa fa-android\"></i> &nbsp;<a href=\"index.php?page=settings-robots\" title=\"$lang[EDIT]\"> $lang[ROBOTS_TXT]</a></li>
43  <li><i class=\"fa fa-puzzle-piece\"></i> &nbsp;<a href=\"index.php?page=settings-assets\" title=\"$lang[EDIT]\"> $lang[ASSETS]</a></li>
44  <li><i class=\"fa fa-font\"></i> &nbsp;<a href=\"index.php?page=settings-fonts\" title=\"$lang[EDIT]\"> $lang[FONTS]</a></li>
45  <li><i class=\"fa fa-database\"></i> &nbsp;<a href=\"index.php?page=settings-database\" title=\"$lang[EDIT]\"> $lang[DATABASE]</a></li>
46  <li><i class=\"fa fa-info-circle\"></i> &nbsp;<a href=\"index.php?page=settings-systeminfo\" title=\"$lang[EDIT]\"> $lang[SYSTEM] $lang[INFO]</a></li>
47  </ol></section>";
48  }
49 
50  /**
51  * @brief Return breadcrumbs for template pages
52  * @param array $lang Language Array
53  * @return string html code
54  */
55  static function getTemplateBreadcrumbs($lang)
56  {
57  // <li><i class=\"fa fa-tint\"></i> &nbsp;<a href=\"index.php?page=template-theme\" title=\"$lang[EDIT]\"> $lang[THEME]</a></li>
58 
59  return "<ol class=\"breadcrumb\">
60  <li><i class=\"fa fa-home\"></i> &nbsp;<a href=\"index.php?page=template-overview\" title=\"$lang[EDIT]\"> $lang[OVERVIEW]</a></li>
61  <li><i class=\"fa fa-cube\"></i> &nbsp;<a href=\"index.php?page=template-positions\" title=\"$lang[EDIT]\"> $lang[POSITIONS]</a></li>
62  <li><i class=\"fa fa-paint-brush\"></i> &nbsp;<a href=\"index.php?page=template-redesign\" title=\"$lang[EDIT]\"> $lang[DESIGN]</a></li>
63  <li><i class=\"fa fa-text-height\"></i> &nbsp;<a href=\"index.php?page=template-typography\" title=\"$lang[EDIT]\"> $lang[TYPOGRAPHY]</a></li>
64  <li><i class=\"fa fa-css3\"></i> &nbsp;<a href=\"index.php?page=template-customcss\" title=\"$lang[EDIT]\"> $lang[CUSTOM_CSS]</a></li>
65  <li><i class=\"fa fa-code\"></i> &nbsp;<a href=\"index.php?page=template-customjs\" title=\"$lang[EDIT]\"> $lang[CUSTOM_JS]</a></li>
66  <li><i class=\"fa fa-puzzle-piece\"></i> &nbsp;<a href=\"index.php?page=template-assets\" title=\"$lang[EDIT]\"> $lang[ASSETS]</a></li>
67  <li><i class=\"fa fa-eye\"></i> &nbsp;<a href=\"index.php?page=template-preview\" title=\"$lang[WEBSITE] $lang[PREVIEW]\"> $lang[PREVIEW]</a></li>
68  </ol></section>";
69  }
70 
71 
72 
73  /**
74  * @brief Header title on top of every page
75  * @param string $title Title to display
76  * @param string $subtext Subtitle as small-tag beneath Title
77  * @return string
78  */
79  static function getTitle($title, $subtext)
80  {
81  if ($title && $subtext) {
82  $html = "<h1>" . $title . "&nbsp;<small>" . $subtext . "</small></h1>";
83  } else {
84  $html = "<h1>" . $title . "</h1>";
85  }
86  return $html;
87  }
88 
89  /**
90  * @brief Set focus to any input field on pageload
91  * @param string $field Name of the html input form element who should be focused.
92  */
93  static function setFocus($field)
94  {
95  print"<script type=\"text/javascript\" >
96  $(document).ready(function() {
97  $('#" . $field . "').focus(); });
98  </script>";
99  }
100 
101  /**
102  * Do a javascript redirect to $location after given delay time ($wait) in ms
103  * @param string $location url to redirect
104  * @param string $wait Time to wait in ms before redirect
105  */
106  static function setTimeout($location, $wait)
107  {
108  print"<script type=\"text/javascript\">
109  setTimeout(\"self.location.href='" . $location . "'\"," . $wait . ");
110  </script>
111  <noscript>
112  <h1>Your Browser needs activated javascript, to render the site correctly.<br>
113  <small>Please click <a href=\"$location\">here</a> to go ahead.</small></h1>
114  </noscript>";
115  }
116 
117  /**
118  * @brief Include Javascript FX to apply on #content-FX DOM element
119  * @param object $db Database object
120  * @param string $time FX time in milliseconds
121  * @param string $type FX type
122  */
123  static function getFX($db, $time, $type)
124  {
125  // set defaults
126  if (!$time) {
127  $time = 820;
128  }
129  if (!$type) {
130  $type = "fadeIn";
131  }
132  // are FX enabled?
133  if (\YAWK\settings::getSetting($db, "backendFX") >= 1) {
134  echo "
135  <!-- optional backend FX on -->
136  <script>$(\"#content-FX\").hide(0).delay(0)." . $type . "(" . $time . ")</script>";
137  }
138  }
139 
140  /**
141  * @brief Draw the AdminLTE Content Wrapper. Useful that view dont crash in situations where the DOM is not loaded or could not be loaded.
142  * @return null
143  */
144  static function drawContentWrapper(){
145  echo "
146  <!-- Content Wrapper. Contains page content -->
147  <div class=\"content-wrapper\" id=\"content-FX\">
148  <!-- Content Header (Page header) -->
149  <section class=\"content-header\">
150  </section>
151  <!-- Main content -->
152  <section class=\"content\">";
153  return null;
154  }
155 
156 
157  /**
158  * @brief Checks whether a user is allowed to log in to backend or not. Logins will be stored.
159  * @param object $db Database object
160  * @return bool
161  */
162  static function checkLogin(object $db): bool
163  { /** @var $db \YAWK\db */
164  /* check user login */
165 
166  // cut off any blank spaces
167  if (isset($_POST['user'])){
168  $_POST['user']=trim($_POST['user']);
169  }
170 
171  $user = new \YAWK\user($db);
172  if(!empty($_POST['user']) && (!empty($_POST['password'])))
173  { // check if user is allowed to login
174  if($user->loginBackEnd($db, $_POST['user'],$_POST['password']))
175  { // create session var
176  $_SESSION['username'] = $_POST['user'];
177  $_SESSION['passwordFail'] = 0;
178  $user->storeLogin($db, 0, "backend", $_POST['user'], $_POST['password']);
179  return true;
180  }
181  else
182  { // if username or pwd is wrong
183  if (isset($_SESSION['passwordFail']))
184  { // add password fail counter
185  $_SESSION['passwordFail']++;
186  }
187  else
188  { // first wrong try
189  $_SESSION['passwordFail'] = 1;
190  }
191  // log this user login / store @ login db table
192  $user->storeLogin($db, 1, "backend", $_POST['user'], $_POST['password']);
193  return false;
194  }
195  }
196  else
197  { // username or password not set
198  // alert: no username was set - please enter a qualified username
199  // \YAWK\alert::draw("warning", "Username", "Please enter a qualified username", "", 2400);
200 
201  return false;
202  }
203  }
204 
205 
206  /**
207  * @brief Draw a SELECT field with all templates, current active template is selected
208  * @version 1.0.0
209  * @author Daniel Retzl <[email protected]>
210  * @website http://yawk.website
211  * @param object $db Database object
212  */
213  public static function drawTemplateSelectField($db, $description)
214  {
215  /* TEMPLATE SELECTOR */
216  echo "<!-- TEMPLATE SELECT -->
217  <select class=\"form-control\" id=\"selectedTemplate\" name=\"selectedTemplate\">
218  <label for id=\"selectedTemplate\">$description</label>
219  <option value=\""; echo \YAWK\template::getCurrentTemplateId($db); echo "\">";
220  echo \YAWK\template::getCurrentTemplateName($db, "backend", 0);
221  echo"</option>";
222  /* foreach to fetch template select fields */
223  foreach(\YAWK\template::getTemplateIds($db) as $template)
224  {
225  echo "<option value=\"".$template['id']."\"";
226  if (isset($_POST['template'])) {
227  if($_POST['template'] === $template['id']){
228  echo "selected=\"selected\"";
229  }
230  }
231  echo ">".$template['name']."</option>";
232  }
233  echo"</select>";
234  }
235 
236 
237  /**
238  * @brief Draw a login form. If username and/or password was given, the form will be pre-filled with given values.
239  * @param string $username The username
240  * @param string $password The password
241  * @return string Returns the complete html form.
242  */
244  { /**
245  * draw login box
246  */
247  if (!isset($username) || (empty($username)))
248  { // set default username: empty
249  $username = "";
250  }
251  if (!isset($password) || (empty($password)))
252  { // set default username: empty
253  $password = "";
254  }
255  if (isset($_SESSION['passwordFail']) && ($_SESSION['passwordFail'] > 1))
256  {
257  // password wrong after user's 2nd try - display reset button
258  $resetBtn = "<a type=\"button\" class=\"btn btn-danger\" id=\"resetPasswordButton\" data-toggle=\"modal\" data-target=\"#myModal\"><i class=\"fa fa-question-circle\"></i> &nbsp;$lang[PASSWORD_FORGOTTEN]</a>";
259  }
260  else
261  { // password not wrong - no button needed
262  $resetBtn = "&nbsp;";
263  }
264 
265  // check if any page is requested
266  if (isset($_GET['page']) && (!empty($_GET['page'])))
267  { // set redirect
268  $redirect = "?page=".$_GET['page']." ";
269  }
270  else
271  { // redirect requested
272  $redirect = '';
273  }
274 
275  $form = "<form role=\"form\" id=\"loginForm\" class=\"form-horizontal\" action=\"index.php".$redirect."\" method=\"post\">
276  <input required type=\"text\" class=\"form-control\" maxlength=\"128\" id=\"user\" value=\"".$username."\" name=\"user\" style=\"margin-bottom:4px;\" placeholder=\"Username\">
277  <input required type=\"password\" class=\"form-control\" id=\"password\" value=\"".$password."\" name=\"password\" placeholder=\"Password\"><br>
278  <button type=\"button\" class=\"btn btn-success\" id=\"loginButton\"><i class=\"fa fa-lock\"></i> &nbsp;".$lang['LOGIN']."</button>
279  &nbsp;&nbsp;".$resetBtn."
280  </form>
281  <div id=\"captchaNode\"></div>
282  <div id=\"loginTimerNode\"></div>";
283  return $form;
284  }
285 
286  /**
287  * @brief Draw a login box. Basically it wraps the drawLoginForm function with an AdminLTE box.
288  * @param object $db Database object
289  * @param string $title Box title
290  * @param string $username The username
291  * @param string $password The password
292  * @return string Returns the complete html form
293  */
294  static function drawLoginBox($db, $lang)
295  { /**
296  * draw login box
297  */
298  /* set focus on text field */
299  \YAWK\backend::setFocus("user");
300  /* get title and draw login box */
301  $title = \YAWK\settings::getSetting($db, "title");
302  $modalWindow = " <!-- Modal -->
303  <form method=\"POST\" action=\"index.php\">
304  <div class=\"modal fade\" id=\"myModal\" role=\"dialog\">
305  <div class=\"modal-dialog\">
306 
307  <!-- Modal content-->
308  <div class=\"modal-content\">
309  <div class=\"modal-header\">
310  <button type=\"button\" class=\"close\" data-dismiss=\"modal\">&times;</button>
311  <h4 class=\"modal-title\">$lang[PASSWORD_RESET]</h4>
312  </div>
313  <div class=\"modal-body\">
314  <label for=\"email\">$lang[EMAIL]</label>
315  <input type=\"text\" class=\"form-control\" id=\"email\" name=\"email\" placeholder=\"$lang[PASSWORD_RESET_HOWTO]\">
316  <div class=\"text-center\"><br><i>$lang[OR]</i><br></div>
317  <label for=\"username\">$lang[USERNAME]</label>
318  <input type=\"text\" class=\"form-control\" id=\"username\" name=\"username\" placeholder=\"$lang[USERNAME]\">
319  <input type=\"hidden\" name=\"resetPasswordRequest\" id=\"resetPasswordRequest\" value=\"true\">
320  </div>
321  <div class=\"modal-footer\">
322  <div class=\"form-group col-md-12\"><h3 class=\"pull-left\">Please solve this captcha:</h3></div>
323  <div class =\"form-group col-md-4\">
324  <input type=\"text\" size=\"1\" maxlength=\"2\" name=\"number1\" id=\"number1\" value=\"".rand(1,12)."\">
325  </div>
326  <div class=\"form-group col-md-4\">
327  <label for=\"number2\"> + </label> <input type=\"text\" size=\"1\" maxlength=\"2\" name=\"number2\" id=\"number2\" value=\"".rand(1,12)."\">
328  </div>
329  <div class=\"form-group col-md-4\">
330  <label for=\"captcha\"> = </label> <input type=\"text\" size=\"2\" maxlength=\"2\" name=\"captcha\" id=\"captcha\">
331  </div>
332  <button type=\"submit\" class=\"btn btn-success\"><i class=\"fa fa-check\"></i> &nbsp;$lang[PASSWORD_RESET]</button>
333  <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\"><i class=\"fa fa-times\"></i>&nbsp; $lang[CANCEL]</button>
334  <input type=\"hidden\" name=\"resetPasswordRequest\" id=\"resetPasswordRequest\" value=\"true\">
335  <hr>";
336  if (!empty($_SERVER['REMOTE_ADDR'])){
337  $ip = $_SERVER['REMOTE_ADDR'];
338  $hostname = gethostname();
339  $network = gethostbyaddr($_SERVER['REMOTE_ADDR']);
340  }
341  else {
342  $ip = "unknown";
343  $hostname = "unknown";
344  $network = "";
345  }
346 
347  $modalWindow .= "<div class=\"text-left small\"><i><small>Access from IP: $ip @ $hostname from network: $network will be logged.</small></i></div>
348  </div>
349  </div>
350 
351  </div>
352  </div>
353  </form>";
354  // TEMPLATE WRAPPER - HEADER & breadcrumbs
355  $loginBox = "
356  <div class=\"row\" id=\"loginbox\"><br><br>
357  <div class=\"col-md-4\">&nbsp;</div>
358  <div class=\"col-md-4\">
359  <div class=\"box box-default\">
360  <div class=\"box-body\">
361  <h3>Login :: <small>" . $title . "</small></h3><br>";
362  $loginBox .= \YAWK\backend::drawLoginForm("","", $lang);
363  $loginBox .= "<div id=\"loginTimerNode\"></div>
364  </div>
365  <br><br>
366  </div>
367  <div class=\"col-md-4\">&nbsp;</div>
368  </div>";
369  return $modalWindow.$loginBox;
370  }
371 
372  /**
373  * @brief Clever function to return the username. Expects the user object as param to work correctly.
374  * @param object $user User object is required.
375  * @return null|string Return the proper string or null.
376  */
377  static function getFullUsername($user)
378  {
379  if (empty($user->firstname))
380  {
381  $currentUser = $user->username;
382  }
383  if (empty($user->lastname))
384  {
385  $currentUser = $user->username;
386  }
387  if (!empty($user->firstname) && (empty($user->lastname)))
388  {
389  $currentUser = $user->firstname;
390  }
391  if (empty($user->firstname) && (!empty($user->lastname)))
392  {
393  $currentUser = $user->lastname;
394  }
395  if (!empty($user->firstname) && (!empty($user->lastname)))
396  {
397  $currentUser = "$user->firstname"."&nbsp;"."$user->lastname";
398  }
399  if (isset($currentUser))
400  {
401  return $currentUser;
402  }
403  else
404  {
405  return null;
406  }
407  }
408 
409 
410  /**
411  * @brief Get pages and user groups into an array.
412  * @param object $db Database object
413  * @return array|string
414  */
415  public static function getPagesArray($db) // get all settings from db like property
416  {
417  /* @param $db \YAWK\db */
418  if ($res = $db->query("SELECT cp.*, cg.value as gid FROM {pages} as cp
419  JOIN {user_groups} as cg on cp.gid = cg.id ORDER BY id DESC")) {
420  $pagesArray = array();
421  while ($row = $res->fetch_assoc()){
422  $pagesArray[] = $row;
423  }
424  /* free result set */
425  $res->close();
426  }
427  else {
428  $pagesArray = '';
429  echo \YAWK\alert::draw("danger", "Error!", "Sorry, fetch database error: getPagesArray failed.","",4200);
430  // die ("Sorry, fetch database error: getPagesArray failed.");
431  }
432  return $pagesArray;
433  }
434 
435  /**
436  * @brief Get Menu id name and published into an array.
437  * @param object $db Database object
438  * @return array
439  */
440  static function getMenusArray($db)
441  {
442  /* @param $db \YAWK\db */
443  if ($res = $db->query("SELECT id, name, published, (
444  SELECT COUNT(*)
445  FROM {menu}
446  WHERE menuID = {menu_names}.id
447  ) count FROM {menu_names}")) {
448  $menusArray = array();
449  while ($rows = $res->fetch_assoc()) {
450  $menusArray[] = $rows;
451  }
452  /* free result set */
453  $res->close();
454  } else {
455  die ("Sorry, fetch database error: getMenus failed.");
456  }
457  return $menusArray;
458  }
459 
460  /**
461  * @brief return all menu ids and names as array
462  * @param $db
463  * @return array
464  */
465  static function getMenuNamesArray($db)
466  {
467  /* @param $db \YAWK\db */
468  if ($res = $db->query("SELECT id, name FROM {menu_names} WHERE published = '1'"))
469  {
470  $menusArray = array();
471  while ($rows = $res->fetch_assoc()) {
472  $menusArray[] = $rows;
473  }
474  /* free result set */
475  $res->close();
476  } else {
477  die ("Sorry, fetch database error: getMenus failed.");
478  }
479  return $menusArray;
480  }
481 
482  /**
483  * @brief Draw a list with all fonts. Expects fonts as array
484  * @param array $fontArray array with font names
485  * @param string $folder the folder where fonts are stored
486  * @param array $lang language array
487  */
489  {
490  // we need to check if its a custom font (ttf, otf, woff) or google font.
491  // this determination is needed to flag the delete link - this ensures that
492  // the delete function knows if it's a file to delete or an entry from the database.
493  if ($type === "Google" || ($type === "google"))
494  { // flag get param as google font
495  $flag = "&type=google";
496  }
497  else
498  { // font type unknown
499  $flag = "&type=custom";
500  }
501  // folder is empty...
502  if (!isset($folder) || (empty($folder)))
503  { // default folder
504  $folder = '../system/fonts/';
505  }
506  // if array is empty - no fonts were found
507  if (empty($fontArray))
508  { // throw a message
509  echo $lang['FONTS_NOT_FOUND'];
510  echo "<a href=\"#\" id=\"addFontBtn\" data-toggle=\"modal\" data-target=\"#myModal\"
511  style=\"margin-top:2px;\"><i><small>&nbsp;&nbsp;&raquo; ".$lang['ADD']."</small></i></a>";
512  }
513  else
514  { // walk through folder
515  foreach ($fontArray as $font)
516  { // draw list with fonts, delete and download icon
517  echo "<!-- draw font -->
518  <h4 style=\"font-family:'$font';\">$font<small>
519  <!-- delete font icon -->
520  <a role=\"dialog\" data-confirm=\"$lang[FONT] &laquo; ".$font." &raquo; $lang[DELETE_CONFIRM]\"
521  title=\"".$lang['FONT_DEL']."\" href=\"index.php?page=settings-fonts&delete=true$flag&font=$font\">
522  <i class=\"fa fa-trash-o pull-right\" data-toggle=\"tooltip\" title=\"$lang[DELETE]\" style=\"margin-top:4px;\"></i></a>&nbsp;";
523 
524  // if google fonts get drawn...
525  if ($type === "Google" || ($type === "google"))
526  {
527  // no download icon
528  }
529  else
530  { // download font icon
531  echo "<a href=\"$folder$font\" title=\"$lang[DOWNLOAD] $font\"><i class=\"fa fa-arrow-circle-o-down pull-right\"
532  data-toggle=\"tooltip\" title=\"$lang[TO_DOWNLOAD]\" style=\"margin-top:4px;\"></i></a>&nbsp;&nbsp;";
533  }
534  // close tags
535  echo "</small></h4><hr>";
536  }
537  }
538  }
539 
540 
541  /**
542  * @brief Draw a box containing all widgets that are linked with given page.
543  * Every Widget gets drawn as small bubble/button and is linked with the
544  * corresponding Widget-edit page. This increased the workflow while editing
545  * a page and their widgets.
546  * @param object $db Database handle
547  * @param object $page current page object
548  * @param array $lang language array
549  */
550  static function drawWidgetsOnPageBox($db, $page, $lang)
551  {
552  // get widget list from database
553  $widgetList = widget::loadWidgetsOfPage($db, $page);
554 
555  // Draw a list of widgets, that are bound to this given page->id
556  echo'<!-- WIDGET OVERVIEW -->
557  <div class="box box-default">
558  <div class="box-header with-border">
559  <h3 class="box-title"><i class="fa fa-tags"></i>&nbsp;&nbsp;'.$lang["WIDGETS"].' <small>'.$lang["WIDGETS_ON_THIS_PAGE"].'</small></h3>
560  <!-- box-tools -->
561  <div class="box-tools pull-right">
562  <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
563  </button>
564  </div>
565  <!-- /.box-tools -->
566  </div>
567  <div class="box-body" style="display: block;">';
568  if (isset($widgetList) && (is_array($widgetList)))
569  {
570  // loop through all found widgets
571  foreach ($widgetList as $widget)
572  {
573  // set color of widget depending on published state
574  if ($widget['published'] == 1){ $wTextColor = 'default'; } else { $wTextColor = 'danger'; }
575 
576  // set widget info tag
577  if ($widget['pageID'] == 0){ $wPageInfo = 'all'; } else { $wPageInfo = 'this'; }
578 
579  // check, if widget title is set
580  if ((empty($widget['widgetTitle'])))
581  { // if not, set widget name as title
582  $widget['widgetTitle'] = $widget['name'];
583  }
584 
585  // draw widget bubble
586  echo '<p style="float:left; margin-right:5px;"><a href="index.php?page=widget-edit&widget='.$widget['id'].'" class="btn btn-xs btn-'.$wTextColor.'" title="'.$lang['EDIT'].': '.$widget['name'].' '.$lang['WIDGET'].'">
587  '.$widget['widgetTitle'].' @<small> '.$wPageInfo.' | '.$widget['position'].'</small></a></p>';
588  }
589  }
590  else {
591  echo'<p>'.$lang['NO_WIDGET_CREATED'].' <small><i>(<a href="index.php?page=widget-new">'.$lang['CREATE'].'</a>)</small></p>';
592  }
593  echo'</div>
594  </div>';
595 
596  } // eof drawWidgetsOnPageBox
597 
598  /**
599  * @brief Draw a small question mark, enabling a tooltip on hover.
600  * toolTipText must be a string and will usually come from any language file.
601  * @param string $toolTipText text that will appear as tooltip on mouseover
602  */
603  public static function printTooltip($toolTipText)
604  {
605  if (!empty($toolTipText))
606  { // print out toolTip markup
607  return '<small><i class="fa fa-question-circle-o text-info" data-placement="auto right" data-toggle="tooltip" title="'.$toolTipText.'"></i></small>';
608  }
609  else {
610  return '<small><i class="fa fa-question-circle-o text-info" data-placement="auto right" data-toggle="tooltip" title="Tooltip fehlt leider :("></i></small>';
611  }
612  }
613 
614  } /* END class::backend */
615 }
$folder
Definition: actions.php:9
$ip
Definition: add-comment.php:9
print $lang['FILEMAN_UPLOAD']
die
Definition: block-user.php:27
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
static getMenusArray($db)
Get Menu id name and published into an array.
Definition: backend.php:440
static getPagesArray($db)
Get pages and user groups into an array.
Definition: backend.php:415
static setTimeout($location, $wait)
Definition: backend.php:106
static getFullUsername($user)
Clever function to return the username. Expects the user object as param to work correctly.
Definition: backend.php:377
static getTitle($title, $subtext)
Header title on top of every page.
Definition: backend.php:79
static getSettingsBreadcrumbs($lang)
Return breadcrumbs for settings pages.
Definition: backend.php:34
static printTooltip($toolTipText)
Draw a small question mark, enabling a tooltip on hover. toolTipText must be a string and will usuall...
Definition: backend.php:603
static drawTemplateSelectField($db, $description)
Draw a SELECT field with all templates, current active template is selected.
Definition: backend.php:213
static setFocus($field)
Set focus to any input field on pageload.
Definition: backend.php:93
static getTemplateBreadcrumbs($lang)
Return breadcrumbs for template pages.
Definition: backend.php:55
static getFX($db, $time, $type)
Include Javascript FX to apply on #content-FX DOM element.
Definition: backend.php:123
static getMenuNamesArray($db)
return all menu ids and names as array
Definition: backend.php:465
static drawLoginForm($username, $password, $lang)
Draw a login form. If username and/or password was given, the form will be pre-filled with given valu...
Definition: backend.php:243
static drawWidgetsOnPageBox($db, $page, $lang)
Draw a box containing all widgets that are linked with given page. Every Widget gets drawn as small b...
Definition: backend.php:550
static drawFontList($fontArray, $folder, $type, $lang)
Draw a list with all fonts. Expects fonts as array.
Definition: backend.php:488
static drawLoginBox($db, $lang)
Draw a login box. Basically it wraps the drawLoginForm function with an AdminLTE box.
Definition: backend.php:294
static drawContentWrapper()
Draw the AdminLTE Content Wrapper. Useful that view dont crash in situations where the DOM is not loa...
Definition: backend.php:144
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470
static getTemplateIds(object $db)
return array with all template id's + names.
Definition: template.php:426
static loadWidgetsOfPage($db, $page)
Returns an array of all widgets that are linked with given page->id.
Definition: widget.php:1182
$subtext
Definition: jplayer.php:19
$rows
Definition: menus.php:126
$type
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
print $_GET['id']
Definition: page-edit.php:357
$page
Definition: pages.php:355
$field
Definition: booking.php:9
$fontArray
$redirect