Esempio n. 1
1
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     $table = new TTable();
     $table->width = '100%';
     // creates the form
     $this->form = new TForm('form_User');
     $this->form->class = 'tform';
     $this->form->style = 'width: 450px;margin:auto; margin-top:120px;';
     // add the notebook inside the form
     $this->form->add($table);
     // create the form fields
     $login = new TEntry('prontuario');
     $password = new TPassword('senha');
     // define the sizes
     $login->setSize(320, 40);
     $password->setSize(320, 40);
     $login->style = 'height:35px; font-size:14px;float:left;border-bottom-left-radius: 0;border-top-left-radius: 0;';
     $password->style = 'height:35px;margin-bottom: 15px;font-size:14px;float:left;border-bottom-left-radius: 0;border-top-left-radius: 0;';
     $row = $table->addRow();
     $row->addCell(new TLabel('Login'))->colspan = 2;
     $row->class = 'tformtitle';
     $login->placeholder = 'Prontuário';
     $password->placeholder = 'Senha';
     $user = '******';
     $locker = '<span style="float:left;width:35px;margin-left:45px;height:35px;" class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>';
     $container1 = new TElement('div');
     $container1->add($user);
     $container1->add($login);
     $container2 = new TElement('div');
     $container2->add($locker);
     $container2->add($password);
     $row = $table->addRow();
     $row->addCell($container1)->colspan = 2;
     // add a row for the field password
     $row = $table->addRow();
     $row->addCell($container2)->colspan = 2;
     // create an action button (save)
     $save_button = new TButton('save');
     // define the button action
     $save_button->setAction(new TAction(array($this, 'onLogin')), _t('Log in'));
     $save_button->class = 'btn btn-success btn-defualt';
     $save_button->style = 'margin-left:32px;width:355px;height:40px;border-radius:6px;font-size:18px';
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($save_button);
     $cell->colspan = 2;
     $this->form->setFields(array($login, $password, $save_button));
     // add the form to the page
     parent::add($this->form);
 }
Esempio n. 2
1
 /**
  * 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}' );");
 }
Esempio n. 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            });");
 }
Esempio n. 4
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} );");
 }
Esempio n. 5
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);
         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();
 }
Esempio n. 6
0
 /**
  * Set Legend
  * @param  $legend frame legend
  */
 public function setLegend($legend)
 {
     $obj = new TElement('legend');
     $obj->add(new TLabel($legend));
     parent::add($obj);
     $this->legend = $legend;
 }
Esempio n. 7
0
 /**
  * Add an child element
  * @param $child Any object that implements the show() method
  */
 public function add($child)
 {
     $wrapper = new TElement('div');
     $wrapper->{'style'} = 'display:inline-block;';
     $wrapper->add($child);
     parent::add($wrapper);
     return $wrapper;
 }
Esempio n. 8
0
 /**
  * Add a new row (TTableRow object) to the table
  * @return TTableRow
  */
 public function addRow()
 {
     // creates a new Table Row
     $row = new TTableRow();
     // add this row to the table element
     parent::add($row);
     return $row;
 }
Esempio n. 9
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();
 }
Esempio n. 10
0
 /**
  * Add an child element
  * @param $child Any object that implements the show() method
  */
 public function add($child)
 {
     $wrapper = new TElement('div');
     $wrapper->{'style'} = 'clear:both';
     $wrapper->add($child);
     parent::add($wrapper);
     return $wrapper;
 }
Esempio n. 11
0
 /**
  * Put a widget inside the panel
  * @param  $widget = widget to be shown
  * @param  $col    = column in pixels.
  * @param  $row    = row in pixels.
  */
 public function put($widget, $col, $row)
 {
     // creates a layer to put the widget inside
     $layer = new TElement('div');
     // define the layer position
     $layer->style = "position:absolute; left:{$col}px; top:{$row}px;";
     // add the widget to the layer
     $layer->add($widget);
     // add the widget to the container
     parent::add($layer);
 }
