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

PHP file_set_sortorder函数代码示例

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

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



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

示例1: store_annotation_document

function store_annotation_document($data)
{
    global $DB, $CFG;
    $fs = get_file_storage();
    $cmid = $data->coursemodule;
    $draftitemid = $data->files;
    $context = context_module::instance($cmid);
    if ($draftitemid) {
        $messagetext = file_save_draft_area_files($draftitemid, $context->id, 'mod_annotation', 'content', 0, array('subdirs' => true));
    }
    $files = $fs->get_area_files($context->id, 'mod_annotation', 'content', 0, 'sortorder', false);
    if (count($files) == 1) {
        // Only one file attached, set it as main file automatically.
        $file = reset($files);
        file_set_sortorder($context->id, 'mod_annotation', 'content', 0, $file->get_filepath(), $file->get_filename(), 1);
    }
    // Find out the file location by getting the content hash.
    $table = "files";
    $results = $DB->get_records($table, array('itemid' => $draftitemid));
    foreach ($results as $result) {
        $userid = $result->userid;
        $timecreated = $result->timecreated;
        $contenthash = $result->contenthash;
        break;
        // Bad way of doing it, TODO.
    }
    // Insert a reference into mdl_annotation_document.
    $table = 'annotation_document';
    $record = new stdClass();
    $record->id = 0;
    // DB will auto increment it.
    $record->userid = $userid;
    $record->group_id = 0;
    $record->time_created = $timecreated;
    $record->documenttype = $data->type;
    $record->location = $contenthash;
    $record->lang = "";
    // Lang column no longer used, highlightjs automatically detects language.
    $record->cmid = $cmid;
    $record->groupannotation = $data->groupannotation;
    if (isset($record->groupannotationsvisible)) {
        $record->groupannotationsvisible = $data->groupannotationsvisible;
    } else {
        $record->groupannotationsvisible = 0;
    }
    $record->allowfrom = $data->allowfrom;
    $record->allowuntil = $data->allowuntil;
    $insertid = $DB->insert_record('annotation_document', $record, false);
}
开发者ID:jamiemcg,项目名称:moodle-collaborative-annotation,代码行数:49,代码来源:locallib.php


示例2: pdfparts_set_mainfile

/**
 * Saves the file from pdfparts record somewhere on the server.
 * @param object $data
 */
function pdfparts_set_mainfile($data)
{
    global $DB;
    $fs = get_file_storage();
    $cmid = $data->coursemodule;
    $draftitemid = $data->files;
    $context = context_module::instance($cmid);
    if ($draftitemid) {
        file_save_draft_area_files($draftitemid, $context->id, 'mod_pdfparts', 'content', 0, array('subdirs' => true));
    }
    $files = $fs->get_area_files($context->id, 'mod_pdfparts', 'content', 0, 'sortorder', false);
    if (count($files) == 1) {
        // only one file attached, set it as main file automatically
        $file = reset($files);
        file_set_sortorder($context->id, 'mod_pdfparts', 'content', 0, $file->get_filepath(), $file->get_filename(), 1);
    }
}
开发者ID:lex-programmer,项目名称:moodle-mod_pdfparts,代码行数:21,代码来源:locallib.php


示例3: validation

 function validation($data, $files)
 {
     global $USER;
     $errors = parent::validation($data, $files);
     $usercontext = context_user::instance($USER->id);
     $fs = get_file_storage();
     if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['files'], 'sortorder, id', false))) {
         $errors['files'] = get_string('required');
         return $errors;
     }
     if (count($files) == 1) {
         // no need to select main file if only one picked
         return $errors;
     } else {
         if (count($files) > 1) {
             $mainfile = false;
             foreach ($files as $file) {
                 if ($file->get_sortorder() == 1) {
                     $mainfile = true;
                     break;
                 }
             }
             // set a default main file
             if (!$mainfile) {
                 $file = reset($files);
                 file_set_sortorder($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename(), 1);
             }
         }
     }
     return $errors;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:mod_form.php


