Пример #1
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to be processed when closing the dialog
  * @param $title_msg  Dialog Title
  */
 public function __construct($type, $message, TAction $action = NULL, $title_msg = '')
 {
     $this->id = 'tmessage_' . mt_rand(1000000000, 1999999999);
     $modal_wrapper = new TElement('div');
     $modal_wrapper->{'class'} = 'modal';
     $modal_wrapper->{'id'} = $this->id;
     $modal_wrapper->{'style'} = 'padding-top: 10%; z-index:4000';
     $modal_wrapper->{'tabindex'} = '-1';
     $modal_dialog = new TElement('div');
     $modal_dialog->{'class'} = 'modal-dialog';
     $modal_content = new TElement('div');
     $modal_content->{'class'} = 'modal-content';
     $modal_header = new TElement('div');
     $modal_header->{'class'} = 'modal-header';
     if ($type == 'info') {
         $image = new TImage("fa:fa fa-info-circle fa-5x blue");
     } else {
         $image = new TImage("fa:fa fa-exclamation-circle fa-5x red");
     }
     $image->{'style'} = 'float:left; margin-right: 10px;';
     $close = new TElement('button');
     $close->{'type'} = 'button';
     $close->{'class'} = 'close';
     $close->{'data-dismiss'} = 'modal';
     $close->{'aria-hidden'} = 'true';
     $close->add('×');
     $title = new TElement('h4');
     $title->{'class'} = 'modal-title';
     $title->{'style'} = 'display:inline';
     $title->add($title_msg ? $title_msg : ($type == 'info' ? AdiantiCoreTranslator::translate('Information') : AdiantiCoreTranslator::translate('Error')));
     $body = new TElement('div');
     $body->{'style'} = 'text-align:left';
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->add($message);
     $body->add($span);
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->{'onclick'} = "\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');";
     $button->add('OK');
     if ($action) {
         $button->{'onclick'} .= "__adianti_load_page('{$action->serialize()}');";
         $button->{'data-toggle'} = "modal";
     }
     $footer = new TElement('div');
     $footer->{'class'} = 'modal-footer';
     $modal_wrapper->add($modal_dialog);
     $modal_dialog->add($modal_content);
     $modal_content->add($modal_header);
     $modal_header->add($close);
     $modal_header->add($title);
     $modal_content->add($body);
     $modal_content->add($footer);
     $footer->add($button);
     $modal_wrapper->show();
     $callback = 'function () {' . $button->{'onclick'} . '}';
     TScript::create("tdialog_start( '#{$this->id}', {$callback} );");
 }
Пример #2
0
 /**
  * Add an action
  * @param $title  Title
  * @param $action Action
  * @param $icon   Icon
  */
 public function addAction($title, TAction $action, $icon = NULL)
 {
     $li = new TElement('li');
     $link = new TElement('a');
     // if ($action instanceof TScriptAction) => don't __load_page...
     $link->{'onclick'} = "__adianti_load_page('{$action->serialize()}');";
     $link->{'style'} = 'cursor: pointer';
     if ($icon) {
         $image = new TImage($icon);
         $image->{'style'} = 'padding: 4px';
         $link->add($image);
     }
     $span = new TElement('span');
     $span->add($title);
     $link->add($span);
     $li->add($link);
     $this->elements->add($li);
 }
Пример #3
0
 /**
  * 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(AdiantiCoreTranslator::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())) {
                 if (is_object($callback[0])) {
                     $rc = new ReflectionClass($callback[0]);
                     $classname = $rc->getShortName();
                 } else {
                     $classname = $callback[0];
                 }
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if (in_array($classname, array('TStandardSeek2'))) {
                     $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'));
                     $ajaxAction->setParameter('criteria', $this->action->getParameter('criteria'));
                     $ajaxAction->setParameter('display_field2', $this->action->getParameter('display_field2'));
                 } else {
                     if ($actionParameters = $this->action->getParameters()) {
                         foreach ($actionParameters as $key => $value) {
                             $ajaxAction->setParameter($key, $value);
                         }
                     }
                 }
                 $ajaxAction->setParameter('form_name', $this->formName);
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('seekaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name})");
                     $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE);
                 }
             }
             $this->action->setParameter('form_name', $this->formName);
             $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();
     }
 }
Пример #4
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
  * @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}' );");
 }
Пример #5
0
 /**
  * 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']);
         }
         if (parent::isStatic()) {
             $this->setParameter('static', '1');
         }
     }
     return parent::serialize($format_action);
 }