4 require_once(
"Services/MediaObjects/classes/class.ilMapArea.php");
55 $this->db = $DIC->database();
56 $this->lng = $DIC->language();
57 $this->parameters = array();
58 $this->mapareas = array();
94 $this->mob_id = $a_mob_id;
127 $this->text_representation = $a_val;
137 return $this->text_representation;
147 $this->upload_hash = $a_val;
168 $item_id =
$ilDB->nextId(
"media_item");
169 $query =
"INSERT INTO media_item (id,mob_id, purpose, location, " .
170 "location_type, format, width, " .
171 "height, halign, caption, nr, text_representation, upload_hash) VALUES " .
173 $ilDB->quote($item_id,
"integer") .
"," .
183 $ilDB->quote($this->
getNr(),
"integer") .
"," .
189 $this->
setId($item_id);
194 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
195 "(" .
$ilDB->quote($item_id,
"integer") .
"," .
197 $ilDB->quote($value,
"text") .
")";
202 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
203 if (is_object($this->mapareas[
$i])) {
204 $this->mapareas[
$i]->setItemId($this->
getId());
205 $this->mapareas[
$i]->setNr($i + 1);
206 $this->mapareas[
$i]->create();
218 $query =
"UPDATE media_item SET " .
219 " mob_id = " .
$ilDB->quote($this->
getMobId(),
"integer") .
"," .
224 " width = " .
$ilDB->quote($this->
getWidth(),
"text") .
"," .
228 " nr = " .
$ilDB->quote($this->
getNr(),
"integer") .
"," .
231 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
235 $query =
"DELETE FROM mob_parameter WHERE med_item_id = " .
241 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
242 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
244 $ilDB->quote($value,
"text") .
")";
259 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
260 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
261 $ilDB->quote($a_name,
"text") .
"," .
262 $ilDB->quote($a_value,
"text") .
")";
273 $item_id = $this->
getId();
278 $query =
"SELECT * FROM media_item WHERE id = " .
281 $query =
"SELECT * FROM media_item WHERE mob_id = " .
283 "AND nr=" .
$ilDB->quote($this->
getNr(),
"integer");
287 $item_rec =
$ilDB->fetchAssoc($item_set);
292 $this->
setWidth($item_rec[
"width"]);
297 $this->
setNr($item_rec[
"nr"]);
298 $this->
setMobId($item_rec[
"mob_id"]);
299 $this->
setId($item_rec[
"id"]);
305 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = " .
308 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
309 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
314 for (
$i = 1;
$i <= $max;
$i++) {
328 $q =
"UPDATE media_item SET tried_thumb = " .
329 $ilDB->quote($a_tried,
"text") .
330 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
332 $ilDB->manipulate($q);
345 $ilDB = $DIC->database();
348 $query =
"SELECT * FROM media_item WHERE mob_id = " .
349 $ilDB->quote($a_mob_id,
"integer") .
" " .
350 "AND purpose = " .
$ilDB->quote($a_purpose,
"text");
352 if ($rec =
$ilDB->fetchAssoc($set)) {
353 return $rec[
"location"];
368 $ilDB = $DIC->database();
371 $query =
"SELECT * FROM media_item WHERE id = " .
372 $ilDB->quote($a_med_id,
"integer");
374 if ($rec =
$ilDB->fetchAssoc($set)) {
375 return $rec[
"mob_id"];
391 $ilDB = $DIC->database();
394 $query =
"SELECT * FROM media_item WHERE mob_id = " .
395 $ilDB->quote($a_mobId,
"integer") .
" " .
396 "AND purpose=" .
$ilDB->quote($a_purpose,
"text") .
" ORDER BY nr";
399 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
414 $ilDB = $DIC->database();
417 $query =
"SELECT * FROM media_item WHERE mob_id = " .
418 $ilDB->quote($a_mob->getId(),
"integer") .
" " .
421 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
423 $media_item->setNr($item_rec[
"nr"]);
424 $media_item->setId($item_rec[
"id"]);
425 $media_item->setLocation($item_rec[
"location"]);
426 $media_item->setLocationType($item_rec[
"location_type"]);
427 $media_item->setFormat($item_rec[
"format"]);
428 $media_item->setWidth($item_rec[
"width"]);
429 $media_item->setHeight($item_rec[
"height"]);
430 $media_item->setHAlign($item_rec[
"halign"]);
431 $media_item->setCaption($item_rec[
"caption"]);
432 $media_item->setPurpose($item_rec[
"purpose"]);
433 $media_item->setMobId($item_rec[
"mob_id"]);
434 $media_item->setThumbTried($item_rec[
"tried_thumb"]);
435 $media_item->setTextRepresentation($item_rec[
"text_representation"]);
436 $media_item->setUploadHash($item_rec[
"upload_hash"]);
439 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = " .
440 $ilDB->quote($item_rec[
"id"],
"integer");
442 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
443 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
448 for (
$i = 1;
$i <= $max;
$i++) {
450 $media_item->addMapArea($area);
454 $a_mob->addMediaItem($media_item);
467 $ilDB = $DIC->database();
470 $query =
"SELECT * FROM media_item WHERE mob_id = " .
471 $ilDB->quote($a_mob_id,
"integer");
473 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
475 $query =
"DELETE FROM mob_parameter WHERE med_item_id = " .
476 $ilDB->quote($item_rec[
"id"],
"integer");
480 $query =
"DELETE FROM map_area WHERE item_id = " .
481 $ilDB->quote($item_rec[
"id"],
"integer");
486 $query =
"DELETE FROM media_item WHERE mob_id = " .
487 $ilDB->quote($a_mob_id,
"integer");
493 $this->purpose = $a_purpose;
503 $this->location = $a_location;
513 $this->location_type =
$a_type;
523 $this->format = $a_format;
533 $this->tried_thumb = $a_tried;
538 return $this->tried_thumb;
554 $this->mapareas[
$i - 2] = $this->mapareas[
$i - 1];
555 $this->mapareas[
$i - 2]->setNr(
$i - 1);
558 if ($nr <= $this->map_cnt) {
559 unset($this->mapareas[$this->map_cnt - 1]);
569 return $this->mapareas[
$nr - 1];
593 $this->width = $a_width;
609 $this->height = $a_height;
626 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
629 return array(
"width" =>
$size[0],
"height" =>
$size[1]);
641 $this->caption = $a_caption;
657 $this->halign = $a_halign;
677 if (self::checkParameter($a_name, $a_value)) {
678 $this->parameters[$a_name] = $a_value;
687 $this->parameters = array();
699 if (is_array($par_arr)) {
700 foreach ($par_arr as $par => $val) {
716 if (substr(strtolower(trim($a_par)), 0, 2) ==
"on") {
720 if (is_int(strpos(strtolower($a_val),
"javascript"))) {
724 if (in_array(strtolower(trim($a_par)), array(
"src"))) {
755 return $this->parameters[$a_name];
775 if (!@is_dir($work_dir)) {
787 return $loc_arr[count($loc_arr) - 1];
806 $o_file = $file_arr[count($file_arr) - 1];
807 $file_arr = explode(
".", $o_file);
808 unset($file_arr[count($file_arr) - 1]);
809 $file = implode($file_arr,
".");
811 if (!$a_reference_copy) {
842 if (is_file($jpeg_file)) {
846 if (is_int(strpos($this->
getFormat(),
"image"))) {
854 if (is_file($thumb_file)) {
857 if (is_file($thumb_file_small)) {
858 unlink($thumb_file_small);
864 if (is_file($med_file)) {
869 if ($a_size ==
"small") {
870 if (is_file($thumb_file_small)) {
871 $random = new \ilRandom();
873 $this->
getPurpose() .
"_small.".$format.
"?dummy=" . $random->int(1, 999999);
876 if (is_file($thumb_file)) {
877 $random = new \ilRandom();
879 $this->
getPurpose() .
".".$format.
"?dummy=" . $random->int(1, 999999);
912 if ($handle && $lcopy) {
913 while (!feof($handle)) {
914 $content = fread($handle, 4096);
915 fwrite($lcopy, $content);
965 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
966 if ((((
$i + 1) == $a_area_nr) && !$a_exclude) ||
967 (((
$i + 1) != $a_area_nr) && $a_exclude) ||
970 $area = $this->mapareas[
$i];
1011 $area->setShape($a_shape);
1012 $area->setCoords($a_coords);
1031 header(
"Pragma: no-cache");
1032 header(
"Expires: 0");
1062 if (imagecolorstotal($this->map_image) > 250) {
1063 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1064 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1066 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1067 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1094 ImageDestroy($this->map_image);
1114 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
1115 $area = $this->mapareas[
$i];
1119 if ($area->getHighlightMode() !=
"") {
1120 $hm =
' HighlightMode="' . $area->getHighlightMode() .
'" ';
1121 $hcl = ($area->getHighlightClass() !=
"")
1122 ? $area->getHighlightClass()
1124 $hm .=
'HighlightClass="' . $hcl .
'" ';
1127 $xml .=
"<MapArea Shape=\"" . $area->getShape() .
"\" Coords=\"" . $area->getCoords() .
"\" " . $hm .
">";
1129 $target_frame = $area->getTargetFrame();
1131 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"") {
1132 $target_frame =
"Glossary";
1135 $tf_str = ($target_frame ==
"")
1137 :
"TargetFrame=\"" . $target_frame .
"\"";
1139 $xml .=
"<IntLink Target=\"" . $area->getTarget($a_insert_inst, $a_inst) .
"\" Type=\"" .
1140 $area->getType() .
"\" $tf_str>";
1142 $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1143 $xml .=
"</IntLink>";
1145 $xml .=
"<ExtLink Href=\"" . str_replace(
"&",
"&", $area->getHref()) .
"\" Title=\"" .
1146 str_replace(
"&",
"&", $area->getExtTitle()) .
"\">";
1147 $xml .= str_replace(
"&",
"&", $area->getTitle());
1148 $xml .=
"</ExtLink>";
1150 $xml .=
"</MapArea>";
1165 $ilDB = $DIC->database();
1169 $query =
"SELECT * FROM media_item WHERE mob_id = " .
1170 $ilDB->quote($a_mob_id,
"integer") .
" " .
1173 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
1187 $ilDB = $DIC->database();
1190 $query =
"SELECT * FROM media_item WHERE mob_id = " .
1191 $ilDB->quote($a_mob_id,
"integer") .
" ORDER BY nr";
1195 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
1197 foreach ($map_links as
$key => $map_link) {
1209 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1214 foreach ($par as $k => $v) {
1229 $db = $DIC->database();
1232 "SELECT * FROM media_item " .
1233 " WHERE upload_hash = %s ",
1237 $media_items = array();
1238 while ($rec =
$db->fetchAssoc($set)) {
1239 $media_items[] = $rec;
1241 return $media_items;
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 convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
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 _getMaxNr($a_item_id)
get maximum nr of media item (static)
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array