protected function _get_input_html(array $params = array())
 {
     $attrs_html = self::_get_attr_html_exclude($params, array('onclick', 'onchange', 'value'));
     $checkbox_attrs_html = self::_get_attr_html_only($params, array('onclick', 'onchange'));
     $input_html = "<{$this->_tagname}{$attrs_html}>";
     if (!empty($this->_options)) {
         $list_html = array();
         $selected_value = $this->get_value();
         foreach ($this->_options as $option) {
             $option_tag = new HTMLInputRadioControl($this->get_name(), $option['label'], $option['value'], $option['value'] == $selected_value);
             $option_tag->update_params($checkbox_attrs_html);
             $option_tag->set_id($this->get_name() . '_' . $option['value']);
             $list_html[] = $option_tag->to_string();
         }
         $need_count = ceil(count($list_html) / $this->_columns) * $this->_columns;
         while (count($list_html) < $need_count) {
             $list_html[] = self::$_DEFAULT_FILL_CELL_HTML;
         }
         $col_md = floor(12 / $this->_columns);
         $table = array();
         $row = array();
         foreach ($list_html as $cell) {
             $row[] = $cell;
             if (count($row) == $this->_columns) {
                 $table[] = $row;
                 $row = array();
             }
         }
         if ($this->_sort_type == self::SORT_ROWS) {
             $count_cols = count($table[0]);
             $count_rows = count($table);
             $list_index = 0;
             for ($index_col = 0; $index_col < $count_cols; $index_col++) {
                 for ($index_row = 0; $index_row < $count_rows; $index_row++) {
                     $table[$index_row][$index_col] = $list_html[$list_index];
                     $list_index++;
                 }
             }
         }
         foreach ($table as $row) {
             $input_html .= "<div class='row'>";
             foreach ($row as $cell) {
                 $input_html .= "<div class='col-md-{$col_md}'>{$cell}</div>";
             }
             $input_html .= "</div>";
         }
     }
     $input_html .= "</{$this->_tagname}>";
     return $input_html;
 }
 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));
 }