ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMediaItem Class Reference

Class ilMediaItem. 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 ()
 
 setTextRepresentation ($a_val)
 Set text representation. More...
 
 getTextRepresentation ()
 Get text representation. 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...
 

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

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
 

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

Constructor & Destructor Documentation

◆ __construct()

ilMediaItem::__construct (   $a_id = 0)

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

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

47  {
48  global $DIC;
49 
50  $this->db = $DIC->database();
51  $this->lng = $DIC->language();
52  $this->parameters = array();
53  $this->mapareas = array();
54  $this->map_cnt = 0;
55 
56  if ($a_id != 0) {
57  $this->setId($a_id);
58  $this->read();
59  }
60  }
setId($a_id)
set media item id
global $DIC
Definition: saml.php:7
read()
read media item data (item id or (mob_id and nr) must be set)
Create styles array
The data for the language used.
+ 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 1148 of file class.ilMediaItem.php.

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

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

1149  {
1150  global $DIC;
1151 
1152  $ilDB = $DIC->database();
1153 
1154  // read media_items records
1155  $query = "SELECT * FROM media_item WHERE mob_id = " .
1156  $ilDB->quote($a_mob_id, "integer") . " ORDER BY nr";
1157 
1158  $item_set = $ilDB->query($query);
1159  $links = array();
1160  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
1161  $map_links = ilMapArea::_getIntLinks($item_rec["id"]);
1162  foreach ($map_links as $key => $map_link) {
1163  $links[$key] = $map_link;
1164  }
1165  }
1166  return $links;
1167  }
global $DIC
Definition: saml.php:7
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
$query
Create styles array
The data for the language used.
global $ilDB
$links
$key
Definition: croninfo.php:18
+ 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 381 of file class.ilMediaItem.php.

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

Referenced by ilObjMediaObject\read().

382  {
383  global $DIC;
384 
385  $ilDB = $DIC->database();
386 
387  // read media_object record
388  $query = "SELECT * FROM media_item WHERE mob_id = " .
389  $ilDB->quote($a_mob->getId(), "integer") . " " .
390  "ORDER BY nr";
391  $item_set = $ilDB->query($query);
392  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
393  $media_item = new ilMediaItem();
394  $media_item->setNr($item_rec["nr"]);
395  $media_item->setId($item_rec["id"]);
396  $media_item->setLocation($item_rec["location"]);
397  $media_item->setLocationType($item_rec["location_type"]);
398  $media_item->setFormat($item_rec["format"]);
399  $media_item->setWidth($item_rec["width"]);
400  $media_item->setHeight($item_rec["height"]);
401  $media_item->setHAlign($item_rec["halign"]);
402  $media_item->setCaption($item_rec["caption"]);
403  $media_item->setPurpose($item_rec["purpose"]);
404  $media_item->setMobId($item_rec["mob_id"]);
405  $media_item->setThumbTried($item_rec["tried_thumb"]);
406  $media_item->setTextRepresentation($item_rec["text_representation"]);
407 
408  // get item parameter
409  $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
410  $ilDB->quote($item_rec["id"], "integer");
411  $par_set = $ilDB->query($query);
412  while ($par_rec = $ilDB->fetchAssoc($par_set)) {
413  $media_item->setParameter($par_rec["name"], $par_rec["value"]);
414  }
415 
416  // get item map areas
417  $max = ilMapArea::_getMaxNr($media_item->getId());
418  for ($i = 1; $i <= $max; $i++) {
419  $area = new ilMapArea($media_item->getId(), $i);
420  $media_item->addMapArea($area);
421  }
422 
423  // add media item to media object
424  $a_mob->addMediaItem($media_item);
425  }
426  }
global $DIC
Definition: saml.php:7
Class ilMediaItem.
$query
Class ilMapArea.
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
global $ilDB
$i
Definition: disco.tpl.php:19
+ 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 358 of file class.ilMediaItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilObjectFeedWriter\__construct().

359  {
360  global $DIC;
361 
362  $ilDB = $DIC->database();
363 
364  // read media_object record
365  $query = "SELECT * FROM media_item WHERE mob_id = " .
366  $ilDB->quote($a_mobId, "integer") . " " .
367  "AND purpose=" . $ilDB->quote($a_purpose, "text") . " ORDER BY nr";
368  $item_set = $ilDB->query($query);
369 
370  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
371  return $item_rec;
372  }
373  return false;
374  }
global $DIC
Definition: saml.php:7
$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 312 of file class.ilMediaItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\_lookupItemPath().

