4 require_once(
"Services/MediaObjects/classes/class.ilMapArea.php");
 
   38                 $this->parameters = array();
 
   39                 $this->mapareas = array();
 
   76                 $this->mob_id = $a_mob_id;
 
  109                 $this->text_representation = $a_val;
 
  119                 return $this->text_representation;
 
  129                 $item_id = $ilDB->nextId(
"media_item");
 
  130                 $query = 
"INSERT INTO media_item (id,mob_id, purpose, location, ".
 
  131                         "location_type, format, width, ".
 
  132                         "height, halign, caption, nr, text_representation) VALUES ".
 
  134                         $ilDB->quote($item_id, 
"integer").
",".
 
  135                         $ilDB->quote($this->
getMobId(), 
"integer").
",".
 
  136                         $ilDB->quote($this->
getPurpose(), 
"text").
",".
 
  139                         $ilDB->quote($this->
getFormat(), 
"text").
",".
 
  140                         $ilDB->quote($this->
getWidth(), 
"text").
",".
 
  141                         $ilDB->quote($this->
getHeight(), 
"text").
",".
 
  142                         $ilDB->quote($this->
getHAlign(), 
"text").
",".
 
  143                         $ilDB->quote($this->
getCaption(), 
"text").
",".
 
  144                         $ilDB->quote($this->
getNr(), 
"integer").
",".
 
  146                 $ilDB->manipulate(
$query);
 
  148                 $this->
setId($item_id);
 
  152                 foreach($params as $name => $value)
 
  154                         $query = 
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
 
  155                                 "(".$ilDB->quote($item_id, 
"integer").
",".
 
  156                                 $ilDB->quote($name, 
"text").
",".
 
  157                                 $ilDB->quote($value, 
"text").
")";
 
  158                         $ilDB->manipulate(
$query);
 
  162                 for ($i=0; $i < count($this->mapareas); $i++)
 
  164                         if (is_object($this->mapareas[$i]))
 
  166                                 $this->mapareas[$i]->setItemId($this->
getId());
 
  167                                 $this->mapareas[$i]->setNr($i + 1);
 
  168                                 $this->mapareas[$i]->create();
 
  180                 $query = 
"UPDATE media_item SET ".
 
  181                         " mob_id = ".$ilDB->quote($this->
getMobId(), 
"integer").
",".
 
  182                         " purpose = ".$ilDB->quote($this->
getPurpose(), 
"text").
",".
 
  183                         " location = ".$ilDB->quote($this->
getLocation(), 
"text").
",".
 
  184                         " location_type = ".$ilDB->quote($this->
getLocationType(), 
"text").
",".
 
  185                         " format = ".$ilDB->quote($this->
getFormat(), 
"text").
",".
 
  186                         " width = ".$ilDB->quote($this->
getWidth(), 
"text").
",".
 
  187                         " height = ".$ilDB->quote($this->
getHeight(), 
"text").
",".
 
  188                         " halign = ".$ilDB->quote($this->
getHAlign(), 
"text").
",".
 
  189                         " caption = ".$ilDB->quote($this->
getCaption(), 
"text").
",".
 
  190                         " nr = ".$ilDB->quote($this->
getNr(), 
"integer").
 
  192                         " WHERE id = ".$ilDB->quote($this->
getId(), 
"integer");
 
  193                 $ilDB->manipulate(
$query);
 
  196                 $query = 
"DELETE FROM mob_parameter WHERE med_item_id = ".
 
  197                         $ilDB->quote($this->
getId(), 
"integer");
 
  201                 foreach($params as $name => $value)
 
  203                         $query = 
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
 
  204                                 "(".$ilDB->quote($this->
getId(), 
"integer").
",".
 
  205                                 $ilDB->quote($name, 
"text").
",".
 
  206                                 $ilDB->quote($value, 
"text").
")";
 
  207                         $ilDB->manipulate(
$query);
 
  221                 $query = 
