Example #1
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to process
  */
 public function __construct($type, $message, TAction $action = NULL)
 {
     $this->id = uniqid();
     if (!is_null($action)) {
         $this->action = '__adianti_load_page(\'' . $action->serialize() . '\');';
     }
     if (TPage::isMobile()) {
         $img = new TElement('img');
         $img->src = "lib/adianti/images/{$type}.png";
         $table = new TTable();
         $table->width = '250px';
         $table->bgcolor = '#E5E5E5';
         $table->style = "border-collapse:collapse";
         $row = $table->addRow();
         $row->addCell($img);
         $row->addCell($message);
         $table->show();
     } else {
         TPage::include_css('lib/adianti/include/tmessage/tmessage.css');
         // creates a pannel to show the dialog
         $painel = new TElement('div');
         $painel->{'class'} = 'tmessage';
         $painel->id = 'tmessage_' . $this->id;
         // creates a table for layout
         $table = new TTable();
         // creates a row for the icon and the message
         $row = $table->addRow();
         $row->addCell(new TImage("lib/adianti/images/{$type}.png"));
         $scroll = new TScroll();
         $scroll->setSize(350, 70);
         $scroll->add($message);
         $scroll->setTransparency(true);
         $cell = $row->addCell($scroll);
         // add the table to the pannel
         $painel->add($table);
         // show the pannel
         $painel->show();
         $script = new TElement('script');
         $script->{'type'} = 'text/javascript';
         $script->add(' $(function() {
             $( "#' . $painel->id . '" ).dialog({
                 height: 180,
                 width: 440,
                 stack: false,
                 zIndex: 3000,
                 modal: true,
                 buttons: {
                     OK: function() {
                         $( this ).dialog( "close" ); ' . $this->action . '
                     }
                 }
                 }).css("visibility", "visible");
                 
             	$( "#' . $painel->id . ' a" ).click(function () {
             	    window.open($(this).attr(\'href\'));
                 }); 
             });');
         $script->show();
     }
 }
Example #2
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         // iterate the checkgroup options
         foreach ($this->items as $index => $label) {
             // instantiates a new CheckButton
             $button = new TCheckButton("{$this->name}[]");
             $button->setTip($this->tag->title);
             $button->setIndexValue($index);
             $button->setProperty('checkgroup', $this->name);
             // verify if the checkbutton is checked
             if (@in_array($index, $this->value)) {
                 //$button->setProperty('checked', '1');
                 $button->setValue($index);
                 // value=indexvalue (checked)
             }
             // check whether the widget is non-editable
             if (!parent::getEditable()) {
                 $button->setEditable(FALSE);
             }
             // create the label for the button
             $obj = new TLabel($label);
             $obj->add($button);
             $obj->show();
             if ($this->layout == 'vertical') {
                 // shows a line break
                 $br = new TElement('br');
                 $br->show();
                 echo "\n";
             }
         }
     }
 }
Example #3
0
 public function show()
 {
     foreach ($this->elements as $item => $value) {
         $li = new TElement('li');
         $a = new TElement('a');
         $a->href = "#{$item}";
         $a->add($item);
         $li->add($a);
         $this->ul->add($li);
     }
     parent::add($this->ul);
     foreach ($this->elements as $item => $value) {
         $conteudo = new TElement('div');
         $conteudo2 = new TElement('div');
         $conteudo->id = $item;
         $conteudo->add($value);
         parent::add($conteudo);
     }
     $script = new TElement('script');
     $script->type = 'text/javascript';
     $code = "  \$(function() {\n\$( '#{$this->id}' ).tabs();\n});";
     $script->add($code);
     parent::add($script);
     parent::show();
 }
