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 * @package backup-convert 18 * @subpackage cc-library 19 * @copyright 2011 Darko Miletic <dmiletic@moodlerooms.com> 20 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 21 */ 22 23 require_once 'cc_general.php'; 24 25 class forum1_resurce_file extends general_cc_file { 26 const deafultname = 'discussion.xml'; 27 28 protected $rootns = 'dt'; 29 protected $rootname = 'dt:topic'; 30 protected $ccnamespaces = array('dt' => 'http://www.imsglobal.org/xsd/imsdt_v1p0', 31 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 32 protected $ccnsnames = array('dt' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_6/imsdt_v1p0_localised.xsd'); 33 34 protected $title = null; 35 protected $text_type = 'text/plain'; 36 protected $text = null; 37 protected $attachments = array(); 38 39 public function set_title($title) { 40 $this->title = self::safexml($title); 41 } 42 43 public function set_text($text, $type='text/plain') { 44 $this->text = self::safexml($text); 45 $this->text_type = $type; 46 } 47 48 public function set_attachments(array $attachments) { 49 $this->attachments = $attachments; 50 } 51 52 protected function on_save() { 53 $this->append_new_element($this->root, 'title', $this->title); 54 $text = $this->append_new_element($this->root, 'text', $this->text); 55 $this->append_new_attribute($text, 'texttype', $this->text_type); 56 if (!empty($this->attachments)) { 57 $attachments = $this->append_new_element($this->root, 'attachments'); 58 foreach ($this->attachments as $value) { 59 $att = $this->append_new_element($attachments, 'attachment'); 60 $this->append_new_attribute($att, 'href', $value); 61 } 62 } 63 return true; 64 } 65 66 } 67 68 class forum11_resurce_file extends forum1_resurce_file { 69 protected $rootns = 'dt'; 70 protected $rootname = 'topic'; 71 protected $ccnamespaces = array('dt' => 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1', 72 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 73 protected $ccnsnames = array('dt' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imsdt_v1p1.xsd'); 74 75 protected function on_save() { 76 $rns = $this->ccnamespaces[$this->rootns]; 77 $this->append_new_element_ns($this->root, $rns, 'title', $this->title); 78 $text = $this->append_new_element_ns($this->root, $rns, 'text', $this->text); 79 $this->append_new_attribute_ns($text, $rns, 'texttype', $this->text_type); 80 if (!empty($this->attachments)) { 81 $attachments = $this->append_new_element_ns($this->root, $rns, 'attachments'); 82 foreach ($this->attachments as $value) { 83 $att = $this->append_new_element_ns($attachments, $rns, 'attachment'); 84 $this->append_new_attribute_ns($att, $rns, 'href', $value); 85 } 86 } 87 return true; 88 } 89 90 } 91 92 93
title
Description
Body
title
Description
Body
title
Description
Body
title
Body