/**
  * Test for PMA_getTextarea
  *
  * @return void
  */
 public function testGetTextarea()
 {
     $GLOBALS['cfg']['TextareaRows'] = 20;
     $GLOBALS['cfg']['TextareaCols'] = 10;
     $GLOBALS['cfg']['CharTextareaRows'] = 5;
     $GLOBALS['cfg']['CharTextareaCols'] = 1;
     $GLOBALS['cfg']['LimitChars'] = 20;
     $column = array();
     $column['is_char'] = true;
     $column['Type'] = 'char(10)';
     $result = PMA_getTextarea($column, 'a', 'b', 'd', 2, 0, 1, "abc/", 'foobar');
     $this->assertTag(PMA_getTagArray('<textarea name="fieldsb" class="char" maxlength="10" rows="5" cols="1" dir="abc/" ' . 'id="field_1_3" tabindex="2">', array('content' => 'foobar')), $result);
     $this->assertContains(" d ", $result);
 }
Ejemplo n.º 2
0
/**
 * Get HTML for the Value column of other datatypes
 * (here, "column" is used in the sense of HTML column in HTML table)
 *
 * @param array   $column                description of column in given table
 * @param string  $default_char_editing  default char editing mode which is stored
 *                                       in the config.inc.php script
 * @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 string  $special_chars         special characters
 * @param integer $tabindex_for_value    offset for the values tabindex
 * @param integer $idindex               id index
 * @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  $data                  data to edit
 * @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_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)
{
    // HTML5 data-* attribute data-type
    $data_type = $GLOBALS['PMA_Types']->getTypeClass($column['True_Type']);
    $fieldsize = PMA_getColumnSize($column, $extracted_columnspec);
    $html_output = $backup_field . "\n";
    if ($column['is_char'] && ($GLOBALS['cfg']['CharEditing'] == 'textarea' || mb_strpos($data, "\n") !== false)) {
        $html_output .= "\n";
        $GLOBALS['cfg']['CharEditing'] = $default_char_editing;
        $html_output .= PMA_getTextarea($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $data_type);
    } else {
        $html_output .= PMA_getHTMLinput($column, $column_name_appendix, $special_chars, $fieldsize, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data_type);
        if ($column['Extra'] == 'auto_increment') {
            $html_output .= '<input type="hidden" name="auto_increment' . $column_name_appendix . '" value="1" />';
        }
        if (substr($column['pma_type'], 0, 9) == 'timestamp') {
            $html_output .= '<input type="hidden" name="fields_type' . $column_name_appendix . '" value="timestamp" />';
        }
        if (substr($column['pma_type'], 0, 8) == 'datetime') {
            $html_output .= '<input type="hidden" name="fields_type' . $column_name_appendix . '" value="datetime" />';
        }
        if ($column['True_Type'] == 'bit') {
            $html_output .= '<input type="hidden" name="fields_type' . $column_name_appendix . '" value="bit" />';
        }
        if ($column['pma_type'] == 'date' || $column['pma_type'] == 'datetime' || substr($column['pma_type'], 0, 9) == 'timestamp') {
            // the _3 suffix points to the date field
            // the _2 suffix points to the corresponding NULL checkbox
            // in dateFormat, 'yy' means the year with 4 digits
        }
    }
    return $html_output;
}
 /**
  * Test for PMA_getTextarea
  *
  * @return void
  */
 public function testGetTextarea()
 {
     $GLOBALS['cfg']['TextareaRows'] = 20;
     $GLOBALS['cfg']['TextareaCols'] = 10;
     $GLOBALS['cfg']['CharTextareaRows'] = 5;
     $GLOBALS['cfg']['CharTextareaCols'] = 1;
     $GLOBALS['cfg']['LimitChars'] = 20;
     $column = array();
     $column['is_char'] = true;
     $column['Type'] = 'char(10)';
     $column['True_Type'] = 'char';
     $result = PMA_getTextarea($column, 'a', 'b', '', 2, 0, 1, "abc/", 'foobar', 'CHAR', false);
     $this->assertContains('<textarea name="fieldsb" class="char" ' . 'data-maxlength="10" rows="5" cols="1" dir="abc/" ' . 'id="field_1_3" tabindex="2" data-type="CHAR">', $result);
 }