Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/cc/entities11.class.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00023 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
00024 
00025 require_once($CFG->dirroot . '/backup/cc/entities.class.php');
00026 
00027 class entities11 extends entities {
00028 
00029     public function get_external_xml($identifier) {
00030         $xpath = cc2moodle::newx_path(cc112moodle::$manifest, cc112moodle::$namespaces);
00031         $files = $xpath->query('/imscc:manifest/imscc:resources/imscc:resource[@identifier="' .
00032                  $identifier . '"]/imscc:file/@href');
00033         $response = empty($files) || ($files->length == 0) ? '' : $files->item(0)->nodeValue;
00034         return $response;
00035     }
00036 
00037     protected function get_all_files () {
00038         global $CFG;
00039         $all_files = array();
00040         $xpath = cc2moodle::newx_path(cc112moodle::$manifest, cc112moodle::$namespaces);
00041         foreach (cc112moodle::$restypes as $type) {
00042             $files = $xpath->query('/imscc:manifest/imscc:resources/imscc:resource[@type="' .
00043                                     $type . '"]/imscc:file/@href');
00044             if (empty($files) || ($files->length == 0)) {
00045                 continue;
00046             }
00047             foreach ($files as $file) {
00048                 //omit html files
00049                 //this is a bit too simplistic
00050                 $ext = strtolower(pathinfo($file->nodeValue, PATHINFO_EXTENSION));
00051                 if (in_array($ext, array('html', 'htm', 'xhtml'))) {
00052                     continue;
00053                 }
00054                 $all_files[] = $file->nodeValue;
00055             }
00056             unset($files);
00057         }
00058 
00059         //are there any labels?
00060         $xquery = "//imscc:item/imscc:item/imscc:item[imscc:title][not(@identifierref)]";
00061         $labels = $xpath->query($xquery);
00062         if (!empty($labels) && ($labels->length > 0)) {
00063             $tname = 'course_files';
00064             $dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
00065             $rfpath = 'folder.gif';
00066             $fpath = $dpath . DIRECTORY_SEPARATOR . 'folder.gif';
00067             if (!file_exists($dpath)) {
00068                 mkdir($dpath);
00069             }
00070             //copy the folder.gif file
00071             $folder_gif = "{$CFG->dirroot}/pix/f/folder.gif";
00072             copy($folder_gif, $fpath);
00073             $all_files[] = $rfpath;
00074         }
00075         $all_files = empty($all_files) ? '' : $all_files;
00076 
00077         return $all_files;
00078     }
00079 
00080 }
00081 
 All Data Structures Namespaces Files Functions Variables Enumerations