ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMediaItem Class Reference

Class ilMediaItem Media Item, component of a media object (file or reference) More...

+ Collaboration diagram for ilMediaItem:

Public Member Functions

 __construct ($a_id=0)
 
 setId ($a_id)
 set media item id More...
 
 getId ()
 get media item id More...
 
 setMobId ($a_mob_id)
 set id of parent media object More...
 
 getMobId ()
 get id of parent media object More...
 
 setNr ($a_nr)
 set number of media item within media object More...
 
 getNr ()
 
 setDuration ($a_val)
 Set duration. More...
 
 getDuration ()
 Get duration. More...
 
 setTextRepresentation ($a_val)
 Set text representation. More...
 
 getTextRepresentation ()
 Get text representation. More...
 
 setUploadHash ($a_val)
 Set upload hash. More...
 
 getUploadHash ()
 Get upload hash. More...
 
 create ()
 create persistent media item More...
 
 update ()
 update media item data (without map areas!) More...
 
 writeParameter ($a_name, $a_value)
 Write parameter. More...
 
 read ()
 read media item data (item id or (mob_id and nr) must be set) More...
 
 writeThumbTried ($a_tried)
 write thumbnail creation try data ("y"/"n") More...
 
 setPurpose ($a_purpose)
 
 getPurpose ()
 
 setLocation ($a_location)
 
 getLocation ()
 
 setLocationType ($a_type)
 
 getLocationType ()
 
 setFormat ($a_format)
 
 getFormat ()
 
 setThumbTried ($a_tried)
 
 getThumbTried ()
 
 addMapArea (&$a_map_area)
 
 deleteMapArea ($nr)
 delete map area More...
 
getMapArea ($nr)
 get map area More...
 
 getMapAreas ()
 get map areas More...
 
 getWidth ()
 get width More...
 
 setWidth ($a_width)
 set width More...
 
 getHeight ()
 get height More...
 
 setHeight ($a_height)
 set height More...
 
 getOriginalSize ()
 get original size More...
 
 setCaption ($a_caption)
 set caption More...
 
 getCaption ()
 get caption More...
 
 setHAlign ($a_halign)
 set horizontal align More...
 
 getHAlign ()
 get horizontal align More...
 
 setParameter ($a_name, $a_value)
 set parameter More...
 
 resetParameters ()
 reset parameters More...
 
 setParameters ($a_par)
 set alle parameters via parameter string (format: par1="value1", par2="value2", ...) More...
 
 getParameters ()
 get all parameters (in array) More...
 
 getParameterString ()
 get all parameters (as string) More...
 
 getParameter ($a_name)
 get a single parameter More...
 
 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 ($a_reference_copy=false)
 Get name of image map work copy file. More...
 
 getDirectory ()
 get media file directory More...
 
 getThumbnailDirectory ($a_mode="filesystem")
 get media file directory More...
 
 getThumbnailTarget ($a_size="")
 get thumbnail target More...
 
 copyOriginal ()
 Copy the orginal file. More...
 
 makeMapWorkCopy ($a_area_nr=0, $a_exclude=false)
 make map work copy of image More...
 
 addAreaToMapWorkCopy ($a_shape, $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 More...
 
getMapWorkImage ()
 get image map work image More...
 
 getMapAreasXML ($a_insert_inst=false, $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 ($a_mob_id, $a_purpose)
 Lookup location for mob id. More...
 
static _lookupMobId ($a_med_id)
 Lookup Mob ID. More...
 
static _getMediaItemsOfMObId ($a_mobId, $a_purpose)
 
static _getMediaItemsOfMOb (&$a_mob)
 read media items into media objects (static) More...
 
static deleteAllItemsOfMob ($a_mob_id)
 Delete all items of a mob. More...
 
static checkParameter ($a_par, $a_val)
 Check parameter (filter javascript related and other unsafe parameters/values) More...
 
static _resolveMapAreaLinks ($a_mob_id)
 resolve internal links of all media items of a media object More...
 
static _getMapAreasIntLinks ($a_mob_id)
 get all internal links of map areas of a mob More...
 
static getMediaItemsForUploadHash ($a_hash)
 Get media items for upload hash. More...
 

Data Fields

 $id
 
 $purpose
 
 $location
 
 $location_type
 
 $format
 
 $width
 
 $height
 
 $caption
 
 $halign
 
 $parameters
 
 $mob_id
 
 $nr
 
 $mapareas
 
 $map_cnt
 
 $map_image
 
 $color1
 
 $color2
 

Protected Attributes

 $db
 
 $lng
 
 $duration = 0
 
 $upload_hash
 

Detailed Description

Class ilMediaItem Media Item, component of a media object (file or reference)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilMediaItem::__construct (   $a_id = 0)

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

References $DIC, read(), and setId().

51  {
52  global $DIC;
53 
54  $this->db = $DIC->database();
55  $this->lng = $DIC->language();
56  $this->parameters = array();
57  $this->mapareas = array();
58  $this->map_cnt = 0;
59 
60  if ($a_id != 0) {
61  $this->setId($a_id);
62  $this->read();
63  }
64  }
setId($a_id)
set media item id
read()
read media item data (item id or (mob_id and nr) must be set)
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ _getMapAreasIntLinks()

static ilMediaItem::_getMapAreasIntLinks (   $a_mob_id)
static

get all internal links of map areas of a mob

Parameters
int$a_mob_idmedia object id

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

References $DIC, $ilDB, $query, and ilMapArea\_getIntLinks().

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

1177  {
1178  global $DIC;
1179 
1180  $ilDB = $DIC->database();
1181 
1182  // read media_items records
1183  $query = "SELECT * FROM media_item WHERE mob_id = " .
1184  $ilDB->quote($a_mob_id, "integer") . " ORDER BY nr";
1185 
1186  $item_set = $ilDB->query($query);
1187  $links = array();
1188  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
1189  $map_links = ilMapArea::_getIntLinks($item_rec["id"]);
1190  foreach ($map_links as $key => $map_link) {
1191  $links[$key] = $map_link;
1192  }
1193  }
1194  return $links;
1195  }
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMediaItemsOfMOb()

static ilMediaItem::_getMediaItemsOfMOb ( $a_mob)
static

read media items into media objects (static)

Parameters
object$a_mobmedia object

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

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

Referenced by ilObjMediaObject\read().

418  {
419  global $DIC;
420 
421  $ilDB = $DIC->database();
422 
423  // read media_object record
424  $query = "SELECT * FROM media_item WHERE mob_id = " .
425  $ilDB->quote($a_mob->getId(), "integer") . " " .
426  "ORDER BY nr";
427  $item_set = $ilDB->query($query);
428  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
429  $media_item = new ilMediaItem();
430  $media_item->setNr($item_rec["nr"]);
431  $media_item->setId($item_rec["id"]);
432  $media_item->setLocation($item_rec["location"]);
433  $media_item->setLocationType($item_rec["location_type"]);
434  $media_item->setFormat($item_rec["format"]);
435  $media_item->setWidth($item_rec["width"]);
436  $media_item->setHeight($item_rec["height"]);
437  $media_item->setHAlign($item_rec["halign"]);
438  $media_item->setCaption($item_rec["caption"]);
439  $media_item->setPurpose($item_rec["purpose"]);
440  $media_item->setMobId($item_rec["mob_id"]);
441  $media_item->setThumbTried($item_rec["tried_thumb"]);
442  $media_item->setTextRepresentation($item_rec["text_representation"]);
443  $media_item->setUploadHash($item_rec["upload_hash"]);
444  $media_item->setDuration((int) $item_rec["duration"]);
445 
446  // get item parameter
447  $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
448  $ilDB->quote($item_rec["id"], "integer");
449  $par_set = $ilDB->query($query);
450  while ($par_rec = $ilDB->fetchAssoc($par_set)) {
451  $media_item->setParameter($par_rec["name"], $par_rec["value"]);
452  }
453 
454  // get item map areas
455  $max = ilMapArea::_getMaxNr($media_item->getId());
456  for ($i = 1; $i <= $max; $i++) {
457  $area = new ilMapArea($media_item->getId(), $i);
458  $media_item->addMapArea($area);
459  }
460 
461  // add media item to media object
462  $a_mob->addMediaItem($media_item);
463  }
464  }
global $DIC
Definition: goto.php:24
Class ilMediaItem Media Item, component of a media object (file or reference)
$query
Class ilMapArea.
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
global $ilDB
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMediaItemsOfMObId()

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

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

