MDL-31562: Implemented support for exporting labels, minor additional

cleanups
This commit is contained in:
Darko Miletic
2012-02-08 16:11:59 -03:00
parent baa5cd8240
commit 5b6d8a05f4
8 changed files with 62 additions and 10 deletions
+1
View File
@@ -39,4 +39,5 @@ require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_converter_url.php');
require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_converter_resource.php');
require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_converter_quiz.php');
require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_converter_page.php');
require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_converter_label.php');
require_once($CFG->dirroot .'/backup/cc/cc_lib/cc_convert_moodle2.php');
+1 -1
View File
@@ -1821,7 +1821,7 @@ class assesment1_resurce_file extends general_cc_file {
}
public function set_title($value) {
$this->assessment_title = $value;
$this->assessment_title = self::safexml($value);
}
protected function on_save() {
+4 -4
View File
@@ -55,10 +55,10 @@ class basicltil1_resurce_file extends general_cc_file {
protected $cartridge_icon = null;
public function set_title($title) {
$this->title = $title;
$this->title = self::safexml($title);
}
public function set_description($description) {
$this->description = $description;
$this->description = self::safexml($description);
}
public function set_launch_url ($url) {
$this->launch_url = $url;
@@ -77,11 +77,11 @@ class basicltil1_resurce_file extends general_cc_file {
$this->vendor = true;
}
public function set_vendor_name ($name) {
$this->vendor_name = $name;
$this->vendor_name = self::safexml($name);
$this->vendor = true;
}
public function set_vendor_description ($desc) {
$this->vendor_description = $desc;
$this->vendor_description = self::safexml($desc);
$this->vendor = true;
}
public function set_vendor_url ($url) {
+39
View File
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package backup-convert
* @subpackage cc-library
* @copyright 2012 Darko Miletic <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once 'cc_converters.php';
require_once 'cc_general.php';
class cc_converter_label extends cc_converter {
public function __construct(cc_i_item &$item, cc_i_manifest &$manifest, $rootpath, $path){
$this->defaultfile = 'label.xml';
parent::__construct($item, $manifest, $rootpath, $path);
}
public function convert($outdir) {
$resitem = new cc_item();
$resitem->title = $this->doc->nodeValue('/activity/label/name');
$this->item->add_child_item($resitem);
return true;
}
}
+2 -2
View File
@@ -37,11 +37,11 @@ class forum1_resurce_file extends general_cc_file {
protected $attachments = array();
public function set_title($title) {
$this->title = $title;
$this->title = self::safexml($title);
}
public function set_text($text, $type='text/plain') {
$this->text = $text;
$this->text = self::safexml($text);
$this->text_type = $type;
}
+2 -2
View File
@@ -35,11 +35,11 @@ class page11_resurce_file extends general_cc_file {
}
public function set_title($value) {
$this->title = $value;
$this->title = self::safexml($value);
}
public function set_intro($value) {
$this->intro = htmlspecialchars(strip_tags($value), ENT_COMPAT, 'UTF-8', false);
$this->intro = self::safexml(strip_tags($value));
}
protected function on_create() {
+1 -1
View File
@@ -44,7 +44,7 @@ class url1_resurce_file extends general_cc_file {
* @param string $title
*/
public function set_title($title) {
$this->title = htmlentities($title);
$this->title = self::safexml($title);
}
/**
+12
View File
@@ -41,6 +41,18 @@ class XMLGenericDocument {
private $is_html = false;
/**
* @param string $value
* @return string
*/
public static function safexml($value) {
$result = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'),
ENT_NOQUOTES,
'UTF-8',
false);
return $result;
}
function __construct($ch = 'UTF-8',$validatenow=true){
$this->charset = $ch;
$this->documentInit();