Exemplo n.º 1
0
 public function __construct($jar_url, $code_class, $width = 0, $height = 0)
 {
     parent::__construct('object');
     $this->set_code_class($code_class);
     $this->set_jar_url($jar_url);
     $this->set_width($width);
     $this->set_height($height);
     $this->_args = new Map();
     $this->set_error_string(self::$_DEFAULT_ERROR_STRING);
 }
 protected function _get_input_html(array $params = array())
 {
     $attrs_html = self::_get_attr_html($params);
     $input_html = "<{$this->_tagname}{$attrs_html}>";
     if ($this->get_default_option_enabled()) {
         $option_text = $this->get_default_option_text() ? $this->get_default_option_text() : \ZPHP\String::get($this->get_optional() ? 'not_specified' : 'select');
         $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'>" . \ZPHP\HTMLHelper::escape($option_text) . "</option>";
         $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'></option>";
     }
     foreach ($this->_options as $option) {
         $option_tag = new HTMLLongTag('option', \ZPHP\HTMLHelper::escape($option['label']));
         $option_tag->set_param('value', \ZPHP\HTMLHelper::escape($option['value']));
         if (!is_null($this->get_value()) && $option['value'] == $this->get_value()) {
             $option_tag->set_param('selected', true);
         }
         $input_html .= $option_tag;
     }
     $input_html .= "</{$this->_tagname}>";
     return $input_html;
 }
 protected function _get_input_html(array $params = array())
 {
     $title = $this->_get_title();
     $attrs_html = self::_get_attr_html($params);
     $input_html = "<{$this->_tagname}{$attrs_html}>";
     if ($this->get_default_option_enabled()) {
         $option_text = $this->get_default_option_text() ? $this->get_default_option_text() : \ZPHP\String::get($this->get_optional() ? 'not_specified' : 'select');
         $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'>" . \ZPHP\HTMLHelper::escape($option_text) . "</option>";
         $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'></option>";
     }
     foreach ($this->_options as $option) {
         $option_tag = new HTMLLongTag('option', \ZPHP\HTMLHelper::escape($option['label']));
         $option_tag->set_param('value', \ZPHP\HTMLHelper::escape($option['value']));
         if (!is_null($this->get_value()) && $option['value'] == $this->get_value()) {
             $option_tag->set_param('selected', true);
         }
         $input_html .= $option_tag;
     }
     $input_html .= "</{$this->_tagname}>";
     $js_id = \ZPHP\JSHelper::cast_str('#' . $this->_get_id());
     $js_container_class = \ZPHP\JSHelper::cast_str(self::$_SELECT2_CONTAINER_CLASS);
     $js_searching = \ZPHP\String::get_js('searching');
     $js_no_matches = \ZPHP\String::get_js('no_matches_found');
     $js_placeholder = $this->_get_title();
     if ((!array_key_exists('placeholder', $params) || !$params['placeholder']) && $this->get_use_title_label() && $title) {
         $js_placeholder = $title;
     }
     $js_placeholder = \ZPHP\JSHelper::cast_str($js_placeholder);
     $input_html .= "<script type='text/javascript'>\n\n\t\t\t\t//\$(document).ready(function () {\n\t\t\t\t\t\t\$({$js_id}).select2({\n\t\t\tcontainerCssClass: {$js_container_class},\n\t\t\tformatSearching: function() {\n\t\t\treturn {$js_searching};\n\t\t\t},\n\t\t\tformatNoMatches: function() {\n\t\t\treturn {$js_no_matches};\n\t\t\t},";
     if ($this->get_width()) {
         $input_html .= "width: " . \ZPHP\JSHelper::cast_str($this->get_width()) . ",";
     }
     $input_html .= "dropdownAutoWidth: true,\n\t\t\tminimumResultsForSearch: -1,\n\t\t\tescapeMarkup: function(s) { return s; },\n\t\t\tplaceholder: {$js_placeholder}\n\t\t\t});";
     /*$(<?=JSHelper::cast_str("#{$id}")?><!--).on('change', function() { --><?//=$tag_attrs['onchange']?><!-- });-->*/
     //		$input_html.= " }); ";
     $input_html .= "\n</script>";
     return $input_html;
 }
 /**
  *
  * @return HTMLTag
  *
  */
 public function add_action_link_icon($title, $icon_class, $onclick = null, $field = null)
 {
     $tag = new HTMLLongTag('a');
     $tag->set_content("<span class='icon {$icon_class}'> </span>");
     $tag->set_param('title', $title);
     $tag->set_param('href', 'javascript: void(0)');
     $this->_set_tag_onclick_function($tag, $onclick, $field);
     return $this->add_action_tag($tag);
 }
