• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP file_prepare_draft_area函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: set_data

 function set_data($defaults)
 {
     if (empty($entry->id)) {
         $entry = new stdClass();
         $entry->id = null;
     }
     $draftitemid = file_get_submitted_draft_itemid('config_attachments');
     file_prepare_draft_area($draftitemid, $this->block->context->id, 'block_slider', 'content', 0, array('subdirs' => true));
     $entry->attachments = $draftitemid;
     parent::set_data($defaults);
     if ($data = parent::get_data()) {
         file_save_draft_area_files($data->config_attachments, $this->block->context->id, 'block_slider', 'content', 0, array('subdirs' => true));
     }
 }
开发者ID:shinriyadi,项目名称:moodle,代码行数:14,代码来源:edit_form.php


示例2: data_preprocessing

 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     $dragids = array();
     // drag no -> dragid
     if (!empty($question->options)) {
         $question->shuffleanswers = $question->options->shuffleanswers;
         $question->drags = array();
         foreach ($question->options->drags as $drag) {
             $dragindex = $drag->no - 1;
             $question->drags[$dragindex] = array();
             $question->drags[$dragindex]['draglabel'] = $drag->label;
             $question->drags[$dragindex]['infinite'] = $drag->infinite;
             $question->drags[$dragindex]['draggroup'] = $drag->draggroup;
             $dragids[$dragindex] = $drag->id;
         }
         $question->drops = array();
         foreach ($question->options->drops as $drop) {
             $question->drops[$drop->no - 1] = array();
             $question->drops[$drop->no - 1]['choice'] = $drop->choice;
             $question->drops[$drop->no - 1]['droplabel'] = $drop->label;
             $question->drops[$drop->no - 1]['xleft'] = $drop->xleft;
             $question->drops[$drop->no - 1]['ytop'] = $drop->ytop;
         }
     }
     //initialise file picker for bgimage
     $draftitemid = file_get_submitted_draft_itemid('bgimage');
     file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', 'bgimage', !empty($question->id) ? (int) $question->id : null, self::file_picker_options());
     $question->bgimage = $draftitemid;
     //initialise file picker for dragimages
     list(, $imagerepeats) = $this->get_drag_item_repeats();
     $draftitemids = optional_param_array('dragitem', array(), PARAM_INT);
     for ($imageindex = 0; $imageindex < $imagerepeats; $imageindex++) {
         $draftitemid = isset($draftitemids[$imageindex]) ? $draftitemids[$imageindex] : 0;
         //numbers not allowed in filearea name
         $itemid = isset($dragids[$imageindex]) ? $dragids[$imageindex] : null;
         file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', 'dragimage', $itemid, self::file_picker_options());
         $question->dragitem[$imageindex] = $draftitemid;
     }
     if (!empty($question->options)) {
         foreach ($question->options->drags as $drag) {
             $dragindex = $drag->no - 1;
             if (!isset($question->dragitem[$dragindex])) {
                 $fileexists = false;
             } else {
                 $fileexists = self::file_uploaded($question->dragitem[$dragindex]);
             }
             $labelexists = trim($question->drags[$dragindex]['draglabel']) != '';
             if ($labelexists && !$fileexists) {
                 $question->dragitemtype[$dragindex] = 'word';
             } else {
                 $question->dragitemtype[$dragindex] = 'image';
             }
         }
     }
     $this->js_call();
     return $question;
 }
开发者ID:ndunand,项目名称:moodle-qtype_ddimageortext,代码行数:60,代码来源:edit_ddimageortext_form.php


