[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/blocks/html/backup/moodle1/ -> lib.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Provides support for the conversion of moodle1 backup to the moodle2 format
  19   *
  20   * @package    block_html
  21   * @copyright  2012 Paul Nicholls
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Block conversion handler for html
  29   */
  30  class moodle1_block_html_handler extends moodle1_block_handler {
  31      private $fileman = null;
  32      protected function convert_configdata(array $olddata) {
  33          $instanceid = $olddata['id'];
  34          $contextid  = $this->converter->get_contextid(CONTEXT_BLOCK, $olddata['id']);
  35          $configdata = unserialize(base64_decode($olddata['configdata']));
  36  
  37          // get a fresh new file manager for this instance
  38          $this->fileman = $this->converter->get_file_manager($contextid, 'block_html');
  39  
  40          // convert course files embedded in the block content
  41          $this->fileman->filearea = 'content';
  42          $this->fileman->itemid   = 0;
  43          $configdata->text = moodle1_converter::migrate_referenced_files($configdata->text, $this->fileman);
  44          $configdata->format = FORMAT_HTML;
  45  
  46          return base64_encode(serialize($configdata));
  47      }
  48  
  49      protected function write_inforef_xml($newdata, $data) {
  50          $this->open_xml_writer("course/blocks/{$data['name']}_{$data['id']}/inforef.xml");
  51          $this->xmlwriter->begin_tag('inforef');
  52          $this->xmlwriter->begin_tag('fileref');
  53          foreach ($this->fileman->get_fileids() as $fileid) {
  54              $this->write_xml('file', array('id' => $fileid));
  55          }
  56          $this->xmlwriter->end_tag('fileref');
  57          $this->xmlwriter->end_tag('inforef');
  58          $this->close_xml_writer();
  59      }
  60  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1