313  {
314  global $DIC;
315 
316  $ilDB = $DIC->database();
317 
318  // read media_object record
319  $query = "SELECT * FROM media_item WHERE mob_id = " .
320  $ilDB->quote($a_mob_id, "integer") . " " .
321  "AND purpose = " . $ilDB->quote($a_purpose, "text");
322  $set = $ilDB->query($query);
323  if ($rec = $ilDB->fetchAssoc($set)) {
324  return $rec["location"];
325  }
326 
327  return "";
328  }
global $DIC
Definition: saml.php:7
$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 335 of file class.ilMediaItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilMapArea\_getMobsForTarget().

336  {
337  global $DIC;
338 
339  $ilDB = $DIC->database();
340 
341  // read media_object record
342  $query = "SELECT * FROM media_item WHERE id = " .
343  $ilDB->quote($a_med_id, "integer");
344  $set = $ilDB->query($query);
345  if ($rec = $ilDB->fetchAssoc($set)) {
346  return $rec["mob_id"];
347  }
348 
349  return "";
350  }
global $DIC
Definition: saml.php:7
$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 1126 of file class.ilMediaItem.php.

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

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

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

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

960  {
961  $this->buildMapWorkImage();
962 
963  // determine ratios
964  $size = @getimagesize($this->getMapWorkCopyName());
965  $x_ratio = 1;
966  if ($size[0] > 0 && $this->getWidth() > 0) {
967  $x_ratio = $this->getWidth() / $size[0];
968  }
969  $y_ratio = 1;
970  if ($size[1] > 0 && $this->getHeight() > 0) {
971  $y_ratio = $this->getHeight() / $size[1];
972  }
973 
974  // add new area to work image
975  $area = new ilMapArea();
976  $area->setShape($a_shape);
977  $area->setCoords($a_coords);
978  $area->draw(
979  $this->getMapWorkImage(),
980  $this->color1,
981  $this->color2,
982  false,
983  $x_ratio,
984  $y_ratio
985  );
986 
987  $this->saveMapWorkImage();
988  }
$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 511 of file class.ilMediaItem.php.

References $map_cnt.

Referenced by read().

512  {
513  $this->mapareas[$this->map_cnt] = $a_map_area;
514  $this->map_cnt++;
515  }
+ Here is the caller graph for this function:

◆ buildMapWorkImage()

ilMediaItem::buildMapWorkImage ( )

build image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

1008  {
1009  $im_type = strtolower($this->getMapWorkCopyType());
1010 
1011  switch ($im_type) {
1012  case "gif":
1013  $this->map_image = ImageCreateFromGIF($this->getMapWorkCopyName());
1014  break;
1015 
1016  case "jpg":
1017  case "jpeg":
1018  $this->map_image = ImageCreateFromJPEG($this->getMapWorkCopyName());
1019  break;
1020 
1021  case "png":
1022  $this->map_image = ImageCreateFromPNG($this->getMapWorkCopyName());
1023  break;
1024  }
1025 
1026  // try to allocate black and white as color. if this is not possible, get the closest colors
1027  if (imagecolorstotal($this->map_image) > 250) {
1028  $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
1029  $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
1030  } else {
1031  $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
1032  $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
1033  }
1034  }
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 683 of file class.ilMediaItem.php.

References array.

Referenced by ilMediaAliasItem\setParameters().