Example #4
0
 /**
  * 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);
         $link->href = "index.php?class={$action}";
         $link->generator = 'adianti';
     } else {
         $link->href = '#';
     }
     if (isset($this->image)) {
         $image = new TImage($this->image);
         $image->style = 'padding-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();
 }
 /**
  * Show the highlighted source code
  */
 public function show()
 {
     $span = new TElement('span');
     $span->style = 'font-size:10pt';
     $span->add(highlight_string($this->content, TRUE));
     $span->show();
 }
 /**
  * método construtor
  * instancia objeto TQuestion
  * @param $message = pergunta ao usuário
  * @param $action_yes = ação para resposta positiva
  * @param $action_no = ação para resposta negativa
  */
 function __construct($message, $url_yes, $url_no)
 {
     // instancia o painel para exibir o diálogo
     $painel = new TElement('div');
     $painel->class = "tquestion";
     // cria um botão para a resposta positiva
     $button1 = new TElement('input');
     $button1->type = 'button';
     $button1->value = 'Sim';
     $button1->onclick = "javascript:location='{$url_yes}'";
     $button1->id = 'bt1';
     // cria um botão para a resposta negativa
     $button2 = new TElement('input');
     $button2->type = 'button';
     $button2->value = 'Não';
     $button2->onclick = "javascript:location='{$url_no}'";
     // cria uma tabela para organizar o layout
     $table = new TTable();
     $table->align = 'center';
     $table->cellspacing = 10;
     // cria uma linha para o ícone e a mensagem
     $row = $table->addRow();
     $row->addCell(new TImage('app.misc/images/question.png'));
     $row->addCell($message);
     // cria uma linha para os botões
     $row = $table->addRow();
     $row->addCell($button1);
     $row->align = 'left';
     $row->addCell($button2);
     // adiciona a tabela ao painél
     $painel->add($table);
     // exibe o painél
     $painel->show();
 }
Example #7
0
 public function show()
 {
     foreach ($this->sources as $s) {
         parent::add($s);
     }
     parent::show();
 }
Example #8
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         // iterate the RadioButton options
         foreach ($this->items as $index => $label) {
             $button = new TRadioButton($this->name);
             $button->setTip($this->tag->title);
             $button->setValue($index);
             // check if contains any value
             if ($this->value == $index) {
                 // mark as checked
                 $button->setProperty('checked', '1');
             }
             // check whether the widget is non-editable
             if (!parent::getEditable()) {
                 $button->setEditable(FALSE);
             }
             // create the label for the button
             $obj = new TLabel($label);
             $obj->add($button);
             $obj->show();
             if ($this->layout == 'vertical') {
                 // shows a line break
                 $br = new TElement('br');
                 $br->show();
             }
             echo "\n";
         }
     }
 }
 /**
  * Shows the tag
  */
 public function show()
 {
     $stylename = 'tscroll' . $this->id;
     $style = new TStyle($stylename);
     if (!$this->transparency) {
         $style->border = '1px solid #c2c2c2';
         $style->background = '#ffffff';
     }
     $style->padding_left = "{$this->margin}px";
     $style->padding_top = "{$this->margin}px";
     $style->padding_right = "{$this->margin}px";
     $style->padding_bottom = "{$this->margin}px";
     $style->width = $this->width . 'px';
     $style->height = $this->height . 'px';
     $style->overflow = 'auto';
     $style->scroll = 'none';
     // check if there's any TSourceCode inside
     if (is_array($this->children)) {
         foreach ($this->children as $child) {
             if ($child instanceof TSourceCode) {
                 $style->background_color = '#ffffff';
             }
         }
     }
     // show the style
     $style->show();
     $this->{'class'} = $stylename;
     parent::show();
 }
Example #10
0
 public function show()
 {
     $time = new TElement('div');
     $time->id = "ptimer_" . uniqid();
     $url = 'engine.php';
     $code = "\n\ntimer({$url},'{$this->page}',{$this->time},'{$time->id}');\n\n";
     TScript::create($code);
     $time->show();
 }
Example #11
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     if ($this->items) {
         foreach ($this->items as $item) {
             parent::add($item);
         }
     }
     parent::show();
 }
Example #12
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $js_mask = str_replace('yyyy', 'yy', $this->mask);
     if (parent::getEditable()) {
         $script = new TElement('script');
         $script->type = 'text/javascript';
         $script->add("\n            \t\$(function() {\n                \$(\"#{$this->id}\").datepicker({\n                    showOn: 'button',\n                    buttonImage: 'lib/adianti/images/tdate.png',\n                    buttonImageOnly: true,    \n            \t\tchangeMonth: true,\n            \t\tchangeYear: true,\n            \t\tdateFormat: '{$js_mask}',\n            \t\tshowButtonPanel: true\n            \t});\n            });");
         $script->show();
     }
     parent::show();
 }
