当前位置: 首页>>代码示例>>PHP>>正文


PHP editors_get_preferred_editor函数代码示例

本文整理汇总了PHP中editors_get_preferred_editor函数的典型用法代码示例。如果您正苦于以下问题:PHP editors_get_preferred_editor函数的具体用法?PHP editors_get_preferred_editor怎么用?PHP editors_get_preferred_editor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了editors_get_preferred_editor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: question_survey_display

 protected function question_survey_display($data, $descendantsdata, $blankquestionnaire = false)
 {
     $output = '';
     // Essay.
     // Columns and rows default values.
     $cols = 80;
     $rows = 15;
     // Use HTML editor or not?
     if ($this->precise == 0) {
         $canusehtmleditor = true;
         $rows = $this->length == 0 ? $rows : $this->length;
     } else {
         $canusehtmleditor = false;
         // Prior to version 2.6, "precise" was used for rows number.
         $rows = $this->precise > 1 ? $this->precise : $this->length;
     }
     $name = 'q' . $this->id;
     if (isset($data->{'q' . $this->id})) {
         $value = $data->{'q' . $this->id};
     } else {
         $value = '';
     }
     if ($canusehtmleditor) {
         $editor = editors_get_preferred_editor();
         $editor->use_editor($name, questionnaire_get_editor_options($this->context));
         $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, 'rows' => $rows, 'cols' => $cols));
     } else {
         $editor = FORMAT_PLAIN;
         $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, 'rows' => $rows, 'cols' => $cols));
     }
     $output .= $texteditor;
     return $output;
 }
开发者ID:remotelearner,项目名称:moodle-mod_questionnaire,代码行数:33,代码来源:essay.php

示例2: manual_comment_fields

 public function manual_comment_fields(question_attempt $qa, question_display_options $options)
 {
     $inputname = $qa->get_behaviour_field_name('comment');
     $id = $inputname . '_id';
     list($commenttext, $commentformat) = $qa->get_current_manual_comment();
     $editor = editors_get_preferred_editor($commentformat);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     $commenttext = format_text($commenttext, $commentformat, array('para' => false));
     $editor->set_text($commenttext);
     $editor->use_editor($id, array('context' => $options->context));
     $commenteditor = html_writer::tag('div', html_writer::tag('textarea', s($commenttext), array('id' => $id, 'name' => $inputname, 'rows' => 10, 'cols' => 60)));
     $editorformat = '';
     if (count($formats) == 1) {
         reset($formats);
         $editorformat .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => key($formats)));
     } else {
         $editorformat = html_writer::start_tag('div', array('class' => 'fitem'));
         $editorformat .= html_writer::start_tag('div', array('class' => 'fitemtitle'));
         $editorformat .= html_writer::tag('label', get_string('format'), array('for' => 'menu' . $inputname . 'format'));
         $editorformat .= html_writer::end_tag('div');
         $editorformat .= html_writer::start_tag('div', array('class' => 'felement fhtmleditor'));
         $editorformat .= html_writer::select($formats, $inputname . 'format', $commentformat, '');
         $editorformat .= html_writer::end_tag('div');
         $editorformat .= html_writer::end_tag('div');
     }
     $comment = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('comment', 'question'), array('for' => $id)), array('class' => 'fitemtitle')) . html_writer::tag('div', $commenteditor, array('class' => 'felement fhtmleditor')), array('class' => 'fitem'));
     $comment .= $editorformat;
     $mark = '';
     if ($qa->get_max_mark()) {
         $currentmark = $qa->get_current_manual_mark();
         $maxmark = $qa->get_max_mark();
         $fieldsize = strlen($qa->format_max_mark($options->markdp)) - 1;
         $markfield = $qa->get_behaviour_field_name('mark');
         $attributes = array('type' => 'text', 'size' => $fieldsize, 'name' => $markfield, 'id' => $markfield);
         if (!is_null($currentmark)) {
             $attributes['value'] = $currentmark;
         }
         $a = new stdClass();
         $a->max = $qa->format_max_mark($options->markdp);
         $a->mark = html_writer::empty_tag('input', $attributes);
         $markrange = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_behaviour_field_name('maxmark'), 'value' => $maxmark)) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('minfraction'), 'value' => $qa->get_min_fraction())) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('maxfraction'), 'value' => $qa->get_max_fraction()));
         $error = $qa->validate_manual_mark($currentmark);
         $errorclass = '';
         if ($error !== '') {
             $erroclass = ' error';
             $error = html_writer::tag('span', $error, array('class' => 'error')) . html_writer::empty_tag('br');
         }
         $mark = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('mark', 'question'), array('for' => $markfield)), array('class' => 'fitemtitle')) . html_writer::tag('div', $error . get_string('xoutofmax', 'question', $a) . $markrange, array('class' => 'felement ftext' . $errorclass)), array('class' => 'fitem'));
     }
     return html_writer::tag('fieldset', html_writer::tag('div', $comment . $mark, array('class' => 'fcontainer clearfix')), array('class' => 'hidden'));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:55,代码来源:rendererbase.php