684  {
685  // do not allow event attributes
686  if (substr(strtolower(trim($a_par)), 0, 2) == "on") {
687  return false;
688  }
689  // no javascript in value
690  if (is_int(strpos(strtolower($a_val), "javascript"))) {
691  return false;
692  }
693  // do not allow to change the src attribute
694  if (in_array(strtolower(trim($a_par)), array("src"))) {
695  return false;
696  }
697 
698  return true;
699  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ copyOriginal()

ilMediaItem::copyOriginal ( )

Copy the orginal file.

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

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

Referenced by makeMapWorkCopy().

857  {
858  $lng = $this->lng;
859  $this->createWorkDirectory();
860 
861  $geom = ($this->getWidth() != "" && $this->getHeight() != "")
862  ? $this->getWidth() . "x" . $this->getHeight()
863  : "";
864 
865  if ($this->getLocationType() != "Reference") {
867  $this->getDirectory() . "/" . $this->getLocation(),
868  $this->getMapWorkCopyName(),
869  $this->getMapWorkCopyType(),
870  $geom
871  );
872  } else {
873  // first copy the external file, if necessary
874  if (!is_file($this->getMapWorkCopyName(true)) || (filesize($this->getMapWorkCopyName(true)) == 0)) {
875  $handle = @fopen($this->getLocation(), "r");
876  $lcopy = fopen($this->getMapWorkCopyName(true), "w");
877  if ($handle && $lcopy) {
878  while (!feof($handle)) {
879  $content = fread($handle, 4096);
880  fwrite($lcopy, $content);
881  }
882  }
883  @fclose($lcopy);
884  @fclose($handle);
885  }
886 
887  // now, create working copy
889  $this->getMapWorkCopyName(true),
890  $this->getMapWorkCopyName(),
891  $this->getMapWorkCopyType(),
892  $geom
893  );
894  }
895 
896  if (!is_file($this->getMapWorkCopyName())) {
897  ilUtil::sendFailure($lng->txt("cont_map_file_not_generated"));
898  return false;
899  }
900  return true;
901  }
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 139 of file class.ilMediaItem.php.

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

140  {
141  $ilDB = $this->db;
142 
143  $item_id = $ilDB->nextId("media_item");
144  $query = "INSERT INTO media_item (id,mob_id, purpose, location, " .
145  "location_type, format, width, " .
146  "height, halign, caption, nr, text_representation) VALUES " .
147  "(" .
148  $ilDB->quote($item_id, "integer") . "," .
149  $ilDB->quote($this->getMobId(), "integer") . "," .
150  $ilDB->quote($this->getPurpose(), "text") . "," .
151  $ilDB->quote($this->getLocation(), "text") . "," .
152  $ilDB->quote($this->getLocationType(), "text") . "," .
153  $ilDB->quote($this->getFormat(), "text") . "," .
154  $ilDB->quote($this->getWidth(), "text") . "," .
155  $ilDB->quote($this->getHeight(), "text") . "," .
156  $ilDB->quote($this->getHAlign(), "text") . "," .
157  $ilDB->quote($this->getCaption(), "text") . "," .
158  $ilDB->quote($this->getNr(), "integer") . "," .
159  $ilDB->quote($this->getTextRepresentation(), "text") . ")";
160  $ilDB->manipulate($query);
161 
162  $this->setId($item_id);
163 
164  // create mob parameters
165  $params = $this->getParameters();
166  foreach ($params as $name => $value) {
167  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
168  "(" . $ilDB->quote($item_id, "integer") . "," .
169  $ilDB->quote($name, "text") . "," .
170  $ilDB->quote($value, "text") . ")";
171  $ilDB->manipulate($query);
172  }
173 
174  // create map areas
175  for ($i=0; $i < count($this->mapareas); $i++) {
176  if (is_object($this->mapareas[$i])) {
177  $this->mapareas[$i]->setItemId($this->getId());
178  $this->mapareas[$i]->setNr($i + 1);
179  $this->mapareas[$i]->create();
180  }
181  }
182  }
$params
Definition: disable.php:11
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:146
$query
global $ilDB
$i
Definition: disco.tpl.php:19
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:

◆ createWorkDirectory()

ilMediaItem::createWorkDirectory ( )

create work directory for image map editing

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

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

Referenced by copyOriginal().

740  {
741  if (!@is_dir(ilUtil::getDataDir() . "/map_workfiles")) {
742  ilUtil::createDirectory(ilUtil::getDataDir() . "/map_workfiles");
743  }
744  $work_dir = $this->getWorkDirectory();
745  if (!@is_dir($work_dir)) {
746  ilUtil::createDirectory($work_dir);
747  }
748  }
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 433 of file class.ilMediaItem.php.

References $DIC, $ilDB, and $query.

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

