Пример #1
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
     if (strstr($this->size, '%') !== FALSE) {
         $this->setProperty('style', "width:{$this->size};", FALSE);
         //aggregate style info
     } else {
         $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(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('onBlur', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)");
         }
     } else {
         // make the field read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // show the tag
     $this->tag->show();
 }
Пример #2
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->id = $this->id;
     $this->tag->name = 'file_' . $this->name . '[]';
     // tag name
     $this->tag->receiver = $this->name;
     // tag name
     $this->tag->value = $this->value;
     // tag value
     $this->tag->type = 'file';
     // input type
     $this->tag->style = "width:{$this->size}px;height:{$this->height}px";
     // size
     $this->tag->multiple = '1';
     $complete_action = "'undefined'";
     // verify if the widget is editable
     if (parent::getEditable()) {
         if (isset($this->completeAction)) {
             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->completeAction->serialize(FALSE);
             $complete_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', this); }";
         }
     } else {
         // make the field read-only
         $this->tag->readonly = "1";
         $this->tag->type = 'text';
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     $id_div = mt_rand(1000000000, 1999999999);
     $div = new TElement('div');
     $div->style = "width:{$this->size}px;";
     $div->id = 'div_file_' . $id_div;
     $divParciais = new TElement('div');
     $divParciais->style = 'width:100%;';
     $divParciais->id = 'div_parciais_' . $id_div;
     foreach ((array) $this->value as $val) {
         $hdFileName = new THidden($this->name . '[]');
         $hdFileName->setValue($val);
         $div->add($hdFileName);
     }
     $div->add($this->tag);
     $div->add($divParciais);
     $div->show();
     $action = "engine.php?class={$this->uploaderClass}";
     TScript::create(" tmultifile_start( '{$this->tag->id}', '{$action}', '{$divParciais->id}', {$complete_action});");
 }
Пример #3
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);
 }
Пример #4
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 (is_string($this->size)) {
         $this->setProperty('style', "width:{$this->size}", FALSE);
     } else {
         $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(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) {
             $this->tag->onKeyPress = "return tentry_mask(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);
         TScript::create(" tentry_autocomplete( '{$this->name}', {$options}); ");
     }
     if ($this->numericMask) {
         TScript::create("tentry_numeric_mask( '{$this->name}', {$this->decimals}, '{$this->decimalsSeparator}', '{$this->thousandSeparator}'); ");
     }
 }
Пример #5
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()) {
         $exit_action = 'function() {}';
         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);
             $exit_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name}) }";
         }
         TScript::create(" tspinner_start( '#{$this->id}', '{$this->value}', '{$this->min}', '{$this->max}', '{$this->step}', {$exit_action}); ");
     } 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();
 }