示例4: validation

 /**
  * validation
  *
  * @param xxx $data
  * @return xxx
  */
 function validation($data, $files)
 {
     global $USER;
     // http://docs.moodle.org/en/Development:lib/formslib.php_Validation
     // Note: see "lang/en/error.php" for a list of common messages
     $errors = array();
     // get the $files specified in the form
     $usercontext = hotpot_get_context(CONTEXT_USER, $USER->id);
     $fs = get_file_storage();
     $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['sourceitemid'], 'sortorder, id', 0);
     // files only, no dirs
     // check we have at least one file
     // (and set mainfile marker, if necessary)
     if (empty($files)) {
         $errors['sourceitemid'] = get_string('required');
         // $errors['sourceitemid'] = get_string('nofile', 'error');
     } else {
         $mainfile = false;
         foreach ($files as $file) {
             if ($file->get_sortorder() == 1) {
                 $mainfile = true;
                 break;
             }
         }
         if (!$mainfile) {
             $file = reset($files);
             // first file in the list
             file_set_sortorder($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename(), 1);
         }
     }
     // studentfeedbackurl
     if ($data['studentfeedback'] == hotpot::FEEDBACK_WEBPAGE || $data['studentfeedback'] == hotpot::FEEDBACK_FORMMAIL) {
         if (empty($data['studentfeedbackurl']) || !preg_match('/^https?:\\/\\/.+/', $data['studentfeedbackurl'])) {
             // empty or invalid url
             $errors['studentfeedback_elements'] = get_string('invalidurl', 'error');
         }
     }
     return $errors;
 }
开发者ID:hapaxapah,项目名称:moodle-mod_hotpot,代码行数:45,代码来源:mod_form.php


示例5: json_encode

             } else {
                 echo json_encode(false);
             }
         }
     } else {
         echo json_encode(false);
     }
     die;
 case 'setmainfile':
     $filename = required_param('filename', PARAM_FILE);
     $filepath = required_param('filepath', PARAM_PATH);
     $filepath = file_correct_filepath($filepath);
     // reset sort order
     file_reset_sortorder($user_context->id, 'user', 'draft', $draftid);
     // set main file
     $return = file_set_sortorder($user_context->id, 'user', 'draft', $draftid, $filepath, $filename, 1);
     echo json_encode($return);
     die;
 case 'updatefile':
     // Allows to Rename file, move it to another directory, change it's license and author information in one request
     $filename = required_param('filename', PARAM_FILE);
     $filepath = required_param('filepath', PARAM_PATH);
     $fs = get_file_storage();
     if (!($file = $fs->get_file($user_context->id, 'user', 'draft', $draftid, $filepath, $filename))) {
         die(json_encode((object) array('error' => get_string('filenotfound', 'error'))));
     }
     $updatedata = array();
     $updatedata['filename'] = $newfilename = optional_param('newfilename', $file->get_filename(), PARAM_FILE);
     $updatedata['filepath'] = $newfilepath = optional_param('newfilepath', $file->get_filepath(), PARAM_PATH);
     $updatedata['license'] = optional_param('newlicense', $file->get_license(), PARAM_TEXT);
     $updatedata['author'] = optional_param('newauthor', $file->get_author(), PARAM_TEXT);
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:draftfiles_ajax.php


示例6: xmldb_resource_upgrade


