4 require_once(
"Services/MediaObjects/classes/class.ilMapArea.php");
38 $this->parameters = array();
39 $this->mapareas = array();
76 $this->mob_id = $a_mob_id;
109 $this->text_representation = $a_val;
119 return $this->text_representation;
130 $item_id = $ilDB->nextId(
"media_item");
131 $query =
"INSERT INTO media_item (id,mob_id, purpose, location, ".
132 "location_type, format, width, ".
133 "height, halign, caption, nr, text_representation) VALUES ".
135 $ilDB->quote($item_id,
"integer").
",".
136 $ilDB->quote($this->
getMobId(),
"integer").
",".
137 $ilDB->quote($this->
getPurpose(),
"text").
",".
140 $ilDB->quote($this->
getFormat(),
"text").
",".
141 $ilDB->quote($this->
getWidth(),
"text").
",".
142 $ilDB->quote($this->
getHeight(),
"text").
",".
143 $ilDB->quote($this->
getHAlign(),
"text").
",".
144 $ilDB->quote($this->
getCaption(),
"text").
",".
145 $ilDB->quote($this->
getNr(),
"integer").
",".
147 $ilDB->manipulate(
$query);
149 $this->
setId($item_id);
153 foreach($params as $name => $value)
155 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
156 "(".$ilDB->quote($item_id,
"integer").
",".
157 $ilDB->quote($name,
"text").
",".
158 $ilDB->quote($value,
"text").
")";
159 $ilDB->manipulate(
$query);
163 for ($i=0; $i < count($this->mapareas); $i++)
165 if (is_object($this->mapareas[$i]))
167 $this->mapareas[$i]->setItemId($this->
getId());
168 $this->mapareas[$i]->setNr($i + 1);
169 $this->mapareas[$i]->create();
181 $query =
"UPDATE media_item SET ".
182 " mob_id = ".$ilDB->quote($this->
getMobId(),
"integer").
",".
183 " purpose = ".$ilDB->quote($this->
getPurpose(),
"text").
",".
184 " location = ".$ilDB->quote($this->
getLocation(),
"text").
",".
185 " location_type = ".$ilDB->quote($this->
getLocationType(),
"text").
",".
186 " format = ".$ilDB->quote($this->
getFormat(),
"text").
",".
187 " width = ".$ilDB->quote($this->
getWidth(),
"text").
",".
188 " height = ".$ilDB->quote($this->
getHeight(),
"text").
",".
189 " halign = ".$ilDB->quote($this->
getHAlign(),
"text").
",".
190 " caption = ".$ilDB->quote($this->
getCaption(),
"text").
",".
191 " nr = ".$ilDB->quote($this->
getNr(),
"integer").
",".
193 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
194 $ilDB->manipulate(
$query);
197 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
198 $ilDB->quote($this->
getId(),
"integer");
202 foreach($params as $name => $value)
204 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
205 "(".$ilDB->quote($this->
getId(),
"integer").
",".
206 $ilDB->quote($name,
"text").
",".
207 $ilDB->quote($value,
"text").
")";
208 $ilDB->manipulate(
$query);
222 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
223 "(".$ilDB->quote($this->
getId(),
"integer").
",".
224 $ilDB->quote($a_name,
"text").
",".
225 $ilDB->quote($a_value,
"text").
")";
226 $ilDB->manipulate(
$query);
236 $item_id = $this->
getId();
242 $query =
"SELECT * FROM media_item WHERE id = ".
243 $ilDB->quote($this->
getId(),
"integer");
247 $query =
"SELECT * FROM media_item WHERE mob_id = ".
248 $ilDB->quote($this->
getMobId(),
"integer").
" ".
249 "AND nr=".$ilDB->quote($this->
getNr(),
"integer");
253 $item_set = $ilDB->query(
$query);
254 $item_rec = $ilDB->fetchAssoc($item_set);
259 $this->
setWidth($item_rec[
"width"]);
264 $this->
setNr($item_rec[
"nr"]);
265 $this->
setMobId($item_rec[
"mob_id"]);
266 $this->
setId($item_rec[
"id"]);
271 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
272 $ilDB->quote($this->
getId(),
"integer");
273 $par_set = $ilDB->query(
$query);
274 while ($par_rec = $ilDB->fetchAssoc($par_set))
276 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
281 for ($i = 1; $i <= $max; $i++)
297 $q =
"UPDATE media_item SET tried_thumb = ".
298 $ilDB->quote($a_tried,
"text").
299 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
301 $ilDB->manipulate($q);
315 $query =
"SELECT * FROM media_item WHERE mob_id = ".
316 $ilDB->quote($a_mob_id,
"integer").
" ".
317 "AND purpose = ".$ilDB->quote($a_purpose,
"text");
318 $set = $ilDB->query(
$query);
319 if ($rec = $ilDB->fetchAssoc($set))
321 return $rec[
"location"];
337 $query =
"SELECT * FROM media_item WHERE id = ".
338 $ilDB->quote($a_med_id,
"integer");
339 $set = $ilDB->query(
$query);
340 if ($rec = $ilDB->fetchAssoc($set))
342 return $rec[
"mob_id"];
359 $query =
"SELECT * FROM media_item WHERE mob_id = ".
360 $ilDB->quote($a_mobId,
"integer").
" ".
361 "AND purpose=" . $ilDB->quote($a_purpose,
"text").
" ORDER BY nr";
362 $item_set = $ilDB->query(
$query);
364 while ($item_rec = $ilDB->fetchAssoc($item_set))
381 $query =
"SELECT * FROM media_item WHERE mob_id = ".
382 $ilDB->quote($a_mob->getId(),
"integer").
" ".
384 $item_set = $ilDB->query(
$query);
385 while ($item_rec = $ilDB->fetchAssoc($item_set))
388 $media_item->setNr($item_rec[
"nr"]);
389 $media_item->setId($item_rec[
"id"]);
390 $media_item->setLocation($item_rec[
"location"]);
391 $media_item->setLocationType($item_rec[
"location_type"]);
392 $media_item->setFormat($item_rec[
"format"]);
393 $media_item->setWidth($item_rec[
"width"]);
394 $media_item->setHeight($item_rec[
"height"]);
395 $media_item->setHAlign($item_rec[
"halign"]);
396 $media_item->setCaption($item_rec[
"caption"]);
397 $media_item->setPurpose($item_rec[
"purpose"]);
398 $media_item->setMobId($item_rec[
"mob_id"]);
399 $media_item->setThumbTried($item_rec[
"tried_thumb"]);
400 $media_item->setTextRepresentation($item_rec[
"text_representation"]);
403 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
404 $ilDB->quote($item_rec[
"id"],
"integer");
405 $par_set = $ilDB->query(
$query);
406 while ($par_rec = $ilDB->fetchAssoc($par_set))
408 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
413 for ($i = 1; $i <= $max; $i++)
415 $area =&
new ilMapArea($media_item->getId(), $i);
416 $media_item->addMapArea($area);
420 $a_mob->addMediaItem($media_item);
432 $query =
"SELECT * FROM media_item WHERE mob_id = ".
433 $ilDB->quote($a_mob_id,
"integer");
434 $item_set = $ilDB->query(
$query);
435 while ($item_rec = $ilDB->fetchAssoc($item_set))
438 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
439 $ilDB->quote($item_rec[
"id"],
"integer");
440 $ilDB->manipulate(
$query);
443 $query =
"DELETE FROM map_area WHERE item_id = ".
444 $ilDB->quote($item_rec[
"id"],
"integer");
445 $ilDB->manipulate(
$query);
449 $query =
"DELETE FROM media_item WHERE mob_id = ".
450 $ilDB->quote($a_mob_id,
"integer");
451 $ilDB->manipulate(
$query);
456 $this->purpose = $a_purpose;
466 $this->location = $a_location;
476 $this->location_type = $a_type;
486 $this->format = $a_format;
496 $this->tried_thumb = $a_tried;
501 return $this->tried_thumb;
519 $this->mapareas[$i-2] =& $this->mapareas[$i-1];
520 $this->mapareas[$i-2]->setNr($i-1);
523 if($nr <= $this->map_cnt)
525 unset($this->mapareas[$this->map_cnt - 1]);
535 return $this->mapareas[
$nr-1];
559 $this->width = $a_width;
575 $this->height = $a_height;
595 $size = @getimagesize($loc);
599 return array(
"width" =>
$size[0],
"height" =>
$size[1]);
611 $this->caption = $a_caption;
627 $this->halign = $a_halign;
647 $this->parameters[$a_name] = $a_value;
655 $this->parameters = array();
667 if(is_array($par_arr))
669 foreach($par_arr as $par => $val)
700 return $this->parameters[$a_name];
721 if(!@is_dir($work_dir))
734 return $loc_arr[count($loc_arr) - 1];
753 $o_file = $file_arr[count($file_arr) - 1];
754 $file_arr = explode(
".", $o_file);
755 unset($file_arr[count($file_arr) - 1]);
756 $file = implode($file_arr,
".");
758 if (!$a_reference_copy)
789 if (is_int(strpos($this->
getFormat(),
"image")))
800 if (is_file($thumb_file))
804 if (is_file($thumb_file_small))
806 unlink($thumb_file_small);
812 if (is_file($med_file))
819 if ($a_size ==
"small")
821 if (is_file($thumb_file_small))
824 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
829 if (is_file($thumb_file))
832 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
862 if ($handle && $lcopy)
864 while (!feof($handle))
866 $content = fread($handle, 4096);
867 fwrite($lcopy, $content);
919 for ($i=0; $i < count($this->mapareas); $i++)
921 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
922 ((($i+1) != $a_area_nr) && $a_exclude) ||
926 $area =& $this->mapareas[$i];
927 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
true,
963 $area->setShape($a_shape);
964 $area->setCoords($a_coords);
965 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
false,
978 header(
"Pragma: no-cache");
979 header(
"Expires: 0");
1009 if (imagecolorstotal($this->map_image) > 250)
1011 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1012 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1016 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1017 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1044 ImageDestroy($this->map_image);
1064 for ($i=0; $i < count($this->mapareas); $i++)
1066 $area =& $this->mapareas[$i];
1070 if ($area->getHighlightMode() !=
"")
1072 $hm =
' HighlightMode="'.$area->getHighlightMode().
'" ';
1073 $hcl = ($area->getHighlightClass() !=
"")
1074 ? $area->getHighlightClass()
1076 $hm.=
'HighlightClass="'.$hcl.
'" ';
1079 $xml .=
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\" ".$hm.
">";
1082 $target_frame = $area->getTargetFrame();
1084 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"")
1086 $target_frame =
"Glossary";
1089 $tf_str = ($target_frame ==
"")
1091 :
"TargetFrame=\"".$target_frame.
"\"";
1093 $xml .=
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
1094 $area->getType().
"\" $tf_str>";
1095 $xml .= $area->getTitle();
1096 $xml .=
"</IntLink>";
1100 $xml .=
"<ExtLink Href=\"".str_replace(
"&",
"&",$area->getHref()).
"\" Title=\"".
1101 $area->getExtTitle().
"\">";
1102 $xml .= $area->getTitle();
1103 $xml .=
"</ExtLink>";
1105 $xml .=
"</MapArea>";
1123 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1124 $ilDB->quote($a_mob_id,
"integer").
" ".
1126 $item_set = $ilDB->query(
$query);
1127 while ($item_rec = $ilDB->fetchAssoc($item_set))
1143 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1144 $ilDB->quote($a_mob_id,
"integer").
" ORDER BY nr";
1146 $item_set = $ilDB->query(
$query);
1148 while ($item_rec = $ilDB->fetchAssoc($item_set))
1151 foreach($map_links as $key => $map_link)
1153 $links[$key] = $map_link;
1164 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1167 foreach ($par as $k => $v)