YaWK  24.1
Yet another WebKit
YAWK\alert Class Reference

Throws a fancy Bootstrap Alert (success, info, warning or danger) More...

+ Inheritance diagram for YAWK\alert:

Static Public Member Functions

static draw ($type, $title, $text, $redirect, $delay)
 

Detailed Description

Throws a fancy Bootstrap Alert (success, info, warning or danger)

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com

Throw default bootstrap-powered alerts. (warning, succes etc...) This lets you throw an alert message box at any time, anywhere in your script. Alert uses 5 Arguments, as shown below. Example: any place of your script where an error, info, success or danger Message needs to be thrown.

Class covers both, backend & frontend functionality. See Methods Summary for Details!

Definition at line 18 of file alert.php.

Member Function Documentation

◆ draw()

static YAWK\alert::draw (   $type,
  $title,
  $text,
  $redirect,
  $delay 
)
static

Definition at line 30 of file alert.php.

31  {
32 
33  // default animation when alert pops in
34  $animatedEnter = "animated fadeInDown";
35  // default animation when alert pops out
36  $animatedExit = "animated fadeOutUp";
37  // default placementFrom (top, bottom)
38  $placementFrom = "top";
39  // default placementFrom (left, center, right)
40  $placementAlign = "center";
41  // any URL to link to
42  $url = "";
43  // URL target
44  $urlTarget = "_blank";
45  // should it be allowed to dismiss this alert?
46  $allowDismiss = "true";
47  // display newest on top if there are more simultaneous alerts?
48  $newestOnTop = "false";
49  // display a progressbar to show how long the alert will stay
50  $progressBar = "false";
51  // offest X axis
52  $offsetX = "10";
53  // offest Y axis
54  $offsetY = "62";
55  // spacing
56  $spacing = "10";
57  // z-index
58  $zIndex = "9999";
59  // icon
60  $icon = "fa fa-info-circle";
61 
62  if (!isset($type) || (empty($type)))
63  {
64  $type = "info";
65  }
66  if (!isset($title) || (empty($title)))
67  {
68  $title = "";
69  }
70  if (!isset($text) || (empty($text)))
71  {
72  $text = "";
73  }
74  if (!isset($redirect) || (empty($redirect)))
75  {
76  $redirect = "";
77  }
78  if (!isset($delay) || (empty($delay)))
79  {
80  $delay = 0;
81  }
82 
83  if (empty($type)) { $type="danger"; }
84  if (empty($title)) { $title="ERROR!"; }
85  if (empty($text)) { $text="Something strange has happened. Text is empty. Sorry that there is no more Information available. (Code 0)"; }
86  if (empty($redirect)) { $redirect="null"; }
87  if (empty($delay)) { $delay="null"; }
88 
89  if ($redirect === "null" && ($delay !== "null"))
90  {
91  $n_delay = $delay;
92  }
93  else {
94  // calculate delay time for notify before redirect
95  $n_delay = $delay;
96  if (is_int($n_delay)){
97  $n_delay = $n_delay / 3;
98  $n_delay = round($n_delay);
99  }
100  }
101 
102  if ($delay === "null")
103  {
104  $n_delay = "null";
105  }
106 
107  // switch icon
108  switch ($type)
109  {
110  case "danger":
111  $icon = "fa fa-exclamation-triangle";
112  break;
113  case "warning":
114  $icon = "fa fa-flash";
115  break;
116  case "success":
117  $icon = "fa fa-check-circle-o";
118  break;
119  case "tipofday":
120  $icon = "fa fa-lightbulb-o";
121  $type = "success";
122  $animatedEnter = "animated fadeInRight";
123  $animatedExit = "animated fadeOutRight";
124  $placementFrom = "top";
125  $placementAlign = "right";
126  break;
127  default:
128  $icon = "fa fa-info-circle";
129  break;
130  }
131 
132  // run notify javascript
133  echo "
134  <script type=\"text/javascript\">
135  $.notify({
136  // options
137  title: '<h4><i class=\"$icon\"></i>&nbsp; $title</h4>',
138  message: '$text',
139  url: '$url',
140  target: '$urlTarget'
141  }, {
142  // settings
143  type: '$type',
144  element: 'body',
145  position: null,
146  allow_dismiss: '$allowDismiss',
147  newest_on_top: '$newestOnTop',
148  showProgressbar: $progressBar,
149  placement: {
150  from: '$placementFrom',
151  align: '$placementAlign'
152  },
153  offset: {
154  x: $offsetX,
155  y: $offsetY
156  },
157  spacing: $spacing,
158  z_index: $zIndex,
159  delay: '$n_delay',
160  timer: 420,
161  url_target: '$urlTarget',
162  mouse_over: 'pause',
163  animate: {
164  enter: '$animatedEnter',
165  exit: '$animatedExit'
166  }
167  });
168  </script>";
169 
170  if ($redirect !== "null" && ($delay !== "null"))
171  {
172  // redirect after notify with given delay param
173  return \YAWK\sys::setTimeout("index.php?$redirect", $delay);
174  }
175  else
176  {
177  return null;
178  }
179  } // ./draw
$offsetY
Definition: actions.php:19
$offsetX
Definition: actions.php:18
$type
$redirect
$url
Definition: user-new.php:101

References $offsetX, $offsetY, $redirect, $type, and $url.

Referenced by YAWK\page\copy(), YAWK\stats\countLogins(), YAWK\page\create(), YAWK\page\delete(), YAWK\template\deleteSettingsCSSFile(), YAWK\BACKEND\AdminLTE\drawHtmlContent(), YAWK\tipOfDay\drawTip(), YAWK\settings\getAllSettingsArray(), YAWK\settings\getEditorSettings(), YAWK\sys\getGroupFromId(), YAWK\sys\getGroupId(), YAWK\user\getLoginData(), YAWK\settings\getLongSetting(), YAWK\page\getMetaTags(), YAWK\page\getProperty(), YAWK\settings\getSettingDescription(), YAWK\stats\getStatsArray(), YAWK\settings\getValueSettingsArray(), YAWK\settings\getWidgetSetting(), YAWK\sys\isBrowscapSet(), YAWK\page\save(), YAWK\user\sendResetEmail(), YAWK\settings\setLongSetting(), YAWK\settings\setSetting(), YAWK\settings\setTemplateSetting(), YAWK\settings\setWidgetSetting(), YAWK\installer\step2(), YAWK\installer\step3(), YAWK\installer\step4(), YAWK\installer\step5(), YAWK\menu\toggleItemOffline(), YAWK\page\toggleLock(), YAWK\page\toggleOffline(), and YAWK\settings\toggleOffline().


The documentation for this class was generated from the following file: