예제 #1
1
 /** 
  * Form definition
  */
 public function definition()
 {
     $mform =& $this->_form;
     $orphanedfiles = $this->_customdata['orphanedfiles'];
     $filecount = count($orphanedfiles);
     $directory = html_writer::span(get_string('directory', 'report_filetrash'), 'bold trashheader');
     $name = html_writer::span(get_string('filename', 'report_filetrash'), 'bold trashheader');
     $size = html_writer::span(get_string('filesize', 'report_filetrash'), 'bold trashheader');
     $extensionheader = html_writer::span(get_string('extension', 'report_filetrash'), 'bold trashheader');
     if ($filecount > 0) {
         $i = 0;
         $mform->addElement('checkbox', 'selectall', get_string('selectall', 'report_filetrash'));
         foreach ($orphanedfiles as $file) {
             $i++;
             $filepath = $file['filepath'];
             $filename = $file['filename'];
             $filekey = $file['filekey'];
             $filesize = $file['filesize'];
             $extension = $file['extension'];
             $link = new moodle_url('/report/filetrash/file.php', array('filepath' => $filepath, 'filename' => $filename));
             $filelink = html_writer::link($link, $filename);
             $header = html_writer::div($directory . $filepath);
             $body = html_writer::div($name . $filelink);
             if (empty($extension)) {
                 $extensiondetails = '';
             } else {
                 $extensiondetails = html_writer::div($extensionheader . $extension);
             }
             $footer = html_writer::div($size . $filesize);
             $filedetails = html_writer::div($header . $body . $extensiondetails . $footer, 'filetrashdetails');
             $mform->addElement('checkbox', 'orphan_' . $filekey, $i . '. ', $filedetails);
         }
         $mform->addElement('submit', 'submit', get_string('delete'), 'submit', null);
     } else {
         $mform->addElement('static', 'nofiles', '', get_string('nofiles', 'report_filetrash'));
     }
 }
예제 #2
1
 /**
  * Displays a course selector for restore
  *
  * @param moodle_url $nextstageurl
  * @param bool $wholecourse true if we are restoring whole course (as with backup::TYPE_1COURSE), false otherwise
  * @param restore_category_search $categories
  * @param restore_course_search $courses
  * @param int $currentcourse
  * @return string
  */
 public function course_selector(moodle_url $nextstageurl, $wholecourse = true, restore_category_search $categories = null, restore_course_search $courses = null, $currentcourse = null)
 {
     global $CFG, $PAGE;
     require_once $CFG->dirroot . '/course/lib.php';
     // These variables are used to check if the form using this function was submitted.
     $target = optional_param('target', false, PARAM_INT);
     $targetid = optional_param('targetid', null, PARAM_INT);
     // Check if they submitted the form but did not provide all the data we need.
     $missingdata = false;
     if ($target and is_null($targetid)) {
         $missingdata = true;
     }
     $nextstageurl->param('sesskey', sesskey());
     $form = html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring(), 'class' => 'mform'));
     foreach ($nextstageurl->params() as $key => $value) {
         $form .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     $hasrestoreoption = false;
     $html = html_writer::start_tag('div', array('class' => 'backup-course-selector backup-restore'));
     if ($wholecourse && !empty($categories) && ($categories->get_count() > 0 || $categories->get_search())) {
         // New course
         $hasrestoreoption = true;
         $html .= $form;
         $html .= html_writer::start_tag('div', array('class' => 'bcs-new-course backup-section'));
         $html .= $this->output->heading(get_string('restoretonewcourse', 'backup'), 2, array('class' => 'header'));
         $html .= $this->backup_detail_input(get_string('restoretonewcourse', 'backup'), 'radio', 'target', backup::TARGET_NEW_COURSE, array('checked' => 'checked'));
         $selectacategoryhtml = $this->backup_detail_pair(get_string('selectacategory', 'backup'), $this->render($categories));
         // Display the category selection as required if the form was submitted but this data was not supplied.
         if ($missingdata && $target == backup::TARGET_NEW_COURSE) {
             $html .= html_writer::span(get_string('required'), 'error');
             $html .= html_writer::start_tag('fieldset', array('class' => 'error'));
             $html .= $selectacategoryhtml;
             $html .= html_writer::end_tag('fieldset');
         } else {
             $html .= $selectacategoryhtml;
         }
         $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
         $html .= html_writer::end_tag('div');
         $html .= html_writer::end_tag('form');
     }
     if ($wholecourse && !empty($currentcourse)) {
         // Current course
         $hasrestoreoption = true;
         $html .= $form;
         $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'targetid', 'value' => $currentcourse));
         $html .= html_writer::start_tag('div', array('class' => 'bcs-current-course backup-section'));
         $html .= $this->output->heading(get_string('restoretocurrentcourse', 'backup'), 2, array('class' => 'header'));
         $html .= $this->backup_detail_input(get_string('restoretocurrentcourseadding', 'backup'), 'radio', 'target', backup::TARGET_CURRENT_ADDING, array('checked' => 'checked'));
         $html .= $this->backup_detail_input(get_string('restoretocurrentcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_CURRENT_DELETING);
         $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
         $html .= html_writer::end_tag('div');
         $html .= html_writer::end_tag('form');
     }
     // If we are restoring an activity, then include the current course.
     if (!$wholecourse) {
         $courses->invalidate_results();
         // Clean list of courses.
         $courses->set_include_currentcourse();
     }
     if (!empty($courses) && ($courses->get_count() > 0 || $courses->get_search())) {
         // Existing course
         $hasrestoreoption = true;
         $html .= $form;
         $html .= html_writer::start_tag('div', array('class' => 'bcs-existing-course backup-section'));
         $html .= $this->output->heading(get_string('restoretoexistingcourse', 'backup'), 2, array('class' => 'header'));
         if ($wholecourse) {
             $html .= $this->backup_detail_input(get_string('restoretoexistingcourseadding', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_ADDING, array('checked' => 'checked'));
             $html .= $this->backup_detail_input(get_string('restoretoexistingcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_DELETING);
         } else {
             $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'target', 'value' => backup::TARGET_EXISTING_ADDING));
         }
         $selectacoursehtml = $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
         // Display the course selection as required if the form was submitted but this data was not supplied.
         if ($missingdata && $target == backup::TARGET_EXISTING_ADDING) {
             $html .= html_writer::span(get_string('required'), 'error');
             $html .= html_writer::start_tag('fieldset', array('class' => 'error'));
             $html .= $selectacoursehtml;
             $html .= html_writer::end_tag('fieldset');
         } else {
             $html .= $selectacoursehtml;
         }
         $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
         $html .= html_writer::end_tag('div');
         $html .= html_writer::end_tag('form');
     }
     if (!$hasrestoreoption) {
         echo $this->output->notification(get_string('norestoreoptions', 'backup'));
     }
     $html .= html_writer::end_tag('div');
     return $html;
 }
 /**
  * Renderers actions for individual course actions.
  *
  * @param course_in_list $course The course to renderer actions for.
  * @return string
  */
 public function search_listitem_actions(course_in_list $course)
 {
     $baseurl = new moodle_url('/course/managementsearch.php', array('courseid' => $course->id, 'categoryid' => $course->category, 'sesskey' => sesskey()));
     $actions = array();
     // Edit.
     if ($course->can_access()) {
         if ($course->can_edit()) {
             $actions[] = $this->output->action_icon(new moodle_url('/course/edit.php', array('id' => $course->id)), new pix_icon('t/edit', get_string('edit')), null, array('class' => 'action-edit'));
         }
         // Show/Hide.
         if ($course->can_change_visibility()) {
             if ($course->visible) {
                 $actions[] = $this->output->action_icon(new moodle_url($baseurl, array('action' => 'hidecourse')), new pix_icon('t/show', get_string('hide')), null, array('data-action' => 'hide', 'class' => 'action-hide'));
             } else {
                 $actions[] = $this->output->action_icon(new moodle_url($baseurl, array('action' => 'showcourse')), new pix_icon('t/hide', get_string('show')), null, array('data-action' => 'show', 'class' => 'action-show'));
             }
         }
     }
     if (empty($actions)) {
         return '';
     }
     return html_writer::span(join('', $actions), 'course-item-actions item-actions');
 }
예제 #4
0
 function display_add_field($recordid = 0, $formdata = null)
 {
     global $DB, $OUTPUT;
     if ($formdata) {
         $fieldname = 'field_' . $this->field->id;
         $content = $formdata->{$fieldname};
     } else {
         if ($recordid) {
             $content = $DB->get_field('data_content', 'content', array('fieldid' => $this->field->id, 'recordid' => $recordid));
             $content = trim($content);
         } else {
             $content = '';
         }
     }
     $str = '<div title="' . s($this->field->description) . '">';
     $options = array();
     $rawoptions = explode("\n", $this->field->param1);
     foreach ($rawoptions as $option) {
         $option = trim($option);
         if (strlen($option) > 0) {
             $options[$option] = $option;
         }
     }
     $str .= '<label for="' . 'field_' . $this->field->id . '">';
     $str .= html_writer::span($this->field->name, 'accesshide');
     if ($this->field->required) {
         $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'), array('class' => 'req', 'title' => get_string('requiredelement', 'form')));
         $str .= html_writer::div($image, 'inline-req');
     }
     $str .= '</label>';
     $str .= html_writer::select($options, 'field_' . $this->field->id, $content, array('' => get_string('menuchoose', 'data')), array('id' => 'field_' . $this->field->id, 'class' => 'mod-data-input custom-select'));
     $str .= '</div>';
     return $str;
 }
예제 #5
0
 /**
  * This method implements changes to the form that need to be made once the form data is set.
  */
 public function definition_after_data()
 {
     $mform = $this->_form;
     if ($userfullnames = $mform->getElementValue('userfullnames')) {
         $mform->getElement('selectednames')->setValue(\html_writer::span($userfullnames, 'selectednames'));
     }
 }
예제 #6
0
 private static function replacebookmarkplaceholder($template, $dataid)
 {
     $bookmarklink = \html_writer::link('#', get_string('bookmark', 'block_databasebookmarks'), array('class' => 'data_bookmark_link', 'data-moreurl' => '##moreurl##'));
     $bookmarkspan = \html_writer::span($bookmarklink, 'data_bookmark_wrapper');
     $template = str_replace('##bookmark##', $bookmarkspan, $template);
     return $template;
 }
예제 #7
0
 /**
  * Add appropriate form elements to the criteria form
  *
  * @param stdClass $data details of overall criterion
  */
 public function config_form_criteria($data)
 {
     global $OUTPUT;
     $prefix = 'criteria-' . $this->id;
     if (count($data->criteria) > 2) {
         echo $OUTPUT->box_start();
         if (!empty($this->description)) {
             $badge = new badge($this->badgeid);
             echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
         }
         echo $OUTPUT->heading($this->get_title(), 2);
         $agg = $data->get_aggregation_methods();
         if (!$data->is_locked() && !$data->is_active()) {
             $editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id));
             $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action'));
             echo $OUTPUT->box($editaction, array('criteria-header'));
             $url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey()));
             echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null, null, array('aria-describedby' => 'overall'));
             echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall'));
         } else {
             echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix');
         }
         echo $OUTPUT->box_end();
     }
 }
예제 #8
0
 /**
  * Warn that the selected plugin type does not match the detected one.
  *
  * @param string $detected detected plugin type
  */
 public function selected_plugintype_mismatch($detected)
 {
     $mform = $this->_form;
     $mform->addRule('plugintype', get_string('required'), 'required', null, 'client');
     $mform->setAdvanced('plugintype', false);
     $mform->setAdvanced('permcheck', false);
     $mform->insertElementBefore($mform->createElement('static', 'selectedplugintypemismatch', '', html_writer::span(get_string('typedetectionmismatch', 'tool_installaddon', $detected), 'error')), 'permcheck');
 }
예제 #9
0
 protected function detail_pair($key, $value, $class = '')
 {
     $html = html_writer::start_div('detail-pair row ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class));
     $html .= html_writer::div(html_writer::span($key), 'pair-key col-sm-3');
     $html .= html_writer::div(html_writer::span($value), 'pair-value col-sm-9');
     $html .= html_writer::end_div();
     return $html;
 }
 /**
  * Renderers a key value pair of information for display.
  *
  * @param string $key
  * @param string $value
  * @param string $class
  * @return string
  */
 protected function detail_pair($key, $value, $class = '')
 {
     $html = html_writer::start_div('detail-pair row yui3-g ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class));
     $html .= html_writer::div(html_writer::span($key), 'pair-key span4 yui3-u-1-4');
     $html .= html_writer::div(html_writer::span($value), 'pair-value span8 yui3-u-3-4');
     $html .= html_writer::end_div();
     return $html;
 }
예제 #11
0
 /**
  * Switch the form to a mode that requires manual selection of the plugin type
  */
 public function require_explicit_plugintype()
 {
     $mform = $this->_form;
     $mform->addRule('plugintype', get_string('required'), 'required', null, 'client');
     $mform->setAdvanced('plugintype', false);
     $mform->setAdvanced('permcheck', false);
     $typedetectionfailed = $mform->createElement('static', 'typedetectionfailed', '', html_writer::span(get_string('typedetectionfailed', 'tool_installaddon'), 'error'));
     $mform->insertElementBefore($typedetectionfailed, 'permcheck');
 }
예제 #12
0
 /**
  * Produces a table to visually compare roles and capabilities.
  *
  * @param array $capabilities An array of capabilities to show comparison for.
  * @param int $contextid The context we are displaying for.
  * @param array $roles An array of roles to show comparison for.
  * @return string
  */
 public function capability_comparison_table(array $capabilities, $contextid, array $roles)
 {
     $strpermissions = $this->get_permission_strings();
     $permissionclasses = $this->get_permission_classes();
     if ($contextid === context_system::instance()->id) {
         $strpermissions[CAP_INHERIT] = new lang_string('notset', 'role');
     }
     $table = new html_table();
     $table->attributes['class'] = 'comparisontable';
     $table->head = array('&nbsp;');
     foreach ($roles as $role) {
         $url = new moodle_url('/admin/roles/define.php', array('action' => 'view', 'roleid' => $role->id));
         $table->head[] = html_writer::div(html_writer::link($url, $role->localname));
     }
     $table->data = array();
     foreach ($capabilities as $capability) {
         $contexts = tool_capability_calculate_role_data($capability, $roles);
         $captitle = new html_table_cell(get_capability_string($capability) . html_writer::span($capability));
         $captitle->header = true;
         $row = new html_table_row(array($captitle));
         foreach ($roles as $role) {
             if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
                 $permission = $contexts[$contextid]->rolecapabilities[$role->id];
             } else {
                 $permission = CAP_INHERIT;
             }
             $cell = new html_table_cell($strpermissions[$permission]);
             $cell->attributes['class'] = $permissionclasses[$permission];
             $row->cells[] = $cell;
         }
         $table->data[] = $row;
     }
     // Start the list item, and print the context name as a link to the place to make changes.
     if ($contextid == context_system::instance()->id) {
         $url = new moodle_url('/admin/roles/manage.php');
         $title = get_string('changeroles', 'tool_capability');
     } else {
         $url = new moodle_url('/admin/roles/override.php', array('contextid' => $contextid));
         $title = get_string('changeoverrides', 'tool_capability');
     }
     $context = context::instance_by_id($contextid);
     $html = $this->output->heading(html_writer::link($url, $context->get_context_name(), array('title' => $title)), 3);
     $html .= html_writer::table($table);
     // If there are any child contexts, print them recursively.
     if (!empty($contexts[$contextid]->children)) {
         foreach ($contexts[$contextid]->children as $childcontextid) {
             $html .= $this->capability_comparison_table($capabilities, $childcontextid, $roles, true);
         }
     }
     return $html;
 }
예제 #13
0
    function display_add_field($recordid = 0, $formdata = null) {
        global $DB, $OUTPUT;

        if ($formdata) {
            $fieldname = 'field_' . $this->field->id;
            if (isset($formdata->$fieldname)) {
                $content = $formdata->$fieldname;
            } else {
                $content = array();
            }
        } else if ($recordid) {
            $content = $DB->get_field('data_content', 'content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid));
            $content = explode('##', $content);
        } else {
            $content = array();
        }

        $str = '<div title="'.s($this->field->description).'">';
        $str .= '<input name="field_' . $this->field->id . '[xxx]" type="hidden" value="xxx"/>'; // hidden field - needed for empty selection

        $str .= '<label for="field_' . $this->field->id . '" class="accesshide">';
        $str .= html_writer::span($this->field->name);
        if ($this->field->required) {
            $str .= '<div class="inline-req">';
            $str .= html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'),
                                     array('class' => 'req', 'title' => get_string('requiredelement', 'form')));
            $str .= '</div>';
        }
        $str .= '</label>';
        $str .= '<select name="field_' . $this->field->id . '[]" id="field_' . $this->field->id . '"';
        $str .= ' multiple="multiple" class="mod-data-input form-control">';

        foreach (explode("\n", $this->field->param1) as $option) {
            $option = trim($option);
            $str .= '<option value="' . s($option) . '"';

            if (in_array($option, $content)) {
                // Selected by user.
                $str .= ' selected = "selected"';
            }

            $str .= '>';
            $str .= $option . '</option>';
        }
        $str .= '</select>';
        $str .= '</div>';

        return $str;
    }
 public function eclass_header($columns)
 {
     global $CFG, $SITE;
     $output = html_writer::start_tag('header', array("role" => "banner", "class" => "navbar navbar-fixed-top moodle-has-zindex"));
     $output .= html_writer::start_tag('nav', array("role" => "navigation", "class" => "navbar-inner"));
     $output .= html_writer::start_div("container-fluid");
     $output .= html_writer::tag('img', '', array("src" => $this->pix_url('ua-logo', 'theme'), "class" => "uofa-logo", "height" => "40px"));
     $output .= html_writer::div(html_writer::link($CFG->wwwroot, $SITE->shortname, array("class" => "brand")), 'nav-brand');
     $output .= html_writer::start_div("pull-right");
     $output .= $this->custom_menu();
     $headingmenu = $this->page_heading_menu();
     $output .= html_writer::alist(array($headingmenu), array("class" => "nav pull-right"));
     $output .= html_writer::div(html_writer::span('', "glyphicons collapse_top"), "scroll-top pull-right", array("title" => "Scroll to top"));
     $output .= $this->login_info();
     $output .= html_writer::end_div();
     $output .= html_writer::end_div();
     $output .= html_writer::end_tag('nav');
     // Mobile stuff.
     $toggleleft = '<li><label class="toggle toggle-navigation"   for="toggle-left" onclick>' . '<div class="mobile-nav-icon glyphicons list"></div><span>Navigation</span></label></li>';
     $togglecenter = '<li><label class="toggle toggle-content" for="toggle-center" onclick>' . '<div class="mobile-nav-icon glyphicons book"></div><span>Content</span></label></li>';
     $toggleright = '';
     if ($this->page->blocks->region_has_content('side-post', $this)) {
         $toggleright = '<li><label class="toggle toggle-blocks"  for="toggle-right" onclick>' . '<div class="mobile-nav-icon glyphicons show_big_thumbnails"></div><span>Blocks</span></label></li>';
     }
     $toggleprofile = '<li><label class="toggle toggle-profile"  for="toggle-profile" onclick>' . '<div class="mobile-nav-icon glyphicons user"></div><span>Profile</span></label></li>';
     switch ($columns) {
         default:
         case 1:
             $togglelist = $togglecenter . $toggleprofile;
             break;
         case 2:
             $togglelist = $toggleleft . $togglecenter . $toggleprofile;
             break;
         case 3:
             $togglelist = $toggleleft . $togglecenter . $toggleright . $toggleprofile;
             break;
     }
     $togglelist .= html_writer::div('', 'active-indicator');
     $output .= html_writer::start_tag('nav', array("class" => "mobile-nav"));
     $output .= html_writer::tag('ul', $togglelist, array("class" => "view-selector"));
     $output .= html_writer::end_tag('nav');
     $output .= html_writer::end_tag('header');
     return $output;
 }
 public function render_databasebookmarks($bookmarks)
 {
     $output = '';
     $bookmarkslinks = array();
     foreach ($bookmarks as $bookmark) {
         $bookmarkmarkup = '';
         $url = new moodle_url("/mod/data/view.php", array('d' => $bookmark->instanceid, 'rid' => $bookmark->recordid));
         $label = $bookmark->bookmarkname;
         $bookmarklink = html_writer::link($url, $label);
         $bookmarkmarkup .= html_writer::span($bookmarklink, 'bookmarklink');
         $iconenrolremove = $this->output->pix_url('t/delete');
         $iconimg = html_writer::img($iconenrolremove, get_string('delete'));
         $deletelink = html_writer::link('#', $iconimg, array('data-rid' => $bookmark->recordid, 'data-action' => 'delete', 'class' => 'data_deletebookmark_link'));
         $bookmarkmarkup .= html_writer::span($deletelink, 'deletelink');
         $bookmarkslinks[] = $bookmarkmarkup;
     }
     $output .= html_writer::alist($bookmarkslinks, array('class' => 'block_databasebookmarks_bookmarklist'));
     return $output;
 }
예제 #16
0
 /**
  * Add a message to the session notification stack.
  *
  * @param string $message The message to add to the stack
  * @param string $level   The type of message to add to the stack
  */
 public static function add($message, $level = null)
 {
     global $PAGE, $SESSION;
     if ($PAGE && $PAGE->state === \moodle_page::STATE_IN_BODY) {
         // Currently in the page body - just render and exit immediately.
         // We insert some code to immediately insert this into the user-notifications created by the header.
         $id = uniqid();
         echo \html_writer::span($PAGE->get_renderer('core')->render(new \core\output\notification($message, $level)), '', array('id' => $id));
         // Insert this JS here using a script directly rather than waiting for the page footer to load to avoid
         // ensure that the message is added to the user-notifications section as soon as possible after it is created.
         echo \html_writer::script("(function() {" . "var notificationHolder = document.getElementById('user-notifications');" . "if (!notificationHolder) { return; }" . "var thisNotification = document.getElementById('{$id}');" . "if (!thisNotification) { return; }" . "notificationHolder.appendChild(thisNotification.firstChild);" . "thisNotification.remove();" . "})();");
         return;
     }
     // Add the notification directly to the session.
     // This will either be fetched in the header, or by JS in the footer.
     if (!isset($SESSION->notifications) || !array($SESSION->notifications)) {
         $SESSION->notifications = [];
     }
     $SESSION->notifications[] = (object) array('message' => $message, 'type' => $level);
 }
예제 #17
0
파일: question.php 프로젝트: evltuma/moodle
 public function apply_attempt_state(question_attempt_step $step)
 {
     $this->order = explode(',', $step->get_qt_var('_order'));
     // Add any missing answers. Sometimes people edit questions after they
     // have been attempted which breaks things.
     foreach ($this->order as $ansid) {
         if (isset($this->answers[$ansid])) {
             continue;
         }
         $a = new stdClass();
         $a->id = 0;
         $a->answer = html_writer::span(get_string('deletedchoice', 'qtype_multichoice'), 'notifyproblem');
         $a->answerformat = FORMAT_HTML;
         $a->fraction = 0;
         $a->feedback = '';
         $a->feedbackformat = FORMAT_HTML;
         $this->answers[$ansid] = $this->qtype->make_answer($a);
         $this->answers[$ansid]->answerformat = FORMAT_HTML;
     }
 }
예제 #18
0
 public function apply_attempt_state(question_attempt_step $step)
 {
     $this->stemorder = explode(',', $step->get_qt_var('_stemorder'));
     $this->set_choiceorder(explode(',', $step->get_qt_var('_choiceorder')));
     // Add any missing subquestions. Sometimes people edit questions after they
     // have been attempted which breaks things.
     foreach ($this->stemorder as $stemid) {
         if (!isset($this->stems[$stemid])) {
             $this->stems[$stemid] = html_writer::span(get_string('deletedsubquestion', 'qtype_match'), 'notifyproblem');
             $this->stemformat[$stemid] = FORMAT_HTML;
             $this->right[$stemid] = 0;
         }
     }
     // Add any missing choices. Sometimes people edit questions after they
     // have been attempted which breaks things.
     foreach ($this->choiceorder as $choiceid) {
         if (!isset($this->choices[$choiceid])) {
             $this->choices[$choiceid] = get_string('deletedchoice', 'qtype_match');
         }
     }
 }
 /**
  * Defines the form elements
  */
 public function definition()
 {
     $mform = $this->_form;
     $installer = $this->_customdata['installer'];
     $mform->addElement('header', 'general', get_string('installfromzip', 'tool_installaddon'));
     $mform->addHelpButton('general', 'installfromzip', 'tool_installaddon');
     $options = $installer->get_plugin_types_menu();
     $mform->addElement('select', 'plugintype', get_string('installfromziptype', 'tool_installaddon'), $options, array('id' => 'tool_installaddon_installfromzip_plugintype'));
     $mform->addHelpButton('plugintype', 'installfromziptype', 'tool_installaddon');
     $mform->addRule('plugintype', null, 'required', null, 'client');
     $mform->addElement('static', 'permcheck', '', html_writer::span(get_string('permcheck', 'tool_installaddon'), '', array('id' => 'tool_installaddon_installfromzip_permcheck')));
     $mform->addElement('filepicker', 'zipfile', get_string('installfromzipfile', 'tool_installaddon'), null, array('accepted_types' => '.zip'));
     $mform->addHelpButton('zipfile', 'installfromzipfile', 'tool_installaddon');
     $mform->addRule('zipfile', null, 'required', null, 'client');
     $mform->addElement('text', 'rootdir', get_string('installfromziprootdir', 'tool_installaddon'));
     $mform->addHelpButton('rootdir', 'installfromziprootdir', 'tool_installaddon');
     $mform->setType('rootdir', PARAM_PLUGIN);
     $mform->setAdvanced('rootdir');
     $mform->addElement('checkbox', 'acknowledgement', get_string('acknowledgement', 'tool_installaddon'), ' ' . get_string('acknowledgementtext', 'tool_installaddon'));
     $mform->addRule('acknowledgement', get_string('acknowledgementmust', 'tool_installaddon'), 'required', null, 'client');
     $this->add_action_buttons(false, get_string('installfromzipsubmit', 'tool_installaddon'));
 }
예제 #20
0
 /**
  * Returns XHTML select field and wrapping div(s)
  *
  * @see output_select_html()
  *
  * @param string $data the option to show as selected
  * @param string $query
  * @return string XHTML field and wrapping div
  */
 public function output_html($data, $query = '')
 {
     $html = '';
     $baseid = $this->get_id();
     $inputname = $this->get_full_name();
     foreach ($this->flowtypes as $flowtype) {
         $html .= \html_writer::start_div();
         $flowtypeid = $baseid . '_' . $flowtype;
         $radioattrs = ['type' => 'radio', 'name' => $inputname, 'id' => $flowtypeid, 'value' => $flowtype];
         if ($data === $flowtype || empty($data) && $flowtype === $this->get_defaultsetting()) {
             $radioattrs['checked'] = 'checked';
         }
         $typename = get_string('cfg_loginflow_' . $flowtype, 'auth_oidc');
         $typedesc = get_string('cfg_loginflow_' . $flowtype . '_desc', 'auth_oidc');
         $html .= \html_writer::empty_tag('input', $radioattrs);
         $html .= \html_writer::label($typename, $flowtypeid, false);
         $html .= '<br />';
         $html .= \html_writer::span($typedesc);
         $html .= '<br /><br />';
         $html .= \html_writer::end_div();
     }
     return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query);
 }