434  {
435  global $DIC;
436 
437  $ilDB = $DIC->database();
438 
439  // iterate all media items ob mob
440  $query = "SELECT * FROM media_item WHERE mob_id = " .
441  $ilDB->quote($a_mob_id, "integer");
442  $item_set = $ilDB->query($query);
443  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
444  // delete all parameters of media item
445  $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
446  $ilDB->quote($item_rec["id"], "integer");
447  $ilDB->manipulate($query);
448 
449  // delete all map areas of media item
450  $query = "DELETE FROM map_area WHERE item_id = " .
451  $ilDB->quote($item_rec["id"], "integer");
452  $ilDB->manipulate($query);
453  }
454 
455  // delete media items
456  $query = "DELETE FROM media_item WHERE mob_id = " .
457  $ilDB->quote($a_mob_id, "integer");
458  $ilDB->manipulate($query);
459  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ deleteMapArea()

ilMediaItem::deleteMapArea (   $nr)

delete map area

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

References $i, $map_cnt, and $nr.

521  {
522  for ($i=1; $i<=$this->map_cnt; $i++) {
523  if ($i > $nr) {
524  $this->mapareas[$i-2] = $this->mapareas[$i-1];
525  $this->mapareas[$i-2]->setNr($i-1);
526  }
527  }
528  if ($nr <= $this->map_cnt) {
529  unset($this->mapareas[$this->map_cnt - 1]);
530  $this->map_cnt--;
531  }
532  }
$i
Definition: disco.tpl.php:19

◆ extractUrlParameters()

ilMediaItem::extractUrlParameters ( )

Extract parameters of special external references to parameter array.

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

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

1173  {
1174  include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
1176  $this->getLocation(),
1177  $this->getParameters()
1178  );
1179  foreach ($par as $k => $v) {
1180  $this->setParameter($k, $v);
1181  }
1182  }
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 617 of file class.ilMediaItem.php.

References $caption.

Referenced by create(), and update().

618  {
619  return $this->caption;
620  }
+ Here is the caller graph for this function:

◆ getDirectory()

ilMediaItem::getDirectory ( )

get media file directory

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

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

Referenced by copyOriginal(), and getThumbnailTarget().

792  {
793  return ilObjMediaObject::_getDirectory($this->getMobId());
794  }
getMobId()
get id of parent media object
static _getDirectory($a_mob_id)
get directory for files of media object (static)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormat()

ilMediaItem::getFormat ( )

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

References $format.

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

497  {
498  return $this->format;
499  }
+ Here is the caller graph for this function:

◆ getHAlign()

ilMediaItem::getHAlign ( )

get horizontal align

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

References $halign.

Referenced by create(), and update().

634  {
635  return $this->halign;
636  }
+ Here is the caller graph for this function:

◆ getHeight()

ilMediaItem::getHeight ( )

get height

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

References $height.

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

570  {
571  return $this->height;
572  }
+ Here is the caller graph for this function:

◆ getId()

ilMediaItem::getId ( )

get media item id

Returns
int media item id

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

References $id.

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

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

◆ getLocation()

ilMediaItem::getLocation ( )

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

References $location.

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

477  {
478  return $this->location;
479  }
+ Here is the caller graph for this function:

◆ getLocationType()

ilMediaItem::getLocationType ( )

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

References $location_type.

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

487  {
488  return $this->location_type;
489  }
+ Here is the caller graph for this function:

◆ getMapArea()

& ilMediaItem::getMapArea (   $nr)

get map area

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

References $nr.

538  {
539  return $this->mapareas[$nr-1];
540  }

◆ getMapAreas()

ilMediaItem::getMapAreas ( )

get map areas

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

References $mapareas.

546  {
547  return $this->mapareas;
548  }

◆ getMapAreasXML()

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

get xml code of media items' areas

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

References $i, $xml, and IL_INT_LINK.

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

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

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

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

774  {
775  $file_arr = explode("/", $this->getLocation());
776  $o_file = $file_arr[count($file_arr) - 1];
777  $file_arr = explode(".", $o_file);
778  unset($file_arr[count($file_arr) - 1]);
779  $file = implode($file_arr, ".");
780 
781  if (!$a_reference_copy) {
782  return $this->getWorkDirectory() . "/" . $file . "." . $this->getMapWorkCopyType();
783  } else {
784  return $this->getWorkDirectory() . "/l_copy_" . $o_file;
785  }
786  }
getMapWorkCopyType()
get image type of image map work copy
getWorkDirectory()
get work directory for image map editing
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 763 of file class.ilMediaItem.php.

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

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

764  {
766  }
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 1065 of file class.ilMediaItem.php.

References $map_image.

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

1066  {
1067  return $this->map_image;
1068  }
+ 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(), 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 585 of file class.ilMediaItem.php.

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

586  {
587  $mob_dir = ilObjMediaObject::_getDirectory($this->getMobId());
588 
589  if (ilUtil::deducibleSize($this->getFormat())) {
590  if ($this->getLocationType() == "LocalFile") {
591  $loc = $mob_dir . "/" . $this->getLocation();
592  } else {
593  $loc = $this->getLocation();
594  }
595 
596  include_once("./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
598  if ($size[0] > 0 && $size[1] > 0) {
599  return array("width" => $size[0], "height" => $size[1]);
600  }
601  }
602 
603  return false;
604  }
$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 directory for files of media object (static)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getParameter()

ilMediaItem::getParameter (   $a_name)

get a single parameter

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

724  {
725  return $this->parameters[$a_name];
726  }

◆ getParameters()

ilMediaItem::getParameters ( )

get all parameters (in array)

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

References $parameters.

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

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

◆ getParameterString()

ilMediaItem::getParameterString ( )

get all parameters (as string)

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

References ilUtil\assembleParameterString().

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

◆ getPurpose()

ilMediaItem::getPurpose ( )

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

References $purpose.

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

467  {
468  return $this->purpose;
469  }
+ Here is the caller graph for this function:

◆ getSuffix()

ilMediaItem::getSuffix ( )

get location suffix

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

References getLocation().

Referenced by getMapWorkCopyType().

754  {
755  $loc_arr = explode(".", $this->getLocation());
756 
757  return $loc_arr[count($loc_arr) - 1];
758  }
+ 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 130 of file class.ilMediaItem.php.

Referenced by create(), and update().

131  {
132  return $this->text_representation;
133  }
+ Here is the caller graph for this function:

◆ getThumbnailDirectory()

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

get media file directory

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

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

Referenced by getThumbnailTarget().

800  {
801  return ilObjMediaObject::_getThumbnailDirectory($this->getMobId(), $a_mode);
802  }
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 807 of file class.ilMediaItem.php.

References ilObjMediaObject\_createThumbnailDirectory(), ilUtil\convertImage(), getDirectory(), getFormat(), getLocation(), getLocationType(), getMobId(), getPurpose(), getThumbnailDirectory(), getThumbTried(), and writeThumbTried().

808  {
809  if (is_int(strpos($this->getFormat(), "image"))) {
810  $thumb_file = $this->getThumbnailDirectory() . "/" .
811  $this->getPurpose() . ".jpeg";
812 
813  $thumb_file_small = $this->getThumbnailDirectory() . "/" .
814  $this->getPurpose() . "_small.jpeg";
815 
816  // generate thumbnail (if not tried before)
817  if ($this->getThumbTried() == "n" && $this->getLocationType() == "LocalFile") {
818  if (is_file($thumb_file)) {
819  unlink($thumb_file);
820  }
821  if (is_file($thumb_file_small)) {
822  unlink($thumb_file_small);
823  }
824  $this->writeThumbTried("y");
826  $med_file = $this->getDirectory() . "/" . $this->getLocation();
827 
828  if (is_file($med_file)) {
829  ilUtil::convertImage($med_file, $thumb_file, "jpeg", "80");
830  ilUtil::convertImage($med_file, $thumb_file_small, "jpeg", "40");
831  }
832  }
833 
834  if ($a_size == "small") {
835  if (is_file($thumb_file_small)) {
836  $random = new \ilRandom();
837  return $this->getThumbnailDirectory("output") . "/" .
838  $this->getPurpose() . "_small.jpeg?dummy=" . $random->int(1, 999999);
839  }
840  } else {
841  if (is_file($thumb_file)) {
842  $random = new \ilRandom();
843  return $this->getThumbnailDirectory("output") . "/" .
844  $this->getPurpose() . ".jpeg?dummy=" . $random->int(1, 999999);
845  }
846  }
847  }
848 
849  return "";
850  }
getMobId()
get id of parent media object
getThumbnailDirectory($a_mode="filesystem")
get media file directory
getDirectory()
get media file directory
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
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 506 of file class.ilMediaItem.php.

Referenced by getThumbnailTarget().

507  {
508  return $this->tried_thumb;
509  }
+ Here is the caller graph for this function:

◆ getWidth()

ilMediaItem::getWidth ( )

get width

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

References $width.

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

554  {
555  return $this->width;
556  }
+ Here is the caller graph for this function:

◆ getWorkDirectory()

ilMediaItem::getWorkDirectory ( )

get work directory for image map editing

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

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

Referenced by createWorkDirectory(), and getMapWorkCopyName().

732  {
733  return ilUtil::getDataDir() . "/map_workfiles/item_" . $this->getId();
734  }
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 909 of file class.ilMediaItem.php.

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

910  {
911  $lng = $this->lng;
912 
913  if (!$this->copyOriginal()) {
914  return false;
915  }
916  $this->buildMapWorkImage();
917 
918  // determine ratios
919  $size = @getimagesize($this->getMapWorkCopyName());
920  $x_ratio = 1;
921  if ($size[0] > 0 && $this->getWidth() > 0) {
922  $x_ratio = $this->getWidth() / $size[0];
923  }
924  $y_ratio = 1;
925  if ($size[1] > 0 && $this->getHeight() > 0) {
926  $y_ratio = $this->getHeight() / $size[1];
927  }
928 
929  // draw map areas
930  for ($i=0; $i < count($this->mapareas); $i++) {
931  if (((($i+1) == $a_area_nr) && !$a_exclude) ||
932  ((($i+1) != $a_area_nr) && $a_exclude) ||
933  ($a_area_nr == 0)
934  ) {
935  $area = $this->mapareas[$i];
936  $area->draw(
937  $this->getMapWorkImage(),
938  $this->color1,
939  $this->color2,
940  true,
941  $x_ratio,
942  $y_ratio
943  );
944  }
945  }
946 
947  $this->saveMapWorkImage();
948 
949  return true;
950  }
$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
$i
Definition: disco.tpl.php:19
getHeight()
get height
+ Here is the call graph for this function:

◆ outputMapWorkCopy()

ilMediaItem::outputMapWorkCopy ( )

output raw map work copy file

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

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

994  {
995  if ($this->getMapWorkCopyType() != "") {
996  header("Pragma: no-cache");
997  header("Expires: 0");
998  header("Content-type: image/" . strtolower($this->getMapWorkCopyType()));
999  readfile($this->getMapWorkCopyName());
1000  }
1001  exit;
1002  }
getMapWorkCopyType()
get image type of image map work copy
getMapWorkCopyName($a_reference_copy=false)
Get name of image map work copy file.
Add a drawing to the header
Definition: 04printing.php:69
+ 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 241 of file class.ilMediaItem.php.

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

Referenced by __construct().

242  {
243  $ilDB = $this->db;
244 
245  $item_id = $this->getId();
246  $mob_id = $this->getMobId();
247  $nr = $this->getNr();
248  $query = "";
249  if ($item_id > 0) {
250  $query = "SELECT * FROM media_item WHERE id = " .
251  $ilDB->quote($this->getId(), "integer");
252  } elseif ($mob_id > 0 && $nr > 0) {
253  $query = "SELECT * FROM media_item WHERE mob_id = " .
254  $ilDB->quote($this->getMobId(), "integer") . " " .
255  "AND nr=" . $ilDB->quote($this->getNr(), "integer");
256  }
257  if ($query != "") {
258  $item_set = $ilDB->query($query);
259  $item_rec = $ilDB->fetchAssoc($item_set);
260 
261  $this->setLocation($item_rec["location"]);
262  $this->setLocationType($item_rec["location_type"]);
263  $this->setFormat($item_rec["format"]);
264  $this->setWidth($item_rec["width"]);
265  $this->setHeight($item_rec["height"]);
266  $this->setHAlign($item_rec["halign"]);
267  $this->setCaption($item_rec["caption"]);
268  $this->setPurpose($item_rec["purpose"]);
269  $this->setNr($item_rec["nr"]);
270  $this->setMobId($item_rec["mob_id"]);
271  $this->setId($item_rec["id"]);
272  $this->setThumbTried($item_rec["tried_thumb"]);
273  $this->setTextRepresentation($item_rec["text_representation"]);
274 
275  // get item parameter
276  $query = "SELECT * FROM mob_parameter WHERE med_item_id = " .
277  $ilDB->quote($this->getId(), "integer");
278  $par_set = $ilDB->query($query);
279  while ($par_rec = $ilDB->fetchAssoc($par_set)) {
280  $this->setParameter($par_rec["name"], $par_rec["value"]);
281  }
282 
283  // get item map areas
284  $max = ilMapArea::_getMaxNr($this->getId());
285  for ($i = 1; $i <= $max; $i++) {
286  $area = new ilMapArea($this->getId(), $i);
287  $this->addMapArea($area);
288  }
289  }
290  }
setCaption($a_caption)
set caption
getId()
get media item id
setId($a_id)
set media item id
setThumbTried($a_tried)
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
$i
Definition: disco.tpl.php:19
setFormat($a_format)
setWidth($a_width)
set width
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 655 of file class.ilMediaItem.php.

References array.

Referenced by setParameters().

656  {
657  $this->parameters = array();
658  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ saveMapWorkImage()

ilMediaItem::saveMapWorkImage ( )

save 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  // save image work-copy and free memory
1044  switch ($im_type) {
1045  case "gif":
1046  ImageGIF($this->map_image, $this->getMapWorkCopyName());
1047  break;
1048 
1049  case "jpg":
1050  case "jpeg":
1051  ImageJPEG($this->map_image, $this->getMapWorkCopyName());
1052  break;
1053 
1054  case "png":
1055  ImagePNG($this->map_image, $this->getMapWorkCopyName());
1056  break;
1057  }
1058 
1059  ImageDestroy($this->map_image);
1060  }
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 609 of file class.ilMediaItem.php.

Referenced by read().

610  {
611  $this->caption = $a_caption;
612  }
+ Here is the caller graph for this function:

◆ setFormat()

ilMediaItem::setFormat (   $a_format)

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

References format.

Referenced by read().

492  {
493  $this->format = $a_format;
494  }
Write to Excel2007 format
+ Here is the caller graph for this function:

◆ setHAlign()

ilMediaItem::setHAlign (   $a_halign)

set horizontal align

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

Referenced by read().

626  {
627  $this->halign = $a_halign;
628  }
+ Here is the caller graph for this function:

◆ setHeight()

ilMediaItem::setHeight (   $a_height)

set height

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

Referenced by read().

578  {
579  $this->height = $a_height;
580  }
+ 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 67 of file class.ilMediaItem.php.

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

68  {
69  $this->id = $a_id;
70  }
+ Here is the caller graph for this function:

◆ setLocation()

ilMediaItem::setLocation (   $a_location)

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

Referenced by read().

472  {
473  $this->location = $a_location;
474  }
+ Here is the caller graph for this function:

◆ setLocationType()

ilMediaItem::setLocationType (   $a_type)

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

References $a_type.

Referenced by read().

482  {
483  $this->location_type = $a_type;
484  }
$a_type
Definition: workflow.php:92
+ 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 87 of file class.ilMediaItem.php.

Referenced by read().

88  {
89  $this->mob_id = $a_mob_id;
90  }
+ 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 645 of file class.ilMediaItem.php.

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

646  {
647  if (self::checkParameter($a_name, $a_value)) {
648  $this->parameters[$a_name] = $a_value;
649  }
650  }
+ 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 665 of file class.ilMediaItem.php.

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

666  {
667  $this->resetParameters();
668  $par_arr = ilUtil::extractParameterString($a_par);
669  if (is_array($par_arr)) {
670  foreach ($par_arr as $par => $val) {
671  $this->setParameter($par, $val);
672  }
673  }
674  }
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 461 of file class.ilMediaItem.php.

Referenced by read().

462  {
463  $this->purpose = $a_purpose;
464  }
+ Here is the caller graph for this function:

◆ setTextRepresentation()

ilMediaItem::setTextRepresentation (   $a_val)

Set text representation.

Parameters
stringtext representation

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

Referenced by read().

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

◆ setThumbTried()

ilMediaItem::setThumbTried (   $a_tried)

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

Referenced by read().

502  {
503  $this->tried_thumb = $a_tried;
504  }
+ Here is the caller graph for this function:

◆ setWidth()

ilMediaItem::setWidth (   $a_width)

set width

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

Referenced by read().

562  {
563  $this->width = $a_width;
564  }
+ Here is the caller graph for this function:

◆ update()

ilMediaItem::update ( )

update media item data (without map areas!)

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

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

188  {
189  $ilDB = $this->db;
190 
191  $query = "UPDATE media_item SET " .
192  " mob_id = " . $ilDB->quote($this->getMobId(), "integer") . "," .
193  " purpose = " . $ilDB->quote($this->getPurpose(), "text") . "," .
194  " location = " . $ilDB->quote($this->getLocation(), "text") . "," .
195  " location_type = " . $ilDB->quote($this->getLocationType(), "text") . "," .
196  " format = " . $ilDB->quote($this->getFormat(), "text") . "," .
197  " width = " . $ilDB->quote($this->getWidth(), "text") . "," .
198  " height = " . $ilDB->quote($this->getHeight(), "text") . "," .
199  " halign = " . $ilDB->quote($this->getHAlign(), "text") . "," .
200  " caption = " . $ilDB->quote($this->getCaption(), "text") . "," .
201  " nr = " . $ilDB->quote($this->getNr(), "integer") . "," .
202  " text_representation = " . $ilDB->quote($this->getTextRepresentation(), "text") .
203  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
204  $ilDB->manipulate($query);
205 
206  // delete mob parameters
207  $query = "DELETE FROM mob_parameter WHERE med_item_id = " .
208  $ilDB->quote($this->getId(), "integer");
209 
210  // create mob parameters
211  $params = $this->getParameters();
212  foreach ($params as $name => $value) {
213  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
214  "(" . $ilDB->quote($this->getId(), "integer") . "," .
215  $ilDB->quote($name, "text") . "," .
216  $ilDB->quote($value, "text") . ")";
217  $ilDB->manipulate($query);
218  }
219  }
$params
Definition: disable.php:11
getId()
get media item id
getWidth()
get width
getMobId()
get id of parent media object
if($format !==null) $name
Definition: metadata.php:146
$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 227 of file class.ilMediaItem.php.

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

228  {
229  $ilDB = $this->db;
230 
231  $query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES " .
232  "(" . $ilDB->quote($this->getId(), "integer") . "," .
233  $ilDB->quote($a_name, "text") . "," .
234  $ilDB->quote($a_value, "text") . ")";
235  $ilDB->manipulate($query);
236  }
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 295 of file class.ilMediaItem.php.

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

Referenced by getThumbnailTarget().

296  {
297  $ilDB = $this->db;
298 
299  $q = "UPDATE media_item SET tried_thumb = " .
300  $ilDB->quote($a_tried, "text") .
301  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
302 
303  $ilDB->manipulate($q);
304  }
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 35 of file class.ilMediaItem.php.

Referenced by getCaption().

◆ $color1

ilMediaItem::$color1

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

◆ $color2

ilMediaItem::$color2

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

◆ $db

ilMediaItem::$db
protected

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

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

◆ $format

ilMediaItem::$format

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

Referenced by getFormat().

◆ $halign

ilMediaItem::$halign

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

Referenced by getHAlign().

◆ $height

ilMediaItem::$height

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

Referenced by getHeight().

◆ $id

ilMediaItem::$id

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

Referenced by getId().

◆ $lng

ilMediaItem::$lng
protected

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

Referenced by copyOriginal(), and makeMapWorkCopy().

◆ $location

ilMediaItem::$location

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

Referenced by getLocation().

◆ $location_type

ilMediaItem::$location_type

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

Referenced by getLocationType().

◆ $map_cnt

ilMediaItem::$map_cnt

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

Referenced by addMapArea(), and deleteMapArea().

◆ $map_image

ilMediaItem::$map_image

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

Referenced by getMapWorkImage().

◆ $mapareas

ilMediaItem::$mapareas

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

Referenced by getMapAreas().

◆ $mob_id

ilMediaItem::$mob_id

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

Referenced by getMobId(), and read().

◆ $nr

ilMediaItem::$nr

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

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

◆ $parameters

ilMediaItem::$parameters

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

Referenced by getParameters().

◆ $purpose

ilMediaItem::$purpose

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

Referenced by getPurpose().

◆ $width

ilMediaItem::$width

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

Referenced by getWidth().


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