ILIAS  release_8 Revision v8.24
ilMediaItem Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilMediaItem:

Public Member Functions

 __construct (int $a_id=0)
 
 setId (int $a_id)
 set media item id More...
 
 getId ()
 
 setMobId (int $a_mob_id)
 set id of parent media object More...
 
 getMobId ()
 
 setNr (int $a_nr)
 set number of media item within media object More...
 
 getNr ()
 
 setDuration (int $a_val)
 
 getDuration ()
 
 setTextRepresentation (string $a_val)
 
 getTextRepresentation ()
 
 setUploadHash (string $a_val)
 
 getUploadHash ()
 
 create ()
 
 update ()
 
 writeParameter (string $a_name, string $a_value)
 
 read ()
 read media item data (item id or (mob_id and nr) must be set) More...
 
 writeThumbTried (string $a_tried)
 write thumbnail creation try data ("y"/"n") More...
 
 setPurpose (string $a_purpose)
 
 getPurpose ()
 
 setLocation (string $a_location)
 
 getLocation ()
 
 setLocationType (string $a_type)
 
 getLocationType ()
 
 setFormat (string $a_format)
 
 getFormat ()
 
 setThumbTried (string $a_tried)
 
 getThumbTried ()
 
 addMapArea (ilMapArea $a_map_area)
 
 deleteMapArea (int $nr)
 
 getMapArea (int $nr)
 
 getMapAreas ()
 
 getWidth ()
 
 setWidth (string $a_width)
 
 getHeight ()
 
 setHeight (string $a_height)
 
 getOriginalSize ()
 
 setCaption (string $a_caption)
 
 getCaption ()
 
 setHAlign (string $a_halign)
 set horizontal align More...
 
 getHAlign ()
 
 setParameter (string $a_name, string $a_value)
 
 resetParameters ()
 
 setParameters (string $a_par)
 set all parameters via parameter string (format: par1="value1", par2="value2", ...) More...
 
 getParameters ()
 
 getParameterString ()
 
 getParameter (string $a_name)
 
 getWorkDirectory ()
 get work directory for image map editing More...
 
 createWorkDirectory ()
 create work directory for image map editing More...
 
 getSuffix ()
 get location suffix More...
 
 getMapWorkCopyType ()
 get image type of image map work copy More...
 
 getMapWorkCopyName (bool $a_reference_copy=false)
 Get name of image map work copy file. More...
 
 getDirectory ()
 get media file directory More...
 
 getThumbnailDirectory (string $a_mode="filesystem")
 get media file directory More...
 
 getThumbnailTarget (string $a_size="")
 get thumbnail target More...
 
 copyOriginal ()
 Copy the original file for map editing to the working directory. More...
 
 makeMapWorkCopy (int $a_area_nr=0, bool $a_exclude=false)
 make map work copy of image More...
 
 addAreaToMapWorkCopy (string $a_shape, string $a_coords)
 draw a new area in work image More...
 
 outputMapWorkCopy ()
 output raw map work copy file More...
 
 buildMapWorkImage ()
 build image map work image More...
 
 saveMapWorkImage ()
 save image map work image as file More...
 
 getMapWorkImage ()
 
 getMapAreasXML (bool $a_insert_inst=false, int $a_inst=0)
 get xml code of media items' areas More...
 
 extractUrlParameters ()
 Extract parameters of special external references to parameter array. More...
 
 determineDuration ()
 

Static Public Member Functions

static _lookupLocationForMobId (int $a_mob_id, string $a_purpose)
 
static _lookupMobId (int $a_med_id)
 
static _getMediaItemsOfMObId (int $a_mobId, string $a_purpose)
 read media item with specific purpose and mobId More...
 
static _getMediaItemsOfMOb (ilObjMediaObject $a_mob)
 Read media items into(!) media object (static) More...
 
static deleteAllItemsOfMob (int $a_mob_id)
 
static checkParameter (string $a_par, string $a_val)
 Check parameter (filter javascript related and other unsafe parameters/values) More...
 
static _resolveMapAreaLinks (int $a_mob_id)
 resolve internal links of all media items of a media object More...
 
static _getMapAreasIntLinks (int $a_mob_id)
 get all internal links of map areas of a mob More...
 
static getMediaItemsForUploadHash (string $a_hash)
 Get media items for upload hash. More...
 

Data Fields

int $id = 0
 
string $purpose = ""
 
string $location = ""
 
string $location_type = ""
 
string $format = ""
 
string $width = ""
 
string $height = ""
 
string $caption = ""
 
string $halign = ""
 
array $parameters = []
 
int $mob_id = 0
 
int $nr = 0
 
array $mapareas = []
 
int $map_cnt = 0
 
 $map_image = null
 
int $color1
 
int $color2
 

Protected Attributes

string $tried_thumb = ""
 
string $text_representation = ""
 
ilDBInterface $db
 
ilLanguage $lng
 
int $duration = 0
 
string $upload_hash = ''
 

Static Private Member Functions

static getGDSupportedImageType (string $a_desired_type)
 returns the best supported image type by this PHP build More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilMediaItem Media Item, component of a media object (file or reference)

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilMediaItem.php.

Constructor & Destructor Documentation

◆ __construct()

ilMediaItem::__construct ( int  $a_id = 0)

Definition at line 54 of file class.ilMediaItem.php.

56 {
57 global $DIC;
58
59 $this->db = $DIC->database();
60 $this->lng = $DIC->language();
61 $this->parameters = array();
62 $this->mapareas = array();
63 $this->map_cnt = 0;
64
65 if ($a_id != 0) {
66 $this->setId($a_id);
67 $this->read();
68 }
69 }
read()
read media item data (item id or (mob_id and nr) must be set)
setId(int $a_id)
set media item id
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\lng(), read(), and setId().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getMapAreasIntLinks()

static ilMediaItem::_getMapAreasIntLinks ( int  $a_mob_id)
static

get all internal links of map areas of a mob

Parameters
int$a_mob_idmedia object id

Definition at line 1148 of file class.ilMediaItem.php.

1150 : array {
1151 global $DIC;
1152
1153 $ilDB = $DIC->database();
1154
1155 // read media_items records
1156 $query = "SELECT * FROM media_item WHERE mob_id = " .
1157 $ilDB->quote($a_mob_id, "integer") . " ORDER BY nr";
1158
1159 $item_set = $ilDB->query($query);
1160 $links = array();
1161 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
1162 $map_links = ilMapArea::_getIntLinks($item_rec["id"]);
1163 foreach ($map_links as $key => $map_link) {
1164 $links[$key] = $map_link;
1165 }
1166 }
1167 return $links;
1168 }
static _getIntLinks(int $a_item_id)
get all internal links of a media items map areas
string $key
Consumer key/client ID value.
Definition: System.php:193
$query

Referenced by ilPageObjectGUI\displayMedia(), ilPageObject\getInternalLinks(), ilLMPresentationGUI\ilMedia(), and ilGlossaryPresentationGUI\media().

+ Here is the caller graph for this function:

◆ _getMediaItemsOfMOb()

static ilMediaItem::_getMediaItemsOfMOb ( ilObjMediaObject  $a_mob)
static