예제 #21
0
파일: renderer.php 프로젝트: evltuma/moodle
 /**
  * Render a node.
  *
  * @param node $node
  *
  * @return string
  */
 public function render_node(node $node)
 {
     $return = '';
     if (is_object($node->url)) {
         $header = \html_writer::link($node->url, $node->title);
     } else {
         $header = $node->title;
     }
     $icon = $node->icon;
     if (!empty($icon)) {
         $header .= $this->render($icon);
     }
     $content = $node->content;
     $classes = $node->classes;
     if (!empty($content)) {
         // There is some content to display below this make this a header.
         $return = \html_writer::tag('dt', $header);
         $return .= \html_writer::tag('dd', $content);
         $return = \html_writer::tag('dl', $return);
         if ($classes) {
             $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes));
         } else {
             $return = \html_writer::tag('li', $return, array('class' => 'contentnode'));
         }
     } else {
         $return = \html_writer::span($header);
         $return = \html_writer::tag('li', $return, array('class' => $classes));
     }
     return $return;
 }
예제 #22
0
 /**
  * Returns the event data list section with url links and other formatting.
  *
  * @param array $eventdata The event data list section.
  * @param string $eventfullpath Full path to the events for this plugin / subplugin.
  * @return array The event data list section with additional formatting.
  */
 private static function format_data($eventdata, $eventfullpath)
 {
     // Get general event information.
     $eventdata[$eventfullpath] = $eventfullpath::get_static_info();
     // Create a link for further event detail.
     $url = new \moodle_url('eventdetail.php', array('eventname' => $eventfullpath));
     $link = \html_writer::link($url, $eventfullpath::get_name());
     $eventdata[$eventfullpath]['fulleventname'] = \html_writer::span($link);
     $eventdata[$eventfullpath]['fulleventname'] .= \html_writer::empty_tag('br');
     $eventdata[$eventfullpath]['fulleventname'] .= \html_writer::span($eventdata[$eventfullpath]['eventname'], 'report-eventlist-name');
     $eventdata[$eventfullpath]['crud'] = self::get_crud_string($eventdata[$eventfullpath]['crud']);
     $eventdata[$eventfullpath]['edulevel'] = self::get_edulevel_string($eventdata[$eventfullpath]['edulevel']);
     $eventdata[$eventfullpath]['legacyevent'] = $eventfullpath::get_legacy_eventname();
     // Mess around getting since information.
     $ref = new \ReflectionClass($eventdata[$eventfullpath]['eventname']);
     $eventdocbloc = $ref->getDocComment();
     $sincepattern = "/since\\s*Moodle\\s([0-9]+.[0-9]+)/i";
     preg_match($sincepattern, $eventdocbloc, $result);
     if (isset($result[1])) {
         $eventdata[$eventfullpath]['since'] = $result[1];
     } else {
         $eventdata[$eventfullpath]['since'] = null;
     }
     // Human readable plugin information to go with the component.
     $pluginstring = explode('\\', $eventfullpath);
     if ($pluginstring[1] !== 'core') {
         $component = $eventdata[$eventfullpath]['component'];
         $manager = get_string_manager();
         if ($manager->string_exists('pluginname', $pluginstring[1])) {
             $eventdata[$eventfullpath]['component'] = \html_writer::span(get_string('pluginname', $pluginstring[1]));
         }
     }
     // Raw event data to be used to sort the "Event name" column.
     $eventdata[$eventfullpath]['raweventname'] = $eventfullpath::get_name() . ' ' . $eventdata[$eventfullpath]['eventname'];
     // Unset information that is not currently required.
     unset($eventdata[$eventfullpath]['action']);
     unset($eventdata[$eventfullpath]['target']);
     return $eventdata;
 }
