From 69f2694433ff0c1f1b21a730179502e2a14382af Mon Sep 17 00:00:00 2001 From: Kaleb Heitzman Date: Mon, 4 Mar 2024 15:43:50 -0500 Subject: [PATCH] Manage (#4) * removed editing requirement * updated documentation * bumped version * updated changelog --- CHANGES.md | 4 +++ README.md | 9 ++++- classes/output/manage_form.php | 60 ++++++++++++++++------------------ version.php | 4 +-- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ba5990b..dd4f81f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 2024030400 + +- Disabled having to be in edit mode for the manage page + ## 2024022202 - Major Refactor diff --git a/README.md b/README.md index c256f6c..d8182db 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,17 @@ You can also find a link in each course to translate only the content found in t The second scheduled task syncs a local copy of your Autotranslation glossary to DeepL for any [language combinations supported by DeepL.](https://www.deepl.com/docs-api/glossaries). You can manage your glossaries at `/filter/autotranslate/glossary.php`. To create a sync job, you will need to click "Sync Glossary" on the Glossary Management page for the selected source and target language pair. +![Glossary Page](docs/glossary.jpg) + Running from the CLI: ```bash php admin/cli/scheduled_task.php --execute='\filter_autotranslate\task\sync_glossaries_task' ``` -![Glossary Page](docs/glossary.jpg) +## Other Tasks + +```bash +# checks that the requested translation has a source text available +php admin/cli/scheduled_task.php --execute='\filter_autotranslate\task\check_source_task' +``` diff --git a/classes/output/manage_form.php b/classes/output/manage_form.php index 0f132b2..19076ae 100644 --- a/classes/output/manage_form.php +++ b/classes/output/manage_form.php @@ -261,40 +261,36 @@ class="col-5 filter-autotranslate__source-text" $mform->addElement('html', '
'); - if ($PAGE->user_is_editing()) { - // Edit mode is on. - $fieldname = 'translation[' . $record->hash . ']'; - $fieldname2 = 'original[' . $record->hash . ']'; - $ishtml = $this->contains_html($record->text); - if ($ishtml) { - $mform->addElement( - 'editor', - $fieldname, - null, - [ - 'autosave' => false, - 'removeorphaneddrafts' => true, - ] - )->setValue(['text' => $record->target_text]); - $mform->setType($fieldname, PARAM_RAW); - } else { - $mform->addElement( - 'textarea', - $fieldname, - null, - [ - 'oninput' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"', - 'onfocus' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"', - ] - ); - $mform->setDefault($fieldname, $record->target_text); - } - $mform->addElement('textarea', $fieldname2, null, ["class" => "d-none"]); - $mform->setDefault($fieldname2, $record->target_text); + + $fieldname = 'translation[' . $record->hash . ']'; + $fieldname2 = 'original[' . $record->hash . ']'; + $ishtml = $this->contains_html($record->text); + if ($ishtml) { + $mform->addElement( + 'editor', + $fieldname, + null, + [ + 'autosave' => false, + 'removeorphaneddrafts' => true, + ] + )->setValue(['text' => $record->target_text]); + $mform->setType($fieldname, PARAM_RAW); } else { - // Edit mode is off. - $mform->addElement('html', $record->target_text); + $mform->addElement( + 'textarea', + $fieldname, + null, + [ + 'oninput' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"', + 'onfocus' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"', + ] + ); + $mform->setDefault($fieldname, $record->target_text); } + $mform->addElement('textarea', $fieldname2, null, ["class" => "d-none"]); + $mform->setDefault($fieldname2, $record->target_text); + $mform->addElement('html', '
'); // Close translation item. diff --git a/version.php b/version.php index 1ca0b06..e06e76b 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024022702; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024030400; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2023042400; // Requires this Moodle version. $plugin->component = 'filter_autotranslate'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_ALPHA; -$plugin->release = '4.3.0 (Build: 2024022702)'; +$plugin->release = '4.3.0 (Build: 2024030400)';