示例3: output_html

 /**
  * Returns an XHTML string for the editor
  *
  * @param string $data
  * @param string $query
  * @return string XHTML string for the editor
  */
 public function output_html($data, $query = '')
 {
     global $USER;
     $default = $this->get_defaultsetting();
     $defaultinfo = $default;
     if (!is_null($default) and $default !== '') {
         $defaultinfo = "\n" . $default;
     }
     $ctx = context_user::instance($USER->id);
     $editor = editors_get_preferred_editor(FORMAT_HTML);
     $options = $this->get_options();
     $draftitemid = file_get_unused_draft_itemid();
     $component = is_null($this->plugin) ? 'core' : $this->plugin;
     $data = file_prepare_draft_area($draftitemid, $options['context']->id, $component, $this->get_full_name() . '_draftitemid', $draftitemid, $options, $data);
     $fpoptions = array();
     $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;
     $image_options->client_id = uniqid();
     $image_options->maxbytes = $options['maxbytes'];
     $image_options->areamaxbytes = $options['areamaxbytes'];
     $image_options->env = 'editor';
     $image_options->itemid = $draftitemid;
     // moodlemedia plugin
     $args->accepted_types = array('video', 'audio');
     $media_options = initialise_filepicker($args);
     $media_options->context = $ctx;
     $media_options->client_id = uniqid();
     $media_options->maxbytes = $options['maxbytes'];
     $media_options->areamaxbytes = $options['areamaxbytes'];
     $media_options->env = 'editor';
     $media_options->itemid = $draftitemid;
     // advlink plugin
     $args->accepted_types = '*';
     $link_options = initialise_filepicker($args);
     $link_options->context = $ctx;
     $link_options->client_id = uniqid();
     $link_options->maxbytes = $options['maxbytes'];
     $link_options->areamaxbytes = $options['areamaxbytes'];
     $link_options->env = 'editor';
     $link_options->itemid = $draftitemid;
     $fpoptions['image'] = $image_options;
     $fpoptions['media'] = $media_options;
     $fpoptions['link'] = $link_options;
     $editor->use_editor($this->get_id(), $options, $fpoptions);
     return format_admin_setting($this, $this->visiblename, '<div class="form-textarea"><textarea rows="' . $this->rows . '" cols="' . $this->cols . '" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" spellcheck="true">' . s($data) . '</textarea></div>
     <input value="' . $draftitemid . '" name="' . $this->get_full_name() . '_draftitemid" type="hidden" />', $this->description, true, '', $defaultinfo, $query);
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:61,代码来源:admin_confightmleditor.php

示例4: display_add_field

 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE;
     $text = '';
     $format = 0;
     $str = '<div title="' . $this->field->description . '">';
     editors_head_setup();
     $options = array();
     $options['trusttext'] = false;
     $options['forcehttps'] = false;
     $options['subdirs'] = false;
     $options['maxfiles'] = 0;
     $options['maxbytes'] = 0;
     $options['changeformat'] = 0;
     $options['noclean'] = false;
     $itemid = $this->field->id;
     $field = 'field_' . $itemid;
     if ($recordid && ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid)))) {
         $text = $content->content;
         $format = $content->content1;
         $text = clean_text($text, $format);
     } else {
         if (can_use_html_editor()) {
             $format = FORMAT_HTML;
         } else {
             $format = FORMAT_PLAIN;
         }
     }
     $editor = editors_get_preferred_editor($format);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     $editor->use_editor($field, $options);
     $str .= '<div><textarea id="' . $field . '" name="' . $field . '" rows="' . $this->field->param3 . '" cols="' . $this->field->param2 . '">' . s($text) . '</textarea></div>';
     $str .= '<div><select 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>';
     return $str;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:46,代码来源:field.class.php