"INSERT INTO mob_parameter (med_item_id, name, value) VALUES ".
 
  222                         "(".$ilDB->quote($this->
getId(), 
"integer").
",".
 
  223                         $ilDB->quote($a_name, 
"text").
",".
 
  224                         $ilDB->quote($a_value, 
"text").
")";
 
  225                 $ilDB->manipulate(
$query);
 
  235                 $item_id = $this->
getId();
 
  241                         $query = 
"SELECT * FROM media_item WHERE id = ".
 
  242                                 $ilDB->quote($this->
getId(), 
"integer");
 
  246                         $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
  247                                 $ilDB->quote($this->
getMobId(), 
"integer").
" ".
 
  248                                 "AND nr=".$ilDB->quote($this->
getNr(), 
"integer");
 
  252                         $item_set = $ilDB->query(
$query);
 
  253                         $item_rec = $ilDB->fetchAssoc($item_set);
 
  258                         $this->
setWidth($item_rec[
"width"]);
 
  263                         $this->
setNr($item_rec[
"nr"]);
 
  264                         $this->
setMobId($item_rec[
"mob_id"]);
 
  265                         $this->
setId($item_rec[
"id"]);
 
  270                         $query = 
"SELECT * FROM mob_parameter WHERE med_item_id = ".
 
  271                                 $ilDB->quote($this->
getId(), 
"integer");
 
  272                         $par_set = $ilDB->query(
$query);
 
  273                         while ($par_rec = $ilDB->fetchAssoc($par_set))
 
  275                                 $this->
setParameter($par_rec[
"name"], $par_rec[
"value"]);
 
  280                         for ($i = 1; $i <= $max; $i++)
 
  296                 $q = 
"UPDATE media_item SET tried_thumb = ".
 
  297                         $ilDB->quote($a_tried, 
"text").
 
  298                         " WHERE id = ".$ilDB->quote($this->
getId(), 
"integer");
 
  300                 $ilDB->manipulate($q);
 
  314                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
  315                         $ilDB->quote($a_mob_id, 
"integer").
" ".
 
  316                         "AND purpose = ".$ilDB->quote($a_purpose, 
"text");
 
  317                 $set = $ilDB->query(
$query);
 
  318                 if ($rec = $ilDB->fetchAssoc($set))
 
  320                         return $rec[
"location"];
 
  336                 $query = 
"SELECT * FROM media_item WHERE id = ".
 
  337                         $ilDB->quote($a_med_id, 
"integer");
 
  338                 $set = $ilDB->query(
$query);
 
  339                 if ($rec = $ilDB->fetchAssoc($set))
 
  341                         return $rec[
"mob_id"];
 
  358                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
  359                         $ilDB->quote($a_mobId, 
"integer").
" ".
 
  360                         "AND purpose=" . $ilDB->quote($a_purpose, 
"text").
" ORDER BY nr";
 
  361                 $item_set = $ilDB->query(
$query);
 
  363                 while ($item_rec = $ilDB->fetchAssoc($item_set))
 
  380                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
  381                         $ilDB->quote($a_mob->getId(), 
"integer").
" ".
 
  383                 $item_set = $ilDB->query(
$query);
 
  384                 while ($item_rec = $ilDB->fetchAssoc($item_set))
 
  387                         $media_item->setNr($item_rec[
"nr"]);
 
  388                         $media_item->setId($item_rec[
"id"]);
 
  389                         $media_item->setLocation($item_rec[
"location"]);
 
  390                         $media_item->setLocationType($item_rec[
"location_type"]);
 
  391                         $media_item->setFormat($item_rec[
"format"]);
 
  392                         $media_item->setWidth($item_rec[
"width"]);
 
  393                         $media_item->setHeight($item_rec[
"height"]);
 
  394                         $media_item->setHAlign($item_rec[
"halign"]);
 
  395                         $media_item->setCaption($item_rec[
"caption"]);
 
  396                         $media_item->setPurpose($item_rec[
"purpose"]);
 
  397                         $media_item->setMobId($item_rec[
"mob_id"]);
 
  398                         $media_item->setThumbTried($item_rec[
"tried_thumb"]);
 
  399                         $media_item->setTextRepresentation($item_rec[
"text_representation"]);
 
  402                         $query = 
