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


PHP file_prepare_draft_area函数代码示例

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


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


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