예제 #23
0
     /**
      * Renders the header bar.
      *
      * @param context_header $contextheader Header bar object.
      * @return string HTML for the header bar.
      */
    protected function render_context_header(context_header $contextheader) {

        // All the html stuff goes here.
        $html = html_writer::start_div('page-context-header');

        // Image data.
        if (isset($contextheader->imagedata)) {
            // Header specific image.
            $html .= html_writer::div($contextheader->imagedata, 'page-header-image');
        }

        // Headings.
        if (!isset($contextheader->heading)) {
            $headings = $this->heading($this->page->heading, $contextheader->headinglevel);
        } else {
            $headings = $this->heading($contextheader->heading, $contextheader->headinglevel);
        }

        $html .= html_writer::tag('div', $headings, array('class' => 'page-header-headings'));

        // Buttons.
        if (isset($contextheader->additionalbuttons)) {
            $html .= html_writer::start_div('btn-group header-button-group');
            foreach ($contextheader->additionalbuttons as $button) {
                if (!isset($button->page)) {
                    // Include js for messaging.
                    if ($button['buttontype'] === 'message') {
                        message_messenger_requirejs();
                    }
                    $image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
                        'class' => 'iconsmall',
                        'role' => 'presentation'
                    ));
                    $image .= html_writer::span($button['title'], 'header-button-title');
                } else {
                    $image = html_writer::empty_tag('img', array(
                        'src' => $button['formattedimage'],
                        'role' => 'presentation'
                    ));
                }
                $html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);
            }
            $html .= html_writer::end_div();
        }
        $html .= html_writer::end_div();

        return $html;
    }
