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


PHP backup_general_helper::detect_backup_format方法代码示例

本文整理汇总了PHP中backup_general_helper::detect_backup_format方法的典型用法代码示例。如果您正苦于以下问题:PHP backup_general_helper::detect_backup_format方法的具体用法?PHP backup_general_helper::detect_backup_format怎么用?PHP backup_general_helper::detect_backup_format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backup_general_helper的用法示例。


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

示例1: display

 /**
  * Renders the destination stage screen
  *
  * @param core_backup_renderer $renderer renderer instance to use
  * @return string HTML code
  */
 public function display(core_backup_renderer $renderer)
 {
     $format = backup_general_helper::detect_backup_format($this->filepath);
     if ($format === backup::FORMAT_MOODLE) {
         // Standard Moodle 2 format, let use get the type of the backup.
         $details = backup_general_helper::get_backup_information($this->filepath);
         if ($details->type === backup::TYPE_1COURSE) {
             $wholecourse = true;
         } else {
             $wholecourse = false;
         }
     } else {
         // Non-standard format to be converted. We assume it contains the
         // whole course for now. However, in the future there might be a callback
         // to the installed converters.
         $wholecourse = true;
     }
     $nextstageurl = new moodle_url('/backup/restore.php', array('contextid' => $this->contextid, 'filepath' => $this->filepath, 'stage' => restore_ui::STAGE_SETTINGS));
     $context = context::instance_by_id($this->contextid);
     if ($context->contextlevel == CONTEXT_COURSE and has_capability('moodle/restore:restorecourse', $context)) {
         $currentcourse = $context->instanceid;
     } else {
         $currentcourse = false;
     }
     return $renderer->course_selector($nextstageurl, $wholecourse, $this->categorysearch, $this->coursesearch, $currentcourse);
 }
开发者ID:educakanchay,项目名称:campus,代码行数:32,代码来源:restore_ui_stage.class.php