Esempio n. 12
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(); ");
     }
 }
Esempio n. 13
0
 /**
  * Add a new cell (TTableCell) to the Table Row
  * @param  $value Cell Content
  * @return TTableCell
  */
 public function addCell($value)
 {
     if (is_null($value)) {
         throw new Exception(AdiantiCoreTranslator::translate('Method ^1 does not accept null values', __METHOD__));
     } else {
         // creates a new Table Cell
         $cell = new TTableCell($value);
         parent::add($cell);
         // returns the cell object
         return $cell;
     }
 }
Esempio n. 14
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;
 }
Esempio n. 15
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();
 }
Esempio n. 16
0
 /**
  * Build a MenuBar from a XML file
  * @param $xml_file path for the file
  * @param $permission_callback check permission callback
  */
 public static function newFromXML($xml_file, $permission_callback = NULL, $bar_class = 'nav navbar-nav', $menu_class = 'dropdown-menu', $item_class = '')
 {
     if (file_exists($xml_file)) {
         $menu_string = file_get_contents($xml_file);
         if (utf8_encode(utf8_decode($menu_string)) == $menu_string) {
             $xml = new SimpleXMLElement($menu_string);
         } else {
             $xml = new SimpleXMLElement(utf8_encode($menu_string));
         }
         $menubar = new TMenuBar();
         $menubar->{'class'} = $bar_class;
         foreach ($xml as $xmlElement) {
             $atts = $xmlElement->attributes();
             $label = (string) $atts['label'];
             $action = (string) $xmlElement->action;
             $icon = (string) $xmlElement->icon;
             $button_div = new TElement('div');
             $button_div->{'class'} = 'btn-group';
             $button = new TElement('button');
             $button->{'data-toggle'} = 'dropdown';
             $button->{'class'} = 'btn btn-default dropdown-toggle';
             $button->add($label);
             $span = new TElement('span');
             $span->{'class'} = 'caret';
             $span->add('');
             $button->add($span);
             $menu = new TMenu($xmlElement->menu->menuitem, $permission_callback, 1, $menu_class, $item_class);
             // check children count (permissions)
             if (count($menu->getMenuItems()) > 0) {
                 $button_div->add($button);
                 $button_div->add($menu);
                 $menubar->add($button_div);
             }
         }
         return $menubar;
     }
 }
Esempio n. 17
0
 /**
  * Add an item
  * @param $path Path to be shown
  * @param $last If the item is the last one
  */
 public function addItem($path, $last = FALSE)
 {
     $li = new TElement('li');
     $this->container->add($li);
     $span = new TElement('span');
     $span->add($path);
     $this->items[$path] = $span;
     if ($last) {
         $li->add($span);
     } else {
         $a = new TElement('a');
         $li->add($a);
         $a->add($span);
     }
 }
Esempio n. 18
0
 /**
  * Class Constructor
  * @param $type    Type of the alert (success, info, warning, danger)
  * @param $message Message to be shown
  */
 public function __construct($type, $message)
 {
     parent::__construct('div');
     $this->{'class'} = 'talert alert alert-dismissible alert-' . $type;
     $this->{'role'} = 'alert';
     $button = new TElement('button');
     $button->{'type'} = 'button';
     $button->{'class'} = 'close';
     $button->{'data-dismiss'} = 'alert';
     $button->{'aria-label'} = 'Close';
     $span = new TElement('span');
     $span->{'aria-hidden'} = 'true';
     $span->add('&times;');
     $button->add($span);
     parent::add($button);
     parent::add($message);
 }
