예제 #1
0
 /**
  * Show the widget
  */
 public function show()
 {
     $this->tag->name = $this->name;
     // tag name
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     if ($this->height) {
         $this->setProperty('style', "height:{$this->height}px", FALSE);
         //aggregate style info
     }
     // check if the field is not editable
     if (!parent::getEditable()) {
         // make the widget read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     if (isset($this->exitAction)) {
         if (!TForm::getFormByName($this->formName) instanceof TForm) {
             throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
         }
         $string_action = $this->exitAction->serialize(FALSE);
         $this->setProperty('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n                                          ajaxLookup('{$string_action}&'+serialform, this)");
     }
     // add the content to the textarea
     $this->tag->add(htmlspecialchars($this->value));
     // show the tag
     $this->tag->show();
 }
예제 #2
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     $this->tag->value = $this->value;
     // tag value
     $this->tag->type = 'password';
     // input type
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     // verify if the field is not editable
     if (parent::getEditable()) {
         if (isset($this->exitAction)) {
             if (!TForm::getFormByName($this->formName) instanceof TForm) {
                 throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
             }
             $string_action = $this->exitAction->serialize(FALSE);
             $this->setProperty('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n                                              ajaxLookup('{$string_action}&'+serialform, this)");
         }
     } else {
         // make the field read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // show the tag
     $this->tag->show();
 }
예제 #3
0
 /**
  * Execute the exit action
  */
 public function onExecuteExitAction()
 {
     if (!TForm::getFormByName($this->formName) instanceof TForm) {
         throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->wname, 'TForm::setFields()'));
     }
     if (isset($this->exitAction) and $this->exitAction instanceof TAction) {
         $callback = $this->exitAction->getAction();
         $param = (array) TForm::retrieveData($this->formName);
         call_user_func($callback, $param);
     }
 }
예제 #4
0
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $form = TForm::getFormByName($form_name);
     if ($form instanceof TForm) {
         $field = $form->getField($field);
         if ($field instanceof IWidget) {
             $field->model->clear();
         }
     }
 }
예제 #5
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         // iterate the RadioButton options
         foreach ($this->items as $index => $label) {
             $button = new TRadioButton($this->name);
             $button->setTip($this->tag->title);
             $button->setValue($index);
             // check if contains any value
             if ($this->value == $index) {
                 // mark as checked
                 $button->setProperty('checked', '1');
             }
             // check whether the widget is non-editable
             if (parent::getEditable()) {
                 if (isset($this->changeAction)) {
                     if (!TForm::getFormByName($this->formName) instanceof TForm) {
                         throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
                     }
                     $string_action = $this->changeAction->serialize(FALSE);
                     $button->setProperty('onChange', "serialform=(\$('#{$this->formName}').serialize());\n                                                          ajaxLookup('{$string_action}&'+serialform, this)");
                 }
             } else {
                 $button->setEditable(FALSE);
             }
             // create the label for the button
             $obj = new TLabel($label);
             $obj->add($button);
             $obj->show();
             if ($this->layout == 'vertical') {
                 // shows a line break
                 $br = new TElement('br');
                 $br->show();
             }
             echo "\n";
         }
     }
 }
예제 #6
0
 /**
  * Show the widget
  */
 public function show()
 {
     // check if it's not editable
     if (parent::getEditable()) {
         if (!TForm::getFormByName($this->formName) instanceof TForm) {
             throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
         }
         $serialized_action = '';
         if ($this->action) {
             // get the action class name
             if (is_array($callback = $this->action->getAction())) {
                 $classname = is_object($callback[0]) ? get_class($callback[0]) : $callback[0];
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if ($classname == 'TStandardSeek') {
                     $ajaxAction->setParameter('parent', $this->action->getParameter('parent'));
                     $ajaxAction->setParameter('database', $this->action->getParameter('database'));
                     $ajaxAction->setParameter('model', $this->action->getParameter('model'));
                     $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field'));
                     $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key'));
                     $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field'));
                 }
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('seekaction', "serialform=(\$('#{$this->formName}').serialize());\n                                                         ajaxLookup('{$string_action}&'+serialform, document.{$this->formName}.{$this->name})");
                     $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE);
                 }
             }
             $serialized_action = $this->action->serialize(FALSE);
         }
         parent::show();
         $this->button->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n                  __adianti_append_page('engine.php?{$serialized_action}&'+serialform)";
         $this->button->show();
         if ($this->auxiliar) {
             echo ' ';
             $this->auxiliar->show();
         }
     } else {
         parent::show();
     }
 }
