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);
434 $query =
"SELECT * FROM media_item WHERE mob_id = ".
435 $ilDB->quote($a_mob_id,
"integer");
436 $item_set = $ilDB->query(
$query);
437 while ($item_rec = $ilDB->fetchAssoc($item_set))
440 $query =
"DELETE FROM mob_parameter WHERE med_item_id = ".
441 $ilDB->quote($item_rec[
"id"],
"integer");
442 $ilDB->manipulate(
$query);
445 $query =
"DELETE FROM map_area WHERE item_id = ".
446 $ilDB->quote($item_rec[
"id"],
"integer");
447 $ilDB->manipulate(
$query);
451 $query =
"DELETE FROM media_item WHERE mob_id = ".
452 $ilDB->quote($a_mob_id,
"integer");
453 $ilDB->manipulate(
$query);
458 $this->purpose = $a_purpose;
468 $this->location = $a_location;
478 $this->location_type =
$a_type;
488 $this->
format = $a_format;
498 $this->tried_thumb = $a_tried;
503 return $this->tried_thumb;
521 $this->mapareas[$i-2] = $this->mapareas[$i-1];
522 $this->mapareas[$i-2]->setNr($i-1);
525 if($nr <= $this->map_cnt)
527 unset($this->mapareas[$this->map_cnt - 1]);
537 return $this->mapareas[$nr-1];
561 $this->width = $a_width;
577 $this->height = $a_height;
598 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
614 $this->caption = $a_caption;
630 $this->halign = $a_halign;
650 if (self::checkParameter($a_name, $a_value))
652 $this->parameters[$a_name] = $a_value;
661 $this->parameters =
array();
673 if(is_array($par_arr))
675 foreach($par_arr as $par => $val)
692 if (substr(strtolower(trim($a_par)), 0, 2) ==
"on")
697 if (is_int(strpos(strtolower($a_val),
"javascript")))
702 if (in_array(strtolower(trim($a_par)),
array(
"src")))
734 return $this->parameters[$a_name];
755 if(!@is_dir($work_dir))
768 return $loc_arr[count($loc_arr) - 1];
787 $o_file = $file_arr[count($file_arr) - 1];
788 $file_arr = explode(
".", $o_file);
789 unset($file_arr[count($file_arr) - 1]);
790 $file = implode($file_arr,
".");
792 if (!$a_reference_copy)
823 if (is_int(strpos($this->
getFormat(),
"image")))
834 if (is_file($thumb_file))
838 if (is_file($thumb_file_small))
840 unlink($thumb_file_small);
846 if (is_file($med_file))
853 if ($a_size ==
"small")
855 if (is_file($thumb_file_small))
858 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
863 if (is_file($thumb_file))
866 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
900 if ($handle && $lcopy)
902 while (!feof($handle))
904 $content = fread($handle, 4096);
905 fwrite($lcopy, $content);
957 for ($i=0; $i < count($this->mapareas); $i++)
959 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
960 ((($i+1) != $a_area_nr) && $a_exclude) ||
964 $area = $this->mapareas[$i];
965 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
true,
1001 $area->setShape($a_shape);
1002 $area->setCoords($a_coords);
1003 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2,
false,
1004 $x_ratio, $y_ratio);
1016 header(
"Pragma: no-cache");
1048 if (imagecolorstotal($this->map_image) > 250)
1050 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1051 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1055 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1056 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1084 ImageDestroy($this->map_image);
1104 for ($i=0; $i < count($this->mapareas); $i++)
1106 $area = $this->mapareas[$i];
1110 if ($area->getHighlightMode() !=
"")
1112 $hm =
' HighlightMode="'.$area->getHighlightMode().
'" ';
1113 $hcl = ($area->getHighlightClass() !=
"")
1114 ? $area->getHighlightClass()
1116 $hm.=
'HighlightClass="'.$hcl.
'" ';
1119 $xml .=
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\" ".$hm.
">";
1122 $target_frame = $area->getTargetFrame();
1124 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"")
1126 $target_frame =
"Glossary";
1129 $tf_str = ($target_frame ==
"")
1131 :
"TargetFrame=\"".$target_frame.
"\"";
1133 $xml .=
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
1134 $area->getType().
"\" $tf_str>";
1136 $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1137 $xml .=
"</IntLink>";
1141 $xml .=
"<ExtLink Href=\"".str_replace(
"&",
"&",$area->getHref()).
"\" Title=\"".
1142 str_replace(
"&",
"&",$area->getExtTitle()).
"\">";
1143 $xml .= str_replace(
"&",
"&", $area->getTitle());
1144 $xml .=
"</ExtLink>";
1146 $xml .=
"</MapArea>";
1163 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1164 $ilDB->quote($a_mob_id,
"integer").
" ".
1166 $item_set = $ilDB->query(
$query);
1167 while ($item_rec = $ilDB->fetchAssoc($item_set))
1183 $query =
"SELECT * FROM media_item WHERE mob_id = ".
1184 $ilDB->quote($a_mob_id,
"integer").
" ORDER BY nr";
1186 $item_set = $ilDB->query(
$query);
1188 while ($item_rec = $ilDB->fetchAssoc($item_set))
1191 foreach($map_links as $key => $map_link)
1193 $links[$key] = $map_link;
1204 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1207 foreach ($par as $k => $v)
static assembleParameterString($a_par_arr)
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
static _resolveIntLinks($a_item_id)
resolve internal links of an item id
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
static createDirectory($a_dir, $a_mod=0755)
create directory
Add a drawing to the header
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getDataDir()
get data directory (outside webspace)
Write to Excel2007 format
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array