Esempio n. 19
0
 /**
  * Class Constructor
  * @param  $value text label
  */
 public function __construct($label = '')
 {
     parent::__construct('div');
     $this->{'id'} = 'texpander_' . uniqid();
     $this->{'class'} = 'dropdown';
     $this->button = new TElement('button');
     $this->button->{'class'} = 'btn btn-default dropdown-toggle';
     $this->button->{'type'} = 'button';
     $this->button->{'id'} = 'button_' . uniqid();
     $this->button->{'data-toggle'} = 'dropdown';
     $this->button->add($label);
     $this->container = new TElement('ul');
     $this->container->{'class'} = 'dropdown-menu texpander-container';
     $this->container->{'style'} = 'z-index: inherit';
     $this->container->{'role'} = 'menu';
     $this->container->{'aria-labelledby'} = $this->button->{'id'};
     parent::add($this->button);
     parent::add($this->container);
 }
Esempio n. 20
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});");
 }
Esempio n. 21
0
 /**
  * Class Constructor
  * @param $source Image path, of bs:bs-glyphicon, fa:font-awesome
  */
 public function __construct($source)
 {
     if (substr($source, 0, 3) == 'bs:') {
         parent::__construct('span');
         $this->class = 'glyphicon glyphicon-' . substr($source, 3);
         parent::add('');
     } else {
         if (substr($source, 0, 3) == 'fa:') {
             parent::__construct('span');
             $this->class = 'fa fa-' . substr($source, 3);
             parent::add('');
         } else {
             if (file_exists($source)) {
                 parent::__construct('img');
                 // assign the image path
                 $this->src = $source;
                 $this->border = 0;
             } else {
                 if (file_exists("app/images/{$source}")) {
                     parent::__construct('img');
                     // assign the image path
                     $this->src = "app/images/{$source}";
                     $this->border = 0;
                 } else {
                     if (file_exists("lib/adianti/images/{$source}")) {
                         parent::__construct('img');
                         // assign the image path
                         $this->src = "lib/adianti/images/{$source}";
                         $this->border = 0;
                     } else {
                         parent::__construct('span');
                     }
                 }
             }
         }
     }
 }
Esempio n. 22
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();
 }
