Merge branch 'm25_MDL-41410_Move_Comment_To_Appropriate_Place' of https://github...
[moodle.git] / backup / cc / cc_lib / cc_version_base.php
blob9fc230e9d644b0c71c4c85a4e26a06eabab7fd56
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.
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/>.
17 /**
18 * @package backup-convert
19 * @subpackage cc-library
20 * @copyright 2011 Darko Miletic <dmiletic@moodlerooms.com>
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 require_once 'cc_organization.php';
27 /**
28 * Abstract Version Base class
31 abstract class cc_version_base {
32 protected $_generator = null;
33 protected $ccnamespaces = array();
34 protected $isrootmanifest = false;
35 protected $manifestID = null;
36 protected $organizationid = null;
37 public $resources = null;
38 protected $metadata = null;
39 public $organizations = null;
40 protected $base = null;
41 public $ccversion = null;
42 public $camversion = null;
45 abstract protected function on_create(DOMDocument &$doc,$rootmanifestnode=null,$nmanifestID=null);
47 abstract protected function create_metadata_manifest (cc_i_metadata_manifest $met,DOMDocument &$doc,$xmlnode=null);
49 abstract protected function create_metadata_resource (cc_i_metadata_resource $met,DOMDocument &$doc,$xmlnode=null);
51 abstract protected function create_metadata_file (cc_i_metadata_file $met,DOMDocument &$doc,$xmlnode=null);
53 abstract protected function create_resource(cc_i_resource &$res, DOMDocument &$doc, $xmlnode=null);
55 abstract protected function create_organization(cc_i_organization &$org, DOMDocument &$doc, $xmlnode=null);
57 public function get_cc_namespaces(){
58 return $this->ccnamespaces;
61 public function create_manifest(DOMDocument &$doc,$rootmanifestnode=null){
62 return $this->on_create($doc,$rootmanifestnode);
65 public function create_resource_node(cc_i_resource &$res, DOMDocument &$doc, $xmlnode = null) {
66 return $this->create_resource($res,$doc,$xmlnode);
70 public function create_metadata_node (&$met, DOMDocument &$doc, $xmlnode = null){
71 return $this->create_metadata_manifest($met,$doc,$xmlnode);
74 public function create_metadata_resource_node (&$met, DOMDocument &$doc, $xmlnode = null){
75 return $this->create_metadata_resource($met,$doc,$xmlnode);
78 public function create_metadata_file_node (&$met, DOMDocument &$doc, $xmlnode = null){
79 return $this->create_metadata_file($met,$doc,$xmlnode);
82 public function create_organization_node(cc_i_organization &$org, DOMDocument &$doc, $xmlnode = null) {
83 return $this->create_organization($org,$doc,$xmlnode);
86 public function manifestID(){
87 return $this->manifestID;
90 public function set_manifestID($id){
91 $this->manifestID = $id;
94 public function get_base(){
95 return $this->base;
98 public function set_base($baseval){
99 $this->base = $baseval;
102 public function import_resources(DOMElement &$node, cc_i_manifest &$doc) {
103 if (is_null($this->resources)){
104 $this->resources = array();
106 $nlist = $node->getElementsByTagNameNS($this->ccnamespaces['imscc'],'resource');
107 if (is_object($nlist)) {
108 foreach ($nlist as $nd) {
109 $sc = new cc_resource($doc,$nd);
110 $this->resources[$sc->identifier]=$sc;
115 public function import_organization_items(DOMElement &$node, cc_i_manifest &$doc) {
116 if (is_null($this->organizations)) {
117 $this->organizations = array();
119 $nlist = $node->getElementsByTagNameNS($this->ccnamespaces['imscc'],'organization');
120 if (is_object($nlist)) {
121 foreach ($nlist as $nd) {
122 $sc = new cc_organization($nd,$doc);
123 $this->organizations[$sc->identifier]=$sc;
128 public function set_generator($value) {
129 $this->_generator = $value;