示例5: test_get_preferred_editor

 /**
  * Tests the installation of event handlers from file
  */
 public function test_get_preferred_editor()
 {
     // Fake a user agent.
     $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.21     5 Safari/534.10';
     $enabled = editors_get_enabled();
     // Array assignment is always a clone.
     $editors = $enabled;
     $first = array_shift($enabled);
     // Get the default editor which should be the first in the list.
     set_user_preference('htmleditor', '');
     $preferred = editors_get_preferred_editor();
     $this->assertEquals($first, $preferred);
     foreach ($editors as $key => $editor) {
         // User has set a preference for a specific editor.
         set_user_preference('htmleditor', $key);
         $preferred = editors_get_preferred_editor();
         $this->assertEquals($editor, $preferred);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:22,代码来源:editorlib_test.php

示例6: response_area_input

 public function response_area_input($name, $qa, $step, $lines, $context)
 {
     global $CFG;
     require_once $CFG->dirroot . '/repository/lib.php';
     $inputname = $qa->get_qt_field_name($name);
     $responseformat = $step->get_qt_var($name . 'format');
     $id = $inputname . '_id';
     $editor = editors_get_preferred_editor($responseformat);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     list($draftitemid, $reponse) = $this->prepare_response_for_editing($name, $step, $context);
     $editor->use_editor($id, $this->get_editor_options($context), $this->get_filepicker_options($context, $draftitemid));
     $output = '';
     $output .= html_writer::start_tag('div', array('class' => $this->class_name() . ' qtype_essay_response'));
     $output .= html_writer::tag('div', html_writer::tag('textarea', s($reponse), array('id' => $id, 'name' => $inputname, 'rows' => $lines, 'cols' => 60)));
     $output .= html_writer::start_tag('div');
     if (count($formats == 1)) {
         reset($formats);
         $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => key($formats)));
     } else {
         $output .= html_writer::select($formats, $inputname . 'format', $responseformat, '');
     }
     $output .= html_writer::end_tag('div');
     $output .= $this->filepicker_html($inputname, $draftitemid);
     $output .= html_writer::end_tag('div');
     return $output;
 }
开发者ID:rama1712,项目名称:moodle,代码行数:30,代码来源:renderer.php

示例7: data_generate_default_template

    data_generate_default_template($data, 'singletemplate');
    data_generate_default_template($data, 'listtemplate');
    data_generate_default_template($data, 'addtemplate');
    data_generate_default_template($data, 'asearchtemplate');
    //Template for advanced searches.
    data_generate_default_template($data, 'rsstemplate');
}
editors_head_setup();
$format = FORMAT_HTML;
if ($mode === 'csstemplate' or $mode === 'jstemplate') {
    $disableeditor = true;
}
if ($disableeditor) {
    $format = FORMAT_PLAIN;
}
$editor = editors_get_preferred_editor($format);
$strformats = format_text_menu();
$formats = $editor->get_supported_formats();
foreach ($formats as $fid) {
    $formats[$fid] = $strformats[$fid];
}
$options = array();
$options['trusttext'] = false;
$options['forcehttps'] = false;
$options['subdirs'] = false;
$options['maxfiles'] = 0;
$options['maxbytes'] = 0;
$options['changeformat'] = 0;
$options['noclean'] = false;
echo '<form id="tempform" action="templates.php?d=' . $data->id . '&amp;mode=' . $mode . '" method="post">';
echo '<div>';
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:templates.php