示例3: data_preprocessing

 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (empty($question->options)) {
         return $question;
     }
     $question->shuffleanswers = $question->options->shuffleanswers;
     $key = 0;
     foreach ($question->options->subquestions as $subquestion) {
         $question->subanswers[$key] = $subquestion->answertext;
         $draftid = file_get_submitted_draft_itemid('subquestions[' . $key . ']');
         $question->subquestions[$key] = array();
         $question->subquestions[$key]['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_ddmatch', 'subquestion', !empty($subquestion->id) ? (int) $subquestion->id : null, $this->fileoptions, $subquestion->questiontext);
         $question->subquestions[$key]['format'] = $subquestion->questiontextformat;
         $question->subquestions[$key]['itemid'] = $draftid;
         $draftid = file_get_submitted_draft_itemid('subanswers[' . $key . ']');
         $question->subanswers[$key] = array();
         $question->subanswers[$key]['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_ddmatch', 'subanswer', !empty($subquestion->id) ? (int) $subquestion->id : null, $this->fileoptions, $subquestion->answertext);
         $question->subanswers[$key]['format'] = $subquestion->answertextformat;
         $question->subanswers[$key]['itemid'] = $draftid;
         $key++;
     }
     return $question;
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:26,代码来源:edit_ddmatch_form.php


示例4: data_preprocessing

 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     if (empty($question->options)) {
         return $question;
     }
     $question->responseformat = $question->options->responseformat;
     $question->responsefieldlines = $question->options->responsefieldlines;
     $question->attachments = $question->options->attachments;
     $question->boardsize = $question->options->boardsize;
     //Set backimage details, and configure a draft area to accept any uploaded pictures
     //all this and this whole method does, is to load existing files into a filearea
     //so it is not called when creating a new question, only when editing an existing one
     //best to use file_get_submitted_draft_itemid - because copying questions gets weird otherwise
     //$draftitemid =$question->options->backimage;
     $draftitemid = file_get_submitted_draft_itemid('backimage');
     file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_poodllrecording', 'backimage', !empty($question->id) ? (int) $question->id : null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
     $question->backimage = $draftitemid;
     $draftid = file_get_submitted_draft_itemid('graderinfo');
     $question->graderinfo = array();
     $question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
     $question->graderinfo['format'] = $question->options->graderinfoformat;
     $question->graderinfo['itemid'] = $draftid;
     return $question;
 }
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:25,代码来源:edit_poodllrecording_form.php


示例5: test_get_unused_filename

 public function test_get_unused_filename()
 {
     global $USER;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $fs = get_file_storage();
     $draftitemid = null;
     $context = context_user::instance($USER->id);
     file_prepare_draft_area($draftitemid, $context->id, 'phpunit', 'test_get_unused_filename', 1);
     $dummy = array('contextid' => $context->id, 'component' => 'user', 'filearea' => 'draft', 'itemid' => $draftitemid, 'filepath' => '/', 'filename' => '');
     // Create some files.
     $existingfiles = array('test', 'test.txt', 'test (1).txt', 'test1.txt', 'test1 (1).txt', 'test1 (2).txt', 'test1 (3).txt', 'test1 (My name is Bob).txt', 'test2 (555).txt', 'test3 (1000).txt', 'test3 (1000MB).txt');
     foreach ($existingfiles as $filename) {
         $dummy['filename'] = $filename;
         $file = $fs->create_file_from_string($dummy, 'blah! ' . $filename);
         $this->assertTrue(repository::draftfile_exists($draftitemid, '/', $filename));
     }
     // Actual testing.
     $this->assertEquals('free.txt', repository::get_unused_filename($draftitemid, '/', 'free.txt'));
     $this->assertEquals('test (1)', repository::get_unused_filename($draftitemid, '/', 'test'));
     $this->assertEquals('test (2).txt', repository::get_unused_filename($draftitemid, '/', 'test.txt'));
     $this->assertEquals('test1 (4).txt', repository::get_unused_filename($draftitemid, '/', 'test1.txt'));
     $this->assertEquals('test1 (8).txt', repository::get_unused_filename($draftitemid, '/', 'test1 (8).txt'));
     $this->assertEquals('test1 ().txt', repository::get_unused_filename($draftitemid, '/', 'test1 ().txt'));
     $this->assertEquals('test2 (556).txt', repository::get_unused_filename($draftitemid, '/', 'test2 (555).txt'));
     $this->assertEquals('test3 (1001).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000).txt'));
     $this->assertEquals('test3 (1000MB) (1).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000MB).txt'));
     $this->assertEquals('test4 (1).txt', repository::get_unused_filename($draftitemid, '/', 'test4 (1).txt'));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:29,代码来源:repositorylib_test.php