Exemplo n.º 5
0
 /**
  *
  * @return $this
  *
  */
 public function add_cancel_button($text = null, array $attrs = array(), $class = '')
 {
     $button = new HTMLLongTag('button', $text ? $text : \ZPHP\String::get_html('cancel'));
     $button->update_params($attrs);
     $button->set_param('type', 'button');
     $button->add_class($class);
     $button->add_class(self::$_DEFAULT_BUTTON_CLASS);
     $button->add_class(self::$_DEFAULT_BUTTON_CANCEL_CLASS);
     $this->_buttons[] = $button;
     if (!$button->get_id()) {
         $button->set_random_id();
     }
     $this->_cancel_buttons[] = $button->get_id();
     return $this;
 }
Exemplo n.º 6
0
 public function get_class()
 {
     $this->add_class($this->get_key() . ' column-' . $this->get_key());
     return parent::get_class();
 }
Exemplo n.º 7
0
 public static function page_entities()
 {
     $block = new HTML\HTMLLongTag('div');
     $form = new HTML\HTMLForm();
     $block->add_content($form);
     $form->set_id('tables-form');
     $form->action = '';
     $form->method = 'post';
     $form->add_content('<style type="text/css">#tables-form legend {font-weight: bold; border-bottom: solid 1px #333; } #tables-form div.table { border-bottom: solid 1px #CCC; padding: 0 0 20px 0; } #tables-form div.table input.text{ border: solid 1px #999; padding: 4px 3px; }</style>');
     $form->add_content('<style type="text/css">#tables-form .action .row { padding: 10px 20px; } </style>');
     $form->add_content('<style type="text/css">#tables-form .form-buttons { padding: 30px 0px; margin: 30px 0 0 0; border-top: solid 1px #444; text-align: right; background: #DDD; } #tables-form .form-buttons  button { margin: 0 40px 0 0; padding: 5px 30px; border: solid 1px #999;} </style>');
     $tables = \DB::select(\DB::raw('SHOW TABLES'));
     $form->open_fieldset('tables');
     $legend_buttons = new HTML\HTMLLongTag('div');
     $legend_buttons->add_style('float', 'right');
     $legend_buttons->add_style('font-size', '10pt');
     $check_all_button = new HTML\HTMLLongTag('a');
     $check_all_button->set_content('Check All');
     $check_all_button->href = 'javascript:void(0)';
     $check_all_button->onclick = "\$('.tables .checkbox').not(':checked').click()";
     $legend_buttons->add_content($check_all_button);
     $legend_buttons->add_content(' &nbsp; / &nbsp; ');
     $check_all_button = new HTML\HTMLLongTag('a');
     $check_all_button->set_content('Uncheck All');
     $check_all_button->href = 'javascript:void(0)';
     $check_all_button->onclick = "\$('.tables .checkbox').filter(':checked').click()";
     $legend_buttons->add_content($check_all_button);
     $form->add_legend('Tables' . $legend_buttons);
     foreach ($tables as $table) {
         $table_name = '';
         foreach ($table as $str) {
             $table_name = $str;
             break;
         }
         if (!in_array($table_name, self::$_PROTECTED_TABLES)) {
             $table_paths = self::_get_table_paths($table_name);
             $table_entity_name = $table_paths['entity']['name'];
             $table_repository_name = $table_paths['repository']['name'];
             $table_repository_database_name = $table_paths['repository_database']['name'];
             $entities_dir = self::_get_entities_dir();
             $dir = opendir($entities_dir);
             while ($phppath = readdir($dir)) {
                 if ($phppath != '.' && $phppath != '..') {
                     $phppath = $entities_dir . DIRECTORY_SEPARATOR . $phppath;
                     $phpcontents = file_get_contents($phppath);
                     if (preg_match('#(?i)protected\\s+\\$table\\s+\\=\\s+(\'|")(?P<table>.+?)(\'|\\")#', $phpcontents, $match)) {
                         if ($match['table'] == $table_name) {
                             if (preg_match('#(?i)class\\s+(?P<classname>.+?)\\s+#', $phpcontents, $match)) {
                                 $table_entity_name = $match['classname'];
                                 break;
                             }
                         }
                     }
                 }
             }
             closedir($dir);
             $repositories_dir = self::_get_repositories_dir();
             $dir = opendir($repositories_dir);
             while ($phppath = readdir($dir)) {
                 if ($phppath != '.' && $phppath != '..') {
                     $phppath = $repositories_dir . DIRECTORY_SEPARATOR . $phppath;
                     $phpcontents = file_get_contents($phppath);
                     if (preg_match('#(?i)const\\s+TABLE_NAME\\s+\\=\\s+(\'|")(?P<table>.+?)(\'|\\")#', $phpcontents, $match)) {
                         if ($match['table'] == $table_name) {
                             if (preg_match('#(?i)interface\\s+(?P<classname>.+?)\\s+#', $phpcontents, $match)) {
                                 $table_repository_name = $match['classname'];
                                 break;
                             }
                         }
                     }
                 }
             }
             closedir($dir);
             $repositories_database_dir = self::_get_repositories_database_dir();
             $dir = opendir($repositories_database_dir);
             while ($phppath = readdir($dir)) {
                 if ($phppath != '.' && $phppath != '..') {
                     $phppath = $repositories_database_dir . DIRECTORY_SEPARATOR . $phppath;
                     $phpcontents = file_get_contents($phppath);
                     if (preg_match('#(?i)class\\s+(?P<classname>.+?)\\s+extends\\s+.*?\\s+implements\\s+.*?\\\\' . preg_quote($table_repository_name) . '#', $phpcontents, $match)) {
                         $table_repository_database_name = $match['classname'];
                         break;
                     }
                 }
             }
             closedir($dir);
             $form->open_row('table');
             $checkbox = new HTML\HTMLInputCheckboxControl('tables[' . $table_name . ']', $table_name);
             $checkbox->get_label()->add_style('display', 'inline')->add_style('margin', '-3px 0 5px 10px')->add_style('vertical-align', 'top')->add_style('cursor', 'pointer');
             $checkbox->add_style('display', 'inline');
             $checkbox->onclick = "\$(" . JSHelper::cast_str('.table-' . $table_name) . ").attr({'disabled':!\$(this).is(':checked')});";
             $form->open_col_md(3);
             $form->add_content($checkbox);
             $text = new HTML\HTMLInputTextControl('tables[' . $table_name . '][entity]', $table_name, $table_entity_name);
             $text->set_show_label(false);
             $text->add_style('width', '100%');
             $text->add_class('table-' . $table_name);
             $text->disabled = true;
             $form->open_col_md(3);
             $form->add_content($text);
             $text = new HTML\HTMLInputTextControl('tables[' . $table_name . '][repository]', $table_name, $table_repository_name);
             $text->set_show_label(false);
             $text->add_style('width', '100%');
             $text->add_class('table-' . $table_name);
             $text->disabled = true;
             $form->open_col_md(3);
             $form->add_content($text);
             $text = new HTML\HTMLInputTextControl('tables[' . $table_name . '][repository_database]', $table_name, $table_repository_database_name);
             $text->set_show_label(false);
             $text->add_style('width', '100%');
             $text->add_class('table-' . $table_name);
             $text->disabled = true;
             $form->open_col_md(3);
             $form->add_content($text);
             $form->close_row();
         }
     }
     $form->open_fieldset('action');
     $form->add_legend('Action');
     $form->open_row();
     $checkbox = new HTML\HTMLInputRadioControl('action', 'Create Entities & Servicies', 'create');
     $checkbox->get_label()->add_style('display', 'inline')->add_style('margin', '-3px 0 5px 10px')->add_style('vertical-align', 'top')->add_style('cursor', 'pointer');
     $checkbox->add_style('display', 'inline');
     $checkbox->set_checked(true);
     $form->add_content($checkbox);
     $form->open_row();
     $checkbox = new HTML\HTMLInputRadioControl('action', 'Delete Tables', 'delete');
     $checkbox->get_label()->add_style('display', 'inline')->add_style('margin', '-3px 0 5px 10px')->add_style('vertical-align', 'top')->add_style('cursor', 'pointer');
     $checkbox->add_style('display', 'inline');
     $form->add_content($checkbox);
     $form->add_submit_cancel_buttons();
     $form->set_cancel_action('location.href = "' . \URL::route(self::URL_INDEX) . '";');
     return self::_prepare_page_html($block, 'Database Tables', \URL::route(self::URL_INDEX));
 }