示例8: toHtml

    /**
     * Returns HTML for editor form element.
     *
     * @return string
     */
    function toHtml() {
        global $CFG, $PAGE, $OUTPUT;
        require_once($CFG->dirroot.'/repository/lib.php');

        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        }

        $ctx = $this->_options['context'];

        $id           = $this->_attributes['id'];
        $elname       = $this->_attributes['name'];

        $subdirs      = $this->_options['subdirs'];
        $maxbytes     = $this->_options['maxbytes'];
        $areamaxbytes = $this->_options['areamaxbytes'];
        $maxfiles     = $this->_options['maxfiles'];
        $changeformat = $this->_options['changeformat']; // TO DO: implement as ajax calls

        $text         = $this->_values['text'];
        $format       = $this->_values['format'];
        $draftitemid  = $this->_values['itemid'];

        // security - never ever allow guest/not logged in user to upload anything
        if (isguestuser() or !isloggedin()) {
            $maxfiles = 0;
        }

        $str = $this->_getTabs();
        $str .= '<div>';

        $editor = editors_get_preferred_editor($format);
        $strformats = format_text_menu();
        $formats =  $editor->get_supported_formats();
        foreach ($formats as $fid) {
            $formats[$fid] = $strformats[$fid];
        }

        // get filepicker info
        //
        $fpoptions = array();
        if ($maxfiles != 0 ) {
            if (empty($draftitemid)) {
                // no existing area info provided - let's use fresh new draft area
                require_once("$CFG->libdir/filelib.php");
                $this->setValue(array('itemid'=>file_get_unused_draft_itemid()));
                $draftitemid = $this->_values['itemid'];
            }

            $args = new stdClass();
            // need these three to filter repositories list
            $args->accepted_types = array('web_image');
            $args->return_types = $this->_options['return_types'];
            $args->context = $ctx;
            $args->env = 'filepicker';
            // advimage plugin
            $image_options = initialise_filepicker($args);
            $image_options->context = $ctx;
            $image_options->client_id = uniqid();
            $image_options->maxbytes = $this->_options['maxbytes'];
            $image_options->areamaxbytes = $this->_options['areamaxbytes'];
            $image_options->env = 'editor';
            $image_options->itemid = $draftitemid;

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

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

            $args->accepted_types = array('.vtt');
            $subtitle_options = initialise_filepicker($args);
            $subtitle_options->context = $ctx;
            $subtitle_options->client_id = uniqid();
            $subtitle_options->maxbytes  = $this->_options['maxbytes'];
            $subtitle_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $subtitle_options->env = 'editor';
            $subtitle_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
//.........这里部分代码省略.........
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:editor.php

示例9: editors_get_preferred_format

/**
 * Returns users preferred text format.
 * @return int standard text format
 */
function editors_get_preferred_format()
{
    global $USER;
    $editor = editors_get_preferred_editor();
    return $editor->get_preferred_format();
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:10,代码来源:editorlib.php

示例10: essay_survey_display

 private function essay_survey_display($data)
 {
     // Essay.
     $cols = $this->length;
     $rows = $this->precise;
     $str = '';
     // If NO cols or rows specified: use HTML editor (if available in this context).
     if (!$cols || !$rows) {
         $cols = 60;
         $rows = 5;
         $canusehtmleditor = $this->usehtmleditor;
         // If cols & rows specified, do not use HTML editor but plain text box
         // use default (60 cols and 5 rows) OR user-specified values.
     } else {
         $canusehtmleditor = false;
     }
     $name = 'q' . $this->id;
     if (isset($data->{'q' . $this->id})) {
         $value = $data->{'q' . $this->id};
     } else {
         $value = '';
     }
     if ($canusehtmleditor) {
         $editor = editors_get_preferred_editor();
         $editor->use_editor($name, questionnaire_get_editor_options($this->context));
         $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, '', ''));
         echo $texteditor;
     } else {
         $str .= '<textarea class="form-textarea" id="edit-' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . s($value) . '</textarea>';
         echo $str;
     }
 }
开发者ID:achocoza,项目名称:moodle26,代码行数:32,代码来源:questiontypes.class.php

