Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
MessagesTrait.php
Go to the documentation of this file.
1<?php
2
4
5use Ajax\semantic\html\elements\HtmlButton;
7use Ajax\semantic\html\elements\HtmlDivider;
8use Ajax\semantic\html\base\HtmlSemDoubleElement;
9use Ajax\semantic\html\collections\HtmlMessage;
12
20
25 abstract protected function _getModelViewer();
26
27 abstract public function _getFiles();
28
29 protected function showSimpleMessage_(CRUDMessage $message, $staticName = null, $toast = false): HtmlMessage {
30 return $this->_showSimpleMessage ( $message->getMessage (), $message->getType (), $message->getTitle (), $message->getIcon (), $message->getTimeout (), $staticName, null, $toast );
31 }
32
33 public function _showSimpleMessage($content, $type, $title = null, $icon = "info", $timeout = NULL, $staticName = null, $closeAction = null, $toast = false): HtmlMessage {
34 $semantic = $this->jquery->semantic ();
35 if (! isset ( $staticName ))
36 $staticName = "msg-" . rand ( 0, 50 );
37 if(isset($this->style)){
38 $type.=' '.$this->style;
39 }
40 $message = $semantic->htmlMessage ( $staticName, $content, $type );
41 if (isset ( $title )) {
42 $message->addHeader ( $title );
43 }
44 if (isset ( $icon )) {
45 $message->setIcon ( $icon );
46 }
47 if ($timeout !== '') {
48 $message->setDismissable ();
49 }
50 if ($timeout != null) {
51 $message->setTimeout ( 3000 );
52 } elseif (isset ( $closeAction )) {
53 $message->getOnClose ( $this->_getFiles ()->getAdminBaseRoute () . "/_closeMessage/" . $closeAction );
54 }
55 if ($toast) {
56 $message->asToast ($toast);
57 }
58 return $message;
59 }
60
61 protected function showConfMessage_(CRUDMessage $message, $url, $responseElement, $data, $attributes = NULL): HtmlMessage {
62 return $this->_showConfMessage ( $message->getMessage (), $message->getType (), $message->getTitle (), $message->getIcon (), $url, $responseElement, $data, $attributes );
63 }
64
65 protected function _showConfMessage($content, $type, $title, $icon, $url, $responseElement, $data, $attributes = NULL): HtmlMessage {
66 $messageDlg = $this->_showSimpleMessage ( $content, $type, $title, $icon );
67 $btOkay = new HtmlButton ( "bt-okay", "Confirm", "negative" );
68 $btOkay->addIcon ( "check circle" );
69 $btOkay->postOnClick ( $url, "{data:'" . $data . "'}", $responseElement, $attributes );
70 $btCancel = new HtmlButton ( "bt-cancel-" . UString::cleanAttribute ( $url ), "Cancel" );
71 $btCancel->addIcon ( "remove circle outline" );
72 $btCancel->onClick ( $messageDlg->jsHide () );
73 $messageDlg->addContent ( [ new HtmlDivider ( "" ),new HtmlSemDoubleElement ( "", "div", "", [ $btOkay->floatRight (),$btCancel->floatRight () ] ) ] );
74 $this->_getModelViewer ()->onConfirmButtons ( $btOkay, $btCancel );
75 return $messageDlg;
76 }
77}
78
Associated with a CRUDController class Responsible of the display.
showSimpleMessage_(CRUDMessage $message, $staticName=null, $toast=false)
_showSimpleMessage($content, $type, $title=null, $icon="info", $timeout=NULL, $staticName=null, $closeAction=null, $toast=false)
showConfMessage_(CRUDMessage $message, $url, $responseElement, $data, $attributes=NULL)
_showConfMessage($content, $type, $title, $icon, $url, $responseElement, $data, $attributes=NULL)
String utilities.
Definition UString.php:15