Read media items into(!) media object (static)

Definition at line 431 of file class.ilMediaItem.php.

433 : void {
434 global $DIC;
435
436 $ilDB = $DIC->database();
437
438 // read media_object record
439 $query = "SELECT * FROM media_item WHERE mob_id = " .
440 $ilDB->quote($a_mob->getId(), "integer") . " " .
441 "ORDER BY nr";
442 $item_set = $ilDB->query($query);
443 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
444 $media_item = new ilMediaItem();
445 $media_item->setNr((int) $item_rec["nr"]);
446 $media_item->setId((int) $item_rec["id"]);
447 $media_item->setLocation((string) $item_rec["location"]);
448 $media_item->setLocationType((string) $item_rec["location_type"]);
449 $media_item->setFormat((string) $item_rec["format"]);
450 $media_item->setWidth((string) $item_rec["width"]);
451 $media_item->setHeight((string) $item_rec["height"]);
452 $media_item->setHAlign((string) $item_rec["halign"]);
453 $media_item->setCaption((string) $item_rec["caption"]);
454 $media_item->setPurpose((string) $item_rec["purpose"]);
455 $media_item->setMobId((int) $item_rec["mob_id"]);
456 $media_item->setThumbTried((string) $item_rec["tried_thumb"]);
457 $media_item->setTextRepresentation((string) $item_rec["text_representation"]);
458 $media_item->setUploadHash((string) $item_rec["upload_hash"]);
459 $media_item->setDuration((int) $item_rec["duration"]);
460
461 // get item parameter
462 $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
463 $ilDB->quote($item_rec["id"], "integer");
464 $par_set = $ilDB->query($query);
465 while ($par_rec = $ilDB->fetchAssoc($par_set)) {
466 $media_item->setParameter($par_rec["name"], $par_rec["value"]);
467 }
468
469 // get item map areas
470 $max = ilMapArea::_getMaxNr($media_item->getId());
471 for ($i = 1; $i <= $max; $i++) {
472 $area = new ilMapArea($media_item->getId(), $i);
473 $media_item->addMapArea($area);
474 }
475
476 // add media item to media object
477 $a_mob->addMediaItem($media_item);
478 }
479 }
Class ilMapArea.
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMediaItem(ilMediaItem $a_item)
$i
Definition: metadata.php:41

References $i, $ilDB, $query, ilMapArea\_getMaxNr(), and ilObjMediaObject\addMediaItem().

Referenced by ilObjMediaObject\read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMediaItemsOfMObId()

static ilMediaItem::_getMediaItemsOfMObId ( int  $a_mobId,
string  $a_purpose 
)
static

read media item with specific purpose and mobId

Parameters
int$a_mobId
string$a_purpose
Returns
?ilMediaItem[]

Definition at line 408 of file class.ilMediaItem.php.

411 : ?array {
412 global $DIC;
413
414 $ilDB = $DIC->database();
415
416 // read media_object record
417 $query = "SELECT * FROM media_item WHERE mob_id = " .
418 $ilDB->quote($a_mobId, "integer") . " " .
419 "AND purpose=" . $ilDB->quote($a_purpose, "text") . " ORDER BY nr";
420 $item_set = $ilDB->query($query);
421
422 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
423 return $item_rec;
424 }
425 return null;
426 }

Referenced by ilObjectFeedWriter\__construct().

+ Here is the caller graph for this function:

◆ _lookupLocationForMobId()

static ilMediaItem::_lookupLocationForMobId ( int  $a_mob_id,
string  $a_purpose 
)
static

Definition at line 364 of file class.ilMediaItem.php.

367 : string {
368 global $DIC;
369
370 $ilDB = $DIC->database();
371
372 // read media_object record
373 $query = "SELECT * FROM media_item WHERE mob_id = " .
374 $ilDB->quote($a_mob_id, "integer") . " " .
375 "AND purpose = " . $ilDB->quote($a_purpose, "text");
376 $set = $ilDB->query($query);
377 if ($rec = $ilDB->fetchAssoc($set)) {
378 return $rec["location"];
379 }
380
381 return "";
382 }

◆ _lookupMobId()

static ilMediaItem::_lookupMobId ( int  $a_med_id)
static

Definition at line 384 of file class.ilMediaItem.php.

386 : int {
387 global $DIC;
388
389 $ilDB = $DIC->database();
390
391 // read media_object record
392 $query = "SELECT * FROM media_item WHERE id = " .
393 $ilDB->quote($a_med_id, "integer");
394 $set = $ilDB->query($query);
395 if ($rec = $ilDB->fetchAssoc($set)) {
396 return (int) $rec["mob_id"];
397 }
398
399 return 0;
400 }

◆ _resolveMapAreaLinks()

static ilMediaItem::_resolveMapAreaLinks ( int  $a_mob_id)
static

resolve internal links of all media items of a media object

Parameters
int$a_mob_idmedia object id

Definition at line 1126 of file class.ilMediaItem.php.

1128 : void {
1129 global $DIC;
1130
1131 $ilDB = $DIC->database();
1132
1133 //echo "mediaItems::resolve<br>";
1134 // read media_object record
1135 $query = "SELECT * FROM media_item WHERE mob_id = " .
1136 $ilDB->quote($a_mob_id, "integer") . " " .
1137 "ORDER BY nr";
1138 $item_set = $ilDB->query($query);
1139 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
1140 ilMapArea::_resolveIntLinks($item_rec["id"]);
1141 }
1142 }
static _resolveIntLinks(int $a_item_id)
resolve internal links of an item id

References ilMapArea\_resolveIntLinks().

Referenced by ilQuestionPageParser\processPagesToParse(), and ilPageObject\resolveIntLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAreaToMapWorkCopy()

ilMediaItem::addAreaToMapWorkCopy ( string  $a_shape,
string  $a_coords 
)

draw a new area in work image

Parameters
string$a_shapeshape
string$a_coordscoordinates string

Definition at line 958 of file class.ilMediaItem.php.

961 : void {
962 $this->buildMapWorkImage();
963
964 // determine ratios
965 $size = getimagesize($this->getMapWorkCopyName());
966 $x_ratio = 1;
967 if ($size[0] > 0 && $this->getWidth() > 0) {
968 $x_ratio = $this->getWidth() / $size[0];
969 }
970 $y_ratio = 1;
971 if ($size[1] > 0 && $this->getHeight() > 0) {
972 $y_ratio = $this->getHeight() / $size[1];
973 }
974
975 // add new area to work image
976 $area = new ilMapArea();
977 $area->setShape($a_shape);
978 $area->setCoords($a_coords);
979 $area->draw(
980 $this->getMapWorkImage(),
981 $this->color1,
982 $this->color2,
983 false,
984 $x_ratio,
985 $y_ratio
986 );
987
988 $this->saveMapWorkImage();
989 }
saveMapWorkImage()
save image map work image as file
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
buildMapWorkImage()
build image map work image

◆ addMapArea()

ilMediaItem::addMapArea ( ilMapArea  $a_map_area)

Definition at line 559 of file class.ilMediaItem.php.

559 : void
560 {
561 $this->mapareas[$this->map_cnt] = $a_map_area;
562 $this->map_cnt++;
563 }

