Merge branch '43822-25-fixonly' of git://github.com/samhemelryk/moodle into MOODLE_25...
[moodle.git] / backup / cc / cc_lib / cc_metadata.php
blob6020b9055c33a8d1a61fc2a418c6ab6ce4333e2d
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
26 /**
27 Defined as specified in CC 1.1
29 class intended_user_role {
30 const LEARNER = 'Learner';
31 const INSTRUCTOR = 'Instructor';
32 const MENTOR = 'Mentor';
35 class technical_role {
36 const AUTHOR = 'author';
37 const PUBLISHER = 'publisher';
38 const UNKNOWN = 'unknown';
39 const INITIATOR = 'initiator';
40 const TERMINATOR = 'terminator';
41 const VALIDATOR = 'validator';
42 const EDITOR = 'editor';
43 const GRAPHICAL_DESIGNER = 'graphical designer';
44 const TECHNICAL_IMPLEMENTER = 'technical implementer';
45 const CONTENT_PROVIDER = 'content provider';
46 const TECHNICAL_VALIDATOR = 'technical validator';
47 const EDUCATION_VALIDATOR = 'educational validator';
48 const SCRIPT_WRITER = 'script writer';
49 const INSTRUCTIONAL_DESIGNER= 'instructional designer';
50 const SUBJET_MATTER_EXPERT = 'subject matter expert';
54 class rights_copyright {
55 const YES = 'yes';
56 const NO = 'no';
60 class rights_cost {
61 const YES = 'yes';
62 const NO = 'no';
66 // Language identifier (as defined in ISO 639-1, ISO 639-2, and ISO 3166-1)
67 class language_lom {
68 const US_ENGLISH = 'en-US';
69 const GB_ENGLISH = 'en-GB';
70 const AR_SPANISH = 'es-AR';
71 const GR_GREEK = 'el-GR';
77 /**
78 * Metadata Manifest
81 class cc_metadata_manifest implements cc_i_metadata_manifest {
84 public $arraygeneral = array();
85 public $arraytech = array();
86 public $arrayrights = array();
87 public $arraylifecycle = array();
90 public function add_metadata_general($obj){
91 if (empty($obj)){
92 throw new Exception('Medatada Object given is invalid or null!');
94 !is_null($obj->title)? $this->arraygeneral['title']=$obj->title:null;
95 !is_null($obj->language)? $this->arraygeneral['language']=$obj->language:null;
96 !is_null($obj->description)? $this->arraygeneral['description']=$obj->description:null;
97 !is_null($obj->keyword)? $this->arraygeneral['keyword']=$obj->keyword:null;
98 !is_null($obj->coverage)? $this->arraygeneral['coverage']=$obj->coverage:null;
99 !is_null($obj->catalog)? $this->arraygeneral['catalog']=$obj->catalog:null;
100 !is_null($obj->entry)? $this->arraygeneral['entry']=$obj->entry:null;
103 public function add_metadata_technical($obj){
104 if (empty($obj)){
105 throw new Exception('Medatada Object given is invalid or null!');
107 !is_null($obj->format)? $this->arraytech['format']=$obj->format:null;
111 public function add_metadata_rights($obj){
112 if (empty($obj)){
113 throw new Exception('Medatada Object given is invalid or null!');
115 !is_null($obj->copyright)? $this->arrayrights['copyrightAndOtherRestrictions']=$obj->copyright:null;
116 !is_null($obj->description)? $this->arrayrights['description']=$obj->description:null;
117 !is_null($obj->cost)? $this->arrayrights['cost']=$obj->cost:null;
122 public function add_metadata_lifecycle($obj){
123 if (empty($obj)){
124 throw new Exception('Medatada Object given is invalid or null!');
126 !is_null($obj->role)? $this->arraylifecycle['role']=$obj->role:null;
127 !is_null($obj->entity)? $this->arraylifecycle['entity']=$obj->entity:null;
128 !is_null($obj->date)? $this->arraylifecycle['date']=$obj->date:null;
136 * Metadata Lifecycle Type
139 class cc_metadata_lifecycle{
141 public $role = array();
142 public $entity = array();
143 public $date = array();
145 public function set_role($role){
146 $this->role[] = array($role);
148 public function set_entity($entity){
149 $this->entity[] = array($entity);
151 public function set_date($date){
152 $this->date[] = array($date);
159 * Metadata Rights Type
162 class cc_metadata_rights {
164 public $copyright = array();
165 public $description = array();
166 public $cost = array();
168 public function set_copyright($copy){
169 $this->copyright[] = array($copy);
171 public function set_description ($des,$language){
172 $this->description[] = array($language,$des);
174 public function set_cost($cost){
175 $this->cost[] = array($cost);
182 * Metadata Technical Type
185 class cc_metadata_technical {
187 public $format = array();
190 public function set_format($format){
191 $this->format[] = array($format);
198 * Metadata General Type
201 class cc_metadata_general {
203 public $title = array();
204 public $language = array();
205 public $description = array();
206 public $keyword = array();
207 public $coverage = array();
208 public $catalog = array();
209 public $entry = array();
213 public function set_coverage ($coverage,$language){
214 $this->coverage[] = array($language,$coverage);
216 public function set_description ($description,$language){
217 $this->description[] = array($language,$description);
219 public function set_keyword ($keyword,$language){
220 $this->keyword[] = array($language,$keyword);
222 public function set_language ($language){
223 $this->language[] = array($language);
225 public function set_title ($title,$language){
226 $this->title[] = array($language,$title);
228 public function set_catalog ($cat){
229 $this->catalog[] = array($cat);
231 public function set_entry ($entry){
232 $this->entry[] = array($entry);