24 define (
"IL_MODE_ALIAS", 1);
25 define (
"IL_MODE_OUTPUT", 2);
26 define (
"IL_MODE_FULL", 3);
28 require_once(
"./Services/MediaObjects/classes/class.ilMediaItem.php");
29 include_once
"classes/class.ilObject.php";
60 $this->is_alias =
false;
61 $this->media_items = array();
62 $this->contains_int_link =
false;
69 $this->ilias->raiseError(
"Operation ilObjMedia::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
74 $this->ilias->raiseError(
"Operation ilObjMedia::getRefId() not allowed.",$this->ilias->error_obj->FATAL);
79 $this->ilias->raiseError(
"Operation ilObjMedia::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
84 $this->ilias->raiseError(
"Operation ilObjMedia::createReference() not allowed.",$this->ilias->error_obj->FATAL);
108 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
109 if (is_int(strpos($a_id,
"_")))
122 if (!($this->
getId() > 0))
129 if (count($usages) == 0)
179 include_once
'Services/MetaData/classes/class.ilMD.php';
187 $md_gen = $md->getGeneral();
189 if (is_object($md_gen))
192 $this->
setTitle($md_gen->getTitle());
194 foreach($md_gen->getDescriptionIds() as
$id)
196 $md_des = $md_gen->getDescription(
$id);
215 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
220 $md_creator->setTitle($this->
getTitle());
221 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
223 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
224 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
225 $md_creator->setLanguage($ilUser->getPref(
'language'));
226 $md_creator->create();
236 include_once(
"Services/MetaData/classes/class.ilMD.php");
237 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
238 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
241 $md_gen =& $md->getGeneral();
242 $md_gen->setTitle($this->
getTitle());
245 $md_des_ids =& $md_gen->getDescriptionIds();
246 if (count($md_des_ids) > 0)
248 $md_des =& $md_gen->getDescription($md_des_ids[0]);
262 include_once(
'Services/MetaData/classes/class.ilMD.php');
275 $this->media_items[] =& $a_item;
297 foreach ($this->media_items as $media_item)
299 if($media_item->getPurpose() == $a_purpose)
313 foreach ($this->media_items as $key => $media_item)
315 if($media_item->getPurpose() == $a_purpose)
317 unset($this->media_items[$key]);
323 foreach ($this->media_items as $media_item)
326 $media_item->setMobId($this->
getId());
327 $media_item->setNr($i);
338 $this->media_items = array();
344 for($i=0; $i<count($this->media_items); $i++)
346 if($this->media_items[$i]->getPurpose() == $a_purpose)
410 $this->is_alias = $a_is_alias;
420 return $this->origin_id = $a_id;
445 $this->import_id = $a_id;
451 function create($a_upload =
false, $a_save_media_items =
true)
460 if ($a_save_media_items)
466 $item->setMobId($this->
getId());
491 if (is_object($item))
493 $item->setMobId($this->
getId());
495 if ($item->getLocationType() ==
"Reference")
497 $item->extractUrlParameters();
552 $a_web =
true, $a_purpose =
"")
554 if ($a_purpose ==
"")
556 $a_purpose =
"Standard";
569 return $path.
"/data/".CLIENT_ID.
"/mobs/mm_".$a_mob_id.
"/".
$location;
600 $xml =
"<MediaObject>";
601 $xml .=
"<MediaAlias OriginId=\"il__mob_".$this->getId().
"\"/>";
606 $xml .=
"<MediaAliasItem Purpose=\"".$item->getPurpose().
"\">";
609 $width = ($item->getWidth() !=
"")
610 ?
"Width=\"".$item->getWidth().
"\""
612 $height = ($item->getHeight() !=
"")
613 ?
"Height=\"".$item->getHeight().
"\""
615 $halign = ($item->getHAlign() !=
"")
616 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
618 $xml .=
"<Layout $width $height $halign />";
621 if ($item->getCaption() !=
"")
623 $xml .=
"<Caption Align=\"bottom\">".
624 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
628 $parameters = $item->getParameters();
629 foreach ($parameters as $name => $value)
631 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
633 $xml .=
"</MediaAliasItem>";
642 $xml =
"<MediaObject Id=\"il__mob_".$this->getId().
"\">";
648 $xml .=
"<MediaItem Purpose=\"".$item->getPurpose().
"\">";
651 $xml.=
"<Location Type=\"".$item->getLocationType().
"\">".
652 $this->
handleAmps($item->getLocation()).
"</Location>";
655 $xml.=
"<Format>".$item->getFormat().
"</Format>";
658 $width = ($item->getWidth() !=
"")
659 ?
"Width=\"".$item->getWidth().
"\""
661 $height = ($item->getHeight() !=
"")
662 ?
"Height=\"".$item->getHeight().
"\""
664 $halign = ($item->getHAlign() !=
"")
665 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
667 $xml .=
"<Layout $width $height $halign />";
670 if ($item->getCaption() !=
"")
672 $xml .=
"<Caption Align=\"bottom\">".
673 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
677 $parameters = $item->getParameters();
678 foreach ($parameters as $name => $value)
680 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
682 $xml .= $item->getMapAreasXML();
683 $xml .=
"</MediaItem>";
691 $xml =
"<MediaObject>";
694 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
696 $md2xml->setExportMode(
true);
697 $md2xml->startExport();
698 $xml.= $md2xml->getXML();
704 $xml .=
"<MediaItem Purpose=\"".$item->getPurpose().
"\">";
707 $xml.=
"<Location Type=\"".$item->getLocationType().
"\">".
708 $this->
handleAmps($item->getLocation()).
"</Location>";
711 $xml.=
"<Format>".$item->getFormat().
"</Format>";
714 $width = ($item->getWidth() !=
"")
715 ?
"Width=\"".$item->getWidth().
"\""
717 $height = ($item->getHeight() !=
"")
718 ?
"Height=\"".$item->getHeight().
"\""
720 $halign = ($item->getHAlign() !=
"")
721 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
723 $xml .=
"<Layout $width $height $halign />";
726 if ($item->getCaption() !=
"")
728 $xml .=
"<Caption Align=\"bottom\">".
729 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
733 $parameters = $item->getParameters();
734 foreach ($parameters as $name => $value)
736 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
738 $xml .= $item->getMapAreasXML(
true, $a_inst);
739 $xml .=
"</MediaItem>";
743 $xml .=
"</MediaObject>";
752 $a_str = str_replace(
"&",
"&", $a_str);
753 $a_str = str_replace(
"&",
"&", $a_str);
775 $subdir =
"il_".IL_INST_ID.
"_mob_".$this->
getId();
786 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
807 $this->contains_int_link = $a_contains_link;
826 $q =
"DELETE FROM mob_usage WHERE usage_type = ".
827 $ilDB->quote($a_type).
" AND usage_id= ".$ilDB->quote($a_id).
828 " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr);
839 $q =
"SELECT * FROM mob_usage WHERE ".
840 "usage_type = ".$ilDB->quote($a_type).
" AND ".
841 "usage_id = ".$ilDB->quote($a_id).
" AND ".
842 "usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr);
844 $mob_set = $ilDB->query($q);
849 $mobs[$mob_rec[
"id"]] = $mob_rec[
"id"];
859 function _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0)
863 $q =
"REPLACE INTO mob_usage (id, usage_type, usage_id, usage_hist_nr) VALUES".
864 " (".$ilDB->quote($a_mob_id).
",".
865 $ilDB->quote($a_type).
",".$ilDB->quote($a_id).
",".
866 $ilDB->quote($a_usage_hist_nr).
")";
877 $q =
"DELETE FROM mob_usage WHERE ".
878 " id = ".$ilDB->quote($a_mob_id).
" AND ".
879 " usage_type = ".$ilDB->quote($a_type).
" AND ".
880 " usage_id = ".$ilDB->quote($a_id).
" AND ".
881 " usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr);
903 $q =
"SELECT * FROM mob_usage WHERE id = ".
905 $us_set = $ilDB->query($q);
909 $ret[] = array(
"type" => $us_rec[
"usage_type"],
910 "id" => $us_rec[
"usage_id"],
911 "hist_nr" => $us_rec[
"usage_hist_nr"]);
915 $q =
"SELECT DISTINCT mep_id FROM mep_tree WHERE child = ".
917 $us_set = $ilDB->query($q);
920 $ret[] = array(
"type" =>
"mep",
921 "id" => $us_rec[
"mep_id"]);
925 include_once(
"./Services/News/classes/class.ilNewsItem.php");
927 foreach($news_usages as $nu)
934 $q =
"SELECT DISTINCT mob_id FROM media_item as it, map_area as area ".
935 " WHERE area.item_id = it.id ".
936 " AND area.link_type='int' ".
937 " AND area.target = ".$ilDB->quote(
"il__mob_".$a_id);
938 $us_set = $ilDB->query($q);
941 $ret[] = array(
"type" =>
"map",
942 "id" => $us_rec[
"mob_id"]);
947 foreach ($users as
$user)
949 $ret[] = array(
"type" =>
"clip",
961 if(is_int(strpos($a_usage[
"type"],
":")))
963 $us_arr = explode(
":", $a_usage[
"type"]);
965 $cont_type = $us_arr[0];
969 $type = $a_usage[
"type"];
972 $id = $a_usage[
"id"];
978 if ($cont_type ==
"cat")
983 if ($cont_type ==
"tst")
989 if ($cont_type ==
"qpl")
991 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
993 if ($qinfo[
"original_id"] > 0)
995 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1000 $obj_id = $qinfo[
"obj_fi"];
1008 if ($cont_type ==
"qpl")
1010 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1012 if ($qinfo[
"original_id"] > 0)
1014 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1019 $obj_id = $qinfo[
"obj_fi"];
1024 if ($cont_type ==
"lm" || $cont_type ==
"dbk")
1026 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1031 if ($cont_type ==
"gdf")
1033 include_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1034 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1048 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1065 $file_path = pathinfo($a_file);
1066 $location = substr($file_path[
"basename"],0,strlen($file_path[
"basename"]) -
1067 strlen($file_path[
"extension"]) - 1).
"_".
1069 $a_height.
".".$file_path[
"extension"];
1070 $target_file = $file_path[
"dirname"].
"/".
1073 (
int) $a_width, (
int) $a_height);
1087 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1126 $types_map = array (
1127 '.a' =>
'application/octet-stream',
1128 '.ai' =>
'application/postscript',
1129 '.aif' =>
'audio/x-aiff',
1130 '.aifc' =>
'audio/x-aiff',
1131 '.aiff' =>
'audio/x-aiff',
1132 '.asd' =>
'application/astound',
1133 '.asf' =>
'video/x-ms-asf',
1134 '.asn' =>
'application/astound',
1135 '.asx' =>
'video/x-ms-asf',
1136 '.au' =>
'audio/basic',
1137 '.avi' =>
'video/x-msvideo',
1138 '.bat' =>
'text/plain',
1139 '.bcpio' =>
'application/x-bcpio',
1140 '.bin' =>
'application/octet-stream',
1141 '.bmp' =>
'image/x-ms-bmp',
1142 '.c' =>
'text/plain',
1143 '.cdf' =>
'application/x-cdf',
1144 '.class' =>
'application/x-java-applet',
1145 '.com' =>
'application/octet-stream',
1146 '.cpio' =>
'application/x-cpio',
1147 '.csh' =>
'application/x-csh',
1148 '.css' =>
'text/css',
1149 '.csv' =>
'text/comma-separated-values',
1150 '.dcr' =>
'application/x-director',
1151 '.dir' =>
'application/x-director',
1152 '.dll' =>
'application/octet-stream',
1153 '.doc' =>
'application/msword',
1154 '.dot' =>
'application/msword',
1155 '.dvi' =>
'application/x-dvi',
1156 '.dwg' =>
'application/acad',
1157 '.dxf' =>
'application/dxf',
1158 '.dxr' =>
'application/x-director',
1159 '.eml' =>
'message/rfc822',
1160 '.eps' =>
'application/postscript',
1161 '.etx' =>
'text/x-setext',
1162 '.exe' =>
'application/octet-stream',
1163 '.flv' =>
'video/x-flv',
1164 '.gif' =>
'image/gif',
1165 '.gtar' =>
'application/x-gtar',
1166 '.gz' =>
'application/gzip',
1167 '.h' =>
'text/plain',
1168 '.hdf' =>
'application/x-hdf',
1169 '.htm' =>
'text/html',
1170 '.html' =>
'text/html',
1171 '.ief' =>
'image/ief',
1172 '.iff' =>
'image/iff',
1173 '.jar' =>
'application/x-java-applet',
1174 '.jpe' =>
'image/jpeg',
1175 '.jpeg' =>
'image/jpeg',
1176 '.jpg' =>
'image/jpeg',
1177 '.js' =>
'application/x-javascript',
1178 '.ksh' =>
'text/plain',
1179 '.latex' =>
'application/x-latex',
1180 '.m1v' =>
'video/mpeg',
1181 '.man' =>
'application/x-troff-man',
1182 '.me' =>
'application/x-troff-me',
1183 '.mht' =>
'message/rfc822',
1184 '.mhtml' =>
'message/rfc822',
1185 '.mid' =>
'audio/x-midi',
1186 '.midi' =>
'audio/x-midi',
1187 '.mif' =>
'application/x-mif',
1188 '.mov' =>
'video/quicktime',
1189 '.movie' =>
'video/x-sgi-movie',
1190 '.mp2' =>
'audio/mpeg',
1191 '.mp3' =>
'audio/mpeg',
1192 '.mpa' =>
'video/mpeg',
1193 '.mpe' =>
'video/mpeg',
1194 '.mpeg' =>
'video/mpeg',
1195 '.mpg' =>
'video/mpeg',
1196 '.mp4' =>
'video/mp4',
1197 '.mv4' =>
'video/mp4',
1198 '.ms' =>
'application/x-troff-ms',
1199 '.nc' =>
'application/x-netcdf',
1200 '.nws' =>
'message/rfc822',
1201 '.o' =>
'application/octet-stream',
1202 '.ogg' =>
'application/ogg',
1203 '.obj' =>
'application/octet-stream',
1204 '.oda' =>
'application/oda',
1205 '.p12' =>
'application/x-pkcs12',
1206 '.p7c' =>
'application/pkcs7-mime',
1207 '.pbm' =>
'image/x-portable-bitmap',
1208 '.pdf' =>
'application/pdf',
1209 '.pfx' =>
'application/x-pkcs12',
1210 '.pgm' =>
'image/x-portable-graymap',
1211 '.php' =>
'application/x-httpd-php',
1212 '.phtml' =>
'application/x-httpd-php',
1213 '.pl' =>
'text/plain',
1214 '.png' =>
'image/png',
1215 '.pnm' =>
'image/x-portable-anymap',
1216 '.pot' =>
'application/vnd.ms-powerpoint',
1217 '.ppa' =>
'application/vnd.ms-powerpoint',
1218 '.ppm' =>
'image/x-portable-pixmap',
1219 '.pps' =>
'application/vnd.ms-powerpoint',
1220 '.ppt' =>
'application/vnd.ms-powerpoint',
1221 '.ps' =>
'application/postscript',
1222 '.psd' =>
'image/psd',
1223 '.pwz' =>
'application/vnd.ms-powerpoint',
1224 '.py' =>
'text/x-python',
1225 '.pyc' =>
'application/x-python-code',
1226 '.pyo' =>
'application/x-python-code',
1227 '.qt' =>
'video/quicktime',
1228 '.ra' =>
'audio/x-pn-realaudio',
1229 '.ram' =>
'application/x-pn-realaudio',
1230 '.ras' =>
'image/x-cmu-raster',
1231 '.rdf' =>
'application/xml',
1232 '.rgb' =>
'image/x-rgb',
1233 '.roff' =>
'application/x-troff',
1234 '.rpm' =>
'audio/x-pn-realaudio-plugin',
1235 '.rtf' =>
'application/rtf',
1236 '.rtx' =>
'text/richtext',
1237 '.sgm' =>
'text/x-sgml',
1238 '.sgml' =>
'text/x-sgml',
1239 '.sh' =>
'application/x-sh',
1240 '.shar' =>
'application/x-shar',
1241 '.sit' =>
'application/x-stuffit',
1242 '.snd' =>
'audio/basic',
1243 '.so' =>
'application/octet-stream',
1244 '.spc' =>
'text/x-speech',
1245 '.src' =>
'application/x-wais-source',
1246 '.sv4cpio'=>
'application/x-sv4cpio',
1247 '.sv4crc' =>
'application/x-sv4crc',
1248 '.svg' =>
'image/svg+xml',
1249 '.swf' =>
'application/x-shockwave-flash',
1250 '.t' =>
'application/x-troff',
1251 '.tar' =>
'application/x-tar',
1252 '.talk' =>
'text/x-speech',
1253 '.tbk' =>
'application/toolbook',
1254 '.tcl' =>
'application/x-tcl',
1255 '.tex' =>
'application/x-tex',
1256 '.texi' =>
'application/x-texinfo',
1257 '.texinfo'=>
'application/x-texinfo',
1258 '.tif' =>
'image/tiff',
1259 '.tiff' =>
'image/tiff',
1260 '.tr' =>
'application/x-troff',
1261 '.tsv' =>
'text/tab-separated-values',
1262 '.tsp' =>
'application/dsptype',
1263 '.txt' =>
'text/plain',
1264 '.ustar' =>
'application',
1265 '.vcf' =>
'text/x-vcard',
1266 '.vox' =>
'audio/voxware',
1267 '.wav' =>
'audio/x-wav',
1268 '.wax' =>
'audio/x-ms-wax',
1269 '.wiz' =>
'application/msword',
1270 '.wm' =>
'video/x-ms-wm',
1271 '.wma' =>
'audio/x-ms-wma',
1272 '.wmd' =>
'video/x-ms-wmd',
1273 '.wml' =>
'text/vnd.wap.wml',
1274 '.wmlc' =>
'application/vnd.wap.wmlc',
1275 '.wmls' =>
'text/vnd.wap.wmlscript',
1276 '.wmlsc' =>
'application/vnd.wap.wmlscriptc',
1277 '.wmv' =>
'video/x-ms-wmv',
1278 '.wmx' =>
'video/x-ms-wmx',
1279 '.wmz' =>
'video/x-ms-wmz',
1280 '.wvx' =>
'video/x-ms-wvx',
1281 '.wrl' =>
'x-world/x-vrml',
1282 '.xbm' =>
'image/x-xbitmap',
1283 '.xla' =>
'application/msexcel',
1284 '.xlb' =>
'application/vnd.ms-excel',
1285 '.xls' =>
'application/msexcel',
1286 '.xml' =>
'text/xml',
1287 '.xpm' =>
'image/x-xpixmap',
1288 '.xsl' =>
'application/xml',
1289 '.xwd' =>
'image/x-xwindowdump',
1290 '.zip' =>
'application/zip');
1307 $media_object->setTitle($name);
1308 $media_object->setDescription(
"");
1309 $media_object->create();
1312 $media_object->createDirectory();
1316 $media_object->addMediaItem($media_item);
1317 $media_item->setPurpose(
"Standard");
1319 $file = $mob_dir.
"/".$name;
1326 copy($tmp_name,
$file);
1332 $media_item->setFormat($format);
1334 $media_item->setLocationType(
"LocalFile");
1335 $media_object->setTitle($name);
1336 $media_object->setDescription($format);
1341 $media_item->setWidth(
$size[0]);
1342 $media_item->setHeight(
$size[1]);
1344 $media_item->setHAlign(
"Left");
1347 $media_object->update();
1349 return $media_object;
1359 if (!is_array($a_ignore))
1361 $a_ignore = array();
1367 foreach($med_items as $med_item)
1370 foreach ($int_links as $k => $int_link)
1372 if ($int_link[
"Type"] ==
"MediaObject")
1374 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
1378 if (!in_array($l_id, $linked) &&
1379 !in_array($l_id, $a_ignore))