Esempio n. 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();
     }
 }
Esempio n. 2
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();
 }
Esempio n. 3
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();
     }
 }
Esempio n. 4
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     // include the needed libraries and styles
     if ($this->fields) {
         $table = new TTable();
         $mdr = array();
         // mandatory
         $fields = array();
         $i = 0;
         foreach ($this->fields as $name => $obj) {
             $row = $table->addRow();
             $label = new TLabel($obj->text);
             if ($obj->inform) {
                 $row->addCell($label);
                 $row->addCell($obj->field);
             }
             $fields[] = $name;
             $post_fields[$name] = 1;
             $obj->field->setName($this->name . '_' . $name);
             if (get_class($obj->field) == 'TComboCombined') {
                 $fields[] = $obj->field->getTextName();
                 $obj->field->setTextName($this->name . '_' . $obj->field->getTextName());
                 $i++;
             }
             $i++;
         }
         $table->show();
     }
     // 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(TAdiantiCoreTranslator::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(TAdiantiCoreTranslator::translate('Delete'));
         $del->setImage('ico_delete.png');
         $can = new TButton("{$this->name}btnCancel");
         $can->setLabel(TAdiantiCoreTranslator::translate('Cancel'));
         $can->setImage('ico_close.png');
         $table = new TTable();
         $row = $table->addRow();
         $row->addCell($add);
         $row->addCell($del);
         $row->addCell($can);
         $table->show();
     }
     // 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->id = "{$this->name}mfTable";
     $head = new TElement('thead');
     $table->add($head);
     $row = new TTableRow();
     $head->add($row);
     // fill the MultiField DataGrid
     foreach ($this->fields as $obj) {
         $c = $obj->text;
         if (get_class($obj->field) == 'TComboCombined') {
             $row->addCell('ID');
         }
         $cell = $row->addCell($c);
         $cell->width = $obj->size . 'px';
     }
     $body = new TElement('tbody');
     $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);
             }
             foreach ($fields as $name) {
                 $cell = $row->addCell(is_null($obj->{$name}) ? '' : $obj->{$name});
                 if (isset($this->fields[$name]->size)) {
                     $cell->style = 'width:' . $this->fields[$name]->size . 'px';
                 }
             }
         }
     }
     $panel->add($table);
     $panel->show();
     echo '<script type="text/javascript">';
     echo "var mtf{$this->name};";
     //echo '$(document).ready(function() {';
     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";
     $fields = implode("','{$this->name}_", $fields);
     echo "mtf{$this->name}.formFieldsName = Array('{$this->name}_{$fields}');\n";
     echo "mtf{$this->name}.formPostFields = Array();\n";
     foreach ($post_fields as $col => $value) {
         echo "mtf{$this->name}.formPostFields['{$col}'] = '{$value}';\n";
     }
     $mdr = implode(',', $mdr);
     echo "mtf{$this->name}.formFieldsMandatory = Array({$mdr});\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 '});';
     echo '</script>';
 }
 /**
  * Shows the DataGrid
  */
 function show()
 {
     TPage::include_css('lib/adianti/include/tdatagrid/tdatagrid.css');
     // shows the datagrid
     parent::show();
     $params = $_REQUEST;
     unset($params['class']);
     unset($params['method']);
     // to keep browsing parameters (order, page, first_page, ...)
     $urlparams = '&' . http_build_query($params);
     // inline editing treatment
     $script = new TElement('script');
     $script->add('$(function() {
     	$(".inlineediting").editInPlace({
     		callback: function(unused, enteredText)
     		{
     		    __adianti_load_page($(this).attr("action")+"' . $urlparams . '&key="+$(this).attr("key")+"&field="+$(this).attr("field")+"&value="+encodeURIComponent(enteredText));
     		    return enteredText;
     		},
     		show_buttons: false,
     		text_size:20,
     		params:column=name
 	    });
     });');
     $script->show();
 }
 /**
  * Show the notebook at the screen
  */
 public function show()
 {
     // includes the CSS and JavaScript functions to handle notebooks
     TPage::include_css('lib/adianti/include/tnotebook/tnotebook.css');
     TPage::include_js('lib/adianti/include/tnotebook/tnotebook.js');
     // count the pages
     $pages = $this->getPageCount();
     // creates a table
     $note_table = new TTable();
     $note_table->{'width'} = $this->width;
     $note_table->{'border'} = 0;
     $note_table->{'cellspacing'} = 0;
     $note_table->{'cellpadding'} = 0;
     $note_table->{'class'} = 'notebook-table';
     // add a row for the tabs
     $row = $note_table->addRow();
     $i = 0;
     $id = $this->id;
     // get javascript code to show/hide sub-notebooks
     $subnotes_hide = $this->_getHideCode();
     $subnotes_show = $this->_getShowCode();
     if ($this->pages) {
         // iterate the tabs, showing them
         foreach ($this->pages as $title => $content) {
             // verify if the current page is to be shown
             $classe = $i == $this->currentPage ? 'tnotebook_aba_sim' : 'tnotebook_aba_nao';
             // add a cell for this tab
             if ($this->tabsVisibility) {
                 $cell = $row->addCell("&nbsp;{$title}&nbsp;");
                 $cell->{'class'} = $classe;
                 $cell->id = "aba_{$id}_{$i}";
                 $cell->height = '23px';
                 $cell->onclick = $subnotes_hide . "tnotebook_hide({$id}, {$pages});" . "tnotebook_show_tab({$id},{$i});" . $this->getShowPageCode($title);
                 // show only this page sub-contents
                 if ($this->tabAction) {
                     $this->tabAction->setParameter('current_page', $i + 1);
                     $string_action = $this->tabAction->serialize(FALSE);
                     $cell->onclick = $cell->onclick . "ajaxExec('{$string_action}')";
                 }
                 $cell->onmouseover = "javascript:tnotebook_prelight(this, {$id}, {$i})";
                 $cell->onmouseout = "javascript:tnotebook_unprelight(this, {$id}, {$i})";
                 // creates the cell spacer
                 $cell = $row->addCell('&nbsp;');
                 $cell->{'class'} = 'tnotebook_spacer';
                 $cell->width = '3px';
                 $i++;
             }
         }
     }
     // creates the cell terminator
     $cell = $row->addCell('&nbsp;');
     $cell->{'class'} = 'tnotebook_end';
     if ($this->tabsVisibility) {
         $row = $note_table->addRow();
         $row->height = '7px';
         $cell = $row->addCell('<span></span>');
         $cell->{'class'} = 'tnotebook_down';
         $cell->colspan = 100;
     }
     // show the table
     $note_table->show();
     // creates a <div> around the content
     $quadro = new TElement('div');
     $quadro->{'class'} = 'tnotebook_quadro';
     $width = $this->width - 7;
     $quadro->style = "height:{$this->height}px;width:{$width}px";
     if ($this->id == 1) {
         self::$subNotes = $this->_getSubNotes();
     }
     $i = 0;
     // iterate the tabs again, now to show the content
     if ($this->pages) {
         foreach ($this->pages as $title => $content) {
             // verify if the current page is to be shown
             if ($i == $this->currentPage and ($this->id == 1 or in_array($this->id, self::$subNotes))) {
                 $classe = 'tnotebook_painel_sim';
             } else {
                 $classe = 'tnotebook_painel_nao';
             }
             // creates a <div> for the contents
             $painel = new TElement('div');
             $painel->{'class'} = $classe;
             // CSS
             $painel->id = "painel_{$id}_{$i}";
             // ID
             $quadro->add($painel);
             // check if the content is an object
             if (is_object($content)) {
                 $painel->add($content);
             }
             $i++;
         }
     }
     $quadro_table = new TTable();
     $quadro_table->width = $this->width;
     $quadro_table->{'class'} = 'tnotebook_table';
     $quadro_table->border = 0;
     $quadro_table->cellspacing = 0;
     $quadro_table->cellpadding = 0;
     $row = $quadro_table->addRow();
     $row->addCell($quadro);
     $quadro_table->show();
 }
$tabela = new TTable();
$tabela->border = 1;
// acrescenta uma linha na tabela
$linha1 = $tabela->addRow();
// cria um objeto parágrafo
$paragrafo = new TParagraph('Este é o logo do GNOME');
$paragrafo->setAlign('left');
// adiciona célula contendo o objeto
$linha1->addCell($paragrafo);
// cria um objeto imagem
$imagem = new Timage('app.images/gnome.png');
$linha1->addCell($imagem);
// acrescenta uma linha na tabela
$linha2 = $tabela->addRow();
// cria um objeto parágrafo
$paragrafo = new TParagraph('Este é o logo do GIMP');
$paragrafo->setAlign('left');
// adiciona célula contendo o objeto
$linha2->addCell($paragrafo);
// cria um objeto imagem
$imagem = new Timage('app.images/gimp.png');
// adiciona célula contendo o objeto
$linha2->addCell($imagem);
// acrescenta uma linha na tabela
$linha3 = $tabela->addRow();
// acrescenta um célula que ocupará o espaço de duas
$celula = $linha3->addCell(new TParagraph('texto em duas colunas'));
$celula->colspan = 2;
// exibe a tabela
$tabela->show();