From 1fac27c1023dab8ab733027cbbe3707383950c38 Mon Sep 17 00:00:00 2001 From: Adrian Jones Date: Thu, 18 Apr 2024 20:09:37 -0700 Subject: [PATCH] Get page path/title, template/field name, etc (and check page exists in data subfield) in Adminer. --- TracyDebugger.module.php | 2 +- .../plugins/AdminerProcessWireLogin.php | 43 +++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/TracyDebugger.module.php b/TracyDebugger.module.php index 7d52aeb..ba235a5 100644 --- a/TracyDebugger.module.php +++ b/TracyDebugger.module.php @@ -27,7 +27,7 @@ public static function getModuleInfo() { 'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__), 'author' => 'Adrian Jones', 'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/', - 'version' => '4.26.18', + 'version' => '4.26.19', 'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first 'singular' => true, 'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4', diff --git a/panels/Adminer/plugins/AdminerProcessWireLogin.php b/panels/Adminer/plugins/AdminerProcessWireLogin.php index 2c58a71..9135629 100644 --- a/panels/Adminer/plugins/AdminerProcessWireLogin.php +++ b/panels/Adminer/plugins/AdminerProcessWireLogin.php @@ -1,5 +1,7 @@ pwAdminUrl.'module/edit/?name='.$val.'" target="_parent">'.$val.''; } elseif(ctype_digit("$original")) { - if(in_array($_GET['select'], ['fieldgroups', 'modules'])) { - // intentionally blank - } - elseif(($_GET['select'] == 'templates' && in_array($field['field'], ['id'])) || ($_GET['select'] == 'pages' && in_array($field['field'], ['templates_id']))) { + if($_GET['select'] == 'templates' && in_array($field['field'], ['id'])) { $val = ''.$val.''; } + elseif($_GET['select'] == 'pages' && in_array($field['field'], ['templates_id'])) { + $name = wire('templates')->get('id='.$val)->get('label|name'); + if($name) { + $val = ''.$val.''; + } + } elseif($_GET['select'] == 'fields' && in_array($field['field'], ['id'])) { $val = ''.$val.''; } elseif(in_array($field['field'], ['field_id', 'fields_id'])) { - $val = ''.$val.''; + $name = wire('fields')->get('id='.$val)->get('label|name'); + if($name) { + $val = ''.$val.''; + } } elseif($_GET['select'] == 'pages' && in_array($field['field'], ['id'])) { $val = ''.$val.''; } elseif(in_array($field['field'], ['pid', 'pages_id', 'parent_id', 'parents_id', 'source_id', 'data'])) { - $val = ''.$val.''; + $data_is_page = false; + if($field['field'] == 'data') { + $f = wire('fields')->get(str_replace('field_', '', $_GET['select'])); + if($f && ($f->type instanceof \ProcessWire\FieldtypePage || $f->type instanceof \ProcessWire\FieldtypePageIDs)) { + $data_is_page = true; + } + } + if($field['field'] != 'data' || ($field['field'] == 'data' && $data_is_page)) { + $label = wire('modules')->isInstalled('PagePaths') ? 'url' : 'title'; + $name = wire('pages')->getRaw('id='.$val, $label); + if($name) { + $val = ''.$val.''; + } + } } elseif(in_array($field['field'], ['uid', 'created_users_id', 'modified_users_id'])) { - $val = ''.$val.''; + $name = wire('pages')->getRaw('id='.$val, 'name'); + if($name) { + $val = ''.$val.''; + } } } }