Esempio n. 23
0
 /**
  * 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} ) ");
 }
Esempio n. 24
0
 /**
  * Add an object to the DataGrid
  * @param $object An Active Record Object
  */
 public function addItem($object)
 {
     if ($this->modelCreated) {
         if ($this->groupColumn and (is_null($this->groupContent) or $this->groupContent !== $object->{$this->groupColumn})) {
             $row = new TElement('tr');
             $row->{'class'} = 'tdatagrid_group';
             $this->tbody->add($row);
             $cell = new TElement('td');
             $cell->add($this->replace($this->groupMask, $object));
             $cell->colspan = count($this->actions) + count($this->action_groups) + count($this->columns);
             $row->add($cell);
             $this->groupContent = $object->{$this->groupColumn};
         }
         // define the background color for that line
         $classname = $this->rowcount % 2 == 0 ? 'tdatagrid_row_even' : 'tdatagrid_row_odd';
         $row = new TElement('tr');
         $this->tbody->add($row);
         $row->{'class'} = $classname;
         if ($this->actions) {
             // iterate the actions
             foreach ($this->actions as $action) {
                 $this->prepareAction($action, $object);
                 // validate action
                 // get the action properties
                 $label = $action->getLabel();
                 $image = $action->getImage();
                 $condition = $action->getDisplayCondition();
                 if (empty($condition) or call_user_func($condition, $object)) {
                     $url = $action->serialize();
                     $first_url = isset($first_url) ? $first_url : $url;
                     // creates a link
                     $link = new TElement('a');
                     $link->href = $url;
                     $link->generator = 'adianti';
                     // verify if the link will have an icon or a label
                     if ($image) {
                         $image_tag = new TImage($image);
                         $image_tag->title = $label;
                         $link->add($image_tag);
                     } else {
                         // add the label to the link
                         $span = new TElement('span');
                         $span->{'class'} = 'btn btn-default';
                         $span->add($label);
                         $link->add($span);
                     }
                 } else {
                     $link = '';
                 }
                 // add the cell to the row
                 $cell = new TElement('td');
                 $row->add($cell);
                 $cell->add($link);
                 $cell->width = '16px';
                 $cell->{'class'} = 'tdatagrid_cell action';
             }
         }
         if ($this->action_groups) {
             foreach ($this->action_groups as $action_group) {
                 $actions = $action_group->getActions();
                 $headers = $action_group->getHeaders();
                 $separators = $action_group->getSeparators();
                 if ($actions) {
                     $dropdown = new TDropDown($action_group->getLabel(), $action_group->getIcon());
                     $last_index = 0;
                     foreach ($actions as $index => $action) {
                         // add intermediate headers and separators
                         for ($n = $last_index; $n < $index; $n++) {
                             if (isset($headers[$n])) {
                                 $dropdown->addHeader($headers[$n]);
                             }
                             if (isset($separators[$n])) {
                                 $dropdown->addSeparator();
                             }
                         }
                         // get the action properties
                         $label = $action->getLabel();
                         $image = $action->getImage();
                         $condition = $action->getDisplayCondition();
                         if (empty($condition) or call_user_func($condition, $object)) {
                             $this->prepareAction($action, $object);
                             // validate action
                             $url = $action->serialize();
                             $first_url = isset($first_url) ? $first_url : $url;
                             $dropdown->addAction($label, $action, $image);
                         }
                         $last_index = $index;
                     }
                     // add the cell to the row
                     $cell = new TElement('td');
                     $row->add($cell);
                     $cell->add($dropdown);
                     $cell->{'class'} = 'tdatagrid_cell action';
                 }
             }
         }
         if ($this->columns) {
             // iterate the DataGrid columns
             foreach ($this->columns as $column) {
                 // get the column properties
                 $name = $column->getName();
                 $align = $column->getAlign();
                 $width = $column->getWidth();
                 $function = $column->getTransformer();
                 $content = $object->{$name};
                 $data = is_null($content) ? '' : $content;
                 // verify if there's a transformer function
                 if ($function) {
                     // apply the transformer functions over the data
                     $data = call_user_func($function, $data, $object, $row);
                 }
                 if ($editaction = $column->getEditAction()) {
                     $editaction_field = $editaction->getField();
                     $div = new TElement('div');
                     $div->{'class'} = 'inlineediting';
                     $div->{'style'} = 'padding-left:5px;padding-right:5px';
                     $div->{'action'} = $editaction->serialize();
                     $div->{'field'} = $name;
                     $div->{'key'} = isset($object->{$editaction_field}) ? $object->{$editaction_field} : NULL;
                     $div->add($data);
                     $cell = new TElement('td');
                     $row->add($cell);
                     $cell->add($div);
                     $cell->{'class'} = 'tdatagrid_cell';
                 } else {
                     // add the cell to the row
                     $cell = new TElement('td');
                     $row->add($cell);
                     $cell->add($data);
                     $cell->{'class'} = 'tdatagrid_cell';
                     $cell->align = $align;
                     if (isset($first_url) and $this->defaultClick) {
                         $cell->href = $first_url;
                         $cell->generator = 'adianti';
                         $cell->{'class'} = 'tdatagrid_cell';
                     }
                 }
                 if ($width) {
                     $cell->width = $width . 'px';
                 }
             }
         }
         if ($this->popover) {
             $data = method_exists($object, 'toArray') ? $object->toArray() : (array) $object;
             $poptitle = $this->poptitle;
             $popcontent = $this->popcontent;
             foreach ($data as $property => $value) {
                 $poptitle = str_replace('{' . $property . '}', $value, $poptitle);
                 $popcontent = str_replace('{' . $property . '}', $value, $popcontent);
             }
             $row->popover = 'true';
             $row->poptitle = $poptitle;
             $row->popcontent = $popcontent;
         }
         $this->objects[$this->rowcount] = $object;
         // increments the row counter
         $this->rowcount++;
         return $row;
     } else {
         throw new Exception(AdiantiCoreTranslator::translate('You must call ^1 before ^2', 'createModel', __METHOD__));
     }
 }
