ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMDCreator.php
Go to the documentation of this file.
1 <?php
2 
3 
4 /*
5  +-----------------------------------------------------------------------------+
6  | ILIAS open source |
7  +-----------------------------------------------------------------------------+
8  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9  | |
10  | This program is free software; you can redistribute it and/or |
11  | modify it under the terms of the GNU General Public License |
12  | as published by the Free Software Foundation; either version 2 |
13  | of the License, or (at your option) any later version. |
14  | |
15  | This program is distributed in the hope that it will be useful, |
16  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18  | GNU General Public License for more details. |
19  | |
20  | You should have received a copy of the GNU General Public License |
21  | along with this program; if not, write to the Free Software |
22  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23  +-----------------------------------------------------------------------------+
24 */
25 
26 
37 {
38  var $md_obj = null;
39 
40  /*
41  * rbac_id ref_id of rbac object (e.g for page objects the obj_id of the content object)
42  */
43  var $rbac_id;
44 
45  /*
46  * obj_id (e.g for structure objects the obj_id of the structure object)
47  */
48  var $obj_id;
49 
50  /*
51  * type of the object (e.g st,pg,crs ...)
52  */
53  var $obj_type;
54 
55  function ilMDCreator($a_rbac_id,$a_obj_id,$a_type)
56  {
57  include_once 'Services/MetaData/classes/class.ilMD.php';
58 
59  if ($a_obj_id == 0)
60  {
61  $a_obj_id = $a_rbac_id;
62  }
63 
64  $this->rbac_id = $a_rbac_id;
65  $this->obj_id = $a_obj_id;
66  $this->obj_type = $a_type;
67 
68  $this->md_obj =& new ilMD($a_rbac_id,$a_obj_id,$a_type);
69  }
70 
71  // SET/GET
72  function setTitle($a_title)
73  {
74  $this->title = $a_title;
75  }
76  function getTitle()
77  {
78  return $this->title;
79  }
80  function setDescription($a_desc)
81  {
82  $this->description = $a_desc;
83  }
84  function getDescription()
85  {
86  return $this->description;
87  }
88  function setTitleLanguage($a_lng)
89  {
90  $this->title_lng = $a_lng;
91  }
92  function &getTitleLanguage()
93  {
94  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
95 
96  return new ilMDLanguageItem($this->title_lng);
97  }
98  function setDescriptionLanguage($a_lng)
99  {
100  $this->title_lng = $a_lng;
101  }
103  {
104  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
105 
106  return new ilMDLanguageItem($this->title_lng);
107  }
108  function setLanguage($a_lng)
109  {
110  $this->title_lng = $a_lng;
111  }
112  function &getLanguage()
113  {
114  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
115 
116  return new ilMDLanguageItem($this->title_lng);
117  }
118  function setKeyword($a_key)
119  {
120  $this->keyword = $a_key;
121  }
122  function getKeyword()
123  {
124  return $this->keyword;
125  }
126 
127 
128  function getRBACId()
129  {
130  return $this->rbac_id;
131  }
132  function getObjId()
133  {
134  return $this->obj_id;
135  }
136  function getObjType()
137  {
138  return $this->obj_type;
139  }
140  function setKeywordLanguage($a_lng)
141  {
142  $this->title_lng = $a_lng;
143  }
144  function &getKeywordLanguage()
145  {
146  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
147 
148  return new ilMDLanguageItem($this->title_lng);
149  }
150  function setCatalog($a_cat)
151  {
152  $this->catalog = $a_cat;
153  }
154  function getCatalog()
155  {
156  return $this->catalog ? $this->catalog : 'ILIAS';
157  }
158  function setEntry($a_entry)
159  {
160  $this->entry = $a_entry;
161  }
162  function getEntry()
163  {
164  return $this->entry ? $this->entry : 'il__'.$this->getObjType().'_'.$this->getObjId();
165  }
166  function setStructure($a_structure)
167  {
168  $this->structure = $a_structure;
169  }
170  function getStructure()
171  {
172  return $this->structure ? $this->structure : 'Hierarchical';
173  }
174 
175 
176 
177  function create()
178  {
179  $this->__createGeneral();
180  }
181 
182  // PROTECTED
183  function __createGeneral()
184  {
185  $md_gen =& $this->md_obj->addGeneral();
186 
187  $md_gen->setStructure($this->getStructure());
188  $md_gen->setTitle($this->getTitle());
189  $md_gen->setTitleLanguage($this->getTitleLanguage());
190  $md_gen->save();
191 
192  $md_ide =& $md_gen->addIdentifier();
193  $md_ide->setCatalog($this->getCatalog());
194  $md_ide->setEntry($this->getEntry());
195  $md_ide->save();
196 
197  $md_lng =& $md_gen->addLanguage();
198  $md_lng->setLanguage($this->getLanguage());
199  $md_lng->save();
200 
201  $md_des =& $md_gen->addDescription();
202  $md_des->setDescription($this->getDescription());
203  $md_des->setDescriptionLanguage($this->getDescriptionLanguage());
204  $md_des->save();
205 
206  $md_key =& $md_gen->addKeyword();
207  $md_key->setKeyword($this->getKeyword());
208  $md_key->setKeywordLanguage($this->getKeywordLanguage());
209  $md_key->save();
210 
211  return true;
212  }
213 }
214 ?>