Ubiquity  2.0.3
php rapid development framework
MessagesTrait.php
Go to the documentation of this file.
1 <?php
2 
4 
12 
19 
23  abstract public function _getModelViewer();
24 
25  protected function _showSimpleMessage(CRUDMessage $message,$staticName=null):HtmlMessage{
26  return $this->showSimpleMessage($message->getMessage(), $message->getType(),$message->getTitle(),$message->getIcon(),$message->getTimeout(),$staticName);
27  }
28 
29  public function showSimpleMessage($content, $type, $title=null,$icon = "info", $timeout = NULL, $staticName = null): HtmlMessage {
30  $semantic = $this->jquery->semantic ();
31  if (! isset ( $staticName ))
32  $staticName = "msg-" . rand ( 0, 50 );
33  $message = $semantic->htmlMessage ( $staticName, $content, $type );
34  if(isset($title)){
35  $message->addHeader($title);
36  }
37  $message->setIcon ( $icon );
38  $message->setDismissable ();
39  if (isset ( $timeout ))
40  $message->setTimeout ( 3000 );
41  return $message;
42  }
43 
44  protected function _showConfMessage(CRUDMessage $message,$url, $responseElement, $data, $attributes = NULL):HtmlMessage {
45  return $this->showConfMessage($message->getMessage(), $message->getType(), $message->getTitle(), $url, $responseElement, $data,$attributes);
46  }
47 
48  public function showConfMessage($content, $type, $title,$url, $responseElement, $data, $attributes = NULL):HtmlMessage {
49  $messageDlg = $this->showSimpleMessage ( $content, $type,$title, "help circle" );
50  $btOkay = new HtmlButton( "bt-okay", "Confirm", "negative" );
51  $btOkay->addIcon ( "check circle" );
52  $btOkay->postOnClick ( $url, "{data:'" . $data . "'}", $responseElement, $attributes );
53  $btCancel = new HtmlButton ( "bt-cancel-" . UString::cleanAttribute ( $url ), "Cancel" );
54  $btCancel->addIcon ( "remove circle outline" );
55  $btCancel->onClick ( $messageDlg->jsHide () );
56  $messageDlg->addContent ( [ new HtmlDivider( "" ),new HtmlSemDoubleElement( "", "div", "", [ $btOkay->floatRight (),$btCancel->floatRight () ] ) ] );
57  $this->_getModelViewer()->confirmButtons($btOkay, $btCancel);
58  return $messageDlg;
59  }
60 }
61 
showSimpleMessage($content, $type, $title=null, $icon="info", $timeout=NULL, $staticName=null)
_showSimpleMessage(CRUDMessage $message, $staticName=null)
static cleanAttribute($attr, $replacement="_")
Definition: UString.php:99
_showConfMessage(CRUDMessage $message, $url, $responseElement, $data, $attributes=NULL)
showConfMessage($content, $type, $title, $url, $responseElement, $data, $attributes=NULL)