From 66a1034ac0a1f440ea3254bacfc82b798b89721b Mon Sep 17 00:00:00 2001 From: Tim Fry Date: Sun, 24 Nov 2024 09:08:28 -0400 Subject: [PATCH] use renumbering --- app/phrases/phrase_edit.php | 43 +++++- .../resources/javascript/phrase_edit.js | 124 +++++++++++++----- 2 files changed, 134 insertions(+), 33 deletions(-) diff --git a/app/phrases/phrase_edit.php b/app/phrases/phrase_edit.php index 415eee723a..e783d63914 100644 --- a/app/phrases/phrase_edit.php +++ b/app/phrases/phrase_edit.php @@ -37,6 +37,16 @@ else { exit; } +//set default domain +if (empty($domain_uuid)) { + $domain_uuid = $_SESSION['domain_uuid'] ?? ''; +} + +//set default user +if (empty($user_uuid)) { + $user_uuid = $_SESSION['user_uuid'] ?? ''; +} + //add multi-lingual support $language = new text; $text = $language->get(); @@ -46,6 +56,11 @@ if (!($database instanceof database)) { $database = database::new(); } +//ensure we have a settings object +if (!($settings instanceof settings)) { + $settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]); +} + //add the defaults $phrase_name = ''; $phrase_language = ''; @@ -196,6 +211,7 @@ if (count($_POST) > 0) { if ($action == "update" && permission_exists('phrase_edit')) { $array = []; if (!empty($_POST['phrase_detail_function'])) { + $recording_files = phrases::get_all_domain_recordings($settings); for ($i = 0; $i < count($_POST['phrase_detail_function']); $i++) { //build data array $array['phrases'][$i]['domain_uuid'] = $domain_uuid; @@ -213,6 +229,7 @@ if (count($_POST) > 0) { if (!empty($_POST['phrase_detail_data'][$i])) { $phrase_detail_uuid = uuid(); + $recording_uuid = $_POST['phrase_detail_data'][$i]; $array['phrase_details'][$i]['phrase_detail_uuid'] = $phrase_detail_uuid; $array['phrase_details'][$i]['phrase_uuid'] = $phrase_uuid; $array['phrase_details'][$i]['domain_uuid'] = $domain_uuid; @@ -220,7 +237,7 @@ if (count($_POST) > 0) { $array['phrase_details'][$i]['phrase_detail_tag'] = $_POST['phrase_detail_tag']; $array['phrase_details'][$i]['phrase_detail_pattern'] = $_POST['phrase_detail_pattern'] ?? null; $array['phrase_details'][$i]['phrase_detail_function'] = $_POST['phrase_detail_function'][$i]; - $array['phrase_details'][$i]['phrase_detail_data'] = $_POST['phrase_detail_data'][$i]; + $array['phrase_details'][$i]['phrase_detail_data'] = $recording_files[$recording_uuid]; //path and filename of recording $array['phrase_details'][$i]['phrase_detail_method'] = $_POST['phrase_detail_method'] ?? null; $array['phrase_details'][$i]['phrase_detail_type'] = $_POST['phrase_detail_type'] ?? null; $array['phrase_details'][$i]['phrase_detail_group'] = $_POST['phrase_detail_group']; @@ -233,7 +250,7 @@ if (count($_POST) > 0) { $database->app_name = 'phrases'; $database->app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba'; if (count($array) > 0) { - $database->save($array); + //$database->save($array); } } @@ -322,11 +339,31 @@ if (count($_POST) > 0) { //javascript constants for use in the selection option group echo "