Exemplo n.º 1
0
 public static function getOnClick($action, $name = '', $target = '')
 {
     $upper = strtoupper($action);
     if (!MAction::isAction($upper)) {
         $action = '>' . $action;
     }
     if ($upper == 'SUBMIT') {
         $onclick = MUI::doPostBack($name);
     } elseif ($upper == 'PRINT') {
         $onclick = MUI::doPrintForm();
     } elseif ($upper == 'REPORT') {
         if ($name != '') {
             $onclick = MUI::doPrintFile($name);
         }
     } elseif ($upper == 'FILE') {
         if ($name != '') {
             $onclick = MUI::doPostBack($name);
         }
     } elseif ($upper == 'PDF') {
         if ($name != '') {
             $onclick = MUI::doShowPDF($name);
         }
     } elseif ($upper == 'POST') {
         $onclick = MUI::doPostBack($name);
     } elseif (substr($upper, 0, 4) == 'OPEN') {
         if (strpos($action, ':') !== false) {
             list($action, $id) = explode(':', $action);
             $onclick = MUI::openWindow($id);
         }
     } elseif (substr($upper, 0, 5) == 'CLOSE') {
         if (strpos($action, ';') !== false) {
             list($close, $postAction) = explode(';', $action);
             $onclick = MUI::closeWindow($id) . ';' . MAction::getOnClick($postAction);
         } else {
             $onclick = MUI::closeWindow($id);
         }
     } elseif (substr($upper, 0, 6) == 'PROMPT') {
         if (strpos($action, ':') !== false) {
             list($action, $id) = explode(':', $action);
             $onclick = MUI::doPrompt($id);
         }
     } elseif (substr($upper, 0, 4) == 'HELP') {
         if (strpos($action, ':') !== false) {
             list($action, $id) = explode(':', $action);
             $onclick = MUI::showHelp($id);
         }
     } elseif ($action[0] == '+') {
         $url = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doWindow($url, $target);
     } elseif ($action[0] == '^') {
         $url = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doDialog($name, $url);
     } elseif ($upper == 'NONE') {
         return "";
     } elseif (substr($upper, 0, 4) == 'HTTP') {
         $onclick = MUI::doGet($action);
     } elseif (substr($upper, 0, 11) == 'JAVASCRIPT:') {
         $onclick = $action;
     } elseif ($action[0] == '!') {
         $onclick = substr($action, 1);
     } elseif ($action[0] == ':') {
         if (strpos($action, '|') !== false) {
             list($action, $name, $updateElement) = explode('|', $action);
         }
         $url = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doAjaxText($url, $name, $updateElement);
     } elseif ($action[0] == '=') {
         $url = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doRedirect($url);
     } elseif ($action[0] == '@') {
         $goto = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doLinkButton($goto, $name);
     } elseif ($action[0] == '>') {
         if (strpos($action, '|') !== false) {
             list($action, $target) = explode('|', $action);
         }
         $goto = MAction::getHrefAction(substr($action, 1));
         $onclick = MUI::doGet($goto, $target);
     } else {
         $onclick = $action;
     }
     return $onclick;
 }
Exemplo n.º 2
0
 public function generateInner()
 {
     $id = $this->getId();
     $value = $this->getValue();
     $numFields = count($this->fields);
     // fields
     $fields = '';
     $n = 1;
     $ref = '';
     $totalWidth = 0;
     foreach ($this->fields as $f) {
         $ref .= ($ref ? ',' : '') . $f->getName();
         $f->form = $this->form;
         $f->setLabel(htmlspecialchars($f->label));
         //$f->formMode = 2;
         $fields[] = $f;
         $totalWidth += $width[] = $f->width ?: '15';
         $n++;
     }
     $btnInsert = new MButton("{$id}_btnInsert", 'Inserir', "!{$id}_ajaxInsert();");
     $actionInsert = MAction::getHref($this->actionInsert);
     $this->page->addJsCode("{$id}_ajaxInsert = function() {  manager.doAjaxText('{$actionInsert}', '{$id}_divGrid', '{$id}_btnInsert') };");
     $fields[] = $btnInsert;
     $field = new MContentPane("{$id}_divGrid");
     $select = $field;
     $btnDelete = new MButton("{$id}_btnDelete", 'Remover selecionados', "!{$id}_ajaxDelete();");
     $actionDelete = MAction::getHref($this->actionDelete);
     $this->page->addJsCode("{$id}_ajaxDelete = function() {  manager.doAjaxText('{$actionDelete}', '{$id}_divGrid', '{$id}_btnDelete') };");
     // layout
     $t = array();
     $array[] = new MDiv('', new MHContainer("{$id}_containerFields", $fields));
     $array[] = new MDiv('', $select);
     $array[] = new MDiv('', $btnDelete);
     $container = new MVContainer('', $array);
     $group = new MBaseGroup('', $this->getCaption(), $container);
     if (strpos($this->actionGrid, Manager::getBaseURL()) !== false) {
         $actionGrid = $this->actionGrid;
     } else {
         $actionGrid = MAction::getHref($this->actionGrid . ($value ? '/' . $value : ''));
     }
     $this->page->onLoad(MUI::set("{$id}_divGrid", 'href', $actionGrid) . ';');
     $div = new MDiv($this->name, $group);
     $div->attributes = clone $this->attributes;
     $div->style = clone $this->style;
     $div->setClass('mGridField');
     $this->inner = array($div);
     return $this->inner;
 }