示例6: definition_appearance

 /**
  *
  */
 protected function definition_appearance()
 {
     global $COURSE;
     // We want to hide that when using the singleactivity course format because it is confusing.
     if (!$this->courseformat->has_view_page()) {
         return;
     }
     $mform =& $this->_form;
     $mform->addElement('header', 'coursedisplayhdr', get_string('appearance'));
     // Activity icon.
     $options = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 1, 'accepted_types' => array('image'));
     $draftitemid = file_get_submitted_draft_itemid('activityicon');
     file_prepare_draft_area($draftitemid, $this->context->id, 'mod_dataform', 'activityicon', 0, $options);
     $mform->addElement('filemanager', 'activityicon', get_string('activityicon', 'dataform'), null, $options);
     $mform->setDefault('activityicon', $draftitemid);
     $mform->addHelpButton('activityicon', 'activityicon', 'mod_dataform');
     // Displayed view.
     $options = array(0 => get_string('choosedots'));
     if ($this->_instance) {
         if ($views = mod_dataform_view_manager::instance($this->_instance)->views_menu) {
             $options = $options + $views;
         }
     }
     $mform->addElement('select', 'inlineview', get_string('inlineview', 'mod_dataform'), $options);
     $mform->addHelpButton('inlineview', 'inlineview', 'mod_dataform');
     // Embedded.
     $mform->addElement('selectyesno', 'embedded', get_string('embedded', 'mod_dataform'));
     $mform->addHelpButton('embedded', 'embedded', 'mod_dataform');
     $mform->disabledIf('embedded', 'inlineview', 'eq', 0);
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:33,代码来源:mod_form.php


