/** * The null column * * @param array $column description of column in given table * @param string $column_name_appendix the name attribute * @param boolean $real_null_value is column value null or not null * @param integer $tabindex tab index * @param integer $tabindex_for_null +6000 * @param integer $idindex id index * @param string $vkey [multi_edit]['row_id'] * @param array $foreigners keys into foreign fields * @param array $foreignData data about the foreign keys * * @return string an html snippet */ function PMA_getNullColumn($column, $column_name_appendix, $real_null_value, $tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData) { if ($column['Null'] != 'YES') { return "<td></td>\n"; } $html_output = ''; $html_output .= '<td>' . "\n"; $html_output .= '<input type="hidden" name="fields_null_prev' . $column_name_appendix . '"'; if ($real_null_value && !$column['first_timestamp']) { $html_output .= ' value="on"'; } $html_output .= ' />' . "\n"; $html_output .= '<input type="checkbox" class="checkbox_null" tabindex="' . ($tabindex + $tabindex_for_null) . '"' . ' name="fields_null' . $column_name_appendix . '"'; if ($real_null_value) { $html_output .= ' checked="checked"'; } $html_output .= ' id="field_' . $idindex . '_2" />'; // nullify_code is needed by the js nullify() function $nullify_code = PMA_getNullifyCodeForNullColumn($column, $foreigners, $foreignData); // to be able to generate calls to nullify() in jQuery $html_output .= '<input type="hidden" class="nullify_code" name="nullify_code' . $column_name_appendix . '" value="' . $nullify_code . '" />'; $html_output .= '<input type="hidden" class="hashed_field" name="hashed_field' . $column_name_appendix . '" value="' . $column['Field_md5'] . '" />'; $html_output .= '<input type="hidden" class="multi_edit" name="multi_edit' . $column_name_appendix . '" value="' . PMA_escapeJsString($vkey) . '" />'; $html_output .= '</td>' . "\n"; return $html_output; }
/** * Test for PMA_getNullifyCodeForNullColumn * * @return void */ public function testGetNullifyCodeForNullColumn() { $column = $foreigners = $foreignData = array(); $column['True_Type'] = 'enum'; $column['Type'] = 'ababababababababababa'; $this->assertEquals('1', PMA_getNullifyCodeForNullColumn($column, null, null)); $column['True_Type'] = 'enum'; $column['Type'] = 'abababababababababab'; $this->assertEquals('2', PMA_getNullifyCodeForNullColumn($column, null, null)); $column['True_Type'] = 'set'; $this->assertEquals('3', PMA_getNullifyCodeForNullColumn($column, null, null)); $column['True_Type'] = ''; $column['Field'] = 'f'; $foreigners['f'] = true; $foreignData['foreign_link'] = ''; $this->assertEquals('4', PMA_getNullifyCodeForNullColumn($column, $foreigners, $foreignData)); }