ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMediaItem Class Reference

Class ilMediaItem. More...

+ Collaboration diagram for ilMediaItem:

Public Member Functions

 ilMediaItem ($a_id=0)
 setId ($a_id)
 set media item id
 getId ()
 get media item id
 setMobId ($a_mob_id)
 set id of parent media object
 getMobId ()
 get id of parent media object
 setNr ($a_nr)
 set number of media item within media object
 getNr ()
 setTextRepresentation ($a_val)
 Set text representation.
 getTextRepresentation ()
 Get text representation.
 create ()
 create persistent media item
 update ()
 update media item data (without map areas!)
 read ()
 read media item data (item id or (mob_id and nr) must be set)
 writeThumbTried ($a_tried)
 write thumbnail creation try data ("y"/"n")
 _getMediaItemsOfMObId ($a_mobId, $a_purpose)
 _getMediaItemsOfMOb (&$a_mob)
 read media items into media objects (static)
 deleteAllItemsOfMob ($a_mob_id)
 static
 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
getMapArea ($nr)
 get map area
 getMapAreas ()
 get map areas
 getWidth ()
 get width
 setWidth ($a_width)
 set width
 getHeight ()
 get height
 setHeight ($a_height)
 set height
 getOriginalSize ()
 get original size
 setCaption ($a_caption)
 set caption
 getCaption ()
 get caption
 setHAlign ($a_halign)
 set horizontal align
 getHAlign ()
 get horizontal align
 setParameter ($a_name, $a_value)
 set parameter
 resetParameters ()
 reset parameters
 setParameters ($a_par)
 set alle parameters via parameter string (format: par1="value1", par2="value2", ...)
 getParameters ()
 get all parameters (in array)
 getParameterString ()
 get all parameters (as string)
 getParameter ($a_name)
 get a single parameter
 getWorkDirectory ()
 get work directory for image map editing
 createWorkDirectory ()
 create work directory for image map editing
 getSuffix ()
 get location suffix
 getMapWorkCopyType ()
 get image type of image map work copy
 getMapWorkCopyName ($a_reference_copy=false)
 Get name of image map work copy file.
 getDirectory ()
 get media file directory
 getThumbnailDirectory ($a_mode="filesystem")
 get media file directory
 getThumbnailTarget ($a_size="")
 get thumbnail target
 copyOriginal ()
 Copy the orginal file.
 makeMapWorkCopy ($a_area_nr=0, $a_exclude=false)
 make map work copy of image
 addAreaToMapWorkCopy ($a_shape, $a_coords)
 draw a new area in work image
 outputMapWorkCopy ()
 output raw map work copy file
 buildMapWorkImage ()
 build image map work image
 saveMapWorkImage ()
 save image map work image
getMapWorkImage ()
 get image map work image
 getMapAreasXML ($a_insert_inst=false, $a_inst=0)
 get xml code of media items' areas
 _resolveMapAreaLinks ($a_mob_id)
 resolve internal links of all media items of a media object
 _getMapAreasIntLinks ($a_mob_id)
 get all internal links of map areas of a mob
 extractUrlParameters ()
 Extract parameters of special external references to parameter array.

Static Public Member Functions

static _lookupLocationForMobId ($a_mob_id, $a_purpose)
 Lookup location for mob id.
static _lookupMobId ($a_med_id)
 Lookup Mob ID.

Data Fields

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

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:
class.ilMediaItem.php 22827 2010-01-22 22:45:39Z akill

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

Member Function Documentation

ilMediaItem::_getMapAreasIntLinks (   $a_mob_id)

get all internal links of map areas of a mob

Parameters
int$a_mob_idmedia object id

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

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

Referenced by ilPageObjectGUI\displayMediaFullscreen(), ilPageObject\getInternalLinks(), ilLMPresentationGUI\ilMedia(), ilGlossaryPresentationGUI\media(), and ilObjMediaPoolGUI\showMedia().

{
global $ilDB;
// read media_items records
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob_id, "integer")." ORDER BY nr";
$item_set = $ilDB->query($query);
$links = array();
while ($item_rec = $ilDB->fetchAssoc($item_set))
{
$map_links = ilMapArea::_getIntLinks($item_rec["id"]);
foreach($map_links as $key => $map_link)
{
$links[$key] = $map_link;
}
}
return $links;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::_getMediaItemsOfMOb ( $a_mob)

read media items into media objects (static)

Parameters
object$a_mobmedia object

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

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

Referenced by ilObjMediaObject\read().

{
global $ilDB;
// read media_object record
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob->getId(), "integer")." ".
"ORDER BY nr";
$item_set = $ilDB->query($query);
while ($item_rec = $ilDB->fetchAssoc($item_set))
{
$media_item =& new ilMediaItem();
$media_item->setNr($item_rec["nr"]);
$media_item->setId($item_rec["id"]);
$media_item->setLocation($item_rec["location"]);
$media_item->setLocationType($item_rec["location_type"]);
$media_item->setFormat($item_rec["format"]);
$media_item->setWidth($item_rec["width"]);
$media_item->setHeight($item_rec["height"]);
$media_item->setHAlign($item_rec["halign"]);
$media_item->setCaption($item_rec["caption"]);
$media_item->setPurpose($item_rec["purpose"]);
$media_item->setMobId($item_rec["mob_id"]);
$media_item->setThumbTried($item_rec["tried_thumb"]);
$media_item->setTextRepresentation($item_rec["text_representation"]);
// get item parameter
$query = "SELECT * FROM mob_parameter WHERE med_item_id = ".
$ilDB->quote($item_rec["id"], "integer");
$par_set = $ilDB->query($query);
while ($par_rec = $ilDB->fetchAssoc($par_set))
{
$media_item->setParameter($par_rec["name"], $par_rec["value"]);
}
// get item map areas
$max = ilMapArea::_getMaxNr($media_item->getId());
for ($i = 1; $i <= $max; $i++)
{
$area =& new ilMapArea($media_item->getId(), $i);
$media_item->addMapArea($area);
}
// add media item to media object
$a_mob->addMediaItem($media_item);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::_getMediaItemsOfMObId (   $a_mobId,
  $a_purpose 
)

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

References $ilDB, and $query.

Referenced by ilObjectFeedWriter\ilObjectFeedWriter().

{
global $ilDB;
// read media_object record
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mobId, "integer")." ".
"AND purpose=" . $ilDB->quote($a_purpose, "text")." ORDER BY nr";
$item_set = $ilDB->query($query);
while ($item_rec = $ilDB->fetchAssoc($item_set))
{
return $item_rec;
}
return false;
}

+ Here is the caller graph for this function:

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

References $ilDB, and $query.

Referenced by ilObjMediaObject\_lookupItemPath().

{
global $ilDB;
// read media_object record
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob_id, "integer")." ".
"AND purpose = ".$ilDB->quote($a_purpose, "text");
$set = $ilDB->query($query);
if ($rec = $ilDB->fetchAssoc($set))
{
return $rec["location"];
}
return "";
}

+ Here is the caller graph for this function:

static ilMediaItem::_lookupMobId (   $a_med_id)
static

Lookup Mob ID.

Parameters
int$a_med_idmedia item id

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

References $ilDB, and $query.

Referenced by ilMapArea\_getMobsForTarget().

{
global $ilDB;
// read media_object record
$query = "SELECT * FROM media_item WHERE id = ".
$ilDB->quote($a_med_id, "integer");
$set = $ilDB->query($query);
if ($rec = $ilDB->fetchAssoc($set))
{
return $rec["mob_id"];
}
return "";
}

+ Here is the caller graph for this function:

ilMediaItem::_resolveMapAreaLinks (   $a_mob_id)

resolve internal links of all media items of a media object

Parameters
int$a_mob_idmedia object id

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

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

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