"SELECT * FROM mob_parameter WHERE med_item_id = ".
 
  403                                 $ilDB->quote($item_rec[
"id"], 
"integer");
 
  404                         $par_set = $ilDB->query(
$query);
 
  405                         while ($par_rec = $ilDB->fetchAssoc($par_set))
 
  407                                 $media_item->setParameter($par_rec[
"name"], $par_rec[
"value"]);
 
  412                         for ($i = 1; $i <= $max; $i++)
 
  414                                 $area =& 
new ilMapArea($media_item->getId(), $i);
 
  415                                 $media_item->addMapArea($area);
 
  419                         $a_mob->addMediaItem($media_item);
 
  431                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
  432                         $ilDB->quote($a_mob_id, 
"integer");
 
  433                 $item_set = $ilDB->query(
$query);
 
  434                 while ($item_rec = $ilDB->fetchAssoc($item_set))
 
  437                         $query = 
"DELETE FROM mob_parameter WHERE med_item_id = ".
 
  438                                 $ilDB->quote($item_rec[
"id"], 
"integer");
 
  439                         $ilDB->manipulate(
$query);
 
  442                         $query = 
"DELETE FROM map_area WHERE item_id = ".
 
  443                                 $ilDB->quote($item_rec[
"id"], 
"integer");
 
  444                         $ilDB->manipulate(
$query);
 
  448                 $query = 
"DELETE FROM media_item WHERE mob_id = ".
 
  449                         $ilDB->quote($a_mob_id, 
"integer");
 
  450                 $ilDB->manipulate(
$query);
 
  455                 $this->purpose = $a_purpose;
 
  465                 $this->location = $a_location;
 
  475                 $this->location_type = $a_type;
 
  485                 $this->format = $a_format;
 
  495                 $this->tried_thumb = $a_tried;
 
  500                 return $this->tried_thumb;
 
  518                                 $this->mapareas[$i-2] =& $this->mapareas[$i-1];
 
  519                                 $this->mapareas[$i-2]->setNr($i-1);
 
  522                 if($nr <= $this->map_cnt)
 
  524                         unset($this->mapareas[$this->map_cnt - 1]);
 
  534                 return $this->mapareas[
$nr-1];
 
  558                 $this->width = $a_width;
 
  574                 $this->height = $a_height;
 
  594                         $size = @getimagesize($loc);
 
  598                                 return array(
"width" => 
$size[0], 
"height" => 
$size[1]);
 
  610                 $this->caption = $a_caption;
 
  626                 $this->halign = $a_halign;
 
  646                 $this->parameters[$a_name] = $a_value;
 
  654                 $this->parameters = array();
 
  666                 if(is_array($par_arr))
 
  668                         foreach($par_arr as $par => $val)
 
  699                 return $this->parameters[$a_name];
 
  720                 if(!@is_dir($work_dir))
 
  733                 return $loc_arr[count($loc_arr) - 1];
 
  752                 $o_file = $file_arr[count($file_arr) - 1];
 
  753                 $file_arr = explode(
".", $o_file);
 
  754                 unset($file_arr[count($file_arr) - 1]);
 
  755                 $file = implode($file_arr, 
".");
 
  757                 if (!$a_reference_copy)
 
  788                 if (is_int(strpos($this->
getFormat(), 
"image")))
 
  799                                 if (is_file($thumb_file))
 
  803                                 if (is_file($thumb_file_small))
 
  805                                         unlink($thumb_file_small);
 
  811                                 if (is_file($med_file))
 
  818                         if ($a_size == 
"small")
 
  820                                 if (is_file($thumb_file_small))
 
  823                                                 $this->
getPurpose().
"_small.jpeg?dummy=".rand(1, 999999);
 
  828                                 if (is_file($thumb_file))
 
  831                                                 $this->
getPurpose().
".jpeg?dummy=".rand(1, 999999);
 
  861                                 if ($handle && $lcopy)
 
  863                                         while (!feof($handle))
 
  865                                                 $content = fread($handle, 4096);
 
  866                                                 fwrite($lcopy, $content);
 
  918                 for ($i=0; $i < count($this->mapareas); $i++)
 
  920                         if (    ((($i+1) == $a_area_nr) && !$a_exclude) ||
 
  921                                         ((($i+1) != $a_area_nr) && $a_exclude) ||
 
  925                                 $area =& $this->mapareas[$i];
 
  926                                 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2, 
true,
 
  962                 $area->setShape($a_shape);
 
  963                 $area->setCoords($a_coords);
 
  964                 $area->draw($this->
getMapWorkImage(), $this->color1, $this->color2, 
false,
 
  977                         header(
"Pragma: no-cache");
 
  978                         header(
"Expires: 0");
 
 1008                 if (imagecolorstotal($this->map_image) > 250)
 
 1010                         $this->color1 = imagecolorclosest($this->map_image, 0, 0, 0);
 
 1011                         $this->color2 = imagecolorclosest($this->map_image, 255, 255, 255);
 
 1015                         $this->color1 = imagecolorallocate($this->map_image, 0, 0, 0);
 
 1016                         $this->color2 = imagecolorallocate($this->map_image, 255, 255, 255);
 
 1043                 ImageDestroy($this->map_image);
 
 1063                 for ($i=0; $i < count($this->mapareas); $i++)
 
 1065                         $area =& $this->mapareas[$i];
 
 1066                         $xml .= 
"<MapArea Shape=\"".$area->getShape().
"\" Coords=\"".$area->getCoords().
"\">";
 
 1069                                 $target_frame = $area->getTargetFrame();
 
 1071                                 if ($area->getType() == 
"GlossaryItem" && $target_frame == 
"")
 
 1073                                         $target_frame = 
"Glossary";
 
 1076                                 $tf_str = ($target_frame == 
"")
 
 1078                                         : 
"TargetFrame=\"".$target_frame.
"\"";
 
 1080                                 $xml .= 
"<IntLink Target=\"".$area->getTarget($a_insert_inst, $a_inst).
"\" Type=\"".
 
 1081                                         $area->getType().
"\" $tf_str>";
 
 1082                                 $xml .= $area->getTitle();
 
 1083                                 $xml .=
"</IntLink>";
 
 1087                                 $xml .= 
"<ExtLink Href=\"".str_replace(
"&", 
"&",$area->getHref()).
"\" Title=\"".
 
 1088                                         $area->getExtTitle().
"\">";
 
 1089                                 $xml .= $area->getTitle();
 
 1090                                 $xml .=
"</ExtLink>";
 
 1092                         $xml .= 
"</MapArea>";
 
 1110                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
 1111                         $ilDB->quote($a_mob_id, 
"integer").
" ".
 
 1113                 $item_set = $ilDB->query(
$query);
 
 1114                 while ($item_rec = $ilDB->fetchAssoc($item_set))
 
 1130                 $query = 
"SELECT * FROM media_item WHERE mob_id = ".
 
 1131                         $ilDB->quote($a_mob_id, 
"integer").
" ORDER BY nr";
 
 1133                 $item_set = $ilDB->query(
$query);
 
 1135                 while ($item_rec = $ilDB->fetchAssoc($item_set))
 
 1138                         foreach($map_links as $key => $map_link)
 
 1140                                 $links[$key] = $map_link;
 
 1151                 include_once(
"./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
 
 1154                 foreach ($par as $k => $v)