Esempio n. 25
0
 /**
  * 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();
 }
Esempio n. 26
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();
 }
Esempio n. 27
0
 /**
  * Class Constructor
  * @param $value  TableCell content
  */
 public function __construct($value)
 {
     parent::__construct('td');
     parent::add($value);
 }
Esempio n. 28
0
 /**
  * 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>';
 }
Esempio n. 29
0
 /**
  * Shows the widget
  */
 public function show()
 {
     $tag = new TEntry($this->name);
     $tag->setEditable(FALSE);
     $tag->setProperty('id', $this->name);
     $tag->setSize(40);
     $tag->setProperty('onchange', "aux = document.getElementsByName('{$this->text_name}'); aux[0].value = this.value;");
     $tag->show();
     // define the tag properties
     $this->tag->name = $this->text_name;
     $this->tag->onchange = "aux_entry = document.getElementById('{$this->name}'); aux_entry.value = this.value;";
     $this->setProperty('style', "width:{$this->size}px", FALSE);
     //aggregate style info
     $this->tag->auxiliar = 1;
     // creates an empty <option> tag
     $option = new TElement('option');
     $option->add('');
     $option->value = '0';
     // valor da TAG
     // add the option tag to the combo
     $this->tag->add($option);
     if ($this->items) {
         // iterate the combobox items
         foreach ($this->items as $chave => $item) {
             // creates an <option> tag
             $option = new TElement('option');
             $option->value = $chave;
             // define the index
             $option->add($item);
             // add the item label
             // verify if this option is selected
             if ($chave == $this->value) {
                 // mark as selected
                 $option->selected = 1;
             }
             // add the option to the combo
             $this->tag->add($option);
         }
     }
     // verify whether the widget is editable
     if (!parent::getEditable()) {
         // make the widget read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }
Esempio n. 30
0
 /**
  * Shows the widget
  */
 public function show()
 {
     // define the tag properties
     $this->tag->name = $this->name;
     // tag name
     if ($this->id) {
         $this->tag->id = $this->id;
     }
     if (strstr($this->size, '%') !== FALSE) {
         $this->setProperty('style', "width:{$this->size};", false);
         //aggregate style info
     } else {
         $this->setProperty('style', "width:{$this->size}px;", false);
         //aggregate style info
     }
     if ($this->defaultOption !== FALSE) {
         // creates an empty <option> tag
         $option = new TElement('option');
         $option->add($this->defaultOption);
         $option->value = '';
         // tag value
         // add the option tag to the combo
         $this->tag->add($option);
     }
     if ($this->items) {
         // iterate the combobox items
         foreach ($this->items as $chave => $item) {
             if (substr($chave, 0, 3) == '>>>') {
                 $optgroup = new TElement('optgroup');
                 $optgroup->label = $item;
                 // add the option to the combo
                 $this->tag->add($optgroup);
             } else {
                 // creates an <option> tag
                 $option = new TElement('option');
                 $option->value = $chave;
                 // define the index
                 $option->add($item);
                 // add the item label
                 // verify if this option is selected
                 if ($chave == $this->value and $this->value !== NULL) {
                     // mark as selected
                     $option->selected = 1;
                 }
                 if (isset($optgroup)) {
                     $optgroup->add($option);
                 } else {
                     $this->tag->add($option);
                 }
             }
         }
     }
     // verify whether the widget is 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);
             $this->setProperty('changeaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)");
             $this->setProperty('onChange', $this->getProperty('changeaction'));
         }
     } else {
         // make the widget read-only
         //$this->tag-> disabled   = "1"; // the value don't post
         $this->tag->{'onclick'} = "return false;";
         $this->tag->{'style'} .= ';pointer-events:none';
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }