Exemple #1
1
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     $table = new TTable();
     $table->width = '100%';
     // creates the form
     $this->form = new TForm('form_User');
     $this->form->class = 'tform';
     $this->form->style = 'width: 450px;margin:auto; margin-top:120px;';
     // add the notebook inside the form
     $this->form->add($table);
     // create the form fields
     $login = new TEntry('prontuario');
     $password = new TPassword('senha');
     // define the sizes
     $login->setSize(320, 40);
     $password->setSize(320, 40);
     $login->style = 'height:35px; font-size:14px;float:left;border-bottom-left-radius: 0;border-top-left-radius: 0;';
     $password->style = 'height:35px;margin-bottom: 15px;font-size:14px;float:left;border-bottom-left-radius: 0;border-top-left-radius: 0;';
     $row = $table->addRow();
     $row->addCell(new TLabel('Login'))->colspan = 2;
     $row->class = 'tformtitle';
     $login->placeholder = 'Prontuário';
     $password->placeholder = 'Senha';
     $user = '******';
     $locker = '<span style="float:left;width:35px;margin-left:45px;height:35px;" class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>';
     $container1 = new TElement('div');
     $container1->add($user);
     $container1->add($login);
     $container2 = new TElement('div');
     $container2->add($locker);
     $container2->add($password);
     $row = $table->addRow();
     $row->addCell($container1)->colspan = 2;
     // add a row for the field password
     $row = $table->addRow();
     $row->addCell($container2)->colspan = 2;
     // create an action button (save)
     $save_button = new TButton('save');
     // define the button action
     $save_button->setAction(new TAction(array($this, 'onLogin')), _t('Log in'));
     $save_button->class = 'btn btn-success btn-defualt';
     $save_button->style = 'margin-left:32px;width:355px;height:40px;border-radius:6px;font-size:18px';
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($save_button);
     $cell->colspan = 2;
     $this->form->setFields(array($login, $password, $save_button));
     // add the form to the page
     parent::add($this->form);
 }
 /**
  * Class Constructor
  * @param $title_msg  Dialog Title
  * @param $form    Dialog form body
  * @param $action  Action to be processed when closing the dialog
  * @param $caption Button caption
  */
 public function __construct($title_msg, TForm $form, TAction $action = NULL, $caption = '')
 {
     $this->id = uniqid();
     $modal_wrapper = new TElement('div');
     $modal_wrapper->{'class'} = 'modal';
     $modal_wrapper->{'id'} = $this->id;
     $modal_wrapper->{'style'} = 'padding-top: 10%; z-index:4000';
     $modal_wrapper->{'tabindex'} = '-1';
     $modal_dialog = new TElement('div');
     $modal_dialog->{'class'} = 'modal-dialog';
     $modal_content = new TElement('div');
     $modal_content->{'class'} = 'modal-content';
     $modal_header = new TElement('div');
     $modal_header->{'class'} = 'modal-header';
     $close = new TElement('button');
     $close->{'type'} = 'button';
     $close->{'class'} = 'close';
     $close->{'data-dismiss'} = 'modal';
     $close->{'aria-hidden'} = 'true';
     $close->add('×');
     $title = new TElement('h4');
     $title->{'class'} = 'modal-title';
     $title->{'style'} = 'display:inline';
     $title->add($title_msg ? $title_msg : AdiantiCoreTranslator::translate('Input'));
     $form_name = $form->getName();
     $wait_message = AdiantiCoreTranslator::translate('Loading');
     if ($form instanceof TQuickForm) {
         $form->delActions();
         $actionButtons = $form->getActionButtons();
         if ($actionButtons) {
             foreach ($actionButtons as $key => $button) {
                 $button->{'data-toggle'} = "modal";
                 $button->{'data-dismiss'} = 'modal';
                 $button->addFunction("\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');");
                 $buttons[] = $button;
             }
         }
     } else {
         $button = new TButton(strtolower(str_replace(' ', '_', $caption)));
         $button->{'data-toggle'} = "modal";
         $button->{'data-dismiss'} = 'modal';
         $button->addFunction("\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');");
         $button->setAction($action);
         $button->setLabel($caption);
         $buttons[] = $button;
         $form->addField($button);
     }
     $footer = new TElement('div');
     $footer->{'class'} = 'modal-footer';
     $modal_wrapper->add($modal_dialog);
     $modal_dialog->add($modal_content);
     $modal_content->add($modal_header);
     $modal_header->add($close);
     $modal_header->add($title);
     $modal_content->add($form);
     $modal_content->add($footer);
     if (isset($buttons) and $buttons) {
         foreach ($buttons as $button) {
             $footer->add($button);
         }
     }
     $modal_wrapper->show();
     TScript::create("tdialog_start( '#{$this->id}' );");
 }
