@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class HtmlModal extends HtmlSemDoubleElement { |
| 18 | 18 | |
| 19 | - protected $_params = []; |
|
| 19 | + protected $_params=[]; |
|
| 20 | 20 | |
| 21 | - protected $_paramParts = []; |
|
| 21 | + protected $_paramParts=[]; |
|
| 22 | 22 | |
| 23 | - public function __construct($identifier, $header = '', $content = '', $actions = null) { |
|
| 23 | + public function __construct($identifier, $header='', $content='', $actions=null) { |
|
| 24 | 24 | parent::__construct($identifier, 'div', 'ui modal'); |
| 25 | 25 | if (isset($header)) { |
| 26 | 26 | $this->setHeader($header); |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function setHeader($value) { |
| 37 | - $this->content['header'] = new HtmlSemDoubleElement('header-' . $this->identifier, 'a', 'header', $value); |
|
| 37 | + $this->content['header']=new HtmlSemDoubleElement('header-'.$this->identifier, 'a', 'header', $value); |
|
| 38 | 38 | return $this; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function setContent($value) { |
| 42 | - $this->content['content'] = new HtmlSemDoubleElement('content-' . $this->identifier, 'div', 'content', $value); |
|
| 42 | + $this->content['content']=new HtmlSemDoubleElement('content-'.$this->identifier, 'div', 'content', $value); |
|
| 43 | 43 | return $this; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | * @return HtmlButton[] |
| 51 | 51 | */ |
| 52 | 52 | public function setActions($actions): array { |
| 53 | - $this->content['actions'] = new HtmlSemDoubleElement('content-' . $this->identifier, 'div', 'actions'); |
|
| 54 | - $r = []; |
|
| 53 | + $this->content['actions']=new HtmlSemDoubleElement('content-'.$this->identifier, 'div', 'actions'); |
|
| 54 | + $r=[]; |
|
| 55 | 55 | if (\is_array($actions)) { |
| 56 | 56 | foreach ($actions as $action) { |
| 57 | - $r[] = $this->addAction($action); |
|
| 57 | + $r[]=$this->addAction($action); |
|
| 58 | 58 | } |
| 59 | 59 | } else { |
| 60 | - $r[] = $this->addAction($actions); |
|
| 60 | + $r[]=$this->addAction($actions); |
|
| 61 | 61 | } |
| 62 | 62 | return $r; |
| 63 | 63 | } |
@@ -68,24 +68,24 @@ discard block |
||
| 68 | 68 | * @return HtmlButton |
| 69 | 69 | */ |
| 70 | 70 | public function addAction($action) { |
| 71 | - if (! $action instanceof BaseHtml) { |
|
| 72 | - $class = ''; |
|
| 71 | + if (!$action instanceof BaseHtml) { |
|
| 72 | + $class=''; |
|
| 73 | 73 | if (\array_search($action, [ |
| 74 | 74 | 'Okay', |
| 75 | 75 | 'Yes', |
| 76 | 76 | 'Validate' |
| 77 | - ]) !== false) { |
|
| 78 | - $class = 'approve'; |
|
| 77 | + ])!==false) { |
|
| 78 | + $class='approve'; |
|
| 79 | 79 | } |
| 80 | 80 | if (\array_search($action, [ |
| 81 | 81 | 'Close', |
| 82 | 82 | 'Cancel', |
| 83 | 83 | 'No' |
| 84 | - ]) !== false) { |
|
| 85 | - $class = 'cancel'; |
|
| 84 | + ])!==false) { |
|
| 85 | + $class='cancel'; |
|
| 86 | 86 | } |
| 87 | - $action = new HtmlButton('action-' . $this->identifier . '-' . JArray::count($this->content['actions']->getContent()), $action); |
|
| 88 | - if ($class !== '') |
|
| 87 | + $action=new HtmlButton('action-'.$this->identifier.'-'.JArray::count($this->content['actions']->getContent()), $action); |
|
| 88 | + if ($class!=='') |
|
| 89 | 89 | $action->addToProperty('class', $class); |
| 90 | 90 | } |
| 91 | 91 | return $this->addElementInPart($action, 'actions'); |
@@ -100,33 +100,33 @@ discard block |
||
| 100 | 100 | return $this->content['actions']->getContent()[$index]; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function addContent($content, $before = false) { |
|
| 103 | + public function addContent($content, $before=false) { |
|
| 104 | 104 | $this->content['content']->addContent($content, $before); |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function addImageContent($image, $description = NULL) { |
|
| 109 | - $content = $this->content['content']; |
|
| 108 | + public function addImageContent($image, $description=NULL) { |
|
| 109 | + $content=$this->content['content']; |
|
| 110 | 110 | if (isset($description)) { |
| 111 | - $description = new HtmlSemDoubleElement('description-' . $this->identifier, 'div', 'description', $description); |
|
| 111 | + $description=new HtmlSemDoubleElement('description-'.$this->identifier, 'div', 'description', $description); |
|
| 112 | 112 | $content->addContent($description, true); |
| 113 | 113 | } |
| 114 | - if ($image !== '') { |
|
| 115 | - $img = new HtmlImage('image-' . $this->identifier, $image, '', 'medium'); |
|
| 114 | + if ($image!=='') { |
|
| 115 | + $img=new HtmlImage('image-'.$this->identifier, $image, '', 'medium'); |
|
| 116 | 116 | $content->addContent($img, true); |
| 117 | 117 | $content->addToProperty('class', 'image'); |
| 118 | 118 | } |
| 119 | 119 | return $this; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function addIconContent($icon, $description = NULL) { |
|
| 123 | - $content = $this->content['content']; |
|
| 122 | + public function addIconContent($icon, $description=NULL) { |
|
| 123 | + $content=$this->content['content']; |
|
| 124 | 124 | if (isset($description)) { |
| 125 | - $description = new HtmlSemDoubleElement('description-' . $this->identifier, 'div', 'description', $description); |
|
| 125 | + $description=new HtmlSemDoubleElement('description-'.$this->identifier, 'div', 'description', $description); |
|
| 126 | 126 | $content->addContent($description, true); |
| 127 | 127 | } |
| 128 | - if ($icon !== '') { |
|
| 129 | - $img = new HtmlIcon('image-' . $this->identifier, $icon); |
|
| 128 | + if ($icon!=='') { |
|
| 129 | + $img=new HtmlIcon('image-'.$this->identifier, $icon); |
|
| 130 | 130 | $content->addContent($img, true); |
| 131 | 131 | $content->addToProperty('class', 'image'); |
| 132 | 132 | } |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function showDimmer($value) { |
| 142 | - $value = $value ? 'show' : 'hide'; |
|
| 143 | - $this->_paramParts[] = [ |
|
| 144 | - "'" . $value . " dimmer'" |
|
| 142 | + $value=$value ? 'show' : 'hide'; |
|
| 143 | + $this->_paramParts[]=[ |
|
| 144 | + "'".$value." dimmer'" |
|
| 145 | 145 | ]; |
| 146 | 146 | return $this; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public function setInverted($recursive = true) { |
|
| 150 | - $this->_params['inverted'] = true; |
|
| 149 | + public function setInverted($recursive=true) { |
|
| 150 | + $this->_params['inverted']=true; |
|
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function setTransition($value) { |
| 159 | - $this->_paramParts[] = [ |
|
| 159 | + $this->_paramParts[]=[ |
|
| 160 | 160 | "'setting'", |
| 161 | 161 | "'transition'", |
| 162 | - "'" . $value . "'" |
|
| 162 | + "'".$value."'" |
|
| 163 | 163 | ]; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param array $params |
| 173 | 173 | * The parameters to pass to the view |
| 174 | 174 | */ |
| 175 | - public function renderView(JsUtils $js, $initialController, $viewName, $params = array()) { |
|
| 175 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
| 176 | 176 | return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * the action name |
| 188 | 188 | * @param array $params |
| 189 | 189 | */ |
| 190 | - public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params = NULL) { |
|
| 190 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
| 191 | 191 | return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
| 199 | 199 | */ |
| 200 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 201 | - $this->content = JArray::sortAssociative($this->content, [ |
|
| 200 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 201 | + $this->content=JArray::sortAssociative($this->content, [ |
|
| 202 | 202 | 'header', |
| 203 | 203 | 'content', |
| 204 | 204 | 'actions' |
@@ -214,14 +214,14 @@ discard block |
||
| 214 | 214 | * @see BaseHtml::run() |
| 215 | 215 | */ |
| 216 | 216 | public function run(JsUtils $js) { |
| 217 | - if (isset($this->_bsComponent) === false) |
|
| 218 | - $this->_bsComponent = $js->semantic()->modal('#' . $this->identifier, $this->_params, $this->_paramParts); |
|
| 217 | + if (isset($this->_bsComponent)===false) |
|
| 218 | + $this->_bsComponent=$js->semantic()->modal('#'.$this->identifier, $this->_params, $this->_paramParts); |
|
| 219 | 219 | $this->addEventsOnRun($js); |
| 220 | 220 | return $this->_bsComponent; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function jsDo($behavior) { |
| 224 | - return "$('#" . $this->identifier . "').modal('" . $behavior . "');"; |
|
| 224 | + return "$('#".$this->identifier."').modal('".$behavior."');"; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | public function jsHide() { |
@@ -229,6 +229,6 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | public function onHidden($js) { |
| 232 | - $this->_params['onHidden'] = $js; |
|
| 232 | + $this->_params['onHidden']=$js; |
|
| 233 | 233 | } |
| 234 | 234 | } |
@@ -85,8 +85,9 @@ discard block |
||
| 85 | 85 | $class = 'cancel'; |
| 86 | 86 | } |
| 87 | 87 | $action = new HtmlButton('action-' . $this->identifier . '-' . JArray::count($this->content['actions']->getContent()), $action); |
| 88 | - if ($class !== '') |
|
| 89 | - $action->addToProperty('class', $class); |
|
| 88 | + if ($class !== '') { |
|
| 89 | + $action->addToProperty('class', $class); |
|
| 90 | + } |
|
| 90 | 91 | } |
| 91 | 92 | return $this->addElementInPart($action, 'actions'); |
| 92 | 93 | } |
@@ -214,8 +215,9 @@ discard block |
||
| 214 | 215 | * @see BaseHtml::run() |
| 215 | 216 | */ |
| 216 | 217 | public function run(JsUtils $js) { |
| 217 | - if (isset($this->_bsComponent) === false) |
|
| 218 | - $this->_bsComponent = $js->semantic()->modal('#' . $this->identifier, $this->_params, $this->_paramParts); |
|
| 218 | + if (isset($this->_bsComponent) === false) { |
|
| 219 | + $this->_bsComponent = $js->semantic()->modal('#' . $this->identifier, $this->_params, $this->_paramParts); |
|
| 220 | + } |
|
| 219 | 221 | $this->addEventsOnRun($js); |
| 220 | 222 | return $this->_bsComponent; |
| 221 | 223 | } |