ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 
ILIAS Filesystem Util Convert LegacyImages $image_converter
 
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 55 of file class.ilMediaItem.php.

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

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

References $DIC, $ilDB, ILIAS\LTI\ToolProvider\$key, and ilMapArea\_getIntLinks().

Referenced by ilPageObjectGUI\displayMedia(), ilCOPageHTMLExport\exportHTMLMOB(), ILIAS\COPage\Link\LinkManager\getDefaultMediaCollector(), ilLMPresentationGUI\ilMedia(), and ilGlossaryPresentationGUI\media().

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
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ 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 433 of file class.ilMediaItem.php.

References $DIC, $ilDB, ilMapArea\_getMaxNr(), ilObjMediaObject\addMediaItem(), and ilObject\getId().

Referenced by ilObjMediaObject\read().

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

References $DIC, and $ilDB.

Referenced by ilObjectFeedWriter\__construct().

413  : ?array {
414  global $DIC;
415 
416  $ilDB = $DIC->database();
417 
418  // read media_object record
419  $query = "SELECT * FROM media_item WHERE mob_id = " .
420  $ilDB->quote($a_mobId, "integer") . " " .
421  "AND purpose=" . $ilDB->quote($a_purpose, "text") . " ORDER BY nr";
422  $item_set = $ilDB->query($query);
423 
424  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
425  return $item_rec;
426  }
427  return null;
428  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookupLocationForMobId()

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

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

References $DIC, and $ilDB.

Referenced by ilObjMediaObject\_lookupItemPath().

369  : string {
370  global $DIC;
371 
372  $ilDB = $DIC->database();
373 
374  // read media_object record
375  $query = "SELECT * FROM media_item WHERE mob_id = " .
376  $ilDB->quote($a_mob_id, "integer") . " " .
377  "AND purpose = " . $ilDB->quote($a_purpose, "text");
378  $set = $ilDB->query($query);
379  if ($rec = $ilDB->fetchAssoc($set)) {
380  return $rec["location"];
381  }
382 
383  return "";
384  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilMediaItem::_lookupMobId ( int  $a_med_id)
static

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

References $DIC, and $ilDB.

Referenced by ilMapArea\_getMobsForTarget().

388  : int {
389  global $DIC;
390 
391  $ilDB = $DIC->database();
392 
393  // read media_object record
394  $query = "SELECT * FROM media_item WHERE id = " .
395  $ilDB->quote($a_med_id, "integer");
396  $set = $ilDB->query($query);
397  if ($rec = $ilDB->fetchAssoc($set)) {
398  return (int) $rec["mob_id"];
399  }
400 
401  return 0;
402  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _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.

References $DIC, $ilDB, and ilMapArea\_resolveIntLinks().

Referenced by ilQuestionPageParser\processPagesToParse(), and ILIAS\COPage\Link\LinkManager\resolveIntLinks().

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
global $DIC
Definition: feed.php:28
+ 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.

References buildMapWorkImage(), getHeight(), getMapWorkCopyName(), getMapWorkImage(), getWidth(), and saveMapWorkImage().

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  }
buildMapWorkImage()
build image map work image
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
saveMapWorkImage()
save image map work image as file
Class ilMapArea.
+ Here is the call graph for this function:

◆ addMapArea()

ilMediaItem::addMapArea ( ilMapArea  $a_map_area)

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

References $map_cnt.

Referenced by read().

561  : void
562  {
563  $this->mapareas[$this->map_cnt] = $a_map_area;
564  $this->map_cnt++;
565  }
+ Here is the caller graph for this function:

◆ buildMapWorkImage()

ilMediaItem::buildMapWorkImage ( )

build image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), ilMediaAliasItem\makeMapWorkCopy(), and makeMapWorkCopy().

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
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkParameter()

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

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

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

Referenced by ilMediaAliasItem\setParameters().

688  : bool {
689  // do not allow event attributes
690  if (substr(strtolower(trim($a_par)), 0, 2) == "on") {
691  return false;
692  }
693  // no javascript in value
694  if (is_int(strpos(strtolower($a_val), "javascript"))) {
695  return false;
696  }
697  // do not allow to change the src attribute
698  if (strtolower(trim($a_par)) == "src") {
699  return false;
700  }
701 
702  return true;
703  }
+ 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 865 of file class.ilMediaItem.php.

References $lng, createWorkDirectory(), getDirectory(), getHeight(), getLocation(), getLocationType(), getMapWorkCopyName(), getMapWorkCopyType(), getWidth(), and ilLanguage\txt().

Referenced by ilMediaAliasItem\makeMapWorkCopy(), and makeMapWorkCopy().

865  : void
866  {
867  $lng = $this->lng;
868  $this->createWorkDirectory();
869 
870  if ($this->getLocationType() !== "Reference") {
871  $this->image_converter->convertToFormat(
872  $this->getDirectory() . "/" . $this->getLocation(),
873  $this->getMapWorkCopyName(),
874  $this->getMapWorkCopyType(),
875  $this->getWidth() === '' ? null : $this->getWidth(),
876  $this->getHeight() === '' ? null : $this->getHeight()
877  );
878  } else {
879  // first copy the external file, if necessary
880  if (!is_file($this->getMapWorkCopyName(true)) || (filesize($this->getMapWorkCopyName(true)) == 0)) {
881  $handle = fopen($this->getLocation(), "r");
882  $lcopy = fopen($this->getMapWorkCopyName(true), "w");
883  if ($handle && $lcopy) {
884  while (!feof($handle)) {
885  $content = fread($handle, 4096);
886  fwrite($lcopy, $content);
887  }
888  }
889  fclose($lcopy);
890  fclose($handle);
891  }
892 
893  // now, create working copy
894  $this->image_converter->convertToFormat(
895  $this->getMapWorkCopyName(true),
896  $this->getMapWorkCopyName(),
897  $this->getMapWorkCopyType(),
898  $this->getWidth() === '' ? null : $this->getWidth(),
899  $this->getHeight() === '' ? null : $this->getHeight()
900  );
901  }
902  if (!is_file($this->getMapWorkCopyName())) {
903  throw new ilMapEditingException($lng->txt("cont_map_file_not_generated"));
904  }
905  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMapWorkCopyType()
get image type of image map work copy
ilLanguage $lng
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...
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
getDirectory()
get media file directory
createWorkDirectory()
create work directory for image map editing
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilMediaItem::create ( )

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

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

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

◆ createWorkDirectory()

ilMediaItem::createWorkDirectory ( )

create work directory for image map editing

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

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

Referenced by copyOriginal().

738  : void
739  {
740  if (!is_dir(ilFileUtils::getDataDir() . "/map_workfiles")) {
742  }
743  $work_dir = $this->getWorkDirectory();
744  if (!is_dir($work_dir)) {
745  ilFileUtils::createDirectory($work_dir);
746  }
747  }
getWorkDirectory()
get work directory for image map editing
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllItemsOfMob()

static ilMediaItem::deleteAllItemsOfMob ( int  $a_mob_id)
static

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

References $DIC, and $ilDB.

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

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

◆ deleteMapArea()

ilMediaItem::deleteMapArea ( int  $nr)

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

References $map_cnt.

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

◆ determineDuration()

ilMediaItem::determineDuration ( )

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

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

Referenced by ilObjMediaCastGUI\getDuration().

1184  : void
1185  {
1186  $ana = new ilMediaAnalyzer();
1187 
1190  $meta = ilExternalMediaAnalyzer::getVimeoMetadata($par["id"]);
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  }
setDuration(int $a_val)
static isVimeo(string $a_location)
Identify Vimeo links.
static _getDirectory(int $a_mob_id)
Get absolute directory.
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...
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 ...
+ 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.

References ilExternalMediaAnalyzer\extractUrlParameters(), getLocation(), getParameters(), and setParameter().

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)
+ Here is the call graph for this function:

◆ getCaption()

ilMediaItem::getCaption ( )

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

References $caption.

Referenced by create(), and update().

636  : string
637  {
638  return $this->caption;
639  }
+ Here is the caller graph for this function:

◆ getDirectory()

ilMediaItem::getDirectory ( )

get media file directory

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

References ilObjMediaObject\_getDirectory(), and getMobId().

Referenced by copyOriginal(), and getThumbnailTarget().

790  : string
791  {
792  return ilObjMediaObject::_getDirectory($this->getMobId());
793  }
static _getDirectory(int $a_mob_id)
Get absolute directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDuration()

ilMediaItem::getDuration ( )

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

References $duration.

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

173  : int
174  {
175  return $this->duration;
176  }
+ Here is the caller graph for this function:

◆ getFormat()

ilMediaItem::getFormat ( )

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

References $format.

Referenced by create(), getOriginalSize(), getThumbnailTarget(), and update().

546  : string
547  {
548  return $this->format;
549  }
+ 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 119 of file class.ilMediaItem.php.

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

◆ getHAlign()

ilMediaItem::getHAlign ( )

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

References $halign.

Referenced by create(), and update().

649  : string
650  {
651  return $this->halign;
652  }
+ Here is the caller graph for this function:

◆ getHeight()

ilMediaItem::getHeight ( )

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

References $height.

Referenced by addAreaToMapWorkCopy(), copyOriginal(), create(), ilMediaAliasItem\makeMapWorkCopy(), makeMapWorkCopy(), and update().

601  : string
602  {
603  return $this->height;
604  }
+ Here is the caller graph for this function:

◆ getId()

ilMediaItem::getId ( )

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

References $id.

Referenced by create(), getWorkDirectory(), read(), update(), writeParameter(), and writeThumbTried().

81  : int
82  {
83  return $this->id;
84  }
+ Here is the caller graph for this function:

◆ getLocation()

ilMediaItem::getLocation ( )

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

References $location.

Referenced by copyOriginal(), create(), determineDuration(), extractUrlParameters(), getMapWorkCopyName(), getOriginalSize(), getSuffix(), getThumbnailTarget(), update(), and ilObjMediaCastGUI\updateMediaItem().

526  : string
527  {
528  return $this->location;
529  }
+ Here is the caller graph for this function:

◆ getLocationType()

ilMediaItem::getLocationType ( )

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

References $location_type.

Referenced by copyOriginal(), create(), determineDuration(), getOriginalSize(), getThumbnailTarget(), update(), and ilObjMediaCastGUI\updateMediaItem().

536  : string
537  {
538  return $this->location_type;
539  }
+ Here is the caller graph for this function:

◆ getMapArea()

ilMediaItem::getMapArea ( int  $nr)

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

581  : ?ilMapArea
582  {
583  return $this->mapareas[$nr - 1] ?? null;
584  }
Class ilMapArea.

◆ getMapAreas()

ilMediaItem::getMapAreas ( )

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

References $mapareas.

586  : array
587  {
588  return $this->mapareas;
589  }

◆ 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.

References IL_INT_LINK.

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

◆ 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 771 of file class.ilMediaItem.php.

References getLocation(), getMapWorkCopyType(), and getWorkDirectory().

Referenced by addAreaToMapWorkCopy(), buildMapWorkImage(), copyOriginal(), ilMediaAliasItem\makeMapWorkCopy(), makeMapWorkCopy(), outputMapWorkCopy(), and saveMapWorkImage().

773  : string {
774  $file_arr = explode("/", $this->getLocation());
775  $o_file = $file_arr[count($file_arr) - 1];
776  $file_arr = explode(".", $o_file);
777  unset($file_arr[count($file_arr) - 1]);
778  $file = implode(".", $file_arr);
779 
780  if (!$a_reference_copy) {
781  return $this->getWorkDirectory() . "/" . $file . "." . $this->getMapWorkCopyType();
782  } else {
783  return $this->getWorkDirectory() . "/l_copy_" . $o_file;
784  }
785  }
getMapWorkCopyType()
get image type of image map work copy
getWorkDirectory()
get work directory for image map editing
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapWorkCopyType()

ilMediaItem::getMapWorkCopyType ( )

get image type of image map work copy

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

References getSuffix().

Referenced by buildMapWorkImage(), copyOriginal(), getMapWorkCopyName(), outputMapWorkCopy(), and saveMapWorkImage().

762  : string
763  {
764  return self::getGDSupportedImageType($this->getSuffix());
765  }
getSuffix()
get location suffix
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapWorkImage()

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

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

References $map_image.

Referenced by addAreaToMapWorkCopy(), ilMediaAliasItem\makeMapWorkCopy(), and makeMapWorkCopy().

1067  {
1068  return $this->map_image;
1069  }
+ Here is the caller graph for this function:

◆ 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.

References $DIC, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

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

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)
global $DIC
Definition: feed.php:28
ilDBInterface $db
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMobId()

ilMediaItem::getMobId ( )

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

References $mob_id.

Referenced by create(), determineDuration(), getDirectory(), getOriginalSize(), getThumbnailDirectory(), getThumbnailTarget(), read(), and update().

94  : int
95  {
96  return $this->mob_id;
97  }
+ Here is the caller graph for this function:

◆ getNr()

ilMediaItem::getNr ( )

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

References $nr.

Referenced by create(), read(), and update().

107  : int
108  {
109  return $this->nr;
110  }
+ Here is the caller graph for this function:

◆ getOriginalSize()

ilMediaItem::getOriginalSize ( )

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

References ilObjMediaObject\_getDirectory(), ilUtil\deducibleSize(), getFormat(), ilMediaImageUtil\getImageSize(), getLocation(), getLocationType(), and getMobId().

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

◆ getParameter()

ilMediaItem::getParameter ( string  $a_name)

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

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

◆ getParameters()

ilMediaItem::getParameters ( )

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

References $parameters.

Referenced by create(), extractUrlParameters(), and update().

705  : array
706  {
707  return $this->parameters;
708  }
+ Here is the caller graph for this function:

◆ getParameterString()

ilMediaItem::getParameterString ( )

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

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

◆ getPurpose()

ilMediaItem::getPurpose ( )

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

References $purpose.

Referenced by create(), getThumbnailTarget(), update(), and ilObjMediaCastGUI\updateMediaItem().

516  : string
517  {
518  return $this->purpose;
519  }
+ Here is the caller graph for this function:

◆ getSuffix()

ilMediaItem::getSuffix ( )

get location suffix

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

References getLocation().

Referenced by getMapWorkCopyType().

752  : string
753  {
754  $loc_arr = explode(".", $this->getLocation());
755 
756  return $loc_arr[count($loc_arr) - 1];
757  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRepresentation()

ilMediaItem::getTextRepresentation ( )

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

References $text_representation.

Referenced by create(), and update().

183  : string
184  {
186  }
string $text_representation
+ Here is the caller graph for this function:

◆ getThumbnailDirectory()

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

get media file directory

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

References ilObjMediaObject\_getThumbnailDirectory(), and getMobId().

Referenced by getThumbnailTarget().

800  : string {
801  return ilObjMediaObject::_getThumbnailDirectory($this->getMobId(), $a_mode);
802  }
static _getThumbnailDirectory(int $a_mob_id, string $a_mode="filesystem")
get directory for files of media object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThumbnailTarget()

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

get thumbnail target

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

References $format, ilObjMediaObject\_createThumbnailDirectory(), ilObjMediaObject\_getURL(), getDirectory(), getFormat(), getLocation(), getLocationType(), getMobId(), getPurpose(), getThumbnailDirectory(), getThumbTried(), and writeThumbTried().

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

◆ getThumbTried()

ilMediaItem::getThumbTried ( )

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

References $tried_thumb.

Referenced by getThumbnailTarget().

556  : string
557  {
558  return $this->tried_thumb;
559  }
+ Here is the caller graph for this function:

◆ getUploadHash()

ilMediaItem::getUploadHash ( )

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

References $upload_hash.

Referenced by create(), and update().

193  : string
194  {
195  return $this->upload_hash;
196  }
+ Here is the caller graph for this function:

◆ getWidth()

ilMediaItem::getWidth ( )

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

References $width.

Referenced by addAreaToMapWorkCopy(), copyOriginal(), create(), ilMediaAliasItem\makeMapWorkCopy(), makeMapWorkCopy(), and update().

591  : string
592  {
593  return $this->width;
594  }
+ Here is the caller graph for this function:

◆ getWorkDirectory()

ilMediaItem::getWorkDirectory ( )

get work directory for image map editing

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

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

Referenced by createWorkDirectory(), and getMapWorkCopyName().

730  : string
731  {
732  return ilFileUtils::getDataDir() . "/map_workfiles/item_" . $this->getId();
733  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller 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.

References $lng, buildMapWorkImage(), copyOriginal(), getHeight(), getMapWorkCopyName(), getMapWorkImage(), getWidth(), and saveMapWorkImage().

915  : void {
916  $lng = $this->lng;
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(),
941  $this->color1,
942  $this->color2,
943  true,
944  $x_ratio,
945  $y_ratio
946  );
947  }
948  }
949 
950  $this->saveMapWorkImage();
951  }
ilLanguage $lng
copyOriginal()
Copy the original file for map editing to the working directory.
buildMapWorkImage()
build image map work image
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
saveMapWorkImage()
save image map work image as file
+ Here is the call graph for this function:

◆ outputMapWorkCopy()

ilMediaItem::outputMapWorkCopy ( )

output raw map work copy file

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

References exit, getMapWorkCopyName(), getMapWorkCopyType(), and ILIAS\UI\examples\Symbol\Glyph\Header\header().

Referenced by ilImageMapEditorGUI\showImageMap().

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:29
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilMediaItem::read ( )

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

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

References $db, $ilDB, ilMapArea\_getMaxNr(), addMapArea(), getId(), getMobId(), getNr(), setCaption(), setDuration(), setFormat(), setHAlign(), setHeight(), setId(), setLocation(), setLocationType(), setMobId(), setNr(), setParameter(), setPurpose(), setTextRepresentation(), setThumbTried(), setUploadHash(), and setWidth().

Referenced by __construct().

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

◆ resetParameters()

ilMediaItem::resetParameters ( )

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

Referenced by setParameters().

663  : void
664  {
665  $this->parameters = [];
666  }
+ Here is the caller graph for this function:

◆ saveMapWorkImage()

ilMediaItem::saveMapWorkImage ( )

save image map work image as file

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), ilMediaAliasItem\makeMapWorkCopy(), and makeMapWorkCopy().

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  }
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCaption()

ilMediaItem::setCaption ( string  $a_caption)

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

Referenced by read().

631  : void
632  {
633  $this->caption = $a_caption;
634  }
+ Here is the caller graph for this function:

◆ setDuration()

ilMediaItem::setDuration ( int  $a_val)

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

Referenced by determineDuration(), and read().

168  : void
169  {
170  $this->duration = $a_val;
171  }
+ Here is the caller graph for this function:

◆ setFormat()

ilMediaItem::setFormat ( string  $a_format)

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

Referenced by read(), and ilObjMediaCastGUI\updateMediaItem().

541  : void
542  {
543  $this->format = $a_format;
544  }
+ Here is the caller graph for this function:

◆ setHAlign()

ilMediaItem::setHAlign ( string  $a_halign)

set horizontal align

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

Referenced by read(), and ilObjMediaCastGUI\updateMediaItem().

644  : void
645  {
646  $this->halign = $a_halign;
647  }
+ Here is the caller graph for this function:

◆ setHeight()

ilMediaItem::setHeight ( string  $a_height)

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

Referenced by read(), and ilObjMediaCastGUI\updateMediaItem().

606  : void
607  {
608  $this->height = $a_height;
609  }
+ Here is the caller graph for this function:

◆ setId()

ilMediaItem::setId ( int  $a_id)

set media item id

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

Referenced by __construct(), create(), and read().

76  : void
77  {
78  $this->id = $a_id;
79  }
+ Here is the caller graph for this function:

◆ setLocation()

ilMediaItem::setLocation ( string  $a_location)

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

Referenced by read(), and ilObjMediaCastGUI\updateMediaItem().

521  : void
522  {
523  $this->location = $a_location;
524  }
+ Here is the caller graph for this function:

◆ setLocationType()

ilMediaItem::setLocationType ( string  $a_type)

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

Referenced by read(), and ilObjMediaCastGUI\updateMediaItem().

531  : void
532  {
533  $this->location_type = $a_type;
534  }
+ Here is the caller graph for this function:

◆ setMobId()

ilMediaItem::setMobId ( int  $a_mob_id)

set id of parent media object

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

Referenced by read().

89  : void
90  {
91  $this->mob_id = $a_mob_id;
92  }
+ Here is the caller graph for this function:

◆ setNr()

ilMediaItem::setNr ( int  $a_nr)

set number of media item within media object

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

Referenced by read().

102  : void
103  {
104  $this->nr = $a_nr;
105  }
+ Here is the caller graph for this function:

◆ setParameter()

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

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

Referenced by extractUrlParameters(), read(), and setParameters().

657  : void {
658  if (self::checkParameter($a_name, $a_value)) {
659  $this->parameters[$a_name] = $a_value;
660  }
661  }
+ Here is the caller graph for this function:

◆ setParameters()

ilMediaItem::setParameters ( string  $a_par)

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

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

References ilUtil\extractParameterString(), resetParameters(), and setParameter().

671  : void
672  {
673  $this->resetParameters();
674  $par_arr = ilUtil::extractParameterString($a_par);
675  if (is_array($par_arr)) {
676  foreach ($par_arr as $par => $val) {
677  $this->setParameter($par, $val);
678  }
679  }
680  }
setParameter(string $a_name, string $a_value)
static extractParameterString(string $a_parstr)
+ Here is the call graph for this function:

