Skip to content

Commit

Permalink
possible way with inline js
Browse files Browse the repository at this point in the history
  • Loading branch information
Oni01110011 committed Jun 18, 2024
1 parent d6c4834 commit 1be8a9f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions classes/newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ private function view_edit_issue_page(array $params) {
$draftitemid = file_get_submitted_draft_itemid('attachments');
$ctx = $options['context'];


if (!$this->check_issue_id($params[NEWSLETTER_PARAM_ISSUE])) {
throw new moodle_exception (
'Wrong ' . NEWSLETTER_PARAM_ISSUE . ' parameter value: ' . $params[NEWSLETTER_PARAM_ISSUE]
Expand Down Expand Up @@ -846,15 +847,13 @@ private function view_edit_issue_page(array $params) {
);

$fpoptions = array();
if($options['maxfiles'] != 0 ) {
if ($options['maxfiles'] != 0 ) {
$args = new stdClass();

// need these three to filter repositories list
$args->accepted_types = array('web_image');
$args->return_types = $options['return_types'];
$args->context = $ctx;
$args->env = 'filepicker';

// advimage plugin
$image_options = initialise_filepicker($args);
$image_options->context = $ctx;
Expand Down Expand Up @@ -893,22 +892,33 @@ private function view_edit_issue_page(array $params) {
$subtitle_options->env = 'editor';
$subtitle_options->itemid = $draftitemid;

$args->accepted_types = ['h5p'];
$h5poptions = initialise_filepicker($args);
$h5poptions->context = $this->context;
$h5poptions->client_id = uniqid();
$h5poptions->maxbytes = $options['maxbytes'];
$h5poptions->env = 'editor';
$h5poptions->itemid = $draftitemid;
if (has_capability('moodle/h5p:deploy', $ctx)) {
// Only set H5P Plugin settings if the user can deploy new H5P content.
// H5P plugin.
$args->accepted_types = array('.h5p');
$h5poptions = initialise_filepicker($args);
$h5poptions->context = $ctx;
$h5poptions->client_id = uniqid();
$h5poptions->maxbytes = $options['maxbytes'];
$h5poptions->areamaxbytes = $options['areamaxbytes'];
$h5poptions->env = 'editor';
$h5poptions->itemid = $draftitemid;
$fpoptions['h5p'] = $h5poptions;
}

$fpoptions['image'] = $image_options;
$fpoptions['media'] = $media_options;
$fpoptions['link'] = $link_options;
$fpoptions['subtitle'] = $subtitle_options;
$fpoptions['h5p'] = $h5poptions;
}

$editor = new newsletter_editor();

// TODO Remove this in MDL-77334 for Moodle 4.6.
// If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.
if (($editor instanceof tinymce_texteditor) && !is_null($this->getAttribute('onchange'))) {
$options['required'] = true;
}

$editor->use_editor('id_htmlcontent', $options, $fpoptions, $issue, $files);
$mform = new issue_form(
null,
Expand Down
2 changes: 1 addition & 1 deletion classes/newsletter_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class newsletter_editor extends editor {
*
* @param string $elementid
* @param array $options
* @param null $fpoptions
* @param array $fpoptions
* @param null $issue
*/
public function use_editor($elementid, array $options = null, $fpoptions = null, $issue = null, array $files = []) {
Expand Down

0 comments on commit 1be8a9f

Please sign in to comment.