@@ -1890,10 +1890,10 @@ private function addClass(
18901890 *
18911891 * @see getTable()
18921892 *
1893- * @param ResultInterface $dtResult the link id associated to the query
1894- * which results have to be displayed
1895- * @param array<string, string[]> $map the list of relations
1896- * @param bool $isLimitedDisplay with limited operations or not
1893+ * @param ResultInterface $dtResult the link id associated to the query
1894+ * which results have to be displayed
1895+ * @param ForeignKeyRelatedTable[] $map the list of relations
1896+ * @param bool $isLimitedDisplay with limited operations or not
18971897 *
18981898 * @return string html content
18991899 *
@@ -2218,16 +2218,16 @@ private function setMimeMap(): void
22182218 *
22192219 * @see getTableBody()
22202220 *
2221- * @param mixed[] $row current row data
2222- * @param int $rowNumber the index of current row
2223- * @param mixed[]|false $colOrder the column order false when
2224- * a property not found false
2225- * when a property not found
2226- * @param array<string, string[]> $map the list of relations
2227- * @param bool|mixed[]|string $colVisib column is visible(false);
2228- * column isn't visible(string
2229- * array)
2230- * @param string $urlSqlQuery the analyzed sql query
2221+ * @param mixed[] $row current row data
2222+ * @param int $rowNumber the index of current row
2223+ * @param mixed[]|false $colOrder the column order false when
2224+ * a property not found false
2225+ * when a property not found
2226+ * @param ForeignKeyRelatedTable[] $map the list of relations
2227+ * @param bool|mixed[]|string $colVisib column is visible(false);
2228+ * column isn't visible(string
2229+ * array)
2230+ * @param string $urlSqlQuery the analyzed sql query
22312231 * @psalm-param 'double-click'|'click'|'disabled' $gridEditConfig
22322232 *
22332233 * @return string html content
@@ -2847,12 +2847,12 @@ private function getClassForDateTimeRelatedFields(FieldMetadata $meta): string
28472847 *
28482848 * @see getTableBody()
28492849 *
2850- * @param string|null $column the column's value
2851- * @param string $class the html class for column
2852- * @param bool $conditionField the column should highlighted or not
2853- * @param FieldMetadata $meta the meta-information about this field
2854- * @param array<string, string[]> $map the list of relations
2855- * @param mixed[] $transformOptions the transformation parameters
2850+ * @param string|null $column the column's value
2851+ * @param string $class the html class for column
2852+ * @param bool $conditionField the column should highlighted or not
2853+ * @param FieldMetadata $meta the meta-information about this field
2854+ * @param ForeignKeyRelatedTable[] $map the list of relations
2855+ * @param mixed[] $transformOptions the transformation parameters
28562856 *
28572857 * @return string the prepared cell, html content
28582858 */
@@ -2896,13 +2896,13 @@ private function getDataCellForNumericColumns(
28962896 *
28972897 * @see getTableBody()
28982898 *
2899- * @param string|null $column the relevant column in data row
2900- * @param string $class the html class for column
2901- * @param FieldMetadata $meta the meta-information about this field
2902- * @param array<string, string[]> $map the list of relations
2903- * @param mixed[] $urlParams the parameters for generate url
2904- * @param bool $conditionField the column should highlighted or not
2905- * @param mixed[] $transformOptions the transformation parameters
2899+ * @param string|null $column the relevant column in data row
2900+ * @param string $class the html class for column
2901+ * @param FieldMetadata $meta the meta-information about this field
2902+ * @param ForeignKeyRelatedTable[] $map the list of relations
2903+ * @param mixed[] $urlParams the parameters for generate url
2904+ * @param bool $conditionField the column should highlighted or not
2905+ * @param mixed[] $transformOptions the transformation parameters
29062906 *
29072907 * @return string the prepared data cell, html content
29082908 */
@@ -3012,13 +3012,13 @@ private function getDataCellForGeometryColumns(
30123012 *
30133013 * @see getTableBody()
30143014 *
3015- * @param string|null $column the relevant column in data row
3016- * @param string $class the html class for column
3017- * @param FieldMetadata $meta the meta-information about the field
3018- * @param array<string, string[]> $map the list of relations
3019- * @param mixed[] $urlParams the parameters for generate url
3020- * @param bool $conditionField the column should highlighted or not
3021- * @param mixed[] $transformOptions the transformation parameters
3015+ * @param string|null $column the relevant column in data row
3016+ * @param string $class the html class for column
3017+ * @param FieldMetadata $meta the meta-information about the field
3018+ * @param ForeignKeyRelatedTable[] $map the list of relations
3019+ * @param mixed[] $urlParams the parameters for generate url
3020+ * @param bool $conditionField the column should highlighted or not
3021+ * @param mixed[] $transformOptions the transformation parameters
30223022 *
30233023 * @return string the prepared data cell, html content
30243024 */
@@ -3442,17 +3442,17 @@ public function getTable(
34423442
34433443 if ($ this ->properties ['table ' ] !== '' ) {
34443444 // This method set the values for $map array
3445- $ map = $ this ->setParamForLinkForeignKeyRelatedTables ( $ map );
3445+ $ map = $ this ->getForeignKeyRelatedTables ( );
34463446
34473447 // Coming from 'Distinct values' action of structure page
34483448 // We manipulate relations mechanism to show a link to related rows.
34493449 if ($ this ->properties ['is_browse_distinct ' ]) {
3450- $ map [$ fieldsMeta [1 ]->name ] = [
3450+ $ map [$ fieldsMeta [1 ]->name ] = new ForeignKeyRelatedTable (
34513451 $ this ->properties ['table ' ],
34523452 $ fieldsMeta [1 ]->name ,
34533453 '' ,
34543454 $ this ->properties ['db ' ],
3455- ] ;
3455+ ) ;
34563456 }
34573457 }
34583458
@@ -3735,13 +3735,9 @@ private function setMessageInformation(
37353735 /**
37363736 * Set the value of $map array for linking foreign key related tables
37373737 *
3738- * @see getTable()
3739- *
3740- * @param array<string, string[]> $map the list of relations
3741- *
3742- * @return array<string, string[]>
3738+ * @return ForeignKeyRelatedTable[]
37433739 */
3744- private function setParamForLinkForeignKeyRelatedTables ( array $ map ): array
3740+ private function getForeignKeyRelatedTables ( ): array
37453741 {
37463742 // To be able to later display a link to the related table,
37473743 // we verify both types of relations: either those that are
@@ -3757,13 +3753,19 @@ private function setParamForLinkForeignKeyRelatedTables(array $map): array
37573753 );
37583754
37593755 if ($ existRel === []) {
3760- return $ map ;
3756+ return [] ;
37613757 }
37623758
3759+ $ map = [];
37633760 foreach ($ existRel as $ masterField => $ rel ) {
37643761 if ($ masterField !== 'foreign_keys_data ' ) {
37653762 $ displayField = $ this ->relation ->getDisplayField ($ rel ['foreign_db ' ], $ rel ['foreign_table ' ]);
3766- $ map [$ masterField ] = [$ rel ['foreign_table ' ], $ rel ['foreign_field ' ], $ displayField , $ rel ['foreign_db ' ]];
3763+ $ map [$ masterField ] = new ForeignKeyRelatedTable (
3764+ $ rel ['foreign_table ' ],
3765+ $ rel ['foreign_field ' ],
3766+ $ displayField ,
3767+ $ rel ['foreign_db ' ],
3768+ );
37673769 } else {
37683770 foreach ($ rel as $ oneKey ) {
37693771 foreach ($ oneKey ['index_list ' ] as $ index => $ oneField ) {
@@ -3772,12 +3774,12 @@ private function setParamForLinkForeignKeyRelatedTables(array $map): array
37723774 $ oneKey ['ref_table_name ' ],
37733775 );
37743776
3775- $ map [$ oneField ] = [
3777+ $ map [$ oneField ] = new ForeignKeyRelatedTable (
37763778 $ oneKey ['ref_table_name ' ],
37773779 $ oneKey ['ref_index_list ' ][$ index ],
37783780 $ displayField ,
37793781 $ oneKey ['ref_db_name ' ] ?? $ GLOBALS ['db ' ],
3780- ] ;
3782+ ) ;
37813783 }
37823784 }
37833785 }
@@ -4024,21 +4026,21 @@ private function handleNonPrintableContents(
40244026 /**
40254027 * Retrieves the associated foreign key info for a data cell
40264028 *
4027- * @param string[] $fieldInfo the relation
4028- * @param string $whereComparison data for the where clause
4029+ * @param ForeignKeyRelatedTable $fieldInfo the relation
4030+ * @param string $whereComparison data for the where clause
40294031 *
40304032 * @return string|null formatted data
40314033 */
4032- private function getFromForeign (array $ fieldInfo , string $ whereComparison ): string |null
4034+ private function getFromForeign (ForeignKeyRelatedTable $ fieldInfo , string $ whereComparison ): string |null
40334035 {
40344036 $ dispsql = 'SELECT '
4035- . Util::backquote ($ fieldInfo[ 2 ] )
4037+ . Util::backquote ($ fieldInfo-> displayField )
40364038 . ' FROM '
4037- . Util::backquote ($ fieldInfo[ 3 ] )
4039+ . Util::backquote ($ fieldInfo-> database )
40384040 . '. '
4039- . Util::backquote ($ fieldInfo[ 0 ] )
4041+ . Util::backquote ($ fieldInfo-> table )
40404042 . ' WHERE '
4041- . Util::backquote ($ fieldInfo[ 1 ] )
4043+ . Util::backquote ($ fieldInfo-> field )
40424044 . $ whereComparison ;
40434045
40444046 $ dispval = $ this ->dbi ->fetchValue ($ dispsql );
@@ -4063,17 +4065,17 @@ private function getFromForeign(array $fieldInfo, string $whereComparison): stri
40634065 * @see getDataCellForNumericColumns(), getDataCellForGeometryColumns(),
40644066 * getDataCellForNonNumericColumns(),
40654067 *
4066- * @param string $class css classes for the td element
4067- * @param bool $conditionField whether the column is a part of the where clause
4068- * @param FieldMetadata $meta the meta-information about the field
4069- * @param array<string, string[]> $map the list of relations
4070- * @param string $data data
4071- * @param string $displayedData data that will be displayed (maybe be chunked)
4072- * @param string $nowrap 'nowrap' if the content should not be wrapped
4073- * @param string $whereComparison data for the where clause
4074- * @param mixed[] $transformOptions options for transformation
4075- * @param bool $isFieldTruncated whether the field is truncated
4076- * @param string $originalLength of a truncated column, or ''
4068+ * @param string $class css classes for the td element
4069+ * @param bool $conditionField whether the column is a part of the where clause
4070+ * @param FieldMetadata $meta the meta-information about the field
4071+ * @param ForeignKeyRelatedTable[] $map the list of relations
4072+ * @param string $data data
4073+ * @param string $displayedData data that will be displayed (maybe be chunked)
4074+ * @param string $nowrap 'nowrap' if the content should not be wrapped
4075+ * @param string $whereComparison data for the where clause
4076+ * @param mixed[] $transformOptions options for transformation
4077+ * @param bool $isFieldTruncated whether the field is truncated
4078+ * @param string $originalLength of a truncated column, or ''
40774079 *
40784080 * @return string formatted data
40794081 */
@@ -4119,14 +4121,12 @@ private function getRowData(
41194121 }
41204122
41214123 if (isset ($ map [$ meta ->name ])) {
4122- /** @var array{0: string, 1: string, 2: string, 3: string} $relation */
41234124 $ relation = $ map [$ meta ->name ];
41244125 // Field to display from the foreign table?
41254126 $ dispval = '' ;
41264127
41274128 // Check that we have a valid column name
4128- // Relation::getDisplayField() returns false by default
4129- if ($ relation [2 ] !== '' ) {
4129+ if ($ relation ->displayField !== '' ) {
41304130 $ dispval = $ this ->getFromForeign ($ relation , $ whereComparison );
41314131 }
41324132
@@ -4140,15 +4140,15 @@ private function getRowData(
41404140 $ value .= ' <code>[-> ' . $ dispval . ']</code> ' ;
41414141 } else {
41424142 $ sqlQuery = 'SELECT * FROM '
4143- . Util::backquote ($ relation[ 3 ] ) . '. '
4144- . Util::backquote ($ relation[ 0 ] )
4143+ . Util::backquote ($ relation-> database ) . '. '
4144+ . Util::backquote ($ relation-> table )
41454145 . ' WHERE '
4146- . Util::backquote ($ relation[ 1 ] )
4146+ . Util::backquote ($ relation-> field )
41474147 . $ whereComparison ;
41484148
41494149 $ urlParams = [
4150- 'db ' => $ relation[ 3 ] ,
4151- 'table ' => $ relation[ 0 ] ,
4150+ 'db ' => $ relation-> database ,
4151+ 'table ' => $ relation-> table ,
41524152 'pos ' => '0 ' ,
41534153 'sql_signature ' => Core::signSqlQuery ($ sqlQuery ),
41544154 'sql_query ' => $ sqlQuery ,
@@ -4158,7 +4158,7 @@ private function getRowData(
41584158 // always apply a transformation on the real data,
41594159 // not on the display field
41604160 $ displayedData = $ transformationPlugin ->applyTransformation ($ data , $ transformOptions , $ meta );
4161- } elseif ($ relationalDisplay === self ::RELATIONAL_DISPLAY_COLUMN && $ relation[ 2 ] !== '' ) {
4161+ } elseif ($ relationalDisplay === self ::RELATIONAL_DISPLAY_COLUMN && $ relation-> displayField !== '' ) {
41624162 // user chose "relational display field" in the
41634163 // display options, so show display field in the cell
41644164 $ displayedData = $ dispval === null ? '<em>NULL</em> ' : Core::mimeDefaultFunction ($ dispval );
0 commit comments