Пример #6
0
 /**
  * Show the widget
  */
 public function show()
 {
     $this->tag->name = $this->name;
     // tag name
     if ($this->size) {
         $this->setProperty('style', "width:{$this->size}px; resize:none", FALSE);
         //aggregate style info
     }
     if ($this->height) {
         $this->setProperty('style', "height:{$this->height}px; resize:none", 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(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('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n                                          __adianti_ajax_lookup('{$string_action}&'+serialform, this)");
     }
     // add the content to the textarea
     $this->tag->add(htmlspecialchars($this->value));
     // show the tag
     $this->tag->show();
 }
Пример #7
0
 /**
  * Shows the widget
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     if ($this->id) {
         $this->tag->id = $this->id;
     }
     if (strstr($this->size, '%') !== FALSE) {
         $this->setProperty('style', "width:{$this->size};", false);
         //aggregate style info
     } else {
         $this->setProperty('style', "width:{$this->size}px;", false);
         //aggregate style info
     }
     if ($this->defaultOption !== FALSE) {
         // creates an empty <option> tag
         $option = new TElement('option');
         $option->add($this->defaultOption);
         $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(AdiantiCoreTranslator::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('changeaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)");
             $this->setProperty('onChange', $this->getProperty('changeaction'));
         }
     } else {
         // make the widget read-only
         //$this->tag-> disabled   = "1"; // the value don't post
         $this->tag->{'onclick'} = "return false;";
         $this->tag->{'style'} .= ';pointer-events:none';
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }
Пример #8
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(AdiantiCoreTranslator::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())) {
                 if (is_object($callback[0])) {
                     $rc = new ReflectionClass($callback[0]);
                     $classname = $rc->getShortName();
                 } else {
                     $classname = $callback[0];
                 }
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if (in_array($classname, array('TStandardSeek2'))) {
                     $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'));
                     $ajaxAction->setParameter('criteria', $this->action->getParameter('criteria'));
                     $ajaxAction->setParameter('display_field2', $this->action->getParameter('display_field2'));
                 } else {
                     if ($actionParameters = $this->action->getParameters()) {
                         foreach ($actionParameters as $key => $value) {
                             $ajaxAction->setParameter($key, $value);
                         }
                     }
                 }
                 $ajaxAction->setParameter('form_name', $this->formName);
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('seekaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name})");
                     $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE);
                 }
             }
             $this->action->setParameter('form_name', $this->formName);
             $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 '&nbsp;';
             $this->auxiliar->show();
         }
     } else {
         parent::show();
     }
 }
Пример #9
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         // iterate the RadioButton options
         $i = 0;
         foreach ($this->items as $index => $label) {
             $button = $this->buttons[$index];
             $button->setName($this->name);
             // check if contains any value
             if ($this->value == $index) {
                 // mark as checked
                 $button->setProperty('checked', '1');
             }
             // create the label for the button
             $obj = $this->labels[$index];
             $obj->{'class'} = 'tcheckgroup_label';
             if ($this->getSize() and isset($this->breakItems)) {
                 $obj->setSize($this->getSize());
             }
             // check whether the widget is non-editable
             if (parent::getEditable()) {
                 if (isset($this->changeAction)) {
                     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->changeAction->serialize(FALSE);
                     $button->setProperty('onChange', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)");
                 }
             } else {
                 $button->setEditable(FALSE);
                 $obj->setFontColor('gray');
             }
             $obj->add($button);
             $obj->show();
             $i++;
             if ($this->layout == 'vertical' or $this->breakItems == $i) {
                 // shows a line break
                 $br = new TElement('br');
                 $br->show();
                 $i = 0;
             }
             echo "\n";
         }
     }
 }
Пример #10
0
 /**
  * Shows the widget
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     $this->tag->id = $this->id;
     // tag name
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     $multiple = $this->maxSize == 1 ? 'false' : 'true';
     $load_items = 'undefined';
     if ($this->initialItems) {
         $new_items = array();
         foreach ($this->initialItems as $key => $item) {
             $new_item = array('id' => $key, 'text' => $item);
             $new_items[] = $new_item;
         }
         if ($multiple == 'true') {
             $load_items = json_encode($new_items);
         } else {
             $load_items = json_encode($new_item);
         }
     }
     $orderColumn = isset($this->orderColumn) ? $this->orderColumn : $this->column;
     $criteria = '';
     if ($this->criteria) {
         $criteria = str_replace(array('+', '/'), array('-', '_'), base64_encode(serialize($this->criteria)));
     }
     $hash = md5("{$this->seed}{$this->database}{$this->key}{$this->column}{$this->model}");
     $length = $this->minLength;
     $class = $this->service;
     $callback = array($class, 'onSearch');
     $method = $callback[1];
     $search_word = AdiantiCoreTranslator::translate('Search');
     $url = "engine.php?class={$class}&method={$method}&static=1&database={$this->database}&key={$this->key}&column={$this->column}&model={$this->model}&orderColumn={$orderColumn}&criteria={$criteria}&operator={$this->operator}&mask={$this->mask}";
     $change_action = 'function() {}';
     if (isset($this->changeAction)) {
         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->changeAction->serialize(FALSE);
         $change_action = "function() { serialform=tmultisearch_get_form_data('{$this->formName}', '{$this->name}');\n                                         __adianti_ajax_lookup('{$string_action}&'+serialform, this); }";
     }
     TScript::create(" tdbmultisearch_start( '{$this->id}', '{$length}', '{$this->maxSize}', '{$search_word}', {$multiple}, '{$url}', '{$this->size}px', '{$this->height}px', {$load_items}, '{$hash}', {$change_action} ); ");
     // shows the component
     $this->tag->show();
 }
Пример #11
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $this->tag->{'id'} = $this->id;
     if ($this->items) {
         $i = 1;
         // iterate the checkgroup options
         foreach ($this->items as $index => $label) {
             // control to reduce available options when they are present
             // in another connected list as a post value
             if ($this->connectedTo and is_array($this->connectedTo)) {
                 foreach ($this->connectedTo as $connectedList) {
                     if (isset($connectedList->items[$index]) and $connectedList->valueSet) {
                         continue 2;
                     }
                 }
             }
             // instantiates a new Item
             $item = new TElement('li');
             if ($this->itemIcon) {
                 $item->add($this->itemIcon);
             }
             $item->add(new TLabel($label));
             $item->{'class'} = 'tsortlist_item btn btn-default';
             $item->{'style'} = 'display:block;';
             $item->{'id'} = "tsortlist_{$this->name}_item_{$i}_li";
             $item->{'title'} = $this->tag->title;
             $input = new TElement('input');
             $input->{'id'} = "tsortlist_{$this->name}_item_{$i}_li_input";
             $input->{'type'} = 'hidden';
             $input->{'name'} = $this->name . '[]';
             $input->{'value'} = $index;
             $item->add($input);
             $this->tag->add($item);
             $i++;
         }
     }
     if (parent::getEditable()) {
         $change_action = 'function() {}';
         if (isset($this->changeAction)) {
             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->changeAction->serialize(FALSE);
             $change_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', this); }";
         }
         $connect = 'false';
         if ($this->connectedTo and is_array($this->connectedTo)) {
             foreach ($this->connectedTo as $connectedList) {
                 $connectIds[] = '#' . $connectedList->getId();
             }
             $connect = implode(', ', $connectIds);
         }
         TScript::create(" tsortlist_start( '#{$this->id}', '{$connect}', {$change_action} ) ");
     }
     $this->tag->show();
 }
Пример #12
0
 /**
  * Execute the exit action
  */
 public function onExecuteExitAction()
 {
     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->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);
     }
 }
Пример #13
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 AdiantiWidgetInterface) {
             $field->setValue(NULL);
         }
     }
 }