Example #13
0
 /**
  * Show
  */
 public function show()
 {
     $script = new TElement('script');
     $script->{'type'} = 'text/javascript';
     $code = '$(document).ready( function() {
                  $(\'.dropdown-toggle\').dropdown()
              });';
     $script->add($code);
     $script->show();
     parent::show();
 }
Example #14
0
 public function show()
 {
     $btn = '  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>';
     $titulo = new TElement('h4');
     $titulo->add($this->titulo);
     $msg = new TElement('p');
     $msg->add($this->msg);
     $this->add($btn);
     $this->add($titulo);
     $this->add($msg);
     parent::show();
 }
Example #15
0
 public function __construct()
 {
     parent::__construct('ul');
     $this->class = 'dropdown-menu dropdown-messages';
     $messages = array();
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $a = new TElement('a');
     $a->{'class'} = "dropdown-toggle";
     $a->{'data-toggle'} = "dropdown";
     $a->{'href'} = "#";
     $a->add(TElement::tag('i', '', array('class' => "fa fa-envelope fa-fw")));
     $a->add(TElement::tag('span', count($messages), array('class' => "badge badge-notify")));
     $a->add(TElement::tag('i', '', array('class' => "fa fa-caret-down")));
     $a->show();
     foreach ($messages as $message) {
         $name = $message[0];
         $date = $message[1];
         $body = $message[2];
         $li = new TElement('li');
         $a = new TElement('a');
         $div = new TElement('div');
         $a->href = '#';
         $li->add($a);
         $a->add($div);
         $div->add(TElement::tag('strong', $name));
         $div->add(TElement::tag('span', TElement::tag('em', $date), array('class' => 'pull-right text-muted')));
         $div2 = new TElement('div');
         $div2->add($body);
         $a->add($div2);
         parent::add($li);
         parent::add(TElement::tag('li', '', array('class' => 'divider')));
     }
     $li = new TElement('li');
     $a = new TElement('a');
     $li->add($a);
     $a->class = 'text-center';
     $a->href = '#';
     $a->add(TElement::tag('strong', 'Read messages'));
     $a->add($i = TElement::tag('i', '', array('class' => 'fa fa-inbox')));
     parent::add($li);
     parent::add(TElement::tag('li', '', array('class' => 'divider')));
     $li = new TElement('li');
     $a = new TElement('a');
     $li->add($a);
     $a->class = 'text-center';
     $a->href = '#';
     $a->add(TElement::tag('strong', 'Send message'));
     $a->add($i = TElement::tag('i', '', array('class' => 'fa fa-envelope-o')));
     parent::add($li);
 }
 public function show()
 {
     $c = "";
     foreach ($this->code as $frames) {
         $c .= "\$( '#" . $frames->id . "' ).resizable({\ncontainment: '#{$this->id}'\n});";
     }
     $code = "\$(function() {\n \n" . $c . "\n\n});";
     $script = new TElement('script');
     $script->type = 'text/javascript';
     $script->add($code);
     parent::add($script);
     parent::show();
 }
 public function show()
 {
     $code = '  google.load("visualization", "1", {packages:["corechart"]});';
     $code .= "google.setOnLoadCallback(drawChart);\n      function drawChart() {\n        var data = google.visualization.arrayToDataTable([\n          ['Year', 'Sales', 'Expenses'],\n          ['2013',  1000,      400],\n          ['2014',  1170,      460],\n          ['2015',  660,       1120],\n          ['2016',  1030,      540]\n        ]);\n\n        var options = {\n          title: 'Company Performance',\n          hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},\n          vAxis: {minValue: 0}\n        };\n\n        var chart = new google.visualization.AreaChart(document.getElementById('{$this->id}'));\n        chart.draw(data, options);\n      }\n";
     $scriptApi = new TElement('script');
     $scriptApi->type = 'text/javascript';
     $scriptApi->src = "https://www.google.com/jsapi";
     $script = new TElement('script');
     $script->type = 'text/javascript';
     $script->add($code);
     parent::add($scriptApi);
     parent::add($script);
     parent::show();
 }
Example #18
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     foreach ($this->elements as $child) {
         $title = new TElement('h3');
         $title->add($child[0]);
         $content = new TElement('div');
         $content->add($child[1]);
         parent::add($title);
         parent::add($content);
     }
     TScript::create('$(document).ready( function() {
                         $( "#' . $this->id . '" ).accordion();
                     });');
     parent::show();
 }
 public function show()
 {
     if ($this->height == null || $this->width == null) {
         throw new Exception('size não especificado');
     }
     if ($this->height == null) {
         throw new Exception('title não especificado');
     }
     $script = new TElement('script');
     $script->type = 'text/javascript';
     $code = "\$(function() {\n\$('#{$this->id}').dialog({ minWidth: {$this->width},minHeight: {$this->height} {$this->modal} {$this->title}} );\n});";
     $script->add($code);
     parent::add($script);
     parent::show();
 }
Example #20
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // TAG name
     $this->tag->value = $this->value;
     // TAG value
     $this->tag->type = 'text';
     // input type
     $this->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";
         $script = new TElement('script');
         $script->add(' $(function() {
                     $( "#' . $this->id . '_div" ).slider({
                         value: ' . $this->value . ',
                         min: ' . $this->min . ',
                         max: ' . $this->max . ',
                         step: ' . $this->step . ',
                         slide: function( event, ui ) {
                             $( "#' . $this->id . '" ).val( ui.value );
                         }
                     });
                     });');
         $script->show();
         $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();
     }
 }
 /**
  * método construtor
  * instancia objeto TQuestion
  * @param $message = pergunta ao usuário
  * @param $action_yes = ação para resposta positiva
  * @param $action_no = ação para resposta negativa
  */
 function __construct($message, TAction $action_yes, TAction $action_no)
 {
     $style = new TStyle('tquestion');
     $style->position = 'absolute';
     $style->left = '30%';
     $style->top = '30%';
     $style->width = '300';
     $style->height = '150';
     $style->border_width = '1px';
     $style->color = 'black';
     $style->background = '#DDDDDD';
     $style->border = '4px solid #000000';
     $style->z_index = '10000000000000000';
     // converte os nomes de métodos em URL's
     $url_yes = $action_yes->serialize();
     $url_no = $action_no->serialize();
     // exibe o estilo na tela
     $style->show();
     // instancia o painel para exibir o diálogo
     $painel = new TElement('div');
     $painel->class = "tquestion";
     // cria um botão para a resposta positiva
     $button1 = new TElement('input');
     $button1->type = 'button';
     $button1->value = 'Sim';
     $button1->onclick = "javascript:location='{$url_yes}'";
     // cria um botão para a resposta negativa
     $button2 = new TElement('input');
     $button2->type = 'button';
     $button2->value = 'Não';
     $button2->onclick = "javascript:location='{$url_no}'";
     // cria uma tabela para organizar o layout
     $table = new TTable();
     $table->align = 'center';
     $table->cellspacing = 10;
     // cria uma linha para o ícone e a mensagem
     $row = $table->addRow();
     $row->addCell(new TImage('app.images/question.png'));
     $row->addCell($message);
     // cria uma linha para os botões
     $row = $table->addRow();
     $row->addCell($button1);
     $row->addCell($button2);
     // adiciona a tabela ao painél
     $painel->add($table);
     // exibe o painél
     $painel->show();
 }