示例11: output_html

 /**
  * Returns an XHTML string for the editor
  *
  * @param string $data
  * @param string $query
  * @return string XHTML string for the editor
  */
 public function output_html($data, $query='') {
     $editor = editors_get_preferred_editor(FORMAT_HTML);
     $editor->set_text($data);
     $editor->use_editor($this->get_id(), array('noclean'=>true));
     return parent::output_html($data, $query);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:13,代码来源:adminlib.php

示例12: get_string

         echo '</fieldset>';
     }
 }
 if (has_capability('mod/questionnaire:message', $context)) {
     // Message editor.
     // Prepare data.
     echo '<fieldset class="clearfix">';
     if ($action == 'sendmessage' && (empty($subject) || empty($message))) {
         echo $OUTPUT->notification(get_string('allfieldsrequired'));
     }
     echo '<legend class="ftoggler">' . get_string('send_message', 'questionnaire') . '</legend>';
     $id = 'message' . '_id';
     $subjecteditor = '&nbsp;&nbsp;&nbsp;<input type="text" id="questionnaire_subject" size="65"
         maxlength="255" name="subject" value="' . $subject . '" />';
     $format = '';
     $editor = editors_get_preferred_editor();
     $editor->use_editor($id, questionnaire_get_editor_options($context));
     $texteditor = html_writer::tag('div', html_writer::tag('textarea', $message, array('id' => $id, 'name' => "message", 'rows' => '10', 'cols' => '60')));
     echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
     // Print editor.
     $table = new html_table();
     $table->align = array('left', 'left');
     $table->data[] = array('<strong>' . get_string('subject', 'questionnaire') . '</strong>', $subjecteditor);
     $table->data[] = array('<strong>' . get_string('messagebody') . '</strong>', $texteditor);
     echo html_writer::table($table);
     // Send button.
     echo $OUTPUT->box_start('mdl-left');
     echo '<div class="buttons">';
     echo '<input type="submit" name="send_message" value="' . get_string('send', 'questionnaire') . '" />';
     echo '</div>';
     echo $OUTPUT->box_end();
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:show_nonrespondents.php

示例13: advanced_editor

 public function advanced_editor()
 {
     // Only output editor if preferred editor is Atto - tiny mce not supported yet.
     editors_head_setup();
     $editor = editors_get_preferred_editor(FORMAT_HTML);
     if (get_class($editor) == 'atto_texteditor') {
         $editor->use_editor('hiddenadvancededitor');
         return '<div id="hiddenadvancededitorcont"><textarea style="display:none" id="hiddenadvancededitor"></textarea></div>';
     }
     return '';
 }
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:11,代码来源:renderer.php

示例14: format_editor_field

 public static function format_editor_field($datafield, $title, $rows = 3, $cols = 40)
 {
     $content = $datafield->contentparam;
     $format = $datafield->formatparam;
     $context = $datafield->context;
     $field = $datafield->field;
     $itemid = $field->id;
     $name = 'field_' . $itemid;
     editors_head_setup();
     $options = self::get_fileoptions($context);
     if ($itemid) {
         $draftitemid = 0;
         $text = clean_text($field->{$content}, $field->{$format});
         $text = file_prepare_draft_area($draftitemid, $context->id, 'mod_data', 'content', $itemid, $options, $text);
     } else {
         $draftitemid = file_get_unused_draft_itemid();
         $text = '';
     }
     // get filepicker options, if required
     if (empty($options['maxfiles'])) {
         $filepicker_options = array();
     } else {
         $filepicker_options = self::get_filepicker_options($context, $draftitemid, $options['maxbytes']);
     }
     // set up editor
     $editor = editors_get_preferred_editor($field->{$format});
     $editor->set_text($text);
     $editor->use_editor('id_' . $name . '_content', $options, $filepicker_options);
     // format editor
     $output = '';
     $output .= self::format_editor_content($draftitemid, $name, $field->{$content}, $rows, $cols);
     $output .= self::format_editor_formats($editor, $name, $field->{$format});
     return html_writer::tag('div', $output, array('title' => $title));
 }
开发者ID:gbateson,项目名称:moodle-datafield_admin,代码行数:34,代码来源:field.class.php

示例15: print_textarea

/**
 * Prints a basic textarea field.
 *
 * @deprecated since Moodle 2.0
 *
 * When using this function, you should
 *
 * @global object
 * @param bool $usehtmleditor Enables the use of the htmleditor for this field.
 * @param int $rows Number of rows to display  (minimum of 10 when $height is non-null)
 * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
 * @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
 * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
 * @param string $name Name to use for the textarea element.
 * @param string $value Initial content to display in the textarea.
 * @param int $obsolete deprecated
 * @param bool $return If false, will output string. If true, will return string value.
 * @param string $id CSS ID to add to the textarea element.
 * @return string|void depending on the value of $return
 */
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
    /// $width and height are legacy fields and no longer used as pixels like they used to be.
    /// However, you can set them to zero to override the mincols and minrows values below.

    // Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used
    // debugging('print_textarea() has been deprecated. You should be using mforms and the editor element.');

    global $CFG;

    $mincols = 65;
    $minrows = 10;
    $str = '';

    if ($id === '') {
        $id = 'edit-'.$name;
    }

    if ($usehtmleditor) {
        if ($height && ($rows < $minrows)) {
            $rows = $minrows;
        }
        if ($width && ($cols < $mincols)) {
            $cols = $mincols;
        }
    }

    if ($usehtmleditor) {
        editors_head_setup();
        $editor = editors_get_preferred_editor(FORMAT_HTML);
        $editor->use_editor($id, array('legacy'=>true));
    } else {
        $editorclass = '';
    }

    $str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
    if ($usehtmleditor) {
        $str .= htmlspecialchars($value); // needed for editing of cleaned text!
    } else {
        $str .= s($value);
    }
    $str .= '</textarea>'."\n";

    if ($return) {
        return $str;
    }
    echo $str;
}
开发者ID:nuckey,项目名称:moodle,代码行数:67,代码来源:deprecatedlib.php


注:本文中的editors_get_preferred_editor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。