示例7: data_preprocessing

 function data_preprocessing($question)
 {
     if (isset($question->options)) {
         $answers = $question->options->answers;
         $answers_ids = array();
         if (count($answers)) {
             $key = 0;
             foreach ($answers as $answer) {
                 $answers_ids[] = $answer->id;
                 $default_values['answer[' . $key . ']'] = $answer->answer;
                 $default_values['fraction[' . $key . ']'] = $answer->fraction;
                 $default_values['feedback[' . $key . ']'] = array();
                 // prepare feedback editor to display files in draft area
                 $draftid_editor = file_get_submitted_draft_itemid('feedback[' . $key . ']');
                 $default_values['feedback[' . $key . ']']['text'] = file_prepare_draft_area($draftid_editor, $this->context->id, 'question', 'answerfeedback', !empty($answer->id) ? (int) $answer->id : null, $this->fileoptions, $answer->feedback);
                 $default_values['feedback[' . $key . ']']['itemid'] = $draftid_editor;
                 // prepare files code block ends
                 $default_values['feedback[' . $key . ']']['format'] = $answer->feedbackformat;
                 $key++;
             }
         }
         $default_values['usecase'] = $question->options->usecase;
         $question = (object) ((array) $question + $default_values);
     }
     return $question;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:26,代码来源:edit_shortanswer_form.php


示例8: set_data

 function set_data($question)
 {
     if (!empty($question->options->trueanswer)) {
         $trueanswer = $question->options->answers[$question->options->trueanswer];
         $draftid = file_get_submitted_draft_itemid('trueanswer');
         $answerid = $question->options->trueanswer;
         $text = $trueanswer->feedback;
         $question->correctanswer = $trueanswer->fraction != 0;
         $question->feedbacktrue = array();
         $question->feedbacktrue['text'] = $trueanswer->feedback;
         $question->feedbacktrue['format'] = $trueanswer->feedbackformat;
         $question->feedbacktrue['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
         $question->feedbacktrue['itemid'] = $draftid;
     }
     if (!empty($question->options->falseanswer)) {
         $falseanswer = $question->options->answers[$question->options->falseanswer];
         $draftid = file_get_submitted_draft_itemid('falseanswer');
         $answerid = $question->options->falseanswer;
         $text = $falseanswer->feedback;
         $question->feedbackfalse = array();
         $question->feedbackfalse['text'] = $falseanswer->feedback;
         $question->feedbackfalse['format'] = $falseanswer->feedbackformat;
         $question->feedbackfalse['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
         $question->feedbackfalse['itemid'] = $draftid;
     }
     parent::set_data($question);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:27,代码来源:edit_truefalse_form.php


示例9: data_preprocessing

 function data_preprocessing(&$default_values)
 {
     // Aaah.. we meet again h5pfile!
     $draftitemid = file_get_submitted_draft_itemid('h5pfile');
     file_prepare_draft_area($draftitemid, $this->context->id, 'mod_hvp', 'package', 0);
     $default_values['h5pfile'] = $draftitemid;
 }
开发者ID:brum1975,项目名称:h5p-moodle-plugin,代码行数:7,代码来源:mod_form.php


示例10: test_upgrade_fix_missing_root_folders_draft

 public function test_upgrade_fix_missing_root_folders_draft()
 {
     global $DB, $SITE;
     $this->resetAfterTest(true);
     $user = $this->getDataGenerator()->create_user();
     $usercontext = context_user::instance($user->id);
     $this->setUser($user);
     $resource1 = $this->getDataGenerator()->get_plugin_generator('mod_resource')->create_instance(array('course' => $SITE->id));
     $context = context_module::instance($resource1->cmid);
     $draftitemid = 0;
     file_prepare_draft_area($draftitemid, $context->id, 'mod_resource', 'content', 0);
     $queryparams = array('component' => 'user', 'contextid' => $usercontext->id, 'filearea' => 'draft', 'itemid' => $draftitemid);
     // Make sure there are two records in files for the draft file area and one of them has filename '.'.
     $records = $DB->get_records_menu('files', $queryparams, '', 'id, filename');
     $this->assertEquals(2, count($records));
     $this->assertTrue(in_array('.', $records));
     $originalhash = $DB->get_field('files', 'pathnamehash', $queryparams + array('filename' => '.'));
     // Delete record with filename '.' and make sure it does not exist any more.
     $DB->delete_records('files', $queryparams + array('filename' => '.'));
     $records = $DB->get_records_menu('files', $queryparams, '', 'id, filename');
     $this->assertEquals(1, count($records));
     $this->assertFalse(in_array('.', $records));
     // Run upgrade script and make sure the record is restored.
     upgrade_fix_missing_root_folders_draft();
     $records = $DB->get_records_menu('files', $queryparams, '', 'id, filename');
     $this->assertEquals(2, count($records));
     $this->assertTrue(in_array('.', $records));
     $newhash = $DB->get_field('files', 'pathnamehash', $queryparams + array('filename' => '.'));
     $this->assertEquals($originalhash, $newhash);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:30,代码来源:upgradelib_test.php


示例11: data_preprocessing

    protected function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);

        if (empty($question->options)) {
            return $question;
        }

        $question->responseformat = $question->options->responseformat;
        $question->responsefieldlines = $question->options->responsefieldlines;
        $question->attachments = $question->options->attachments;

        $draftid = file_get_submitted_draft_itemid('graderinfo');
        $question->graderinfo = array();
        $question->graderinfo['text'] = file_prepare_draft_area(
            $draftid,           // draftid
            $this->context->id, // context
            'qtype_essay',      // component
            'graderinfo',       // filarea
            !empty($question->id) ? (int) $question->id : null, // itemid
            $this->fileoptions, // options
            $question->options->graderinfo // text
        );
        $question->graderinfo['format'] = $question->options->graderinfoformat;
        $question->graderinfo['itemid'] = $draftid;

        return $question;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:27,代码来源:edit_essay_form.php


示例12: set_data

 function set_data($defaults)
 {
     if (!empty($this->block->config) && is_object($this->block->config)) {
         $whatshot = $this->block->config->whatshot;
         $draftid_editor = file_get_submitted_draft_itemid('config_whatshot');
         if (empty($whatshot)) {
             $currenttext = '';
         } else {
             $currenttext = $whatshot;
         }
         $defaults->config_whatshot['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_dashboard', 'content', 0, array('subdirs' => true), $currenttext);
         $defaults->config_whatshot['itemid'] = $draftid_editor;
         $defaults->config_whatshot['format'] = $this->block->config->format;
     } else {
         $whatshot = '';
     }
     if (!$this->block->user_can_edit() && !empty($this->block->config->title)) {
         // If a title has been set but the user cannot edit it format it nicely
         $title = $this->block->config->title;
         $defaults->config_title = format_string($title, true, $this->page->context);
         // Remove the title from the config so that parent::set_data doesn't set it.
         unset($this->block->config->title);
     }
     // have to delete text here, otherwise parent::set_data will empty content
     // of editor
     unset($this->block->config->whatshot);
     parent::set_data($defaults);
     // restore $text
     $this->block->config->whatshot = $whatshot;
     if (isset($title)) {
         // Reset the preserved title
         $this->block->config->title = $title;
     }
 }
开发者ID:rtsfc,项目名称:moodle-block_dashboard,代码行数:34,代码来源:edit_form.php


示例13: data_preprocessing

 function data_preprocessing(&$default_values) {
     if ($this->current->instance) {
         // editing existing instance - copy existing files into draft area
         $draftitemid = file_get_submitted_draft_itemid('files');
         file_prepare_draft_area($draftitemid, $this->context->id, 'mod_folder', 'content', 0, array('subdirs'=>true));
         $default_values['files'] = $draftitemid;
     }
 }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:8,代码来源:mod_form.php


示例14: prepare_message_for_edit

 public function prepare_message_for_edit($cm, $post)
 {
     $this->append_edited_by($post);
     $context = \context_module::instance($cm->id);
     $post = trusttext_pre_edit($post, 'message', $context);
     $itemid = file_get_submitted_draft_itemid('message');
     $message = file_prepare_draft_area($itemid, $context->id, 'mod_hsuforum', 'post', $post->id, \mod_hsuforum_post_form::editor_options($context, $post->id), $post->message);
     return array($message, $itemid);
 }
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:9,代码来源:form_service.php


示例15: definition_after_data

 /**
  * Fill in the current page data for this customcert.
  */
 public function definition_after_data()
 {
     $mform = $this->_form;
     // Editing existing instance - copy existing files into draft area.
     $draftitemid = file_get_submitted_draft_itemid('customcertimage');
     file_prepare_draft_area($draftitemid, context_system::instance()->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
     $element = $mform->getElement('customcertimage');
     $element->setValue($draftitemid);
 }
开发者ID:rezaies,项目名称:moodle-mod_customcert,代码行数:12,代码来源:upload_image_form.php


示例16: set_data

 function set_data($defaults)
 {
     global $COURSE;
     if (!$this->block->user_can_edit()) {
         if (!empty($this->block->config->title)) {
             // If a title has been set but the user cannot edit it format it nicely
             $title = $this->block->config->title;
             $defaults->config_title = format_string($title, true, $this->page->context);
             // Remove the title from the config so that parent::set_data doesn't set it.
             unset($this->block->config->title);
         }
         if (!empty($this->block->config->imagespot)) {
             $fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
             $draftitemid = '';
             file_prepare_draft_area($draftitemid, $this->block->context->id, 'block_informationspot', 'image', 0, $fileoptions);
             $defaults->config_imagespot = $draftitemid;
             unset($this->block->config->imagespot);
         }
         if (!empty($this->block->config->text)) {
             $text = $this->block->config->text;
             $defaults->config_text = format_text($text, true, $this->page->context);
             unset($this->block->config->text);
         }
         if (!empty($this->block->config->buttontext)) {
             $buttontext = $this->block->config->buttontext;
             $defaults->config_buttontext = format_string($buttontext, true, $this->page->context);
             unset($this->block->config->buttontext);
         }
         if (!empty($this->block->config->buttonlink)) {
             $buttonlink = $this->block->config->buttonlink;
             $defaults->config_buttonlink = $buttonlink;
             unset($this->block->config->buttonlink);
         }
     }
     parent::set_data($defaults);
     if (!isset($this->block->config)) {
         $this->block->config = new stdClass();
     }
     if (isset($title)) {
         $this->block->config->title = $title;
     }
     if (isset($draftitemid)) {
         $this->block->config->imagespot = $draftitemid;
     }
     if (isset($title)) {
         $this->block->config->title = $title;
     }
     if (isset($text)) {
         $this->block->config->text = $text;
     }
     if (isset($buttontext)) {
         $this->block->config->buttontext = $buttontext;
     }
     if (isset($buttonlink)) {
         $this->block->config->buttonlink = $title;
     }
 }
开发者ID:bobopinna,项目名称:moodle-blocks_informationspot,代码行数:57,代码来源:edit_form.php


示例17: display_add_field

 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE, $USER;
     $file = false;
     $content = false;
     $displayname = '';
     $fs = get_file_storage();
     $context = $PAGE->context;
     $itemid = null;
     // editing an existing database entry
     if ($recordid) {
         if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
             file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id);
             if (!empty($content->content)) {
                 if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
                     $usercontext = context_user::instance($USER->id);
                     if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false))) {
                         return false;
                     }
                     if (empty($content->content1)) {
                         // Print icon if file already exists
                         $src = moodle_url::make_draftfile_url($itemid, '/', $file->get_filename());
                         $displayname = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . '<a href="' . $src . '" >' . s($file->get_filename()) . '</a>';
                     } else {
                         $displayname = 'no file added';
                     }
                 }
             }
         }
     } else {
         $itemid = file_get_unused_draft_itemid();
     }
     $html = '';
     // database entry label
     $html .= '<div title="' . s($this->field->description) . '">';
     $html .= '<fieldset><legend><span class="accesshide">' . $this->field->name . '</span></legend>';
     // itemid element
     $html .= '<input type="hidden" name="field_' . $this->field->id . '_file" value="' . $itemid . '" />';
     $options = new stdClass();
     $options->maxbytes = $this->field->param3;
     $options->maxfiles = 1;
     // Limit to one file for the moment, this may be changed if requested as a feature in the future.
     $options->itemid = $itemid;
     $options->accepted_types = '*';
     $options->return_types = FILE_INTERNAL;
     $options->context = $PAGE->context;
     $fm = new form_filemanager($options);
     // Print out file manager.
     $output = $PAGE->get_renderer('core', 'files');
     $html .= $output->render($fm);
     $html .= '</fieldset>';
     $html .= '</div>';
     $module = array('name' => 'form_filemanager', 'fullpath' => '/lib/form/filemanager.js', 'requires' => array('core_filepicker', 'base', 'io-base', 'node', 'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin'), 'strings' => array(array('error', 'moodle'), array('info', 'moodle'), array('confirmdeletefile', 'repository'), array('draftareanofiles', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'), array('invalidjson', 'repository'), array('popupblockeddownload', 'repository'), array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'), array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'), array('confirmrenamefile', 'repository'), array('edit', 'moodle')));
     $PAGE->requires->js_init_call('M.form_filemanager.init', array($fm->options), true, $module);
     return $html;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:56,代码来源:field.class.php


示例18: 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


示例19: display_add_field

 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE, $USER;
     $file = false;
     $content = false;
     $displayname = '';
     $fs = get_file_storage();
     $context = $PAGE->context;
     $itemid = null;
     // editing an existing database entry
     if ($recordid) {
         if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
             file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id);
             if (!empty($content->content)) {
                 if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
                     $usercontext = context_user::instance($USER->id);
                     if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false))) {
                         return false;
                     }
                     if (empty($content->content1)) {
                         // Print icon if file already exists
                         $src = moodle_url::make_draftfile_url($itemid, '/', $file->get_filename());
                         $displayname = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . '<a href="' . $src . '" >' . s($file->get_filename()) . '</a>';
                     } else {
                         $displayname = 'no file added';
                     }
                 }
             }
         }
     } else {
         $itemid = file_get_unused_draft_itemid();
     }
     $html = '';
     // database entry label
     $html .= '<div title="' . s($this->field->description) . '">';
     $html .= '<fieldset><legend><span class="accesshide">' . $this->field->name . '</span></legend>';
     // itemid element
     $html .= '<input type="hidden" name="field_' . $this->field->id . '_file" value="' . $itemid . '" />';
     $options = new stdClass();
     $options->maxbytes = $this->field->param3;
     $options->maxfiles = 1;
     // Limit to one file for the moment, this may be changed if requested as a feature in the future.
     $options->itemid = $itemid;
     $options->accepted_types = '*';
     $options->return_types = FILE_INTERNAL;
     $options->context = $PAGE->context;
     $fm = new form_filemanager($options);
     // Print out file manager.
     $output = $PAGE->get_renderer('core', 'files');
     $html .= $output->render($fm);
     $html .= '</fieldset>';
     $html .= '</div>';
     return $html;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:54,代码来源:field.class.php