Exemple #3
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to be processed when closing the dialog
  * @param $title_msg  Dialog Title
  */
 public function __construct($type, $message, TAction $action = NULL, $title_msg = '')
 {
     $this->id = 'tmessage_' . mt_rand(1000000000, 1999999999);
     $modal_wrapper = new TElement('div');
     $modal_wrapper->{'class'} = 'modal';
     $modal_wrapper->{'id'} = $this->id;
     $modal_wrapper->{'style'} = 'padding-top: 10%; z-index:4000';
     $modal_wrapper->{'tabindex'} = '-1';
     $modal_dialog = new TElement('div');
     $modal_dialog->{'class'} = 'modal-dialog';
     $modal_content = new TElement('div');
     $modal_content->{'class'} = 'modal-content';
     $modal_header = new TElement('div');
     $modal_header->{'class'} = 'modal-header';
     if ($type == 'info') {
         $image = new TImage("fa:fa fa-info-circle fa-5x blue");
     } else {
         $image = new TImage("fa:fa fa-exclamation-circle fa-5x red");
     }
     $image->{'style'} = 'float:left; margin-right: 10px;';
     $close = new TElement('button');
     $close->{'type'} = 'button';
     $close->{'class'} = 'close';
     $close->{'data-dismiss'} = 'modal';
     $close->{'aria-hidden'} = 'true';
     $close->add('×');
     $title = new TElement('h4');
     $title->{'class'} = 'modal-title';
     $title->{'style'} = 'display:inline';
     $title->add($title_msg ? $title_msg : ($type == 'info' ? AdiantiCoreTranslator::translate('Information') : AdiantiCoreTranslator::translate('Error')));
     $body = new TElement('div');
     $body->{'style'} = 'text-align:left';
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->add($message);
     $body->add($span);
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->{'onclick'} = "\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');";
     $button->add('OK');
     if ($action) {
         $button->{'onclick'} .= "__adianti_load_page('{$action->serialize()}');";
         $button->{'data-toggle'} = "modal";
     }
     $footer = new TElement('div');
     $footer->{'class'} = 'modal-footer';
     $modal_wrapper->add($modal_dialog);
     $modal_dialog->add($modal_content);
     $modal_content->add($modal_header);
     $modal_header->add($close);
     $modal_header->add($title);
     $modal_content->add($body);
     $modal_content->add($footer);
     $footer->add($button);
     $modal_wrapper->show();
     $callback = 'function () {' . $button->{'onclick'} . '}';
     TScript::create("tdialog_start( '#{$this->id}', {$callback} );");
 }
Exemple #4
0
 /**
  * Set Legend
  * @param  $legend frame legend
  */
 public function setLegend($legend)
 {
     $obj = new TElement('legend');
     $obj->add(new TLabel($legend));
     parent::add($obj);
     $this->legend = $legend;
 }
Exemple #5
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 #6
0
 /**
  * Add an child element
  * @param $child Any object that implements the show() method
  */
 public function add($child)
 {
     $wrapper = new TElement('div');
     $wrapper->{'style'} = 'clear:both';
     $wrapper->add($child);
     parent::add($wrapper);
     return $wrapper;
 }
Exemple #7
0
 /**
  * Show the highlighted source code
  */
 public function show()
 {
     $span = new TElement('span');
     $span->{'style'} = 'font-size:10pt';
     $span->{'class'} = 'tsourcecode';
     $span->add(highlight_string($this->content, TRUE));
     $span->show();
 }
Exemple #8
0
 /**
  * Add an child element
  * @param $child Any object that implements the show() method
  */
 public function add($child)
 {
     $wrapper = new TElement('div');
     $wrapper->{'style'} = 'display:inline-block;';
     $wrapper->add($child);
     parent::add($wrapper);
     return $wrapper;
 }
Exemple #9
0
 /**
  * Add an item
  * @param $path Path to be shown
  * @param $last If the item is the last one
  */
 public function addItem($path, $last = FALSE)
 {
     $li = new TElement('li');
     $this->container->add($li);
     $span = new TElement('span');
     $span->add($path);
     $this->items[$path] = $span;
     if ($last) {
         $li->add($span);
     } else {
         $a = new TElement('a');
         $li->add($a);
         $a->add($span);
     }
 }
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $link = new TElement('a');
     if ($this->action) {
         //$url['class'] = $this->action;
         //$url_str = http_build_query($url);
         $action = str_replace('#', '&', $this->action);
         if (substr($action, 0, 7) == 'http://') {
             $link->href = $action;
             $link->target = '_blank';
         } else {
             $link->href = "index.php?class={$action}";
             $link->generator = 'adianti';
         }
     } else {
         $link->href = '#';
     }
     if (isset($this->image)) {
         $image = new TImage($this->image);
         //$image-> style = 'margin-right: 8px';
         $link->add($image);
     }
     $link->add(' ' . $this->label);
     // converts into ISO
     $this->add($link);
     if ($this->menu instanceof TMenu) {
         $this->{'class'} = 'dropdown-submenu';
         parent::add($this->menu);
     }
     parent::show();
 }