Example #22
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     TPage::include_css('lib/valums/fileuploader.css');
     TPage::include_js('lib/valums/fileuploader.js');
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     $this->tag->value = $this->value;
     // tag value
     $this->tag->type = 'text';
     // input type
     $this->tag->style = "width:{$this->size}px";
     // size
     // verify if the widget is editable
     if (!parent::getEditable()) {
         // make the field read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     $div = new TElement('div');
     $div->style = "display:inline";
     $div->id = 'div_file_' . uniqid();
     $table = new TTable();
     $table->cellspacing = 0;
     $row = $table->addRow();
     $row->addCell($this->tag);
     $row->addCell($div);
     $table->show();
     $script = new TElement('script');
     $script->{'type'} = 'text/javascript';
     $class = 'TFileUploader';
     $script->add('
         new qq.FileUploader({
             element: document.getElementById("' . $div->id . '"),
             action: "engine.php?class=' . $class . '",
             debug: true,
             onComplete: function(id, fileName, responseJSON)
             {
                 document.getElementsByName("' . $this->name . '")[0].value= responseJSON.target;
             }
         });');
     $script->show();
 }
Example #23
0
 public function show()
 {
     $time = new TElement('div');
     $time->id = "ptimer_" . uniqid();
     $campos = serialize($this->campos);
     $action = serialize($this->action);
     //$campos = base64_encode($campos);
     if (!file_exists('timer.php')) {
         $file = file_get_contents('app/lib/PWD-Lib/PTimer/timer.php');
         $fp = fopen("timer.php", "a");
         $escreve = fwrite($fp, "{$file}");
         // Fecha o arquivo
         fclose($fp);
     }
     $url = "'timer.php'";
     $code = "\n\nrunPtimer({$url},'{$this->model}','{$this->banco}','{$campos}','{$action}','{$this->key}',{$this->time},'{$time->id}');\n\n";
     TScript::create($code);
     $time->show();
 }
Example #24
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     foreach ($this->elements as $child) {
         $title = new TElement('h3');
         $title->add($child[0]);
         $content = new TElement('div');
         $content->add($child[1]);
         parent::add($title);
         parent::add($content);
     }
     $script = new TElement('script');
     $script->{'type'} = 'text/javascript';
     $code = '
         $(document).ready( function() {
             $( "#' . $this->id . '" ).accordion();
         });
         ';
     $script->add($code);
     $script->show();
     parent::show();
 }
 /**
  * método construtor
  * instancia objeto TMessage
  * @param $type      = tipo de mensagem (info, error)
  * @param $message = mensagem ao usuário
  */
 public function __construct($type, $message)
 {
     //        $style = new TStyle('tmessage');
     //        $style->position      = 'absolute';
     //        $style->left          = '30%';
     //        $style->top           = '30%';
     //        $style->width         = '600';
     //        $style->height        = '350';
     //        $style->color         = 'black';
     //        $style->background    = '#DDDDDD';
     //        $style->border        = '4px solid #000000';
     //        $style->z_index       = '10000000000000000';
     //
     //        // exibe o estilo na tela
     //        $style->show();
     // instancia o painel para exibir o diálogo
     $painel = new TElement('div');
     $painel->class = "tmessage";
     $painel->id = "tmessage";
     // cria um botão que vai fechar o diálogo
     $button = new TElement('input');
     $button->type = 'button';
     $button->value = 'Fechar';
     $button->onclick = "document.getElementById('tmessage').style.display='none'";
     // cria um tabela para organizar o layout
     $table = new TTable();
     $table->align = 'center';
     // cria uma linha para o ícone e a mensagem
     $row = $table->addRow();
     $row->addCell(new TImage("app.misc/images/{$type}.png"));
     $row->addCell($message);
     // cria uma linha para o botão
     $row = $table->addRow();
     $row->addCell('');
     $row->addCell($button);
     // adiciona a tabela ao painél
     $painel->add($table);
     // exibe o painél
     $painel->show();
 }
 /**
  * método show()
  * exibe o widget na tela
  */
 public function show()
 {
     if ($this->items) {
         // percorre cada uma das opções do rádio
         foreach ($this->items as $index => $label) {
             $button = new TCheckButton("{$this->name}[]");
             $button->setValue($index);
             // verifica se deve ser marcado
             if (@in_array($index, $this->value)) {
                 $button->setProperty('checked', '1');
             }
             $button->show();
             $obj = new TLabel($label);
             $obj->show();
             if ($this->layout == 'vertical') {
                 // exibe uma tag de quebra de linha
                 $br = new TElement('br');
                 $br->show();
                 echo "\n";
             }
         }
     }
 }
 /**
  * método show()
  * exibe o widget na tela
  */
 public function show()
 {
     if ($this->items) {
         // percorre cada uma das opções do rádio
         foreach ($this->items as $index => $label) {
             $button = new TRadioButton($this->name);
             $button->setValue($index);
             // se possui qualquer valor
             if ($this->value == $index) {
                 // marca o radio button
                 $button->setProperty('checked', '1');
             }
             $button->show();
             $obj = new TLabel($label);
             $obj->show();
             if ($this->layout == 'vertical') {
                 // exibe uma tag de quebra de linha
                 $br = new TElement('br');
                 $br->show();
             }
             echo "\n";
         }
     }
 }