예제 #7
0
 /**
  * Shows the widget
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     // creates an empty <option> tag
     $option = new TElement('option');
     $option->add('');
     $option->value = '';
     // tag value
     // add the option tag to the combo
     $this->tag->add($option);
     if ($this->items) {
         // iterate the combobox items
         foreach ($this->items as $chave => $item) {
             if (substr($chave, 0, 3) == '>>>') {
                 $optgroup = new TElement('optgroup');
                 $optgroup->label = $item;
                 // add the option to the combo
                 $this->tag->add($optgroup);
             } else {
                 // creates an <option> tag
                 $option = new TElement('option');
                 $option->value = $chave;
                 // define the index
                 $option->add($item);
                 // add the item label
                 // verify if this option is selected
                 if ($chave == $this->value and $this->value !== NULL) {
                     // mark as selected
                     $option->selected = 1;
                 }
                 if (isset($optgroup)) {
                     $optgroup->add($option);
                 } else {
                     $this->tag->add($option);
                 }
             }
         }
     }
     // verify whether the widget is editable
     if (parent::getEditable()) {
         if (isset($this->changeAction)) {
             if (!TForm::getFormByName($this->formName) instanceof TForm) {
                 throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
             }
             $string_action = $this->changeAction->serialize(FALSE);
             $this->setProperty('onChange', "serialform=(\$('#{$this->formName}').serialize());\n                                              ajaxLookup('{$string_action}&'+serialform, this)");
         }
     } else {
         // make the widget read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }
예제 #8
0
 /**
  * Reload combobox items after it is already shown
  * @param $formname form name (used in gtk version)
  * @param $name field name
  * @param $items array with items
  */
 public static function reload($formname, $name, $items)
 {
     $form = TForm::getFormByName($formname);
     $combo = $form->getField($name);
     $combo->clear();
     $combo->addItems($items);
 }
예제 #9
0
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $form = TForm::getFormByName($form_name);
     if ($form instanceof TForm) {
         $field = $form->getField($field);
         if ($field instanceof IWidget) {
             $field->setValue(array());
         }
     }
 }
예제 #10
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->mask) {
         TPage::include_js('lib/adianti/include/tentry/tentry.js');
     } else {
         if ($this->numericMask) {
             TPage::include_js('lib/adianti/include/tentry/jquery-imask-min.js');
         }
     }
     // define the tag properties
     $this->tag->name = $this->name;
     // TAG name
     $this->tag->value = $this->value;
     // TAG value
     $this->tag->type = 'text';
     // input type
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     if ($this->id) {
         $this->tag->id = $this->id;
     }
     // verify if the widget is non-editable
     if (parent::getEditable()) {
         if (isset($this->exitAction)) {
             if (!TForm::getFormByName($this->formName) instanceof TForm) {
                 throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
             }
             $string_action = $this->exitAction->serialize(FALSE);
             $this->setProperty('exitaction', "serialform=(\$('#{$this->formName}').serialize());\n                                                 ajaxLookup('{$string_action}&'+serialform, document.{$this->formName}.{$this->name})", FALSE);
             $this->setProperty('onBlur', $this->getProperty('exitaction'), FALSE);
         }
         if ($this->mask) {
             $this->tag->onKeyPress = "return entryMask(this,event,'{$this->mask}')";
         }
     } else {
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->onmouseover = "style.cursor='default'";
     }
     // shows the tag
     $this->tag->show();
     if (isset($this->completion)) {
         $options = json_encode($this->completion);
         $script = new TElement('script');
         $script->add("\$('input[name=\"{$this->name}\"]').autocomplete({source: {$options} });");
         $script->show();
     }
     if ($this->numericMask) {
         $script = new TElement('script');
         $script->add("\$('input[name=\"{$this->name}\"]').iMask({\n\t\t                        type : 'number',\n\t\t                        decDigits   : {$this->decimals},\n\t\t                        decSymbol   : '{$this->decimalsSeparator}',\n\t\t                        groupSymbol : '{$this->thousandSeparator}'\n\t                    });");
         $script->show();
     }
 }