Exemple #11
0
 /**
  * Show the widget
  */
 public function show()
 {
     $this->style->width = $this->width . 'px';
     $this->style->height = $this->height . 'px';
     $this->style->show();
     parent::show();
 }
Exemple #12
0
 /**
  * Add a new row (TTableRow object) to the table
  * @return TTableRow
  */
 public function addRow()
 {
     // creates a new Table Row
     $row = new TTableRow();
     // add this row to the table element
     parent::add($row);
     return $row;
 }
Exemple #13
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $wrapper = new TElement('div');
     $wrapper->{'class'} = 'input-group color-div';
     $span = new TElement('span');
     $span->{'class'} = 'input-group-addon tcolor';
     $i = new TElement('i');
     $i->{'class'} = 'tcolor-icon';
     $span->add($i);
     ob_start();
     parent::show();
     $child = ob_get_contents();
     ob_end_clean();
     $wrapper->add($child);
     $wrapper->add($span);
     $wrapper->show();
     if (parent::getEditable()) {
         TScript::create(" tcolor_start(); ");
     }
 }
Exemple #14
0
 /**
  * Add a new cell (TTableCell) to the Table Row
  * @param  $value Cell Content
  * @return TTableCell
  */
 public function addCell($value)
 {
     if (is_null($value)) {
         throw new Exception(AdiantiCoreTranslator::translate('Method ^1 does not accept null values', __METHOD__));
     } else {
         // creates a new Table Cell
         $cell = new TTableCell($value);
         parent::add($cell);
         // returns the cell object
         return $cell;
     }
 }
Exemple #15
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);
     $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
     }
     $div = new TElement('div');
     $div->style = "display:inline;width:100%;";
     $div->id = 'div_file_' . mt_rand(1000000000, 1999999999);
     $div->add($hdFileName);
     $div->add($this->tag);
     $div->show();
     $action = "engine.php?class={$this->uploaderClass}";
     TScript::create(" tfile_start( '{$this->tag->id}', '{$action}', '{$div->id}', {$complete_action});");
 }
Exemple #16
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $progressBar = new TElement('div');
     $progressBar->{'class'} = "progress-bar progress-bar-{$this->className}";
     $progressBar->{'role'} = 'progressbar';
     $progressBar->{'arial-valuenow'} = $this->value;
     $progressBar->{'arial-valuemin'} = '0';
     $progressBar->{'arial-valuemax'} = '100';
     $progressBar->{'style'} = 'width: ' . $this->value . '%;';
     $value = str_replace('{value}', $this->value, $this->mask);
     $progressBar->add($value);
     parent::add($progressBar);
     parent::show();
 }
Exemple #17
0
 /**
  * Shows the tag
  */
 public function show()
 {
     $stylename = 'style_' . $this->{'id'};
     $style = new TStyle($stylename);
     if (!$this->transparency) {
         $style->border = '1px solid #c2c2c2';
         $style->background = '#ffffff';
     }
     $style->padding = "{$this->margin}px";
     $style->width = $this->width . 'px';
     $style->height = $this->height . 'px';
     // show the style
     $style->show();
     $this->{'class'} = "tscroll {$stylename}";
     parent::show();
 }
Exemple #18
0
 /**
  * Shows the tag
  */
 public function show()
 {
     if (!$this->transparency) {
         $this->{'style'} .= ';border: 1px solid #c2c2c2';
         $this->{'style'} .= ';background: #ffffff';
     }
     $this->{'style'} .= ";padding: {$this->margin}px";
     if ($this->width) {
         $this->{'style'} .= ";width:{$this->width}px";
     }
     if ($this->height) {
         $this->{'style'} .= ";height:{$this->height}px";
     }
     $this->{'class'} .= " tscroll";
     parent::show();
 }
Exemple #19
0
 /**
  * Class Constructor
  * @param $type    Type of the alert (success, info, warning, danger)
  * @param $message Message to be shown
  */
 public function __construct($type, $message)
 {
     parent::__construct('div');
     $this->{'class'} = 'talert alert alert-dismissible alert-' . $type;
     $this->{'role'} = 'alert';
     $button = new TElement('button');
     $button->{'type'} = 'button';
     $button->{'class'} = 'close';
     $button->{'data-dismiss'} = 'alert';
     $button->{'aria-label'} = 'Close';
     $span = new TElement('span');
     $span->{'aria-hidden'} = 'true';
     $span->add('&times;');
     $button->add($span);
     parent::add($button);
     parent::add($message);
 }
