4 require_once(
"Services/MediaObjects/classes/class.ilMapArea.php");
54 $this->db = $DIC->database();
55 $this->lng = $DIC->language();
56 $this->parameters = array();
57 $this->mapareas = array();
90 $this->mob_id = $a_mob_id;
121 $this->duration = $a_val;
139 $this->text_representation = $a_val;
148 return $this->text_representation;
157 $this->upload_hash = $a_val;
176 $item_id =
$ilDB->nextId(
"media_item");
177 $query =
"INSERT INTO media_item (id,mob_id, purpose, location, " .
178 "location_type, format, width, " .
179 "height, halign, caption, nr, text_representation, upload_hash, duration) VALUES " .
181 $ilDB->quote($item_id,
"integer") .
"," .
191 $ilDB->quote($this->
getNr(),
"integer") .
"," .
198 $this->
setId($item_id);
202 foreach ($params as
$name => $value) {
203 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
204 "(" .
$ilDB->quote($item_id,
"integer") .
"," .
206 $ilDB->quote($value,
"text") .
")";
211 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
212 if (is_object($this->mapareas[
$i])) {
213 $this->mapareas[
$i]->setItemId($this->
getId());
214 $this->mapareas[
$i]->setNr($i + 1);
215 $this->mapareas[
$i]->create();
227 $query =
"UPDATE media_item SET " .
228 " mob_id = " .
$ilDB->quote($this->
getMobId(),
"integer") .
"," .
233 " width = " .
$ilDB->quote($this->
getWidth(),
"text") .
"," .
237 " nr = " .
$ilDB->quote($this->
getNr(),
"integer") .
"," .
241 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
245 $query =
"DELETE FROM mob_parameter WHERE med_item_id = " .
250 foreach ($params as
$name => $value) {
251 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
252 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
254 $ilDB->quote($value,
"text") .
")";
268 $query =
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
269 "(" .
$ilDB->quote($this->
getId(),
"integer") .
"," .
270 $ilDB->quote($a_name,
"text") .
"," .
271 $ilDB->quote($a_value,
"text") .
")";
282 $item_id = $this->
getId();
287 $query =
"SELECT * FROM media_item WHERE id = " .
290 $query =
"SELECT * FROM media_item WHERE mob_id = " .
292 "AND nr=" .
$ilDB->quote($this->
getNr(),
"integer");
296 $item_rec =
$ilDB->fetchAssoc($item_set);
301 $this->
setWidth($item_rec[
"width"]);
306 $this->
setNr($item_rec[
"nr"]);
307 $this->
setMobId($item_rec[
"mob_id"]);
308 $this->
setId($item_rec[
"id"]);
315 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = " .
318 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
319 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
324 for (
$i = 1;
$i <= $max;
$i++) {
338 $q =
"UPDATE media_item SET tried_thumb = " .
339 $ilDB->quote($a_tried,
"text") .
340 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
342 $ilDB->manipulate($q);
354 $ilDB = $DIC->database();
357 $query =
"SELECT * FROM media_item WHERE mob_id = " .
358 $ilDB->quote($a_mob_id,
"integer") .
" " .
359 "AND purpose = " .
$ilDB->quote($a_purpose,
"text");
361 if ($rec =
$ilDB->fetchAssoc($set)) {
362 return $rec[
"location"];
376 $ilDB = $DIC->database();
379 $query =
"SELECT * FROM media_item WHERE id = " .
380 $ilDB->quote($a_med_id,
"integer");
382 if ($rec =
$ilDB->fetchAssoc($set)) {
383 return $rec[
"mob_id"];
399 $ilDB = $DIC->database();
402 $query =
"SELECT * FROM media_item WHERE mob_id = " .
403 $ilDB->quote($a_mobId,
"integer") .
" " .
404 "AND purpose=" .
$ilDB->quote($a_purpose,
"text") .
" ORDER BY nr";
407 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
421 $ilDB = $DIC->database();
424 $query =
"SELECT * FROM media_item WHERE mob_id = " .
425 $ilDB->quote($a_mob->getId(),
"integer") .
" " .
428 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
430 $media_item->setNr($item_rec[
"nr"]);
431 $media_item->setId($item_rec[
"id"]);
432 $media_item->setLocation($item_rec[
"location"]);
433 $media_item->setLocationType($item_rec[
"location_type"]);
434 $media_item->setFormat($item_rec[
"format"]);
435 $media_item->setWidth($item_rec[
"width"]);
436 $media_item->setHeight($item_rec[
"height"]);
437 $media_item->setHAlign($item_rec[
"halign"]);
438 $media_item->setCaption($item_rec[
"caption"]);
439 $media_item->setPurpose($item_rec[
"purpose"]);
440 $media_item->setMobId($item_rec[
"mob_id"]);
441 $media_item->setThumbTried($item_rec[
"tried_thumb"]);
442 $media_item->setTextRepresentation($item_rec[
"text_representation"]);
443 $media_item->setUploadHash($item_rec[
"upload_hash"]);
444 $media_item->setDuration((
int) $item_rec[
"duration"]);
447 $query =
"SELECT * FROM mob_parameter WHERE med_item_id = " .
448 $ilDB->quote($item_rec[
"id"],
"integer");
450 while ($par_rec =
$ilDB->fetchAssoc($par_set)) {
451 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
456 for (
$i = 1;
$i <= $max;
$i++) {
458 $media_item->addMapArea($area);
462 $a_mob->addMediaItem($media_item);
474 $ilDB = $DIC->database();
477 $query =
"SELECT * FROM media_item WHERE mob_id = " .
478 $ilDB->quote($a_mob_id,
"integer");
480 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
482 $query =
"DELETE FROM mob_parameter WHERE med_item_id = " .
483 $ilDB->quote($item_rec[
"id"],
"integer");
487 $query =
"DELETE FROM map_area WHERE item_id = " .
488 $ilDB->quote($item_rec[
"id"],
"integer");
493 $query =
"DELETE FROM media_item WHERE mob_id = " .
494 $ilDB->quote($a_mob_id,
"integer");
500 $this->purpose = $a_purpose;
510 $this->location = $a_location;
520 $this->location_type = $a_type;
530 $this->format = $a_format;
540 $this->tried_thumb = $a_tried;
545 return $this->tried_thumb;
561 $this->mapareas[
$i - 2] = $this->mapareas[
$i - 1];
562 $this->mapareas[
$i - 2]->setNr(
$i - 1);
565 if ($nr <= $this->map_cnt) {
566 unset($this->mapareas[$this->map_cnt - 1]);
576 return $this->mapareas[
$nr - 1];
600 $this->width = $a_width;
616 $this->height = $a_height;
633 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
636 return array(
"width" =>
$size[0],
"height" =>
$size[1]);
648 $this->caption = $a_caption;
664 $this->halign = $a_halign;
682 if (self::checkParameter($a_name, $a_value)) {
683 $this->parameters[$a_name] = $a_value;
692 $this->parameters = array();
703 if (is_array($par_arr)) {
704 foreach ($par_arr as $par => $val) {
719 if (substr(strtolower(trim($a_par)), 0, 2) ==
"on") {
723 if (is_int(strpos(strtolower($a_val),
"javascript"))) {
727 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];
805 $o_file = $file_arr[count($file_arr) - 1];
806 $file_arr = explode(
".", $o_file);
807 unset($file_arr[count($file_arr) - 1]);
808 $file = implode(
".", $file_arr);
810 if (!$a_reference_copy) {
841 if (is_file($jpeg_file)) {
844 if (is_int(strpos($this->
getFormat(),
"image"))) {
851 if (is_file($thumb_file)) {
854 if (is_file($thumb_file_small)) {
855 unlink($thumb_file_small);
861 if (is_file($med_file)) {
867 if ($this->
getFormat() ===
"image/svg+xml") {
870 if ($a_size ==
"small") {
871 if (is_file($thumb_file_small)) {
872 $random = new \ilRandom();
877 if (is_file($thumb_file)) {
878 $random = new \ilRandom();
912 if ($handle && $lcopy) {
913 while (!feof($handle)) {
914 $content = fread($handle, 4096);
915 fwrite($lcopy, $content);
964 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
965 if ((((
$i + 1) == $a_area_nr) && !$a_exclude) ||
966 (((
$i + 1) != $a_area_nr) && $a_exclude) ||
969 $area = $this->mapareas[
$i];
1008 $area->setShape($a_shape);
1009 $area->setCoords($a_coords);
1028 header(
"Pragma: no-cache");
1029 header(
"Expires: 0");
1059 if (imagecolorstotal($this->map_image) > 250) {
1060 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1061 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1063 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1064 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1091 ImageDestroy($this->map_image);
1110 for (
$i = 0;
$i < count($this->mapareas);
$i++) {
1111 $area = $this->mapareas[
$i];
1115 if ($area->getHighlightMode() !=
"") {
1116 $hm =
' HighlightMode="' . $area->getHighlightMode() .
'" ';
1117 $hcl = ($area->getHighlightClass() !=
"")
1118 ? $area->getHighlightClass()
1120 $hm .=
'HighlightClass="' . $hcl .
'" ';
1123 $xml .=
"<MapArea Shape=\"" . $area->getShape() .
"\" Coords=\"" . $area->getCoords() .
"\" " . $hm .
">";
1125 $target_frame = $area->getTargetFrame();
1127 if ($area->getType() ==
"GlossaryItem" && $target_frame ==
"") {
1128 $target_frame =
"Glossary";
1131 $tf_str = ($target_frame ==
"")
1133 :
"TargetFrame=\"" . $target_frame .
"\"";
1135 $xml .=
"<IntLink Target=\"" . $area->getTarget($a_insert_inst, $a_inst) .
"\" Type=\"" .
1136 $area->getType() .
"\" $tf_str>";
1138 $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1139 $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>";
1159 $ilDB = $DIC->database();
1163 $query =
"SELECT * FROM media_item WHERE mob_id = " .
1164 $ilDB->quote($a_mob_id,
"integer") .
" " .
1167 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
1180 $ilDB = $DIC->database();
1183 $query =
"SELECT * FROM media_item WHERE mob_id = " .
1184 $ilDB->quote($a_mob_id,
"integer") .
" ORDER BY nr";
1188 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
1190 foreach ($map_links as $key => $map_link) {
1191 $links[$key] = $map_link;
1202 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1207 foreach ($par as $k => $v) {
1216 $ana->analyzeFile();
1217 $this->
setDuration((
int) $ana->getPlaytimeSeconds());
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