//.........这里部分代码省略.........
        // Define field legacyfiles to be added to resource
        $field = new xmldb_field('legacyfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'mainfile');
        // Conditionally launch add field legacyfiles
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field legacyfileslast to be added to resource
        $field = new xmldb_field('legacyfileslast', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'legacyfiles');
        // Conditionally launch add field legacyfileslast
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field display to be added to resource
        $field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'legacyfileslast');
        // Conditionally launch add field display
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field displayoptions to be added to resource
        $field = new xmldb_field('displayoptions', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'display');
        // Conditionally launch add field displayoptions
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field filterfiles to be added to resource
        $field = new xmldb_field('filterfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'displayoptions');
        // Conditionally launch add field filterfiles
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field revision to be added to resource
        $field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'filterfiles');
        // Conditionally launch add field revision
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        //mark all records as awaiting migration
        $DB->set_field('resource', 'tobemigrated', 1, array());
        // resource savepoint reached
        upgrade_mod_savepoint(true, 2009062601, 'resource');
    }
    if ($oldversion < 2009062603) {
        resource_20_migrate();
        upgrade_mod_savepoint(true, 2009062603, 'resource');
    }
    if ($oldversion < 2009063000) {
        //migrate and prune old settings - admins need to review and set up all module settings anyway
        if (!empty($CFG->resource_framesize)) {
            set_config('framesize', $CFG->resource_framesize, 'resource');
        }
        if (!empty($CFG->resource_popupheight)) {
            set_config('popupheight', $CFG->resource_popupheight, 'resource');
        }
        if (!empty($CFG->resource_popupwidth)) {
            set_config('popupwidth', $CFG->resource_popupwidth, 'resource');
        }
        $cleanupsettings = array('resource_framesize', 'resource_popupheight', 'resource_popupwidth', 'resource_popupmenubar', 'resource_websearch', 'resource_defaulturl', 'resource_allowlocalfiles', 'resource_popup', 'resource_popupresizable', 'resource_popupscrollbars', 'resource_popupdirectories', 'resource_popuplocation', 'resource_popuptoolbar', 'resource_popupstatus');
        foreach ($cleanupsettings as $setting) {
            unset_config($setting);
        }
        upgrade_mod_savepoint(true, 2009063000, 'resource');
    }
    if ($oldversion < 2009080501) {
        require_once "{$CFG->libdir}/filelib.php";
        $sql = "SELECT r.id,\n                       r.mainfile,\n                       cm.id AS cmid\n                  FROM {resource} r\n                  JOIN {modules} m ON m.name='resource'\n                  JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = r.id)";
        $instances = $DB->get_recordset_sql($sql);
        foreach ($instances as $instance) {
            if (empty($instance->mainfile)) {
                // weird
                continue;
            }
            $context = get_context_instance(CONTEXT_MODULE, $instance->cmid, MUST_EXIST);
            $parts = explode('/', $instance->mainfile);
            $filename = array_pop($parts);
            $filepath = implode('/', $parts);
            file_set_sortorder($context->id, 'mod_resource', 'content', 0, $filepath, $filename, 1);
        }
        $instances->close();
        /// Define field mainfile to be dropped from resource
        $table = new xmldb_table('resource');
        $field = new xmldb_field('mainfile');
        $dbman->drop_field($table, $field);
        /// resource savepoint reached
        upgrade_mod_savepoint(true, 2009080501, 'resource');
    }
    // MDL-10906. Removing resource_allowlocalfiles setting.
    if ($oldversion < 2010083000) {
        unset_config('resource_allowlocalfiles');
        upgrade_mod_savepoint(true, 2010083000, 'resource');
    }
    if ($oldversion < 2011022700) {
        // refresh resource links breakage caused by invalid sortorder
        require_once $CFG->dirroot . '/course/lib.php';
        rebuild_course_cache(0, true);
        upgrade_mod_savepoint(true, 2011022700, 'resource');
    }
    // Moodle v2.1.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:upgrade.php


示例7: geogebra_extract_package

/**
 * Extracts GGB package, sets up all variables.
 * @param int $cmid
 * @return filename
 */
function geogebra_extract_package($cmid)
{
    global $DB;
    $fs = get_file_storage();
    $context = context_module::instance($cmid);
    $files = $fs->get_area_files($context->id, 'mod_geogebra', 'content', 0, 'sortorder', false);
    if (count($files) == 1) {
        // only one file attached, set it as main file automatically
        $package = reset($files);
        file_set_sortorder($context->id, 'mod_geogebra', 'content', 0, $package->get_filepath(), $package->get_filename(), 1);
        $filename = $package->get_filename();
        // Extract files
        $fs->delete_area_files($context->id, 'mod_geogebra', 'extracted_files');
        $packer = get_file_packer('application/zip');
        $package->extract_to_storage($packer, $context->id, 'mod_geogebra', 'extracted_files', 0, '/');
    }
    return $filename;
}
开发者ID:ninelanterns,项目名称:moodle-mod_geogebra,代码行数:23,代码来源:locallib.php


示例8: set_mainfile

 public function set_mainfile()
 {
     $fs = get_file_storage();
     $fileid = $this->instance->url;
     if ($fileid) {
         file_save_draft_area_files($fileid, $this->context->id, 'mod_jclic', 'content', 0, self::get_filemanager_options());
     }
     $files = $fs->get_area_files($this->context->id, 'mod_jclic', 'content', 0, 'sortorder', false);
     if (count($files) == 1) {
         // only one file attached, set it as main file automatically
         $file = reset($files);
         file_set_sortorder($this->context->id, 'mod_jclic', 'content', 0, $file->get_filepath(), $file->get_filename(), 1);
         return $file->get_filename();
     }
     return null;
 }
开发者ID:danielvdml,项目名称:moodleyarcho,代码行数:16,代码来源:locallib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP file_size函数代码示例发布时间:2022-05-15
下一篇:
PHP file_scan_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