Exemplo n.º 3
0
 public function addEvent($event, $handler, $preventDefault = true, $dijit = false)
 {
     if ($handler[0] == ':') {
         $url = Manager::getCurrentURL() . '?event=' . substr($handler, 1);
         $handler = MUI::doAjaxText($url, $this->id);
     }
     $isDijit = false;
     //$this->getIsDijit() || $dijit;
     if ($event == 'onClick') {
         $event = 'click';
     } elseif ($event == 'onChange') {
         $event = 'change';
     }
     $this->event[$event][] = array('handler' => $handler, 'prevent' => $preventDefault, 'dijit' => $isDijit);
 }
Exemplo n.º 4
0
 public function generateInner()
 {
     $isFormBase = count($this->actions) || $this->addMenu;
     if ($this->property->base) {
         // this is a FormAction
         if ($this->property->generateBase) {
             $formBase = $this->property->base;
             $path = dirname($this->view->viewFile);
             $base = $this->instance($formBase, $path);
             //new $formBase();
             $base->load();
             $inline = $this->property->inline && !$isFormBase;
             if ($inline) {
                 if (count($base->actions) && !$base->menuAdded) {
                     $this->actions = $base->actions;
                     $title = $this->getTitle();
                     $key = array_search($title, $this->actions);
                     if ($key !== false) {
                         $label = new MLabel($title);
                         $label->setClass('mBoxPaneTitle');
                         $this->actions[$key] = $label;
                     }
                     $this->addMenuBar();
                 }
                 $this->setTitle($base->getTitle());
                 $this->property->base = $base->getBase();
                 $this->property->inline = $base->getInline();
                 $this->property->generateBase = $base->getGenerateBase();
                 $this->inner = $this;
                 return;
             } else {
                 $this->property->generateBase = false;
                 $base->addForm($this);
                 $this->concreteForm = $base;
                 $this->inner = $this->render();
                 return;
             }
         } else {
             if (count($this->actions) && !$this->menuAdded) {
                 $this->addMenuBar();
             }
         }
     } else {
         if (count($this->actions) && !$this->menuAdded) {
             $this->addMenuBar();
         }
     }
     if ($this->page->isWindow()) {
         $this->setClose($this->ui->closeWindow());
     }
     if ($this->property->close == 'modal') {
         if ($this->property->modal) {
             $this->page->onLoad(MUI::closeWindow(''));
         }
         $this->property->close = null;
     }
     parent::generateInner();
     $submit = $this->inner['submit'];
     $body = $this->inner['body'];
     $buttons = $this->inner['buttons'];
     $footer = $this->generateFooter();
     if ($this->property->outerBox) {
         $this->formBox->setCaption($this->property->title);
         if ($this->property->close) {
             $this->formBox->setClose($this->property->close);
         }
         $this->formBox->setControls(array($this->header, $body, $this->footer));
         if ($buttons) {
             $this->formBox->addAction($buttons);
         }
         $this->setClass("mForm");
         if (!is_null($this->align)) {
             $this->addStyle('text-align', $this->align);
         }
     } else {
         $this->formBox = new MContainer($this->getId(), $body);
         if ($buttons) {
             $this->formBox->addControl($buttons);
         }
         if (!is_null($this->align)) {
             $this->formBox->addStyle('text-align', $this->align);
         }
     }
     $form = new MConcreteForm($this->tagId);
     $form->addContent($this->formBox);
     $form->setAction($this->action);
     $form->setEnctype($this->enctype);
     $form->setMethod($this->method);
     if ($this->enterSubmit) {
         $button = $this->buttons[$this->enterSubmit];
         $event = MAction::getOnClick($button->getAction(), $this->enterSubmit);
         $form->addEvent('keypress', "if (event.keyCode==dojo.keys.ENTER) { event.preventDefault();{$event};}", false);
     }
     if ($this->enterAction) {
         $event = MAction::getOnClick($this->enterAction, $this->tagId);
         $form->addEvent('keypress', "if (event.keyCode==dojo.keys.ENTER) { event.preventDefault();{$event};}", false);
     }
     $this->page->onSubmit($submit, $this->tagId);
     $this->concreteForm = $form;
     $this->inner = $this->render();
 }