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;
129 $item_id = $ilDB->nextId(
"media_item");
130 $query =
"INSERT INTO media_item (id,mob_id, purpose, location, ".
131 "location_type, format, width, ".
132 "height, halign, caption, nr, text_representation) VALUES ".
134 $ilDB->quote($item_id,
"integer").
",".
135 $ilDB->quote($this->
getMobId(),
"integer").
",".
136 $ilDB->quote($this->
getPurpose(),
"text").
",".
139 $ilDB->quote($this->
getFormat(),
"text").
",".
140 $ilDB->quote($this->
getWidth(),
"text").
",".
141 $ilDB->quote($this->
getHeight(),
"text").
",".
142 $ilDB->quote($this->
getHAlign(),
"text").
",".
143 $ilDB->quote($this->
getCaption(),
"text").
",".
144 $ilDB->quote($this->
getNr(),
"integer").
",".
146 $ilDB->manipulate(
$query);
148 $this->
setId($item_id);
154 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
155 "(".$ilDB->quote($item_id,
"integer").
",".
156 $ilDB->quote(
$name,
"text").
",".
157 $ilDB->quote($value,
"text").
")";
158 $ilDB->manipulate(
$query);
162 for ($i=0; $i < count($this->mapareas); $i++)
164 $this->mapareas[$i]->setItemId($this->
getId());
165 $this->mapareas[$i]->setNr($i + 1);
166 $this->mapareas[$i]->create();
177 $query =
"UPDATE media_item SET ".
178 " mob_id = ".$ilDB->quote($this->
getMobId(),
"integer").
",".
179 " purpose = ".$ilDB->quote($this->
getPurpose(),
"text").
",".
180 " location = ".$ilDB->quote($this->
getLocation(),
"text").
",".
181 " location_type = ".$ilDB->quote($this->
getLocationType(),
"text").
",".
182 " format = ".$ilDB->quote($this->
getFormat(),
"text").
",".
183 " width = ".$ilDB->quote($this->
getWidth(),
"text").
",".
184 " height = ".$ilDB->quote($this->
getHeight(),
"text").
",".
185 " halign = ".$ilDB->quote($this->
getHAlign(),
"text").
",".
186 " caption = ".$ilDB->quote($this->
getCaption(),
"text").
",".
187 " nr = ".$ilDB->quote($this->
getNr(),
"integer").
189 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
190 $ilDB->manipulate(
$query);
193 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
194 $ilDB->quote($this->
getId(),
"integer");
200 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
201 "(".$ilDB->quote($this->
getId(),
"integer").
",".
202 $ilDB->quote(
$name,
"text").
",".
203 $ilDB->quote($value,
"text").
")";
204 $ilDB->manipulate(
$query);
215 $item_id = $this->
getId();
221 $query =
"SELECT * FROM media_item WHERE id = ".
222 $ilDB->quote($this->
getId(),
"integer");
226 $query =
"SELECT * FROM media_item WHERE mob_id = ".
227 $ilDB->quote($this->
getMobId(),
"integer").
" ".
228 "AND nr=".$ilDB->quote($this->
getNr(),
"integer");
232 $item_set = $ilDB->query(
$query);
233 $item_rec = $ilDB->fetchAssoc($item_set);
238 $this->
setWidth($item_rec[
"width"]);
243 $this->
setNr($item_rec[
"nr"]);
244 $this->
setMobId($item_rec[
"mob_id"]);
245 $this->
setId($item_rec[
"id"]);
250 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
251 $ilDB->quote($this->
getId(),
"integer");
252 $par_set = $ilDB->query(
$query);
253 while ($par_rec = $ilDB->fetchAssoc($par_set))
255 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
260 for ($i = 1; $i <= $max; $i++)
276 $q =
"UPDATE media_item SET tried_thumb = ".
277 $ilDB->quote($a_tried,
"text").
278 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
280 $ilDB->manipulate(
$q);
294 $query =
"SELECT * FROM media_item WHERE mob_id = ".
295 $ilDB->quote($a_mob_id,
"integer").
" ".
296 "AND purpose = ".$ilDB->quote($a_purpose,
"text");
297 $set = $ilDB->query(
$query);
298 if ($rec = $ilDB->fetchAssoc($set))
300 return $rec[
"location"];
316 $query =
"SELECT * FROM media_item WHERE id = ".
317 $ilDB->quote($a_med_id,
"integer");
318 $set = $ilDB->query(
$query);
319 if ($rec = $ilDB->fetchAssoc($set))
321 return $rec[
"mob_id"];
338 $query =
"SELECT * FROM media_item WHERE mob_id = ".
339 $ilDB->quote($a_mobId,
"integer").
" ".
340 "AND purpose=" . $ilDB->quote($a_purpose,
"text").
" ORDER BY nr";
341 $item_set = $ilDB->query(
$query);
343 while ($item_rec = $ilDB->fetchAssoc($item_set))
360 $query =
"SELECT * FROM media_item WHERE mob_id = ".
361 $ilDB->quote($a_mob->getId(),
"integer").
" ".
363 $item_set = $ilDB->query(
$query);
364 while ($item_rec = $ilDB->fetchAssoc($item_set))
367 $media_item->setNr($item_rec[
"nr"]);
368 $media_item->setId($item_rec[
"id"]);
369 $media_item->setLocation($item_rec[
"location"]);
370 $media_item->setLocationType($item_rec[
"location_type"]);
371 $media_item->setFormat($item_rec[
"format"]);
372 $media_item->setWidth($item_rec[
"width"]);
373 $media_item->setHeight($item_rec[
"height"]);
374 $media_item->setHAlign($item_rec[
"halign"]);
375 $media_item->setCaption($item_rec[
"caption"]);
376 $media_item->setPurpose($item_rec[
"purpose"]);
377 $media_item->setMobId($item_rec[
"mob_id"]);
378 $media_item->setThumbTried($item_rec[
"tried_thumb"]);
379 $media_item->setTextRepresentation($item_rec[
"text_representation"]);
382 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = ".
383 $ilDB->quote($item_rec[
"id"],
"integer");
384 $par_set = $ilDB->query(
$query);
385 while ($par_rec = $ilDB->fetchAssoc($par_set))
387 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
392 for ($i = 1; $i <= $max; $i++)
394 $area =&
new ilMapArea($media_item->getId(), $i);
395 $media_item->addMapArea($area);
399 $a_mob->addMediaItem($media_item);
411 $query =
"SELECT * FROM media_item WHERE mob_id = ".
412 $ilDB->quote($a_mob_id,
"integer");
413 $item_set = $ilDB->query(
$query);
414 while ($item_rec = $ilDB->fetchAssoc($item_set))
417 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
418 $ilDB->quote($item_rec[
"id"],
"integer");
419 $ilDB->manipulate(
$query);
422 $query =
"DELETE FROM map_area WHERE item_id = ".
423 $ilDB->quote($item_rec[
"id"],
"integer");
424 $ilDB->manipulate(
$query);
428 $query =
"DELETE FROM media_item WHERE mob_id = ".
429 $ilDB->quote($a_mob_id,
"integer");
430 $ilDB->manipulate(
$query);
435 $this->purpose = $a_purpose;
445 $this->location = $a_location;
455 $this->location_type = $a_type;
465 $this->format = $a_format;
475 $this->tried_thumb = $a_tried;
480 return $this->tried_thumb;
498 $this->mapareas[$i-2] =& $this->mapareas[$i-1];
499 $this->mapareas[$i-2]->setNr($i-1);
502 if($nr <= $this->map_cnt)
504 unset($this->mapareas[$this->map_cnt - 1]);
514 return $this->mapareas[
$nr-1];
538 $this->width = $a_width;
554 $this->height = $a_height;
574 $size = @getimagesize($loc);
578 return array(
"width" =>
$size[0],
"height" =>
$size[1]);
590 $this->caption = $a_caption;
606 $this->halign = $a_halign;
626 $this->parameters[$a_name] = $a_value;
634 $this->parameters = array();
646 if(is_array($par_arr))
648 foreach($par_arr as $par => $val)
679 return $this->parameters[$a_name];
700 if(!@is_dir($work_dir))
713 return $loc_arr[count($loc_arr) - 1];
732 $o_file = $file_arr[count($file_arr) - 1];
733 $file_arr = explode(
".", $o_file);
734 unset($file_arr[count($file_arr) - 1]);
735 $file = implode($file_arr,
".");
737 if (!$a_reference_copy)
768 if (is_int(strpos($this->
getFormat(),
"image")))
779 if (is_file($thumb_file))
783 if (is_file($thumb_file_small))
785 unlink($thumb_file_small);
791 if (is_file($med_file))
798 if ($a_size ==
"small")
800 if (is_file($thumb_file_small))
803 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
808 if (is_file($thumb_file))
811 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
841 if ($handle && $lcopy)
843 while (!feof($handle))
845 $content = fread($handle, 4096);
846 fwrite($lcopy, $content);
898 for ($i=0; $i < count($this->mapareas); $i++)
900 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
901 ((($i+1) != $a_area_nr) && $a_exclude) ||
905 $area =& $this->mapareas[$i];
906 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
true,
942 $area->setShape($a_shape);
943 $area->setCoords($a_coords);
944 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
false,
957 header(
"Pragma: no-cache");
958 header(
"Expires: 0");
988 if (imagecolorstotal($this->map_image) > 250)
990 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
991 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
995 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
996 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1023 ImageDestroy($this->map_image);
1043 for ($i=0; $i < count($this->mapareas); $i++)
1045 $area =& $this->mapareas[$i];
1046 $xml .=
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\">";
1049 $target_frame = $area->getTargetFrame();
1051 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"")
1053 $target_frame =
"Glossary";
1056 $tf_str = ($target_frame ==
"")
1058 :
"TargetFrame=\"".$target_frame.
"\"";
1060 $xml .=
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
1061 $area->getType().
"\" $tf_str>";
1062 $xml .= $area->getTitle();
1063 $xml .=
"</IntLink>";
1067 $xml .=
"<ExtLink Href=\"".str_replace(
"&",
"&",$area->getHref()).
"\" Title=\"".
1068 $area->getExtTitle().
"\">";
1069 $xml .= $area->getTitle();
1070 $xml .=
"</ExtLink>";
1072 $xml .=
"</MapArea>";
1090 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1091 $ilDB->quote($a_mob_id,
"integer").
" ".
1093 $item_set = $ilDB->query(
$query);
1094 while ($item_rec = $ilDB->fetchAssoc($item_set))
1110 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1111 $ilDB->quote($a_mob_id,
"integer").
" ORDER BY nr";
1113 $item_set = $ilDB->query(
$query);
1115 while ($item_rec = $ilDB->fetchAssoc($item_set))
1118 foreach($map_links as
$key => $map_link)
1120 $links[
$key] = $map_link;
1131 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1134 foreach ($par as $k => $v)