22
33declare (strict_types=1 );
44
5- namespace PhpMyAdmin \Controllers \Database ;
5+ namespace PhpMyAdmin \Controllers \Triggers ;
66
77use PhpMyAdmin \Controllers \AbstractController ;
8- use PhpMyAdmin \Database \Triggers ;
98use PhpMyAdmin \DatabaseInterface ;
109use PhpMyAdmin \DbTableExists ;
1110use PhpMyAdmin \Http \ServerRequest ;
1211use PhpMyAdmin \ResponseRenderer ;
1312use PhpMyAdmin \Template ;
13+ use PhpMyAdmin \Triggers \Triggers ;
1414use PhpMyAdmin \Url ;
1515use PhpMyAdmin \Util ;
1616
2020/**
2121 * Triggers management.
2222 */
23- class TriggersController extends AbstractController
23+ final class IndexController extends AbstractController
2424{
2525 public function __construct (
2626 ResponseRenderer $ response ,
@@ -37,7 +37,7 @@ public function __invoke(ServerRequest $request): void
3737 $ GLOBALS ['urlParams ' ] ??= null ;
3838 $ GLOBALS ['errorUrl ' ] ??= null ;
3939
40- $ this ->addScriptFiles (['database/ triggers.js ' ]);
40+ $ this ->addScriptFiles (['triggers.js ' ]);
4141
4242 if (! $ this ->response ->isAjax ()) {
4343 /**
@@ -73,6 +73,19 @@ public function __invoke(ServerRequest $request): void
7373 */
7474 $ GLOBALS ['errors ' ] = [];
7575
76- $ this ->triggers ->main ();
76+ $ this ->triggers ->handleEditor ();
77+ $ this ->triggers ->export ();
78+
79+ $ triggers = Triggers::getDetails ($ this ->dbi , $ GLOBALS ['db ' ], $ GLOBALS ['table ' ]);
80+ $ hasTriggerPrivilege = Util::currentUserHasPrivilege ('TRIGGER ' , $ GLOBALS ['db ' ], $ GLOBALS ['table ' ]);
81+ $ isAjax = $ this ->response ->isAjax () && empty ($ _REQUEST ['ajax_page_request ' ]);
82+
83+ $ this ->render ('triggers/list ' , [
84+ 'db ' => $ GLOBALS ['db ' ],
85+ 'table ' => $ GLOBALS ['table ' ],
86+ 'triggers ' => $ triggers ,
87+ 'has_privilege ' => $ hasTriggerPrivilege ,
88+ 'is_ajax ' => $ isAjax ,
89+ ]);
7790 }
7891}
0 commit comments