diff --git a/maint.php b/maint.php index af10520..0873bf8 100644 --- a/maint.php +++ b/maint.php @@ -28,6 +28,7 @@ chdir('../../'); include_once('./include/auth.php'); include_once($config['base_path'] . '/plugins/maint/functions.php'); +include_once($config['base_path'] . '/plugins/maint/ui_helpers.php'); define('MAINT_HOST_FILTER_LOC_ANY', '__any'); // internal value unlikely in data define('MAINT_HOST_FILTER_LOC_NONE', '__none'); @@ -99,15 +100,11 @@ break; case 'edit': - top_header(); - schedule_edit(); - bottom_footer(); + maint_render_with_layout('schedule_edit'); break; default: - top_header(); - schedules(); - bottom_footer(); + maint_render_with_layout('schedules'); break; } diff --git a/tests/test_layout_wrapper.php b/tests/test_layout_wrapper.php new file mode 100644 index 0000000..0980774 --- /dev/null +++ b/tests/test_layout_wrapper.php @@ -0,0 +1,65 @@ +content->bottom', $events === array('top_header', 'content', 'bottom_footer')); + +$source = file_get_contents(__DIR__ . '/../maint.php'); + +assert_true( + 'edit action uses shared layout helper', + strpos($source, "maint_render_with_layout('schedule_edit');") !== false +); +assert_true( + 'default action uses shared layout helper', + strpos($source, "maint_render_with_layout('schedules');") !== false +); + +echo "\n"; +echo "Results: $pass passed, $fail failed\n"; + +exit($fail > 0 ? 1 : 0); diff --git a/ui_helpers.php b/ui_helpers.php new file mode 100644 index 0000000..ea8fb7e --- /dev/null +++ b/ui_helpers.php @@ -0,0 +1,19 @@ +