예제 #24
0
파일: lib.php 프로젝트: rezaies/moodle
/**
 * Return a pair of spans containing classes to allow the subscribe and
 * unsubscribe icons to be pre-loaded by a browser.
 *
 * @return string The generated markup
 */
function forum_get_discussion_subscription_icon_preloaders()
{
    $o = '';
    $o .= html_writer::span('&nbsp;', 'preload-subscribe');
    $o .= html_writer::span('&nbsp;', 'preload-unsubscribe');
    return $o;
}
예제 #25
0
 public function test_span()
 {
     // All options.
     $this->assertSame('<span class="frog" id="kermit">ribbit</span>', html_writer::span('ribbit', 'frog', array('id' => 'kermit')));
     // Combine class from attributes and $class.
     $this->assertSame('<span class="amphibian frog">ribbit</span>', html_writer::span('ribbit', 'frog', array('class' => 'amphibian')));
     // Class only.
     $this->assertSame('<span class="frog">ribbit</span>', html_writer::span('ribbit', 'frog'));
     // Attributes only.
     $this->assertSame('<span id="kermit">ribbit</span>', html_writer::span('ribbit', '', array('id' => 'kermit')));
     // No options.
     $this->assertSame('<span>ribbit</span>', html_writer::span('ribbit'));
 }
    function get_content() {
        global $CFG, $DB, $PAGE;

        require_once($CFG->libdir . '/filelib.php');
        require_once($CFG->dirroot . '/blocks/cobalt_reports/report.class.php');
        require_once($CFG->dirroot . '/blocks/cobalt_reports/locallib.php');
        if ($this->content !== NULL) {
            return $this->content;
        }

        $filteropt = new stdClass;
        $filteropt->overflowdiv = true;
        if ($this->content_is_trusted()) {
            // fancy reportdashboard allowed only on course, category and system blocks.
            $filteropt->noclean = true;
        }
        $this->content = new stdClass;
        $this->content->footer = '';
        $this->content->text = "";

        if (isset($this->config->reportlist)) {
            $reportid = $this->config->reportlist;
            $reportclass = create_reportclass($reportid);
            $components = cr_unserialize($reportclass->config->components);
            $reportcontenttypes = cr_listof_reporttypes($this->config->reportlist);
            $blockinstanceid = $this->instance->id;
            $this->content->text .= html_writer::select($reportcontenttypes, 'report', $this->config->reportcontenttype, false, array('id' => 'reporttype_' . $this->instance->id . '', 'onchange' => "generate_report(\"reporttype_\",$reportid,\"reportcontainer\",$blockinstanceid,\"$CFG->wwwroot\")"));
            $this->content->text .= html_writer::start_tag('div', array('id' => 'reportcontainer' . $this->instance->id . ''));
            $report = cr_get_reportinstance($this->config->reportlist);
            if (isset($report) && !$report->global) {
                $this->content->text .= '';
            } elseif (isset($this->config->reportlist)) {
                $renderer = $this->page->get_renderer('block_reportdashboard');
                $this->content->text .= $renderer->generate_dashboardreport($reportclass, $this->config->reportcontenttype, $blockinstanceid);
            }
            $this->content->text .=html_writer::end_tag('div');
            $link_url = new moodle_url('/blocks/cobalt_reports/viewreport.php', array('id'=>$reportid, 'courseid' => 1));
            $link = html_writer::link($link_url, html_writer::span(get_string('viewmore'), '', array('id'=>'reportdashboard_right')));
            $this->content->text .=$link;
        } else {
            $this->content->text .= '';
        }

        unset($filteropt); // memory footprint

        return $this->content;
    }
예제 #27
0
 /**
  * Helper method to render the information about the available plugin update
  *
  * @param core_plugin_manager $pluginman plugin manager instance
  * @param \core\update\info $updateinfo information about the available update for the plugin
  */
 protected function plugin_available_update_info(core_plugin_manager $pluginman, \core\update\info $updateinfo)
 {
     $boxclasses = 'pluginupdateinfo';
     $info = array();
     if (isset($updateinfo->release)) {
         $info[] = html_writer::div(get_string('updateavailable_release', 'core_plugin', $updateinfo->release), 'info release');
     }
     if (isset($updateinfo->maturity)) {
         $info[] = html_writer::div(get_string('maturity' . $updateinfo->maturity, 'core_admin'), 'info maturity');
         $boxclasses .= ' maturity' . $updateinfo->maturity;
     }
     if (isset($updateinfo->download)) {
         $info[] = html_writer::div(html_writer::link($updateinfo->download, get_string('download')), 'info download');
     }
     if (isset($updateinfo->url)) {
         $info[] = html_writer::div(html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin')), 'info more');
     }
     $box = html_writer::start_div($boxclasses);
     $box .= html_writer::div(get_string('updateavailable', 'core_plugin', $updateinfo->version), 'version');
     $box .= html_writer::div(implode(html_writer::span(' ', 'separator'), $info), 'infos');
     if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason)) {
         $box .= $this->output->single_button(new moodle_url($this->page->url, array('installupdate' => $updateinfo->component, 'installupdateversion' => $updateinfo->version)), get_string('updateavailableinstall', 'core_admin'), 'post', array('class' => 'singlebutton updateavailableinstall'));
     } else {
         $reasonhelp = $this->info_remote_plugin_not_installable($reason);
         if ($reasonhelp) {
             $box .= html_writer::div($reasonhelp, 'reasonhelp updateavailableinstall');
         }
     }
     $box .= html_writer::end_div();
     return $box;
 }
