70 $this->_template =
"%wrapContentBefore%%content%%wrapContentAfter%";
72 if (isset($modelInstance)) {
73 if (\is_object($modelInstance)) {
74 $this->_model = \get_class($modelInstance);
76 $this->
show($modelInstance);
78 $this->_generated =
false;
81 protected function _init($instanceViewer, $contentKey,
$content, $edition) {
82 $this->_instanceViewer = $instanceViewer;
88 $this->_edition = $edition;
98 if (\is_string($fieldName)) {
99 $fields = $this->_instanceViewer->getVisibleProperties();
100 $index = \array_search($fieldName, $fields);
106 return $this->identifier .
"-{$prefix}-" . $this->_instanceViewer->getIdentifier();
110 return $this->_instanceViewer->getFieldName($index);
114 return $this->_instanceViewer->getCaption($index);
119 public function show($modelInstance) {
120 if (\is_array($modelInstance)) {
121 $modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
123 $this->_modelInstance = $modelInstance;
162 if ($index !==
false) {
163 $this->_instanceViewer->afterCompile($index, $callback);
173 $this->_instanceViewer->setCaptions($captions);
178 $this->_instanceViewer->setCaption($this->
_getIndex($index), $caption);
183 $this->_instanceViewer->setVisibleProperties($fields);
188 $this->_instanceViewer->addField($field, $key);
193 $this->_instanceViewer->addFields($fields);
198 return $this->_instanceViewer->visiblePropertiesCount();
201 public function addMessage($attributes = NULL, $fieldName =
"message") {
202 $this->_instanceViewer->addField($fieldName);
203 $count = $this->_instanceViewer->visiblePropertiesCount();
215 $this->_instanceViewer->insertField($index, $field, $key);
221 if ($index !==
false) {
222 $this->_instanceViewer->insertInField($index, $field, $key);
238 if ($index !==
false) {
239 $this->_instanceViewer->setValueFunction($index, $callback);
245 $this->_instanceViewer->setIdentifierFunction($callback);
254 if (isset($this->_toolbar) ===
false) {
255 $this->_toolbar =
new HtmlMenu(
"toolbar-" . $this->identifier);
271 if ($element->getIdentifier() ===
"") {
272 $element->setIdentifier(
"tb-item-" . $this->identifier .
"-" . $tb->count());
275 if (isset($callback)) {
276 if (\is_callable($callback)) {
280 return $tb->addItem($element);
293 if (isset($icon) && method_exists($result,
"addIcon"))
294 $result->addIcon($icon);
306 if (JArray::isAssociative($items)) {
307 foreach ($items as $icon => $item) {
311 foreach ($items as $item) {
328 if (\is_string($value)) {
329 $dd =
new HtmlDropdown(
"dropdown-" . $this->identifier .
"-" . $value, $value, $items);
343 $bt =
new HtmlButton(
"bt-" . $caption, $caption, $cssStyle);
370 $bt->addIcon($icon, $before, $labeled);
376 $this->
_buttonAsSubmit($button,
"click", $url, $responseElement, $parameters);
388 $this->_instanceViewer->setCaptionCallback($captionCallback);
411 $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
420 return $this->_instanceViewer->getDefaultValueFunction();
429 return "$('#" . $this->identifier .
" .ui.input,#" . $this->identifier .
" .ui.dropdown,#" . $this->identifier .
" .ui.checkbox').toggleClass('disabled'," . $disable .
");";
440 $bt =
new HtmlButton($this->identifier .
"-editBtn", $caption);
442 $bt->setActive($this->_edition);
443 $bt->onClick($this->
jsDisabled(Javascript::prep_value(
"!$(event.target).hasClass('active')")));
458 if (! isset($this->_form)) {
459 $this->_form =
new HtmlForm(
"frm-" . $this->identifier);
467 if (isset($this->_form)) {
474 foreach ($fields as $field) {
475 $this->_form->addField($field);
477 return $this->_form->run($js);
481 if (isset($this->_form)) {
483 if (\
sizeof($this->_form->getValidationParams()) > 0)
484 $noValidate =
"novalidate";
485 $this->
wrapContent(
"<form class='" . $this->_form->getProperty(
'class') .
"' id='frm-" . $this->identifier .
"' name='frm-" . $this->identifier .
"' " . $noValidate .
">",
"</form>");
498 $this->
getForm()->setValidationParams($_validationParams);
503 return $this->_instanceViewer->moveFieldTo($from, $to);
509 return $this->_instanceViewer->swapFields($index1, $index2);
514 if ($index !==
false) {
515 $this->_instanceViewer->removeField($index);
521 $modal =
new HtmlModal(
"modal-" . $this->identifier, $header);
522 $modal->setContent($this);
523 if (isset($this->_form)) {
524 $this->_form->onSuccess($modal->jsHide());
wrapContent($before, $after="")
getContentInstances($class)