/**
  * 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}' );");
 }
 /**
  * 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 #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
 /**
  * Show the widget
  */
 public function show()
 {
     $this->style->width = $this->width . 'px';
     $this->style->height = $this->height . 'px';
     $this->style->show();
     parent::show();
 }
Exemple #5
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();
 }
 /**
  * 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 = 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';
     $image = new TImage("lib/adianti/images/{$type}.png");
     $image->{'style'} = 'float:left';
     $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->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'style'} = 'margin-left:20px;float:left; display:inline-block';
     $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 #7
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 #8
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();
 }
 /**
  * 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 #10
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 #11
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(); ");
     }
 }
 /**
  * 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>';
 }
Exemple #13
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 editable
     if (parent::getEditable()) {
         $this->tag->readonly = "1";
         $this->tag->style = "width:40px;-moz-user-select:none;border:0;text-align:center";
         $div = new TElement('div');
         $div->id = $this->id . '_div';
         $div->style = "width:{$this->size}px";
         $main_div = new TElement('div');
         $main_div->style = "text-align:center;width:{$this->size}px";
         TScript::create(" tslider_start( '#{$this->id}', {$this->value}, {$this->min}, {$this->max}, {$this->step}); ");
         $main_div->add($this->tag);
         $main_div->add($div);
         $main_div->show();
     } else {
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->style = "width:40px;-moz-user-select:none;";
         $this->tag->onmouseover = "style.cursor='default'";
         $this->tag->show();
     }
 }
Exemple #14
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__));
     }
 }
Exemple #15
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 #16
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->action) {
         //$url['class'] = $this->action;
         //$url_str = http_build_query($url);
         $action = str_replace('#', '&', $this->action);
         if (substr($action, 0, 7) == 'http://') {
             $this->link->href = $action;
             $this->link->target = '_blank';
         } else {
             $this->link->href = "index.php?class={$action}";
             $this->link->generator = 'adianti';
         }
     } else {
         $this->link->href = '#';
     }
     if (isset($this->image)) {
         $image = new TImage($this->image);
         $this->link->add($image);
     }
     $label = new TElement('span');
     $label->add($this->label);
     $this->link->add($label);
     // converts into ISO
     $this->add($this->link);
     if ($this->menu instanceof TMenu) {
         $this->link->{'class'} = $this->linkClass;
         if (strstr($this->linkClass, 'dropdown')) {
             $this->link->{'data-toggle'} = "dropdown";
         }
         if ($this->level == 0) {
             $caret = new TElement('b');
             $caret->{'class'} = 'caret';
             $caret->add('');
             $this->link->add($caret);
         }
         parent::add($this->menu);
     }
     parent::show();
 }
Exemple #17
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $action_code = '';
     if ($this->actions) {
         foreach ($this->actions as $action_array) {
             $label = $action_array[0];
             $action = $action_array[1];
             $action_code .= "\"{$label}\": function() {  {$action} },";
         }
     }
     $ok_button = '';
     if ($this->useOKButton) {
         $ok_button = '  OK: function() {
             				$( this ).remove();
             			}';
     }
     $left = $this->left ? $this->left : 0;
     $top = $this->top ? $this->top : 0;
     $pos_string = '';
     $id = $this->{'id'};
     parent::add(TScript::create("tjquerydialog_start( '#{$id}', {$this->modal}, {$this->draggable}, {$this->resizable}, {$this->width}, {$this->height}, {$top}, {$left}, {$this->stackOrder}, { {$action_code} {$ok_button} } ); ", FALSE));
     parent::show();
 }
Exemple #18
0
 /**
  * Show the PageNavigation widget
  */
 public function show()
 {
     if (!$this->action instanceof TAction) {
         throw new Exception(AdiantiCoreTranslator::translate('You must call ^1 before add this component', __CLASS__ . '::' . 'setAction()'));
     }
     $first_page = isset($this->first_page) ? $this->first_page : 1;
     $direction = 'asc';
     $page_size = isset($this->limit) ? $this->limit : 10;
     $max = 10;
     $registros = $this->count;
     if (!$registros) {
         $registros = 0;
     }
     if ($page_size > 0) {
         $pages = (int) ($registros / $page_size) - $first_page + 1;
     } else {
         $pages = 1;
     }
     if ($page_size > 0) {
         $resto = $registros % $page_size;
     }
     $pages += $resto > 0 ? 1 : 0;
     $last_page = min($pages, $max);
     $nav = new TElement('nav');
     $nav->{'class'} = 'tpagenavigation';
     $nav->align = 'center';
     $ul = new TElement('ul');
     $ul->{'class'} = 'pagination';
     $nav->add($ul);
     // previous
     $item = new TElement('li');
     $link = new TElement('a');
     $span = new TElement('span');
     $link->{'href'} = '#';
     $link->{'aria-label'} = 'Previous';
     $ul->add($item);
     $item->add($link);
     $link->add($span);
     if ($first_page > 1) {
         $this->action->setParameter('offset', ($first_page - $max - 1) * $page_size);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('direction', $this->direction);
         $this->action->setParameter('page', $first_page - $max);
         $this->action->setParameter('first_page', $first_page - $max);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $span->add('&laquo;');
     } else {
         $span->add('&nbsp;');
     }
     for ($n = $first_page; $n <= $last_page + $first_page - 1; $n++) {
         $offset = ($n - 1) * $page_size;
         $item = new TElement('li');
         $link = new TElement('a');
         $span = new TElement('span');
         $this->action->setParameter('offset', $offset);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('direction', $this->direction);
         $this->action->setParameter('page', $n);
         $this->action->setParameter('first_page', $first_page);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $ul->add($item);
         $item->add($link);
         $link->add($span);
         $span->add($n);
         if ($this->page == $n) {
             $item->{'class'} = 'active';
         }
     }
     for ($z = $n; $z <= 10; $z++) {
         $item = new TElement('li');
         $link = new TElement('a');
         $span = new TElement('span');
         $item->{'class'} = 'off';
         $ul->add($item);
         $item->add($link);
         $link->add($span);
         $span->add($z);
     }
     $item = new TElement('li');
     $link = new TElement('a');
     $span = new TElement('span');
     $link->{'aria-label'} = "Next";
     $ul->add($item);
     $item->add($link);
     $link->add($span);
     if ($pages > $max) {
         $offset = ($n - 1) * $page_size;
         $first_page = $n;
         $this->action->setParameter('offset', $offset);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('direction', $this->direction);
         $this->action->setParameter('page', $n);
         $this->action->setParameter('first_page', $first_page);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $span->add('&raquo;');
     } else {
         $span->add('&nbsp;');
     }
     $nav->show();
 }
 /**
  * Class Constructor
  * @param  $message    A string containint the question
  * @param  $action_yes Action taken for YES response
  * @param  $action_no  Action taken for NO  response
  * @param  $title_msg  Dialog Title
  */
 public function __construct($message, TAction $action_yes = NULL, TAction $action_no = NULL, $title_msg = '')
 {
     $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';
     $image = new TImage("lib/adianti/images/question.png");
     $image->{'style'} = 'float:left';
     $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('Question'));
     $body = new TElement('div');
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'style'} = 'margin-left:20px;float:left; display:inline-block';
     $span->add($message);
     $body->add($span);
     $footer = new TElement('div');
     $footer->{'class'} = 'modal-footer';
     if ($action_yes) {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-toggle'} = "modal";
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('Yes'));
         $button->{'onclick'} = '__adianti_load_page(\'' . $action_yes->serialize() . '\')';
         $footer->add($button);
     }
     if ($action_no) {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-toggle'} = "modal";
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('No'));
         $button->{'onclick'} = '__adianti_load_page(\'' . $action_no->serialize() . '\')';
         $footer->add($button);
     } else {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('No'));
         $footer->add($button);
     }
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->add(AdiantiCoreTranslator::translate('Cancel'));
     $footer->add($button);
     $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);
     $modal_wrapper->show();
     TScript::create("tdialog_start( '#{$this->id}' );");
 }
 /**
  * Shows the expander
  */
 public function show()
 {
     parent::show();
     TScript::create('texpander_start();');
 }
 /**
  * Show
  */
 public function show()
 {
     TScript::create('tmenubar_start()');
     parent::show();
 }
 /**
  * Show the PageNavigation widget
  */
 public function show()
 {
     if (!$this->action instanceof TAction) {
         throw new Exception(AdiantiCoreTranslator::translate('You must call ^1 before add this component', __CLASS__ . '::' . 'setAction()'));
     }
     $first_page = isset($this->first_page) ? $this->first_page : 1;
     $direction = 'asc';
     $page_size = isset($this->limit) ? $this->limit : 10;
     $max = 10;
     $registros = $this->count;
     if (!$registros) {
         $registros = 0;
     }
     if ($page_size > 0) {
         $pages = (int) ($registros / $page_size) - $first_page + 1;
     } else {
         $pages = 1;
     }
     if ($page_size > 0) {
         $resto = $registros % $page_size;
     }
     $pages += $resto > 0 ? 1 : 0;
     $last_page = min($pages, $max);
     $div = new TElement('div');
     $div->{'class'} = 'tpagenavigation';
     $div->align = 'center';
     $table = new TTable();
     $table->cellpadding = 0;
     $table->cellspacing = 0;
     $row = $table->addRow();
     //previous
     $link = new TElement('a');
     $span = new TElement('span');
     $cell = $row->addCell($link);
     $link->add($span);
     $cell->{'class'} = 'prev';
     if ($first_page > 1) {
         $this->action->setParameter('offset', ($first_page - $max) * $page_size);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('page', $first_page - $max);
         $this->action->setParameter('first_page', $first_page - $max);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $span->add('&lt;&lt;');
     } else {
         $span->add('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
     }
     for ($n = $first_page; $n <= $last_page + $first_page - 1; $n++) {
         $offset = ($n - 1) * $page_size;
         $link = new TElement('a');
         $this->action->setParameter('offset', $offset);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('page', $n);
         $this->action->setParameter('first_page', $first_page);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $span = new TElement('span');
         $span->add($n);
         $cell = $row->addCell($link);
         $link->add($span);
         if ($this->page == $n) {
             $cell->{'class'} = 'on';
         }
     }
     for ($z = $n; $z <= 10; $z++) {
         $link = new TElement('a');
         $span = new TElement('span');
         $span->add($z);
         $cell = $row->addCell($link);
         $link->add($span);
         $cell->{'class'} = 'off';
     }
     $link = new TElement('a');
     $span = new TElement('span');
     $cell = $row->addCell($link);
     $link->add($span);
     $cell->{'class'} = 'next';
     if ($pages > $max) {
         $offset = ($n - 1) * $page_size;
         $first_page = $n;
         $this->action->setParameter('offset', $offset);
         $this->action->setParameter('limit', $page_size);
         $this->action->setParameter('page', $n);
         $this->action->setParameter('first_page', $first_page);
         $this->action->setParameter('order', $this->order);
         $link->href = $this->action->serialize();
         $link->generator = 'adianti';
         $span->add('&nbsp; &gt;&gt; &nbsp; ');
     } else {
         $span->add('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
     }
     $div->add($table);
     $div->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()
 {
     // 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});");
 }
 /**
  * Show the calendar
  */
 public function show()
 {
     $this->style = "width: {$this->width}px; height: {$this->height}px";
     $this->month = $this->month ? $this->month : date('m');
     $this->year = $this->year ? $this->year : date('Y');
     $table = new TTable();
     $table->width = '100%';
     parent::add($table);
     $row = $table->addRow();
     $cell = $row->addCell($this->months[$this->month - 1] . ' ' . $this->year);
     $cell->colspan = 7;
     $cell->class = 'calendar-header';
     $row = $table->addRow();
     $row->addCell('S')->class = 'calendar-header';
     $row->addCell('M')->class = 'calendar-header';
     $row->addCell('T')->class = 'calendar-header';
     $row->addCell('W')->class = 'calendar-header';
     $row->addCell('T')->class = 'calendar-header';
     $row->addCell('F')->class = 'calendar-header';
     $row->addCell('S')->class = 'calendar-header';
     $prev_year = $this->year;
     $next_year = $this->year;
     $prev_month = $this->month - 1;
     $next_month = $this->month + 1;
     if ($prev_month == 0) {
         $prev_month = 12;
         $prev_year = $this->year - 1;
     }
     if ($next_month == 13) {
         $next_month = 1;
         $next_year = $this->year + 1;
     }
     $timestamp = mktime(0, 0, 0, $this->month, 1, $this->year);
     $maxday = date("t", $timestamp);
     $thismonth = getdate($timestamp);
     $startday = $thismonth['wday'];
     for ($i = 0; $i < $maxday + $startday; $i++) {
         if ($i % 7 == 0) {
             $row = $table->addRow();
             $row->class = 'calendar-rowdata';
         }
         if ($i < $startday) {
             $row->addCell('');
         } else {
             $current_day = $i - $startday + 1;
             $cell = $row->addCell($current_day);
             if (in_array($current_day, $this->selectedDays)) {
                 $cell->class = 'calendar-data calendar-selected';
             } else {
                 $cell->class = 'calendar-data';
             }
             $cell->valign = 'middle';
             if ($this->action instanceof TAction) {
                 $this->action->setParameter('year', $this->year);
                 $this->action->setParameter('month', $this->month);
                 $this->action->setParameter('day', $current_day);
                 $string_action = $this->action->serialize(FALSE);
                 $cell->onclick = "__adianti_ajax_exec('{$string_action}')";
             }
         }
     }
     parent::show();
 }
 /**
  * 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 #27
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         foreach ($this->items as $item) {
             parent::add($item);
         }
     }
     parent::show();
 }
Exemple #28
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();
 }
 /**
  * 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";
         }
     }
 }