예제 #28
0
 /**
  * Prepares the paging bar for output.
  *
  * This method validates the arguments set up for the paging bar and then
  * produces fragments of HTML to assist display later on.
  *
  * @param renderer_base $output
  * @param moodle_page $page
  * @param string $target
  * @throws coding_exception
  */
 public function prepare(renderer_base $output, moodle_page $page, $target)
 {
     if (!isset($this->totalcount) || is_null($this->totalcount)) {
         throw new coding_exception('paging_bar requires a totalcount value.');
     }
     if (!isset($this->page) || is_null($this->page)) {
         throw new coding_exception('paging_bar requires a page value.');
     }
     if (empty($this->perpage)) {
         throw new coding_exception('paging_bar requires a perpage value.');
     }
     if (empty($this->baseurl)) {
         throw new coding_exception('paging_bar requires a baseurl value.');
     }
     if ($this->totalcount > $this->perpage) {
         $pagenum = $this->page - 1;
         if ($this->page > 0) {
             $this->previouslink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar => $pagenum)), get_string('previous'), array('class' => 'previous'));
         }
         if ($this->perpage > 0) {
             $lastpage = ceil($this->totalcount / $this->perpage);
         } else {
             $lastpage = 1;
         }
         if ($this->page > round($this->maxdisplay / 3 * 2)) {
             $currpage = $this->page - round($this->maxdisplay / 3);
             $this->firstlink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar => 0)), '1', array('class' => 'first'));
         } else {
             $currpage = 0;
         }
         $displaycount = $displaypage = 0;
         while ($displaycount < $this->maxdisplay and $currpage < $lastpage) {
             $displaypage = $currpage + 1;
             if ($this->page == $currpage) {
                 $this->pagelinks[] = html_writer::span($displaypage, 'current-page');
             } else {
                 $pagelink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar => $currpage)), $displaypage);
                 $this->pagelinks[] = $pagelink;
             }
             $displaycount++;
             $currpage++;
         }
         if ($currpage < $lastpage) {
             $lastpageactual = $lastpage - 1;
             $this->lastlink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar => $lastpageactual)), $lastpage, array('class' => 'last'));
         }
         $pagenum = $this->page + 1;
         if ($pagenum != $displaypage) {
             $this->nextlink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar => $pagenum)), get_string('next'), array('class' => 'next'));
         }
     }
 }
예제 #29
-1
 /**
  * Produces a navigation node for the navigation tree
  *
  * @param navigation_node[] $items
  * @param array $attrs
  * @param int $expansionlimit
  * @param array $options
  * @param int $depth
  * @return string
  */
 protected function navigation_node($items, $attrs = array(), $expansionlimit = null, array $options = array(), $depth = 1)
 {
     // Exit if empty, we don't want an empty ul element.
     if (count($items) === 0) {
         return '';
     }
     // Turn our navigation items into list items.
     $lis = array();
     // Set the number to be static for unique id's.
     static $number = 0;
     foreach ($items as $item) {
         $number++;
         if (!$item->display && !$item->contains_active_node()) {
             continue;
         }
         $content = $item->get_content();
         $title = $item->get_title();
         $isexpandable = empty($expansionlimit) || ($item->type > navigation_node::TYPE_ACTIVITY || $item->type < $expansionlimit) || $item->contains_active_node() && $item->children->count() > 0;
         $isbranch = $isexpandable && ($item->children->count() > 0 || $item->has_children() && (isloggedin() || $item->type <= navigation_node::TYPE_CATEGORY));
         // Skip elements which have no content and no action - no point in showing them
         if (!$isexpandable && empty($item->action)) {
             continue;
         }
         $hasicon = (!$isbranch || $item->type == navigation_node::TYPE_ACTIVITY || $item->type == navigation_node::TYPE_RESOURCE) && $item->icon instanceof renderable;
         if ($hasicon) {
             $icon = $this->output->render($item->icon);
             // Because an icon is being used we're going to wrap the actual content in a span.
             // This will allow designers to create columns for the content, as we've done in styles.css.
             $content = $icon . html_writer::span($content, 'item-content-wrap');
         } else {
             $icon = '';
         }
         if ($item->helpbutton !== null) {
             $content = trim($item->helpbutton) . html_writer::tag('span', $content, array('class' => 'clearhelpbutton'));
         }
         if ($content === '') {
             continue;
         }
         $nodetextid = 'label_' . $depth . '_' . $number;
         $attributes = array('tabindex' => '-1', 'id' => $nodetextid);
         if ($title !== '') {
             $attributes['title'] = $title;
         }
         if ($item->hidden) {
             $attributes['class'] = 'dimmed_text';
         }
         if (is_string($item->action) || empty($item->action) || ($item->type === navigation_node::TYPE_CATEGORY || $item->type === navigation_node::TYPE_MY_CATEGORY) && empty($options['linkcategories'])) {
             $content = html_writer::tag('span', $content, $attributes);
         } else {
             if ($item->action instanceof action_link) {
                 //TODO: to be replaced with something else
                 $link = $item->action;
                 $link->text = $icon . html_writer::span($link->text, 'item-content-wrap');
                 $link->attributes = array_merge($link->attributes, $attributes);
                 $content = $this->output->render($link);
             } else {
                 if ($item->action instanceof moodle_url) {
                     $content = html_writer::link($item->action, $content, $attributes);
                 }
             }
         }
         // This applies to the li item which contains all child lists too.
         $liclasses = array($item->get_css_type(), 'depth_' . $depth);
         // Class attribute on the div item which only contains the item content.
         $divclasses = array('tree_item');
         $liexpandable = array();
         $lirole = array('role' => 'treeitem');
         if ($isbranch) {
             $liclasses[] = 'contains_branch';
             if ($depth == 1) {
                 $liexpandable = array('data-expandable' => 'false', 'data-collapsible' => 'false');
             } else {
                 $liexpandable = array('aria-expanded' => $item->has_children() && (!$item->forceopen || $item->collapse) ? "false" : "true");
             }
             if ($item->requiresajaxloading) {
                 $liexpandable['data-requires-ajax'] = 'true';
                 $liexpandable['data-loaded'] = 'false';
                 $liexpandable['data-node-id'] = $item->id;
                 $liexpandable['data-node-key'] = $item->key;
                 $liexpandable['data-node-type'] = $item->type;
             }
             $divclasses[] = 'branch';
         } else {
             $divclasses[] = 'leaf';
         }
         if ($hasicon) {
             // Add this class if the item has an icon, whether it is a branch or not.
             $liclasses[] = 'item_with_icon';
             $divclasses[] = 'hasicon';
         }
         if ($item->isactive === true) {
             $liclasses[] = 'current_branch';
         }
         if (!empty($item->classes) && count($item->classes) > 0) {
             $divclasses[] = join(' ', $item->classes);
         }
         // Now build attribute arrays.
         $liattr = array('class' => join(' ', $liclasses)) + $liexpandable + $lirole;
         $divattr = array('class' => join(' ', $divclasses));
         if (!empty($item->id)) {
             $divattr['id'] = $item->id;
         }
         // Create the structure.
         $content = html_writer::tag('p', $content, $divattr);
         if ($isexpandable) {
             $content .= $this->navigation_node($item->children, array('role' => 'group'), $expansionlimit, $options, $depth + 1);
         }
         if (!empty($item->preceedwithhr) && $item->preceedwithhr === true) {
             $content = html_writer::empty_tag('hr') . $content;
         }
         if ($depth == 1) {
             $liattr['tabindex'] = '0';
         }
         $liattr['aria-labelledby'] = $nodetextid;
         $content = html_writer::tag('li', $content, $liattr);
         $lis[] = $content;
     }
     if (count($lis) === 0) {
         // There is still a chance, despite having items, that nothing had content and no list items were created.
         return '';
     }
     // We used to separate using new lines, however we don't do that now, instead we'll save a few chars.
     // The source is complex already anyway.
     return html_writer::tag('ul', implode('', $lis), $attrs);
 }
