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();
238 $nr = $this->
getNr();
242 $query =
"SELECT * FROM media_item WHERE id = ".
243 $ilDB->quote($this->
getId(),
"integer");
245 else if ($mob_id > 0 && $nr > 0)
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;
596 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
600 return array(
"width" =>
$size[0],
"height" =>
$size[1]);
612 $this->caption = $a_caption;
628 $this->halign = $a_halign;
648 if (self::checkParameter($a_name, $a_value))
650 $this->parameters[$a_name] = $a_value;
659 $this->parameters = array();
671 if(is_array($par_arr))
673 foreach($par_arr as $par => $val)
690 if (substr(strtolower(trim($a_par)), 0, 2) ==
"on")
695 if (is_int(strpos(strtolower($a_val),
"javascript")))
700 if (in_array(strtolower(trim($a_par)), array(
"src")))
732 return $this->parameters[$a_name];
753 if(!@is_dir($work_dir))
766 return $loc_arr[count($loc_arr) - 1];
785 $o_file = $file_arr[count($file_arr) - 1];
786 $file_arr = explode(
".", $o_file);
787 unset($file_arr[count($file_arr) - 1]);
788 $file = implode($file_arr,
".");
790 if (!$a_reference_copy)
821 if (is_int(strpos($this->
getFormat(),
"image")))
832 if (is_file($thumb_file))
836 if (is_file($thumb_file_small))
838 unlink($thumb_file_small);
844 if (is_file($med_file))
851 if ($a_size ==
"small")
853 if (is_file($thumb_file_small))
856 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
861 if (is_file($thumb_file))
864 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
894 if ($handle && $lcopy)
896 while (!feof($handle))
898 $content = fread($handle, 4096);
899 fwrite($lcopy, $content);
951 for ($i=0; $i < count($this->mapareas); $i++)
953 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
954 ((($i+1) != $a_area_nr) && $a_exclude) ||
958 $area =& $this->mapareas[$i];
959 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
true,
995 $area->setShape($a_shape);
996 $area->setCoords($a_coords);
997 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
false,
1010 header(
"Pragma: no-cache");
1011 header(
"Expires: 0");
1042 if (imagecolorstotal($this->map_image) > 250)
1044 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1045 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1049 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1050 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1078 ImageDestroy($this->map_image);
1098 for ($i=0; $i < count($this->mapareas); $i++)
1100 $area =& $this->mapareas[$i];
1104 if ($area->getHighlightMode() !=
"")
1106 $hm =
' HighlightMode="'.$area->getHighlightMode().
'" ';
1107 $hcl = ($area->getHighlightClass() !=
"")
1108 ? $area->getHighlightClass()
1110 $hm.=
'HighlightClass="'.$hcl.
'" ';
1113 $xml .=
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\" ".$hm.
">";
1116 $target_frame = $area->getTargetFrame();
1118 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"")
1120 $target_frame =
"Glossary";
1123 $tf_str = ($target_frame ==
"")
1125 :
"TargetFrame=\"".$target_frame.
"\"";
1127 $xml .=
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
1128 $area->getType().
"\" $tf_str>";
1130 $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1131 $xml .=
"</IntLink>";
1135 $xml .=
"<ExtLink Href=\"".str_replace(
"&",
"&",$area->getHref()).
"\" Title=\"".
1136 $area->getExtTitle().
"\">";
1137 $xml .= $area->getTitle();
1138 $xml .=
"</ExtLink>";
1140 $xml .=
"</MapArea>";
1158 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1159 $ilDB->quote($a_mob_id,
"integer").
" ".
1161 $item_set = $ilDB->query(
$query);
1162 while ($item_rec = $ilDB->fetchAssoc($item_set))
1178 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1179 $ilDB->quote($a_mob_id,
"integer").
" ORDER BY nr";
1181 $item_set = $ilDB->query(
$query);
1183 while ($item_rec = $ilDB->fetchAssoc($item_set))
1186 foreach($map_links as $key => $map_link)
1188 $links[$key] = $map_link;
1199 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1202 foreach ($par as $k => $v)
static assembleParameterString($a_par_arr)
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
_getMaxNr($a_item_id)
get maximum nr of media item (static)
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
static createDirectory($a_dir, $a_mod=0755)
create directory
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getDataDir()
get data directory (outside webspace)
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
_getIntLinks($a_item_id)
get all internal links of a media items map areas
_resolveIntLinks($a_item_id)
resolve internal links of an item id
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array