/** * Get the HTML elements for value column in insert form * (here, "column" is used in the sense of HTML column in HTML table) * * @param array $column description of column in given table * @param string $backup_field hidden input field * @param string $column_name_appendix the name attribute * @param string $onChangeClause onchange clause for fields * @param integer $tabindex tab index * @param integer $tabindex_for_value offset for the values tabindex * @param integer $idindex id index * @param string $data description of the column field * @param string $special_chars special characters * @param array $foreignData data about the foreign keys * @param boolean $odd_row whether row is odd * @param array $paramTableDbArray array containing $table and $db * @param integer $rownumber the row number * @param array $titles An HTML IMG tag for a particular icon from * a theme, which may be an actual file or * an icon from a sprite * @param string $text_dir text direction * @param string $special_chars_encoded replaced char if the string starts * with a \r\n pair (0x0d0a) add an extra \n * @param string $vkey [multi_edit]['row_id'] * @param boolean $is_upload is upload or not * @param integer $biggest_max_file_size 0 integer * @param string $default_char_editing default char editing mode which is stored * in the config.inc.php script * @param array $no_support_types list of datatypes that are not (yet) * handled by PMA * @param array $gis_data_types list of GIS data types * @param array $extracted_columnspec associative array containing type, * spec_in_brackets and possibly * enum_set_values (another array) * * @return string an html snippet */ function PMA_getValueColumn($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $special_chars, $foreignData, $odd_row, $paramTableDbArray, $rownumber, $titles, $text_dir, $special_chars_encoded, $vkey, $is_upload, $biggest_max_file_size, $default_char_editing, $no_support_types, $gis_data_types, $extracted_columnspec) { // HTML5 data-* attribute data-type $data_type = $GLOBALS['PMA_Types']->getTypeClass($column['True_Type']); $html_output = ''; if ($foreignData['foreign_link'] == true) { $html_output .= PMA_getForeignLink($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $paramTableDbArray, $rownumber, $titles); } elseif (is_array($foreignData['disp_row'])) { $html_output .= PMA_dispRowForeignData($backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $foreignData); } elseif ($GLOBALS['cfg']['LongtextDoubleTextarea'] && mb_strstr($column['pma_type'], 'longtext')) { $html_output = ' </td>'; $html_output .= '</tr>'; $html_output .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . '<td colspan="5" class="right">'; $html_output .= PMA_getTextarea($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $data_type); } elseif (mb_strstr($column['pma_type'], 'text')) { $html_output .= PMA_getTextarea($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $data_type); $html_output .= "\n"; if (mb_strlen($special_chars) > 32000) { $html_output .= "</td>\n"; $html_output .= '<td>' . __('Because of its length,<br /> this column might not be editable.'); } } elseif ($column['pma_type'] == 'enum') { $html_output .= PMA_getPmaTypeEnum($column, $backup_field, $column_name_appendix, $extracted_columnspec, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data); } elseif ($column['pma_type'] == 'set') { $html_output .= PMA_getPmaTypeSet($column, $extracted_columnspec, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data); } elseif ($column['is_binary'] || $column['is_blob']) { $html_output .= PMA_getBinaryAndBlobColumn($column, $data, $special_chars, $biggest_max_file_size, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $vkey, $is_upload); } elseif (!in_array($column['pma_type'], $no_support_types)) { $html_output .= PMA_getValueColumnForOtherDatatypes($column, $default_char_editing, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $special_chars, $tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $data, $extracted_columnspec); } if (in_array($column['pma_type'], $gis_data_types)) { $html_output .= PMA_getHTMLforGisDataTypes(); } return $html_output; }
/** * Test for PMA_getBinaryAndBlobColumn * * @return void */ public function testGetBinaryAndBlobColumn() { $GLOBALS['cfg']['ProtectBinary'] = 'blob'; $column = array(); $column['is_blob'] = true; $column['Field_md5'] = '123'; $column['pma_type'] = 'blob'; $column['True_Type'] = 'blob'; $GLOBALS['max_upload_size'] = 65536; $result = PMA_getBinaryAndBlobColumn($column, '12\\"23', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', true); $this->assertEquals('Binary - do not edit (5 B)<input type="hidden" name="fields_typeb" ' . 'value="protected" /><input type="hidden" name="fieldsb" value="" />' . '<br /><input type="file" name="fields_uploadfoo[123]" class="text' . 'field" id="field_1_3" size="10" c/> (Max: 64KiB)' . "\n", $result); // case 2 $GLOBALS['cfg']['ProtectBinary'] = "all"; $column['is_binary'] = true; $result = PMA_getBinaryAndBlobColumn($column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', false); $this->assertEquals('Binary - do not edit (4 B)<input type="hidden" name="fields_typeb" ' . 'value="protected" /><input type="hidden" name="fieldsb" value="" ' . '/>', $result); // case 3 $GLOBALS['cfg']['ProtectBinary'] = "noblob"; $column['is_blob'] = false; $result = PMA_getBinaryAndBlobColumn($column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', true); $this->assertEquals('Binary - do not edit (4 B)<input type="hidden" name="fields_typeb" ' . 'value="protected" /><input type="hidden" name="fieldsb" value="" ' . '/>', $result); // case 4 $GLOBALS['cfg']['ProtectBinary'] = false; $column['is_blob'] = true; $column['is_char'] = true; $column['Type'] = 'char(255)'; $GLOBALS['cfg']['TextareaRows'] = 20; $GLOBALS['cfg']['TextareaCols'] = 10; $GLOBALS['cfg']['CharTextareaRows'] = 5; $GLOBALS['cfg']['CharTextareaCols'] = 1; $GLOBALS['cfg']['LimitChars'] = 100; $result = PMA_getBinaryAndBlobColumn($column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', true); $this->assertEquals("\na\n" . '<textarea name="fieldsb" class="char" maxlength="255" rows="5" cols="1" dir="/" ' . 'id="field_1_3" c tabindex="3"></textarea><br /><input type="file" ' . 'name="fields_uploadfoo[123]" class="textfield" id="field_1_3" ' . 'size="10" c/> (Max: 64KiB)' . "\n", $result); // case 5 $GLOBALS['cfg']['ProtectBinary'] = false; $GLOBALS['cfg']['LongtextDoubleTextarea'] = true; $GLOBALS['cfg']['LimitChars'] = 100; $column['is_blob'] = false; $column['len'] = 255; $column['is_char'] = false; $GLOBALS['cfg']['TextareaRows'] = 20; $GLOBALS['cfg']['TextareaCols'] = 10; $result = PMA_getBinaryAndBlobColumn($column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', true); $this->assertEquals("\na\n" . '<textarea name="fieldsb" class="" rows="20" cols="10" dir="/" ' . 'id="field_1_3" c tabindex="3"></textarea>', $result); // case 6 $column['is_blob'] = false; $column['len'] = 10; $GLOBALS['cfg']['LimitChars'] = 40; /** * This condition should be tested, however, it gives an undefined function * PMA_getFileSelectOptions error: * $GLOBALS['cfg']['UploadDir'] = true; * */ $result = PMA_getBinaryAndBlobColumn($column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, 'foo', true); $this->assertEquals("\na\n" . '<input type="text" name="fieldsb" value="" size="10" class=' . '"textfield" c tabindex="3" id="field_1_3" />', $result); }