예제 #11
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // TAG name
     $this->tag->value = $this->value;
     // TAG value
     $this->tag->type = 'text';
     // input type
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     if ($this->id) {
         $this->tag->{'id'} = $this->id;
     } else {
         $this->tag->{'id'} = $this->name . "PEntry";
     }
     // verify if the widget is non-editable
     if (parent::getEditable()) {
         if (isset($this->exitAction)) {
             if (!TForm::getFormByName($this->formName) instanceof TForm) {
                 throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
             }
             $string_action = $this->exitAction->serialize(FALSE);
             $this->setProperty('exitaction', "serialform=(\$('#{$this->formName}').serialize());\n                                                 __adianti_ajax_lookup('{$string_action}&'+serialform, document.{$this->formName}.{$this->name})", FALSE);
             $this->setProperty('onBlur', $this->getProperty('exitaction'), FALSE);
         }
         if ($this->mask) {
             $id = $this->tag->{'id'};
             TScript::create("pmask('{$id}','{$this->mask}')");
         }
     } else {
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->onmouseover = "style.cursor='default'";
     }
     // shows the tag
     $this->tag->show();
     if (isset($this->completion)) {
         $options = json_encode($this->completion);
         TScript::create(" tentry_autocomplete( '{$this->name}', {$options}); ");
     }
     if ($this->numericMask) {
         TScript::create("tentry_numeric_mask( '{$this->name}', {$this->decimals}, '{$this->decimalsSeparator}', '{$this->thousandSeparator}'); ");
     }
 }
예제 #12
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // TAG name
     $this->tag->value = $this->value;
     // TAG value
     $this->tag->type = 'text';
     // input type
     $this->tag->style = "width:{$this->size}px";
     // size
     if ($this->id) {
         $this->tag->id = $this->id;
     }
     // verify if the widget is non-editable
     if (parent::getEditable()) {
         $change_action = '';
         if (isset($this->exitAction)) {
             if (!TForm::getFormByName($this->formName) instanceof TForm) {
                 throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
             }
             $string_action = $this->exitAction->serialize(FALSE);
             $change_action = "serialform=(\$('#{$this->formName}').serialize());\n                                                  ajaxLookup('{$string_action}&'+serialform, this);";
         }
         $script = new TElement('script');
         $script->add(' $(function() {
                     $( "#' . $this->id . '" ).spinner({
                         step: ' . $this->step . ',
                         numberFormat: "n",
                         spin: function( event, ui ) {
                             ' . $change_action . '
                             if ( ui.value > ' . $this->max . ' ) {
                                 $( this ).spinner( "value", ' . $this->min . ' );
                                 return false;
                             } else if ( ui.value < ' . $this->min . ' ) {
                                 $( this ).spinner( "value", ' . $this->max . ' );
                                 return false;
                             }
                         }
                     });
                     });');
         $script->show();
     } else {
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->style = "width:{$this->size}px;" . "-moz-user-select:none;";
         $this->tag->onmouseover = "style.cursor='default'";
     }
     // shows the tag
     $this->tag->show();
 }