Ejemplo n.º 1
0
 /**
  * Get data cell for geometry type fields
  *
  * @param string  $column                the relevant column in data row
  * @param string  $class                 the html class for column
  * @param object  $meta                  the meta-information about this field
  * @param array   $map                   the list of relations
  * @param array   $_url_params           the parameters for generate url
  * @param boolean $condition_field       the column should highlighted or not
  * @param string  $transformation_plugin the name of transformation function
  * @param string  $default_function      the default transformation function
  * @param string  $transform_options     the transformation parameters
  * @param boolean $is_field_truncated    the condition for blob data replacements
  * @param array   $analyzed_sql          the analyzed query
  *
  * @return  string  $cell                  the prepared data cell, html content
  *
  * @access  private
  *
  * @see     _getTableBody()
  */
 private function _getDataCellForGeometryColumns($column, $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql)
 {
     $pftext = $_SESSION['tmpval']['pftext'];
     $limitChars = $GLOBALS['cfg']['LimitChars'];
     if (!isset($column) || is_null($column)) {
         $cell = $this->_buildNullDisplay($class, $condition_field, $meta);
     } elseif ($column != '') {
         // Display as [GEOMETRY - (size)]
         if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_GEOM) {
             $geometry_text = $this->_handleNonPrintableContents(strtoupper(self::GEOMETRY_FIELD), isset($column) ? $column : '', $transformation_plugin, $transform_options, $default_function, $meta);
             $cell = $this->_buildValueDisplay($class, $condition_field, $geometry_text);
         } elseif ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_WKT) {
             // Prepare in Well Known Text(WKT) format.
             $where_comparison = ' = ' . $column;
             // Convert to WKT format
             $wktval = PMA_Util::asWKT($column);
             if ($GLOBALS['PMA_String']->strlen($wktval) > $limitChars && $pftext == self::DISPLAY_PARTIAL_TEXT) {
                 $wktval = $GLOBALS['PMA_String']->substr($wktval, 0, $limitChars) . '...';
                 $is_field_truncated = true;
             }
             $cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $wktval, $transformation_plugin, $default_function, '', $where_comparison, $transform_options, $is_field_truncated);
         } else {
             // Prepare in  Well Known Binary (WKB) format.
             if ($_SESSION['tmpval']['display_binary']) {
                 $where_comparison = ' = ' . $column;
                 $wkbval = $this->_displayBinaryAsPrintable($column, 'binary', 8);
                 if ($GLOBALS['PMA_String']->strlen($wkbval) > $limitChars && $pftext == self::DISPLAY_PARTIAL_TEXT) {
                     $wkbval = $GLOBALS['PMA_String']->substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
                     $is_field_truncated = true;
                 }
                 $cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $wkbval, $transformation_plugin, $default_function, '', $where_comparison, $transform_options, $is_field_truncated);
             } else {
                 $wkbval = $this->_handleNonPrintableContents(self::BINARY_FIELD, $column, $transformation_plugin, $transform_options, $default_function, $meta, $_url_params);
                 $cell = $this->_buildValueDisplay($class, $condition_field, $wkbval);
             }
         }
     } else {
         $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
     }
     return $cell;
 }
Ejemplo n.º 2
0
 /**
  * Get data cell for geometry type fields
  *
  * @param string  $column                the relevant column in data row
  * @param string  $class                 the html class for column
  * @param object  $meta                  the meta-information about this field
  * @param array   $map                   the list of relations
  * @param array   $_url_params           the parameters for generate url
  * @param boolean $condition_field       the column should highlighted or not
  * @param string  $transformation_plugin the name of transformation function
  * @param string  $default_function      the default transformation function
  * @param string  $transform_options     the transformation parameters
  * @param array   $analyzed_sql          the analyzed query
  *
  * @return  string  $cell                  the prepared data cell, html content
  *
  * @access  private
  *
  * @see     _getTableBody()
  */
 private function _getDataCellForGeometryColumns($column, $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $analyzed_sql)
 {
     if (!isset($column) || is_null($column)) {
         $cell = $this->_buildNullDisplay($class, $condition_field, $meta);
         return $cell;
     }
     if ($column == '') {
         $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
         return $cell;
     }
     // Display as [GEOMETRY - (size)]
     if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_GEOM) {
         $geometry_text = $this->_handleNonPrintableContents(strtoupper(self::GEOMETRY_FIELD), isset($column) ? $column : '', $transformation_plugin, $transform_options, $default_function, $meta);
         $cell = $this->_buildValueDisplay($class, $condition_field, $geometry_text);
         return $cell;
     }
     if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_WKT) {
         // Prepare in Well Known Text(WKT) format.
         $where_comparison = ' = ' . $column;
         // Convert to WKT format
         $wktval = PMA_Util::asWKT($column);
         $is_field_truncated = $this->_getPartialText($wktval);
         $cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $wktval, $transformation_plugin, $default_function, '', $where_comparison, $transform_options, $is_field_truncated);
         return $cell;
     }
     // Prepare in  Well Known Binary (WKB) format.
     if ($_SESSION['tmpval']['display_binary']) {
         $where_comparison = ' = ' . $column;
         $wkbval = substr(bin2hex($column), 8);
         $is_field_truncated = $this->_getPartialText($wkbval);
         $cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $wkbval, $transformation_plugin, $default_function, '', $where_comparison, $transform_options, $is_field_truncated);
         return $cell;
     }
     $wkbval = $this->_handleNonPrintableContents(self::BINARY_FIELD, $column, $transformation_plugin, $transform_options, $default_function, $meta, $_url_params);
     $cell = $this->_buildValueDisplay($class, $condition_field, $wkbval);
     return $cell;
 }