References $DIC, $ilDB, and $query.

Referenced by ilObjectFeedWriter\__construct().

396  {
397  global $DIC;
398 
399  $ilDB = $DIC->database();
400 
401  // read media_object record
402  $query = "SELECT * FROM media_item WHERE mob_id = " .
403  $ilDB->quote($a_mobId, "integer") . " " .
404  "AND purpose=" . $ilDB->quote($a_purpose, "text") . " ORDER BY nr";
405  $item_set = $ilDB->query($query);
406 
407  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
408  return $item_rec;
409  }
410  return false;
411  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupLocationForMobId()

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

Lookup location for mob id.

Parameters
int$a_mob_idmedia object id
string$a_purposepurpose

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

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\_lookupItemPath().

351  {
352  global $DIC;
353 
354  $ilDB = $DIC->database();
355 
356  // read media_object record
357  $query = "SELECT * FROM media_item WHERE mob_id = " .
358  $ilDB->quote($a_mob_id, "integer") . " " .
359  "AND purpose = " . $ilDB->quote($a_purpose, "text");
360  $set = $ilDB->query($query);
361  if ($rec = $ilDB->fetchAssoc($set)) {
362  return $rec["location"];
363  }
364 
365  return "";
366  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilMediaItem::_lookupMobId (   $a_med_id)
static

Lookup Mob ID.

Parameters
int$a_med_idmedia item id

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

References $DIC, $ilDB, and $query.

Referenced by ilMapArea\_getMobsForTarget().

373  {
374  global $DIC;
375 
376  $ilDB = $DIC->database();
377 
378  // read media_object record
379  $query = "SELECT * FROM media_item WHERE id = " .
380  $ilDB->quote($a_med_id, "integer");
381  $set = $ilDB->query($query);
382  if ($rec = $ilDB->fetchAssoc($set)) {
383  return $rec["mob_id"];
384  }
385 
386  return "";
387  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _resolveMapAreaLinks()

static ilMediaItem::_resolveMapAreaLinks (   $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 1155 of file class.ilMediaItem.php.

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

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

1156  {
1157  global $DIC;
1158 
1159  $ilDB = $DIC->database();
1160 
1161  //echo "mediaItems::resolve<br>";
1162  // read media_object record
1163  $query = "SELECT * FROM media_item WHERE mob_id = " .
1164  $ilDB->quote($a_mob_id, "integer") . " " .
1165  "ORDER BY nr";
1166  $item_set = $ilDB->query($query);
1167  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
1168  ilMapArea::_resolveIntLinks($item_rec["id"]);
1169  }
1170  }
static _resolveIntLinks($a_item_id)
resolve internal links of an item id
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAreaToMapWorkCopy()

ilMediaItem::addAreaToMapWorkCopy (   $a_shape,
  $a_coords 
)

draw a new area in work image

Parameters
string$a_shapeshape
string$a_coordscoordinates string

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

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

992  {
993  $this->buildMapWorkImage();
994 
995  // determine ratios
996  $size = @getimagesize($this->getMapWorkCopyName());
997  $x_ratio = 1;
998  if ($size[0] > 0 && $this->getWidth() > 0) {
999  $x_ratio = $this->getWidth() / $size[0];
1000  }
1001  $y_ratio = 1;
1002  if ($size[1] > 0 && $this->getHeight() > 0) {
1003  $y_ratio = $this->getHeight() / $size[1];
1004  }
1005 
1006  // add new area to work image
1007  $area = new ilMapArea();
1008  $area->setShape($a_shape);
1009  $area->setCoords($a_coords);
1010  $area->draw(
1011  $this->getMapWorkImage(),
1012  $this->color1,
1013  $this->color2,
1014  false,
1015  $x_ratio,
1016  $y_ratio
1017  );
1018 
1019  $this->saveMapWorkImage();
1020  }
$size
Definition: RandomTest.php:84
getWidth()
get width
buildMapWorkImage()
build image map work image
& getMapWorkImage()
get image map work image
getMapWorkCopyName($a_reference_copy=false)
Get name of image map work copy file.
saveMapWorkImage()
save image map work image
Class ilMapArea.
getHeight()
get height
+ Here is the call graph for this function:

◆ addMapArea()

ilMediaItem::addMapArea ( $a_map_area)

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

References $map_cnt.

Referenced by read().

549  {
550  $this->mapareas[$this->map_cnt] = $a_map_area;
551  $this->map_cnt++;
552  }
+ Here is the caller graph for this function:

◆ buildMapWorkImage()

ilMediaItem::buildMapWorkImage ( )

build image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

1040  {
1041  $im_type = strtolower($this->getMapWorkCopyType());
1042 
1043  switch ($im_type) {
1044  case "gif":
1045  $this->map_image = ImageCreateFromGIF($this->getMapWorkCopyName());
1046  break;
1047 
1048  case "jpg":
1049  case "jpeg":
1050  $this->map_image = ImageCreateFromJPEG($this->getMapWorkCopyName());
1051  break;
1052 
1053  case "png":
1054  $this->map_image = ImageCreateFromPNG($this->getMapWorkCopyName());
1055  break;
1056  }
1057 
1058  // try to allocate black and white as color. if this is not possible, get the closest colors
1059  if (imagecolorstotal($this->map_image) > 250) {
1060  $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1061  $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1062  } else {
1063  $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1064  $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1065  }
1066  }
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName($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 (   $a_par,
  $a_val 
)
static

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

Parameters
string$a_parparameter
string$a_valvalue
Returns
bool

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

Referenced by ilMediaAliasItem\setParameters().

717  {
718  // do not allow event attributes
719  if (substr(strtolower(trim($a_par)), 0, 2) == "on") {
720  return false;
721  }
722  // no javascript in value
723  if (is_int(strpos(strtolower($a_val), "javascript"))) {
724  return false;
725  }
726  // do not allow to change the src attribute
727  if (in_array(strtolower(trim($a_par)), array("src"))) {
728  return false;
729  }
730 
731  return true;
732  }
+ Here is the caller graph for this function:

◆ copyOriginal()

ilMediaItem::copyOriginal ( )

Copy the orginal file.

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

References $lng, ilUtil\convertImage(), createWorkDirectory(), getDirectory(), getHeight(), getLocation(), getLocationType(), getMapWorkCopyName(), getMapWorkCopyType(), getWidth(), and ilUtil\sendFailure().

Referenced by makeMapWorkCopy().

892  {
893  $lng = $this->lng;
894  $this->createWorkDirectory();
895 
896  $geom = ($this->getWidth() != "" && $this->getHeight() != "")
897  ? $this->getWidth() . "x" . $this->getHeight()
898  : "";
899 
900  if ($this->getLocationType() != "Reference") {
902  $this->getDirectory() . "/" . $this->getLocation(),
903  $this->getMapWorkCopyName(),
904  $this->getMapWorkCopyType(),
905  $geom
906  );
907  } else {
908  // first copy the external file, if necessary
909  if (!is_file($this->getMapWorkCopyName(true)) || (filesize($this->getMapWorkCopyName(true)) == 0)) {
910  $handle = @fopen($this->getLocation(), "r");
911  $lcopy = fopen($this->getMapWorkCopyName(true), "w");
912  if ($handle && $lcopy) {
913  while (!feof($handle)) {
914  $content = fread($handle, 4096);
915  fwrite($lcopy, $content);
916  }
917  }
918  @fclose($lcopy);
919  @fclose($handle);
920  }
921 
922  // now, create working copy
924  $this->getMapWorkCopyName(true),
925  $this->getMapWorkCopyName(),
926  $this->getMapWorkCopyType(),
927  $geom
928  );
929  }
930 
931  if (!is_file($this->getMapWorkCopyName())) {
932  ilUtil::sendFailure($lng->txt("cont_map_file_not_generated"));
933  return false;
934  }
935  return true;
936  }
getMapWorkCopyType()
get image type of image map work copy
getWidth()
get width
getMapWorkCopyName($a_reference_copy=false)
Get name of image map work copy file.
getDirectory()
get media file directory
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
createWorkDirectory()
create work directory for image map editing
getHeight()
get height
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilMediaItem::create ( )

create persistent media item

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

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

173  {
174  $ilDB = $this->db;
175 
176  $item_id = $ilDB->nextId("media_item");
177  $query = "INSERT INTO media_item (id,mob_id, purpose, location, " .
178  "location_type, format, width, " .
179  "height, halign, caption, nr, text_representation, upload_hash, duration) VALUES " .
180  "(" .
181  $ilDB->quote($item_id, "integer") . "," .
182  $ilDB->quote($this->getMobId(), "integer") . "," .
183  $ilDB->quote($this->getPurpose(), "text") . "," .
184  $ilDB->quote($this->getLocation(), "text") . "," .
185  $ilDB->quote($this->getLocationType(), "text") . "," .
186  $ilDB->quote($this->getFormat(), "text") . "," .
187  $ilDB->quote($this->getWidth(), "text") . "," .
188  $ilDB->quote($this->getHeight(), "text") . "," .
189  $ilDB->quote($this->getHAlign(), "text") . "," .
190  $ilDB->quote($this->getCaption(), "text") . "," .
191  $ilDB->quote($this->getNr(), "integer") . "," .
192  $ilDB->quote($this->getTextRepresentation(), "text") . "," .
193  $ilDB->quote($this->getUploadHash(), "text") . "," .
194  $ilDB->quote($this->getDuration(), "integer") .
195  ")";
196  $ilDB->manipulate($query);
197 
198  $this->setId($item_id);
199 
200  // create mob parameters
201  $params = $this->getParameters();
202  foreach ($params as $name => $value) {
203  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
204  "(" . $ilDB->quote($item_id, "integer") . "," .
205  $ilDB->quote($name, "text") . "," .
206  $ilDB->quote($value, "text") . ")";
207  $ilDB->manipulate($query);
208  }
209 
210  // create map areas
211  for ($i = 0; $i < count($this->mapareas); $i++) {
212  if (is_object($this->mapareas[$i])) {
213  $this->mapareas[$i]->setItemId($this->getId());
214  $this->mapareas[$i]->setNr($i + 1);
215  $this->mapareas[$i]->create();
216  }
217  }
218  }
getDuration()
Get duration.
getId()
get media item id
getWidth()
get width
setId($a_id)
set media item id
getMobId()
get id of parent media object
if($format !==null) $name
Definition: metadata.php:230
getUploadHash()
Get upload hash.
$query
global $ilDB
getCaption()
get caption
getParameters()
get all parameters (in array)
getHAlign()
get horizontal align
getTextRepresentation()
Get text representation.
getHeight()
get height
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ createWorkDirectory()

ilMediaItem::createWorkDirectory ( )

create work directory for image map editing

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

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

Referenced by copyOriginal().

770  {
771  if (!@is_dir(ilUtil::getDataDir() . "/map_workfiles")) {
772  ilUtil::createDirectory(ilUtil::getDataDir() . "/map_workfiles");
773  }
774  $work_dir = $this->getWorkDirectory();
775  if (!@is_dir($work_dir)) {
776  ilUtil::createDirectory($work_dir);
777  }
778  }
getWorkDirectory()
get work directory for image map editing
static createDirectory($a_dir, $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 (   $a_mob_id)
static

Delete all items of a mob.

Parameters
int$a_mob_idmedia object id

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

References $DIC, $ilDB, and $query.

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

471  {
472  global $DIC;
473 
474  $ilDB = $DIC->database();
475 
476  // iterate all media items ob mob
477  $query = "SELECT * FROM media_item WHERE mob_id = " .
478  $ilDB->quote($a_mob_id, "integer");
479  $item_set = $ilDB->query($query);
480  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
481  // delete all parameters of media item
482  $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
483  $ilDB->quote($item_rec["id"], "integer");
484  $ilDB->manipulate($query);
485 
486  // delete all map areas of media item
487  $query = "DELETE FROM map_area WHERE item_id = " .
488  $ilDB->quote($item_rec["id"], "integer");
489  $ilDB->manipulate($query);
490  }
491 
492  // delete media items
493  $query = "DELETE FROM media_item WHERE mob_id = " .
494  $ilDB->quote($a_mob_id, "integer");
495  $ilDB->manipulate($query);
496  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ deleteMapArea()

ilMediaItem::deleteMapArea (   $nr)

delete map area

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

References $i, $map_cnt, and $nr.

558  {
559  for ($i = 1; $i <= $this->map_cnt; $i++) {
560  if ($i > $nr) {
561  $this->mapareas[$i - 2] = $this->mapareas[$i - 1];
562  $this->mapareas[$i - 2]->setNr($i - 1);
563  }
564  }
565  if ($nr <= $this->map_cnt) {
566  unset($this->mapareas[$this->map_cnt - 1]);
567  $this->map_cnt--;
568  }
569  }
$i
Definition: metadata.php:24

◆ determineDuration()

ilMediaItem::determineDuration ( )

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

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

1213  {
1214  $ana = new ilMediaAnalyzer();
1215  $ana->setFile(ilObjMediaObject::_getDirectory($this->getMobId()) . "/" . $this->getLocation());
1216  $ana->analyzeFile();
1217  $this->setDuration((int) $ana->getPlaytimeSeconds());
1218  }
setDuration($a_val)
Set duration.
getMobId()
get id of parent media object
static _getDirectory($a_mob_id)
Get absolute directory.
Analyzes media files.
+ Here is the call graph for this function:

◆ extractUrlParameters()

ilMediaItem::extractUrlParameters ( )

Extract parameters of special external references to parameter array.

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

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

1201  {
1202  include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1204  $this->getLocation(),
1205  $this->getParameters()
1206  );
1207  foreach ($par as $k => $v) {
1208  $this->setParameter($k, $v);
1209  }
1210  }
static extractUrlParameters($a_location, $a_parameter)
Extract URL information to parameter array.
getParameters()
get all parameters (in array)
setParameter($a_name, $a_value)
set parameter
+ Here is the call graph for this function:

◆ getCaption()

ilMediaItem::getCaption ( )

get caption

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

References $caption.

Referenced by create(), and update().

655  {
656  return $this->caption;
657  }
+ Here is the caller graph for this function:

◆ getDirectory()

ilMediaItem::getDirectory ( )

get media file directory

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

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

Referenced by copyOriginal(), and getThumbnailTarget().

821  {
822  return ilObjMediaObject::_getDirectory($this->getMobId());
823  }
getMobId()
get id of parent media object
static _getDirectory($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 ( )

Get duration.

Returns
int duration

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

References $duration.

Referenced by create(), and update().

129  {
130  return $this->duration;
131  }
+ Here is the caller graph for this function:

◆ getFormat()

ilMediaItem::getFormat ( )

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

References $format.

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

534  {
535  return $this->format;
536  }
+ Here is the caller graph for this function:

◆ getHAlign()

ilMediaItem::getHAlign ( )

get horizontal align

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

References $halign.

Referenced by create(), and update().

671  {
672  return $this->halign;
673  }
+ Here is the caller graph for this function:

◆ getHeight()

ilMediaItem::getHeight ( )

get height

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

References $height.

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

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

◆ getId()

ilMediaItem::getId ( )

get media item id

Returns
int media item id

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

References $id.

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

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

◆ getLocation()

ilMediaItem::getLocation ( )

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

References $location.

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

514  {
515  return $this->location;
516  }
+ Here is the caller graph for this function:

◆ getLocationType()

ilMediaItem::getLocationType ( )

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

References $location_type.

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

524  {
525  return $this->location_type;
526  }
+ Here is the caller graph for this function:

◆ getMapArea()

& ilMediaItem::getMapArea (   $nr)

get map area

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

References $nr.

575  {
576  return $this->mapareas[$nr - 1];
577  }

◆ getMapAreas()

ilMediaItem::getMapAreas ( )

get map areas

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

References $mapareas.

583  {
584  return $this->mapareas;
585  }

◆ getMapAreasXML()

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

get xml code of media items' areas

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

References $i, $xml, and IL_INT_LINK.

1106  {
1107  $xml = "";
1108 
1109  // build xml of map areas
1110  for ($i = 0; $i < count($this->mapareas); $i++) {
1111  $area = $this->mapareas[$i];
1112 
1113  // highlight mode
1114  $hm = "";
1115  if ($area->getHighlightMode() != "") {
1116  $hm = ' HighlightMode="' . $area->getHighlightMode() . '" ';
1117  $hcl = ($area->getHighlightClass() != "")
1118  ? $area->getHighlightClass()
1119  : "Accented";
1120  $hm .= 'HighlightClass="' . $hcl . '" ';
1121  }
1122 
1123  $xml .= "<MapArea Shape=\"" . $area->getShape() . "\" Coords=\"" . $area->getCoords() . "\" " . $hm . ">";
1124  if ($area->getLinkType() == IL_INT_LINK) {
1125  $target_frame = $area->getTargetFrame();
1126 
1127  if ($area->getType() == "GlossaryItem" && $target_frame == "") {
1128  $target_frame = "Glossary";
1129  }
1130 
1131  $tf_str = ($target_frame == "")
1132  ? ""
1133  : "TargetFrame=\"" . $target_frame . "\"";
1134 
1135  $xml .= "<IntLink Target=\"" . $area->getTarget($a_insert_inst, $a_inst) . "\" Type=\"" .
1136  $area->getType() . "\" $tf_str>";
1137  // see bug 17893 and http://stackoverflow.com/questions/4026502/xml-error-at-ampersand
1138  $xml .= htmlspecialchars($area->getTitle(), ENT_QUOTES);
1139  $xml .= "</IntLink>";
1140  } else {
1141  $xml .= "<ExtLink Href=\"" . str_replace("&", "&amp;", $area->getHref()) . "\" Title=\"" .
1142  str_replace("&", "&amp;", $area->getExtTitle()) . "\">";
1143  $xml .= str_replace("&", "&amp;", $area->getTitle());
1144  $xml .= "</ExtLink>";
1145  }
1146  $xml .= "</MapArea>";
1147  }
1148  return $xml;
1149  }
const IL_INT_LINK
$xml
Definition: metadata.php:332
$i
Definition: metadata.php:24

◆ getMapWorkCopyName()

ilMediaItem::getMapWorkCopyName (   $a_reference_copy = false)

Get name of image map work copy file.

Parameters
stringGet name, for copy of external referenced image

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

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

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

803  {
804  $file_arr = explode("/", $this->getLocation());
805  $o_file = $file_arr[count($file_arr) - 1];
806  $file_arr = explode(".", $o_file);
807  unset($file_arr[count($file_arr) - 1]);
808  $file = implode(".", $file_arr);
809 
810  if (!$a_reference_copy) {
811  return $this->getWorkDirectory() . "/" . $file . "." . $this->getMapWorkCopyType();
812  } else {
813  return $this->getWorkDirectory() . "/l_copy_" . $o_file;
814  }
815  }
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 793 of file class.ilMediaItem.php.

References ilUtil\getGDSupportedImageType(), and getSuffix().

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

794  {
796  }
getSuffix()
get location suffix
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapWorkImage()

& ilMediaItem::getMapWorkImage ( )

get image map work image

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

References $map_image.

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

1098  {
1099  return $this->map_image;
1100  }
+ Here is the caller graph for this function:

◆ getMediaItemsForUploadHash()

static ilMediaItem::getMediaItemsForUploadHash (   $a_hash)
static

Get media items for upload hash.

Parameters
string$a_hashupload hash
Returns
array

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

References $db, and $DIC.

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

1226  {
1227  global $DIC;
1228 
1229  $db = $DIC->database();
1230 
1231  $set = $db->queryF(
1232  "SELECT * FROM media_item " .
1233  " WHERE upload_hash = %s ",
1234  array("text"),
1235  array($a_hash)
1236  );
1237  $media_items = array();
1238  while ($rec = $db->fetchAssoc($set)) {
1239  $media_items[] = $rec;
1240  }
1241  return $media_items;
1242  }
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ getMobId()

ilMediaItem::getMobId ( )

get id of parent media object

Returns
int media object id

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

References $mob_id.

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

98  {
99  return $this->mob_id;
100  }
+ Here is the caller graph for this function:

◆ getNr()

ilMediaItem::getNr ( )

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

References $nr.

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

111  {
112  return $this->nr;
113  }
+ Here is the caller graph for this function:

◆ getOriginalSize()

ilMediaItem::getOriginalSize ( )

get original size

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

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

623  {
624  $mob_dir = ilObjMediaObject::_getDirectory($this->getMobId());
625 
626  if (ilUtil::deducibleSize($this->getFormat())) {
627  if ($this->getLocationType() == "LocalFile") {
628  $loc = $mob_dir . "/" . $this->getLocation();
629  } else {
630  $loc = $this->getLocation();
631  }
632 
633  include_once("./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
635  if ($size[0] > 0 && $size[1] > 0) {
636  return array("width" => $size[0], "height" => $size[1]);
637  }
638  }
639 
640  return false;
641  }
$size
Definition: RandomTest.php:84
static getImageSize($a_location)
Get image size from location.
getMobId()
get id of parent media object
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static _getDirectory($a_mob_id)
Get absolute directory.
+ Here is the call graph for this function:

◆ getParameter()

ilMediaItem::getParameter (   $a_name)

get a single parameter

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

754  {
755  return $this->parameters[$a_name];
756  }

◆ getParameters()

ilMediaItem::getParameters ( )

get all parameters (in array)

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

References $parameters.

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

738  {
739  return $this->parameters;
740  }
+ Here is the caller graph for this function:

◆ getParameterString()

ilMediaItem::getParameterString ( )

get all parameters (as string)

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

References ilUtil\assembleParameterString().

746  {
747  return ilUtil::assembleParameterString($this->parameters);
748  }
static assembleParameterString($a_par_arr)
+ Here is the call graph for this function:

◆ getPurpose()

ilMediaItem::getPurpose ( )

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

References $purpose.

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

504  {
505  return $this->purpose;
506  }
+ Here is the caller graph for this function:

◆ getSuffix()

ilMediaItem::getSuffix ( )

get location suffix

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

References getLocation().

Referenced by getMapWorkCopyType().

784  {
785  $loc_arr = explode(".", $this->getLocation());
786 
787  return $loc_arr[count($loc_arr) - 1];
788  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRepresentation()

ilMediaItem::getTextRepresentation ( )

Get text representation.

Returns
string text representation

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

Referenced by create(), and update().

147  {
148  return $this->text_representation;
149  }
+ Here is the caller graph for this function:

◆ getThumbnailDirectory()

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

get media file directory

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

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

Referenced by getThumbnailTarget().

829  {
830  return ilObjMediaObject::_getThumbnailDirectory($this->getMobId(), $a_mode);
831  }
static _getThumbnailDirectory($a_mob_id, $a_mode="filesystem")
get directory for files of media object (static)
getMobId()
get id of parent media object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThumbnailTarget()

ilMediaItem::getThumbnailTarget (   $a_size = "")

get thumbnail target

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

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

837  {
838  $jpeg_file = $this->getThumbnailDirectory() . "/" .
839  $this->getPurpose() . ".jpeg";
840  $format = "png";
841  if (is_file($jpeg_file)) {
842  $format = "jpeg";
843  }
844  if (is_int(strpos($this->getFormat(), "image"))) {
845  $thumb_file = $this->getThumbnailDirectory() . "/" .
846  $this->getPurpose() . "." . $format;
847  $thumb_file_small = $this->getThumbnailDirectory() . "/" .
848  $this->getPurpose() . "_small." . $format;
849  // generate thumbnail (if not tried before)
850  if ($this->getThumbTried() == "n" && $this->getLocationType() == "LocalFile" && $this->getFormat() !== "image/svg+xml") {
851  if (is_file($thumb_file)) {
852  unlink($thumb_file);
853  }
854  if (is_file($thumb_file_small)) {
855  unlink($thumb_file_small);
856  }
857  $this->writeThumbTried("y");
859  $med_file = $this->getDirectory() . "/" . $this->getLocation();
860 
861  if (is_file($med_file)) {
862  $mob = new ilObjMediaObject($this->getMobId());
863  $mob->makeThumbnail($this->getLocation(), $this->getPurpose() . "." . $format, $format, "80");
864  $mob->makeThumbnail($this->getLocation(), $this->getPurpose() . "_small." . $format, $format, "40");
865  }
866  }
867  if ($this->getFormat() === "image/svg+xml") {
868  return ilObjMediaObject::_getURL($this->getMobId()) . "/" . $this->getLocation();
869  }
870  if ($a_size == "small") {
871  if (is_file($thumb_file_small)) {
872  $random = new \ilRandom();
873  return $this->getThumbnailDirectory("output") . "/" .
874  $this->getPurpose() . "_small." . $format . "?dummy=" . $random->int(1, 999999);
875  }
876  } else {
877  if (is_file($thumb_file)) {
878  $random = new \ilRandom();
879  return $this->getThumbnailDirectory("output") . "/" .
880  $this->getPurpose() . "." . $format . "?dummy=" . $random->int(1, 999999);
881  }
882  }
883  }
884 
885  return "";
886  }
getMobId()
get id of parent media object
static _getURL($a_mob_id)
get directory for files of media object (static)
getThumbnailDirectory($a_mode="filesystem")
get media file directory
getDirectory()
get media file directory
Class ilObjMediaObject.
static _createThumbnailDirectory($a_obj_id)
Create thumbnail directory.
writeThumbTried($a_tried)
write thumbnail creation try data ("y"/"n")
+ Here is the call graph for this function:

◆ getThumbTried()

ilMediaItem::getThumbTried ( )

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

Referenced by getThumbnailTarget().

544  {
545  return $this->tried_thumb;
546  }
+ Here is the caller graph for this function:

◆ getUploadHash()

ilMediaItem::getUploadHash ( )

Get upload hash.

Returns
string upload hash

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

References $upload_hash.

Referenced by create(), and update().

165  {
166  return $this->upload_hash;
167  }
+ Here is the caller graph for this function:

◆ getWidth()

ilMediaItem::getWidth ( )

get width

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

References $width.

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

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

◆ getWorkDirectory()

ilMediaItem::getWorkDirectory ( )

get work directory for image map editing

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

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

Referenced by createWorkDirectory(), and getMapWorkCopyName().

762  {
763  return ilUtil::getDataDir() . "/map_workfiles/item_" . $this->getId();
764  }
getId()
get media item id
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 (   $a_area_nr = 0,
  $a_exclude = false 
)

make map work copy of image

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

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

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

944  {
945  $lng = $this->lng;
946 
947  if (!$this->copyOriginal()) {
948  return false;
949  }
950  $this->buildMapWorkImage();
951 
952  // determine ratios
953  $size = @getimagesize($this->getMapWorkCopyName());
954  $x_ratio = 1;
955  if ($size[0] > 0 && $this->getWidth() > 0) {
956  $x_ratio = $this->getWidth() / $size[0];
957  }
958  $y_ratio = 1;
959  if ($size[1] > 0 && $this->getHeight() > 0) {
960  $y_ratio = $this->getHeight() / $size[1];
961  }
962 
963  // draw map areas
964  for ($i = 0; $i < count($this->mapareas); $i++) {
965  if (((($i + 1) == $a_area_nr) && !$a_exclude) ||
966  ((($i + 1) != $a_area_nr) && $a_exclude) ||
967  ($a_area_nr == 0)
968  ) {
969  $area = $this->mapareas[$i];
970  $area->draw(
971  $this->getMapWorkImage(),
972  $this->color1,
973  $this->color2,
974  true,
975  $x_ratio,
976  $y_ratio
977  );
978  }
979  }
980 
981  $this->saveMapWorkImage();
982 
983  return true;
984  }
$size
Definition: RandomTest.php:84
getWidth()
get width
copyOriginal()
Copy the orginal file.
buildMapWorkImage()
build image map work image
& getMapWorkImage()
get image map work image
getMapWorkCopyName($a_reference_copy=false)
Get name of image map work copy file.
saveMapWorkImage()
save image map work image
getHeight()
get height
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ outputMapWorkCopy()

ilMediaItem::outputMapWorkCopy ( )

output raw map work copy file

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

References exit, getMapWorkCopyName(), and getMapWorkCopyType().

1026  {
1027  if ($this->getMapWorkCopyType() != "") {
1028  header("Pragma: no-cache");
1029  header("Expires: 0");
1030  header("Content-type: image/" . strtolower($this->getMapWorkCopyType()));
1031  readfile($this->getMapWorkCopyName());
1032  }
1033  exit;
1034  }
exit
Definition: login.php:29
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName($a_reference_copy=false)
Get name of image map work copy file.
+ Here is the call graph for this function:

◆ read()

ilMediaItem::read ( )

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

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

References $db, $i, $ilDB, $mob_id, $nr, $query, 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().

279  {
280  $ilDB = $this->db;
281 
282  $item_id = $this->getId();
283  $mob_id = $this->getMobId();
284  $nr = $this->getNr();
285  $query = "";
286  if ($item_id > 0) {
287  $query = "SELECT * FROM media_item WHERE id = " .
288  $ilDB->quote($this->getId(), "integer");
289  } elseif ($mob_id > 0 && $nr > 0) {
290  $query = "SELECT * FROM media_item WHERE mob_id = " .
291  $ilDB->quote($this->getMobId(), "integer") . " " .
292  "AND nr=" . $ilDB->quote($this->getNr(), "integer");
293  }
294  if ($query != "") {
295  $item_set = $ilDB->query($query);
296  $item_rec = $ilDB->fetchAssoc($item_set);
297 
298  $this->setLocation($item_rec["location"]);
299  $this->setLocationType($item_rec["location_type"]);
300  $this->setFormat($item_rec["format"]);
301  $this->setWidth($item_rec["width"]);
302  $this->setHeight($item_rec["height"]);
303  $this->setHAlign($item_rec["halign"]);
304  $this->setCaption($item_rec["caption"]);
305  $this->setPurpose($item_rec["purpose"]);
306  $this->setNr($item_rec["nr"]);
307  $this->setMobId($item_rec["mob_id"]);
308  $this->setId($item_rec["id"]);
309  $this->setThumbTried($item_rec["tried_thumb"]);
310  $this->setTextRepresentation($item_rec["text_representation"]);
311  $this->setUploadHash($item_rec["upload_hash"]);
312  $this->setDuration((int) $item_rec["duration"]);
313 
314  // get item parameter
315  $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
316  $ilDB->quote($this->getId(), "integer");
317  $par_set = $ilDB->query($query);
318  while ($par_rec = $ilDB->fetchAssoc($par_set)) {
319  $this->setParameter($par_rec["name"], $par_rec["value"]);
320  }
321 
322  // get item map areas
323  $max = ilMapArea::_getMaxNr($this->getId());
324  for ($i = 1; $i <= $max; $i++) {
325  $area = new ilMapArea($this->getId(), $i);
326  $this->addMapArea($area);
327  }
328  }
329  }
setCaption($a_caption)
set caption
getId()
get media item id
setId($a_id)
set media item id
setThumbTried($a_tried)
setUploadHash($a_val)
Set upload hash.
setDuration($a_val)
Set duration.
setLocation($a_location)
setHeight($a_height)
set height
getMobId()
get id of parent media object
setNr($a_nr)
set number of media item within media object
addMapArea(&$a_map_area)
setPurpose($a_purpose)
$query
setMobId($a_mob_id)
set id of parent media object
setHAlign($a_halign)
set horizontal align
setTextRepresentation($a_val)
Set text representation.
Class ilMapArea.
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
global $ilDB
setFormat($a_format)
setWidth($a_width)
set width
$i
Definition: metadata.php:24
setParameter($a_name, $a_value)
set parameter
setLocationType($a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetParameters()

ilMediaItem::resetParameters ( )

reset parameters

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

Referenced by setParameters().

691  {
692  $this->parameters = array();
693  }
+ Here is the caller graph for this function:

◆ saveMapWorkImage()

ilMediaItem::saveMapWorkImage ( )

save image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

1072  {
1073  $im_type = strtolower($this->getMapWorkCopyType());
1074 
1075  // save image work-copy and free memory
1076  switch ($im_type) {
1077  case "gif":
1078  ImageGIF($this->map_image, $this->getMapWorkCopyName());
1079  break;
1080 
1081  case "jpg":
1082  case "jpeg":
1083  ImageJPEG($this->map_image, $this->getMapWorkCopyName());
1084  break;
1085 
1086  case "png":
1087  ImagePNG($this->map_image, $this->getMapWorkCopyName());
1088  break;
1089  }
1090 
1091  ImageDestroy($this->map_image);
1092  }
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName($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 (   $a_caption)

set caption

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

Referenced by read().

647  {
648  $this->caption = $a_caption;
649  }
+ Here is the caller graph for this function:

◆ setDuration()

ilMediaItem::setDuration (   $a_val)

Set duration.

Parameters
int$a_valduration

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

Referenced by determineDuration(), and read().

120  {
121  $this->duration = $a_val;
122  }
+ Here is the caller graph for this function:

◆ setFormat()

ilMediaItem::setFormat (   $a_format)

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

Referenced by read().

529  {
530  $this->format = $a_format;
531  }
+ Here is the caller graph for this function:

◆ setHAlign()

ilMediaItem::setHAlign (   $a_halign)

set horizontal align

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

Referenced by read().

663  {
664  $this->halign = $a_halign;
665  }
+ Here is the caller graph for this function:

◆ setHeight()

ilMediaItem::setHeight (   $a_height)

set height

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

Referenced by read().

615  {
616  $this->height = $a_height;
617  }
+ Here is the caller graph for this function:

◆ setId()

ilMediaItem::setId (   $a_id)

set media item id

Parameters
int$a_idmedia item id

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

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

71  {
72  $this->id = $a_id;
73  }
+ Here is the caller graph for this function:

◆ setLocation()

ilMediaItem::setLocation (   $a_location)

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

Referenced by read().

509  {
510  $this->location = $a_location;
511  }
+ Here is the caller graph for this function:

◆ setLocationType()

ilMediaItem::setLocationType (   $a_type)

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

Referenced by read().

519  {
520  $this->location_type = $a_type;
521  }
+ Here is the caller graph for this function:

◆ setMobId()

ilMediaItem::setMobId (   $a_mob_id)

set id of parent media object

Parameters
int$a_mob_idmedia object id

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

Referenced by read().

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

◆ setNr()

ilMediaItem::setNr (   $a_nr)

set number of media item within media object

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

Referenced by read().

106  {
107  $this->nr = $a_nr;
108  }
+ Here is the caller graph for this function:

◆ setParameter()

ilMediaItem::setParameter (   $a_name,
  $a_value 
)

set parameter

Parameters
string$a_nameparameter name
string$a_valueparameter value

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

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

681  {
682  if (self::checkParameter($a_name, $a_value)) {
683  $this->parameters[$a_name] = $a_value;
684  }
685  }
+ Here is the caller graph for this function:

◆ setParameters()

ilMediaItem::setParameters (   $a_par)

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

Parameters
string$a_parparameter string

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

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

700  {
701  $this->resetParameters();
702  $par_arr = ilUtil::extractParameterString($a_par);
703  if (is_array($par_arr)) {
704  foreach ($par_arr as $par => $val) {
705  $this->setParameter($par, $val);
706  }
707  }
708  }
resetParameters()
reset parameters
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array
setParameter($a_name, $a_value)
set parameter
+ Here is the call graph for this function:

◆ setPurpose()

ilMediaItem::setPurpose (   $a_purpose)

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

Referenced by read().

499  {
500  $this->purpose = $a_purpose;
501  }
+ Here is the caller graph for this function:

◆ setTextRepresentation()

ilMediaItem::setTextRepresentation (   $a_val)

Set text representation.

Parameters
stringtext representation

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

Referenced by read().

138  {
139  $this->text_representation = $a_val;
140  }
+ Here is the caller graph for this function:

◆ setThumbTried()

ilMediaItem::setThumbTried (   $a_tried)

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

Referenced by read().

539  {
540  $this->tried_thumb = $a_tried;
541  }
+ Here is the caller graph for this function:

◆ setUploadHash()

ilMediaItem::setUploadHash (   $a_val)

Set upload hash.

Parameters
string$a_valupload hash

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

Referenced by read().

156  {
157  $this->upload_hash = $a_val;
158  }
+ Here is the caller graph for this function:

◆ setWidth()

ilMediaItem::setWidth (   $a_width)

set width

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

Referenced by read().

599  {
600  $this->width = $a_width;
601  }
+ Here is the caller graph for this function:

◆ update()

ilMediaItem::update ( )

update media item data (without map areas!)

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

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

224  {
225  $ilDB = $this->db;
226 
227  $query = "UPDATE media_item SET " .
228  " mob_id = " . $ilDB->quote($this->getMobId(), "integer") . "," .
229  " purpose = " . $ilDB->quote($this->getPurpose(), "text") . "," .
230  " location = " . $ilDB->quote($this->getLocation(), "text") . "," .
231  " location_type = " . $ilDB->quote($this->getLocationType(), "text") . "," .
232  " format = " . $ilDB->quote($this->getFormat(), "text") . "," .
233  " width = " . $ilDB->quote($this->getWidth(), "text") . "," .
234  " height = " . $ilDB->quote($this->getHeight(), "text") . "," .
235  " halign = " . $ilDB->quote($this->getHAlign(), "text") . "," .
236  " caption = " . $ilDB->quote($this->getCaption(), "text") . "," .
237  " nr = " . $ilDB->quote($this->getNr(), "integer") . "," .
238  " text_representation = " . $ilDB->quote($this->getTextRepresentation(), "text") . "," .
239  " upload_hash = " . $ilDB->quote($this->getUploadHash(), "text") . "," .
240  " duration = " . $ilDB->quote($this->getDuration(), "integer") .
241  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
242  $ilDB->manipulate($query);
243 
244  // delete mob parameters
245  $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
246  $ilDB->quote($this->getId(), "integer");
247 
248  // create mob parameters
249  $params = $this->getParameters();
250  foreach ($params as $name => $value) {
251  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
252  "(" . $ilDB->quote($this->getId(), "integer") . "," .
253  $ilDB->quote($name, "text") . "," .
254  $ilDB->quote($value, "text") . ")";
255  $ilDB->manipulate($query);
256  }
257  }
getDuration()
Get duration.
getId()
get media item id
getWidth()
get width
getMobId()
get id of parent media object
if($format !==null) $name
Definition: metadata.php:230
getUploadHash()
Get upload hash.
$query
global $ilDB
getCaption()
get caption
getParameters()
get all parameters (in array)
getHAlign()
get horizontal align
getTextRepresentation()
Get text representation.
getHeight()
get height
+ Here is the call graph for this function:

◆ writeParameter()

ilMediaItem::writeParameter (   $a_name,
  $a_value 
)

Write parameter.

Parameters

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

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

265  {
266  $ilDB = $this->db;
267 
268  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
269  "(" . $ilDB->quote($this->getId(), "integer") . "," .
270  $ilDB->quote($a_name, "text") . "," .
271  $ilDB->quote($a_value, "text") . ")";
272  $ilDB->manipulate($query);
273  }
getId()
get media item id
$query
global $ilDB
+ Here is the call graph for this function:

◆ writeThumbTried()

ilMediaItem::writeThumbTried (   $a_tried)

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

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

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

Referenced by getThumbnailTarget().

335  {
336  $ilDB = $this->db;
337 
338  $q = "UPDATE media_item SET tried_thumb = " .
339  $ilDB->quote($a_tried, "text") .
340  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
341 
342  $ilDB->manipulate($q);
343  }
getId()
get media item id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $caption

ilMediaItem::$caption

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

Referenced by getCaption().

◆ $color1

ilMediaItem::$color1

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

◆ $color2

ilMediaItem::$color2

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

◆ $db

ilMediaItem::$db
protected

◆ $duration

ilMediaItem::$duration = 0
protected

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

Referenced by getDuration().

◆ $format

ilMediaItem::$format

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

Referenced by getFormat(), and getThumbnailTarget().

◆ $halign

ilMediaItem::$halign

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

Referenced by getHAlign().

◆ $height

ilMediaItem::$height

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

Referenced by getHeight().

◆ $id

ilMediaItem::$id

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

Referenced by getId().

◆ $lng

ilMediaItem::$lng
protected

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

Referenced by copyOriginal(), and makeMapWorkCopy().

◆ $location

ilMediaItem::$location

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

Referenced by getLocation().

◆ $location_type

ilMediaItem::$location_type

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

Referenced by getLocationType().

◆ $map_cnt

ilMediaItem::$map_cnt

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

Referenced by addMapArea(), and deleteMapArea().

◆ $map_image

ilMediaItem::$map_image

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

Referenced by getMapWorkImage().

◆ $mapareas

ilMediaItem::$mapareas

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

Referenced by getMapAreas().

◆ $mob_id

ilMediaItem::$mob_id

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

Referenced by getMobId(), and read().

◆ $nr

ilMediaItem::$nr

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

Referenced by deleteMapArea(), getMapArea(), getNr(), and read().

◆ $parameters

ilMediaItem::$parameters

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

Referenced by getParameters().

◆ $purpose

ilMediaItem::$purpose

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

Referenced by getPurpose().

◆ $upload_hash

ilMediaItem::$upload_hash
protected

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

Referenced by getUploadHash().

◆ $width

ilMediaItem::$width

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

Referenced by getWidth().


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