24 require_once(
"Services/MediaObjects/classes/class.ilMapArea.php");
62 $this->parameters = array();
63 $this->mapareas = array();
100 $this->mob_id = $a_mob_id;
133 $query =
"INSERT INTO media_item (mob_id, purpose, location, ".
134 "location_type, format, width, ".
135 "height, halign, caption, nr) VALUES ".
136 "(".$ilDB->quote($this->
getMobId()).
",".
141 $ilDB->quote($this->
getWidth()).
",".
145 $ilDB->quote($this->
getNr()).
")";
146 $this->ilias->db->query($query);
147 #echo "create_mob:$query:<br>";
148 $item_id = $this->ilias->db->getLastInsertId();
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).
",".
157 $ilDB->quote($name).
",".
158 $ilDB->quote($value).
")";
159 $this->ilias->db->query($query);
163 for ($i=0; $i < count($this->mapareas); $i++)
165 $this->mapareas[$i]->setItemId($this->
getId());
166 $this->mapareas[$i]->setNr($i + 1);
167 $this->mapareas[$i]->create();
178 $query =
"UPDATE media_item SET ".
179 " mob_id = ".$ilDB->quote($this->
getMobId()).
",".
180 " purpose = ".$ilDB->quote($this->
getPurpose()).
",".
181 " location = ".$ilDB->quote($this->
getLocation()).
",".
183 " format = ".$ilDB->quote($this->
getFormat()).
",".
184 " width = ".$ilDB->quote($this->
getWidth()).
",".
185 " height = ".$ilDB->quote($this->
getHeight()).
",".
186 " halign = ".$ilDB->quote($this->
getHAlign()).
",".
187 " caption = ".$ilDB->quote($this->
getCaption()).
",".
188 " nr = ".$ilDB->quote($this->
getNr()).
189 " WHERE id = ".$ilDB->quote($this->
getId());
190 $this->ilias->db->query($query);
193 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
194 $ilDB->quote($this->
getId());
198 foreach($params as $name => $value)
200 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
201 "(".$ilDB->quote($this->
getId()).
",".
202 $ilDB->quote($name).
",".
203 $ilDB->quote($value).
")";
204 $this->ilias->db->query($query);
215 $item_id = $this->
getId();
221 $query =
"SELECT * FROM media_item WHERE id = ".$ilDB->quote($this->
getId());
225 $query =
"SELECT * FROM media_item WHERE mob_id = ".$ilDB->quote($this->
getMobId()).
" ".
226 "AND nr=".$ilDB->quote($this->
getNr());
230 $item_set = $this->ilias->db->query($query);
236 $this->
setWidth($item_rec[
"width"]);
241 $this->
setNr($item_rec[
"nr"]);
242 $this->
setMobId($item_rec[
"mob_id"]);
243 $this->
setId($item_rec[
"id"]);
247 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
248 $ilDB->quote($this->
getId());
249 $par_set = $this->ilias->db->query($query);
252 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
257 for ($i = 1; $i <= $max; $i++)
273 $q =
"UPDATE media_item SET tried_thumb=".
274 $ilDB->quote($a_tried).
275 " WHERE id = ".$ilDB->quote($this->
getId());
291 $query =
"SELECT * FROM media_item WHERE mob_id = ".$ilDB->quote($a_mob_id).
" ".
292 "AND purpose = ".$ilDB->quote($a_purpose);
293 $set = $ilDB->query($query);
296 return $rec[
"location"];
312 $query =
"SELECT * FROM media_item WHERE id = ".$ilDB->quote($a_med_id);
313 $set = $ilDB->query($query);
316 return $rec[
"mob_id"];
333 $query =
"SELECT * FROM media_item WHERE mob_id = ".$ilDB->quote($a_mobId).
" ".
334 "AND purpose=" . $ilDB->quote($a_purpose) .
" ORDER BY nr";
335 $item_set = $ilDB->query($query);
354 $query =
"SELECT * FROM media_item WHERE mob_id = ".$ilDB->quote($a_mob->getId()).
" ".
356 $item_set = $this->ilias->db->query($query);
360 $media_item->setNr($item_rec[
"nr"]);
361 $media_item->setId($item_rec[
"id"]);
362 $media_item->setLocation($item_rec[
"location"]);
363 $media_item->setLocationType($item_rec[
"location_type"]);
364 $media_item->setFormat($item_rec[
"format"]);
365 $media_item->setWidth($item_rec[
"width"]);
366 $media_item->setHeight($item_rec[
"height"]);
367 $media_item->setHAlign($item_rec[
"halign"]);
368 $media_item->setCaption($item_rec[
"caption"]);
369 $media_item->setPurpose($item_rec[
"purpose"]);
370 $media_item->setMobId($item_rec[
"mob_id"]);
371 $media_item->setThumbTried($item_rec[
"tried_thumb"]);
374 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
375 $ilDB->quote($item_rec[
"id"]);
376 $par_set = $this->ilias->db->query($query);
379 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
384 for ($i = 1; $i <= $max; $i++)
386 $area =&
new ilMapArea($media_item->getId(), $i);
387 $media_item->addMapArea($area);
391 $a_mob->addMediaItem($media_item);
403 $query =
"SELECT * FROM media_item WHERE mob_id = ".
404 $ilDB->quote($a_mob_id);
405 $item_set = $this->ilias->db->query($query);
409 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
410 $ilDB->quote($item_rec[
"id"]);
411 $this->ilias->db->query($query);
414 $query =
"DELETE FROM map_area WHERE item_id = ".
415 $ilDB->quote($item_rec[
"id"]);
416 $this->ilias->db->query($query);
420 $query =
"DELETE FROM media_item WHERE mob_id = ".
421 $ilDB->quote($a_mob_id);
422 $this->ilias->db->query($query);
427 $this->purpose = $a_purpose;
437 $this->location = $a_location;
447 $this->location_type = $a_type;
457 $this->format = $a_format;
467 $this->tried_thumb = $a_tried;
472 return $this->tried_thumb;
490 $this->mapareas[$i-2] =& $this->mapareas[$i-1];
491 $this->mapareas[$i-2]->setNr($i-1);
494 if($nr <= $this->map_cnt)
496 unset($this->mapareas[$this->map_cnt - 1]);
506 return $this->mapareas[
$nr-1];
530 $this->width = $a_width;
546 $this->height = $a_height;
581 $this->caption = $a_caption;
597 $this->halign = $a_halign;
617 $this->parameters[$a_name] = $a_value;
625 $this->parameters = array();
637 if(is_array($par_arr))
639 foreach($par_arr as $par => $val)
670 return $this->parameters[$a_name];
691 if(!@is_dir($work_dir))
704 return $loc_arr[count($loc_arr) - 1];
723 $o_file = $file_arr[count($file_arr) - 1];
724 $file_arr = explode(
".", $o_file);
725 unset($file_arr[count($file_arr) - 1]);
726 $file = implode($file_arr,
".");
728 if (!$a_reference_copy)
759 if (is_int(strpos($this->
getFormat(),
"image")))
770 if (is_file($thumb_file))
774 if (is_file($thumb_file_small))
776 unlink($thumb_file_small);
782 if (is_file($med_file))
789 if ($a_size ==
"small")
791 if (is_file($thumb_file_small))
794 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
799 if (is_file($thumb_file))
802 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
832 if ($handle && $lcopy)
834 while (!feof($handle))
836 $content = fread($handle, 4096);
837 fwrite($lcopy, $content);
889 for ($i=0; $i < count($this->mapareas); $i++)
891 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
892 ((($i+1) != $a_area_nr) && $a_exclude) ||
896 $area =& $this->mapareas[$i];
897 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
true,
933 $area->setShape($a_shape);
934 $area->setCoords($a_coords);
935 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
false,
948 header(
"Pragma: no-cache");
949 header(
"Expires: 0");
979 if (imagecolorstotal($this->map_image) > 250)
981 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
982 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
986 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
987 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1014 ImageDestroy($this->map_image);
1034 for ($i=0; $i < count($this->mapareas); $i++)
1036 $area =& $this->mapareas[$i];
1037 $xml .=
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\">";
1040 $target_frame = $area->getTargetFrame();
1042 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"")
1044 $target_frame =
"Glossary";
1047 $tf_str = ($target_frame ==
"")
1049 :
"TargetFrame=\"".$target_frame.
"\"";
1051 $xml .=
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
1052 $area->getType().
"\" $tf_str>";
1053 $xml .= $area->getTitle();
1054 $xml .=
"</IntLink>";
1058 $xml .=
"<ExtLink Href=\"".str_replace(
"&",
"&",$area->getHref()).
"\" Title=\"".
1059 $area->getExtTitle().
"\">";
1060 $xml .= $area->getTitle();
1061 $xml .=
"</ExtLink>";
1063 $xml .=
"</MapArea>";
1081 $query =
"SELECT * FROM media_item WHERE mob_id = ".$ilDB->quote($a_mob_id).
" ".
1083 $item_set = $this->ilias->db->query($query);
1100 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1101 $ilDB->quote($a_mob_id).
" ORDER BY nr";
1103 $item_set = $this->ilias->db->query($query);
1108 foreach($map_links as $key => $map_link)
1110 $links[$key] = $map_link;
1121 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1124 foreach ($par as $k => $v)