◆ buildMapWorkImage()

ilMediaItem::buildMapWorkImage ( )

build image map work image

Definition at line 1008 of file class.ilMediaItem.php.

1008 : void
1009 {
1010 $im_type = strtolower($this->getMapWorkCopyType());
1011
1012 switch ($im_type) {
1013 case "gif":
1014 $this->map_image = imagecreatefromgif($this->getMapWorkCopyName());
1015 break;
1016
1017 case "jpg":
1018 case "jpeg":
1019 $this->map_image = imagecreatefromjpeg($this->getMapWorkCopyName());
1020 break;
1021
1022 case "png":
1023 $this->map_image = imagecreatefrompng($this->getMapWorkCopyName());
1024 break;
1025 }
1026
1027 // try to allocate black and white as color. if this is not possible, get the closest colors
1028 if (imagecolorstotal($this->map_image) > 250) {
1029 $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1030 $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1031 } else {
1032 $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1033 $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1034 }
1035 }
getMapWorkCopyType()
get image type of image map work copy

◆ checkParameter()

static ilMediaItem::checkParameter ( string  $a_par,
string  $a_val 
)
static

Check parameter (filter javascript related and other unsafe parameters/values)

Definition at line 683 of file class.ilMediaItem.php.

686 : bool {
687 // do not allow event attributes
688 if (substr(strtolower(trim($a_par)), 0, 2) == "on") {
689 return false;
690 }
691 // no javascript in value
692 if (is_int(strpos(strtolower($a_val), "javascript"))) {
693 return false;
694 }
695 // do not allow to change the src attribute
696 if (strtolower(trim($a_par)) == "src") {
697 return false;
698 }
699
700 return true;
701 }

Referenced by ilMediaAliasItem\setParameters().

+ Here is the caller graph for this function:

◆ copyOriginal()

ilMediaItem::copyOriginal ( )

Copy the original file for map editing to the working directory.

Exceptions
ilMapEditingException

Definition at line 863 of file class.ilMediaItem.php.

863 : void
864 {
866 $this->createWorkDirectory();
867
868 $geom = ($this->getWidth() != "" && $this->getHeight() != "")
869 ? $this->getWidth() . "x" . $this->getHeight()
870 : "";
871
872 if ($this->getLocationType() !== "Reference") {
874 $this->getDirectory() . "/" . $this->getLocation(),
875 $this->getMapWorkCopyName(),
876 $this->getMapWorkCopyType(),
877 $geom
878 );
879 } else {
880 // first copy the external file, if necessary
881 if (!is_file($this->getMapWorkCopyName(true)) || (filesize($this->getMapWorkCopyName(true)) == 0)) {
882 $handle = fopen($this->getLocation(), "r");
883 $lcopy = fopen($this->getMapWorkCopyName(true), "w");
884 if ($handle && $lcopy) {
885 while (!feof($handle)) {
886 $content = fread($handle, 4096);
887 fwrite($lcopy, $content);
888 }
889 }
890 fclose($lcopy);
891 fclose($handle);
892 }
893
894 // now, create working copy
896 $this->getMapWorkCopyName(true),
897 $this->getMapWorkCopyName(),
898 $this->getMapWorkCopyType(),
899 $geom
900 );
901 }
902 if (!is_file($this->getMapWorkCopyName())) {
903 throw new ilMapEditingException($lng->txt("cont_map_file_not_generated"));
904 }
905 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
createWorkDirectory()
create work directory for image map editing
getDirectory()
get media file directory
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image

References $lng, and ilShellUtil\convertImage().

+ Here is the call graph for this function:

◆ create()

ilMediaItem::create ( )

Definition at line 196 of file class.ilMediaItem.php.

196 : void
197 {
199
200 $item_id = $ilDB->nextId("media_item");
201 $query = "INSERT INTO media_item (id,mob_id, purpose, location, " .
202 "location_type, format, width, " .
203 "height, halign, caption, nr, text_representation, upload_hash, duration) VALUES " .
204 "(" .
205 $ilDB->quote($item_id, "integer") . "," .
206 $ilDB->quote($this->getMobId(), "integer") . "," .
207 $ilDB->quote($this->getPurpose(), "text") . "," .
208 $ilDB->quote($this->getLocation(), "text") . "," .
209 $ilDB->quote($this->getLocationType(), "text") . "," .
210 $ilDB->quote($this->getFormat(), "text") . "," .
211 $ilDB->quote($this->getWidth(), "text") . "," .
212 $ilDB->quote($this->getHeight(), "text") . "," .
213 $ilDB->quote($this->getHAlign(), "text") . "," .
214 $ilDB->quote($this->getCaption(), "text") . "," .
215 $ilDB->quote($this->getNr(), "integer") . "," .
216 $ilDB->quote($this->getTextRepresentation(), "text") . "," .
217 $ilDB->quote($this->getUploadHash(), "text") . "," .
218 $ilDB->quote($this->getDuration(), "integer") .
219 ")";
220 $ilDB->manipulate($query);
221
222 $this->setId($item_id);
223
224 // create mob parameters
225 $params = $this->getParameters();
226 foreach ($params as $name => $value) {
227 $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
228 "(" . $ilDB->quote($item_id, "integer") . "," .
229 $ilDB->quote($name, "text") . "," .
230 $ilDB->quote($value, "text") . ")";
231 $ilDB->manipulate($query);
232 }
233
234 // create map areas
235 for ($i = 0; $i < count($this->mapareas); $i++) {
236 if (is_object($this->mapareas[$i])) {
237 $this->mapareas[$i]->setItemId($this->getId());
238 $this->mapareas[$i]->setNr($i + 1);
239 $this->mapareas[$i]->create();
240 }
241 }
242 }
ilDBInterface $db
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
if($format !==null) $name
Definition: metadata.php:247

References $db, $i, $ilDB, $name, $params, $query, getCaption(), getDuration(), getFormat(), getHAlign(), getHeight(), getId(), getLocation(), getLocationType(), getMobId(), getNr(), getParameters(), getPurpose(), getTextRepresentation(), getUploadHash(), getWidth(), and setId().

+ Here is the call graph for this function:

◆ createWorkDirectory()

ilMediaItem::createWorkDirectory ( )

create work directory for image map editing

Definition at line 736 of file class.ilMediaItem.php.

736 : void
737 {
738 if (!is_dir(ilFileUtils::getDataDir() . "/map_workfiles")) {
740 }
741 $work_dir = $this->getWorkDirectory();
742 if (!is_dir($work_dir)) {
744 }
745 }
static getDataDir()
get data directory (outside webspace)
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
getWorkDirectory()
get work directory for image map editing

References ilFileUtils\createDirectory(), and ilFileUtils\getDataDir().

+ Here is the call graph for this function:

◆ deleteAllItemsOfMob()

static ilMediaItem::deleteAllItemsOfMob ( int  $a_mob_id)
static

Definition at line 481 of file class.ilMediaItem.php.

