ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCMediaObject.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPageContent.php");
25 
37 {
38  var $dom;
39  var $mob_node;
40 
44  function init()
45  {
46  $this->setType("media");
47  }
48 
54  function readMediaObject($a_mob_id = 0)
55  {
56  if ($a_mob_id > 0)
57  {
58  $mob = new ilObjMediaObject($a_mob_id);
59  $this->setMediaObject($mob);
60  }
61  }
62 
63  function setNode(&$a_node)
64  {
65  parent::setNode($a_node); // this is the PageContent node
66  $this->mob_node =& $a_node->first_child();
67  }
68 
72  function setDom(&$a_dom)
73  {
74  $this->dom =& $a_dom;
75  }
76 
80  function setHierId($a_hier_id)
81  {
82  $this->hier_id = $a_hier_id;
83  }
84 
90  function setMediaObject($a_mediaobject)
91  {
92  $this->mediaobject = $a_mediaobject;
93  }
94 
100  function getMediaObject()
101  {
102  return $this->mediaobject;
103  }
104 
105  function createMediaObject()
106  {
107  $this->setMediaObject(new ilObjMediaObject());
108  }
109 
110  function create(&$a_pg_obj, $a_hier_id)
111  {
112 //echo "::".is_object($this->dom).":";
113  $this->node = $this->createPageContentNode();
114 
115  //$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER);
116  //$this->list_node =& $this->dom->create_element("List");
117  //$this->list_node =& $this->node->append_child($this->list_node);
118  }
119 
126  function createAlias(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
127  {
128  $this->node =& $this->dom->create_element("PageContent");
129  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
130  $this->mob_node =& $this->dom->create_element("MediaObject");
131  $this->mob_node =& $this->node->append_child($this->mob_node);
132  $this->mal_node =& $this->dom->create_element("MediaAlias");
133  $this->mal_node =& $this->mob_node->append_child($this->mal_node);
134  $this->mal_node->set_attribute("OriginId", "il__mob_".$this->getMediaObject()->getId());
135 
136  // standard view
137  $item_node =& $this->dom->create_element("MediaAliasItem");
138  $item_node =& $this->mob_node->append_child($item_node);
139  $item_node->set_attribute("Purpose", "Standard");
140  $media_item =& $this->getMediaObject()->getMediaItem("Standard");
141 
142  $layout_node =& $this->dom->create_element("Layout");
143  $layout_node =& $item_node->append_child($layout_node);
144  if ($media_item->getWidth() > 0)
145  {
146  $layout_node->set_attribute("Width", $media_item->getWidth());
147  }
148  if ($media_item->getHeight() > 0)
149  {
150  $layout_node->set_attribute("Height", $media_item->getHeight());
151  }
152  $layout_node->set_attribute("HorizontalAlign", "Left");
153 
154  // caption
155  if ($media_item->getCaption() != "")
156  {
157  $cap_node =& $this->dom->create_element("Caption");
158  $cap_node =& $item_node->append_child($cap_node);
159  $cap_node->set_attribute("Align", "bottom");
160  $cap_node->set_content($media_item->getCaption());
161  }
162 
163  $pars = $media_item->getParameters();
164  foreach($pars as $par => $val)
165  {
166  $par_node =& $this->dom->create_element("Parameter");
167  $par_node =& $item_node->append_child($par_node);
168  $par_node->set_attribute("Name", $par);
169  $par_node->set_attribute("Value", $val);
170  }
171 
172  // fullscreen view
173  $fullscreen_item =& $this->getMediaObject()->getMediaItem("Fullscreen");
174  if (is_object($fullscreen_item))
175  {
176  $item_node =& $this->dom->create_element("MediaAliasItem");
177  $item_node =& $this->mob_node->append_child($item_node);
178  $item_node->set_attribute("Purpose", "Fullscreen");
179 
180  // width and height
181  $layout_node =& $this->dom->create_element("Layout");
182  $layout_node =& $item_node->append_child($layout_node);
183  if ($fullscreen_item->getWidth() > 0)
184  {
185  $layout_node->set_attribute("Width", $fullscreen_item->getWidth());
186  }
187  if ($fullscreen_item->getHeight() > 0)
188  {
189  $layout_node->set_attribute("Height", $fullscreen_item->getHeight());
190  }
191 
192  // caption
193  if ($fullscreen_item->getCaption() != "")
194  {
195  $cap_node =& $this->dom->create_element("Caption");
196  $cap_node =& $item_node->append_child($cap_node);
197  $cap_node->set_attribute("Align", "bottom");
198  $cap_node->set_content($fullscreen_item->getCaption());
199  }
200 
201  $pars = $fullscreen_item->getParameters();
202  foreach($pars as $par => $val)
203  {
204  $par_node =& $this->dom->create_element("Parameter");
205  $par_node =& $item_node->append_child($par_node);
206  $par_node->set_attribute("Name", $par);
207  $par_node->set_attribute("Value", $val);
208  }
209  }
210  }
211 
215  function dumpXML()
216  {
217  $xml = $this->dom->dump_node($this->node);
218  return $xml;
219  }
220 }
221 ?>