◆ setPurpose()

ilMediaItem::setPurpose ( string  $a_purpose)

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

Referenced by read().

511  : void
512  {
513  $this->purpose = $a_purpose;
514  }
+ Here is the caller graph for this function:

◆ setTextRepresentation()

ilMediaItem::setTextRepresentation ( string  $a_val)

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

Referenced by read().

178  : void
179  {
180  $this->text_representation = $a_val;
181  }
+ Here is the caller graph for this function:

◆ setThumbTried()

ilMediaItem::setThumbTried ( string  $a_tried)

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

Referenced by read().

551  : void
552  {
553  $this->tried_thumb = $a_tried;
554  }
+ Here is the caller graph for this function:

◆ setUploadHash()

ilMediaItem::setUploadHash ( string  $a_val)

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

Referenced by read().

188  : void
189  {
190  $this->upload_hash = $a_val;
191  }
+ Here is the caller graph for this function:

◆ setWidth()

ilMediaItem::setWidth ( string  $a_width)

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

Referenced by read().

596  : void
597  {
598  $this->width = $a_width;
599  }
+ Here is the caller graph for this function:

◆ update()

ilMediaItem::update ( )

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

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

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

◆ writeParameter()

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

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

References $db, $ilDB, and getId().

286  : void {
287  $ilDB = $this->db;
288 
289  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
290  "(" . $ilDB->quote($this->getId(), "integer") . "," .
291  $ilDB->quote($a_name, "text") . "," .
292  $ilDB->quote($a_value, "text") . ")";
293  $ilDB->manipulate($query);
294  }
ilDBInterface $db
+ Here is the call graph for this function:

◆ writeThumbTried()

ilMediaItem::writeThumbTried ( string  $a_tried)

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

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

References $db, $ilDB, $q, and getId().

Referenced by getThumbnailTarget().

355  : void
356  {
357  $ilDB = $this->db;
358 
359  $q = "UPDATE media_item SET tried_thumb = " .
360  $ilDB->quote($a_tried, "text") .
361  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
362 
363  $ilDB->manipulate($q);
364  }
ilDBInterface $db
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $caption

string ilMediaItem::$caption = ""

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

Referenced by getCaption().

◆ $color1

int ilMediaItem::$color1

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

◆ $color2

int ilMediaItem::$color2

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

◆ $db

ilDBInterface ilMediaItem::$db
protected

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

Referenced by create(), read(), update(), writeParameter(), and writeThumbTried().

◆ $duration

int ilMediaItem::$duration = 0
protected

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

Referenced by getDuration().

◆ $format

string ilMediaItem::$format = ""

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

Referenced by getFormat(), and getThumbnailTarget().

◆ $halign

string ilMediaItem::$halign = ""

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

Referenced by getHAlign().

◆ $height

string ilMediaItem::$height = ""

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

Referenced by getHeight().

◆ $id

int ilMediaItem::$id = 0

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

Referenced by getId().

◆ $image_converter

ILIAS Filesystem Util Convert LegacyImages ilMediaItem::$image_converter
protected

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

◆ $lng

ilLanguage ilMediaItem::$lng
protected

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

Referenced by copyOriginal(), and makeMapWorkCopy().

◆ $location

string ilMediaItem::$location = ""

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

Referenced by getLocation().

◆ $location_type

string ilMediaItem::$location_type = ""

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

Referenced by getLocationType().

◆ $map_cnt

int ilMediaItem::$map_cnt = 0

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

Referenced by addMapArea(), and deleteMapArea().

◆ $map_image

ilMediaItem::$map_image = null

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

Referenced by getMapWorkImage().

◆ $mapareas

array ilMediaItem::$mapareas = []

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

Referenced by getMapAreas().

◆ $mob_id

int ilMediaItem::$mob_id = 0

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

Referenced by getMobId().

◆ $nr

int ilMediaItem::$nr = 0

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

Referenced by getNr().

◆ $parameters

array ilMediaItem::$parameters = []

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

Referenced by getParameters().

◆ $purpose

string ilMediaItem::$purpose = ""

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

Referenced by getPurpose().

◆ $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.

Referenced by getThumbTried().

◆ $upload_hash

string ilMediaItem::$upload_hash = ''
protected

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

Referenced by getUploadHash().

◆ $width

string ilMediaItem::$width = ""

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

Referenced by getWidth().


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