/** * Test for parsing options. * * @param string $input String to parse * @param array $expected Expected result * * @return void * * @dataProvider getOptionsData */ public function testGetOptions($input, $expected) { $this->assertEquals( $expected, PMA_Transformation_getOptions($input) ); }
/** * Get the values for one data row * * @param integer &$dt_result the link id associated to the query * which results have to be displayed * @param array $row current row data * @param integer $row_no the index of current row * @param array $col_order the column order * false when a property not found * @param array $map the list of relations * @param string $grid_edit_class the class for all editable columns * @param boolean $col_visib column is visible(false) * array column isn't visible(string array) * @param string $where_clause where clause * @param string $url_sql_query the analyzed sql query * @param array $analyzed_sql the analyzed query * * @return string $row_values_html html content * * @access private * * @see _getTableBody() */ private function _getRowValues(&$dt_result, $row, $row_no, $col_order, $map, $grid_edit_class, $col_visib, $where_clause, $url_sql_query, $analyzed_sql) { $row_values_html = ''; // Following variable are needed for use in isset/empty or // use with array indexes/safe use in foreach $sql_query = $this->__get('sql_query'); $fields_meta = $this->__get('fields_meta'); $highlight_columns = $this->__get('highlight_columns'); $mime_map = $this->__get('mime_map'); $row_info = $this->_getRowInfoForSpecialLinks($row, $col_order); $uniqueConditionMap = array(); $columnCount = $this->__get('fields_cnt'); for ($currentColumn = 0; $currentColumn < $columnCount; ++$currentColumn) { // assign $i with appropriate column order $i = $col_order ? $col_order[$currentColumn] : $currentColumn; $meta = $fields_meta[$i]; $orgFullColName = $this->__get('db') . '.' . $meta->orgtable . '.' . $meta->orgname; $not_null_class = $meta->not_null ? 'not_null' : ''; $relation_class = isset($map[$meta->name]) ? 'relation' : ''; $hide_class = $col_visib && !$col_visib[$currentColumn] ? 'hide' : ''; $grid_edit = $meta->orgtable != '' ? $grid_edit_class : ''; // handle datetime-related class, for grid editing $field_type_class = $this->_getClassForDateTimeRelatedFields($meta->type); $is_field_truncated = false; // combine all the classes applicable to this column's value $class = $this->_getClassesForColumn($grid_edit, $not_null_class, $relation_class, $hide_class, $field_type_class); // See if this column should get highlight because it's used in the // where-query. $condition_field = isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_Util::backquote($meta->name)])) ? true : false; // Wrap MIME-transformations. [MIME] $default_function = 'PMA_mimeDefaultFunction'; // default_function $transformation_plugin = $default_function; $transform_options = array(); if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($mime_map[$orgFullColName]['mimetype']) && !empty($mime_map[$orgFullColName]['transformation'])) { $file = $mime_map[$orgFullColName]['transformation']; $include_file = 'libraries/plugins/transformations/' . $file; if (file_exists($include_file)) { include_once $include_file; $class_name = PMA_getTransformationClassName($file); // todo add $plugin_manager $plugin_manager = null; $transformation_plugin = new $class_name($plugin_manager); $transform_options = PMA_Transformation_getOptions(isset($mime_map[$orgFullColName]['transformation_options']) ? $mime_map[$orgFullColName]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $mime_map[$orgFullColName]['mimetype']); } // end if file_exists } // end if transformation is set } // end if mime/transformation works. // Check whether the field needs to display with syntax highlighting $dbLower = mb_strtolower($this->__get('db')); $tblLower = mb_strtolower($meta->orgtable); $nameLower = mb_strtolower($meta->orgname); if (!empty($this->transformation_info[$dbLower][$tblLower][$nameLower]) && trim($row[$i]) != '' && !$_SESSION['tmpval']['hide_transformation']) { include_once $this->transformation_info[$dbLower][$tblLower][$nameLower][0]; $transformation_plugin = new $this->transformation_info[$dbLower][$tblLower][$nameLower][1](null); $transform_options = PMA_Transformation_getOptions(isset($mime_map[$orgFullColName]['transformation_options']) ? $mime_map[$orgFullColName]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $this->transformation_info[$dbLower][mb_strtolower($meta->orgtable)][mb_strtolower($meta->orgname)][2]); } // Check for the predefined fields need to show as link in schemas include_once 'libraries/special_schema_links.lib.php'; if (isset($GLOBALS['special_schema_links']) && !empty($GLOBALS['special_schema_links'][$dbLower][$tblLower][$nameLower])) { $linking_url = $this->_getSpecialLinkUrl($row[$i], $row_info, mb_strtolower($meta->orgname)); include_once "libraries/plugins/transformations/Text_Plain_Link.class.php"; $transformation_plugin = new Text_Plain_Link(); $transform_options = array(0 => $linking_url, 2 => true); $meta->mimetype = str_replace('_', '/', 'Text/Plain'); } $_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'where_clause' => $where_clause, 'transform_key' => $meta->name); /* * The result set can have columns from more than one table, * this is why we have to check for the unique conditions * related to this table; however getUniqueCondition() is * costly and does not need to be called if we already know * the conditions for the current table. */ if (!isset($uniqueConditionMap[$meta->orgtable])) { $unique_conditions = PMA_Util::getUniqueCondition($dt_result, $this->__get('fields_cnt'), $this->__get('fields_meta'), $row, false, $meta->orgtable); $uniqueConditionMap[$meta->orgtable] = $unique_conditions; } $transform_url_params = array('db' => $this->__get('db'), 'table' => $meta->orgtable, 'where_clause' => $uniqueConditionMap[$meta->orgtable][0], 'transform_key' => $meta->orgname); if (!empty($sql_query)) { $_url_params['sql_query'] = $url_sql_query; $transform_url_params['sql_query'] = $url_sql_query; } $transform_options['wrapper_link'] = PMA_URL_getCommon($transform_url_params); $vertical_display = $this->__get('vertical_display'); if ($meta->numeric == 1) { // n u m e r i c $vertical_display['data'][$row_no][$i] = $this->_getDataCellForNumericColumns($row[$i], $class, $condition_field, $meta, $map, $is_field_truncated, $analyzed_sql, $transformation_plugin, $default_function, $transform_options); } elseif ($meta->type == self::GEOMETRY_FIELD) { // g e o m e t r y // Remove 'grid_edit' from $class as we do not allow to // inline-edit geometry data. $class = str_replace('grid_edit', '', $class); $vertical_display['data'][$row_no][$i] = $this->_getDataCellForGeometryColumns($row[$i], $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $analyzed_sql); } else { // n o t n u m e r i c $vertical_display['data'][$row_no][$i] = $this->_getDataCellForNonNumericColumns($row[$i], $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql, $dt_result, $i); } // output stored cell $row_values_html .= $vertical_display['data'][$row_no][$i]; if (isset($vertical_display['rowdata'][$i][$row_no])) { $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i]; } else { $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } $this->__set('vertical_display', $vertical_display); } // end for return $row_values_html; }
/** * Get the values for one data row * * @param integer &$dt_result the link id associated to the query * which results have to be displayed * @param array $row current row data * @param integer $row_no the index of current row * @param array $col_order the column order * false when a property not found * @param array $map the list of relations * @param string $grid_edit_class the class for all editable columns * @param boolean $col_visib column is visible(false) * array column isn't visible(string array) * @param string $where_clause where clause * @param string $url_sql_query the analyzed sql query * @param array $analyzed_sql the analyzed query * @param boolean $directionCondition the directional condition * * @return string $row_values_html html content * * @access private * * @see _getTableBody() */ private function _getRowValues(&$dt_result, $row, $row_no, $col_order, $map, $grid_edit_class, $col_visib, $where_clause, $url_sql_query, $analyzed_sql, $directionCondition) { $row_values_html = ''; // Following variable are needed for use in isset/empty or // use with array indexes/safe use in foreach $sql_query = $this->__get('sql_query'); $fields_meta = $this->__get('fields_meta'); $highlight_columns = $this->__get('highlight_columns'); $mime_map = $this->__get('mime_map'); $row_info = $this->_getRowInfoForSpecialLinks($row, $col_order); for ($currentColumn = 0; $currentColumn < $this->__get('fields_cnt'); ++$currentColumn) { // assign $i with appropriate column order $i = $col_order ? $col_order[$currentColumn] : $currentColumn; $meta = $fields_meta[$i]; $not_null_class = $meta->not_null ? 'not_null' : ''; $relation_class = isset($map[$meta->name]) ? 'relation' : ''; $hide_class = $col_visib && !$col_visib[$currentColumn] && $_SESSION['tmpval']['disp_direction'] != self::DISP_DIR_VERTICAL ? 'hide' : ''; // handle datetime-related class, for grid editing $field_type_class = $this->_getClassForDateTimeRelatedFields($meta->type); $is_field_truncated = false; // combine all the classes applicable to this column's value $class = $this->_getClassesForColumn($grid_edit_class, $not_null_class, $relation_class, $hide_class, $field_type_class, $row_no); // See if this column should get highlight because it's used in the // where-query. $condition_field = isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_Util::backquote($meta->name)])) ? true : false; // Wrap MIME-transformations. [MIME] $default_function = '_mimeDefaultFunction'; // default_function $transformation_plugin = $default_function; $transform_options = array(); if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($mime_map[$meta->name]['mimetype']) && isset($mime_map[$meta->name]['transformation']) && !empty($mime_map[$meta->name]['transformation'])) { $file = $mime_map[$meta->name]['transformation']; $include_file = 'libraries/plugins/transformations/' . $file; if (file_exists($include_file)) { include_once $include_file; $class_name = str_replace('.class.php', '', $file); // todo add $plugin_manager $plugin_manager = null; $transformation_plugin = new $class_name($plugin_manager); $transform_options = PMA_Transformation_getOptions(isset($mime_map[$meta->name]['transformation_options']) ? $mime_map[$meta->name]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $mime_map[$meta->name]['mimetype']); } // end if file_exists } // end if transformation is set } // end if mime/transformation works. $_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'where_clause' => $where_clause, 'transform_key' => $meta->name); if (!empty($sql_query)) { $_url_params['sql_query'] = $url_sql_query; } $transform_options['wrapper_link'] = PMA_URL_getCommon($_url_params); $vertical_display = $this->__get('vertical_display'); // Check whether the field needs to display with syntax highlighting if (!empty($this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)]) && trim($row[$i]) != '') { $row[$i] = PMA_Util::formatSql($row[$i]); include_once $this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][0]; $transformation_plugin = new $this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][1](null); $transform_options = PMA_Transformation_getOptions(isset($mime_map[$meta->name]['transformation_options']) ? $mime_map[$meta->name]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][2]); } // Check for the predefined fields need to show as link in schemas include_once 'libraries/special_schema_links.lib.php'; if (isset($GLOBALS['special_schema_links']) && !empty($GLOBALS['special_schema_links'][strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)])) { $linking_url = $this->_getSpecialLinkUrl($row[$i], $row_info, strtolower($meta->name)); include_once "libraries/plugins/transformations/Text_Plain_Link.class.php"; $transformation_plugin = new Text_Plain_Link(null); $transform_options = array(0 => $linking_url, 2 => true); $meta->mimetype = str_replace('_', '/', 'Text/Plain'); } if ($meta->numeric == 1) { // n u m e r i c $vertical_display['data'][$row_no][$i] = $this->_getDataCellForNumericColumns($row[$i], $class, $condition_field, $meta, $map, $is_field_truncated, $analyzed_sql, $transformation_plugin, $default_function, $transform_options); } elseif (stristr($meta->type, self::BLOB_FIELD)) { // b l o b // PMA_mysql_fetch_fields returns BLOB in place of // TEXT fields type so we have to ensure it's really a BLOB $field_flags = $GLOBALS['dbi']->fieldFlags($dt_result, $i); $vertical_display['data'][$row_no][$i] = $this->_getDataCellForBlobColumns($row[$i], $class, $meta, $_url_params, $field_flags, $transformation_plugin, $default_function, $transform_options, $condition_field, $is_field_truncated); } elseif ($meta->type == self::GEOMETRY_FIELD) { // g e o m e t r y // Remove 'grid_edit' from $class as we do not allow to // inline-edit geometry data. $class = str_replace('grid_edit', '', $class); $vertical_display['data'][$row_no][$i] = $this->_getDataCellForGeometryColumns($row[$i], $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql); } else { // n o t n u m e r i c a n d n o t B L O B $vertical_display['data'][$row_no][$i] = $this->_getDataCellForNonNumericAndNonBlobColumns($row[$i], $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql, $dt_result, $i); } // output stored cell if ($directionCondition) { $row_values_html .= $vertical_display['data'][$row_no][$i]; } if (isset($vertical_display['rowdata'][$i][$row_no])) { $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i]; } else { $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } $this->__set('vertical_display', $vertical_display); } // end for return $row_values_html; }
/** * Function to get html for each insert/edit column * * @param array $table_columns table columns * @param int $column_number column index in 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 bool $odd_row whether odd 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 $default_char_editing default char editing mode which is stored * in the config.inc.php script * @param string $text_dir text direction * @param array $repopulate the data to be repopulated * @param array $column_mime the mime information of column * @param string $where_clause the where clause * * @return string */ function 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) { $column = $table_columns[$column_number]; if (!isset($column['processed'])) { $column = PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen); } $as_is = false; if (!empty($repopulate) && !empty($current_row)) { $current_row[$column['Field']] = $repopulate[$column['Field_md5']]; $as_is = true; } $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']); if (-1 === $column['len']) { $column['len'] = $GLOBALS['dbi']->fieldLen($current_result, $column_number); // length is unknown for geometry fields, // make enough space to edit very simple WKTs if (-1 === $column['len']) { $column['len'] = 30; } } //Call validation when the form submitted... $onChangeClause = $chg_evt_handler . "=\"return verificationsAfterFieldChange('" . PMA_escapeJsString($column['Field_md5']) . "', '" . PMA_escapeJsString($jsvkey) . "','" . $column['pma_type'] . "')\""; // Use an MD5 as an array index to avoid having special characters // in the name attribute (see bug #1746964 ) $column_name_appendix = $vkey . '[' . $column['Field_md5'] . ']'; if ($column['Type'] === 'datetime' && !isset($column['Default']) && !is_null($column['Default']) && $insert_mode) { $column['Default'] = date('Y-m-d H:i:s', time()); } $html_output = PMA_getHtmlForFunctionOption($odd_row, $column, $column_name_appendix); if ($GLOBALS['cfg']['ShowFieldTypesInDataEditView']) { $html_output .= PMA_getHtmlForInsertEditColumnType($column); } //End if // Get a list of GIS data types. $gis_data_types = PMA_Util::getGISDatatypes(); // Prepares the field value $real_null_value = false; $special_chars_encoded = ''; if (!empty($current_row)) { // (we are editing) list($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field) = PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix, $as_is); } else { // (we are inserting) // display default values $tmp = $column; if (isset($repopulate[$column['Field_md5']])) { $tmp['Default'] = $repopulate[$column['Field_md5']]; } list($real_null_value, $data, $special_chars, $backup_field, $special_chars_encoded) = PMA_getSpecialCharsAndBackupFieldForInsertingMode($tmp, $real_null_value); unset($tmp); } $idindex = $o_rows * $columns_cnt + $column_number + 1; $tabindex = $idindex; // Get a list of data types that are not yet supported. $no_support_types = PMA_Util::unsupportedDatatypes(); // The function column // ------------------- if ($GLOBALS['cfg']['ShowFunctionFields']) { $html_output .= PMA_getFunctionColumn($column, $is_upload, $column_name_appendix, $onChangeClause, $no_support_types, $tabindex_for_function, $tabindex, $idindex, $insert_mode); } // The null column // --------------- $foreignData = PMA_getForeignData($foreigners, $column['Field'], false, '', ''); $html_output .= PMA_getNullColumn($column, $column_name_appendix, $real_null_value, $tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData); // The value column (depends on type) // ---------------- // See bug #1667887 for the reason why we don't use the maxlength // HTML attribute //add data attributes "no of decimals" and "data type" $no_decimals = 0; $type = current(explode("(", $column['pma_type'])); if (preg_match('/\\(([^()]+)\\)/', $column['pma_type'], $match)) { $match[0] = trim($match[0], '()'); $no_decimals = $match[0]; } $html_output .= '<td' . ' data-type="' . $type . '"' . ' data-decimals="' . $no_decimals . '">' . "\n"; // Will be used by js/tbl_change.js to set the default value // for the "Continue insertion" feature $html_output .= '<span class="default_value hide">' . $special_chars . '</span>'; // Check input transformation of column $transformed_html = ''; if (!empty($column_mime['input_transformation'])) { $file = $column_mime['input_transformation']; $include_file = 'libraries/plugins/transformations/' . $file; if (is_file($include_file)) { include_once $include_file; $class_name = PMA_getTransformationClassName($file); $transformation_plugin = new $class_name(); $transformation_options = PMA_Transformation_getOptions($column_mime['input_transformation_options']); $_url_params = array('db' => $db, 'table' => $table, 'transform_key' => $column['Field'], 'where_clause' => $where_clause); $transformation_options['wrapper_link'] = PMA_URL_getCommon($_url_params); $current_value = ''; if (isset($current_row[$column['Field']])) { $current_value = $current_row[$column['Field']]; } if (method_exists($transformation_plugin, 'getInputHtml')) { $transformed_html = $transformation_plugin->getInputHtml($column, $row_id, $column_name_appendix, $transformation_options, $current_value, $text_dir, $tabindex, $tabindex_for_value, $idindex); } if (method_exists($transformation_plugin, 'getScripts')) { $GLOBALS['plugin_scripts'] = array_merge($GLOBALS['plugin_scripts'], $transformation_plugin->getScripts()); } } } if (!empty($transformed_html)) { $html_output .= $transformed_html; } else { $html_output .= PMA_getValueColumn($column, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data, $special_chars, $foreignData, $odd_row, array($table, $db), $row_id, $titles, $text_dir, $special_chars_encoded, $vkey, $is_upload, $biggest_max_file_size, $default_char_editing, $no_support_types, $gis_data_types, $extracted_columnspec); } $html_output .= '</td>' . '</tr>'; return $html_output; }
// available in $multi_edit_columns_name[$key] $file_to_insert = new PMA_File(); $file_to_insert->checkTblChangeForm($key, $rownumber); $possibly_uploaded_val = $file_to_insert->getContent(); if ($possibly_uploaded_val !== false) { $current_value = $possibly_uploaded_val; } // Apply Input Transformation if defined if (!empty($mime_map[$column_name]) && !empty($mime_map[$column_name]['input_transformation'])) { $filename = 'libraries/plugins/transformations/' . $mime_map[$column_name]['input_transformation']; if (is_file($filename)) { include_once $filename; $classname = PMA_getTransformationClassName($mime_map[$column_name]['input_transformation']); /** @var IOTransformationsPlugin $transformation_plugin */ $transformation_plugin = new $classname(); $transformation_options = PMA_Transformation_getOptions($mime_map[$column_name]['input_transformation_options']); $current_value = $transformation_plugin->applyTransformation($current_value, $transformation_options); // check if transformation was successful or not // and accordingly set error messages & insert_fail if (method_exists($transformation_plugin, 'isSuccess') && !$transformation_plugin->isSuccess()) { $insert_fail = true; $row_skipped = true; $insert_errors[] = sprintf(__('Row: %1$s, Column: %2$s, Error: %3$s'), $rownumber, $column_name, $transformation_plugin->getError()); } } } if ($file_to_insert->isError()) { $message .= $file_to_insert->getError(); } // delete $file_to_insert temporary variable $file_to_insert->cleanUp();
/** * Transform edited values * * @param string $db db name * @param string $table table name * @param array $transformation mimetypes for all columns of a table * [field_name][field_key] * @param array $edited_values transform columns list and new values * @param string $file file containing the transformation plugin * @param string $column_name column name * @param array $extra_data extra data array * * @return array $extra_data */ function PMA_transformEditedValues($db, $table, $transformation, $edited_values, $file, $column_name, $extra_data) { foreach ($edited_values as $cell_index => $curr_cell_edited_values) { if (isset($curr_cell_edited_values[$column_name])) { $column_data = $curr_cell_edited_values[$column_name]; $_url_params = array('db' => $db, 'table' => $table, 'where_clause' => $_REQUEST['where_clause'], 'transform_key' => $column_name); $include_file = 'libraries/plugins/transformations/' . $file; if (file_exists($include_file)) { include_once $include_file; $transform_options = PMA_Transformation_getOptions(isset($transformation['transformation_options']) ? $transformation['transformation_options'] : ''); $transform_options['wrapper_link'] = PMA_URL_getCommon($_url_params); $class_name = str_replace('.class.php', '', $file); $plugin_manager = null; $transformation_plugin = new $class_name($plugin_manager); } $extra_data['transformations'][$cell_index] = $transformation_plugin->applyTransformation($column_data, $transform_options, ''); } } // end of loop for each transformation cell return $extra_data; }
if (isset($where_clause)) { $result = $GLOBALS['dbi']->query('SELECT * FROM ' . PMA\libraries\Util::backquote($table) . ' WHERE ' . $where_clause . ';', null, PMA\libraries\DatabaseInterface::QUERY_STORE); $row = $GLOBALS['dbi']->fetchAssoc($result); } else { $result = $GLOBALS['dbi']->query('SELECT * FROM ' . PMA\libraries\Util::backquote($table) . ' LIMIT 1;', null, PMA\libraries\DatabaseInterface::QUERY_STORE); $row = $GLOBALS['dbi']->fetchAssoc($result); } // No row returned if (!$row) { exit; } // end if (no record returned) $default_ct = 'application/octet-stream'; if ($cfgRelation['commwork'] && $cfgRelation['mimework']) { $mime_map = PMA_getMime($db, $table); $mime_options = PMA_Transformation_getOptions(isset($mime_map[$transform_key]['transformation_options']) ? $mime_map[$transform_key]['transformation_options'] : ''); foreach ($mime_options as $key => $option) { if (substr($option, 0, 10) == '; charset=') { $mime_options['charset'] = $option; } } } // Only output the http headers $response = PMA\libraries\Response::getInstance(); $response->getHeader()->sendHttpHeaders(); // [MIME] if (isset($ct) && !empty($ct)) { $mime_type = $ct; } else { $mime_type = (!empty($mime_map[$transform_key]['mimetype']) ? str_replace('_', '/', $mime_map[$transform_key]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : ''); }