示例20: display_add_field

 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE, $USER;
     $file = false;
     $content = false;
     $displayname = '';
     $fs = get_file_storage();
     $context = $PAGE->context;
     $itemid = null;
     // editing an existing database entry
     if ($recordid) {
         if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
             file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id);
             if (!empty($content->content)) {
                 if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
                     $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
                     if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false))) {
                         return false;
                     }
                     if (empty($content->content1)) {
                         // Print icon if file already exists
                         $src = moodle_url::make_draftfile_url($itemid, '/', $file->get_filename());
                         $displayname = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . '<a href="' . $src . '" >' . s($file->get_filename()) . '</a>';
                     } else {
                         $displayname = 'no file added';
                     }
                 }
             }
         }
     } else {
         $itemid = file_get_unused_draft_itemid();
     }
     $html = '';
     // database entry label
     $html .= '<div title="' . s($this->field->description) . '">';
     $html .= '<fieldset><legend><span class="accesshide">' . $this->field->name . '</span></legend>';
     // itemid element
     $html .= '<input type="hidden" name="field_' . $this->field->id . '_file" value="' . $itemid . '" />';
     $options = new stdClass();
     $options->maxbytes = $this->field->param3;
     $options->itemid = $itemid;
     $options->accepted_types = '*';
     $options->return_types = FILE_INTERNAL;
     $options->context = $PAGE->context;
     $fp = new file_picker($options);
     // print out file picker
     $html .= $OUTPUT->render($fp);
     $html .= '</fieldset>';
     $html .= '</div>';
     $module = array('name' => 'data_filepicker', 'fullpath' => '/mod/data/data.js', 'requires' => array('core_filepicker'));
     $PAGE->requires->js_init_call('M.data_filepicker.init', array($fp->options), true, $module);
     return $html;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:53,代码来源:field.class.php



注:本文中的file_prepare_draft_area函数示例整理自Github/MS


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_prepare_standard_editor函数代码示例发布时间:2022-05-15
下一篇:
PHP file_prepare_directory函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap