/** * Test for PMA_getHtmlForInsertEditFormColumn * * @return void */ public function testGetHtmlForInsertEditFormColumn() { $o_rows = 0; $tabindex = 0; $GLOBALS['plugin_scripts'] = array(); $table_columns = array(array('Field' => 'col', 'Type' => 'varchar(20)', 'Null' => 'Yes', 'Privileges' => 'insert,update,select')); $repopulate = array(md5('col') => 'val'); $column_mime = array('input_transformation' => 'input/Image_JPEG_Upload.php', 'input_transformation_options' => '150'); // Test w/ input transformation $actual = PMA_getHtmlForInsertEditFormColumn($table_columns, 0, array(), false, array(), '', '', '', false, array(), false, $o_rows, $tabindex, 0, false, 0, array(), 0, 0, 'table', 'db', 0, array(), 0, '', '', $repopulate, $column_mime, ''); $this->assertContains('col', $actual); $this->assertContains('<option>AES_ENCRYPT</option>', $actual); $this->assertContains('<span class="column_type" dir="ltr">varchar(20)</span>', $actual); $this->assertContains('<tr class="noclick even">', $actual); $this->assertContains('<span class="default_value hide">', $actual); $this->assertContains('<img src="" width="150" height="100" ' . 'alt="Image preview here"/>', $actual); $this->assertContains('<input type="file" ' . 'name="fields_upload[d89e2ddb530bb8953b290ab0793aecb0]" ' . 'accept="image/*" ' . 'class="image-upload"' . '/>', $actual); // Test w/o input_transformation $table_columns = array(array('Field' => 'qwerty', 'Type' => 'datetime', 'Null' => 'Yes', 'Key' => '', 'Extra' => '', 'Default' => null, 'Privileges' => 'insert,update,select')); $repopulate = array(md5('qwerty') => '12-10-14'); $actual = PMA_getHtmlForInsertEditFormColumn($table_columns, 0, array(), false, array(), '', '', '', true, array(), false, $o_rows, $tabindex, 0, false, 0, array(), 0, 0, 'table', 'db', 0, array(), 0, '', '', $repopulate, array(), ''); $this->assertContains('qwerty', $actual); $this->assertContains('<option>UUID</option>', $actual); $this->assertContains('<span class="column_type" dir="ltr">datetime</span>', $actual); $this->assertContains('<input type="text" ' . 'name="fields[d8578edf8458ce06fbc5bb76a58c5ca4]" ' . 'value="12-10-14.000000"', $actual); }
/** * Function to get html for each insert/edit row * * @param array $url_params url parameters * @param array $table_columns table columns * @param array $comments_map comments map * @param bool $timestamp_seen whether timestamp seen * @param array $current_result current result * @param string $chg_evt_handler javascript change event handler * @param string $jsvkey javascript validation key * @param string $vkey validation key * @param bool $insert_mode whether insert mode * @param array $current_row current row * @param int &$o_rows row offset * @param int &$tabindex tab index * @param int $columns_cnt columns count * @param bool $is_upload whether upload * @param int $tabindex_for_function tab index offset for function * @param array $foreigners foreigners * @param int $tabindex_for_null tab index offset for null * @param int $tabindex_for_value tab index offset for value * @param string $table table * @param string $db database * @param int $row_id row id * @param array $titles titles * @param int $biggest_max_file_size biggest max file size * @param string $text_dir text direction * @param array $repopulate the data to be repopulated * @param array $where_clause_array the array of where clauses * * @return string */ function PMA_getHtmlForInsertEditRow($url_params, $table_columns, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, &$o_rows, &$tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array) { $html_output = PMA_getHeadAndFootOfInsertRowTable($url_params) . '<tbody>'; //store the default value for CharEditing $default_char_editing = $GLOBALS['cfg']['CharEditing']; $mime_map = PMA_getMIME($db, $table); $odd_row = true; $where_clause = ''; if (isset($where_clause_array[$row_id])) { $where_clause = $where_clause_array[$row_id]; } for ($column_number = 0; $column_number < $columns_cnt; $column_number++) { $table_column = $table_columns[$column_number]; // skip this column if user does not have necessary column privilges if (!PMA_userHasColumnPrivileges($table_column, $insert_mode)) { continue; } $column_mime = array(); if (isset($mime_map[$table_column['Field']])) { $column_mime = $mime_map[$table_column['Field']]; } $html_output .= PMA_getHtmlForInsertEditFormColumn($table_columns, $column_number, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, $odd_row, $o_rows, $tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $default_char_editing, $text_dir, $repopulate, $column_mime, $where_clause); $odd_row = !$odd_row; } // end for $o_rows++; $html_output .= ' </tbody>' . '</table><br />' . '<div class="clearfloat"></div>'; return $html_output; }
/** * Function to get html for each insert/edit row * * @param array $url_params url parameters * @param array $table_columns table columns * @param array $column column * @param array $comments_map comments map * @param bool $timestamp_seen whether timestamp seen * @param array $current_result current result * @param string $chg_evt_handler javascript change event handler * @param string $jsvkey javascript validation key * @param string $vkey validation key * @param bool $insert_mode whether insert mode * @param array $current_row current row * @param int &$o_rows row offset * @param int &$tabindex tab index * @param int $columns_cnt columns count * @param bool $is_upload whether upload * @param int $tabindex_for_function tab index offset for function * @param array $foreigners foreigners * @param int $tabindex_for_null tab index offset for null * @param int $tabindex_for_value tab index offset for value * @param string $table table * @param string $db database * @param int $row_id row id * @param array $titles titles * @param int $biggest_max_file_size biggest max file size * @param string $text_dir text direction * * @return string */ function PMA_getHtmlForInsertEditRow($url_params, $table_columns, $column, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, &$o_rows, &$tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $text_dir) { $html_output = PMA_getHeadAndFootOfInsertRowTable($url_params) . '<tbody>'; //store the default value for CharEditing $default_char_editing = $GLOBALS['cfg']['CharEditing']; $odd_row = true; for ($i = 0; $i < $columns_cnt; $i++) { $html_output .= PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, $odd_row, $o_rows, $tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $default_char_editing, $text_dir); $odd_row = !$odd_row; } // end for $o_rows++; $html_output .= ' </tbody>' . '</table><br />'; return $html_output; }