Example #28
0
 /**
  * Show the widget
  */
 public function show()
 {
     // check if the field is not editable
     if (parent::getEditable()) {
         $tag = new TElement('textarea');
         $tag->{'id'} = $this->widgetId;
         $tag->{'class'} = 'thtmleditor';
         // CSS
         $tag->name = $this->name;
         // tag name
         $tag->style = "width:{$this->size}px;";
         $this->tag->add($tag);
         if ($this->height) {
             $tag->style .= "height:{$this->height}px";
         }
         // add the content to the textarea
         $tag->add(htmlspecialchars($this->value));
         $script = new TElement('script');
         $script->type = 'text/javascript';
         $script->add('
             $("#' . $tag->{'id'} . '").cleditor({width:"' . $this->size . 'px", height:"' . $this->height . 'px"})
         ');
         $script->show();
     } else {
         $this->tag->style = "width:{$this->size}px;";
         $this->tag->style .= "height:{$this->height}px;";
         $this->tag->style .= "background-color:#FFFFFF;";
         $this->tag->style .= "border: 1px solid #000000;";
         $this->tag->style .= "padding: 5px;";
         $this->tag->style .= "overflow: auto;";
         // add the content to the textarea
         $this->tag->add($this->value);
     }
     // show the tag
     $this->tag->show();
 }
Example #29
0
 /**
  * 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
  */
 public function __construct($message, TAction $action_yes = NULL, TAction $action_no = NULL)
 {
     $this->id = uniqid();
     if (TPage::isMobile()) {
         $img = new TElement('img');
         $img->src = "lib/adianti/images/question.png";
         $yes = new TElement('a');
         $yes->href = $action_yes->serialize();
         $yes->generator = 'adianti';
         $yes->add(TAdiantiCoreTranslator::translate('Yes'));
         $no = new TElement('a');
         $no->href = $action_no->serialize();
         $no->generator = 'adianti';
         $no->add(TAdiantiCoreTranslator::translate('No'));
         $table = new TTable();
         $table->width = '250px';
         $table->bgcolor = '#E5E5E5';
         $table->style = "border-collapse:collapse";
         $row = $table->addRow();
         $row->addCell($img);
         $table2 = new TTable();
         $row->addCell($table2);
         $row = $table2->addRow();
         $c = $row->addCell($message);
         $c->colspan = 2;
         $row = $table2->addRow();
         $row->addCell($yes);
         $row->addCell($no);
         $table->show();
     } else {
         TPage::include_css('lib/adianti/include/tmessage/tmessage.css');
         // creates a layer to show the dialog
         $painel = new TElement('div');
         $painel->{'class'} = "tmessage";
         $painel->id = 'tquestion_' . $this->id;
         $url_yes = '';
         $url_no = '';
         if ($action_yes) {
             // convert the actions into URL's
             $url_yes = TAdiantiCoreTranslator::translate('Yes') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_yes->serialize() . '\');},';
         }
         if ($action_no) {
             $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_no->serialize() . '\');},';
         } else {
             $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" );},';
         }
         // creates a table for layout
         $table = new TTable();
         // creates a row for the icon and the message
         $row = $table->addRow();
         $row->addCell(new TImage("lib/adianti/images/question.png"));
         $scroll = new TScroll();
         $scroll->setSize(400, 200);
         $scroll->add($message);
         $cell = $row->addCell($scroll);
         // add the table to the pannel
         $painel->add($table);
         // show the pannel
         $painel->show();
         $script = new TElement('script');
         $script->add(' $(function() {
             $( "#' . $painel->id . '" ).dialog({
                 height: 340,
                 width: 500,
                 modal: true,
                 stack: false,
                 zIndex: 3000,
                 buttons: {
                 ' . $url_yes . $url_no . TAdiantiCoreTranslator::translate('Cancel') . ': function() {
                         $( this ).dialog( "close" );
                     }
                 }
                 }).css("visibility", "visible");
             });');
         $script->show();
     }
 }
Example #30
0
 /**
  * Reload combobox items after it is already shown
  * @param $formname form name (used in gtk version)
  * @param $name field name
  * @param $items array with items
  */
 public static function reload($formname, $name, $items)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $code = '$(function() {';
     $code .= '$(\'select[name="' . $name . '"]\').html("");';
     foreach ($items as $key => $value) {
         $code .= '$("<option value=\'' . $key . '\'>' . $value . '</option>").appendTo(\'select[name="' . $name . '"]\');';
     }
     $code .= '});';
     $script->add($code);
     $script->show();
 }