示例2: to_moodle2_format

 /**
  * Converts the given directory with the backup into moodle2 format
  *
  * @param string $tempdir The directory to convert
  * @param string $format The current format, if already detected
  * @param base_logger|null if the conversion should be logged, use this logger
  * @throws convert_helper_exception
  * @return bool false if unable to find the conversion path, true otherwise
  */
 public static function to_moodle2_format($tempdir, $format = null, $logger = null)
 {
     if (is_null($format)) {
         $format = backup_general_helper::detect_backup_format($tempdir);
     }
     // get the supported conversion paths from all available converters
     $converters = self::available_converters();
     $descriptions = array();
     foreach ($converters as $name) {
         $classname = "{$name}_converter";
         if (!class_exists($classname)) {
             throw new convert_helper_exception('class_not_loaded', $classname);
         }
         if ($logger instanceof base_logger) {
             backup_helper::log('available converter', backup::LOG_DEBUG, $classname, 1, false, $logger);
         }
         $descriptions[$name] = call_user_func($classname . '::description');
     }
     // choose the best conversion path for the given format
     $path = self::choose_conversion_path($format, $descriptions);
     if (empty($path)) {
         if ($logger instanceof base_logger) {
             backup_helper::log('unable to find the conversion path', backup::LOG_ERROR, null, 0, false, $logger);
         }
         return false;
     }
     if ($logger instanceof base_logger) {
         backup_helper::log('conversion path established', backup::LOG_INFO, implode(' => ', array_merge($path, array('moodle2'))), 0, false, $logger);
     }
     foreach ($path as $name) {
         if ($logger instanceof base_logger) {
             backup_helper::log('running converter', backup::LOG_INFO, $name, 0, false, $logger);
         }
         $converter = convert_factory::get_converter($name, $tempdir, $logger);
         $converter->convert();
     }
     // make sure we ended with moodle2 format
     if (!self::detect_moodle2_format($tempdir)) {
         throw new convert_helper_exception('conversion_failed');
     }
     return true;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:51,代码来源:convert_helper.class.php

示例3: __construct

 /**
  *
  * @param string $tempdir Directory under tempdir/backup awaiting restore
  * @param int $courseid Course id where restore is going to happen
  * @param bool $interactive backup::INTERACTIVE_YES[true] or backup::INTERACTIVE_NO[false]
  * @param int $mode backup::MODE_[ GENERAL | HUB | IMPORT | SAMESITE ]
  * @param int $userid
  * @param int $target backup::TARGET_[ NEW_COURSE | CURRENT_ADDING | CURRENT_DELETING | EXISTING_ADDING | EXISTING_DELETING ]
  */
 public function __construct($tempdir, $courseid, $interactive, $mode, $userid, $target)
 {
     $this->tempdir = $tempdir;
     $this->courseid = $courseid;
     $this->interactive = $interactive;
     $this->mode = $mode;
     $this->userid = $userid;
     $this->target = $target;
     // Apply some defaults
     $this->type = '';
     $this->format = backup::FORMAT_UNKNOWN;
     $this->execution = backup::EXECUTION_INMEDIATE;
     $this->operation = backup::OPERATION_RESTORE;
     $this->executiontime = 0;
     $this->samesite = false;
     $this->checksum = '';
     $this->precheck = null;
     // Apply current backup version and release if necessary
     backup_controller_dbops::apply_version_and_release();
     // Check courseid is correct
     restore_check::check_courseid($this->courseid);
     // Check user is correct
     restore_check::check_user($this->userid);
     // Calculate unique $restoreid
     $this->calculate_restoreid();
     // Default logger chain (based on interactive/execution)
     $this->logger = backup_factory::get_logger_chain($this->interactive, $this->execution, $this->restoreid);
     // Instantiate the output_controller singleton and active it if interactive and inmediate
     $oc = output_controller::get_instance();
     if ($this->interactive == backup::INTERACTIVE_YES && $this->execution == backup::EXECUTION_INMEDIATE) {
         $oc->set_active(true);
     }
     $this->log('instantiating restore controller', backup::LOG_INFO, $this->restoreid);
     // Set initial status
     $this->set_status(backup::STATUS_CREATED);
     // Calculate original restore format
     $this->format = backup_general_helper::detect_backup_format($tempdir);
     // If format is not moodle2, set to conversion needed
     if ($this->format !== backup::FORMAT_MOODLE) {
         $this->set_status(backup::STATUS_REQUIRE_CONV);
         // Else, format is moodle2, load plan, apply security and set status based on interactivity
     } else {
         // Load plan
         $this->load_plan();
         // Perform all initial security checks and apply (2nd param) them to settings automatically
         restore_check::check_security($this, true);
         if ($this->interactive == backup::INTERACTIVE_YES) {
             $this->set_status(backup::STATUS_SETTING_UI);
         } else {
             $this->set_status(backup::STATUS_NEED_PRECHECK);
         }
     }
 }
开发者ID:nickread,项目名称:moodle,代码行数:62,代码来源:restore_controller.class.php

示例4: display

 /**
  *
  * @global moodle_database $DB
  * @param core_backup_renderer $renderer
  * @return string
  */
 public function display($renderer)
 {
     global $DB, $USER, $PAGE;
     $format = backup_general_helper::detect_backup_format($this->filepath);
     if ($format !== 'moodle2') {
         return $renderer->invalid_format($format);
     }
     $this->details = backup_general_helper::get_backup_information($this->filepath);
     $url = new moodle_url('/backup/restore.php', array('contextid' => $this->contextid, 'filepath' => $this->filepath, 'stage' => restore_ui::STAGE_SETTINGS));
     $context = get_context_instance_by_id($this->contextid);
     $currentcourse = $context->contextlevel == CONTEXT_COURSE && has_capability('moodle/restore:restorecourse', $context) ? $context->instanceid : false;
     $html = $renderer->course_selector($url, $this->details, $this->categorysearch, $this->coursesearch, $currentcourse);
     return $html;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:20,代码来源:restore_ui_stage.class.php

示例5: convert

 /**
  * convert from current format to backup::MOODLE format
  */
 public function convert()
 {
     if ($this->status != backup::STATUS_REQUIRE_CONV) {
         throw new restore_controller_exception('cannot_convert_not_required_status');
     }
     if ($this->format == backup::FORMAT_UNKNOWN) {
         throw new restore_controller_exception('cannot_convert_from_unknown_format');
     }
     if ($this->format == backup::FORMAT_MOODLE1) {
         // TODO: Implement moodle1 => moodle2 conversion
         throw new restore_controller_exception('cannot_convert_yet_from_moodle1_format');
     }
     // Once conversions have finished, we check again the format
     $newformat = backup_general_helper::detect_backup_format($tempdir);
     // If format is moodle2, load plan, apply security and set status based on interactivity
     if ($newformat === backup::FORMAT_MOODLE) {
         // Load plan
         $this->load_plan();
         // Perform all initial security checks and apply (2nd param) them to settings automatically
         restore_check::check_security($this, true);
         if ($this->interactive == backup::INTERACTIVE_YES) {
             $this->set_status(backup::STATUS_SETTING_UI);
         } else {
             $this->set_status(backup::STATUS_NEED_PRECHECK);
         }
     } else {
         throw new restore_controller_exception('conversion_ended_with_wrong_format', $newformat);
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:32,代码来源:restore_controller.class.php


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