481 : void
482 {
483 global $DIC;
484
485 $ilDB = $DIC->database();
486
487 // iterate all media items ob mob
488 $query = "SELECT * FROM media_item WHERE mob_id = " .
489 $ilDB->quote($a_mob_id, "integer");
490 $item_set = $ilDB->query($query);
491 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
492 // delete all parameters of media item
493 $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
494 $ilDB->quote($item_rec["id"], "integer");
495 $ilDB->manipulate($query);
496
497 // delete all map areas of media item
498 $query = "DELETE FROM map_area WHERE item_id = " .
499 $ilDB->quote($item_rec["id"], "integer");
500 $ilDB->manipulate($query);
501 }
502
503 // delete media items
504 $query = "DELETE FROM media_item WHERE mob_id = " .
505 $ilDB->quote($a_mob_id, "integer");
506 $ilDB->manipulate($query);
507 }

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\delete(), and ilObjMediaObject\update().

+ Here is the caller graph for this function:

◆ deleteMapArea()

ilMediaItem::deleteMapArea ( int  $nr)

Definition at line 565 of file class.ilMediaItem.php.

565 : void
566 {
567 for ($i = 1; $i <= $this->map_cnt; $i++) {
568 if ($i > $nr) {
569 $this->mapareas[$i - 2] = $this->mapareas[$i - 1];
570 $this->mapareas[$i - 2]->setNr($i - 1);
571 }
572 }
573 if ($nr <= $this->map_cnt) {
574 unset($this->mapareas[$this->map_cnt - 1]);
575 $this->map_cnt--;
576 }
577 }

References $i.

◆ determineDuration()

ilMediaItem::determineDuration ( )

Definition at line 1184 of file class.ilMediaItem.php.

1184 : void
1185 {
1186 $ana = new ilMediaAnalyzer();
1187
1191 if ($meta["duration"] > 0) {
1192 $this->setDuration((int) $meta["duration"]);
1193 }
1194 } else {
1195 $file = ($this->getLocationType() == "Reference")
1196 ? $this->getLocation()
1197 : ilObjMediaObject::_getDirectory($this->getMobId()) . "/" . $this->getLocation();
1198
1199 $remote = false;
1200
1201 try {
1202 if (substr($file, 0, 4) == "http") {
1203 if ($fp_remote = fopen($file, 'rb')) {
1204 $tmpdir = ilFileUtils::ilTempnam();
1205 ilFileUtils::makeDir($tmpdir);
1206 $localtempfilename = tempnam($tmpdir, 'getID3');
1207 if ($fp_local = fopen($localtempfilename, 'wb')) {
1208 while ($buffer = fread($fp_remote, 8192)) {
1209 fwrite($fp_local, $buffer);
1210 }
1211 fclose($fp_local);
1212 $file = $localtempfilename;
1213 }
1214 fclose($fp_remote);
1215 }
1216 }
1217
1218 $ana->setFile($file);
1219 $ana->analyzeFile();
1220 $this->setDuration((int) $ana->getPlaytimeSeconds());
1221
1222 if ($remote) {
1223 unlink($localtempfilename);
1224 }
1225 } catch (Exception $e) {
1226 }
1227 }
1228 }
static isVimeo(string $a_location)
Identify Vimeo links.
static extractVimeoParameters(string $a_location)
Extract Vimeo Parameter.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDuration(int $a_val)
static _getDirectory(int $a_mob_id)
Get absolute directory.

References Vendor\Package\$e, ilObjMediaObject\_getDirectory(), ilExternalMediaAnalyzer\extractVimeoParameters(), ilExternalMediaAnalyzer\getVimeoMetadata(), ilFileUtils\ilTempnam(), ilExternalMediaAnalyzer\isVimeo(), and ilFileUtils\makeDir().

Referenced by ilObjMediaCastGUI\getDuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractUrlParameters()

ilMediaItem::extractUrlParameters ( )

Extract parameters of special external references to parameter array.

Definition at line 1173 of file class.ilMediaItem.php.

1173 : void
1174 {
1176 $this->getLocation(),
1177 $this->getParameters()
1178 );
1179 foreach ($par as $k => $v) {
1180 $this->setParameter($k, $v);
1181 }
1182 }
static extractUrlParameters(string $a_location, array $a_parameter)
Extract URL information to parameter array.
setParameter(string $a_name, string $a_value)

References ilExternalMediaAnalyzer\extractUrlParameters().

+ Here is the call graph for this function:

◆ getCaption()

ilMediaItem::getCaption ( )

Definition at line 634 of file class.ilMediaItem.php.

634 : string
635 {
636 return $this->caption;
637 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getDirectory()

ilMediaItem::getDirectory ( )

get media file directory

Definition at line 788 of file class.ilMediaItem.php.

788 : string
789 {
791 }

References ilObjMediaObject\_getDirectory().

+ Here is the call graph for this function:

◆ getDuration()

ilMediaItem::getDuration ( )

Definition at line 171 of file class.ilMediaItem.php.

171 : int
172 {
173 return $this->duration;
174 }

References $duration.

Referenced by create(), ilObjMediaCastGUI\getDuration(), and update().

+ Here is the caller graph for this function:

◆ getFormat()

ilMediaItem::getFormat ( )

Definition at line 544 of file class.ilMediaItem.php.

544 : string
545 {
546 return $this->format;
547 }

References $format.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getGDSupportedImageType()

static ilMediaItem::getGDSupportedImageType ( string  $a_desired_type)
staticprivate

returns the best supported image type by this PHP build

Parameters
string$a_desired_type
Returns
string supported image type ("jpg" | "gif" | "png" | "")

Definition at line 117 of file class.ilMediaItem.php.

117 : string
118 {
119 $a_desired_type = strtolower($a_desired_type);
120 // get supported Image Types
121 $im_types = ImageTypes();
122
123 switch ($a_desired_type) {
124 case "jpg":
125 case "jpeg":
126 if ($im_types & IMG_JPG) {
127 return "jpg";
128 }
129 if ($im_types & IMG_GIF) {
130 return "gif";
131 }
132 if ($im_types & IMG_PNG) {
133 return "png";
134 }
135 break;
136
137 case "gif":
138 if ($im_types & IMG_GIF) {
139 return "gif";
140 }
141 if ($im_types & IMG_JPG) {
142 return "jpg";
143 }
144 if ($im_types & IMG_PNG) {
145 return "png";
146 }
147 break;
148
149 case "svg":
150 case "png":
151 if ($im_types & IMG_PNG) {
152 return "png";
153 }
154 if ($im_types & IMG_JPG) {
155 return "jpg";
156 }
157 if ($im_types & IMG_GIF) {
158 return "gif";
159 }
160 break;
161 }
162
163 return "";
164 }

◆ getHAlign()

ilMediaItem::getHAlign ( )

Definition at line 647 of file class.ilMediaItem.php.

647 : string
648 {
649 return $this->halign;
650 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getHeight()

ilMediaItem::getHeight ( )

Definition at line 599 of file class.ilMediaItem.php.

599 : string
600 {
601 return $this->height;
602 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilMediaItem::getId ( )

Definition at line 79 of file class.ilMediaItem.php.

79 : int
80 {
81 return $this->id;
82 }

References $id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getLocation()

ilMediaItem::getLocation ( )

Definition at line 524 of file class.ilMediaItem.php.

524 : string
525 {
526 return $this->location;
527 }

References $location.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getLocationType()

ilMediaItem::getLocationType ( )

Definition at line 534 of file class.ilMediaItem.php.

534 : string
535 {
537 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getMapArea()

ilMediaItem::getMapArea ( int  $nr)

Definition at line 579 of file class.ilMediaItem.php.

579 : ?ilMapArea
580 {
581 return $this->mapareas[$nr - 1] ?? null;
582 }

◆ getMapAreas()

ilMediaItem::getMapAreas ( )

Definition at line 584 of file class.ilMediaItem.php.

584 : array
585 {
586 return $this->mapareas;
587 }

◆ getMapAreasXML()

ilMediaItem::getMapAreasXML ( bool  $a_insert_inst = false,
int  $a_inst = 0 
)

get xml code of media items' areas

Definition at line 1074 of file class.ilMediaItem.php.

1077 : string {
1078 $xml = "";
1079
1080 // build xml of map areas
1081 for ($i = 0; $i < count($this->mapareas); $i++) {
1082 $area = $this->mapareas[$i];
1083
1084 // highlight mode
1085 $hm = "";
1086 if ($area->getHighlightMode() != "") {
1087 $hm = ' HighlightMode="' . $area->getHighlightMode() . '" ';
1088 $hcl = ($area->getHighlightClass() != "")
1089 ? $area->getHighlightClass()
1090 : "Accented";
1091 $hm .= 'HighlightClass="' . $hcl . '" ';
1092 }
1093
1094 $xml .= "<MapArea Shape=\"" . $area->getShape() . "\" Coords=\"" . $area->getCoords() . "\" " . $hm . ">";
1095 if ($area->getLinkType() == IL_INT_LINK) {
1096 $target_frame = $area->getTargetFrame();
1097
1098 if ($area->getType() == "GlossaryItem" && $target_frame == "") {
1099 $target_frame = "Glossary";
1100 }
1101
1102 $tf_str = ($target_frame == "")
1103 ? ""
1104 : "TargetFrame=\"" . $target_frame . "\"";
1105
1106 $xml .= "<IntLink Target=\"" . $area->getTarget($a_insert_inst, $a_inst) . "\" Type=\"" .
1107 $area->getType() . "\" $tf_str>";
1108 // see bug 17893 and http://stackoverflow.com/questions/4026502/xml-error-at-ampersand
1109 $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1110 $xml .= "</IntLink>";
1111 } else {
1112 $xml .= "<ExtLink Href=\"" . str_replace("&", "&amp;", $area->getHref()) . "\" Title=\"" .
1113 str_replace("&", "&amp;", $area->getExtTitle()) . "\">";
1114 $xml .= str_replace("&", "&amp;", $area->getTitle());
1115 $xml .= "</ExtLink>";
1116 }
1117 $xml .= "</MapArea>";
1118 }
1119 return $xml;
1120 }
const IL_INT_LINK
$xml
Definition: metadata.php:351

◆ getMapWorkCopyName()

ilMediaItem::getMapWorkCopyName ( bool  $a_reference_copy = false)

Get name of image map work copy file.

Parameters
bool$a_reference_copyget name for copy of external referenced image

Definition at line 769 of file class.ilMediaItem.php.

771 : string {
772 $file_arr = explode("/", $this->getLocation());
773 $o_file = $file_arr[count($file_arr) - 1];
774 $file_arr = explode(".", $o_file);
775 unset($file_arr[count($file_arr) - 1]);
776 $file = implode(".", $file_arr);
777
778 if (!$a_reference_copy) {
779 return $this->getWorkDirectory() . "/" . $file . "." . $this->getMapWorkCopyType();
780 } else {
781 return $this->getWorkDirectory() . "/l_copy_" . $o_file;
782 }
783 }

◆ getMapWorkCopyType()

ilMediaItem::getMapWorkCopyType ( )

get image type of image map work copy

Definition at line 760 of file class.ilMediaItem.php.

760 : string
761 {
763 }
getSuffix()
get location suffix
static getGDSupportedImageType(string $a_desired_type)
returns the best supported image type by this PHP build

◆ getMapWorkImage()

ilMediaItem::getMapWorkImage ( )
Returns
GdImage|resource|null

Definition at line 1066 of file class.ilMediaItem.php.

1067 {
1068 return $this->map_image;
1069 }

◆ getMediaItemsForUploadHash()

static ilMediaItem::getMediaItemsForUploadHash ( string  $a_hash)
static

Get media items for upload hash.

Parameters
string$a_hashupload hash
Returns
array[]

Definition at line 1235 of file class.ilMediaItem.php.

1237 : array {
1238 global $DIC;
1239
1240 $db = $DIC->database();
1241
1242 $set = $db->queryF(
1243 "SELECT * FROM media_item " .
1244 " WHERE upload_hash = %s ",
1245 array("text"),
1246 array($a_hash)
1247 );
1248 $media_items = array();
1249 while ($rec = $db->fetchAssoc($set)) {
1250 $media_items[] = $rec;
1251 }
1252 return $media_items;
1253 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

Referenced by ilObjMediaPoolGUI\editTitlesAndDescriptions(), ilMediaCreationGUI\editTitlesAndDescriptions(), ilObjMediaPoolGUI\saveTitlesAndDescriptions(), and ilMediaCreationGUI\saveTitlesAndDescriptions().

+ Here is the caller graph for this function:

◆ getMobId()

ilMediaItem::getMobId ( )

Definition at line 92 of file class.ilMediaItem.php.

92 : int
93 {
94 return $this->mob_id;
95 }

References $mob_id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getNr()

ilMediaItem::getNr ( )

Definition at line 105 of file class.ilMediaItem.php.

105 : int
106 {
107 return $this->nr;
108 }

References $nr.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getOriginalSize()

ilMediaItem::getOriginalSize ( )

Definition at line 609 of file class.ilMediaItem.php.

609 : ?array
610 {
611 $mob_dir = ilObjMediaObject::_getDirectory($this->getMobId());
612
613 if (ilUtil::deducibleSize($this->getFormat())) {
614 if ($this->getLocationType() == "LocalFile") {
615 $loc = $mob_dir . "/" . $this->getLocation();
616 } else {
617 $loc = $this->getLocation();
618 }
619
620 $size = ilMediaImageUtil::getImageSize($loc);
621 if ($size[0] > 0 && $size[1] > 0) {
622 return array("width" => $size[0], "height" => $size[1]);
623 }
624 }
625
626 return null;
627 }
static getImageSize(string $a_location)
Get image size from location.
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()

References ilObjMediaObject\_getDirectory(), ilUtil\deducibleSize(), and ilMediaImageUtil\getImageSize().

+ Here is the call graph for this function:

◆ getParameter()

ilMediaItem::getParameter ( string  $a_name)

Definition at line 720 of file class.ilMediaItem.php.

720 : string
721 {
722 return (string) ($this->parameters[$a_name] ?? "");
723 }

◆ getParameters()

ilMediaItem::getParameters ( )

Definition at line 703 of file class.ilMediaItem.php.

703 : array
704 {
705 return $this->parameters;
706 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getParameterString()

ilMediaItem::getParameterString ( )

Definition at line 708 of file class.ilMediaItem.php.

708 : string
709 {
710 if (is_array($this->parameters)) {
711 $target_arr = [];
712 foreach ($this->parameters as $par => $val) {
713 $target_arr[] = "$par=\"$val\"";
714 }
715 return implode(", ", $target_arr);
716 }
717 return "";
718 }
$target_arr
Definition: goto.php:50

References $target_arr.

◆ getPurpose()

ilMediaItem::getPurpose ( )

Definition at line 514 of file class.ilMediaItem.php.

514 : string
515 {
516 return $this->purpose;
517 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getSuffix()

ilMediaItem::getSuffix ( )

get location suffix

Definition at line 750 of file class.ilMediaItem.php.

750 : string
751 {
752 $loc_arr = explode(".", $this->getLocation());
753
754 return $loc_arr[count($loc_arr) - 1];
755 }

◆ getTextRepresentation()

ilMediaItem::getTextRepresentation ( )

Definition at line 181 of file class.ilMediaItem.php.

181 : string
182 {
184 }
string $text_representation

References $text_representation.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getThumbnailDirectory()

ilMediaItem::getThumbnailDirectory ( string  $a_mode = "filesystem")

get media file directory

Definition at line 796 of file class.ilMediaItem.php.

798 : string {
799 return ilObjMediaObject::_getThumbnailDirectory($this->getMobId(), $a_mode);
800 }
static _getThumbnailDirectory(int $a_mob_id, string $a_mode="filesystem")
get directory for files of media object

◆ getThumbnailTarget()

ilMediaItem::getThumbnailTarget ( string  $a_size = "")

get thumbnail target

Definition at line 805 of file class.ilMediaItem.php.

807 : string {
808 $jpeg_file = $this->getThumbnailDirectory() . "/" .
809 $this->getPurpose() . ".jpeg";
810 $format = "png";
811 if (is_file($jpeg_file)) {
812 $format = "jpeg";
813 }
814 if (is_int(strpos($this->getFormat(), "image"))) {
815 $thumb_file = $this->getThumbnailDirectory() . "/" .
816 $this->getPurpose() . "." . $format;
817 $thumb_file_small = $this->getThumbnailDirectory() . "/" .
818 $this->getPurpose() . "_small." . $format;
819 // generate thumbnail (if not tried before)
820 if ($this->getThumbTried() == "n" && $this->getLocationType() == "LocalFile" && $this->getFormat() !== "image/svg+xml") {
821 if (is_file($thumb_file)) {
822 unlink($thumb_file);
823 }
824 if (is_file($thumb_file_small)) {
825 unlink($thumb_file_small);
826 }
827 $this->writeThumbTried("y");
829 $med_file = $this->getDirectory() . "/" . $this->getLocation();
830
831 if (is_file($med_file)) {
832 $mob = new ilObjMediaObject($this->getMobId());
833 $mob->makeThumbnail($this->getLocation(), $this->getPurpose() . "." . $format, $format, "80");
834 $mob->makeThumbnail($this->getLocation(), $this->getPurpose() . "_small." . $format, $format, "40");
835 }
836 }
837 if ($this->getFormat() === "image/svg+xml") {
838 return ilObjMediaObject::_getURL($this->getMobId()) . "/" . $this->getLocation();
839 }
840 if ($a_size == "small") {
841 if (is_file($thumb_file_small)) {
842 $random = new \ilRandom();
843 return $this->getThumbnailDirectory("output") . "/" .
844 $this->getPurpose() . "_small." . $format . "?dummy=" . $random->int(1, 999999);
845 }
846 } else {
847 if (is_file($thumb_file)) {
848 $random = new \ilRandom();
849 return $this->getThumbnailDirectory("output") . "/" .
850 $this->getPurpose() . "." . $format . "?dummy=" . $random->int(1, 999999);
851 }
852 }
853 }
854
855 return "";
856 }
getThumbnailDirectory(string $a_mode="filesystem")
get media file directory
writeThumbTried(string $a_tried)
write thumbnail creation try data ("y"/"n")
static _createThumbnailDirectory(int $a_obj_id)
Create thumbnail directory.
static _getURL(int $a_mob_id)
get directory for files of media object

References $format.

◆ getThumbTried()

ilMediaItem::getThumbTried ( )

Definition at line 554 of file class.ilMediaItem.php.

554 : string
555 {
556 return $this->tried_thumb;
557 }

◆ getUploadHash()

ilMediaItem::getUploadHash ( )

Definition at line 191 of file class.ilMediaItem.php.

191 : string
192 {
193 return $this->upload_hash;
194 }

References $upload_hash.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getWidth()

ilMediaItem::getWidth ( )

Definition at line 589 of file class.ilMediaItem.php.

589 : string
590 {
591 return $this->width;
592 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getWorkDirectory()

ilMediaItem::getWorkDirectory ( )

get work directory for image map editing

Definition at line 728 of file class.ilMediaItem.php.

728 : string
729 {
730 return ilFileUtils::getDataDir() . "/map_workfiles/item_" . $this->getId();
731 }

References ilFileUtils\getDataDir(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ makeMapWorkCopy()

ilMediaItem::makeMapWorkCopy ( int  $a_area_nr = 0,
bool  $a_exclude = false 
)

make map work copy of image

Parameters
int$a_area_nrdraw area $a_area_nr only
bool$a_excludetrue: draw all areas but area $a_area_nr

Definition at line 912 of file class.ilMediaItem.php.

915 : void {
917
918 $this->copyOriginal();
919 $this->buildMapWorkImage();
920
921 // determine ratios
922 $size = getimagesize($this->getMapWorkCopyName());
923 $x_ratio = 1;
924 if ($size[0] > 0 && $this->getWidth() > 0) {
925 $x_ratio = $this->getWidth() / $size[0];
926 }
927 $y_ratio = 1;
928 if ($size[1] > 0 && $this->getHeight() > 0) {
929 $y_ratio = $this->getHeight() / $size[1];
930 }
931
932 // draw map areas
933 for ($i = 0; $i < count($this->mapareas); $i++) {
934 if (((($i + 1) == $a_area_nr) && !$a_exclude) ||
935 ((($i + 1) != $a_area_nr) && $a_exclude) ||
936 ($a_area_nr == 0)
937 ) {
938 $area = $this->mapareas[$i];
939 $area->draw(
940 $this->getMapWorkImage(),
943 true,
944 $x_ratio,
945 $y_ratio
946 );
947 }
948 }
949
950 $this->saveMapWorkImage();
951 }
copyOriginal()
Copy the original file for map editing to the working directory.

◆ outputMapWorkCopy()

ilMediaItem::outputMapWorkCopy ( )

output raw map work copy file

Definition at line 994 of file class.ilMediaItem.php.

994 : void
995 {
996 if ($this->getMapWorkCopyType() != "") {
997 header("Pragma: no-cache");
998 header("Expires: 0");
999 header("Content-type: image/" . strtolower($this->getMapWorkCopyType()));
1000 readfile($this->getMapWorkCopyName());
1001 }
1002 exit;
1003 }
exit
Definition: login.php:28

References exit.

◆ read()

ilMediaItem::read ( )

read media item data (item id or (mob_id and nr) must be set)

Definition at line 297 of file class.ilMediaItem.php.

297 : void
298 {
300
301 $item_id = $this->getId();
302 $mob_id = $this->getMobId();
303 $nr = $this->getNr();
304 $query = "";
305 if ($item_id > 0) {
306 $query = "SELECT * FROM media_item WHERE id = " .
307 $ilDB->quote($this->getId(), "integer");
308 } elseif ($mob_id > 0 && $nr > 0) {
309 $query = "SELECT * FROM media_item WHERE mob_id = " .
310 $ilDB->quote($this->getMobId(), "integer") . " " .
311 "AND nr=" . $ilDB->quote($this->getNr(), "integer");
312 }
313 if ($query != "") {
314 $item_set = $ilDB->query($query);
315 $item_rec = $ilDB->fetchAssoc($item_set);
316
317 $this->setLocation((string) $item_rec["location"]);
318 $this->setLocationType((string) $item_rec["location_type"]);
319 $this->setFormat((string) $item_rec["format"]);
320 $this->setWidth((string) $item_rec["width"]);
321 $this->setHeight((string) $item_rec["height"]);
322 $this->setHAlign((string) $item_rec["halign"]);
323 $this->setCaption((string) $item_rec["caption"]);
324 $this->setPurpose((string) $item_rec["purpose"]);
325 $this->setNr((int) $item_rec["nr"]);
326 $this->setMobId((int) $item_rec["mob_id"]);
327 $this->setId((int) $item_rec["id"]);
328 $this->setThumbTried((string) $item_rec["tried_thumb"]);
329 $this->setTextRepresentation((string) $item_rec["text_representation"]);
330 $this->setUploadHash((string) $item_rec["upload_hash"]);
331 $this->setDuration((int) $item_rec["duration"]);
332
333 // get item parameter
334 $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
335 $ilDB->quote($this->getId(), "integer");
336 $par_set = $ilDB->query($query);
337 while ($par_rec = $ilDB->fetchAssoc($par_set)) {
338 $this->setParameter($par_rec["name"], $par_rec["value"]);
339 }
340
341 // get item map areas
342 $max = ilMapArea::_getMaxNr($this->getId());
343 for ($i = 1; $i <= $max; $i++) {
344 $area = new ilMapArea($this->getId(), $i);
345 $this->addMapArea($area);
346 }
347 }
348 }
setLocationType(string $a_type)
setNr(int $a_nr)
set number of media item within media object
setUploadHash(string $a_val)
setWidth(string $a_width)
addMapArea(ilMapArea $a_map_area)
setThumbTried(string $a_tried)
setLocation(string $a_location)
setCaption(string $a_caption)
setHeight(string $a_height)
setTextRepresentation(string $a_val)
setFormat(string $a_format)
setHAlign(string $a_halign)
set horizontal align
setPurpose(string $a_purpose)
setMobId(int $a_mob_id)
set id of parent media object

References $i, $ilDB, $query, ilMapArea\_getMaxNr(), and ILIAS\Survey\Mode\getId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetParameters()

ilMediaItem::resetParameters ( )

Definition at line 661 of file class.ilMediaItem.php.

661 : void
662 {
663 $this->parameters = [];
664 }

◆ saveMapWorkImage()

ilMediaItem::saveMapWorkImage ( )

save image map work image as file

Definition at line 1040 of file class.ilMediaItem.php.

1040 : void
1041 {
1042 $im_type = strtolower($this->getMapWorkCopyType());
1043
1044 // save image work-copy and free memory
1045 switch ($im_type) {
1046 case "gif":
1047 imagegif($this->map_image, $this->getMapWorkCopyName());
1048 break;
1049
1050 case "jpg":
1051 case "jpeg":
1052 imagejpeg($this->map_image, $this->getMapWorkCopyName());
1053 break;
1054
1055 case "png":
1056 imagepng($this->map_image, $this->getMapWorkCopyName());
1057 break;
1058 }
1059
1060 imagedestroy($this->map_image);
1061 }

◆ setCaption()

ilMediaItem::setCaption ( string  $a_caption)

Definition at line 629 of file class.ilMediaItem.php.

629 : void
630 {
631 $this->caption = $a_caption;
632 }

◆ setDuration()

ilMediaItem::setDuration ( int  $a_val)

Definition at line 166 of file class.ilMediaItem.php.

166 : void
167 {
168 $this->duration = $a_val;
169 }

◆ setFormat()

ilMediaItem::setFormat ( string  $a_format)

Definition at line 539 of file class.ilMediaItem.php.

539 : void
540 {
541 $this->format = $a_format;
542 }

◆ setHAlign()

ilMediaItem::setHAlign ( string  $a_halign)

set horizontal align

Definition at line 642 of file class.ilMediaItem.php.

642 : void
643 {
644 $this->halign = $a_halign;
645 }

◆ setHeight()

ilMediaItem::setHeight ( string  $a_height)

Definition at line 604 of file class.ilMediaItem.php.

604 : void
605 {
606 $this->height = $a_height;
607 }

◆ setId()

ilMediaItem::setId ( int  $a_id)

set media item id

Definition at line 74 of file class.ilMediaItem.php.

74 : void
75 {
76 $this->id = $a_id;
77 }

Referenced by __construct(), and create().

+ Here is the caller graph for this function:

◆ setLocation()

ilMediaItem::setLocation ( string  $a_location)

Definition at line 519 of file class.ilMediaItem.php.

519 : void
520 {
521 $this->location = $a_location;
522 }

◆ setLocationType()

ilMediaItem::setLocationType ( string  $a_type)

Definition at line 529 of file class.ilMediaItem.php.

529 : void
530 {
531 $this->location_type = $a_type;
532 }

◆ setMobId()

ilMediaItem::setMobId ( int  $a_mob_id)

set id of parent media object

Definition at line 87 of file class.ilMediaItem.php.

87 : void
88 {
89 $this->mob_id = $a_mob_id;
90 }

◆ setNr()

ilMediaItem::setNr ( int  $a_nr)

set number of media item within media object

Definition at line 100 of file class.ilMediaItem.php.

100 : void
101 {
102 $this->nr = $a_nr;
103 }

◆ setParameter()

ilMediaItem::setParameter ( string  $a_name,
string  $a_value 
)

Definition at line 652 of file class.ilMediaItem.php.

655 : void {
656 if (self::checkParameter($a_name, $a_value)) {
657 $this->parameters[$a_name] = $a_value;
658 }
659 }

◆ setParameters()

ilMediaItem::setParameters ( string  $a_par)

set all parameters via parameter string (format: par1="value1", par2="value2", ...)

Definition at line 669 of file class.ilMediaItem.php.

669 : void
670 {
671 $this->resetParameters();
672 $par_arr = ilUtil::extractParameterString($a_par);
673 if (is_array($par_arr)) {
674 foreach ($par_arr as $par => $val) {
675 $this->setParameter($par, $val);
676 }
677 }
678 }
static extractParameterString(string $a_parstr)

References ilUtil\extractParameterString().

+ Here is the call graph for this function:

◆ setPurpose()

ilMediaItem::setPurpose ( string  $a_purpose)

Definition at line 509 of file class.ilMediaItem.php.

509 : void
510 {
511 $this->purpose = $a_purpose;
512 }

◆ setTextRepresentation()

ilMediaItem::setTextRepresentation ( string  $a_val)

Definition at line 176 of file class.ilMediaItem.php.

176 : void
177 {
178 $this->text_representation = $a_val;
179 }

◆ setThumbTried()

ilMediaItem::setThumbTried ( string  $a_tried)

Definition at line 549 of file class.ilMediaItem.php.

549 : void
550 {
551 $this->tried_thumb = $a_tried;
552 }

◆ setUploadHash()

ilMediaItem::setUploadHash ( string  $a_val)

Definition at line 186 of file class.ilMediaItem.php.

186 : void
187 {
188 $this->upload_hash = $a_val;
189 }

◆ setWidth()

ilMediaItem::setWidth ( string  $a_width)

Definition at line 594 of file class.ilMediaItem.php.

594 : void
595 {
596 $this->width = $a_width;
597 }

◆ update()

ilMediaItem::update ( )

Definition at line 244 of file class.ilMediaItem.php.

244 : void
245 {
247
248 $query = "UPDATE media_item SET " .
249 " mob_id = " . $ilDB->quote($this->getMobId(), "integer") . "," .
250 " purpose = " . $ilDB->quote($this->getPurpose(), "text") . "," .
251 " location = " . $ilDB->quote($this->getLocation(), "text") . "," .
252 " location_type = " . $ilDB->quote($this->getLocationType(), "text") . "," .
253 " format = " . $ilDB->quote($this->getFormat(), "text") . "," .
254 " width = " . $ilDB->quote($this->getWidth(), "text") . "," .
255 " height = " . $ilDB->quote($this->getHeight(), "text") . "," .
256 " halign = " . $ilDB->quote($this->getHAlign(), "text") . "," .
257 " caption = " . $ilDB->quote($this->getCaption(), "text") . "," .
258 " nr = " . $ilDB->quote($this->getNr(), "integer") . "," .
259 " text_representation = " . $ilDB->quote($this->getTextRepresentation(), "text") . "," .
260 " upload_hash = " . $ilDB->quote($this->getUploadHash(), "text") . "," .
261 " duration = " . $ilDB->quote($this->getDuration(), "integer") .
262 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
263 $ilDB->manipulate($query);
264
265 // delete mob parameters
266 $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
267 $ilDB->quote($this->getId(), "integer");
268 $ilDB->manipulate($query);
269
270 // create mob parameters
271 $params = $this->getParameters();
272 foreach ($params as $name => $value) {
273 $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
274 "(" . $ilDB->quote($this->getId(), "integer") . "," .
275 $ilDB->quote($name, "text") . "," .
276 $ilDB->quote($value, "text") . ")";
277 $ilDB->manipulate($query);
278 }
279 }

References $db, $ilDB, $name, $params, $query, getCaption(), getDuration(), getFormat(), getHAlign(), getHeight(), getId(), getLocation(), getLocationType(), getMobId(), getNr(), getParameters(), getPurpose(), getTextRepresentation(), getUploadHash(), and getWidth().

+ Here is the call graph for this function:

◆ writeParameter()

ilMediaItem::writeParameter ( string  $a_name,
string  $a_value 
)

Definition at line 281 of file class.ilMediaItem.php.

284 : void {
286
287 $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
288 "(" . $ilDB->quote($this->getId(), "integer") . "," .
289 $ilDB->quote($a_name, "text") . "," .
290 $ilDB->quote($a_value, "text") . ")";
291 $ilDB->manipulate($query);
292 }

◆ writeThumbTried()

ilMediaItem::writeThumbTried ( string  $a_tried)

write thumbnail creation try data ("y"/"n")

Definition at line 353 of file class.ilMediaItem.php.

353 : void
354 {
356
357 $q = "UPDATE media_item SET tried_thumb = " .
358 $ilDB->quote($a_tried, "text") .
359 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
360
361 $ilDB->manipulate($q);
362 }

References $ilDB, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

Field Documentation

◆ $caption

string ilMediaItem::$caption = ""

Definition at line 38 of file class.ilMediaItem.php.

◆ $color1

int ilMediaItem::$color1

Definition at line 49 of file class.ilMediaItem.php.

◆ $color2

int ilMediaItem::$color2

Definition at line 50 of file class.ilMediaItem.php.

◆ $db

ilDBInterface ilMediaItem::$db
protected

Definition at line 28 of file class.ilMediaItem.php.

Referenced by create(), and update().

◆ $duration

int ilMediaItem::$duration = 0
protected

Definition at line 51 of file class.ilMediaItem.php.

Referenced by getDuration().

◆ $format

string ilMediaItem::$format = ""

Definition at line 35 of file class.ilMediaItem.php.

◆ $halign

string ilMediaItem::$halign = ""

Definition at line 39 of file class.ilMediaItem.php.

◆ $height

string ilMediaItem::$height = ""

Definition at line 37 of file class.ilMediaItem.php.

◆ $id

int ilMediaItem::$id = 0

Definition at line 31 of file class.ilMediaItem.php.

Referenced by getId().

◆ $lng

ilLanguage ilMediaItem::$lng
protected

Definition at line 29 of file class.ilMediaItem.php.

◆ $location

string ilMediaItem::$location = ""

Definition at line 33 of file class.ilMediaItem.php.

◆ $location_type

string ilMediaItem::$location_type = ""

Definition at line 34 of file class.ilMediaItem.php.

◆ $map_cnt

int ilMediaItem::$map_cnt = 0

Definition at line 44 of file class.ilMediaItem.php.

◆ $map_image

ilMediaItem::$map_image = null

Definition at line 48 of file class.ilMediaItem.php.

◆ $mapareas

array ilMediaItem::$mapareas = []

Definition at line 43 of file class.ilMediaItem.php.

◆ $mob_id

int ilMediaItem::$mob_id = 0

Definition at line 41 of file class.ilMediaItem.php.

Referenced by getMobId().

◆ $nr

int ilMediaItem::$nr = 0

Definition at line 42 of file class.ilMediaItem.php.

Referenced by getNr().

◆ $parameters

array ilMediaItem::$parameters = []

Definition at line 40 of file class.ilMediaItem.php.

◆ $purpose

string ilMediaItem::$purpose = ""

Definition at line 32 of file class.ilMediaItem.php.

◆ $text_representation

string ilMediaItem::$text_representation = ""
protected

Definition at line 27 of file class.ilMediaItem.php.

Referenced by getTextRepresentation().

◆ $tried_thumb

string ilMediaItem::$tried_thumb = ""
protected

Definition at line 26 of file class.ilMediaItem.php.

◆ $upload_hash

string ilMediaItem::$upload_hash = ''
protected

Definition at line 52 of file class.ilMediaItem.php.

Referenced by getUploadHash().

◆ $width

string ilMediaItem::$width = ""

Definition at line 36 of file class.ilMediaItem.php.


The documentation for this class was generated from the following file: