Exemple #1
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkColorButton();
     parent::add($this->widget);
     $this->setSize(200);
 }
Exemple #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
     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();
 }
Exemple #3
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->value = $this->value;
     // tag value
     $this->tag->type = 'file';
     // input type
     $this->tag->style = "width:{$this->size}px;height:{$this->height}px";
     // size
     $hdFileName = new THidden($this->name);
     $hdFileName->setValue($this->value);
     // verify if the widget is editable
     if (!parent::getEditable()) {
         // make the field read-only
         $this->tag->readonly = "1";
         $this->tag->type = 'text';
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     $div = new TElement('div');
     $div->style = "display:inline;width:100%;";
     $div->id = 'div_file_' . uniqid();
     $div->add($hdFileName);
     $div->add($this->tag);
     $div->show();
     $uploaderClass = 'AdiantiUploaderService';
     $action = "engine.php?class={$uploaderClass}";
     TScript::create("\n            \$(document).ready( function()\n            {\n                \$('#{$this->tag->id}').change( function()\n                {\n                    var tfile = new  TFileAjaxUpload('{$this->tag->id}','{$action}','{$div->id}');\n                    \n                    tfile.initFileAjaxUpload();\n                });\n            });");
 }
Exemple #4
0
 /**
  * Class Constructor
  * @param $name Name of the widget
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkFileChooserButton(AdiantiCoreTranslator::translate('Open'), GTK::FILE_CHOOSER_ACTION_OPEN);
     parent::add($this->widget);
     $this->setSize(200);
 }
 /**
  * Show the widget
  */
 public function show()
 {
     // check if the field is not editable
     if (parent::getEditable()) {
         $tag = new TElement('textarea');
         $tag->{'id'} = $this->id;
         $tag->{'class'} = 'thtmleditor';
         // CSS
         $tag->name = $this->name;
         // tag name
         $this->setProperty('style', "width:{$this->size}px", FALSE);
         //aggregate style info
         $this->tag->add($tag);
         if ($this->height) {
             $tag->style .= "height:{$this->height}px";
         }
         // add the content to the textarea
         $tag->add(htmlspecialchars($this->value));
         TScript::create(" thtmleditor_start( '{$tag->{'id'}}', '{$this->size}', '{$this->height}' ); ");
     } else {
         $this->tag->style = "width:{$this->size}px;";
         $this->tag->style .= "height:{$this->height}px;";
         $this->tag->style .= "background-color:#FFFFFF;";
         $this->tag->style .= "border: 1px solid #000000;";
         $this->tag->style .= "padding: 5px;";
         $this->tag->style .= "overflow: auto;";
         // add the content to the textarea
         $this->tag->add($this->value);
     }
     // show the tag
     $this->tag->show();
 }
Exemple #6
0
 /**
  * Define the widget's content
  * @param  $value  widget's content
  */
 public function setValue($value)
 {
     $value = str_replace('<br>', "\n", $value);
     $value = str_replace('&nbsp;', ' ', $value);
     $this->value = $value;
     parent::set_text($value);
     $this->show();
 }
 /**
  * Class Constructor
  * @param  $name Field Name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkEntry();
     parent::add($this->widget);
     $this->setSize(200);
     $this->widget->set_visibility(FALSE);
 }
Exemple #8
0
 /**
  * Class Constructor
  * @param $name Name of the widget
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkEntry();
     parent::add($this->widget);
     $this->setSize(200);
     $this->chars = array('-', '_', '.', '/', '\\', ':', '|', '(', ')', '[', ']', '{', '}');
     // Connecting 'changed' signal to check the typed chars.
     $this->handler = $this->widget->connect_after('changed', array($this, 'onChanged'));
 }
Exemple #9
0
 /**
  * Class Constructor
  * @param $name Widet's name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkScrolledWindow();
     $this->widget->set_size_request(200, -1);
     parent::add($this->widget);
     $this->textview = new GtkTextView();
     $this->textview->set_wrap_mode(Gtk::WRAP_WORD);
     $this->textbuffer = $this->textview->get_buffer();
     $this->widget->add($this->textview);
 }
Exemple #10
0
 /**
  * Class Constructor
  * @param  $name widget's name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = GtkComboBox::new_text();
     parent::add($this->widget);
     $this->defaultOption = '';
     // create the combo model
     $this->model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING);
     $this->widget->set_model($this->model);
     $this->setSize(200);
 }
Exemple #11
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});");
 }
 /**
  * Class Constructor
  * @param $name Name of the widget
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkHBox();
     parent::add($this->widget);
     $this->entry = new GtkEntry();
     $this->btn = new TButton('find');
     $this->btn->set_image(new TImage('lib/adianti/images/ico_find.png'));
     $this->btn->set_relief(Gtk::RELIEF_NONE);
     $this->useOutEvent = TRUE;
     $this->validations = array();
     $this->widget->pack_start($this->entry, false, false);
     $this->widget->pack_start($this->btn, false, false);
 }
 /**
  * Class Constructor
  * @param  $name Widget's name
  */
 public function __construct($name)
 {
     // executes the parent class constructor
     parent::__construct($name);
     $this->id = 'tmultisearch' . uniqid();
     $this->height = 100;
     $this->minLength = 5;
     $this->maxSize = 0;
     if (LANG !== 'en') {
         TPage::include_js('lib/adianti/include/tmultisearch/select2_locale_' . LANG . '.js');
     }
     // creates a <select> tag
     $this->tag = new TElement('input');
     $this->tag->{'type'} = 'hidden';
     $this->tag->{'component'} = 'multisearch';
 }
Exemple #14
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     $this->tag->value = $this->value;
     $this->tag->type = 'radio';
     $this->tag->{'class'} = '';
     // verify if the field is not editable
     if (!parent::getEditable()) {
         // 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';
     }
     // show the tag
     $this->tag->show();
 }
 /**
  * Class Constructor
  * @param  $name widget's name
  * @param  $text widget's name
  */
 public function __construct($name, $text_name)
 {
     parent::__construct($name);
     $this->widget = new GtkHBox();
     parent::add($this->widget);
     $this->text_name = $text_name;
     // create the combo model
     $this->model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING);
     $this->entry = new GtkEntry();
     $this->entry->set_size_request(50, 25);
     $this->entry->set_sensitive(FALSE);
     $this->combo = GtkComboBox::new_text();
     $this->combo->set_model($this->model);
     $this->combo->set_size_request(200, -1);
     $this->combo->connect_simple('changed', array($this, 'onComboChange'));
     $this->widget->pack_start($this->entry);
     $this->widget->pack_start($this->combo);
 }
Exemple #16
0
 /**
  * Class Constructor
  * @param  $name widget's name
  */
 function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkFrame();
     parent::add($this->widget);
     $this->container = new GtkVBox();
     $this->initialItems = array();
     $this->items = array();
     $targets = array(array('text/plain', 0, -1));
     $this->widget->connect('drag_data_received', array($this, 'onDataReceived'));
     $this->widget->drag_dest_set(Gtk::DEST_DEFAULT_ALL, $targets, Gdk::ACTION_COPY);
     $scroll = new GtkScrolledWindow();
     $scroll->set_border_width(4);
     $this->widget->add($scroll);
     $hbox = new GtkHBox();
     $scroll->add_with_viewport($hbox);
     $hbox->pack_start($this->container, TRUE, TRUE);
     $hbox->set_border_width(20);
     parent::show_all();
 }
Exemple #17
0
 /**
  * Class Constructor
  * @param  $name widget's name
  */
 function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkScrolledWindow();
     $this->widget->set_policy(GTK::POLICY_AUTOMATIC, GTK::POLICY_ALWAYS);
     parent::add($this->widget);
     $this->tree = new GtkTreeView();
     $this->tree->connect_simple('select-cursor-row', array($this, 'onPreExecuteExitAction'));
     $this->tree->connect_simple('button-press-event', array($this, 'onPreExecuteExitAction'));
     $this->model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING);
     $this->tree->set_model($this->model);
     $this->tree->set_headers_visible(FALSE);
     $this->tree->set_rubber_banding(TRUE);
     $this->tree->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
     $column = new GtkTreeViewColumn();
     $cell_renderer = new GtkCellRendererText();
     $column->pack_start($cell_renderer, true);
     $column->add_attribute($cell_renderer, 'text', 1);
     $this->tree->append_column($column);
     $this->widget->add($this->tree);
     parent::show_all();
 }
Exemple #18
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     // define the tag properties for the checkbutton
     $this->tag->name = $this->name;
     // tag name
     $this->tag->type = 'checkbox';
     // input type
     $this->tag->value = $this->indexValue;
     // value
     $this->tag->{'class'} = '';
     // compare current value with indexValue
     if ($this->indexValue == $this->value) {
         $this->tag->checked = '1';
     }
     // check whether the widget is non-editable
     if (!parent::getEditable()) {
         // 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';
     }
     // shows the tag
     $this->tag->show();
 }
Exemple #19
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();
 }
Exemple #20
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}'); ");
     }
 }
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     $wrapper = new TElement('div');
     $wrapper->{'mtf_name'} = $this->getName();
     // include the needed libraries and styles
     if ($this->fields) {
         $table = new TTable();
         $mandatories = array();
         // mandatory
         $fields = array();
         $i = 0;
         if ($this->orientation == 'horizontal') {
             $row_label = $table->addRow();
             $row_field = $table->addRow();
         }
         foreach ($this->fields as $name => $obj) {
             if ($this->orientation == 'vertical') {
                 $row = $table->addRow();
                 $row_label = $row;
                 $row_field = $row;
             }
             $label = new TLabel($obj->text);
             if ($obj->mandatory) {
                 $label->setFontColor('red');
             }
             $row_label->addCell($label);
             $row_field->addCell($obj->field);
             $mandatories[] = $obj->mandatory;
             $fields[] = $name;
             $post_fields[$name] = 1;
             $sizes[$name] = $obj->size;
             $obj->field->setName($this->name . '_' . $name);
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $aux_name = $obj->field->getTextName();
                 $aux_full_name = $this->name . '_' . $aux_name;
                 $mandatories[] = 0;
                 $obj->field->setTextName($aux_full_name);
                 $fields[] = $aux_name;
                 $post_fields[$aux_name] = 1;
                 // invert sizes
                 $sizes[$aux_name] = $obj->size;
                 $sizes[$name] = 20;
                 $i++;
             }
             $i++;
         }
         $wrapper->add($table);
     }
     // check whether the widget is non-editable
     if (parent::getEditable()) {
         // create three buttons to control the MultiField
         $add = new TButton("{$this->name}btnStore");
         $add->setLabel(AdiantiCoreTranslator::translate('Register'));
         $add->setImage('fa:angle-double-down');
         $add->addFunction("multifields['{$this->name}'].addRowFromFormFields()");
         $del = new TButton("{$this->name}btnDelete");
         $del->setLabel(AdiantiCoreTranslator::translate('Delete'));
         $del->setImage('fa:trash');
         $can = new TButton("{$this->name}btnCancel");
         $can->setLabel(AdiantiCoreTranslator::translate('Cancel'));
         $can->setImage('fa:times-circle');
         $hbox_buttons = new THBox();
         $hbox_buttons->{'style'} = 'margin-top:3px;margin-bottom:3px';
         $hbox_buttons->add($add);
         $hbox_buttons->add($del);
         $hbox_buttons->add($can);
         $wrapper->add($hbox_buttons);
     }
     // create the MultiField Panel
     $panel = new TElement('div');
     $panel->{'class'} = "multifieldDiv";
     $input = new THidden($this->name);
     $panel->add($input);
     // create the MultiField DataGrid Header
     $table = new TTable();
     $table->{'class'} = 'multifield';
     $table->{'id'} = "{$this->name}mfTable";
     $head = new TElement('thead');
     $table->add($head);
     $row = new TTableRow();
     $head->add($row);
     // fill the MultiField DataGrid
     if ($this->fields) {
         foreach ($this->fields as $obj) {
             $c = $obj->text;
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $cell = $row->addCell('ID');
                 $cell->{'width'} = '20px';
                 $cell->{'class'} = 'multifield_header';
             }
             $cell = $row->addCell($c);
             $cell->{'width'} = $obj->size . 'px';
             $cell->{'class'} = 'multifield_header';
         }
     }
     $body_height = $this->height - 34;
     $body = new TElement('tbody');
     $body->{'style'} = "height: {$body_height}px";
     $body->{'class'} = 'tmultifield_scrolling';
     $table->add($body);
     if ($this->objects) {
         foreach ($this->objects as $obj) {
             if (isset($obj->id)) {
                 $row = new TTableRow();
                 $row->dbId = $obj->id;
                 $body->add($row);
             } else {
                 $row = new TTableRow();
                 $body->add($row);
             }
             if ($fields) {
                 foreach ($fields as $name) {
                     $cellValue = is_null($obj->{$name}) ? '' : $obj->{$name};
                     $original = $cellValue;
                     if (is_array(json_decode($cellValue))) {
                         $content = json_decode($cellValue);
                         $rows = array();
                         foreach ($content as $_row) {
                             $rows[] = implode(':', array_values(get_object_vars($_row)));
                         }
                         $cellValue = implode(',', $rows);
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = htmlspecialchars($original);
                     } else {
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = $cellValue;
                     }
                     if (isset($sizes[$name])) {
                         $cell->style = 'width:' . $sizes[$name] . 'px;';
                     }
                 }
             }
         }
     }
     $panel->add($table);
     $wrapper->add($panel);
     $wrapper->show();
     $fields_json = json_encode($fields);
     $mandatories_json = json_encode($mandatories);
     TScript::create(" tmultifield_start( '{$this->name}', {$fields_json}, {$mandatories_json}, {$this->width},{$this->height} ) ");
 }
Exemple #22
0
 /**
  * Set the value
  */
 public function setValue($value)
 {
     parent::setValue((int) $value);
 }
Exemple #23
0
 /**
  * Show the widget
  */
 public function show()
 {
     $this->tag->{'id'} = $this->id;
     $this->tag->{'class'} = 'thtmleditor';
     // CSS
     $this->tag->name = $this->name;
     // tag name
     // add the content to the textarea
     $this->tag->add(htmlspecialchars($this->value));
     TScript::create(" thtmleditor_start( '{$this->tag->{'id'}}', '{$this->size}', '{$this->height}' ); ");
     // check if the field is not editable
     if (!parent::getEditable()) {
         TScript::create(" thtmleditor_disable_field('{$this->formName}', '{$this->name}'); ");
     }
     // show the tag
     $this->tag->show();
 }
Exemple #24
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();
 }
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     $wrapper = new TElement('div');
     $wrapper->{'mtf_name'} = $this->getName();
     // include the needed libraries and styles
     if ($this->fields) {
         $table = new TTable();
         $mandatory = array();
         // mandatory
         $fields = array();
         $i = 0;
         if ($this->orientation == 'horizontal') {
             $row_label = $table->addRow();
             $row_field = $table->addRow();
         }
         foreach ($this->fields as $name => $obj) {
             if ($this->orientation == 'vertical') {
                 $row = $table->addRow();
                 $row_label = $row;
                 $row_field = $row;
             }
             $label = new TLabel($obj->text);
             if ($obj->mandatory) {
                 $label->setFontColor('red');
             }
             $row_label->addCell($label);
             $row_field->addCell($obj->field);
             $mandatory[] = $obj->mandatory;
             $fields[] = $name;
             $post_fields[$name] = 1;
             $sizes[$name] = $obj->size;
             $obj->field->setName($this->name . '_' . $name);
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $aux_name = $obj->field->getTextName();
                 $aux_full_name = $this->name . '_' . $aux_name;
                 $mandatory[] = 0;
                 $obj->field->setTextName($aux_full_name);
                 $fields[] = $aux_name;
                 $post_fields[$aux_name] = 1;
                 // invert sizes
                 $sizes[$aux_name] = $obj->size;
                 $sizes[$name] = 20;
                 $i++;
             }
             $i++;
         }
         $wrapper->add($table);
     }
     // check whether the widget is non-editable
     if (parent::getEditable()) {
         // create three buttons to control the MultiField
         $add = new TButton("{$this->name}btnStore");
         $add->setLabel(AdiantiCoreTranslator::translate('Register'));
         //$add->setName("{$this->name}btnStore");
         $add->setImage('ico_save.png');
         $add->addFunction("mtf{$this->name}.addRowFromFormFields()");
         $del = new TButton("{$this->name}btnDelete");
         $del->setLabel(AdiantiCoreTranslator::translate('Delete'));
         $del->setImage('ico_delete.png');
         $can = new TButton("{$this->name}btnCancel");
         $can->setLabel(AdiantiCoreTranslator::translate('Cancel'));
         $can->setImage('ico_close.png');
         $hbox_buttons = new THBox();
         $hbox_buttons->{'style'} = 'margin-top:3px;margin-bottom:3px';
         $hbox_buttons->add($add);
         $hbox_buttons->add($del);
         $hbox_buttons->add($can);
         $wrapper->add($hbox_buttons);
     }
     // create the MultiField Panel
     $panel = new TElement('div');
     $panel->{'class'} = "multifieldDiv";
     $input = new THidden($this->name);
     $panel->add($input);
     // create the MultiField DataGrid Header
     $table = new TTable();
     $table->{'class'} = 'multifield';
     $table->{'id'} = "{$this->name}mfTable";
     $head = new TElement('thead');
     $table->add($head);
     $row = new TTableRow();
     $head->add($row);
     // fill the MultiField DataGrid
     if ($this->fields) {
         foreach ($this->fields as $obj) {
             $c = $obj->text;
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $cell = $row->addCell('ID');
                 $cell->{'width'} = '20px';
                 $cell->{'class'} = 'multifield_header';
             }
             $cell = $row->addCell($c);
             $cell->{'width'} = $obj->size . 'px';
             $cell->{'class'} = 'multifield_header';
         }
     }
     $body_height = $this->height - 34;
     $body = new TElement('tbody');
     $body->{'style'} = "height: {$body_height}px";
     $body->{'class'} = 'tmultifield_scrolling';
     $table->add($body);
     if ($this->objects) {
         foreach ($this->objects as $obj) {
             if (isset($obj->id)) {
                 $row = new TTableRow();
                 $row->dbId = $obj->id;
                 $body->add($row);
             } else {
                 $row = new TTableRow();
                 $body->add($row);
             }
             if ($fields) {
                 foreach ($fields as $name) {
                     $cellValue = is_null($obj->{$name}) ? '' : $obj->{$name};
                     $original = $cellValue;
                     if (is_array(json_decode($cellValue))) {
                         $content = json_decode($cellValue);
                         $rows = array();
                         foreach ($content as $_row) {
                             $rows[] = implode(':', array_values(get_object_vars($_row)));
                         }
                         $cellValue = implode(',', $rows);
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = htmlspecialchars($original);
                     } else {
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = $cellValue;
                     }
                     if (isset($sizes[$name])) {
                         $cell->style = 'width:' . $sizes[$name] . 'px;';
                     }
                 }
             }
         }
     }
     $panel->add($table);
     $wrapper->add($panel);
     $wrapper->show();
     echo '<script type="text/javascript">';
     echo "var mtf{$this->name};";
     echo "mtf{$this->name} = new MultiField('{$this->name}mfTable',{$this->width},{$this->height});\n";
     $s = implode("','", $fields);
     echo "mtf{$this->name}.formFieldsAlias = Array('{$s}');\n";
     $sfields = implode("','{$this->name}_", $fields);
     echo "mtf{$this->name}.formFieldsName = Array('{$this->name}_{$sfields}');\n";
     echo "mtf{$this->name}.formPostFields = Array();\n";
     if ($post_fields) {
         foreach ($post_fields as $col => $value) {
             echo "mtf{$this->name}.formPostFields['{$col}'] = '{$value}';\n";
         }
     }
     $mdr_array = implode(',', $mandatory);
     echo "mtf{$this->name}.formFieldsMandatory = [{$mdr_array}];\n";
     echo "mtf{$this->name}.mandatoryMessage = '" . AdiantiCoreTranslator::translate('The field ^1 is required') . "';\n";
     echo "mtf{$this->name}.storeButton  = document.getElementsByName('{$this->name}btnStore')[0];\n";
     echo "mtf{$this->name}.deleteButton = document.getElementsByName('{$this->name}btnDelete')[0];\n";
     echo "mtf{$this->name}.cancelButton = document.getElementsByName('{$this->name}btnCancel')[0];\n";
     echo "mtf{$this->name}.inputResult  = document.getElementsByName('{$this->name}')[0];\n";
     echo '</script>';
 }
 /**
  * Shows the widget
  */
 public function show()
 {
     $tag = new TEntry($this->name);
     $tag->setEditable(FALSE);
     $tag->setProperty('id', $this->name);
     $tag->setSize(40);
     $tag->setProperty('onchange', "aux = document.getElementsByName('{$this->text_name}'); aux[0].value = this.value;");
     $tag->show();
     // define the tag properties
     $this->tag->name = $this->text_name;
     $this->tag->onchange = "aux_entry = document.getElementById('{$this->name}'); aux_entry.value = this.value;";
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     $this->tag->auxiliar = 1;
     // creates an empty <option> tag
     $option = new TElement('option');
     $option->add('');
     $option->value = '0';
     // valor da TAG
     // add the option tag to the combo
     $this->tag->add($option);
     if ($this->items) {
         // iterate the combobox items
         foreach ($this->items as $chave => $item) {
             // 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) {
                 // mark as selected
                 $option->selected = 1;
             }
             // add the option to the combo
             $this->tag->add($option);
         }
     }
     // verify whether the widget is editable
     if (!parent::getEditable()) {
         // make the widget read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }
Exemple #27
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";
         }
     }
 }
Exemple #28
0
 /**
  * Clone the object
  */
 public function __clone()
 {
     parent::__clone();
     $this->embedStyle = clone $this->embedStyle;
 }
Exemple #29
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();
 }
Exemple #30
0
 /**
  * Define the name of the form to wich the button is attached
  * @param $name    A string containing the name of the form
  * @ignore-autocomplete on
  */
 public function setFormName($name)
 {
     parent::setFormName($name);
     $this->entry->setFormName($name);
 }