|
Moodle
2.2.1
http://www.collinsharper.com
|
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 require_once 'cc_general.php'; 00024 00025 class forum1_resurce_file extends general_cc_file { 00026 const deafultname = 'discussion.xml'; 00027 00028 protected $rootns = 'dt'; 00029 protected $rootname = 'dt:topic'; 00030 protected $ccnamespaces = array('dt' => 'http://www.imsglobal.org/xsd/imsdt_v1p0', 00031 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 00032 protected $ccnsnames = array('dt' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_6/imsdt_v1p0_localised.xsd'); 00033 00034 protected $title = null; 00035 protected $text_type = 'text/plain'; 00036 protected $text = null; 00037 protected $attachments = array(); 00038 00039 public function set_title($title) { 00040 $this->title = self::safexml($title); 00041 } 00042 00043 public function set_text($text, $type='text/plain') { 00044 $this->text = self::safexml($text); 00045 $this->text_type = $type; 00046 } 00047 00048 public function set_attachments(array $attachments) { 00049 $this->attachments = $attachments; 00050 } 00051 00052 protected function on_save() { 00053 $this->append_new_element($this->root, 'title', $this->title); 00054 $text = $this->append_new_element($this->root, 'text', $this->text); 00055 $this->append_new_attribute($text, 'texttype', $this->text_type); 00056 if (!empty($this->attachments)) { 00057 $attachments = $this->append_new_element($this->root, 'attachments'); 00058 foreach ($this->attachments as $value) { 00059 $att = $this->append_new_element($attachments, 'attachment'); 00060 $this->append_new_attribute($att, 'href', $value); 00061 } 00062 } 00063 return true; 00064 } 00065 00066 } 00067 00068 class forum11_resurce_file extends forum1_resurce_file { 00069 protected $rootns = 'dt'; 00070 protected $rootname = 'topic'; 00071 protected $ccnamespaces = array('dt' => 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1', 00072 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 00073 protected $ccnsnames = array('dt' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imsdt_v1p1.xsd'); 00074 00075 protected function on_save() { 00076 $rns = $this->ccnamespaces[$this->rootns]; 00077 $this->append_new_element_ns($this->root, $rns, 'title', $this->title); 00078 $text = $this->append_new_element_ns($this->root, $rns, 'text', $this->text); 00079 $this->append_new_attribute_ns($text, $rns, 'texttype', $this->text_type); 00080 if (!empty($this->attachments)) { 00081 $attachments = $this->append_new_element_ns($this->root, $rns, 'attachments'); 00082 foreach ($this->attachments as $value) { 00083 $att = $this->append_new_element_ns($attachments, $rns, 'attachment'); 00084 $this->append_new_attribute_ns($att, $rns, 'href', $value); 00085 } 00086 } 00087 return true; 00088 } 00089 00090 } 00091 00092 00093