Пример #14
0
 /**
  * Shows the widget
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     $this->tag->id = $this->id;
     // tag name
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     $multiple = $this->maxSize == 1 ? 'false' : 'true';
     $load_items = 'undefined';
     if ($this->initialItems) {
         $new_items = array();
         foreach ($this->initialItems as $key => $item) {
             $new_item = array('id' => $key, 'text' => $item);
             $new_items[] = $new_item;
         }
         if ($multiple == 'true') {
             $load_items = json_encode($new_items);
         } else {
             $load_items = json_encode($new_item);
         }
     }
     $preitems_json = 'undefined';
     if ($this->items) {
         $preitems = array();
         foreach ($this->items as $key => $item) {
             $new_item = array('id' => $key, 'text' => $item);
             $preitems[] = $new_item;
         }
         $preitems_json = json_encode($preitems);
     }
     $search_word = AdiantiCoreTranslator::translate('Search');
     if ($this->editable) {
         $this->tag->show();
         $change_action = 'function() {}';
         if (isset($this->changeAction)) {
             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->changeAction->serialize(FALSE);
             $change_action = "function() { serialform=tmultisearch_get_form_data('{$this->formName}', '{$this->name}');\n                                             __adianti_ajax_lookup('{$string_action}&'+serialform, this); }";
         }
         TScript::create(" tmultisearch_start( '{$this->id}', '{$this->minLength}', '{$this->maxSize}', '{$search_word}', {$multiple}, {$preitems_json}, '{$this->size}px', '{$this->height}px', {$load_items}, {$change_action} ); ");
     } else {
         $this->tag->{'readonly'} = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->{'onmouseover'} = "style.cursor='default'";
         $this->tag->{'type'} = 'text';
         $this->tag->{'value'} = $this->encodeData($this->value);
         $this->tag->show();
     }
 }
Пример #15
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         // iterate the checkgroup options
         $i = 0;
         foreach ($this->items as $index => $label) {
             $button = $this->buttons[$index];
             // verify if the checkbutton is checked
             if (@in_array($index, $this->value)) {
                 $button->setValue($index);
                 // value=indexvalue (checked)
             }
             // create the label for the button
             $obj = $this->labels[$index];
             $obj->{'class'} = 'tcheckgroup_label';
             $obj->setTip($this->tag->title);
             if ($this->getSize() and isset($this->breakItems)) {
                 $obj->setSize($this->getSize());
             }
             // check whether the widget is non-editable
             if (parent::getEditable()) {
                 if (isset($this->changeAction)) {
                     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->changeAction->serialize(FALSE);
                     $button->setProperty('onChange', "serialform=(\$('#{$this->formName}').serialize());\n                                                          __adianti_ajax_lookup('{$string_action}&'+serialform, this)");
                 }
             } else {
                 $button->setEditable(FALSE);
                 $obj->setFontColor('gray');
             }
             $obj->add($button);
             $obj->show();
             $i++;
             if ($this->layout == 'vertical' or $this->breakItems == $i) {
                 // shows a line break
                 $br = new TElement('br');
                 $br->show();
                 $i = 0;
             }
             echo "\n";
         }
     }
 }