{
global $ilDB;
//echo "mediaItems::resolve<br>";
// read media_object record
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob_id, "integer")." ".
"ORDER BY nr";
$item_set = $ilDB->query($query);
while ($item_rec = $ilDB->fetchAssoc($item_set))
{
ilMapArea::_resolveIntLinks($item_rec["id"]);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::addAreaToMapWorkCopy (   $a_shape,
  $a_coords 
)

draw a new area in work image

Parameters
string$a_shapeshape
string$a_coordscoordinates string

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

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

{
// determine ratios
$size = @getimagesize($this->getMapWorkCopyName());
$x_ratio = 1;
if ($size[0] > 0 && $this->getWidth() > 0)
{
$x_ratio = $this->getWidth() / $size[0];
}
$y_ratio = 1;
if ($size[1] > 0 && $this->getHeight() > 0)
{
$y_ratio = $this->getHeight() / $size[1];
}
// add new area to work image
$area = new ilMapArea();
$area->setShape($a_shape);
$area->setCoords($a_coords);
$area->draw($this->getMapWorkImage(), $this->color1, $this->color2, false,
$x_ratio, $y_ratio);
$this->saveMapWorkImage();
}

+ Here is the call graph for this function:

ilMediaItem::addMapArea ( $a_map_area)

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

References $map_cnt.

Referenced by read().

{
$this->mapareas[$this->map_cnt] =& $a_map_area;
$this->map_cnt++;
}

+ Here is the caller graph for this function:

ilMediaItem::buildMapWorkImage ( )

build image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

{
$im_type = strtolower($this->getMapWorkCopyType());
switch ($im_type)
{
case "gif":
$this->map_image = ImageCreateFromGIF($this->getMapWorkCopyName());
break;
case "jpg":
$this->map_image = ImageCreateFromJPEG($this->getMapWorkCopyName());
break;
case "png":
$this->map_image = ImageCreateFromPNG($this->getMapWorkCopyName());
break;
}
// try to allocate black and white as color. if this is not possible, get the closest colors
if (imagecolorstotal($this->map_image) > 250)
{
$this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
$this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
}
else
{
$this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
$this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::copyOriginal ( )

Copy the orginal file.

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

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

Referenced by makeMapWorkCopy().

{
global $lng;
if ($this->getLocationType() != "Reference")
{
$this->getMapWorkCopyType());
}
else
{
// first copy the external file, if necessary
if (!is_file($this->getMapWorkCopyName(true)) || (filesize($this->getMapWorkCopyName(true)) == 0))
{
$handle = @fopen($this->getLocation(), "r");
$lcopy = fopen($this->getMapWorkCopyName(true), "w");
if ($handle && $lcopy)
{
while (!feof($handle))
{
$content = fread($handle, 4096);
fwrite($lcopy, $content);
}
}
@fclose($lcopy);
@fclose($handle);
}
// now, create working copy
$this->getMapWorkCopyType());
}
if (!is_file($this->getMapWorkCopyName()))
{
ilUtil::sendFailure($lng->txt("cont_map_file_not_generated"));
return false;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::create ( )

create persistent media item

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

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

{
global $ilDB;
$item_id = $ilDB->nextId("media_item");
$query = "INSERT INTO media_item (id,mob_id, purpose, location, ".
"location_type, format, width, ".
"height, halign, caption, nr, text_representation) VALUES ".
"(".
$ilDB->quote($item_id, "integer").",".
$ilDB->quote($this->getMobId(), "integer").",".
$ilDB->quote($this->getPurpose(), "text").",".
$ilDB->quote($this->getLocation(), "text").",".
$ilDB->quote($this->getLocationType(), "text").",".
$ilDB->quote($this->getFormat(), "text").",".
$ilDB->quote($this->getWidth(), "text").",".
$ilDB->quote($this->getHeight(), "text").",".
$ilDB->quote($this->getHAlign(), "text").",".
$ilDB->quote($this->getCaption(), "text").",".
$ilDB->quote($this->getNr(), "integer").",".
$ilDB->quote($this->getTextRepresentation(), "text").")";
$ilDB->manipulate($query);
$this->setId($item_id);
// create mob parameters
$params = $this->getParameters();
foreach($params as $name => $value)
{
$query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
"(".$ilDB->quote($item_id, "integer").",".
$ilDB->quote($name, "text").",".
$ilDB->quote($value, "text").")";
$ilDB->manipulate($query);
}
// create map areas
for ($i=0; $i < count($this->mapareas); $i++)
{
$this->mapareas[$i]->setItemId($this->getId());
$this->mapareas[$i]->setNr($i + 1);
$this->mapareas[$i]->create();
}
}

+ Here is the call graph for this function:

ilMediaItem::createWorkDirectory ( )

create work directory for image map editing

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

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

Referenced by copyOriginal().

{
if(!@is_dir(ilUtil::getDataDir()."/map_workfiles"))
{
}
$work_dir = $this->getWorkDirectory();
if(!@is_dir($work_dir))
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::deleteAllItemsOfMob (   $a_mob_id)

static

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

References $ilDB, and $query.

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

{
global $ilDB;
// iterate all media items ob mob
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob_id, "integer");
$item_set = $ilDB->query($query);
while ($item_rec = $ilDB->fetchAssoc($item_set))
{
// delete all parameters of media item
$query = "DELETE FROM mob_parameter WHERE med_item_id = ".
$ilDB->quote($item_rec["id"], "integer");
$ilDB->manipulate($query);
// delete all map areas of media item
$query = "DELETE FROM map_area WHERE item_id = ".
$ilDB->quote($item_rec["id"], "integer");
$ilDB->manipulate($query);
}
// delete media items
$query = "DELETE FROM media_item WHERE mob_id = ".
$ilDB->quote($a_mob_id, "integer");
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

ilMediaItem::deleteMapArea (   $nr)

delete map area

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

References $map_cnt, and $nr.

{
for ($i=1; $i<=$this->map_cnt; $i++)
{
if($i > $nr)
{
$this->mapareas[$i-2] =& $this->mapareas[$i-1];
$this->mapareas[$i-2]->setNr($i-1);
}
}
if($nr <= $this->map_cnt)
{
unset($this->mapareas[$this->map_cnt - 1]);
$this->map_cnt--;
}
}
ilMediaItem::extractUrlParameters ( )

Extract parameters of special external references to parameter array.

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

References getLocation(), getParameters(), and setParameter().

{
include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
$this->getLocation(), $this->getParameters());
foreach ($par as $k => $v)
{
$this->setParameter($k, $v);
}
}

+ Here is the call graph for this function:

ilMediaItem::getCaption ( )

get caption

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

References $caption.

Referenced by create(), and update().

{
}

+ Here is the caller graph for this function:

ilMediaItem::getDirectory ( )

get media file directory

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

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

Referenced by copyOriginal(), and getThumbnailTarget().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::getFormat ( )

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

References $format.

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

{
return $this->format;
}

+ Here is the caller graph for this function:

ilMediaItem::getHAlign ( )

get horizontal align

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

References $halign.

Referenced by create(), and update().

{
return $this->halign;
}

+ Here is the caller graph for this function:

ilMediaItem::getHeight ( )

get height

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

References $height.

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

{
return $this->height;
}

+ Here is the caller graph for this function:

ilMediaItem::getId ( )

get media item id

Returns
int media item id

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

References $id.

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

{
return $this->id;
}

+ Here is the caller graph for this function:

ilMediaItem::getLocation ( )

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

References $location.

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

{
}

+ Here is the caller graph for this function:

ilMediaItem::getLocationType ( )

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

References $location_type.

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

{
}

+ Here is the caller graph for this function:

& ilMediaItem::getMapArea (   $nr)

get map area

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

References $nr.

{
return $this->mapareas[$nr-1];
}
ilMediaItem::getMapAreas ( )

get map areas

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

References $mapareas.

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

get xml code of media items' areas

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

References IL_INT_LINK.

{
$xml = "";
// build xml of map areas
for ($i=0; $i < count($this->mapareas); $i++)
{
$area =& $this->mapareas[$i];
$xml .= "<MapArea Shape=\"".$area->getShape()."\" Coords=\"".$area->getCoords()."\">";
if ($area->getLinkType() == IL_INT_LINK)
{
$target_frame = $area->getTargetFrame();
if ($area->getType() == "GlossaryItem" && $target_frame == "")
{
$target_frame = "Glossary";
}
$tf_str = ($target_frame == "")
? ""
: "TargetFrame=\"".$target_frame."\"";
$xml .= "<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst)."\" Type=\"".
$area->getType()."\" $tf_str>";
$xml .= $area->getTitle();
$xml .="</IntLink>";
}
else
{
$xml .= "<ExtLink Href=\"".str_replace("&", "&amp;",$area->getHref())."\" Title=\"".
$area->getExtTitle()."\">";
$xml .= $area->getTitle();
$xml .="</ExtLink>";
}
$xml .= "</MapArea>";
}
return $xml;
}
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 729 of file class.ilMediaItem.php.

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

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

{
$file_arr = explode("/", $this->getLocation());
$o_file = $file_arr[count($file_arr) - 1];
$file_arr = explode(".", $o_file);
unset($file_arr[count($file_arr) - 1]);
$file = implode($file_arr, ".");
//$file = "wcopy";
if (!$a_reference_copy)
{
return $this->getWorkDirectory()."/".$file.".".$this->getMapWorkCopyType();
}
else
{
return $this->getWorkDirectory()."/l_copy_".$o_file;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::getMapWorkCopyType ( )

get image type of image map work copy

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilMediaItem::getMapWorkImage ( )

get image map work image

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

References $map_image.

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

{
}

+ Here is the caller graph for this function:

ilMediaItem::getMobId ( )

get id of parent media object

Returns
int media object id

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

References $mob_id.

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

{
return $this->mob_id;
}

+ Here is the caller graph for this function:

ilMediaItem::getNr ( )

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

References $nr.

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

{
return $this->nr;
}

+ Here is the caller graph for this function:

ilMediaItem::getOriginalSize ( )

get original size

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

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

{
{
if ($this->getLocationType() == "LocalFile")
{
$loc = $mob_dir."/".$this->getLocation();
}
else
{
$loc = $this->getLocation();
}
$size = @getimagesize($loc);
if ($size[0] > 0 && $size[1] > 0)
{
return array("width" => $size[0], "height" => $size[1]);
}
}
return false;
}

+ Here is the call graph for this function:

ilMediaItem::getParameter (   $a_name)

get a single parameter

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

{
return $this->parameters[$a_name];
}
ilMediaItem::getParameters ( )

get all parameters (in array)

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

References $parameters.

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

{
}

+ Here is the caller graph for this function:

ilMediaItem::getParameterString ( )

get all parameters (as string)

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

References ilUtil\assembleParameterString().

{
return ilUtil::assembleParameterString($this->parameters);
}

+ Here is the call graph for this function:

ilMediaItem::getPurpose ( )

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

References $purpose.

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

{
}

+ Here is the caller graph for this function:

ilMediaItem::getSuffix ( )

get location suffix

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

References getLocation().

Referenced by getMapWorkCopyType().

{
$loc_arr = explode(".", $this->getLocation());
return $loc_arr[count($loc_arr) - 1];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::getTextRepresentation ( )

Get text representation.

Returns
string text representation

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

Referenced by create(), and update().

{
return $this->text_representation;
}

+ Here is the caller graph for this function:

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

get media file directory

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

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

Referenced by getThumbnailTarget().

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::getThumbnailTarget (   $a_size = "")

get thumbnail target

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

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

{
if (is_int(strpos($this->getFormat(), "image")))
{
$thumb_file = $this->getThumbnailDirectory()."/".
$this->getPurpose().".jpeg";
$thumb_file_small = $this->getThumbnailDirectory()."/".
$this->getPurpose()."_small.jpeg";
// generate thumbnail (if not tried before)
if ($this->getThumbTried() == "n" && $this->getLocationType() == "LocalFile")
{
if (is_file($thumb_file))
{
unlink($thumb_file);
}
if (is_file($thumb_file_small))
{
unlink($thumb_file_small);
}
$this->writeThumbTried("y");
$med_file = $this->getDirectory()."/".$this->getLocation();
if (is_file($med_file))
{
ilUtil::convertImage($med_file, $thumb_file, "jpeg", "80");
ilUtil::convertImage($med_file, $thumb_file_small, "jpeg", "40");
}
}
if ($a_size == "small")
{
if (is_file($thumb_file_small))
{
return $this->getThumbnailDirectory("output")."/".
$this->getPurpose()."_small.jpeg?dummy=".rand(1, 999999);
}
}
else
{
if (is_file($thumb_file))
{
return $this->getThumbnailDirectory("output")."/".
$this->getPurpose().".jpeg?dummy=".rand(1, 999999);
}
}
}
return "";
}

+ Here is the call graph for this function:

ilMediaItem::getThumbTried ( )

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

Referenced by getThumbnailTarget().

{
return $this->tried_thumb;
}

+ Here is the caller graph for this function:

ilMediaItem::getWidth ( )

get width

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

References $width.

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

{
return $this->width;
}

+ Here is the caller graph for this function:

ilMediaItem::getWorkDirectory ( )

get work directory for image map editing

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

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

Referenced by createWorkDirectory(), and getMapWorkCopyName().

{
return ilUtil::getDataDir()."/map_workfiles/item_".$this->getId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::ilMediaItem (   $a_id = 0)

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

References read(), and setId().

Referenced by _getMediaItemsOfMOb().

{
$this->parameters = array();
$this->mapareas = array();
$this->map_cnt = 0;
if ($a_id != 0)
{
$this->setId($a_id);
$this->read();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
global $lng;
if (!$this->copyOriginal())
{
return false;
}
// determine ratios
$size = @getimagesize($this->getMapWorkCopyName());
$x_ratio = 1;
if ($size[0] > 0 && $this->getWidth() > 0)
{
$x_ratio = $this->getWidth() / $size[0];
}
$y_ratio = 1;
if ($size[1] > 0 && $this->getHeight() > 0)
{
$y_ratio = $this->getHeight() / $size[1];
}
// draw map areas
for ($i=0; $i < count($this->mapareas); $i++)
{
if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
((($i+1) != $a_area_nr) && $a_exclude) ||
($a_area_nr == 0)
)
{
$area =& $this->mapareas[$i];
$area->draw($this->getMapWorkImage(), $this->color1, $this->color2, true,
$x_ratio, $y_ratio);
}
}
$this->saveMapWorkImage();
return true;
}

+ Here is the call graph for this function:

ilMediaItem::outputMapWorkCopy ( )

output raw map work copy file

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

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

{
if ($this->getMapWorkCopyType() != "")
{
header("Pragma: no-cache");
header("Expires: 0");
header("Content-type: image/".strtolower($this->getMapWorkCopyType()));
readfile($this->getMapWorkCopyName());
}
}

+ Here is the call graph for this function:

ilMediaItem::read ( )

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

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

References $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 ilMediaItem().

{
global $ilDB;
$item_id = $this->getId();
$mob_id = $this->getMobId();
$nr = $this->getNr();
$query = "";
if($item_id > 0)
{
$query = "SELECT * FROM media_item WHERE id = ".
$ilDB->quote($this->getId(), "integer");
}
else if ($mob_id > 0 && $nr > 0)
{
$query = "SELECT * FROM media_item WHERE mob_id = ".
$ilDB->quote($this->getMobId(), "integer")." ".
"AND nr=".$ilDB->quote($this->getNr(), "integer");
}
if ($query != "")
{
$item_set = $ilDB->query($query);
$item_rec = $ilDB->fetchAssoc($item_set);
$this->setLocation($item_rec["location"]);
$this->setLocationType($item_rec["location_type"]);
$this->setFormat($item_rec["format"]);
$this->setWidth($item_rec["width"]);
$this->setHeight($item_rec["height"]);
$this->setHAlign($item_rec["halign"]);
$this->setCaption($item_rec["caption"]);
$this->setPurpose($item_rec["purpose"]);
$this->setNr($item_rec["nr"]);
$this->setMobId($item_rec["mob_id"]);
$this->setId($item_rec["id"]);
$this->setThumbTried($item_rec["tried_thumb"]);
$this->setTextRepresentation($item_rec["text_representation"]);
// get item parameter
$query = "SELECT * FROM mob_parameter WHERE med_item_id = ".
$ilDB->quote($this->getId(), "integer");
$par_set = $ilDB->query($query);
while ($par_rec = $ilDB->fetchAssoc($par_set))
{
$this->setParameter($par_rec["name"], $par_rec["value"]);
}
// get item map areas
$max = ilMapArea::_getMaxNr($this->getId());
for ($i = 1; $i <= $max; $i++)
{
$area =& new ilMapArea($this->getId(), $i);
$this->addMapArea($area);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::resetParameters ( )

reset parameters

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

Referenced by setParameters().

{
$this->parameters = array();
}

+ Here is the caller graph for this function:

ilMediaItem::saveMapWorkImage ( )

save image map work image

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

References getMapWorkCopyName(), and getMapWorkCopyType().

Referenced by addAreaToMapWorkCopy(), and makeMapWorkCopy().

{
$im_type = strtolower($this->getMapWorkCopyType());
// save image work-copy and free memory
switch ($im_type)
{
case "gif":
ImageGIF($this->map_image, $this->getMapWorkCopyName());
break;
case "jpg":
ImageJPEG($this->map_image, $this->getMapWorkCopyName());
break;
case "png":
ImagePNG($this->map_image, $this->getMapWorkCopyName());
break;
}
ImageDestroy($this->map_image);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaItem::setCaption (   $a_caption)

set caption

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

Referenced by read().

{
$this->caption = $a_caption;
}

+ Here is the caller graph for this function:

ilMediaItem::setFormat (   $a_format)

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

Referenced by read().

{
$this->format = $a_format;
}

+ Here is the caller graph for this function:

ilMediaItem::setHAlign (   $a_halign)

set horizontal align

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

Referenced by read().

{
$this->halign = $a_halign;
}

+ Here is the caller graph for this function:

ilMediaItem::setHeight (   $a_height)

set height

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

Referenced by read().

{
$this->height = $a_height;
}

+ Here is the caller graph for this function:

ilMediaItem::setId (   $a_id)

set media item id

Parameters
int$a_idmedia item id

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

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

{
$this->id = $a_id;
}

+ Here is the caller graph for this function:

ilMediaItem::setLocation (   $a_location)

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

Referenced by read().

{
$this->location = $a_location;
}

+ Here is the caller graph for this function:

ilMediaItem::setLocationType (   $a_type)

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

Referenced by read().

{
$this->location_type = $a_type;
}

+ Here is the caller graph for this function:

ilMediaItem::setMobId (   $a_mob_id)

set id of parent media object

Parameters
int$a_mob_idmedia object id

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

Referenced by read().

{
$this->mob_id = $a_mob_id;
}

+ Here is the caller graph for this function:

ilMediaItem::setNr (   $a_nr)

set number of media item within media object

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

Referenced by read().

{
$this->nr = $a_nr;
}

+ Here is the caller graph for this function:

ilMediaItem::setParameter (   $a_name,
  $a_value 
)

set parameter

Parameters
string$a_nameparameter name
string$a_valueparameter value

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

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

{
$this->parameters[$a_name] = $a_value;
}

+ Here is the caller graph for this function:

ilMediaItem::setParameters (   $a_par)

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

Parameters
string$a_parparameter string

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

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

{
$this->resetParameters();
$par_arr = ilUtil::extractParameterString($a_par);
if(is_array($par_arr))
{
foreach($par_arr as $par => $val)
{
$this->setParameter($par, $val);
}
}
}

+ Here is the call graph for this function:

ilMediaItem::setPurpose (   $a_purpose)

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

Referenced by read().

{
$this->purpose = $a_purpose;
}

+ Here is the caller graph for this function:

ilMediaItem::setTextRepresentation (   $a_val)

Set text representation.

Parameters
stringtext representation

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

Referenced by read().

{
$this->text_representation = $a_val;
}

+ Here is the caller graph for this function:

ilMediaItem::setThumbTried (   $a_tried)

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

Referenced by read().

{
$this->tried_thumb = $a_tried;
}

+ Here is the caller graph for this function:

ilMediaItem::setWidth (   $a_width)

set width

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

Referenced by read().

{
$this->width = $a_width;
}

+ Here is the caller graph for this function:

ilMediaItem::update ( )

update media item data (without map areas!)

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

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

{
global $ilDB;
$query = "UPDATE media_item SET ".
" mob_id = ".$ilDB->quote($this->getMobId(), "integer").",".
" purpose = ".$ilDB->quote($this->getPurpose(), "text").",".
" location = ".$ilDB->quote($this->getLocation(), "text").",".
" location_type = ".$ilDB->quote($this->getLocationType(), "text").",".
" format = ".$ilDB->quote($this->getFormat(), "text").",".
" width = ".$ilDB->quote($this->getWidth(), "text").",".
" height = ".$ilDB->quote($this->getHeight(), "text").",".
" halign = ".$ilDB->quote($this->getHAlign(), "text").",".
" caption = ".$ilDB->quote($this->getCaption(), "text").",".
" nr = ".$ilDB->quote($this->getNr(), "integer").
" text_representation = ".$ilDB->quote($this->getTextRepresentation(), "text").
" WHERE id = ".$ilDB->quote($this->getId(), "integer");
$ilDB->manipulate($query);
// delete mob parameters
$query = "DELETE FROM mob_parameter WHERE med_item_id = ".
$ilDB->quote($this->getId(), "integer");
// create mob parameters
$params = $this->getParameters();
foreach($params as $name => $value)
{
$query = "INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
"(".$ilDB->quote($this->getId(), "integer").",".
$ilDB->quote($name, "text").",".
$ilDB->quote($value, "text").")";
$ilDB->manipulate($query);
}
}

+ Here is the call graph for this function:

ilMediaItem::writeThumbTried (   $a_tried)

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

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

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

Referenced by getThumbnailTarget().

{
global $ilDB;
$q = "UPDATE media_item SET tried_thumb = ".
$ilDB->quote($a_tried, "text").
" WHERE id = ".$ilDB->quote($this->getId(), "integer");
$ilDB->manipulate($q);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilMediaItem::$caption

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

Referenced by getCaption().

ilMediaItem::$color1

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

ilMediaItem::$color2

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

ilMediaItem::$format

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

Referenced by getFormat().

ilMediaItem::$halign

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

Referenced by getHAlign().

ilMediaItem::$height

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

Referenced by getHeight().

ilMediaItem::$id

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

Referenced by getId().

ilMediaItem::$location

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

Referenced by getLocation().

ilMediaItem::$location_type

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

Referenced by getLocationType().

ilMediaItem::$map_cnt

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

Referenced by addMapArea(), and deleteMapArea().

ilMediaItem::$map_image

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

Referenced by getMapWorkImage().

ilMediaItem::$mapareas

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

Referenced by getMapAreas().

ilMediaItem::$mob_id

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

Referenced by getMobId(), and read().

ilMediaItem::$nr

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

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

ilMediaItem::$parameters

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

Referenced by getParameters().

ilMediaItem::$purpose

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

Referenced by getPurpose().

ilMediaItem::$width

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

Referenced by getWidth().


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