예제 #30
-1
    function display_add_field($recordid = 0, $formdata = null) {
        global $CFG, $DB, $OUTPUT, $PAGE;

        $text   = '';
        $format = 0;
        $str = '<div title="' . s($this->field->description) . '">';
        $str .= '<label for="field_' . $this->field->id . '" class="accesshide">';
        $str .= html_writer::span($this->field->name);
        if ($this->field->required) {
            $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'),
                                     array('class' => 'req', 'title' => get_string('requiredelement', 'form')));
            $str .= html_writer::div($image, 'inline-req');
        }
        $str .= '</label>';

        editors_head_setup();
        $options = $this->get_options();

        $itemid = $this->field->id;
        $field = 'field_'.$itemid;

        if ($formdata) {
            $fieldname = 'field_' . $this->field->id . '_content1';
            if (isset($formdata->$fieldname)) {
                $format = $formdata->$fieldname;
            } else {
                $format = file_get_unused_draft_itemid();
            }
            $fieldname = 'field_' . $this->field->id . '_itemid';
            if (isset($formdata->$fieldname)) {
                $draftitemid = clean_param($formdata->$fieldname, PARAM_INT);
            } else {
                $draftitemid = file_get_unused_draft_itemid();
            }
            $fieldname = 'field_' . $this->field->id;
            if (isset($formdata->$fieldname)) {
                $text = $formdata->$fieldname;
            }
        } else if ($recordid &&
                   $content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
            $format = $content->content1;
            $text = clean_text($content->content, $format);
            $text = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_data', 'content', $content->id, $options, $text);
        } else {
            $draftitemid = file_get_unused_draft_itemid();
            $format = FORMAT_HTML;
        }

        // get filepicker info
        //
        $fpoptions = array();
        if ($options['maxfiles'] != 0 ) {
            $args = new stdClass();
            // need these three to filter repositories list
            $args->accepted_types = array('web_image');
            $args->return_types = (FILE_INTERNAL | FILE_EXTERNAL);
            $args->context = $this->context;
            $args->env = 'filepicker';
            // advimage plugin
            $image_options = initialise_filepicker($args);
            $image_options->context = $this->context;
            $image_options->client_id = uniqid();
            $image_options->maxbytes = $options['maxbytes'];
            $image_options->env = 'editor';
            $image_options->itemid = $draftitemid;

            // moodlemedia plugin
            $args->accepted_types = array('video', 'audio');
            $media_options = initialise_filepicker($args);
            $media_options->context = $this->context;
            $media_options->client_id = uniqid();
            $media_options->maxbytes  = $options['maxbytes'];
            $media_options->env = 'editor';
            $media_options->itemid = $draftitemid;

            // advlink plugin
            $args->accepted_types = '*';
            $link_options = initialise_filepicker($args);
            $link_options->context = $this->context;
            $link_options->client_id = uniqid();
            $link_options->maxbytes  = $options['maxbytes'];
            $link_options->env = 'editor';
            $link_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
            $fpoptions['link'] = $link_options;
        }

        $editor = editors_get_preferred_editor($format);
        $strformats = format_text_menu();
        $formats =  $editor->get_supported_formats();
        foreach ($formats as $fid) {
            $formats[$fid] = $strformats[$fid];
        }
        $editor->set_text($text);
        $editor->use_editor($field, $options, $fpoptions);
        $str .= '<input type="hidden" name="'.$field.'_itemid" value="'.s($draftitemid).'" />';
        $str .= '<div class="mod-data-input">';
        $str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'" spellcheck="true">'.s($text).'</textarea></div>';
        $str .= '<div><label class="accesshide" for="' . $field . '_content1">' . get_string('format') . '</label>';
        $str .= '<select id="' . $field . '_content1" name="'.$field.'_content1">';
        foreach ($formats as $key=>$desc) {
            $selected = ($format == $key) ? 'selected="selected"' : '';
            $str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
        }
        $str .= '</select>';

        $str .= '</div>';
        $str .= '</div>';
        $str .= '</div>';
        return $str;
    }