Ejemplo n.º 3
0
/**
 * Prepares the field value and retrieve special chars, backup field and data array
 *
 * @param array   $current_row          a row of the table
 * @param array   $column               description of column in given table
 * @param array   $extracted_columnspec associative array containing type,
 *                                      spec_in_brackets and possibly
 *                                      enum_set_values (another array)
 * @param boolean $real_null_value      whether column value null or not null
 * @param array   $gis_data_types       list of GIS data types
 * @param string  $column_name_appendix string to append to column name in input
 * @param bool    $as_is                use the data as is, used in repopulating
 *
 * @return array $real_null_value, $data, $special_chars, $backup_field,
 *               $special_chars_encoded
 */
function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix, $as_is)
{
    $special_chars_encoded = '';
    $data = null;
    // (we are editing)
    if (!isset($current_row[$column['Field']])) {
        $real_null_value = true;
        $current_row[$column['Field']] = '';
        $special_chars = '';
        $data = $current_row[$column['Field']];
    } elseif ($column['True_Type'] == 'bit') {
        $special_chars = $as_is ? $current_row[$column['Field']] : PMA_Util::printableBitValue($current_row[$column['Field']], $extracted_columnspec['spec_in_brackets']);
    } elseif ((substr($column['True_Type'], 0, 9) == 'timestamp' || $column['True_Type'] == 'datetime' || $column['True_Type'] == 'time') && mb_strpos($current_row[$column['Field']], ".") !== false) {
        $current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : PMA_Util::addMicroseconds($current_row[$column['Field']]);
        $special_chars = htmlspecialchars($current_row[$column['Field']]);
    } elseif (in_array($column['True_Type'], $gis_data_types)) {
        // Convert gis data to Well Know Text format
        $current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : PMA_Util::asWKT($current_row[$column['Field']], true);
        $special_chars = htmlspecialchars($current_row[$column['Field']]);
    } else {
        // special binary "characters"
        if ($column['is_binary'] || $column['is_blob'] && $GLOBALS['cfg']['ProtectBinary'] !== 'all') {
            $current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : bin2hex($current_row[$column['Field']]);
        }
        // end if
        $special_chars = htmlspecialchars($current_row[$column['Field']]);
        //We need to duplicate the first \n or otherwise we will lose
        //the first newline entered in a VARCHAR or TEXT column
        $special_chars_encoded = PMA_Util::duplicateFirstNewline($special_chars);
        $data = $current_row[$column['Field']];
    }
    // end if... else...
    //when copying row, it is useful to empty auto-increment column
    // to prevent duplicate key error
    if (isset($_REQUEST['default_action']) && $_REQUEST['default_action'] === 'insert') {
        if ($column['Key'] === 'PRI' && mb_strpos($column['Extra'], 'auto_increment') !== false) {
            $data = $special_chars_encoded = $special_chars = null;
        }
    }
    // If a timestamp field value is not included in an update
    // statement MySQL auto-update it to the current timestamp;
    // however, things have changed since MySQL 4.1, so
    // it's better to set a fields_prev in this situation
    $backup_field = '<input type="hidden" name="fields_prev' . $column_name_appendix . '" value="' . htmlspecialchars($current_row[$column['Field']]) . '" />';
    return array($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field);
}