|
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/>. 00016 00024 require_once 'cc_general.php'; 00025 00026 class url1_resurce_file extends general_cc_file { 00027 const deafultname = 'weblink.xml'; 00028 00029 protected $rootns = 'wl'; 00030 protected $rootname = 'wl:webLink'; 00031 protected $ccnamespaces = array('wl' => 'http://www.imsglobal.org/xsd/imswl_v1p0', 00032 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 00033 protected $ccnsnames = array('wl' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd'); 00034 00035 protected $url = null; 00036 protected $title = null; 00037 protected $href = null; 00038 protected $target = '_self'; 00039 protected $window_features = null; 00040 00046 public function set_title($title) { 00047 $this->title = self::safexml($title); 00048 } 00049 00057 public function set_url($url, $target='_self', $window_features=null) { 00058 $this->url = $url; 00059 $this->target = $target; 00060 $this->window_features = $window_features; 00061 } 00062 00063 protected function on_save() { 00064 $this->append_new_element($this->root, 'title', $this->title); 00065 $url = $this->append_new_element($this->root, 'url'); 00066 $this->append_new_attribute($url, 'href', $this->url); 00067 if (!empty($this->target)) { 00068 $this->append_new_attribute($url, 'target', $this->target); 00069 } 00070 if (!empty($this->window_features)) { 00071 $this->append_new_attribute($url, 'windowFeatures', $this->window_features); 00072 } 00073 return true; 00074 } 00075 00076 } 00077 00078 class url11_resurce_file extends url1_resurce_file { 00079 protected $rootname = 'webLink'; 00080 00081 protected $ccnamespaces = array('wl' => 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1', 00082 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 00083 protected $ccnsnames = array('wl' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imswl_v1p1.xsd'); 00084 00085 protected function on_save() { 00086 $rns = $this->ccnamespaces[$this->rootns]; 00087 $this->append_new_element_ns($this->root, $rns, 'title', $this->title); 00088 $url = $this->append_new_element_ns($this->root, $rns, 'url'); 00089 $this->append_new_attribute_ns($url, $rns, 'href', $this->url); 00090 if (!empty($this->target)) { 00091 $this->append_new_attribute_ns($url, $rns, 'target', $this->target); 00092 } 00093 if (!empty($this->window_features)) { 00094 $this->append_new_attribute_ns($url, $rns, 'windowFeatures', $this->window_features); 00095 } 00096 return true; 00097 } 00098 } 00099