Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a custom editor to phpMyAdmin for certain fields only?

I would like to integrate JSON Editor Online with phpMyAdmin so as to edit certain table fields which contain PHP arrays encoded in JSON format.

I went through the Configuration options and the only ones related to field editors were:

CharEditing: Which editor should be used for CHAR/VARCHAR fields

I read this SO question which points to tbl_change.php but can't see any easy way of customizing it.

I wish we could do something like this:

  • define which fields need the custom editor (e.g. based on criteria such as data type, field name...)
  • associate these fields with the name of the custom editor
  • create the custom editor in a normalized way (using JS we could describe how the field value is loaded into the editor and which event/value to use to save the edited value back into the DB.

Does anybody know about a way of adding a custom editor to phpMyAdmin for certain fields only?

like image 596
Max Avatar asked Nov 04 '22 01:11

Max


2 Answers

i search on phpmyadmin files i found two file that i think is related to this

sql.php and libraries/display_tbl.lib.php i have one idea in display_tbl.lib.php is one variable

line 1293: $grid_edit_class = 'grid_edit';

this is the name of class that phpmyadmin editor with this class name find field that is editable. you can change it to something else like grid_edit2 with this work now phpmyadmin editor is disable.

gis_data_editor.js is phpmyadmin editor that include in sql.php

now you can include your editor files in sql.php and set grid_edit2 for your editor but you have one another problem on save edited field.

in my search it is down by makegrid.js you can see post script on line 29 you should compatible your editor with this script or write your own post script for send edited data to tbl_replace.php this is a sample of post data header

ajax_request:true
sql_query:
token:0203ddaa0c51d4776e93921e6ca1281f
db:sepidarsoft_portal
table:archive_media
clause_is_unique:1
where_clause[]:`archive_media`.`_id` = 45
fields[multi_edit][0][]:1364198434
fields_name[multi_edit][0][]:UTime
fields_null[multi_edit][0][]:
rel_fields_list:
do_transformations:false
transform_fields_list:
relational_display:K
goto:sql.php
submit_type:save
_nocache:1364974511419938233

hope this information help you

like image 28
mohammad mohsenipur Avatar answered Nov 09 '22 10:11

mohammad mohsenipur


There is no support for plugins to customize editor right now.

However you can quite easily change used editor for some fields in libraries/insert_edit.lib.php - change function PMA_getValueColumn, which is responsible for getting HTML code for field edit.

PS: The above is about upcoming phpMyAdmin 4.0, I'm not sure about older versions.

like image 198
Michal Čihař Avatar answered Nov 09 '22 08:11

Michal Čihař