2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * @subpackage backup-imscc
19 * @copyright 2011 Darko Miletic (dmiletic@moodlerooms.com)
20 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
25 require_once($CFG->dirroot
. '/backup/cc/entities.class.php');
27 class entities11
extends entities
{
29 public function get_external_xml($identifier) {
30 $xpath = cc2moodle
::newx_path(cc112moodle
::$manifest, cc112moodle
::$namespaces);
31 $files = $xpath->query('/imscc:manifest/imscc:resources/imscc:resource[@identifier="' .
32 $identifier . '"]/imscc:file/@href');
33 $response = empty($files) ||
($files->length
== 0) ?
'' : $files->item(0)->nodeValue
;
37 protected function get_all_files () {
40 $xpath = cc2moodle
::newx_path(cc112moodle
::$manifest, cc112moodle
::$namespaces);
41 foreach (cc112moodle
::$restypes as $type) {
42 $files = $xpath->query('/imscc:manifest/imscc:resources/imscc:resource[@type="' .
43 $type . '"]/imscc:file/@href');
44 if (empty($files) ||
($files->length
== 0)) {
47 foreach ($files as $file) {
49 //this is a bit too simplistic
50 $ext = strtolower(pathinfo($file->nodeValue
, PATHINFO_EXTENSION
));
51 if (in_array($ext, array('html', 'htm', 'xhtml'))) {
54 $all_files[] = $file->nodeValue
;
59 //are there any labels?
60 $xquery = "//imscc:item/imscc:item/imscc:item[imscc:title][not(@identifierref)]";
61 $labels = $xpath->query($xquery);
62 if (!empty($labels) && ($labels->length
> 0)) {
63 $tname = 'course_files';
64 $dpath = cc2moodle
::$path_to_manifest_folder . DIRECTORY_SEPARATOR
. $tname;
65 $rfpath = 'files.gif';
66 $fpath = $dpath . DIRECTORY_SEPARATOR
. 'files.gif';
67 if (!file_exists($dpath)) {
68 mkdir($dpath, $CFG->directorypermissions
, true);
70 //copy the folder.gif file
71 $folder_gif = "{$CFG->dirroot}/pix/i/files.gif";
72 copy($folder_gif, $fpath);
73 $all_files[] = $rfpath;
75 $all_files = empty($all_files) ?
'' : $all_files;