Exemple #20
0
 /**
  * Create a script
  * @param $code source code
  */
 public static function create($code, $show = TRUE)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add($code);
     if ($show) {
         $script->show();
     }
     return $script;
 }
Exemple #21
0
 /**
  * Class Constructor
  * @param $source Image path, of bs:bs-glyphicon, fa:font-awesome
  */
 public function __construct($source)
 {
     if (substr($source, 0, 3) == 'bs:') {
         parent::__construct('span');
         $this->class = 'glyphicon glyphicon-' . substr($source, 3);
         parent::add('');
     } else {
         if (substr($source, 0, 3) == 'fa:') {
             parent::__construct('span');
             $this->class = 'fa fa-' . substr($source, 3);
             parent::add('');
         } else {
             if (file_exists($source)) {
                 parent::__construct('img');
                 // assign the image path
                 $this->src = $source;
                 $this->border = 0;
             } else {
                 if (file_exists("app/images/{$source}")) {
                     parent::__construct('img');
                     // assign the image path
                     $this->src = "app/images/{$source}";
                     $this->border = 0;
                 } else {
                     if (file_exists("lib/adianti/images/{$source}")) {
                         parent::__construct('img');
                         // assign the image path
                         $this->src = "lib/adianti/images/{$source}";
                         $this->border = 0;
                     } else {
                         parent::__construct('span');
                     }
                 }
             }
         }
     }
 }
Exemple #22
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     if ($this->action) {
         if (empty($this->formName)) {
             throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->label, 'TForm::setFields()'));
         }
         // get the action as URL
         $url = $this->action->serialize(FALSE);
         if ($this->action->isStatic()) {
             $url .= '&static=1';
         }
         $wait_message = AdiantiCoreTranslator::translate('Loading');
         // define the button's action (ajax post)
         $action = "Adianti.waitMessage = '{$wait_message}';";
         $action .= "{$this->functions}";
         $action .= "__adianti_post_data('{$this->formName}', '{$url}');";
         $action .= "return false;";
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-sm btn-default';
         $button->onclick = $action;
         $button->id = 'tbutton_' . $this->name;
         $button->name = $this->name;
         $action = '';
     } else {
         $action = $this->functions;
         // creates the button using a div
         $button = new TElement('div');
         $button->id = 'tbutton_' . $this->name;
         $button->name = $this->name;
         $button->{'class'} = 'btn btn-default btn-sm';
         $button->onclick = $action;
     }
     if ($this->properties) {
         foreach ($this->properties as $property => $value) {
             $button->{$property} = $value;
         }
     }
     $span = new TElement('span');
     if ($this->image) {
         $image = new TElement('span');
         if (substr($this->image, 0, 3) == 'bs:') {
             $image = new TElement('i');
             $image->{'class'} = 'glyphicon glyphicon-' . substr($this->image, 3);
         } else {
             if (substr($this->image, 0, 3) == 'fa:') {
                 $image = new TElement('i');
                 $image->{'class'} = 'fa fa-' . substr($this->image, 3);
             } else {
                 if (file_exists('app/images/' . $this->image)) {
                     $image = new TImage('app/images/' . $this->image);
                 } else {
                     if (file_exists('lib/adianti/images/' . $this->image)) {
                         $image = new TImage('lib/adianti/images/' . $this->image);
                     }
                 }
             }
         }
         $image->{'style'} = 'padding-right:4px';
         $span->add($image);
     }
     if ($this->label) {
         $span->add($this->label);
     }
     $button->add($span);
     $button->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();
         $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 #24
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";
         }
     }
 }
 /**
  * Shows the tag
  */
 public function show()
 {
     $objectId = $this->{'id'};
     $collapsed = $this->collapsed ? 'true' : 'false';
     parent::add(TScript::create(" ttreeview_start( '#{$objectId}', {$collapsed} ); ", FALSE));
     parent::show();
 }
Exemple #26
0
 /**
  * Decide wich action to take and show the page
  */
 public function show()
 {
     // just execute run() from toplevel TPage's, not nested ones
     if (!$this->getIsWrapped()) {
         $this->run();
     }
     parent::show();
     if (!$this->constructed) {
         throw new Exception(AdiantiCoreTranslator::translate('You must call ^1 constructor', __CLASS__));
     }
 }
 /**
  * Class Constructor
  * @param $value  TableCell content
  */
 public function __construct($value)
 {
     parent::__construct('td');
     parent::add($value);
 }
 /**
  * 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 #30
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();
 }