public function generateForm() { $this->property->action = $this->property->action ?: Manager::getCurrentURL(); \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST'); \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%"); $this->property->role = "form"; $fields = $buttons = $help = $tools = ""; $fields = $this->generateFields(); $buttons = $this->generateButtons(); $help = $this->generateHelp(); if ($this->tools != NULL) { mdump('has tools'); $tools = $this->generateTools(); } // menubar if ($this->property->menubar) { $menubar = PainterControl::generate($this->property->menubar); } // por default, o método de submissão é POST \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST"); if ($this->property->onsubmit) { PainterControl::getPage()->onSubmit($this->property->onsubmit, $this->property->id); } // se o form tem fields com validators, define onSubmit $validators = ''; if (count($this->property->toValidate)) { PainterControl::getPage()->onSubmit("\$('#{$this->property->id}').form('validate')", $this->property->id); $validators = implode(',', $this->property->bsValidator); } //mdump($fields); // obtem o codigo html via template $inner = PainterControl::fetch('painter/formdialog', $this, ['fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'tools' => $tools, 'validators' => $validators, 'menubar' => $menubar]); return $inner; }
private function getControlFromNode($fieldClass, $node) { if ($this->ignoreElement($node)) { return NULL; } if ($fieldClass == 'css' || $fieldClass == 'style') { $control = $this->handleNodeCSS($node); } elseif ($fieldClass == 'javascript') { $control = $this->handleNodeJavascript($node); } else { if ($this->painter->hasMethod($fieldClass)) { //$control = new $fieldClass(); $control = new MBaseControl($fieldClass); $control->tag = $fieldClass; } else { $control = new MBaseControl('mhtml'); $control->tag = $fieldClass; } $this->getPropertiesFromNode($control, $node); \Maestro\Utils\MUtil::setIfNull($control->property->name, $control->property->id); $this->handleChildren($control, $node); if ($attributes['base'] != '') { $file = $this->path . '/' . $attributes['base'] . '.xml'; $baseControls = $this->fetch($file, $this->context); $first = $baseControls[0]; $first->addControl($control); return $first; } } return $control; }
public function setName($name) { \Maestro\Utils\MUtil::setIfNull($this->property->id, $name); $this->property->name = $name; }
public static function mpanel($control) { $control->options->title = $control->property->title; if ($control->property->close != '') { $control->options->closable = true; // captura o evento 'onClose' para executar action definida em $control->close $action = addslashes(Action::parseAction($control->close)); $onClose = "function(e) {manager.doAction(\"{$action}\");}"; $control->options->onClose = (object) $onClose; } $inner = ""; if ($control->property->menubar) { $inner .= $control->property->menubar->generate(); } if ($control->hasControls()) { foreach ($control->controls as $child) { $inner .= $child->generate(); } } $tools = ''; if ($control->property->tools) { $control->property->tools->id = $control->property->id > '_tools'; $control->options->tools = "#{$control->tools->id}"; $tools = self::mdiv($control->property->tools); } MUtil::setIfNull($control->style->width, "100%"); $control->plugin = 'panel'; self::setPluginClass($control); //self::createJS($control); $attributes = self::getAttributes($control); return <<<EOT <div {$attributes}> {$inner} </div> {$tools} EOT; }
public function generate() { // panel $panel = new MBaseControl('mpanel'); $panel->property->title = $this->property->title; $panel->style->width = $this->style->width; $panel->property->close = $this->property->close; $panel->property->class = $this->property->class; //mdump('--'); //mdump($this->style->border); $panel->options->border = isset($this->style->border) ? $this->style->border : false; $panel->generate(); //gera o panel para obter todos os atributos // propriedades $this->property->action = $this->property->action ?: Manager::getCurrentURL(); \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST'); \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%"); $this->property->role = "form"; // define o layout com base na classe bootstrap do form \Maestro\Utils\MUtil::setIfNull($this->property->layout, "horizontal"); $this->setClass("form-{$this->property->layout}"); // neste tema o mform é constituído de 3 blocos principais: fields, buttons e help $fields = $buttons = $help = ""; if ($this->fields != NULL) { $fields = $this->generateFields(); } if ($this->buttons != NULL) { $buttons = $this->generateButtons(); } if ($this->help != NULL) { $help = $this->generateHelp(); } // toolbar if ($this->toolbar) { $this->toolbar->tag = 'header'; $this->toolbar->setClass('datagrid-toolbar'); $toolbar = $this->toolbar->generate(); } // menubar if ($this->property->menubar) { $menubar = $this->property->menubar->generate(); } // por default, o método de submissão é POST \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST"); if ($this->property->onsubmit) { $this->page->onSubmit($this->property->onsubmit, $this->property->id); } // se o form tem fields com validators, define onSubmit $validators = ''; if (count($this->property->toValidate)) { $this->page->onSubmit("\$('#{$this->property->id}').form('validate')", $this->id); $validators = implode(',', $this->property->bsValidator); } // obtem o codigo html via template $result = $this->painter->fetch('mform', $this, ['panel' => $panel, 'fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'validators' => $validators, 'menubar' => $menubar, 'toolbar' => $toolbar]); return $result; }