Example #1
0
 public function generate()
 {
     $div = new MDiv($this->id, ' ', 'mButtonIcon ' . $this->icon);
     $action = MAction::getOnClick($this->value, $this->id);
     $div->addEvent('click', $action);
     return $div->generate();
 }
Example #2
0
    public function generateInner()
    {
        $js = "!{$this->popupName}.start();";
        $text = $this->getText();
        if ($text == '' || !$text) {
            $button = new MButtonIcon($js);
            $button->setIcon('managerIconButtonNew');
        } else {
            if ($text == 'hidden') {
                $button = new MLabel('');
            } else {
                $button = new MButton('', $text, $js);
            }
        }
        $html = $button->generate();
        $action = MAction::getHref($this->action);
        $jsCode = <<<HERE
        {$this->popupName}.setContext({
             name    : '{$this->popupName}',
             action  : '{$action}',
             related : '{$this->related}',
             filter  : '{$this->filter}',
             field   : '{$this->name}'
        });
HERE;
        $this->page->addJsCode("{$this->popupName} = new Manager.FormPopup();");
        $this->page->addJsCode($jsCode);
        $this->inner = new MDiv('', $html, '');
    }
Example #3
0
 public function generate()
 {
     $onclick = MAction::getOnClick($this->action, $this->property->id);
     $this->addEvent('click', $onclick);
     $this->setContent($this->label);
     return parent::generate();
 }
Example #4
0
 public function generate()
 {
     $this->setId(uniqid());
     if ($this->useStore) {
     } else {
         $onclick = MAction::getOnClick($this->action, $this->getId());
         $this->addEvent('click', $onclick);
     }
     $this->setContent(MUtil::detectUTF8($this->label) ? $this->label : utf8_encode($this->label));
     return parent::generate();
 }
Example #5
0
 public static function getHref($href)
 {
     if ($href != '') {
         if ($href[0] == '#') {
             $href = Manager::getStaticURL(Manager::getApp(), substr($href, 1));
         } else {
             $href = MAction::getHrefAction($href);
         }
     }
     return $href;
 }
Example #6
0
    public function generate()
    {
        $id = $this->getId();
        $url = MAction::getHref($this->url);
        $onload = <<<HERE
var {$id} = manager.addWindow('{$id}');
manager.getWindow('{$id}').setHref('{$url}');

HERE;
        $this->page->addJsCode($onload);
        return '';
    }
Example #7
0
 public function generate()
 {
     $icon = new MImage('', '', 'managerIcon managerIconCursor managerIcon' . ucfirst($this->icon));
     if ($this->text) {
         $text = new MSpan('', $this->text, 'managerIconText managerIconCursor');
     }
     $div = new MDiv($this->id, array($icon, $text), 'mToolIcon');
     $action = MAction::getOnClick($this->action, $div->id);
     $div->addEvent('click', $action);
     if ($this->title) {
         $div->setHTMLTitle($this->title);
     }
     return $div->generate();
 }
Example #8
0
 public function generateAction()
 {
     $this->action = MAction::generate($this, $this->action);
 }
Example #9
0
 public static function generate($control, $action)
 {
     $isAction = MAction::isAction($action);
     if ($isAction) {
         if (!$control->hasEvent('onClick') && !$control->hasEvent('click')) {
             $control->addEvent('click', MAction::getOnClick($action, $control->getId(), $control->target));
         }
         return '';
     } else {
         return MAction::getHref($action);
     }
 }
Example #10
0
 public function setAction($action)
 {
     $action = MAction::getOnClick($action, $this->jsId);
     $action = str_replace("#0#", '" + item.id + "', $action);
     $this->selectEvent .= "console.log(item);" . $action . ";\n";
 }
Example #11
0
 public function generateAction()
 {
     if (!MAction::isAction($this->action)) {
         $this->setAction('+' . $this->action);
     }
 }
