/**
  * Define o ID para carregar o conteudo dinamicamente
  * @param $id ID a ser carregada
  * @param $getContentAjax Campo a ser carregado via ajax
  */
 public function setAction(TAction $action, $getContentAjax = null)
 {
     if (is_null($getContentAjax)) {
         $this->action = '__adianti_load_page(\'' . $action->serialize() . '\');';
     } else {
         $this->action = '__adianti_load_page(\'' . $action->serialize() . '&' . $getContentAjax . '=\'+$("#' . $getContentAjax . '").val());';
     }
 }
示例#2
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to be processed when closing the dialog
  */
 public function __construct($type, $message, TAction $action = NULL)
 {
     $this->id = uniqid();
     if ($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(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->{'type'} = 'text/javascript';
         $script->add(' $(function() {
             $( "#' . $painel->id . '" ).dialog({
                 height: 340,
                 width: 500,
                 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();
     }
 }
 /**
  * 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();
 }
示例#4
0
 /**
  * Show the widget
  */
 public function show()
 {
     // check if it's not editable
     if (parent::getEditable()) {
         $serialized_action = '';
         if ($this->action) {
             // get the action class name
             if (is_array($callback = $this->action->getAction())) {
                 $classname = get_class($callback[0]);
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if ($classname == 'TStandardSeek') {
                     $ajaxAction->setParameter('parent', $this->action->getParameter('parent'));
                     $ajaxAction->setParameter('database', $this->action->getParameter('database'));
                     $ajaxAction->setParameter('model', $this->action->getParameter('model'));
                     $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field'));
                     $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key'));
                     $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field'));
                 }
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n                                                      ajaxLookup('{$string_action}&'+serialform, this)");
                 }
             }
             $serialized_action = $this->action->serialize(FALSE);
         }
         parent::show();
         $image = new TImage('lib/adianti/images/ico_find.png');
         $link = new TElement('a');
         $link->onmouseover = 'style.cursor = \'pointer\'';
         $link->onmouseout = 'style.cursor = \'default\'';
         $link->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n                  __adianti_append_page('engine.php?{$serialized_action}&'+serialform)";
         $link->add($image);
         $link->show();
         if ($this->auxiliar) {
             echo ' ';
             $this->auxiliar->show();
         }
     } else {
         parent::show();
     }
 }
示例#5
0
 function __construct()
 {
     parent::__construct();
     //Cria uma Tabela
     $this->table = new TTable();
     //Define as propriedades da Tabela
     $this->table->border = 1;
     $this->table->width = 500;
     $this->table->style = 'border-collapse:collapse';
     //Adiciona uma linha na tabela
     $row = $this->table->addRow();
     //Cria tres Ações
     $action1 = new TAction(array($this, 'onProdutos'));
     $action2 = new TAction(array($this, 'onContatos'));
     $action3 = new TAction(array($this, 'onEmpresa'));
     //Cria tres Links
     $link1 = new TElement('a');
     $link2 = new TElement('a');
     $link3 = new TElement('a');
     //Define Ação dos Links
     $link1->href = $action1->serialize();
     $link2->href = $action2->serialize();
     $link3->href = $action3->serialize();
     //Define o Rotulo dos Links
     $link1->add('Produtos');
     $link2->add('Contatos');
     $link3->add('Empresa');
     //Adiciona os Links na Linha
     //Logo serão Criadas 3 Linhas
     $row->addCell($link1);
     $row->addCell($link2);
     $row->addCell($link3);
     //Cria uma linha para o Conteudo
     //Cria uma linha e atribui a referencia a $content
     $this->content = $this->table->addRow();
     //Adiciona a tabela na pagina
     parent::add($this->table);
 }
 /**
  * método __construct()
  * instancia uma nova página
  */
 function __construct()
 {
     parent::__construct();
     // cria uma tabela
     $this->table = new TTable();
     // define algumas propriedades para tabela
     $this->table->border = 1;
     $this->table->width = 500;
     $this->table->style = 'border-collapse:collapse';
     // adiciona uma linha na tabela
     $row = $this->table->addRow();
     $row->bgcolor = '#d0d0d0';
     // cria três ações
     $action1 = new TAction(array($this, 'onProdutos'));
     $action2 = new TAction(array($this, 'onContato'));
     $action3 = new TAction(array($this, 'onEmpresa'));
     // cria três links
     $link1 = new TElement('a');
     $link2 = new TElement('a');
     $link3 = new TElement('a');
     // define a ação dos links
     $link1->href = $action1->serialize();
     $link2->href = $action2->serialize();
     $link3->href = $action3->serialize();
     // define o rótulo de texto dos links
     $link1->add('Produtos');
     $link2->add('Contato');
     $link3->add('Empresa');
     // adiciona os links na linha
     $row->addCell($link1);
     $row->addCell($link2);
     $row->addCell($link3);
     // cria uma linha para conteúdo
     $this->content = $this->table->addRow();
     // adiciona a tabela na página
     parent::add($this->table);
 }
示例#7
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();
     }
 }
 /**
  * Converts the action into an URL
  * @param  $format_action = format action with document or javascript (ajax=no)
  */
 public function serialize($format_action = TRUE)
 {
     if (is_array($this->action) and is_object($this->action[0])) {
         if (isset($_REQUEST['offset'])) {
             $this->setParameter('offset', $_REQUEST['offset']);
         }
         if (isset($_REQUEST['limit'])) {
             $this->setParameter('limit', $_REQUEST['limit']);
         }
         if (isset($_REQUEST['page'])) {
             $this->setParameter('page', $_REQUEST['page']);
         }
         if (isset($_REQUEST['first_page'])) {
             $this->setParameter('first_page', $_REQUEST['first_page']);
         }
         if (isset($_REQUEST['order'])) {
             $this->setParameter('order', $_REQUEST['order']);
         }
     }
     return parent::serialize($format_action);
 }
 /**
  * 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 fade';
     $modal_wrapper->{'id'} = $this->id;
     $modal_wrapper->{'style'} = 'margin-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 : TAdiantiCoreTranslator::translate('Question'));
     $body = new TElement('div');
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'display'} = 'block';
     $span->{'style'} = 'margin-left:20px;float:left';
     $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->add(TAdiantiCoreTranslator::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->add(TAdiantiCoreTranslator::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(TAdiantiCoreTranslator::translate('No'));
         $footer->add($button);
     }
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->add(TAdiantiCoreTranslator::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();
     $script = new TElement('script');
     $script->{'type'} = 'text/javascript';
     $script->add(' $(document).ready(function() {
         $("#' . $this->id . '").modal({backdrop:true, keyboard:true});
         });');
     $script->show();
 }
 /**
  * Show the widget
  */
 public function show()
 {
     // check if it's not editable
     if (parent::getEditable()) {
         if (!TForm::getFormByName($this->formName) instanceof TForm) {
             throw new Exception(TAdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
         }
         $serialized_action = '';
         if ($this->action) {
             // get the action class name
             if (is_array($callback = $this->action->getAction())) {
                 $classname = is_object($callback[0]) ? get_class($callback[0]) : $callback[0];
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if ($classname == 'TStandardSeek') {
                     $ajaxAction->setParameter('parent', $this->action->getParameter('parent'));
                     $ajaxAction->setParameter('database', $this->action->getParameter('database'));
                     $ajaxAction->setParameter('model', $this->action->getParameter('model'));
                     $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field'));
                     $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key'));
                     $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field'));
                 }
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('seekaction', "serialform=(\$('#{$this->formName}').serialize());\n                                                         ajaxLookup('{$string_action}&'+serialform, document.{$this->formName}.{$this->name})");
                     $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE);
                 }
             }
             $serialized_action = $this->action->serialize(FALSE);
         }
         parent::show();
         $this->button->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n                  __adianti_append_page('engine.php?{$serialized_action}&'+serialform)";
         $this->button->show();
         if ($this->auxiliar) {
             echo ' ';
             $this->auxiliar->show();
         }
     } else {
         parent::show();
     }
 }