Example #12
0
 public function generate()
 {
     $internalForm = false;
     if (!is_array($this->message)) {
         $this->message = array($this->message);
     }
     $this->box = new MBox($this->caption, $this->close, '');
     $type = ucfirst($this->promptType);
     $m = new MUnorderedList($this->id . 'Message', $this->message);
     $m->type = 'none';
     $textBox = new MDiv($this->id . 'BoxText', $m, "text");
     $iconBox = new MDiv($this->id . 'BoxIcon', '', "icon icon{$type}");
     $imageTextBox = new MHContainer('', array($iconBox, $textBox));
     $imageTextBox->setClass('mPromptBox');
     $this->box->setControls($imageTextBox);
     if (!$this->form instanceof MBaseForm) {
         $this->form = new MSimpleForm();
         $this->controls[0] = $this->form;
         $internalForm = true;
     }
     if ($this->buttons) {
         foreach ($this->buttons as $button) {
             list($label, $action, $event) = $button;
             $name = $this->name . trim($label);
             $spanLabel = new MDiv('', $label, 'button');
             $b = new MButton($name, $spanLabel->generate());
             $onclick = "manager.byId(\"{$this->id}\").hide();" . ($action ? MAction::getOnClick($action, $this->form->getTagId()) : '');
             $b->addEvent('click', $onclick, true, false);
             $this->box->addAction($b);
         }
     }
     $this->box->setExtendClass("title title{$type}");
     $this->controls[1] = new MDiv("{$this->id}Box", $this->box, "mPrompt");
     $prompt = new MDiv("{$this->id}Pane", $this->controls);
     if (($this->form instanceof MBaseForm and !$internalForm) || !$this->page->isPostBack()) {
         $prompt = new MDiv($this->id, $prompt, '', $this->getStyle());
         $prompt->addStyle('display', 'none');
         $prompt->setDojoType('Manager.DialogSimple');
     }
     return $prompt->generate();
 }
Example #13
0
 public function setClose($action = '')
 {
     $this->close = '!' . ($action ? MAction::getOnClick($action) : '') . "manager.byId('{$this->id}Help').hide();";
 }
Example #14
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;
 }
Example #15
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();
 }
Example #16
0
    public function generateInner()
    {
        $this->label = $this->label ? '&nbsp;' : '';
        if (!$this->readonly) {
            $button = new MButtonFind("!{$this->lookupName}.start();");
            $action = MAction::getHref($this->action);
            $jsCode = <<<HERE
        {$this->lookupName}.setContext({
             name    : '{$this->lookupName}',
             action  : '{$action}',
             related : '{$this->related}',
             filter  : '{$this->filter}',
             form    : '{$this->getFormId()}',
             field   : '{$this->name}',
             autocomplete : '{$this->autocomplete}'
        });
HERE;
            $this->page->addJsCode("{$this->lookupName} = new Manager.Lookup();");
            $this->page->addJsCode($jsCode);
        } else {
            $button = new MButtonFind('!return false;');
        }
        //        $content[] = $button->generate();
        //        $html = $this->painter->generateToString($content);
        //        $this->inner = new MDiv('', $html, '');
        $this->inner = $button;
    }
Example #17
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) {
         $fieldList .= ($fieldList ? ',' : '') . $f->getId();
         $f->form = $this->form;
         $f->setLabel(htmlspecialchars($f->label));
         //$f->formMode = 2;
         $fields[] = $f;
         $totalWidth += $width[] = $f->property->size ?: '15';
         $n++;
     }
     $btnInsert = new MButton("{$id}_btnInsert", 'Inserir', "!{$id}.insert();");
     //$fields[] = $btnInsert;
     $divGrid = new MContentPane("{$id}_divGrid");
     $btnDelete = new MButton("{$id}_btnDelete", 'Remover', "!{$id}.delete();");
     //$fields[] = $btnDelete;
     // layout
     $t = array();
     $array[] = new MHiddenField("{$id}_data");
     $array[] = new MDiv('', new MHContainer("{$id}_containerFields", $fields));
     $array[] = new MDiv('', $divGrid);
     $container = new MVContainer('', $array);
     $group = new MBaseGroup('', $this->getCaption(), $container);
     $actionGrid = MAction::getHref($this->actionGrid . '/' . $value);
     $div = new MDiv($this->name, $group, 'mGridField');
     $this->inner = array($div);
     $this->page->addDojoRequire("manager.GridInput");
     $this->page->addJsCode("var {$id} = Manager.GridInput('{$id}','{$fieldList}','{$actionGrid}');");
     $this->page->onLoad("{$id}.loadData({$this->data});");
     return $this->inner;
 }