示例#11
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to be processed when closing the dialog
  * @param $title_msg  Dialog Title
  */
 public function __construct($type, $message, TAction $action = NULL, $title_msg = '')
 {
     $this->id = uniqid();
     $modal_wrapper = new TElement('div');
     $modal_wrapper->{'class'} = 'modal fade';
     $modal_wrapper->{'id'} = $this->id;
     $modal_wrapper->{'style'} = 'margin-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' ? TAdiantiCoreTranslator::translate('Information') : TAdiantiCoreTranslator::translate('Error')));
     $body = new TElement('div');
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'display'} = 'block';
     $span->{'style'} = 'margin-left:20px;float:left';
     $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');";
     $button->add('OK');
     if ($action) {
         $button->{'onclick'} = "__adianti_load_page('{$action->serialize()}');";
         unset($button->{'data-dismiss'});
         $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();
     $script = new TElement('script');
     $script->{'type'} = 'text/javascript';
     $script->add(' $(document).ready(function() {
         $("#' . $this->id . '").modal({backdrop:true, keyboard:true});
         });');
     $script->show();
 }
<?php

include_once 'app.widgets/TAction.class.php';
class Receptor
{
    function acao($parameter)
    {
        echo "Aчуo executada com sucesso\n<br>";
    }
}
$receptor = new Receptor();
$action1 = new TAction(array($receptor, 'acao'));
$action1->setParameter('nome', 'pablo');
echo $action1->serialize();
echo "<br>\n";
$action2 = new TAction('strtoup');
$action2->setParameter('nome', 'pablo');
echo $action2->serialize();
示例#13
0
<?php

/* Abstração e Emcapsulamento do envio dos controles
* page1.php?method=olaMundo&nome=Ricardo
* page1.php?class=Clientes&method=listar
* Pela Classe TAction
*/
include_once '../app.widgets/TAction.class.php';
class pessoa
{
    private $nome;
    function setNome($parametro)
    {
        echo 'setNome executado<br />';
    }
}
function printName($parametro)
{
    echo 'printName executado<br />';
}
$objPessoa = new pessoa();
$action1 = new TAction(array($objPessoa, 'setNome'));
$action1->setParameter('nome', 'Bill');
echo $action1->serialize() . '<br />';
$action2 = new TAction('printName');
$action2->setParameter('nome', 'Jobs');
echo $action2->serialize() . '<br />';